Refactored CPauseManager (again)

dev-time-step
krzys-h 2015-10-01 18:55:41 +02:00
parent 58035f3cd1
commit 3815ef0bd6
10 changed files with 150 additions and 137 deletions

View File

@ -29,31 +29,32 @@
CPauseManager::CPauseManager() CPauseManager::CPauseManager()
{} {
m_main = CRobotMain::GetInstancePointer();
}
CPauseManager::~CPauseManager() CPauseManager::~CPauseManager()
{} {}
ActivePause* CPauseManager::ActivatePause(PauseType type) ActivePause* CPauseManager::ActivatePause(PauseType type, PauseMusic music)
{ {
assert(type != PAUSE_NONE); //GetLogger()->Debug("Activated pause mode - %s\n", GetPauseName(type).c_str());
GetLogger()->Debug("Activated pause mode - %s\n", GetPauseName(type).c_str()); auto pause = std::unique_ptr<ActivePause>(new ActivePause(type, music)); // TODO: Can't use MakeUnique here because the constructor is private
auto pause = std::unique_ptr<ActivePause>(new ActivePause(type)); // TODO: Can't use MakeUnique here because the constructor is private
ActivePause* ptr = pause.get(); ActivePause* ptr = pause.get();
m_activePause.push_back(std::move(pause)); m_activePause.push_back(std::move(pause));
UpdatePause(); Update();
return ptr; return ptr;
} }
void CPauseManager::DeactivatePause(ActivePause* pause) void CPauseManager::DeactivatePause(ActivePause* pause)
{ {
if (pause == nullptr) return; if (pause == nullptr) return;
GetLogger()->Debug("Deactivated pause mode - %s\n", GetPauseName(pause->type).c_str()); //GetLogger()->Debug("Deactivated pause mode - %s\n", GetPauseName(pause->type).c_str());
m_activePause.erase(std::remove_if( m_activePause.erase(std::remove_if(
m_activePause.begin(), m_activePause.end(), m_activePause.begin(), m_activePause.end(),
[&](const std::unique_ptr<ActivePause>& x) { return x.get() == pause; }) [&](const std::unique_ptr<ActivePause>& x) { return x.get() == pause; })
); );
UpdatePause(); Update();
} }
void CPauseManager::FlushPause() void CPauseManager::FlushPause()
@ -61,49 +62,38 @@ void CPauseManager::FlushPause()
m_activePause.clear(); m_activePause.clear();
} }
bool CPauseManager::IsPause() PauseType CPauseManager::GetPause()
{ {
return m_activePause.size() > 0; PauseType current = PAUSE_NONE;
} for(auto& pause : m_activePause)
PauseType CPauseManager::GetPauseType()
{
if (m_activePause.size() > 0)
return m_activePause[m_activePause.size()-1]->type;
return PAUSE_NONE;
}
void CPauseManager::UpdatePause()
{
PauseType type = GetPauseType();
if (type != PAUSE_NONE)
{ {
GetLogger()->Info("Game paused - %s\n", GetPauseName(type).c_str()); current |= pause->type;
} }
else return current;
{
GetLogger()->Info("Game resumed\n");
}
CRobotMain::GetInstancePointer()->UpdatePause(type);
} }
std::string CPauseManager::GetPauseName(PauseType pause) bool CPauseManager::IsPauseType(PauseType type)
{ {
switch(pause) PauseType current = GetPause();
{ return (current & type) == type;
case PAUSE_NONE: return "None"; }
case PAUSE_USER: return "User";
case PAUSE_SATCOM: return "SatCom"; void CPauseManager::Update()
case PAUSE_SATCOMMOVIE: return "SatCom opening animation"; {
case PAUSE_DIALOG: return "Dialog"; m_main->UpdatePause(GetPause()); //TODO
case PAUSE_EDITOR: return "CBot editor";
case PAUSE_VISIT: return "Visit"; PauseMusic music = PAUSE_MUSIC_NONE;
case PAUSE_CHEAT: return "Cheat console"; for(int i = m_activePause.size()-1; i >= 0; i--)
case PAUSE_PHOTO: return "Photo mode"; {
case PAUSE_CODE_BATTLE_LOCK: return "Code battle lock"; if (m_activePause[i]->music != PAUSE_MUSIC_NONE)
default: assert(false); // Should never happen {
} music = m_activePause[i]->music;
return "?"; break;
}
}
if (music != m_lastPauseMusic)
{
m_main->UpdatePauseMusic(music);
m_lastPauseMusic = music;
}
} }

