29 #include "common/error.h"
36 #include "level/build_type.h"
37 #include "level/level_category.h"
39 #include "level/research_type.h"
41 #include "object/drive_type.h"
42 #include "object/mission_type.h"
44 #include "object/tool_type.h"
77 std::string PhaseToString(Phase phase);
78 bool IsInSimulationConfigPhase(Phase phase);
79 bool IsPhaseWithWorld(Phase phase);
80 bool IsMainMenuPhase(Phase phase);
110 class CMainUserInterface;
122 std::string name =
"";
126 const int MAXSHOWLIMIT = 5;
127 const int MAXSHOWPARTI = 200;
128 const float SHOWLIMITTIME = 20.0f;
130 const int MAXSCENE = 999;
138 int parti[MAXSHOWPARTI] = {};
140 float duration = 0.0f;
151 const int SATCOM_HUSTON = 0;
152 const int SATCOM_SAT = 1;
153 const int SATCOM_OBJECT = 2;
154 const int SATCOM_LOADING = 3;
155 const int SATCOM_PROG = 4;
156 const int SATCOM_SOLUCE = 5;
157 const int SATCOM_MAX = 6;
182 bool GetSatComLock();
207 Error ProcessEndMissionTakeForGroup(std::vector<CSceneEndCondition*>& endTakes);
225 const std::string& GetScriptName();
226 const std::string& GetScriptFile();
229 bool GetShowSoluce();
230 bool GetSceneSoluce();
233 MissionType GetMissionType();
240 void SetLevel(LevelCategory cat,
int chap,
int rank);
241 LevelCategory GetLevelCategory();
245 void SetReadScene(std::string path);
246 void UpdateChapterPassed();
250 void UpdatePauseMusic(PauseMusic music);
262 float radius,
float duration=SHOWLIMITTIME);
279 bool IOWriteScene(std::string filename, std::string filecbot, std::string filescreenshot,
const std::string& info,
bool emergencySave =
false);
289 void DisplayError(Error err,
CObject* pObj,
float time=10.0f);
290 void DisplayError(Error err,
Math::Vector goal,
float height=15.0f,
float dist=60.0f,
float time=10.0f);
292 void UpdateCustomLevelList();
293 std::string GetCustomLevelName(
int id);
294 const std::vector<std::string>& GetCustomLevelList();
299 void StartMissionTimer();
301 void SetAutosave(
bool enable);
303 void SetAutosaveInterval(
int interval);
304 int GetAutosaveInterval();
305 void SetAutosaveSlots(
int slots);
306 int GetAutosaveSlots();
323 void SetEnableBuild(
int enableBuild);
328 void SetEnableResearch(
int enableResearch);
333 void SetDoneResearch(
int doneResearch,
int team);
351 Error CanBuildError(
ObjectType type,
int team);
357 Error CanFactoryError(
ObjectType type,
int team);
360 void RemoveFromSelectionHistory(
CObject*
object);
369 void SetDebugCrashSpheres(
bool draw);
371 bool GetDebugCrashSpheres();
378 void ShowSaveIndicator(
bool show);
380 void CreateScene(
bool soluce,
bool fixScene,
bool resetObject);
383 void LevelLoadingError(
const std::string& error,
const std::runtime_error& exception, Phase exitPhase = PHASE_LEVEL_LIST);
403 void UpdateSpeedLabel();
405 void AutosaveRotate();
408 void PushToSelectionHistory(
CObject* obj);
409 CObject* PopFromSelectionHistory();
411 void CreateCodeBattleInterface();
412 void DestroyCodeBattleInterface();
413 void SetCodeBattleSpectatorMode(
bool mode);
414 void UpdateDebugCrashSpheres();
429 CInput* m_input =
nullptr;
430 std::unique_ptr<CObjectManager> m_objMan;
431 std::unique_ptr<CMainMovie> m_movie;
432 std::unique_ptr<CPauseManager> m_pause;
433 std::unique_ptr<Gfx::CModelManager> m_modelManager;
434 std::unique_ptr<Gfx::CTerrain> m_terrain;
435 std::unique_ptr<Gfx::CCamera> m_camera;
436 std::unique_ptr<Ui::CMainUserInterface> m_ui;
437 std::unique_ptr<Ui::CMainShort> m_short;
438 std::unique_ptr<Ui::CMainMap> m_map;
439 std::unique_ptr<Ui::CInterface> m_interface;
440 std::unique_ptr<Ui::CDisplayInfo> m_displayInfo;
441 std::unique_ptr<Ui::CDisplayText> m_displayText;
442 std::unique_ptr<Ui::CDebugMenu> m_debugMenu;
443 std::unique_ptr<CSettings> m_settings;
456 LevelCategory m_levelCategory;
461 std::string m_sceneReadPath;
463 float m_winDelay = 0.0f;
464 float m_lostDelay = 0.0f;
465 bool m_fixScene =
false;
467 CObject* m_selectObject =
nullptr;
469 Phase m_phase = PHASE_WELCOME1;
473 bool m_cmdEdit =
false;
475 bool m_selectInsect =
false;
476 bool m_showSoluce =
false;
477 bool m_showAll =
false;
478 bool m_cheatRadar =
false;
479 bool m_shortCut =
false;
480 std::string m_audioTrack;
481 bool m_audioRepeat =
false;
482 std::string m_satcomTrack;
483 bool m_satcomRepeat =
false;
484 std::string m_editorTrack;
485 bool m_editorRepeat =
false;
486 int m_movieInfoIndex = 0;
488 CObject* m_controller =
nullptr;
490 MissionType m_missionType = MISSION_NORMAL;
491 bool m_immediatSatCom =
false;
492 bool m_beginSatCom =
false;
493 bool m_lockedSatCom =
false;
494 bool m_movieLock =
false;
495 bool m_satComLock =
false;
496 bool m_editLock =
false;
497 bool m_editFull =
false;
498 bool m_hilite =
false;
499 bool m_trainerPilot =
false;
500 bool m_friendAim =
false;
501 bool m_resetCreate =
false;
502 bool m_mapShow =
false;
503 bool m_mapImage =
false;
504 char m_mapFilename[100] = {};
509 std::string m_tooltipName;
510 float m_tooltipTime = 0.0f;
512 char m_infoFilename[SATCOM_MAX][100] = {};
513 CObject* m_infoObject =
nullptr;
517 std::string m_scriptName =
"";
518 std::string m_scriptFile =
"";
519 std::string m_endingWin =
"";
520 std::string m_endingLost =
"";
521 bool m_winTerminate =
false;
523 float m_globalMagnifyDamage = 0.0f;
525 bool m_exitAfterMission =
false;
527 bool m_codeBattleInit =
false;
528 bool m_codeBattleStarted =
false;
532 std::map<int, std::string> m_teamNames;
534 std::vector<NewScriptName> m_newScriptName;
537 CObject* m_visitObject =
nullptr;
538 CObject* m_visitArrow =
nullptr;
539 float m_visitTime = 0.0f;
540 float m_visitParticle = 0.0f;
545 std::vector<std::unique_ptr<CSceneEndCondition>> m_endTake;
548 long m_endTakeResearch = 0;
549 float m_endTakeWinDelay = 0.0f;
550 float m_endTakeLostDelay = 0.0f;
552 std::vector<std::unique_ptr<CAudioChangeCondition>> m_audioChange;
554 std::map<std::string, MinMax> m_obligatoryTokens;
563 Error m_missionResult = ERR_OK;
569 std::map<int, Gfx::Color> m_colorNewBot;
573 float m_colorShiftWater = 0.0f;
575 bool m_missionTimerEnabled =
false;
576 bool m_missionTimerStarted =
false;
577 float m_missionTimer = 0.0f;
579 bool m_autosave =
false;
580 int m_autosaveInterval = 0;
581 int m_autosaveSlots = 0;
582 float m_autosaveLast = 0.0f;
584 int m_shotSaving = 0;
586 std::deque<CObject*> m_selectionHistory;
587 bool m_debugCrashSpheres;
const std::string & GetTeamName(int id)
Returns team name for the given team id.
Definition: robotmain.cpp:5574
void AddNewScriptName(ObjectType type, const std::string &name)
Adds a script name.
Definition: robotmain.cpp:4443
void StartDisplayVisit(EventType event)
Start of the visit instead of an error.
Definition: robotmain.cpp:1607
void SetFriendAim(bool friendAim)
Indicates whether mouse is on an friend object, on which we should not shoot.
Definition: robotmain.cpp:5387
Definition: pausemanager.cpp:31
CSingleton base class for singletons.
void StartMusic()
Starts music with a mission.
Definition: robotmain.cpp:5399
float SearchNearestObject(Math::Vector center, CObject *exclu)
Calculates the distance to the nearest object.
Definition: robotmain.cpp:3973
void StopSuspend()
End of dialogue during the game.
Definition: robotmain.cpp:1578
bool FreeSpace(Math::Vector ¢er, float minRadius, float maxRadius, float space, CObject *exclu)
Calculates a free space.
Definition: robotmain.cpp:4022
ParticleType
Definition: particle.h:63
bool IsResearchEnabled(ResearchType type)
Returns true if the given research is enabled.
Definition: robotmain.cpp:5644
void SetSpeed(float speed)
Changes game speed.
Definition: robotmain.cpp:5262
Definition: displaytext.h:51
bool GetShowMap()
Indicates whether the mini-map is visible.
Definition: robotmain.cpp:5312
void IOWriteSceneFinished()
Notifies the user that scene write is finished.
Definition: robotmain.cpp:4685
MainMovieType GetMainMovie()
Returns the type of current movie.
Definition: robotmain.cpp:1452
void StopDisplayInfo()
End of displaying of instructions.
Definition: robotmain.cpp:1526
std::string GetCustomLevelDir()
Returns folder name of the scene that user selected to play.
Definition: robotmain.cpp:5244
bool m_missionResultFromScript
true if m_missionResult has been set by LevelController script, this disables normal EndMissionTake p...
Definition: robotmain.h:565
Definition: robotmain.h:132
bool IsResearchDone(ResearchType type, int team)
Returns true if the given research is done.
Definition: robotmain.cpp:5649
void InitEye()
Initializes the view.
Definition: robotmain.cpp:2346
bool SelectObject(CObject *obj, bool displayError=true)
Selects the object aimed by the mouse.
Definition: robotmain.cpp:1847
bool DeselectObject()
Deselects the selected object.
Definition: robotmain.cpp:1886
Definition: robotmain.h:108
CObject * SearchNearest(Math::Vector pos, CObject *exclu)
Returns the nearest selectable object from a given position.
Definition: robotmain.cpp:1940
Camera handling - CCamera class.
int m_build
Enabled buildings.
Definition: robotmain.h:557
void StartDisplayInfo(int index, bool movie)
Definition: robotmain.cpp:1470
bool m_codeBattleSpectator
Code battle spectator mode, hides object UI, changes camera to CAM_TYPE_PLANE and allows for switchin...
Definition: robotmain.h:530
void HiliteClear()
Removes setting evidence of the object with the mouse hovers over.
Definition: robotmain.cpp:2066
int CreateSpot(Math::Vector pos, Gfx::Color color)
Creates a light spot.
Definition: robotmain.cpp:3796
bool CanBuild(ObjectType type, int team)
Retruns true if all requirements to build this object are met (EnableBuild + DoneResearch) ...
Definition: robotmain.cpp:5686
Audio change condition.
Definition: scene_conditions.h:97
float m_gameTime
Playing time since level start.
Definition: robotmain.h:452
void FrameVisit(float rTime)
Move the arrow to visit.
Definition: robotmain.cpp:1706
Definition: singleton.h:30
void ClearInterface()
Removes hilite and tooltip.
Definition: robotmain.cpp:5438
int GetGamerFace()
Returns the representation to use for the player.
Definition: robotmain.cpp:5196
Manager for static models.
Definition: oldmodelmanager.h:54
void CreateTooltip(Math::Point pos, const std::string &text)
Creates a tooltip.
Definition: robotmain.cpp:2168
std::string GetNewScriptName(ObjectType type, int rank)
Seeks a script name for a given type.
Definition: robotmain.cpp:4452
Definition: old_object.h:79
bool CreateShortcuts()
Creates interface shortcuts to the units.
Definition: robotmain.cpp:5297
void SaveOneScript(CObject *obj)
Saves all programs of the robot.
Definition: robotmain.cpp:4395
void SetEditLock(bool lock, bool edit)
Management of the lock mode for the edition.
Definition: robotmain.cpp:5350
CObject * GetSelectObject()
Returns the object that default was select after the creation of a scene.
Definition: robotmain.cpp:1773
void SetMissionResultFromScript(Error result, float delay)
Set mission result from LevelController script.
Definition: robotmain.cpp:4923
Global event queue.
Definition: event.h:866
void ExecuteCmd(const std::string &cmd)
Executes a command.
Definition: robotmain.cpp:1148
Manager for dynamic lights in 3D scene.
Definition: lightman.h:146
PauseType
Definition: pausemanager.h:35
Definition: parserline.h:37
void SetShowLimit(int i, Gfx::ParticleType parti, CObject *obj, Math::Vector pos, float radius, float duration=SHOWLIMITTIME)
Specifies the boundaries to show.
Definition: robotmain.cpp:4279
std::string m_levelFile
if set, loads this file instead of building from category/chap/rank
Definition: robotmain.h:460
void FlushNewScriptName()
Empty the list.
Definition: robotmain.cpp:4437
void ChangeCamera()
Change the mode of the camera.
Definition: robotmain.cpp:2237
Definition: robotmain.h:159
Cloud layer renderer.
Definition: cloud.h:54
Lightning effect renderer.
Definition: lightning.h:55
int CreateLight(Math::Vector direction, Gfx::Color color)
Creates a directional light.
Definition: robotmain.cpp:3775
Particle engine.
Definition: particle.h:223
bool IsSelectable(CObject *obj)
Indicates whether an object is selectable.
Definition: robotmain.cpp:2024
void UpdateMap()
Updates the map.
Definition: robotmain.cpp:5306
bool IsTeamColorDefined(int id)
Returns true if team-specific colored texture is available.
Definition: robotmain.cpp:5580
bool FlatFreeSpace(Math::Vector ¢er, float minFlat, float minRadius, float maxRadius, float space, CObject *exclu)
Calculates a flat free space.
Definition: robotmain.cpp:4087
float GetPersoAngle()
Returns the angle of presentation.
Definition: robotmain.cpp:5214
CObject * DeselectAll()
Deselects everything, and returns the object that was selected.
Definition: robotmain.cpp:1780
bool IsLoading()
Returns true if the game is on the loading screen.
Definition: robotmain.cpp:5469
virtual ~CRobotMain()
Destructor of robot application.
Definition: robotmain.cpp:280
float GetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu)
Calculates the maximum radius of a free space.
Definition: robotmain.cpp:4160
Definition: settings.h:32
CObject * IOReadObject(CLevelParserLine *line, const std::string &programDir, const std::string &objCounterText, float objectProgress, int objRank=-1)
Resumes the game.
Definition: robotmain.cpp:4692
Planet manager.
Definition: planet.h:49
CMainMovie - control over movie sequences.
float GetGlobalMagnifyDamage()
Returns global magnifyDamage setting.
Definition: robotmain.cpp:5747
void ScenePerso()
Load the scene for the character.
Definition: robotmain.cpp:2676
Scene end condition.
Definition: scene_conditions.h:73
void IOWriteObject(CLevelParserLine *line, CObject *obj, const std::string &programDir, int objRank)
Writes an object into the backup file.
Definition: robotmain.cpp:4484
void SelectOneObject(CObject *obj, bool displayError=true)
Selects an object, without attending to deselect the rest.
Definition: robotmain.cpp:1794
bool GetGamerOnlyHead()
Returns the mode with just the head.
Definition: robotmain.cpp:5208
const std::map< std::string, MinMax > & GetObligatoryTokenList()
Returns the list instructions required in CBot program in level.
Definition: robotmain.cpp:5130
CObject * SearchToto()
Returns the object toto.
Definition: robotmain.cpp:1934
bool IOIsBusy()
Seeks if an object occupies in a spot, to prevent a backup of the game.
Definition: robotmain.cpp:4469
void FlushShowLimit(int i)
Erases the boundaries shown.
Definition: robotmain.cpp:4263
2D point
Definition: point.h:50
bool CanPlayerInteract()
Returns true if player can interact with things manually.
Definition: robotmain.cpp:5564
void SelectHuman()
Selects the human.
Definition: robotmain.cpp:1922
Main application.
Definition: app.h:152
void ShowDropZone(CObject *metal, CObject *transporter)
Shows the buildable area when a cube of metal is deposited.
Definition: robotmain.cpp:4189
void UpdateInfoText()
Updates the text information.
Definition: robotmain.cpp:2330
void HiliteObject(Math::Point pos)
Highlights the object with the mouse hovers over.
Definition: robotmain.cpp:2088
void StartSuspend()
Beginning of a dialogue during the game.
Definition: robotmain.cpp:1558
void ChangePhase(Phase phase)
Changes phase.
Definition: robotmain.cpp:361
void SetSatComLock(bool lock)
Management of the blocking of the call of SatCom.
Definition: robotmain.cpp:5339
long m_researchEnable
Available researches.
Definition: robotmain.h:559
Camera moving in 3D scene.
Definition: camera.h:128
void ResetCreate()
Resets all objects to their original position.
Definition: robotmain.cpp:4870
void SetExitAfterMission(bool exit)
Enable mode where completing mission closes the game.
Definition: robotmain.cpp:5559
int GetDoneResearch(int team)
Get/set done researches.
Definition: robotmain.cpp:5608
Management of pause modes.
Terrain loader/generator and manager.
Definition: terrain.h:147
bool ReadFileStack(CObject *obj, FILE *file, int objRank)
Resumes the execution stack of the program in a robot.
Definition: robotmain.cpp:4421
Error CheckEndMission(bool frame)
Checks if the mission is over.
Definition: robotmain.cpp:5049
bool SaveFileStack(CObject *obj, FILE *file, int objRank)
Saves the stack of the program in execution of a robot.
Definition: robotmain.cpp:4406
bool IOWriteScene(std::string filename, std::string filecbot, std::string filescreenshot, const std::string &info, bool emergencySave=false)
Saves the current game.
Definition: robotmain.cpp:4539
bool IsBuildingEnabled(BuildType type)
Returns true if the given building is enabled.
Definition: robotmain.cpp:5619
Namespace for (new) graphics code.
Definition: app.h:49
void FrameShowLimit(float rTime)
Advances the boundaries shown.
Definition: robotmain.cpp:4326
Definition: player_profile.h:58
The graphics engine.
Definition: engine.h:585
bool ProcessEvent(Event &event)
Processes an event.
Definition: robotmain.cpp:647
bool GetTrainerPilot()
Indicates whether it is possible to control a driving robot.
Definition: robotmain.cpp:5136
CObject * DetectObject(Math::Point pos)
Detects the object aimed by the mouse.
Definition: robotmain.cpp:1976
CObject * SearchHuman()
Returns the object human.
Definition: robotmain.cpp:1928
std::unique_ptr< CPlayerProfile > m_playerProfile
Progress of loaded player.
Definition: robotmain.h:446
Event types, structs and event queue.
bool EventObject(const Event &event)
Makes the event for all robots.
Definition: robotmain.cpp:2653
void HiliteFrame(float rTime)
Highlights the object with the mouse hovers over.
Definition: robotmain.cpp:2151
void SetMovieLock(bool lock)
Management of the lock mode for movies.
Definition: robotmain.cpp:5319
void StartShowLimit()
Mount the boundaries of the selected object.
Definition: robotmain.cpp:4315
void AbortMovie()
Cancels the current movie.
Definition: robotmain.cpp:2304
ObjectType
Type of game object.
Definition: object_type.h:33
void HelpObject()
Displays help for an object.
Definition: robotmain.cpp:2224
Water manager/renderer.
Definition: water.h:72
CObject * GetSelect()
Returns the selected object.
Definition: robotmain.cpp:1964
CRobotMain()
Constructor of robot application.
Definition: robotmain.cpp:131
void CreateScene(bool soluce, bool fixScene, bool resetObject)
Creates the whole scene.
Definition: robotmain.cpp:2711
Definition: robotmain.h:144
bool DestroySelectedObject()
Deletes the selected object.
Definition: robotmain.cpp:2048
void HideDropZone(CObject *metal)
Hides buildable area when a cube of metal is taken up.
Definition: robotmain.cpp:4173
Invalid event / no event.
Definition: event.h:47
Particle rendering - CParticle class (aka particle)
3D (3x1) vector
Definition: vector.h:53
float m_gameTimeAbsolute
Playing time since level start, not dependent on simulation speed.
Definition: robotmain.h:454
void ResetObject()
Resets all objects to their original position.
Definition: robotmain.cpp:4863
bool CanFactory(ObjectType type, int team)
Retruns true if all requirements to create this object in BotFactory are met (DoneResearch) ...
Definition: robotmain.cpp:5714
void SaveAllScript()
Saves all programs of all the robots.
Definition: robotmain.cpp:4386
void UpdateAudio(bool frame)
Updates the audiotracks.
Definition: robotmain.cpp:4907
RGBA color.
Definition: color.h:39
int GetEnableResearch()
Get/set enabled researches.
Definition: robotmain.cpp:5598
Manages CObject instances.
Definition: object_manager.h:148
void StopDisplayVisit()
End of the visit instead of an error.
Definition: robotmain.cpp:1736
EventType
Type of event message.
Definition: event.h:41
void ChangeColor()
Change the colors and textures.
Definition: robotmain.cpp:3821
float m_time
Time since level start, including pause and intro movie.
Definition: robotmain.h:450
Event sent by system, interface or game.
Definition: event.h:735
Definition: pausemanager.h:71
void SelectPlayer(std::string playerName)
Changes current player.
Definition: robotmain.cpp:4848
char * GetDisplayInfoName(int index)
Returns the name of the text display.
Definition: robotmain.cpp:1551
Error ProcessEndMissionTake()
Definition: robotmain.cpp:4960
Definition: interface.h:59
Base class for all 3D in-game objects.
Definition: object.h:63
bool m_endTakeImmediat
If true, the mission ends immediately after completing the requirements without requiring SpaceShip t...
Definition: robotmain.h:547
float GetGameTime()
Returns the absolute time of the game.
Definition: robotmain.cpp:1600
void DeleteAllObjects()
Quickly removes all objects.
Definition: robotmain.cpp:1904
bool EventFrame(const Event &event)
Advances the entire scene.
Definition: robotmain.cpp:2354
int GetEnableBuild()
Get/set enabled buildings.
Definition: robotmain.cpp:5588
int GetGamerGlasses()
Returns the representation to use for the player.
Definition: robotmain.cpp:5202
Sound plugin interface.
Definition: sound.h:60
void MarkResearchDone(ResearchType type, int team)
Marks research as done.
Definition: robotmain.cpp:5660
void FlushDisplayInfo()
Clears the display of instructions.
Definition: robotmain.cpp:1459
void SetEditFull(bool full)
Management of the fullscreen mode during editing.
Definition: robotmain.cpp:5375
bool GetFixScene()
Indicates whether the scene is fixed, without interaction.
Definition: robotmain.cpp:5142
Definition: robotmain.h:119
std::map< int, int > m_researchDone
Done researches for each team.
Definition: robotmain.h:561
void ClearTooltip()
Clears the previous tooltip.
Definition: robotmain.cpp:2217
void UpdateShortcuts()
Updates all the shortcuts.
Definition: robotmain.cpp:1767
CObject * IOReadScene(std::string filename, std::string filecbot)
Resumes some part of the game.
Definition: robotmain.cpp:4738