From 59d5545eca41b4ab41346f380991ff91287b83e8 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 22 Jul 2015 18:01:24 +0200 Subject: [PATCH] Fixed code pause editor bug (#527) --- src/app/pausemanager.cpp | 1 + src/app/pausemanager.h | 12 ++++++------ src/object/robotmain.cpp | 8 +++++--- src/script/script.cpp | 6 ++++-- src/ui/studio.cpp | 28 ++++++++++++++++------------ 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/app/pausemanager.cpp b/src/app/pausemanager.cpp index 42152209..bb28dcf6 100644 --- a/src/app/pausemanager.cpp +++ b/src/app/pausemanager.cpp @@ -95,6 +95,7 @@ std::string CPauseManager::GetPauseName(PauseType pause) case PAUSE_VISIT: return "Visit"; case PAUSE_CHEAT: return "Cheat console"; case PAUSE_PHOTO: return "Photo mode"; + case PAUSE_CODE_BATTLE_LOCK: return "Code battle lock"; default: assert(false); // Should never happen } return "?"; diff --git a/src/app/pausemanager.h b/src/app/pausemanager.h index 411742e1..2bd6c0a9 100644 --- a/src/app/pausemanager.h +++ b/src/app/pausemanager.h @@ -38,7 +38,8 @@ enum PauseType { PAUSE_EDITOR, PAUSE_VISIT, PAUSE_CHEAT, - PAUSE_PHOTO + PAUSE_PHOTO, + PAUSE_CODE_BATTLE_LOCK }; class CPauseManager : public CSingleton @@ -46,19 +47,18 @@ class CPauseManager : public CSingleton public: CPauseManager(); ~CPauseManager(); - + void SetPause(PauseType pause); void ClearPause(); bool GetPause(); bool GetPause(PauseType pause); PauseType GetPauseType(); - + private: std::string GetPauseName(PauseType pause); - + private: CSoundInterface* m_sound; - + PauseType m_pause; }; - diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index f1cfd843..c45adae8 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -831,7 +831,7 @@ bool CRobotMain::ProcessEvent(Event &event) m_camera->GetType() != Gfx::CAM_TYPE_VISIT && !m_movie->IsExist()) { - ChangePause(m_pause->GetPause(PAUSE_USER) ? PAUSE_NONE : PAUSE_USER); + ChangePause(m_pause->GetPause(PAUSE_USER) || m_pause->GetPause(PAUSE_CODE_BATTLE_LOCK) ? PAUSE_NONE : PAUSE_USER); } } if (event.key.slot == INPUT_SLOT_CAMERA) @@ -2764,7 +2764,8 @@ bool CRobotMain::EventFrame(const Event &event) { // NOTE: It's important to do this AFTER the first update event finished processing // because otherwise all robot parts are misplaced - ChangePause(PAUSE_USER); + ChangePause(PAUSE_CODE_BATTLE_LOCK); + m_sound->MuteAll(false); // Allow sound m_codeBattleInit = true; // Will start on resume } @@ -6086,7 +6087,8 @@ void CRobotMain::SetExitAfterMission(bool exit) bool CRobotMain::CanPlayerInteract() { - if(GetMissionType() == MISSION_CODE_BATTLE) { + if(GetMissionType() == MISSION_CODE_BATTLE) + { return !m_codeBattleStarted; } return true; diff --git a/src/script/script.cpp b/src/script/script.cpp index f8e59e16..26d9f94b 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -480,7 +480,10 @@ bool CScript::Step(const Event &event) if ( m_bContinue ) // instuction "move", "goto", etc. ? { - m_pause->ClearPause(); // removes the pause + if (m_pause->GetPauseType() == PAUSE_EDITOR) + { + m_pause->ClearPause(); // removes the pause + } } return false; } @@ -1098,4 +1101,3 @@ char* CScript::GetFilename() { return m_filename; } - diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 3ef9994f..08fc6def 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -957,26 +957,30 @@ void CStudio::UpdateFlux() { if ( m_bRunning ) { -#if 1 if ( m_bRealTime ) // run? { - m_pause->ClearPause(); - m_sound->MuteAll(false); + if(m_pause->GetPauseType() == PAUSE_EDITOR) + { + m_pause->ClearPause(); + m_sound->MuteAll(false); + } } else // step by step? + { + if(!m_pause->GetPause()) + { + m_pause->SetPause(PAUSE_EDITOR); + m_sound->MuteAll(true); + } + } + } + else // stop? + { + if(!m_pause->GetPause()) { m_pause->SetPause(PAUSE_EDITOR); m_sound->MuteAll(true); } -#else - m_pause->ClearPause(); - m_sound->MuteAll(false); -#endif - } - else // stop? - { - m_pause->SetPause(PAUSE_EDITOR); - m_sound->MuteAll(true); } }