View File

@ -27,19 +27,40 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
class CRobotMain;
enum PauseType enum PauseType
{ {
PAUSE_NONE = 0, PAUSE_NONE = 0,
PAUSE_USER, PAUSE_ENGINE = (1<<0), //!< pause all the CEngine classes
PAUSE_SATCOM, PAUSE_HIDE_SHORTCUTS = (1<<1), //!< hide the shortcuts
PAUSE_SATCOMMOVIE, PAUSE_PHOTO = (1<<2), //!< photo mode, TODO: remove
PAUSE_DIALOG, PAUSE_OBJECT_UPDATES = (1<<3), //!< do not send events to objects
PAUSE_EDITOR, PAUSE_MUTE_SOUND = (1<<4), //!< mute sound
PAUSE_VISIT, };
PAUSE_CHEAT, inline PauseType& operator|=(PauseType& a, const PauseType& b)
PAUSE_PHOTO, {
PAUSE_CODE_BATTLE_LOCK 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,
}; };
struct ActivePause struct ActivePause
@ -47,14 +68,16 @@ struct ActivePause
private: private:
friend class CPauseManager; friend class CPauseManager;
explicit ActivePause(PauseType type) explicit ActivePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE)
: type(type) : type(type)
, music(music)
{} {}
ActivePause(const ActivePause&) = delete; ActivePause(const ActivePause&) = delete;
ActivePause& operator=(const ActivePause&) = delete; ActivePause& operator=(const ActivePause&) = delete;
PauseType type; PauseType type;
PauseMusic music;
}; };
class CPauseManager class CPauseManager
@ -63,19 +86,21 @@ public:
CPauseManager(); CPauseManager();
~CPauseManager(); ~CPauseManager();
ActivePause* ActivatePause(PauseType type); ActivePause* ActivatePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE);
void DeactivatePause(ActivePause* pause); void DeactivatePause(ActivePause* pause);
void FlushPause(); void FlushPause();
bool IsPause(); PauseType GetPause();
PauseType GetPauseType(); bool IsPauseType(PauseType type);
private: private:
void UpdatePause(); //static std::string GetPauseName(PauseType pause);
void Update();
static std::string GetPauseName(PauseType pause);
private: private:
CRobotMain* m_main;
std::vector<std::unique_ptr<ActivePause>> m_activePause; std::vector<std::unique_ptr<ActivePause>> m_activePause;
PauseMusic m_lastPauseMusic = PAUSE_MUSIC_NONE;
}; };

View File

@ -22,7 +22,6 @@
#include "app/app.h" #include "app/app.h"
#include "app/input.h" #include "app/input.h"
#include "app/pausemanager.h"
#include "app/system.h" #include "app/system.h"
#include "common/image.h" #include "common/image.h"
@ -89,7 +88,6 @@ CEngine::CEngine(CApplication *app, CSystemUtils* systemUtils)
m_planet = nullptr; m_planet = nullptr;
m_sound = nullptr; m_sound = nullptr;
m_terrain = nullptr; m_terrain = nullptr;
m_pause = nullptr;
m_showStats = false; m_showStats = false;
@ -272,11 +270,6 @@ CCloud* CEngine::GetCloud()
return m_cloud.get(); return m_cloud.get();
} }
CPauseManager* CEngine::GetPauseManager()
{
return m_pause.get();
}
void CEngine::SetTerrain(CTerrain* terrain) void CEngine::SetTerrain(CTerrain* terrain)
{ {
m_terrain = terrain; m_terrain = terrain;
@ -303,7 +296,6 @@ bool CEngine::Create()
m_cloud = MakeUnique<CCloud>(this); m_cloud = MakeUnique<CCloud>(this);
m_lightning = MakeUnique<CLightning>(this); m_lightning = MakeUnique<CLightning>(this);
m_planet = MakeUnique<CPlanet>(this); m_planet = MakeUnique<CPlanet>(this);
m_pause = MakeUnique<CPauseManager>();
m_lightMan->SetDevice(m_device); m_lightMan->SetDevice(m_device);
m_particle->SetDevice(m_device); m_particle->SetDevice(m_device);
@ -353,7 +345,6 @@ void CEngine::Destroy()
m_shadowMap = Texture(); m_shadowMap = Texture();
} }
m_pause.reset();
m_lightMan.reset(); m_lightMan.reset();
m_text.reset(); m_text.reset();
m_particle.reset(); m_particle.reset();
@ -491,9 +482,14 @@ void CEngine::WriteScreenShotThread(std::unique_ptr<WriteScreenShotData> data)
CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(Event(EVENT_WRITE_SCENE_FINISHED)); CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(Event(EVENT_WRITE_SCENE_FINISHED));
} }
void CEngine::SetPause(bool pause)
{
m_pause = pause;
}
bool CEngine::GetPause() bool CEngine::GetPause()
{ {
return m_pause->IsPause(); return m_pause;
} }
void CEngine::SetShowStats(bool show) void CEngine::SetShowStats(bool show)

