Refactored CPauseManager (again)
parent
58035f3cd1
commit
3815ef0bd6
|
@ -29,31 +29,32 @@
|
|||
|
||||
|
||||
CPauseManager::CPauseManager()
|
||||
{}
|
||||
{
|
||||
m_main = CRobotMain::GetInstancePointer();
|
||||
}
|
||||
|
||||
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());
|
||||
auto pause = std::unique_ptr<ActivePause>(new ActivePause(type)); // TODO: Can't use MakeUnique here because the constructor is private
|
||||
//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
|
||||
ActivePause* ptr = pause.get();
|
||||
m_activePause.push_back(std::move(pause));
|
||||
UpdatePause();
|
||||
Update();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void CPauseManager::DeactivatePause(ActivePause* pause)
|
||||
{
|
||||
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.begin(), m_activePause.end(),
|
||||
[&](const std::unique_ptr<ActivePause>& x) { return x.get() == pause; })
|
||||
);
|
||||
UpdatePause();
|
||||
Update();
|
||||
}
|
||||
|
||||
void CPauseManager::FlushPause()
|
||||
|
@ -61,49 +62,38 @@ void CPauseManager::FlushPause()
|
|||
m_activePause.clear();
|
||||
}
|
||||
|
||||
bool CPauseManager::IsPause()
|
||||
PauseType CPauseManager::GetPause()
|
||||
{
|
||||
return m_activePause.size() > 0;
|
||||
}
|
||||
|
||||
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)
|
||||
PauseType current = PAUSE_NONE;
|
||||
for(auto& pause : m_activePause)
|
||||
{
|
||||
GetLogger()->Info("Game paused - %s\n", GetPauseName(type).c_str());
|
||||
current |= pause->type;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLogger()->Info("Game resumed\n");
|
||||
}
|
||||
|
||||
CRobotMain::GetInstancePointer()->UpdatePause(type);
|
||||
return current;
|
||||
}
|
||||
|
||||
std::string CPauseManager::GetPauseName(PauseType pause)
|
||||
bool CPauseManager::IsPauseType(PauseType type)
|
||||
{
|
||||
switch(pause)
|
||||
{
|
||||
case PAUSE_NONE: return "None";
|
||||
case PAUSE_USER: return "User";
|
||||
case PAUSE_SATCOM: return "SatCom";
|
||||
case PAUSE_SATCOMMOVIE: return "SatCom opening animation";
|
||||
case PAUSE_DIALOG: return "Dialog";
|
||||
case PAUSE_EDITOR: return "CBot editor";
|
||||
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 "?";
|
||||
PauseType current = GetPause();
|
||||
return (current & type) == type;
|
||||
}
|
||||
|
||||
void CPauseManager::Update()
|
||||
{
|
||||
m_main->UpdatePause(GetPause()); //TODO
|
||||
|
||||
PauseMusic music = PAUSE_MUSIC_NONE;
|
||||
for(int i = m_activePause.size()-1; i >= 0; i--)
|
||||
{
|
||||
if (m_activePause[i]->music != PAUSE_MUSIC_NONE)
|
||||
{
|
||||
music = m_activePause[i]->music;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (music != m_lastPauseMusic)
|
||||
{
|
||||
m_main->UpdatePauseMusic(music);
|
||||
m_lastPauseMusic = music;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,19 +27,40 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class CRobotMain;
|
||||
|
||||
|
||||
enum PauseType
|
||||
{
|
||||
PAUSE_NONE = 0,
|
||||
PAUSE_USER,
|
||||
PAUSE_SATCOM,
|
||||
PAUSE_SATCOMMOVIE,
|
||||
PAUSE_DIALOG,
|
||||
PAUSE_EDITOR,
|
||||
PAUSE_VISIT,
|
||||
PAUSE_CHEAT,
|
||||
PAUSE_PHOTO,
|
||||
PAUSE_CODE_BATTLE_LOCK
|
||||
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,
|
||||
};
|
||||
|
||||
struct ActivePause
|
||||
|
@ -47,14 +68,16 @@ struct ActivePause
|
|||
private:
|
||||
friend class CPauseManager;
|
||||
|
||||
explicit ActivePause(PauseType type)
|
||||
explicit ActivePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE)
|
||||
: type(type)
|
||||
, music(music)
|
||||
{}
|
||||
|
||||
ActivePause(const ActivePause&) = delete;
|
||||
ActivePause& operator=(const ActivePause&) = delete;
|
||||
|
||||
PauseType type;
|
||||
PauseMusic music;
|
||||
};
|
||||
|
||||
class CPauseManager
|
||||
|
@ -63,19 +86,21 @@ public:
|
|||
CPauseManager();
|
||||
~CPauseManager();
|
||||
|
||||
ActivePause* ActivatePause(PauseType type);
|
||||
ActivePause* ActivatePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE);
|
||||
void DeactivatePause(ActivePause* pause);
|
||||
|
||||
void FlushPause();
|
||||
|
||||
bool IsPause();
|
||||
PauseType GetPauseType();
|
||||
PauseType GetPause();
|
||||
bool IsPauseType(PauseType type);
|
||||
|
||||
private:
|
||||
void UpdatePause();
|
||||
|
||||
static std::string GetPauseName(PauseType pause);
|
||||
//static std::string GetPauseName(PauseType pause);
|
||||
void Update();
|
||||
|
||||
private:
|
||||
CRobotMain* m_main;
|
||||
|
||||
std::vector<std::unique_ptr<ActivePause>> m_activePause;
|
||||
PauseMusic m_lastPauseMusic = PAUSE_MUSIC_NONE;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "app/app.h"
|
||||
#include "app/input.h"
|
||||
#include "app/pausemanager.h"
|
||||
#include "app/system.h"
|
||||
|
||||
#include "common/image.h"
|
||||
|
@ -89,7 +88,6 @@ CEngine::CEngine(CApplication *app, CSystemUtils* systemUtils)
|
|||
m_planet = nullptr;
|
||||
m_sound = nullptr;
|
||||
m_terrain = nullptr;
|
||||
m_pause = nullptr;
|
||||
|
||||
m_showStats = false;
|
||||
|
||||
|
@ -272,11 +270,6 @@ CCloud* CEngine::GetCloud()
|
|||
return m_cloud.get();
|
||||
}
|
||||
|
||||
CPauseManager* CEngine::GetPauseManager()
|
||||
{
|
||||
return m_pause.get();
|
||||
}
|
||||
|
||||
void CEngine::SetTerrain(CTerrain* terrain)
|
||||
{
|
||||
m_terrain = terrain;
|
||||
|
@ -303,7 +296,6 @@ bool CEngine::Create()
|
|||
m_cloud = MakeUnique<CCloud>(this);
|
||||
m_lightning = MakeUnique<CLightning>(this);
|
||||
m_planet = MakeUnique<CPlanet>(this);
|
||||
m_pause = MakeUnique<CPauseManager>();
|
||||
|
||||
m_lightMan->SetDevice(m_device);
|
||||
m_particle->SetDevice(m_device);
|
||||
|
@ -353,7 +345,6 @@ void CEngine::Destroy()
|
|||
m_shadowMap = Texture();
|
||||
}
|
||||
|
||||
m_pause.reset();
|
||||
m_lightMan.reset();
|
||||
m_text.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));
|
||||
}
|
||||
|
||||
void CEngine::SetPause(bool pause)
|
||||
{
|
||||
m_pause = pause;
|
||||
}
|
||||
|
||||
bool CEngine::GetPause()
|
||||
{
|
||||
return m_pause->IsPause();
|
||||
return m_pause;
|
||||
}
|
||||
|
||||
void CEngine::SetShowStats(bool show)
|
||||
|
|
|
@ -645,8 +645,6 @@ public:
|
|||
CPlanet* GetPlanet();
|
||||
//! Returns the fog manager
|
||||
CCloud* GetCloud();
|
||||
//! Returns the pause manager
|
||||
CPauseManager* GetPauseManager();
|
||||
|
||||
//! Sets the terrain object
|
||||
void SetTerrain(CTerrain* terrain);
|
||||
|
@ -676,8 +674,11 @@ public:
|
|||
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
|
||||
|
@ -1287,7 +1288,6 @@ protected:
|
|||
std::unique_ptr<CCloud> m_cloud;
|
||||
std::unique_ptr<CLightning> m_lightning;
|
||||
std::unique_ptr<CPlanet> m_planet;
|
||||
std::unique_ptr<CPauseManager> m_pause;
|
||||
std::unique_ptr<CPyroManager> m_pyroManager;
|
||||
|
||||
//! Last encountered error
|
||||
|
@ -1465,6 +1465,9 @@ protected:
|
|||
std::string m_timerText;
|
||||
|
||||
std::unordered_map<std::string, int> m_staticMeshBaseObjects;
|
||||
|
||||
//! Pause the animation updates
|
||||
bool m_pause = false;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -135,11 +135,11 @@ CRobotMain::CRobotMain()
|
|||
m_cloud = m_engine->GetCloud();
|
||||
m_lightning = m_engine->GetLightning();
|
||||
m_planet = m_engine->GetPlanet();
|
||||
m_pause = m_engine->GetPauseManager();
|
||||
m_input = CInput::GetInstancePointer();
|
||||
|
||||
m_modelManager = MakeUnique<Gfx::CModelManager>();
|
||||
m_settings = MakeUnique<CSettings>();
|
||||
m_pause = MakeUnique<CPauseManager>();
|
||||
m_interface = MakeUnique<Ui::CInterface>();
|
||||
m_terrain = MakeUnique<Gfx::CTerrain>();
|
||||
m_camera = MakeUnique<Gfx::CCamera>();
|
||||
|
@ -193,7 +193,6 @@ CRobotMain::CRobotMain()
|
|||
m_editLock = false;
|
||||
m_editFull = false;
|
||||
m_hilite = false;
|
||||
m_freePhoto = false;
|
||||
m_selectInsect = false;
|
||||
m_showSoluce = false;
|
||||
|
||||
|
@ -294,6 +293,11 @@ Ui::CDisplayText* CRobotMain::GetDisplayText()
|
|||
return m_displayText.get();
|
||||
}
|
||||
|
||||
CPauseManager* CRobotMain::GetPauseManager()
|
||||
{
|
||||
return m_pause.get();
|
||||
}
|
||||
|
||||
void CRobotMain::ResetAfterVideoConfigChanged()
|
||||
{
|
||||
// Recreate the interface (needed if the aspect ratio changes)
|
||||
|
@ -431,11 +435,12 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
m_movieLock = false;
|
||||
m_satComLock = false;
|
||||
m_editLock = false;
|
||||
m_freePhoto = false;
|
||||
m_resetCreate = false;
|
||||
m_infoObject = nullptr;
|
||||
|
||||
m_pause->FlushPause();
|
||||
m_freePhotoPause = nullptr;
|
||||
m_userPause = nullptr;
|
||||
FlushDisplayInfo();
|
||||
m_engine->SetRankView(0);
|
||||
m_terrain->FlushRelief();
|
||||
|
@ -713,7 +718,7 @@ bool CRobotMain::ProcessEvent(Event &event)
|
|||
if (pe == nullptr) return false;
|
||||
pe->SetState(Ui::STATE_VISIBLE);
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
|
@ -847,9 +852,9 @@ bool CRobotMain::ProcessEvent(Event &event)
|
|||
{
|
||||
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
|
||||
|
@ -1190,11 +1195,10 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
|
||||
if (strcmp(cmd, "photo1") == 0)
|
||||
{
|
||||
m_freePhoto = !m_freePhoto;
|
||||
if (m_freePhoto)
|
||||
if (m_freePhotoPause == nullptr)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -1207,12 +1211,11 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
|
||||
if (strcmp(cmd, "photo2") == 0)
|
||||
{
|
||||
m_freePhoto = !m_freePhoto;
|
||||
if (m_freePhoto)
|
||||
if (m_freePhotoPause == nullptr)
|
||||
{
|
||||
m_camera->SetType(Gfx::CAM_TYPE_FREE);
|
||||
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_displayText->HideText(true);
|
||||
}
|
||||
|
@ -1450,7 +1453,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
|
|||
{
|
||||
m_movieInfoIndex = index;
|
||||
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_displayText->HideText(true);
|
||||
return;
|
||||
|
@ -1546,7 +1549,7 @@ void CRobotMain::StartSuspend()
|
|||
{
|
||||
m_sound->MuteAll(true);
|
||||
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
|
||||
CreateShortcuts();
|
||||
|
||||
|
@ -1674,7 +1677,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
|
|||
m_camera->StartVisit(m_displayText->GetVisitGoal(event),
|
||||
m_displayText->GetVisitDist(event));
|
||||
m_displayText->SetVisit(event);
|
||||
m_visitPause = m_pause->ActivatePause(PAUSE_VISIT);
|
||||
m_visitPause = m_pause->ActivatePause(PAUSE_ENGINE);
|
||||
}
|
||||
|
||||
//! Move the arrow to visit
|
||||
|
@ -2408,16 +2411,16 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
}
|
||||
|
||||
m_time += event.rTime;
|
||||
if (!m_movieLock && !m_pause->IsPause())
|
||||
if (!m_movieLock && !m_pause->IsPauseType(PAUSE_ENGINE))
|
||||
{
|
||||
m_gameTime += event.rTime;
|
||||
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;
|
||||
|
||||
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 ||
|
||||
m_levelCategory == LevelCategory::FreeGame ||
|
||||
|
@ -2449,7 +2452,7 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
}
|
||||
|
||||
CObject* toto = nullptr;
|
||||
if (!m_freePhoto)
|
||||
if (!m_pause->IsPauseType(PAUSE_OBJECT_UPDATES))
|
||||
{
|
||||
// Advances all the robots, but not toto.
|
||||
for (CObject* obj : m_objMan->GetAllObjects())
|
||||
|
@ -2539,7 +2542,7 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
}
|
||||
|
||||
// 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);
|
||||
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
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -2696,7 +2699,7 @@ void CRobotMain::ShowSaveIndicator(bool show)
|
|||
//! Makes the event for all robots
|
||||
bool CRobotMain::EventObject(const Event &event)
|
||||
{
|
||||
if (m_freePhoto) return true;
|
||||
if (m_pause->IsPauseType(PAUSE_OBJECT_UPDATES)) return true;
|
||||
|
||||
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
|
||||
void CRobotMain::SetFriendAim(bool friendAim)
|
||||
{
|
||||
|
@ -5558,29 +5555,29 @@ void CRobotMain::StartMusic()
|
|||
|
||||
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();
|
||||
if (pause != PAUSE_NONE) HiliteClear();
|
||||
}
|
||||
|
||||
switch (pause)
|
||||
void CRobotMain::UpdatePauseMusic(PauseMusic music)
|
||||
{
|
||||
switch (music)
|
||||
{
|
||||
case PAUSE_NONE:
|
||||
case PAUSE_MUSIC_NONE:
|
||||
m_sound->StopPauseMusic();
|
||||
break;
|
||||
|
||||
case PAUSE_EDITOR:
|
||||
case PAUSE_MUSIC_EDITOR:
|
||||
if (m_editorTrack != "")
|
||||
m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat);
|
||||
break;
|
||||
|
||||
case PAUSE_SATCOM:
|
||||
case PAUSE_MUSIC_SATCOM:
|
||||
if (m_satcomTrack != "")
|
||||
m_sound->PlayPauseMusic(m_satcomTrack, m_satcomRepeat);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Don't change music
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,6 +159,7 @@ public:
|
|||
Gfx::CTerrain* GetTerrain();
|
||||
Ui::CInterface* GetInterface();
|
||||
Ui::CDisplayText* GetDisplayText();
|
||||
CPauseManager* GetPauseManager();
|
||||
|
||||
void CreateConfigFile();
|
||||
void LoadConfigFile();
|
||||
|
@ -182,7 +183,6 @@ public:
|
|||
bool GetEditLock();
|
||||
void SetEditFull(bool full);
|
||||
bool GetEditFull();
|
||||
bool GetFreePhoto();
|
||||
void SetFriendAim(bool friendAim);
|
||||
bool GetFriendAim();
|
||||
|
||||
|
@ -258,6 +258,7 @@ public:
|
|||
|
||||
void StartMusic();
|
||||
void UpdatePause(PauseType pause);
|
||||
void UpdatePauseMusic(PauseMusic music);
|
||||
void ClearInterface();
|
||||
void ChangeColor();
|
||||
|
||||
|
@ -436,10 +437,10 @@ protected:
|
|||
Gfx::COldModelManager* m_oldModelManager = nullptr;
|
||||
Gfx::CLightManager* m_lightMan = nullptr;
|
||||
CSoundInterface* m_sound = nullptr;
|
||||
CPauseManager* m_pause = nullptr;
|
||||
CInput* m_input = nullptr;
|
||||
std::unique_ptr<CObjectManager> m_objMan;
|
||||
std::unique_ptr<CMainMovie> m_movie;
|
||||
std::unique_ptr<CPauseManager> m_pause;
|
||||
std::unique_ptr<Gfx::CModelManager> m_modelManager;
|
||||
std::unique_ptr<Gfx::CTerrain> m_terrain;
|
||||
std::unique_ptr<Gfx::CCamera> m_camera;
|
||||
|
@ -477,7 +478,6 @@ protected:
|
|||
ActivePause* m_userPause = nullptr;
|
||||
int m_cameraRank = 0;
|
||||
Gfx::Color m_color;
|
||||
bool m_freePhoto = false;
|
||||
ActivePause* m_freePhotoPause = nullptr;
|
||||
bool m_cmdEdit = false;
|
||||
ActivePause* m_cmdEditPause = nullptr;
|
||||
|
|
|
@ -69,7 +69,7 @@ CDisplayInfo::CDisplayInfo()
|
|||
m_main = CRobotMain::GetInstancePointer();
|
||||
m_interface = m_main->GetInterface();
|
||||
m_camera = m_main->GetCamera();
|
||||
m_pause = m_engine->GetPauseManager();
|
||||
m_pause = m_main->GetPauseManager();
|
||||
|
||||
m_bInfoMaximized = true;
|
||||
m_bInfoMinimized = false;
|
||||
|
@ -363,7 +363,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
|
|||
|
||||
m_main->SetEditLock(true, 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_camera->SetType(Gfx::CAM_TYPE_INFO);
|
||||
|
||||
|
|
|
@ -106,19 +106,18 @@ bool CMainShort::CreateShortcuts()
|
|||
m_interface->CreateShortcut(pos, dim, 128+7, EVENT_OBJECT_MOVIELOCK);
|
||||
return true;
|
||||
}
|
||||
if ( !m_main->GetFreePhoto() &&
|
||||
if ( !m_main->GetPauseManager()->IsPauseType(PAUSE_PHOTO) &&
|
||||
(m_main->GetEditLock() ||
|
||||
m_engine->GetPause()) ) // hangs during edition?
|
||||
{
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
// Create new shortcuts
|
||||
|
|
|
@ -82,7 +82,7 @@ CStudio::CStudio()
|
|||
m_main = CRobotMain::GetInstancePointer();
|
||||
m_interface = m_main->GetInterface();
|
||||
m_camera = m_main->GetCamera();
|
||||
m_pause = m_engine->GetPauseManager();
|
||||
m_pause = m_main->GetPauseManager();
|
||||
m_settings = CSettings::GetInstancePointer();
|
||||
|
||||
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_editorPause != nullptr)
|
||||
if (m_runningPause != nullptr)
|
||||
{
|
||||
m_pause->DeactivatePause(m_editorPause);
|
||||
m_editorPause = nullptr;
|
||||
m_pause->DeactivatePause(m_runningPause);
|
||||
m_runningPause = nullptr;
|
||||
}
|
||||
}
|
||||
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_editCamera = m_camera->GetType();
|
||||
m_camera->SetType(Gfx::CAM_TYPE_EDIT);
|
||||
m_editorPause = m_pause->ActivatePause(PAUSE_HIDE_SHORTCUTS, PAUSE_MUSIC_EDITOR);
|
||||
|
||||
m_bRunning = m_script->IsRunning();
|
||||
m_bRealTime = m_bRunning;
|
||||
|
@ -914,7 +915,8 @@ bool CStudio::StopEditScript(bool bCancel)
|
|||
|
||||
m_pause->DeactivatePause(m_editorPause);
|
||||
m_editorPause = nullptr;
|
||||
m_sound->MuteAll(false);
|
||||
m_pause->DeactivatePause(m_runningPause);
|
||||
m_runningPause = nullptr;
|
||||
m_main->SetEditLock(false, true);
|
||||
m_camera->SetType(m_editCamera);
|
||||
return true;
|
||||
|
@ -984,22 +986,22 @@ void CStudio::UpdateFlux()
|
|||
{
|
||||
if ( m_bRealTime ) // run?
|
||||
{
|
||||
m_pause->DeactivatePause(m_editorPause);
|
||||
m_editorPause = nullptr;
|
||||
m_pause->DeactivatePause(m_runningPause);
|
||||
m_runningPause = nullptr;
|
||||
}
|
||||
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?
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ protected:
|
|||
bool m_bRunning;
|
||||
bool m_bRealTime;
|
||||
ActivePause* m_editorPause = nullptr;
|
||||
ActivePause* m_runningPause = nullptr;
|
||||
std::string m_helpFilename;
|
||||
|
||||
StudioDialog m_dialog;
|
||||
|
|
Loading…
Reference in New Issue