1 /* 2 * This file is part of the Colobot: Gold Edition source code 3 * Copyright (C) 2001-2020, Daniel Roux, EPSITEC SA & TerranovaTeam 4 * http://epsitec.ch; http://colobot.info; http://github.com/colobot 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 * See the GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see http://gnu.org/licenses 18 */ 19 20 /** 21 * \file app/pausemanager.h 22 * \brief Management of pause modes 23 */ 24 #pragma once 25 26 #include "common/make_unique.h" 27 28 #include <string> 29 #include <vector> 30 #include <memory> 31 32 class CRobotMain; 33 34 35 enum PauseType 36 { 37 PAUSE_NONE = 0, 38 PAUSE_ENGINE = (1<<0), //!< pause all the CEngine classes 39 PAUSE_HIDE_SHORTCUTS = (1<<1), //!< hide the shortcuts 40 PAUSE_PHOTO = (1<<2), //!< photo mode, TODO: remove 41 PAUSE_OBJECT_UPDATES = (1<<3), //!< do not send events to objects 42 PAUSE_MUTE_SOUND = (1<<4), //!< mute sound 43 PAUSE_CAMERA = (1<<5), //!< freeze camera 44 }; 45 inline PauseType& operator|=(PauseType& a, const PauseType& b) 46 { 47 return a = static_cast<PauseType>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b)); 48 } 49 inline PauseType operator|(PauseType a, const PauseType& b) 50 { 51 return a |= b; 52 } 53 inline PauseType& operator&=(PauseType& a, const PauseType& b) 54 { 55 return a = static_cast<PauseType>(static_cast<unsigned int>(a) & static_cast<unsigned int>(b)); 56 } 57 inline PauseType operator&(PauseType a, const PauseType& b) 58 { 59 return a &= b; 60 } 61 62 enum PauseMusic 63 { 64 PAUSE_MUSIC_NONE = 0, 65 PAUSE_MUSIC_EDITOR = 1, 66 PAUSE_MUSIC_SATCOM = 2, 67 }; 68 69 struct ActivePause; 70 71 class CPauseManager 72 { 73 public: 74 CPauseManager(); 75 ~CPauseManager(); 76 77 ActivePause* ActivatePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE); 78 void DeactivatePause(ActivePause* pause); 79 80 void FlushPause(); 81 82 PauseType GetPause(); 83 bool IsPauseType(PauseType type); 84 85 private: 86 //static std::string GetPauseName(PauseType pause); 87 void Update(); 88 89 private: 90 CRobotMain* m_main; 91 92 std::vector<std::unique_ptr<ActivePause>> m_activePause; 93 PauseMusic m_lastPauseMusic = PAUSE_MUSIC_NONE; 94 }; 95