View File

@ -645,8 +645,6 @@ public:
CPlanet* GetPlanet(); CPlanet* GetPlanet();
//! Returns the fog manager //! Returns the fog manager
CCloud* GetCloud(); CCloud* GetCloud();
//! Returns the pause manager
CPauseManager* GetPauseManager();
//! Sets the terrain object //! Sets the terrain object
void SetTerrain(CTerrain* terrain); void SetTerrain(CTerrain* terrain);
@ -676,8 +674,11 @@ public:
void WriteScreenShot(const std::string& fileName); void WriteScreenShot(const std::string& fileName);
//! Get pause mode //@{
TEST_VIRTUAL bool GetPause(); //! Management of animation pause mode
void SetPause(bool pause);
bool GetPause();
//@}
//@{ //@{
//! Management of displaying statistic information //! Management of displaying statistic information
@ -1287,7 +1288,6 @@ protected:
std::unique_ptr<CCloud> m_cloud; std::unique_ptr<CCloud> m_cloud;
std::unique_ptr<CLightning> m_lightning; std::unique_ptr<CLightning> m_lightning;
std::unique_ptr<CPlanet> m_planet; std::unique_ptr<CPlanet> m_planet;
std::unique_ptr<CPauseManager> m_pause;
std::unique_ptr<CPyroManager> m_pyroManager; std::unique_ptr<CPyroManager> m_pyroManager;
//! Last encountered error //! Last encountered error
@ -1465,6 +1465,9 @@ protected:
std::string m_timerText; std::string m_timerText;
std::unordered_map<std::string, int> m_staticMeshBaseObjects; std::unordered_map<std::string, int> m_staticMeshBaseObjects;
//! Pause the animation updates
bool m_pause = false;
}; };

View File

