colobot/src/app/pausemanager.h

107 lines
2.7 KiB
C
Raw Normal View History

/*
* This file is part of the Colobot: Gold Edition source code
2015-08-22 14:40:02 +00:00
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
2013-12-31 11:58:45 +00:00
/**
* \file app/pausemanager.h
* \brief Management of pause modes
*/
#pragma once
#include <string>
2015-08-31 19:47:55 +00:00
#include <vector>
#include <memory>
2013-12-31 11:58:45 +00:00
2015-10-01 16:55:41 +00:00
class CRobotMain;
2013-12-31 11:58:45 +00:00
2015-08-02 09:40:47 +00:00
enum PauseType
{
2013-12-31 11:58:45 +00:00
PAUSE_NONE = 0,
2015-10-01 16:55:41 +00:00
PAUSE_ENGINE = (1<<0), //!< pause all the CEngine classes
PAUSE_HIDE_SHORTCUTS = (1<<1), //!< hide the shortcuts
PAUSE_PHOTO = (1<<2), //!< photo mode, TODO: remove
PAUSE_OBJECT_UPDATES = (1<<3), //!< do not send events to objects
PAUSE_MUTE_SOUND = (1<<4), //!< mute sound
};
inline PauseType& operator|=(PauseType& a, const PauseType& b)
{
return a = static_cast<PauseType>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b));
}
inline PauseType operator|(PauseType a, const PauseType& b)
{
return a |= b;
}
inline PauseType& operator&=(PauseType& a, const PauseType& b)
{
return a = static_cast<PauseType>(static_cast<unsigned int>(a) & static_cast<unsigned int>(b));
}
inline PauseType operator&(PauseType a, const PauseType& b)
{
return a &= b;
}
enum PauseMusic
{
PAUSE_MUSIC_NONE = 0,
PAUSE_MUSIC_EDITOR = 1,
PAUSE_MUSIC_SATCOM = 2,
2013-12-31 11:58:45 +00:00
};
2015-08-31 19:47:55 +00:00
struct ActivePause
{
private:
friend class CPauseManager;
2015-10-01 16:55:41 +00:00
explicit ActivePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE)
2015-08-31 19:47:55 +00:00
: type(type)
2015-10-01 16:55:41 +00:00
, music(music)
2015-08-31 19:47:55 +00:00
{}
ActivePause(const ActivePause&) = delete;
ActivePause& operator=(const ActivePause&) = delete;
PauseType type;
2015-10-01 16:55:41 +00:00
PauseMusic music;
2015-08-31 19:47:55 +00:00
};
2015-08-31 20:05:21 +00:00
class CPauseManager
2013-12-31 11:58:45 +00:00
{
public:
CPauseManager();
~CPauseManager();
2015-07-22 16:01:24 +00:00
2015-10-01 16:55:41 +00:00
ActivePause* ActivatePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE);
2015-08-31 19:47:55 +00:00
void DeactivatePause(ActivePause* pause);
2015-07-22 16:01:24 +00:00
2015-08-31 19:47:55 +00:00
void FlushPause();
2015-10-01 16:55:41 +00:00
PauseType GetPause();
bool IsPauseType(PauseType type);
2015-07-22 16:01:24 +00:00
private:
2015-10-01 16:55:41 +00:00
//static std::string GetPauseName(PauseType pause);
void Update();
2015-07-22 16:01:24 +00:00
2015-08-31 19:47:55 +00:00
private:
2015-10-01 16:55:41 +00:00
CRobotMain* m_main;
2015-08-31 19:47:55 +00:00
std::vector<std::unique_ptr<ActivePause>> m_activePause;
2015-10-01 16:55:41 +00:00
PauseMusic m_lastPauseMusic = PAUSE_MUSIC_NONE;
2013-12-31 11:58:45 +00:00
};