Refactored CPauseManager
parent
cc7e36968f
commit
ff17961584
2
data
2
data
|
@ -1 +1 @@
|
|||
Subproject commit 11911a9a4de2ec08dcefc291e80bde7ec1224e24
|
||||
Subproject commit eb4dc8489609c33a93b67bbc45939d5b5ee6d8ee
|
|
@ -25,62 +25,66 @@
|
|||
|
||||
#include "level/robotmain.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
template<> CPauseManager* CSingleton<CPauseManager>::m_instance = nullptr;
|
||||
|
||||
|
||||
CPauseManager::CPauseManager()
|
||||
{
|
||||
m_sound = CApplication::GetInstancePointer()->GetSound();
|
||||
|
||||
m_pause = PAUSE_NONE;
|
||||
}
|
||||
{}
|
||||
|
||||
CPauseManager::~CPauseManager()
|
||||
{}
|
||||
|
||||
ActivePause* CPauseManager::ActivatePause(PauseType type)
|
||||
{
|
||||
m_sound = nullptr;
|
||||
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
|
||||
ActivePause* ptr = pause.get();
|
||||
m_activePause.push_back(std::move(pause));
|
||||
UpdatePause();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void CPauseManager::SetPause(PauseType pause)
|
||||
void CPauseManager::DeactivatePause(ActivePause* pause)
|
||||
{
|
||||
if (pause != PAUSE_NONE)
|
||||
{
|
||||
if (m_pause != pause)
|
||||
{
|
||||
GetLogger()->Info("Game paused - %s\n", GetPauseName(pause).c_str());
|
||||
CRobotMain::GetInstancePointer()->StartPauseMusic(pause);
|
||||
}
|
||||
if (pause == nullptr) return;
|
||||
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();
|
||||
}
|
||||
|
||||
m_pause = pause;
|
||||
void CPauseManager::FlushPause()
|
||||
{
|
||||
m_activePause.clear();
|
||||
}
|
||||
|
||||
bool CPauseManager::IsPause()
|
||||
{
|
||||
return m_activePause.size() > 0;
|
||||
}
|
||||
|
||||
void CPauseManager::UpdatePause()
|
||||
{
|
||||
PauseType type = PAUSE_NONE;
|
||||
if (m_activePause.size() > 0)
|
||||
type = m_activePause[m_activePause.size()-1]->type;
|
||||
|
||||
if (type != PAUSE_NONE)
|
||||
{
|
||||
GetLogger()->Info("Game paused - %s\n", GetPauseName(type).c_str());
|
||||
}
|
||||
else
|
||||
ClearPause();
|
||||
}
|
||||
|
||||
void CPauseManager::ClearPause()
|
||||
{
|
||||
if(m_pause != PAUSE_NONE)
|
||||
{
|
||||
GetLogger()->Info("Game resumed\n");
|
||||
m_sound->StopPauseMusic();
|
||||
}
|
||||
|
||||
m_pause = PAUSE_NONE;
|
||||
}
|
||||
|
||||
bool CPauseManager::GetPause()
|
||||
{
|
||||
return m_pause != PAUSE_NONE;
|
||||
}
|
||||
|
||||
bool CPauseManager::GetPause(PauseType pause)
|
||||
{
|
||||
return m_pause == pause;
|
||||
}
|
||||
|
||||
PauseType CPauseManager::GetPauseType()
|
||||
{
|
||||
return m_pause;
|
||||
CRobotMain::GetInstancePointer()->UpdatePause(type);
|
||||
}
|
||||
|
||||
std::string CPauseManager::GetPauseName(PauseType pause)
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
|
||||
enum PauseType
|
||||
|
@ -44,23 +44,39 @@ enum PauseType
|
|||
PAUSE_CODE_BATTLE_LOCK
|
||||
};
|
||||
|
||||
struct ActivePause
|
||||
{
|
||||
private:
|
||||
friend class CPauseManager;
|
||||
|
||||
explicit ActivePause(PauseType type)
|
||||
: type(type)
|
||||
{}
|
||||
|
||||
ActivePause(const ActivePause&) = delete;
|
||||
ActivePause& operator=(const ActivePause&) = delete;
|
||||
|
||||
PauseType type;
|
||||
};
|
||||
|
||||
class CPauseManager : public CSingleton<CPauseManager>
|
||||
{
|
||||
public:
|
||||
CPauseManager();
|
||||
~CPauseManager();
|
||||
|
||||
void SetPause(PauseType pause);
|
||||
void ClearPause();
|
||||
bool GetPause();
|
||||
bool GetPause(PauseType pause);
|
||||
PauseType GetPauseType();
|
||||
ActivePause* ActivatePause(PauseType type);
|
||||
void DeactivatePause(ActivePause* pause);
|
||||
|
||||
void FlushPause();
|
||||
|
||||
bool IsPause();
|
||||
|
||||
private:
|
||||
std::string GetPauseName(PauseType pause);
|
||||
void UpdatePause();
|
||||
|
||||
static std::string GetPauseName(PauseType pause);
|
||||
|
||||
private:
|
||||
CSoundInterface* m_sound;
|
||||
|
||||
PauseType m_pause;
|
||||
std::vector<std::unique_ptr<ActivePause>> m_activePause;
|
||||
};
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "level/robotmain.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
template<> CSettings* CSingleton<CSettings>::m_instance = nullptr;
|
||||
|
||||
CSettings::CSettings()
|
||||
|
|
|
@ -514,7 +514,7 @@ void CEngine::WriteScreenShotThread(std::unique_ptr<WriteScreenShotData> data)
|
|||
|
||||
bool CEngine::GetPause()
|
||||
{
|
||||
return m_pause->GetPause();
|
||||
return m_pause->IsPause();
|
||||
}
|
||||
|
||||
void CEngine::SetShowStats(bool show)
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "object/interface/destroyable_object.h"
|
||||
#include "object/interface/transportable_object.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
// Graphics module namespace
|
||||
namespace Gfx
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include "object/subclass/shielder.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
#include "object/subclass/shielder.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
// Graphics module namespace
|
||||
namespace Gfx
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "app/app.h"
|
||||
#include "app/input.h"
|
||||
#include "app/pausemanager.h"
|
||||
|
||||
#include "common/config_file.h"
|
||||
#include "common/event.h"
|
||||
|
@ -210,7 +211,6 @@ CRobotMain::CRobotMain()
|
|||
m_cheatRadar = false;
|
||||
m_fixScene = false;
|
||||
m_trainerPilot = false;
|
||||
m_suspend = false;
|
||||
m_friendAim = false;
|
||||
m_resetCreate = false;
|
||||
m_shortCut = true;
|
||||
|
@ -431,7 +431,7 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
m_resetCreate = false;
|
||||
m_infoObject = nullptr;
|
||||
|
||||
ChangePause(PAUSE_NONE);
|
||||
m_pause->FlushPause();
|
||||
FlushDisplayInfo();
|
||||
m_engine->SetRankView(0);
|
||||
m_terrain->FlushRelief();
|
||||
|
@ -649,7 +649,8 @@ bool CRobotMain::ProcessEvent(Event &event)
|
|||
MainMovieType type = m_movie->GetStopType();
|
||||
if (type == MM_SATCOMopen)
|
||||
{
|
||||
ChangePause(PAUSE_NONE);
|
||||
m_pause->DeactivatePause(m_satcomMoviePause);
|
||||
m_satcomMoviePause = nullptr;
|
||||
SelectObject(m_infoObject, false); // hands over the command buttons
|
||||
m_map->ShowMap(m_mapShow);
|
||||
m_displayText->HideText(false);
|
||||
|
@ -689,7 +690,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) ChangePause(PAUSE_CHEAT);
|
||||
if (m_phase == PHASE_SIMUL) m_cmdEditPause = m_pause->ActivatePause(PAUSE_CHEAT);
|
||||
m_cmdEdit = true;
|
||||
}
|
||||
return false;
|
||||
|
@ -704,7 +705,11 @@ bool CRobotMain::ProcessEvent(Event &event)
|
|||
pe->GetText(cmd, 50);
|
||||
pe->SetText("");
|
||||
pe->ClearState(Ui::STATE_VISIBLE);
|
||||
if (m_phase == PHASE_SIMUL) ChangePause(PAUSE_NONE);
|
||||
if (m_phase == PHASE_SIMUL)
|
||||
{
|
||||
m_pause->DeactivatePause(m_cmdEditPause);
|
||||
m_cmdEditPause = nullptr;
|
||||
}
|
||||
ExecuteCmd(cmd);
|
||||
m_cmdEdit = false;
|
||||
return false;
|
||||
|
@ -817,11 +822,17 @@ bool CRobotMain::ProcessEvent(Event &event)
|
|||
}
|
||||
if (data->slot == INPUT_SLOT_PAUSE)
|
||||
{
|
||||
if (!m_movieLock && !m_editLock && !m_cmdEdit &&
|
||||
m_camera->GetType() != Gfx::CAM_TYPE_VISIT &&
|
||||
!m_movie->IsExist())
|
||||
if (m_userPause == nullptr)
|
||||
{
|
||||
ChangePause(m_pause->GetPause(PAUSE_USER) || m_pause->GetPause(PAUSE_CODE_BATTLE_LOCK) ? PAUSE_NONE : PAUSE_USER);
|
||||
if (!m_pause->IsPause())
|
||||
{
|
||||
m_userPause = m_pause->ActivatePause(PAUSE_USER);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pause->DeactivatePause(m_userPause);
|
||||
m_userPause = nullptr;
|
||||
}
|
||||
}
|
||||
if (data->slot == INPUT_SLOT_CAMERA)
|
||||
|
@ -1160,12 +1171,13 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
if (m_freePhoto)
|
||||
{
|
||||
m_camera->SetType(Gfx::CAM_TYPE_FREE);
|
||||
ChangePause(PAUSE_PHOTO);
|
||||
m_freePhotoPause = m_pause->ActivatePause(PAUSE_PHOTO);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_camera->SetType(Gfx::CAM_TYPE_BACK);
|
||||
ChangePause(PAUSE_NONE);
|
||||
m_pause->DeactivatePause(m_freePhotoPause);
|
||||
m_freePhotoPause = nullptr;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1177,14 +1189,15 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
{
|
||||
m_camera->SetType(Gfx::CAM_TYPE_FREE);
|
||||
DeselectAll(); // removes the control buttons
|
||||
ChangePause(PAUSE_PHOTO);
|
||||
m_freePhotoPause = m_pause->ActivatePause(PAUSE_PHOTO);
|
||||
m_map->ShowMap(false);
|
||||
m_displayText->HideText(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_camera->SetType(Gfx::CAM_TYPE_BACK);
|
||||
ChangePause(PAUSE_NONE);
|
||||
m_pause->DeactivatePause(m_freePhotoPause);
|
||||
m_freePhotoPause = nullptr;
|
||||
m_map->ShowMap(m_mapShow);
|
||||
m_displayText->HideText(false);
|
||||
}
|
||||
|
@ -1388,7 +1401,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
|
|||
{
|
||||
m_movieInfoIndex = index;
|
||||
m_movie->Start(MM_SATCOMopen, 2.5f);
|
||||
ChangePause(PAUSE_SATCOMMOVIE);
|
||||
m_satcomMoviePause = m_pause->ActivatePause(PAUSE_SATCOMMOVIE);
|
||||
m_infoObject = DeselectAll(); // removes the control buttons
|
||||
m_displayText->HideText(true);
|
||||
return;
|
||||
|
@ -1398,7 +1411,8 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
|
|||
if (m_movie->IsExist())
|
||||
{
|
||||
m_movie->Stop();
|
||||
ChangePause(PAUSE_NONE);
|
||||
m_pause->DeactivatePause(m_satcomMoviePause);
|
||||
m_satcomMoviePause = nullptr;
|
||||
SelectObject(m_infoObject, false); // hands over the command buttons
|
||||
m_displayText->HideText(false);
|
||||
}
|
||||
|
@ -1483,8 +1497,7 @@ void CRobotMain::StartSuspend()
|
|||
{
|
||||
m_sound->MuteAll(true);
|
||||
ClearInterface();
|
||||
m_suspendInitPause = m_pause->GetPauseType();
|
||||
m_pause->SetPause(PAUSE_DIALOG);
|
||||
m_suspend = m_pause->ActivatePause(PAUSE_DIALOG);
|
||||
m_engine->SetOverFront(false); // over flat behind
|
||||
CreateShortcuts();
|
||||
|
||||
|
@ -1494,8 +1507,6 @@ void CRobotMain::StartSuspend()
|
|||
|
||||
m_suspendInitCamera = m_camera->GetType();
|
||||
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
|
||||
|
||||
m_suspend = true;
|
||||
}
|
||||
|
||||
//! End of dialogue during the game
|
||||
|
@ -1503,7 +1514,8 @@ void CRobotMain::StopSuspend()
|
|||
{
|
||||
m_sound->MuteAll(false);
|
||||
ClearInterface();
|
||||
m_pause->SetPause(m_suspendInitPause);
|
||||
m_pause->DeactivatePause(m_suspend);
|
||||
m_suspend = nullptr;
|
||||
m_engine->SetOverFront(true); // over flat front
|
||||
CreateShortcuts();
|
||||
|
||||
|
@ -1513,8 +1525,6 @@ void CRobotMain::StopSuspend()
|
|||
m_displayText->HideText(false);
|
||||
|
||||
m_camera->SetType(m_suspendInitCamera);
|
||||
|
||||
m_suspend = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1615,7 +1625,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
|
|||
m_camera->StartVisit(m_displayText->GetVisitGoal(event),
|
||||
m_displayText->GetVisitDist(event));
|
||||
m_displayText->SetVisit(event);
|
||||
ChangePause(PAUSE_VISIT);
|
||||
m_visitPause = m_pause->ActivatePause(PAUSE_VISIT);
|
||||
}
|
||||
|
||||
//! Move the arrow to visit
|
||||
|
@ -1668,7 +1678,8 @@ void CRobotMain::StopDisplayVisit()
|
|||
|
||||
m_camera->StopVisit();
|
||||
m_displayText->ClearVisit();
|
||||
ChangePause(PAUSE_NONE);
|
||||
m_pause->DeactivatePause(m_visitPause);
|
||||
m_visitPause = nullptr;
|
||||
if (m_visitObject != nullptr)
|
||||
{
|
||||
SelectObject(m_visitObject, false); // gives the command buttons
|
||||
|
@ -2006,7 +2017,7 @@ void CRobotMain::HiliteObject(Math::Point pos)
|
|||
if (obj == nullptr) return;
|
||||
}
|
||||
|
||||
if (m_suspend) return;
|
||||
if (m_suspend != nullptr) return;
|
||||
|
||||
if (obj == nullptr)
|
||||
{
|
||||
|
@ -2329,16 +2340,16 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
}
|
||||
|
||||
m_time += event.rTime;
|
||||
if (!m_movieLock && !m_pause->GetPause())
|
||||
if (!m_movieLock && !m_pause->IsPause())
|
||||
{
|
||||
m_gameTime += event.rTime;
|
||||
m_gameTimeAbsolute += m_app->GetRealRelTime() / 1e9f;
|
||||
}
|
||||
|
||||
if (!m_movieLock && !m_pause->GetPause() && m_missionTimerStarted)
|
||||
if (!m_movieLock && !m_pause->IsPause() && m_missionTimerStarted)
|
||||
m_missionTimer += event.rTime;
|
||||
|
||||
if (!m_pause->GetPause() && m_autosave && m_gameTimeAbsolute >= m_autosaveLast+(m_autosaveInterval*60) && m_phase == PHASE_SIMUL)
|
||||
if (!m_pause->IsPause() && m_autosave && m_gameTimeAbsolute >= m_autosaveLast+(m_autosaveInterval*60) && m_phase == PHASE_SIMUL)
|
||||
{
|
||||
if (m_levelCategory == LevelCategory::Missions ||
|
||||
m_levelCategory == LevelCategory::FreeGame ||
|
||||
|
@ -2460,7 +2471,7 @@ bool CRobotMain::EventFrame(const Event &event)
|
|||
}
|
||||
|
||||
// Moves edition indicator.
|
||||
if (m_editLock || m_pause->GetPause()) // edition in progress?
|
||||
if (m_editLock || m_pause->IsPause()) // edition in progress?
|
||||
{
|
||||
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
|
||||
if (pc != nullptr)
|
||||
|
@ -2567,12 +2578,12 @@ 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_CODE_BATTLE_LOCK);
|
||||
m_userPause = m_pause->ActivatePause(PAUSE_CODE_BATTLE_LOCK);
|
||||
m_sound->MuteAll(false); // Allow sound
|
||||
m_codeBattleInit = true; // Will start on resume
|
||||
}
|
||||
|
||||
if (!m_codeBattleStarted && !m_pause->GetPause())
|
||||
if (!m_codeBattleStarted && m_userPause != nullptr)
|
||||
{
|
||||
m_codeBattleStarted = true;
|
||||
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||
|
@ -5305,20 +5316,6 @@ void CRobotMain::UpdateChapterPassed()
|
|||
}
|
||||
|
||||
|
||||
//! Changes on the pause mode
|
||||
void CRobotMain::ChangePause(PauseType pause)
|
||||
{
|
||||
if (pause != PAUSE_NONE)
|
||||
m_pause->SetPause(pause);
|
||||
else
|
||||
m_pause->ClearPause();
|
||||
|
||||
m_sound->MuteAll(m_pause->GetPause());
|
||||
CreateShortcuts();
|
||||
if (m_pause->GetPause()) HiliteClear();
|
||||
}
|
||||
|
||||
|
||||
//! Changes game speed
|
||||
void CRobotMain::SetSpeed(float speed)
|
||||
{
|
||||
|
@ -5484,11 +5481,18 @@ void CRobotMain::StartMusic()
|
|||
}
|
||||
}
|
||||
|
||||
//! Starts pause music
|
||||
void CRobotMain::StartPauseMusic(PauseType pause)
|
||||
void CRobotMain::UpdatePause(PauseType pause)
|
||||
{
|
||||
switch(pause)
|
||||
m_sound->MuteAll(pause != PAUSE_NONE);
|
||||
CreateShortcuts();
|
||||
if (pause != PAUSE_NONE) HiliteClear();
|
||||
|
||||
switch (pause)
|
||||
{
|
||||
case PAUSE_NONE:
|
||||
m_sound->StopPauseMusic();
|
||||
break;
|
||||
|
||||
case PAUSE_EDITOR:
|
||||
if (m_editorTrack != "")
|
||||
m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat);
|
||||
|
|
|
@ -89,6 +89,8 @@ class CAudioChangeCondition;
|
|||
class CPlayerProfile;
|
||||
class CSettings;
|
||||
class COldObject;
|
||||
class CPauseManager;
|
||||
struct ActivePause;
|
||||
|
||||
namespace Gfx
|
||||
{
|
||||
|
@ -185,8 +187,6 @@ public:
|
|||
void SetTracePrecision(float factor);
|
||||
float GetTracePrecision();
|
||||
|
||||
void ChangePause(PauseType pause);
|
||||
|
||||
void SetSpeed(float speed);
|
||||
float GetSpeed();
|
||||
|
||||
|
@ -256,7 +256,7 @@ public:
|
|||
void UpdateChapterPassed();
|
||||
|
||||
void StartMusic();
|
||||
void StartPauseMusic(PauseType pause);
|
||||
void UpdatePause(PauseType pause);
|
||||
void ClearInterface();
|
||||
void ChangeColor();
|
||||
|
||||
|
@ -465,10 +465,13 @@ protected:
|
|||
CObject* m_selectObject = nullptr;
|
||||
|
||||
Phase m_phase = PHASE_WELCOME1;
|
||||
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;
|
||||
bool m_selectInsect = false;
|
||||
bool m_showSoluce = false;
|
||||
bool m_showAll = false;
|
||||
|
@ -500,8 +503,7 @@ protected:
|
|||
bool m_mapImage = false;
|
||||
char m_mapFilename[100] = {};
|
||||
|
||||
bool m_suspend = false;
|
||||
PauseType m_suspendInitPause = PAUSE_NONE;
|
||||
ActivePause* m_suspend = nullptr;
|
||||
Gfx::CameraType m_suspendInitCamera = Gfx::CAM_TYPE_NULL;
|
||||
|
||||
Math::Point m_tooltipPos;
|
||||
|
@ -513,6 +515,7 @@ protected:
|
|||
int m_infoIndex = 0;
|
||||
int m_infoPos[SATCOM_MAX] = {};
|
||||
int m_infoUsed = 0;
|
||||
ActivePause* m_satcomMoviePause = nullptr;
|
||||
|
||||
char m_title[100] = {};
|
||||
char m_resume[500] = {};
|
||||
|
@ -543,6 +546,7 @@ protected:
|
|||
float m_visitParticle = 0.0f;
|
||||
Math::Vector m_visitPos;
|
||||
Math::Vector m_visitPosArrow;
|
||||
ActivePause* m_visitPause = nullptr;
|
||||
|
||||
std::vector<std::unique_ptr<CSceneEndCondition>> m_endTake;
|
||||
long m_endTakeResearch = 0;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/window.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/window.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
|
||||
const float BASE_LAND_TIME = 7.5f; // hard landing
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/window.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
|
||||
const float DERRICK_DELAY = 10.0f; // duration of the extraction
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/window.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/window.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
|
||||
const float LABO_DELAY = 20.0f; // duration of the analysis
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
const int PARAM_DEPOSE = 2; // run=2 -> deposits the spaceship
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
#include "object/interface/powered_object.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/controls/gauge.h"
|
||||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/window.h"
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
#include "object/interface/transportable_object.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/window.h"
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// Object's constructor.
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
//?const float MARGIN_FRONT = 2.0f;
|
||||
//?const float MARGIN_BACK = 2.0f;
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
const float ENERGY_RECOVER = 0.25f; // energy consumed by recovery
|
||||
const float RECOVER_DIST = 11.8f;
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
// Object's constructor.
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
const float ENERGY_TIME = 20.0f; // maximum duration if full battery
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
const float ENERGY_TERRA = 0.40f; // energy consumed by blow
|
||||
const float ACTION_RADIUS = 400.0f;
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
|
||||
#include "object/task/task.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
|
||||
|
||||
const float LANDING_SPEED = 3.0f;
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "script/script.h"
|
||||
|
||||
#include "app/pausemanager.h"
|
||||
|
||||
#include "common/restext.h"
|
||||
#include "common/stringutils.h"
|
||||
|
||||
|
@ -64,7 +62,6 @@ CScript::CScript(COldObject* object)
|
|||
m_terrain = m_main->GetTerrain();
|
||||
m_water = m_engine->GetWater();
|
||||
m_interface = m_main->GetInterface();
|
||||
m_pause = CPauseManager::GetInstancePointer();
|
||||
|
||||
m_ipf = CBOT_IPF;
|
||||
m_errMode = ERM_STOP;
|
||||
|
@ -322,6 +319,11 @@ void CScript::SetStepMode(bool bStep)
|
|||
m_bStepMode = bStep;
|
||||
}
|
||||
|
||||
bool CScript::GetStepMode()
|
||||
{
|
||||
return m_bStepMode;
|
||||
}
|
||||
|
||||
|
||||
// Runs the program from the beginning.
|
||||
|
||||
|
@ -379,13 +381,8 @@ bool CScript::Continue()
|
|||
GetError(s);
|
||||
m_main->GetDisplayText()->DisplayText(s.c_str(), m_object, 10.0f, Ui::TT_ERROR);
|
||||
}
|
||||
m_pause->SetPause(PAUSE_EDITOR); // gives pause
|
||||
return true;
|
||||
}
|
||||
if ( !m_bContinue )
|
||||
{
|
||||
m_pause->SetPause(PAUSE_EDITOR); // gives pause
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -427,10 +424,6 @@ bool CScript::Step()
|
|||
if ( !m_bRun ) return true;
|
||||
if ( !m_bStepMode ) return false;
|
||||
|
||||
// ??? m_engine->SetPause(false);
|
||||
// TODO: m_app StepSimulation??? m_engine->StepSimulation(0.01f); // advance of 10ms
|
||||
// ??? m_engine->SetPause(true);
|
||||
|
||||
if ( m_botProg->Run(this, 0) ) // step mode
|
||||
{
|
||||
m_botProg->GetError(m_error, m_cursor1, m_cursor2);
|
||||
|
@ -454,14 +447,6 @@ bool CScript::Step()
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( m_bContinue ) // instuction "move", "goto", etc. ?
|
||||
{
|
||||
if (m_pause->GetPauseType() == PAUSE_EDITOR)
|
||||
{
|
||||
m_pause->ClearPause(); // removes the pause
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
class COldObject;
|
||||
class CTaskExecutorObject;
|
||||
class CRobotMain;
|
||||
class CPauseManager;
|
||||
class CScriptFunctions;
|
||||
|
||||
namespace Ui
|
||||
|
@ -70,6 +69,7 @@ public:
|
|||
void GetTitle(char* buffer);
|
||||
|
||||
void SetStepMode(bool bStep);
|
||||
bool GetStepMode();
|
||||
bool Run();
|
||||
bool Continue();
|
||||
bool Step();
|
||||
|
@ -110,7 +110,6 @@ protected:
|
|||
CRobotMain* m_main = nullptr;
|
||||
Gfx::CTerrain* m_terrain = nullptr;
|
||||
Gfx::CWater* m_water = nullptr;
|
||||
CPauseManager* m_pause = nullptr;
|
||||
|
||||
int m_ipf = 0; // number of instructions/second
|
||||
int m_errMode = 0; // what to do in case of error
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "ui/displayinfo.h"
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/pausemanager.h"
|
||||
|
||||
#include "common/misc.h"
|
||||
#include "common/restext.h"
|
||||
|
@ -79,7 +80,6 @@ CDisplayInfo::CDisplayInfo()
|
|||
m_lightSuppl = -1;
|
||||
m_toto = nullptr;
|
||||
m_bSoluce = false;
|
||||
m_initPause = PAUSE_NONE;
|
||||
m_bEditLock = false;
|
||||
m_infoCamera = Gfx::CAM_TYPE_NULL;
|
||||
m_index = -1;
|
||||
|
@ -363,8 +363,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
|
|||
|
||||
m_main->SetEditLock(true, false);
|
||||
m_main->SetEditFull(false);
|
||||
m_initPause = m_pause->GetPauseType();
|
||||
m_pause->SetPause(PAUSE_SATCOM);
|
||||
m_satcomPause = m_pause->ActivatePause(PAUSE_SATCOM);
|
||||
m_infoCamera = m_camera->GetType();
|
||||
m_camera->SetType(Gfx::CAM_TYPE_INFO);
|
||||
|
||||
|
@ -829,9 +828,10 @@ void CDisplayInfo::StopDisplayInfo()
|
|||
}
|
||||
else
|
||||
{
|
||||
m_pause->SetPause(m_initPause);
|
||||
m_main->SetEditLock(false, false);
|
||||
}
|
||||
m_pause->DeactivatePause(m_satcomPause);
|
||||
m_satcomPause = nullptr;
|
||||
m_camera->SetType(m_infoCamera);
|
||||
|
||||
m_engine->SetDrawWorld(true); // draws all on the interface
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "app/pausemanager.h"
|
||||
|
||||
#include "common/event.h"
|
||||
|
||||
#include "graphics/engine/camera.h"
|
||||
|
@ -30,6 +28,8 @@
|
|||
class CRobotMain;
|
||||
class CObject;
|
||||
class CEventQueue;
|
||||
class CPauseManager;
|
||||
struct ActivePause;
|
||||
|
||||
struct Event;
|
||||
|
||||
|
@ -92,7 +92,7 @@ protected:
|
|||
Math::Point m_infoFinalDim;
|
||||
int m_lightSuppl;
|
||||
bool m_bEditLock;
|
||||
PauseType m_initPause;
|
||||
ActivePause* m_satcomPause = nullptr;
|
||||
bool m_bSoluce;
|
||||
CObject* m_toto;
|
||||
};
|
||||
|
|
|
@ -107,7 +107,7 @@ bool CMainShort::CreateShortcuts()
|
|||
m_engine->GetPause()) ) // hangs during edition?
|
||||
{
|
||||
m_interface->CreateShortcut(pos, dim, 128+6, EVENT_OBJECT_EDITLOCK);
|
||||
if(!m_engine->GetPause() || CPauseManager::GetInstancePointer()->GetPauseType() == PAUSE_DIALOG)
|
||||
if (!m_engine->GetPause())
|
||||
return true;
|
||||
}
|
||||
if (m_main->GetFreePhoto() && m_main->GetSelect() == nullptr)
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "level/parser/parser.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/screen/screen_level_list.h"
|
||||
|
||||
#include "ui/controls/button.h"
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "level/parser/parser.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/controls/button.h"
|
||||
#include "ui/controls/group.h"
|
||||
#include "ui/controls/interface.h"
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "graphics/engine/camera.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/controls/button.h"
|
||||
#include "ui/controls/interface.h"
|
||||
#include "ui/controls/label.h"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "CBot/CBotDll.h"
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/pausemanager.h"
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/logger.h"
|
||||
|
@ -92,7 +93,6 @@ CStudio::CStudio()
|
|||
m_bRealTime = true;
|
||||
m_bRunning = false;
|
||||
m_fixInfoTextTime = 0.0f;
|
||||
m_initPause = PAUSE_NONE;
|
||||
m_dialog = SD_NULL;
|
||||
m_editCamera = Gfx::CAM_TYPE_NULL;
|
||||
}
|
||||
|
@ -352,6 +352,22 @@ bool CStudio::EventFrame(const Event &event)
|
|||
list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST));
|
||||
if ( list == nullptr ) return false;
|
||||
|
||||
if (m_script->IsRunning() && (!m_script->GetStepMode() || m_script->IsContinue()))
|
||||
{
|
||||
if (m_editorPause != nullptr)
|
||||
{
|
||||
m_pause->DeactivatePause(m_editorPause);
|
||||
m_editorPause = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_editorPause == nullptr)
|
||||
{
|
||||
m_editorPause = m_pause->ActivatePause(PAUSE_EDITOR);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_script->IsRunning() && m_bRunning ) // stop?
|
||||
{
|
||||
m_bRunning = false;
|
||||
|
@ -557,7 +573,6 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
|
|||
|
||||
m_main->SetEditLock(true, true);
|
||||
m_main->SetEditFull(false);
|
||||
m_initPause = m_pause->GetPauseType();
|
||||
m_main->SetSpeed(1.0f);
|
||||
m_editCamera = m_camera->GetType();
|
||||
m_camera->SetType(Gfx::CAM_TYPE_EDIT);
|
||||
|
@ -889,7 +904,8 @@ bool CStudio::StopEditScript(bool bCancel)
|
|||
|
||||
m_interface->DeleteControl(EVENT_WINDOW3);
|
||||
|
||||
m_pause->SetPause(m_initPause);
|
||||
m_pause->DeactivatePause(m_editorPause);
|
||||
m_editorPause = nullptr;
|
||||
m_sound->MuteAll(false);
|
||||
m_main->SetEditLock(false, true);
|
||||
m_camera->SetType(m_editCamera);
|
||||
|
@ -960,27 +976,22 @@ void CStudio::UpdateFlux()
|
|||
{
|
||||
if ( m_bRealTime ) // run?
|
||||
{
|
||||
if(m_pause->GetPauseType() == PAUSE_EDITOR)
|
||||
{
|
||||
m_pause->ClearPause();
|
||||
m_sound->MuteAll(false);
|
||||
}
|
||||
m_pause->DeactivatePause(m_editorPause);
|
||||
m_editorPause = nullptr;
|
||||
}
|
||||
else // step by step?
|
||||
{
|
||||
if(!m_pause->GetPause())
|
||||
if (m_editorPause == nullptr)
|
||||
{
|
||||
m_pause->SetPause(PAUSE_EDITOR);
|
||||
m_sound->MuteAll(true);
|
||||
m_editorPause = m_pause->ActivatePause(PAUSE_EDITOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // stop?
|
||||
{
|
||||
if(!m_pause->GetPause())
|
||||
if (m_editorPause == nullptr)
|
||||
{
|
||||
m_pause->SetPause(PAUSE_EDITOR);
|
||||
m_sound->MuteAll(true);
|
||||
m_editorPause = m_pause->ActivatePause(PAUSE_EDITOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "app/pausemanager.h"
|
||||
|
||||
#include "common/event.h"
|
||||
|
||||
#include "graphics/engine/camera.h"
|
||||
|
@ -32,6 +30,8 @@ class CScript;
|
|||
class CSoundInterface;
|
||||
class CSettings;
|
||||
struct Program;
|
||||
class CPauseManager;
|
||||
struct ActivePause;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ protected:
|
|||
float m_fixInfoTextTime;
|
||||
bool m_bRunning;
|
||||
bool m_bRealTime;
|
||||
PauseType m_initPause;
|
||||
ActivePause* m_editorPause = nullptr;
|
||||
std::string m_helpFilename;
|
||||
|
||||
StudioDialog m_dialog;
|
||||
|
|
Loading…
Reference in New Issue