@ -135,11 +135,11 @@ CRobotMain::CRobotMain()
m_cloud = m_engine->GetCloud(); m_cloud = m_engine->GetCloud();
m_lightning = m_engine->GetLightning(); m_lightning = m_engine->GetLightning();
m_planet = m_engine->GetPlanet(); m_planet = m_engine->GetPlanet();
m_pause = m_engine->GetPauseManager();
m_input = CInput::GetInstancePointer(); m_input = CInput::GetInstancePointer();
m_modelManager = MakeUnique<Gfx::CModelManager>(); m_modelManager = MakeUnique<Gfx::CModelManager>();
m_settings = MakeUnique<CSettings>(); m_settings = MakeUnique<CSettings>();
m_pause = MakeUnique<CPauseManager>();
m_interface = MakeUnique<Ui::CInterface>(); m_interface = MakeUnique<Ui::CInterface>();
m_terrain = MakeUnique<Gfx::CTerrain>(); m_terrain = MakeUnique<Gfx::CTerrain>();
m_camera = MakeUnique<Gfx::CCamera>(); m_camera = MakeUnique<Gfx::CCamera>();
@ -193,7 +193,6 @@ CRobotMain::CRobotMain()
m_editLock = false; m_editLock = false;
m_editFull = false; m_editFull = false;
m_hilite = false; m_hilite = false;
m_freePhoto = false;
m_selectInsect = false; m_selectInsect = false;
m_showSoluce = false; m_showSoluce = false;
@ -294,6 +293,11 @@ Ui::CDisplayText* CRobotMain::GetDisplayText()
return m_displayText.get(); return m_displayText.get();
} }
CPauseManager* CRobotMain::GetPauseManager()
{
return m_pause.get();
}
void CRobotMain::ResetAfterVideoConfigChanged() void CRobotMain::ResetAfterVideoConfigChanged()
{ {
// Recreate the interface (needed if the aspect ratio changes) // Recreate the interface (needed if the aspect ratio changes)
@ -431,11 +435,12 @@ void CRobotMain::ChangePhase(Phase phase)
m_movieLock = false; m_movieLock = false;
m_satComLock = false; m_satComLock = false;
m_editLock = false; m_editLock = false;
m_freePhoto = false;
m_resetCreate = false; m_resetCreate = false;
m_infoObject = nullptr; m_infoObject = nullptr;
m_pause->FlushPause(); m_pause->FlushPause();
m_freePhotoPause = nullptr;
m_userPause = nullptr;
FlushDisplayInfo(); FlushDisplayInfo();
m_engine->SetRankView(0); m_engine->SetRankView(0);
m_terrain->FlushRelief(); m_terrain->FlushRelief();
@ -713,7 +718,7 @@ bool CRobotMain::ProcessEvent(Event &event)
if (pe == nullptr) return false; if (pe == nullptr) return false;
pe->SetState(Ui::STATE_VISIBLE); pe->SetState(Ui::STATE_VISIBLE);
m_interface->SetFocus(pe); m_interface->SetFocus(pe);
if (m_phase == PHASE_SIMUL) m_cmdEditPause = m_pause->ActivatePause(PAUSE_CHEAT); if (m_phase == PHASE_SIMUL) m_cmdEditPause = m_pause->ActivatePause(PAUSE_ENGINE);
m_cmdEdit = true; m_cmdEdit = true;
} }
return false; return false;
@ -847,9 +852,9 @@ bool CRobotMain::ProcessEvent(Event &event)
{ {
if (m_userPause == nullptr) if (m_userPause == nullptr)
{ {
if (!m_pause->IsPause()) if (!m_pause->IsPauseType(PAUSE_ENGINE))
{ {
m_userPause = m_pause->ActivatePause(PAUSE_USER); m_userPause = m_pause->ActivatePause(PAUSE_ENGINE);
} }
} }
else else
@ -1190,11 +1195,10 @@ void CRobotMain::ExecuteCmd(char *cmd)
if (strcmp(cmd, "photo1") == 0) if (strcmp(cmd, "photo1") == 0)
{ {
m_freePhoto = !m_freePhoto; if (m_freePhotoPause == nullptr)
if (m_freePhoto)
{ {
m_camera->SetType(Gfx::CAM_TYPE_FREE); m_camera->SetType(Gfx::CAM_TYPE_FREE);
m_freePhotoPause = m_pause->ActivatePause(PAUSE_PHOTO); m_freePhotoPause = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_PHOTO|PAUSE_OBJECT_UPDATES);
} }
else else
{ {
@ -1207,12 +1211,11 @@ void CRobotMain::ExecuteCmd(char *cmd)
if (strcmp(cmd, "photo2") == 0) if (strcmp(cmd, "photo2") == 0)
{ {
m_freePhoto = !m_freePhoto; if (m_freePhotoPause == nullptr)
if (m_freePhoto)
{ {
m_camera->SetType(Gfx::CAM_TYPE_FREE); m_camera->SetType(Gfx::CAM_TYPE_FREE);
DeselectAll(); // removes the control buttons DeselectAll(); // removes the control buttons
m_freePhotoPause = m_pause->ActivatePause(PAUSE_PHOTO); m_freePhotoPause = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_PHOTO|PAUSE_OBJECT_UPDATES);
m_map->ShowMap(false); m_map->ShowMap(false);
m_displayText->HideText(true); m_displayText->HideText(true);
} }
@ -1450,7 +1453,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
{ {
m_movieInfoIndex = index; m_movieInfoIndex = index;
m_movie->Start(MM_SATCOMopen, 2.5f); m_movie->Start(MM_SATCOMopen, 2.5f);
m_satcomMoviePause = m_pause->ActivatePause(PAUSE_SATCOMMOVIE); m_satcomMoviePause = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_HIDE_SHORTCUTS);
m_infoObject = DeselectAll(); // removes the control buttons m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true); m_displayText->HideText(true);
return; return;
@ -1546,7 +1549,7 @@ void CRobotMain::StartSuspend()
{ {
m_sound->MuteAll(true); m_sound->MuteAll(true);
ClearInterface(); ClearInterface();
m_suspend = m_pause->ActivatePause(PAUSE_DIALOG); m_suspend = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_HIDE_SHORTCUTS|PAUSE_MUTE_SOUND);
m_engine->SetOverFront(false); // over flat behind m_engine->SetOverFront(false); // over flat behind
CreateShortcuts(); CreateShortcuts();
@ -1674,7 +1677,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
m_camera->StartVisit(m_displayText->GetVisitGoal(event), m_camera->StartVisit(m_displayText->GetVisitGoal(event),
m_displayText->GetVisitDist(event)); m_displayText->GetVisitDist(event));
m_displayText->SetVisit(event); m_displayText->SetVisit(event);
m_visitPause = m_pause->ActivatePause(PAUSE_VISIT); m_visitPause = m_pause->ActivatePause(PAUSE_ENGINE);
} }
//! Move the arrow to visit //! Move the arrow to visit
@ -2408,16 +2411,16 @@ bool CRobotMain::EventFrame(const Event &event)
} }
m_time += event.rTime; m_time += event.rTime;
if (!m_movieLock && !m_pause->IsPause()) if (!m_movieLock && !m_pause->IsPauseType(PAUSE_ENGINE))
{ {
m_gameTime += event.rTime; m_gameTime += event.rTime;
m_gameTimeAbsolute += m_app->GetRealRelTime() / 1e9f; m_gameTimeAbsolute += m_app->GetRealRelTime() / 1e9f;
} }
if (!m_movieLock && !m_pause->IsPause() && m_missionTimerStarted) if (!m_movieLock && !m_pause->IsPauseType(PAUSE_ENGINE) && m_missionTimerStarted)
m_missionTimer += event.rTime; m_missionTimer += event.rTime;
if (!m_pause->IsPause() && m_autosave && m_gameTimeAbsolute >= m_autosaveLast+(m_autosaveInterval*60) && m_phase == PHASE_SIMUL) if (!m_pause->IsPauseType(PAUSE_ENGINE) && m_autosave && m_gameTimeAbsolute >= m_autosaveLast+(m_autosaveInterval*60) && m_phase == PHASE_SIMUL)
{ {
if (m_levelCategory == LevelCategory::Missions || if (m_levelCategory == LevelCategory::Missions ||
m_levelCategory == LevelCategory::FreeGame || m_levelCategory == LevelCategory::FreeGame ||
@ -2449,7 +2452,7 @@ bool CRobotMain::EventFrame(const Event &event)
} }
CObject* toto = nullptr; CObject* toto = nullptr;
if (!m_freePhoto) if (!m_pause->IsPauseType(PAUSE_OBJECT_UPDATES))
{ {
// Advances all the robots, but not toto. // Advances all the robots, but not toto.
for (CObject* obj : m_objMan->GetAllObjects()) for (CObject* obj : m_objMan->GetAllObjects())
@ -2539,7 +2542,7 @@ bool CRobotMain::EventFrame(const Event &event)
} }
// Moves edition indicator. // Moves edition indicator.
if (m_editLock || m_pause->IsPause()) // edition in progress? if (m_editLock || m_pause->IsPauseType(PAUSE_ENGINE)) // edition in progress?
{ {
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK); Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
if (pc != nullptr) if (pc != nullptr)
@ -2646,7 +2649,7 @@ bool CRobotMain::EventFrame(const Event &event)
{ {
// NOTE: It's important to do this AFTER the first update event finished processing // NOTE: It's important to do this AFTER the first update event finished processing
// because otherwise all robot parts are misplaced // because otherwise all robot parts are misplaced
m_userPause = m_pause->ActivatePause(PAUSE_CODE_BATTLE_LOCK); m_userPause = m_pause->ActivatePause(PAUSE_ENGINE);
m_codeBattleInit = true; // Will start on resume m_codeBattleInit = true; // Will start on resume
} }
@ -2696,7 +2699,7 @@ void CRobotMain::ShowSaveIndicator(bool show)
//! Makes the event for all robots //! Makes the event for all robots
bool CRobotMain::EventObject(const Event &event) bool CRobotMain::EventObject(const Event &event)
{ {
if (m_freePhoto) return true; if (m_pause->IsPauseType(PAUSE_OBJECT_UPDATES)) return true;
m_resetCreate = false; m_resetCreate = false;
@ -5516,12 +5519,6 @@ bool CRobotMain::GetEditFull()
} }
bool CRobotMain::GetFreePhoto()
{
return m_freePhoto;
}
//! Indicates whether mouse is on an friend object, on which we should not shoot //! Indicates whether mouse is on an friend object, on which we should not shoot
void CRobotMain::SetFriendAim(bool friendAim) void CRobotMain::SetFriendAim(bool friendAim)
{ {
@ -5558,29 +5555,29 @@ void CRobotMain::StartMusic()
void CRobotMain::UpdatePause(PauseType pause) void CRobotMain::UpdatePause(PauseType pause)
{ {
m_sound->MuteAll(pause != PAUSE_NONE); m_engine->SetPause(pause & PAUSE_ENGINE);
m_sound->MuteAll(pause & PAUSE_MUTE_SOUND);
CreateShortcuts(); CreateShortcuts();
if (pause != PAUSE_NONE) HiliteClear(); if (pause != PAUSE_NONE) HiliteClear();
}
switch (pause) void CRobotMain::UpdatePauseMusic(PauseMusic music)
{
switch (music)
{ {
case PAUSE_NONE: case PAUSE_MUSIC_NONE:
m_sound->StopPauseMusic(); m_sound->StopPauseMusic();
break; break;
case PAUSE_EDITOR: case PAUSE_MUSIC_EDITOR:
if (m_editorTrack != "") if (m_editorTrack != "")
m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat); m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat);
break; break;
case PAUSE_SATCOM: case PAUSE_MUSIC_SATCOM:
if (m_satcomTrack != "") if (m_satcomTrack != "")
m_sound->PlayPauseMusic(m_satcomTrack, m_satcomRepeat); m_sound->PlayPauseMusic(m_satcomTrack, m_satcomRepeat);
break; break;
default:
// Don't change music
break;
} }
} }

View File

@ -159,6 +159,7 @@ public:
Gfx::CTerrain* GetTerrain(); Gfx::CTerrain* GetTerrain();
Ui::CInterface* GetInterface(); Ui::CInterface* GetInterface();
Ui::CDisplayText* GetDisplayText(); Ui::CDisplayText* GetDisplayText();
CPauseManager* GetPauseManager();
void CreateConfigFile(); void CreateConfigFile();
void LoadConfigFile(); void LoadConfigFile();
@ -182,7 +183,6 @@ public:
bool GetEditLock(); bool GetEditLock();
void SetEditFull(bool full); void SetEditFull(bool full);
bool GetEditFull(); bool GetEditFull();
bool GetFreePhoto();
void SetFriendAim(bool friendAim); void SetFriendAim(bool friendAim);
bool GetFriendAim(); bool GetFriendAim();
@ -258,6 +258,7 @@ public:
void StartMusic(); void StartMusic();
void UpdatePause(PauseType pause); void UpdatePause(PauseType pause);
void UpdatePauseMusic(PauseMusic music);
void ClearInterface(); void ClearInterface();
void ChangeColor(); void ChangeColor();
@ -436,10 +437,10 @@ protected:
Gfx::COldModelManager* m_oldModelManager = nullptr; Gfx::COldModelManager* m_oldModelManager = nullptr;
Gfx::CLightManager* m_lightMan = nullptr; Gfx::CLightManager* m_lightMan = nullptr;
CSoundInterface* m_sound = nullptr; CSoundInterface* m_sound = nullptr;
CPauseManager* m_pause = nullptr;
CInput* m_input = nullptr; CInput* m_input = nullptr;
std::unique_ptr<CObjectManager> m_objMan; std::unique_ptr<CObjectManager> m_objMan;
std::unique_ptr<CMainMovie> m_movie; std::unique_ptr<CMainMovie> m_movie;
std::unique_ptr<CPauseManager> m_pause;
std::unique_ptr<Gfx::CModelManager> m_modelManager; std::unique_ptr<Gfx::CModelManager> m_modelManager;
std::unique_ptr<Gfx::CTerrain> m_terrain; std::unique_ptr<Gfx::CTerrain> m_terrain;
std::unique_ptr<Gfx::CCamera> m_camera; std::unique_ptr<Gfx::CCamera> m_camera;
@ -477,7 +478,6 @@ protected:
ActivePause* m_userPause = nullptr; ActivePause* m_userPause = nullptr;
int m_cameraRank = 0; int m_cameraRank = 0;
Gfx::Color m_color; Gfx::Color m_color;
bool m_freePhoto = false;
ActivePause* m_freePhotoPause = nullptr; ActivePause* m_freePhotoPause = nullptr;
bool m_cmdEdit = false; bool m_cmdEdit = false;
ActivePause* m_cmdEditPause = nullptr; ActivePause* m_cmdEditPause = nullptr;

View File

@ -69,7 +69,7 @@ CDisplayInfo::CDisplayInfo()
m_main = CRobotMain::GetInstancePointer(); m_main = CRobotMain::GetInstancePointer();
m_interface = m_main->GetInterface(); m_interface = m_main->GetInterface();
m_camera = m_main->GetCamera(); m_camera = m_main->GetCamera();
m_pause = m_engine->GetPauseManager(); m_pause = m_main->GetPauseManager();
m_bInfoMaximized = true; m_bInfoMaximized = true;
m_bInfoMinimized = false; m_bInfoMinimized = false;
@ -363,7 +363,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
m_main->SetEditLock(true, false); m_main->SetEditLock(true, false);
m_main->SetEditFull(false); m_main->SetEditFull(false);
m_satcomPause = m_pause->ActivatePause(PAUSE_SATCOM); m_satcomPause = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_HIDE_SHORTCUTS|PAUSE_MUTE_SOUND, PAUSE_MUSIC_SATCOM);
m_infoCamera = m_camera->GetType(); m_infoCamera = m_camera->GetType();
m_camera->SetType(Gfx::CAM_TYPE_INFO); m_camera->SetType(Gfx::CAM_TYPE_INFO);

View File

@ -106,19 +106,18 @@ bool CMainShort::CreateShortcuts()
m_interface->CreateShortcut(pos, dim, 128+7, EVENT_OBJECT_MOVIELOCK); m_interface->CreateShortcut(pos, dim, 128+7, EVENT_OBJECT_MOVIELOCK);
return true; return true;
} }
if ( !m_main->GetFreePhoto() && if ( !m_main->GetPauseManager()->IsPauseType(PAUSE_PHOTO) &&
(m_main->GetEditLock() || (m_main->GetEditLock() ||
m_engine->GetPause()) ) // hangs during edition? m_engine->GetPause()) ) // hangs during edition?
{ {
m_interface->CreateShortcut(pos, dim, 128+6, EVENT_OBJECT_EDITLOCK); m_interface->CreateShortcut(pos, dim, 128+6, EVENT_OBJECT_EDITLOCK);
} }
if (m_main->GetFreePhoto() && m_main->GetSelect() == nullptr) if (m_main->GetPauseManager()->IsPauseType(PAUSE_PHOTO) && m_main->GetSelect() == nullptr)
{ {
return true; return true;
} }
PauseType pauseType = m_engine->GetPauseManager()->GetPauseType();
if (pauseType == PAUSE_SATCOM || pauseType == PAUSE_EDITOR || pauseType == PAUSE_DIALOG) if (m_main->GetPauseManager()->IsPauseType(PAUSE_HIDE_SHORTCUTS))
return true; return true;
// Create new shortcuts // Create new shortcuts

View File

@ -82,7 +82,7 @@ CStudio::CStudio()
m_main = CRobotMain::GetInstancePointer(); m_main = CRobotMain::GetInstancePointer();
m_interface = m_main->GetInterface(); m_interface = m_main->GetInterface();
m_camera = m_main->GetCamera(); m_camera = m_main->GetCamera();
m_pause = m_engine->GetPauseManager(); m_pause = m_main->GetPauseManager();
m_settings = CSettings::GetInstancePointer(); m_settings = CSettings::GetInstancePointer();
m_program = nullptr; m_program = nullptr;
@ -356,17 +356,17 @@ bool CStudio::EventFrame(const Event &event)
if (m_script->IsRunning() && (!m_script->GetStepMode() || m_script->IsContinue())) if (m_script->IsRunning() && (!m_script->GetStepMode() || m_script->IsContinue()))
{ {
if (m_editorPause != nullptr) if (m_runningPause != nullptr)
{ {
m_pause->DeactivatePause(m_editorPause); m_pause->DeactivatePause(m_runningPause);
m_editorPause = nullptr; m_runningPause = nullptr;
} }
} }
else else
{ {
if (m_editorPause == nullptr) if (m_runningPause == nullptr)
{ {
m_editorPause = m_pause->ActivatePause(PAUSE_EDITOR); m_runningPause = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_MUTE_SOUND);
} }
} }
@ -578,6 +578,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
m_main->SetSpeed(1.0f); m_main->SetSpeed(1.0f);
m_editCamera = m_camera->GetType(); m_editCamera = m_camera->GetType();
m_camera->SetType(Gfx::CAM_TYPE_EDIT); m_camera->SetType(Gfx::CAM_TYPE_EDIT);
m_editorPause = m_pause->ActivatePause(PAUSE_HIDE_SHORTCUTS, PAUSE_MUSIC_EDITOR);
m_bRunning = m_script->IsRunning(); m_bRunning = m_script->IsRunning();
m_bRealTime = m_bRunning; m_bRealTime = m_bRunning;
@ -914,7 +915,8 @@ bool CStudio::StopEditScript(bool bCancel)
m_pause->DeactivatePause(m_editorPause); m_pause->DeactivatePause(m_editorPause);
m_editorPause = nullptr; m_editorPause = nullptr;
m_sound->MuteAll(false); m_pause->DeactivatePause(m_runningPause);
m_runningPause = nullptr;
m_main->SetEditLock(false, true); m_main->SetEditLock(false, true);
m_camera->SetType(m_editCamera); m_camera->SetType(m_editCamera);
return true; return true;
@ -984,22 +986,22 @@ void CStudio::UpdateFlux()
{ {
if ( m_bRealTime ) // run? if ( m_bRealTime ) // run?
{ {
m_pause->DeactivatePause(m_editorPause); m_pause->DeactivatePause(m_runningPause);
m_editorPause = nullptr; m_runningPause = nullptr;
} }
else // step by step? else // step by step?
{ {
if (m_editorPause == nullptr) if (m_runningPause == nullptr)
{ {
m_editorPause = m_pause->ActivatePause(PAUSE_EDITOR); m_runningPause = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_MUTE_SOUND);
} }
} }
} }
else // stop? else // stop?
{ {
if (m_editorPause == nullptr) if (m_runningPause == nullptr)
{ {
m_editorPause = m_pause->ActivatePause(PAUSE_EDITOR); m_runningPause = m_pause->ActivatePause(PAUSE_ENGINE|PAUSE_MUTE_SOUND);
} }
} }
} }

View File

@ -114,6 +114,7 @@ protected:
bool m_bRunning; bool m_bRunning;
bool m_bRealTime; bool m_bRealTime;
ActivePause* m_editorPause = nullptr; ActivePause* m_editorPause = nullptr;
ActivePause* m_runningPause = nullptr;
std::string m_helpFilename; std::string m_helpFilename;
StudioDialog m_dialog; StudioDialog m_dialog;