29 #include "common/error.h"
32 #include "level/build_type.h"
33 #include "level/level_category.h"
35 #include "level/research_type.h"
40 #include "object/drive_type.h"
41 #include "object/mission_type.h"
43 #include "object/tool_type.h"
75 std::string PhaseToString(Phase phase);
76 bool IsInSimulationConfigPhase(Phase phase);
77 bool IsPhaseWithWorld(Phase phase);
78 bool IsMainMenuPhase(Phase phase);
109 class CMainUserInterface;
120 std::string name =
"";
124 const int MAXSHOWLIMIT = 5;
125 const int MAXSHOWPARTI = 200;
126 const float SHOWLIMITTIME = 20.0f;
128 const int MAXSCENE = 999;
136 int parti[MAXSHOWPARTI] = {};
138 float duration = 0.0f;
143 const int SATCOM_HUSTON = 0;
144 const int SATCOM_SAT = 1;
145 const int SATCOM_OBJECT = 2;
146 const int SATCOM_LOADING = 3;
147 const int SATCOM_PROG = 4;
148 const int SATCOM_SOLUCE = 5;
149 const int SATCOM_MAX = 6;
163 void LoadConfigFile();
165 void ResetAfterDeviceChanged();
178 bool GetSatComLock();
188 float GetTracePrecision();
204 void SetEndMission(Error result,
float delay);
206 Error CheckEndMissionForGroup(std::vector<CSceneEndCondition*>& endTakes);
231 char* GetScriptName();
232 char* GetScriptFile();
235 bool GetInterfaceGlint();
238 bool GetShowSoluce();
239 bool GetSceneSoluce();
242 MissionType GetMissionType();
249 void SetLevel(LevelCategory cat,
int chap,
int rank);
250 LevelCategory GetLevelCategory();
254 void SetReadScene(std::string path);
255 void UpdateChapterPassed();
258 void UpdatePause(PauseType pause);
270 float radius,
float duration=SHOWLIMITTIME);
287 bool IOWriteScene(std::string filename, std::string filecbot, std::string filescreenshot,
const std::string& info,
bool emergencySave =
false);
297 void DisplayError(Error err,
CObject* pObj,
float time=10.0f);
298 void DisplayError(Error err,
Math::Vector goal,
float height=15.0f,
float dist=60.0f,
float time=10.0f);
300 void UpdateCustomLevelList();
301 std::string GetCustomLevelName(
int id);
302 const std::vector<std::string>& GetCustomLevelList();
307 void StartMissionTimer();
309 void SetAutosave(
bool enable);
311 void SetAutosaveInterval(
int interval);
312 int GetAutosaveInterval();
313 void SetAutosaveSlots(
int slots);
314 int GetAutosaveSlots();
331 void SetEnableBuild(
int enableBuild);
336 void SetEnableResearch(
int enableResearch);
341 void SetDoneResearch(
int doneResearch,
int team);
359 Error CanBuildError(
ObjectType type,
int team);
365 Error CanFactoryError(
ObjectType type,
int team);
368 void RemoveFromSelectionHistory(
CObject*
object);
382 void ShowSaveIndicator(
bool show);
384 void CreateScene(
bool soluce,
bool fixScene,
bool resetObject);
387 void LevelLoadingError(
const std::string& error,
const std::runtime_error& exception, Phase exitPhase = PHASE_LEVEL_LIST);
411 void UpdateSpeedLabel();
413 int AutosaveRotate(
bool freeOne);
416 void PushToSelectionHistory(
CObject* obj);
417 CObject* PopFromSelectionHistory();
419 void CreateCodeBattleInterface();
420 void DestroyCodeBattleInterface();
421 void SetCodeBattleSpectatorMode(
bool mode);
438 CInput* m_input =
nullptr;
439 std::unique_ptr<CObjectManager> m_objMan;
440 std::unique_ptr<CMainMovie> m_movie;
441 std::unique_ptr<Gfx::CModelManager> m_modelManager;
442 std::unique_ptr<Gfx::CTerrain> m_terrain;
443 std::unique_ptr<Gfx::CCamera> m_camera;
444 std::unique_ptr<Ui::CMainUserInterface> m_ui;
445 std::unique_ptr<Ui::CMainShort> m_short;
446 std::unique_ptr<Ui::CMainMap> m_map;
447 std::unique_ptr<Ui::CInterface> m_interface;
448 std::unique_ptr<Ui::CDisplayInfo> m_displayInfo;
449 std::unique_ptr<Ui::CDisplayText> m_displayText;
450 std::unique_ptr<CSettings> m_settings;
463 LevelCategory m_levelCategory;
466 std::string m_sceneReadPath;
468 float m_winDelay = 0.0f;
469 float m_lostDelay = 0.0f;
470 bool m_fixScene =
false;
472 CObject* m_selectObject =
nullptr;
474 Phase m_phase = PHASE_WELCOME1;
476 int m_cameraRank = 0;
478 bool m_freePhoto =
false;
480 bool m_cmdEdit =
false;
482 bool m_selectInsect =
false;
483 bool m_showSoluce =
false;
484 bool m_showAll =
false;
485 bool m_cheatRadar =
false;
486 bool m_shortCut =
false;
487 std::string m_audioTrack;
488 bool m_audioRepeat =
false;
489 std::string m_satcomTrack;
490 bool m_satcomRepeat =
false;
491 std::string m_editorTrack;
492 bool m_editorRepeat =
false;
493 int m_movieInfoIndex = 0;
495 CObject* m_controller =
nullptr;
497 MissionType m_missionType = MISSION_NORMAL;
498 bool m_immediatSatCom =
false;
499 bool m_beginSatCom =
false;
500 bool m_lockedSatCom =
false;
501 bool m_movieLock =
false;
502 bool m_satComLock =
false;
503 bool m_editLock =
false;
504 bool m_editFull =
false;
505 bool m_hilite =
false;
506 bool m_trainerPilot =
false;
507 bool m_friendAim =
false;
508 bool m_resetCreate =
false;
509 bool m_mapShow =
false;
510 bool m_mapImage =
false;
511 char m_mapFilename[100] = {};
517 std::string m_tooltipName;
518 float m_tooltipTime = 0.0f;
520 char m_infoFilename[SATCOM_MAX][100] = {};
521 CObject* m_infoObject =
nullptr;
523 int m_infoPos[SATCOM_MAX] = {};
527 char m_title[100] = {};
528 char m_resume[500] = {};
529 char m_scriptName[100] = {};
530 char m_scriptFile[100] = {};
531 int m_endingWinRank = 0;
532 int m_endingLostRank = 0;
533 bool m_winTerminate =
false;
535 float m_globalMagnifyDamage = 0.0f;
537 bool m_exitAfterMission =
false;
539 bool m_codeBattleInit =
false;
540 bool m_codeBattleStarted =
false;
544 std::map<int, std::string> m_teamNames;
546 std::vector<NewScriptName> m_newScriptName;
548 float m_cameraPan = 0.0f;
549 float m_cameraZoom = 0.0f;
552 CObject* m_visitObject =
nullptr;
553 CObject* m_visitArrow =
nullptr;
554 float m_visitTime = 0.0f;
555 float m_visitParticle = 0.0f;
560 std::vector<std::unique_ptr<CSceneEndCondition>> m_endTake;
561 long m_endTakeResearch = 0;
562 float m_endTakeWinDelay = 0.0f;
563 float m_endTakeLostDelay = 0.0f;
565 std::vector<std::unique_ptr<CAudioChangeCondition>> m_audioChange;
567 int m_obligatoryTotal = 0;
568 char m_obligatoryToken[100][20] = {};
569 int m_prohibitedTotal = 0;
570 char m_prohibitedToken[100][20] = {};
579 Error m_missionResult = ERR_OK;
584 std::map<int, Gfx::Color> m_colorNewBot;
591 float m_colorShiftWater = 0.0f;
593 bool m_missionTimerEnabled =
false;
594 bool m_missionTimerStarted =
false;
595 float m_missionTimer = 0.0f;
597 bool m_autosave =
false;
598 int m_autosaveInterval = 0;
599 int m_autosaveSlots = 0;
600 float m_autosaveLast = 0.0f;
602 int m_shotSaving = 0;
604 std::deque<CObject*> m_selectionHistory;
const std::string & GetTeamName(int id)
Returns team name for the given team id.
Definition: robotmain.cpp:5763
void AddNewScriptName(ObjectType type, const std::string &name)
Adds a script name.
Definition: robotmain.cpp:4463
void StartDisplayVisit(EventType event)
Start of the visit instead of an error.
Definition: robotmain.cpp:1584
CameraType
Type of camera.
Definition: camera.h:46
void SetFriendAim(bool friendAim)
Indicates whether mouse is on an friend object, on which we should not shoot.
Definition: robotmain.cpp:5522
Definition: pausemanager.h:45
CSingleton base class for singletons.
void StartMusic()
Starts music with a mission.
Definition: robotmain.cpp:5546
float SearchNearestObject(Math::Vector center, CObject *exclu)
Calculates the distance to the nearest object.
Definition: robotmain.cpp:3993
void StopSuspend()
End of dialogue during the game.
Definition: robotmain.cpp:1558
bool FreeSpace(Math::Vector ¢er, float minRadius, float maxRadius, float space, CObject *exclu)
Calculates a free space.
Definition: robotmain.cpp:4042
ParticleType
Definition: particle.h:63
bool IsResearchEnabled(ResearchType type)
Returns true if the given research is enabled.
Definition: robotmain.cpp:5833
void SetSpeed(float speed)
Changes game speed.
Definition: robotmain.cpp:5391
Definition: displaytext.h:51
bool GetShowMap()
Indicates whether the mini-map is visible.
Definition: robotmain.cpp:5441
void IOWriteSceneFinished()
Notifies the user that scene write is finished.
Definition: robotmain.cpp:4732
void SetTracePrecision(float factor)
Management of the precision of drawing the ground.
Definition: robotmain.cpp:5534
MainMovieType GetMainMovie()
Returns the type of current movie.
Definition: robotmain.cpp:1415
void StopDisplayInfo()
End of displaying of instructions.
Definition: robotmain.cpp:1494
std::string GetCustomLevelDir()
Returns folder name of the scene that user selected to play.
Definition: robotmain.cpp:5373
Definition: robotmain.h:130
bool IsResearchDone(ResearchType type, int team)
Returns true if the given research is done.
Definition: robotmain.cpp:5838
void InitEye()
Initializes the view.
Definition: robotmain.cpp:2388
InputSlot
Available slots for input bindings NOTE: When adding new values, remember to also update keyTable in ...
Definition: key.h:76
bool DeselectObject()
Deselects the selected object.
Definition: robotmain.cpp:1858
void RemoteCamera(float pan, float zoom, float rTime)
Panned with the camera if a button is pressed.
Definition: robotmain.cpp:2336
Definition: robotmain.h:107
void SelectOneObject(CObject *pObj, bool displayError=true)
Selects an object, without attending to deselect the rest.
Definition: robotmain.cpp:1765
Camera handling - CCamera class.
int m_build
Enabled buildings.
Definition: robotmain.h:573
void StartDisplayInfo(int index, bool movie)
Definition: robotmain.cpp:1435
bool m_codeBattleSpectator
Code battle spectator mode, hides object UI, changes camera to CAM_TYPE_PLANE and allows for switchin...
Definition: robotmain.h:542
void HiliteClear()
Removes setting evidence of the object with the mouse hovers over.
Definition: robotmain.cpp:2042
int CreateSpot(Math::Vector pos, Gfx::Color color)
Creates a light spot.
Definition: robotmain.cpp:3813
bool IsSelectable(CObject *pObj)
Indicates whether an object is selectable.
Definition: robotmain.cpp:2000
void KeyCamera(EventType event, InputSlot key)
Remote control the camera using the arrow keys.
Definition: robotmain.cpp:2277
bool CanBuild(ObjectType type, int team)
Retruns true if all requirements to build this object are met (EnableBuild + DoneResearch) ...
Definition: robotmain.cpp:5875
Audio change condition.
Definition: scene_conditions.h:96
float m_gameTime
Playing time since level start.
Definition: robotmain.h:459
void FrameVisit(float rTime)
Move the arrow to visit.
Definition: robotmain.cpp:1677
Definition: singleton.h:30
void ClearInterface()
Removes hilite and tooltip.
Definition: robotmain.cpp:5584
int GetGamerFace()
Returns the representation to use for the player.
Definition: robotmain.cpp:5327
Manager for static models.
Definition: oldmodelmanager.h:55
void CreateTooltip(Math::Point pos, const std::string &text)
Creates a tooltip.
Definition: robotmain.cpp:2144
std::string GetNewScriptName(ObjectType type, int rank)
Seeks a script name for a given type.
Definition: robotmain.cpp:4472
Definition: old_object.h:77
bool CreateShortcuts()
Creates interface shortcuts to the units.
Definition: robotmain.cpp:5426
void SetEditLock(bool lock, bool edit)
Management of the lock mode for the edition.
Definition: robotmain.cpp:5479
CObject * GetSelectObject()
Returns the object that default was select after the creation of a scene.
Definition: robotmain.cpp:1744
Global event queue.
Definition: event.h:840
Manager for dynamic lights in 3D scene.
Definition: lightman.h:146
void ExecuteCmd(char *cmd)
Executes a command.
Definition: robotmain.cpp:1112
Definition: parserline.h:37
int GetObligatoryToken()
Returns the number of instructions required.
Definition: robotmain.cpp:5207
void FlushNewScriptName()
Empty the list.
Definition: robotmain.cpp:4457
void ChangeCamera()
Change the mode of the camera.
Definition: robotmain.cpp:2213
Definition: robotmain.h:151
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:3792
void SetShowLimit(int i, Gfx::ParticleType parti, CObject *pObj, Math::Vector pos, float radius, float duration=SHOWLIMITTIME)
Specifies the boundaries to show.
Definition: robotmain.cpp:4299
Particle engine.
Definition: particle.h:223
void UpdateMap()
Updates the map.
Definition: robotmain.cpp:5435
bool IsTeamColorDefined(int id)
Returns true if team-specific colored texture is available.
Definition: robotmain.cpp:5769
bool FlatFreeSpace(Math::Vector ¢er, float minFlat, float minRadius, float maxRadius, float space, CObject *exclu)
Calculates a flat free space.
Definition: robotmain.cpp:4107
float GetPersoAngle()
Returns the angle of presentation.
Definition: robotmain.cpp:5345
CObject * DeselectAll()
Deselects everything, and returns the object that was selected.
Definition: robotmain.cpp:1751
bool IsLoading()
Returns true if the game is on the loading screen.
Definition: robotmain.cpp:5615
CObject * SearchNearest(Math::Vector pos, CObject *pExclu)
Returns the nearest selectable object from a given position.
Definition: robotmain.cpp:1912
virtual ~CRobotMain()
Destructor of robot application.
Definition: robotmain.cpp:273
float GetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu)
Calculates the maximum radius of a free space.
Definition: robotmain.cpp:4180
Definition: settings.h:31
CObject * IOReadObject(CLevelParserLine *line, const std::string &programDir, const std::string &objCounterText, float objectProgress, int objRank=-1)
Resumes the game.
Definition: robotmain.cpp:4739
Planet manager.
Definition: planet.h:49
CMainMovie - control over movie sequences.
bool SaveFileStack(CObject *pObj, FILE *file, int objRank)
Saves the stack of the program in execution of a robot.
Definition: robotmain.cpp:4426
float GetGlobalMagnifyDamage()
Returns global magnifyDamage setting.
Definition: robotmain.cpp:5936
void ScenePerso()
Load the scene for the character.
Definition: robotmain.cpp:2726
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:4504
bool GetGamerOnlyHead()
Returns the mode with just the head.
Definition: robotmain.cpp:5339
CObject * SearchToto()
Returns the object toto.
Definition: robotmain.cpp:1906
bool IOIsBusy()
Seeks if an object occupies in a spot, to prevent a backup of the game.
Definition: robotmain.cpp:4489
void FlushShowLimit(int i)
Erases the boundaries shown.
Definition: robotmain.cpp:4283
2D point
Definition: point.h:50
void CreateConfigFile()
Creates the file colobot.ini at the first time.
Definition: robotmain.cpp:319
bool CanPlayerInteract()
Returns true if player can interact with things manually.
Definition: robotmain.cpp:5753
bool IsProhibitedToken(const char *token)
Checks if an instruction is not part of the banned list.
Definition: robotmain.cpp:5230
void SelectHuman()
Selects the human.
Definition: robotmain.cpp:1894
Main application.
Definition: app.h:191
void ShowDropZone(CObject *metal, CObject *transporter)
Shows the buildable area when a cube of metal is deposited.
Definition: robotmain.cpp:4209
void UpdateInfoText()
Updates the text information.
Definition: robotmain.cpp:2372
void HiliteObject(Math::Point pos)
Highlights the object with the mouse hovers over.
Definition: robotmain.cpp:2064
int GetDisplayInfoPosition(int index)
Returns the name of the text display.
Definition: robotmain.cpp:1528
void StartSuspend()
Beginning of a dialogue during the game.
Definition: robotmain.cpp:1541
void ChangePhase(Phase phase)
Changes phase.
Definition: robotmain.cpp:383
Entry point into CRobotMain.
Definition: controller.h:40
void SetSatComLock(bool lock)
Management of the blocking of the call of SatCom.
Definition: robotmain.cpp:5468
long m_researchEnable
Available researches.
Definition: robotmain.h:575
Camera moving in 3D scene.
Definition: camera.h:134
void ResetCreate()
Resets all objects to their original position.
Definition: robotmain.cpp:4941
void SetExitAfterMission(bool exit)
Enable mode where completing mission closes the game.
Definition: robotmain.cpp:5748
int GetDoneResearch(int team)
Get/set done researches.
Definition: robotmain.cpp:5797
Management of pause modes.
Terrain loader/generator and manager.
Definition: terrain.h:145
Error CheckEndMission(bool frame)
Checks if the mission is over.
Definition: robotmain.cpp:5031
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:4586
bool IsBuildingEnabled(BuildType type)
Returns true if the given building is enabled.
Definition: robotmain.cpp:5808
Namespace for (new) graphics code.
Definition: app.h:49
void FrameShowLimit(float rTime)
Advances the boundaries shown.
Definition: robotmain.cpp:4346
Definition: player_profile.h:57
The graphics engine.
Definition: engine.h:620
bool ProcessEvent(Event &event)
Processes an event.
Definition: robotmain.cpp:641
bool GetTrainerPilot()
Indicates whether it is possible to control a driving robot.
Definition: robotmain.cpp:5242
CObject * DetectObject(Math::Point pos)
Detects the object aimed by the mouse.
Definition: robotmain.cpp:1953
CObject * SearchHuman()
Returns the object human.
Definition: robotmain.cpp:1900
std::unique_ptr< CPlayerProfile > m_playerProfile
Progress of loaded player.
Definition: robotmain.h:453
bool EventObject(const Event &event)
Makes the event for all robots.
Definition: robotmain.cpp:2693
void HiliteFrame(float rTime)
Highlights the object with the mouse hovers over.
Definition: robotmain.cpp:2127
void SetMovieLock(bool lock)
Management of the lock mode for movies.
Definition: robotmain.cpp:5448
void StartShowLimit()
Mount the boundaries of the selected object.
Definition: robotmain.cpp:4335
void AbortMovie()
Cancels the current movie.
Definition: robotmain.cpp:2356
ObjectType
Type of game object.
Definition: object_type.h:33
void HelpObject()
Displays help for an object.
Definition: robotmain.cpp:2200
Water manager/renderer.
Definition: water.h:74
CObject * GetSelect()
Returns the selected object.
Definition: robotmain.cpp:1936
CRobotMain()
Constructor of robot application.
Definition: robotmain.cpp:123
void CreateScene(bool soluce, bool fixScene, bool resetObject)
Creates the whole scene.
Definition: robotmain.cpp:2761
bool DestroySelectedObject()
Deletes the selected object.
Definition: robotmain.cpp:2024
void HideDropZone(CObject *metal)
Hides buildable area when a cube of metal is taken up.
Definition: robotmain.cpp:4193
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:461
void ResetObject()
Resets all objects to their original position.
Definition: robotmain.cpp:4934
bool SelectObject(CObject *pObj, bool displayError=true)
Selects the object aimed by the mouse.
Definition: robotmain.cpp:1819
bool CanFactory(ObjectType type, int team)
Retruns true if all requirements to create this object in BotFactory are met (DoneResearch) ...
Definition: robotmain.cpp:5903
Undefined.
Definition: camera.h:49
void SaveAllScript()
Saves all programs of all the robots.
Definition: robotmain.cpp:4406
void UpdateAudio(bool frame)
Updates the audiotracks.
Definition: robotmain.cpp:4978
bool ReadFileStack(CObject *pObj, FILE *file, int objRank)
Resumes the execution stack of the program in a robot.
Definition: robotmain.cpp:4441
RGBA color.
Definition: color.h:39
int GetEnableResearch()
Get/set enabled researches.
Definition: robotmain.cpp:5787
void SaveOneScript(CObject *pObj)
Saves all programs of the robot.
Definition: robotmain.cpp:4415
Manages CObject instances.
Definition: object_manager.h:148
void StopDisplayVisit()
End of the visit instead of an error.
Definition: robotmain.cpp:1707
EventType
Type of event message.
Definition: event.h:41
int IsObligatoryToken(const char *token)
Checks if an instruction is part of the obligatory list.
Definition: robotmain.cpp:5219
void ChangeColor()
Change the colors and textures.
Definition: robotmain.cpp:3838
float m_time
Time since level start, including pause and intro movie.
Definition: robotmain.h:457
Event sent by system, interface or game.
Definition: event.h:709
Definition: pausemanager.h:60
void SelectPlayer(std::string playerName)
Changes current player.
Definition: robotmain.cpp:4919
char * GetDisplayInfoName(int index)
Returns the name of the text display.
Definition: robotmain.cpp:1522
void SetDisplayInfoPosition(int index, int pos)
Returns the name of the text display.
Definition: robotmain.cpp:1534
Definition: interface.h:58
Base class for all 3D in-game objects.
Definition: object.h:59
float GetGameTime()
Returns the absolute time of the game.
Definition: robotmain.cpp:1577
void DeleteAllObjects()
Quickly removes all objects.
Definition: robotmain.cpp:1876
bool EventFrame(const Event &event)
Advances the entire scene.
Definition: robotmain.cpp:2396
int GetEnableBuild()
Get/set enabled buildings.
Definition: robotmain.cpp:5777
int GetGamerGlasses()
Returns the representation to use for the player.
Definition: robotmain.cpp:5333
Sound plugin interface.
Definition: sound.h:57
void MarkResearchDone(ResearchType type, int team)
Marks research as done.
Definition: robotmain.cpp:5849
void FlushDisplayInfo()
Clears the display of instructions.
Definition: robotmain.cpp:1422
void SetEditFull(bool full)
Management of the fullscreen mode during editing.
Definition: robotmain.cpp:5504
bool GetFixScene()
Indicates whether the scene is fixed, without interaction.
Definition: robotmain.cpp:5248
Definition: robotmain.h:117
Math::Vector LookatPoint(Math::Vector eye, float angleH, float angleV, float length)
Calculates the point of arrival of the camera.
Definition: robotmain.cpp:2715
std::map< int, int > m_researchDone
Done researches for each team.
Definition: robotmain.h:577
void ClearTooltip()
Clears the previous tooltip.
Definition: robotmain.cpp:2193
void UpdateShortcuts()
Updates all the shortcuts.
Definition: robotmain.cpp:1738
CObject * IOReadScene(std::string filename, std::string filecbot)
Resumes some part of the game.
Definition: robotmain.cpp:4809