Let HandleWindowDragging return a boolean status
[openttd/fttd.git] / src / game / game.hpp
blob729044fddd4aadebc9bf6f066e0f85d670165e64
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file game.hpp Base functions for all Games. */
12 #ifndef GAME_HPP
13 #define GAME_HPP
15 #include "../script/script_infolist.hpp"
16 #include "../script/api/script_event_types.hpp"
17 #include "../string.h"
18 #include "../saveload/saveload_buffer.h"
20 /**
21 * Main Game class. Contains all functions needed to start, stop, save and load Game Scripts.
23 class Game {
24 public:
25 /**
26 * Called every game-tick to let Game do something.
28 static void GameLoop();
30 /**
31 * Initialize the Game system.
33 static void Initialize();
35 /**
36 * Start up a new GameScript.
38 static void StartNew();
40 /**
41 * Uninitialize the Game system.
43 static void Uninitialize(bool keepConfig);
45 /**
46 * Suspends the Game Script and then pause the execution of the script. The
47 * script will not be resumed from its suspended state until the script
48 * has been unpaused.
50 static void Pause();
52 /**
53 * Resume execution of the Game Script. This function will not actually execute
54 * the script, but set a flag so that the script is executed my the usual
55 * mechanism that executes the script.
57 static void Unpause();
59 /**
60 * Checks if the Game Script is paused.
61 * @return true if the Game Script is paused, otherwise false.
63 static bool IsPaused();
65 /**
66 * Queue a new event for a Game Script.
68 static void NewEvent(class ScriptEvent *event);
70 /**
71 * Get the current GameScript instance.
73 static class GameInstance *GetGameInstance() { return Game::instance; }
75 /**
76 * Get the current GameInfo.
78 static const class GameInfo *GetInfo() { return Game::info; }
80 static void Rescan();
81 static void ResetConfig();
83 /**
84 * Save data from a GameScript to a savegame.
86 static void Save(SaveDumper *dumper);
88 /**
89 * Load data for a GameScript from a savegame.
91 static void Load(LoadBuffer *reader, int version);
93 /** Wrapper function for GameScanner::GetConsoleList */
94 static void GetConsoleList (stringb *buf, bool newest_only = false);
95 /** Wrapper function for GameScanner::GetConsoleLibraryList */
96 static void GetConsoleLibraryList (stringb *buf);
97 /** Wrapper function for GameScanner::GetUniqueInfoList */
98 static const ScriptInfoList::List *GetUniqueInfoList();
99 /** Wrapper function for GameScannerInfo::FindInfo */
100 static class GameInfo *FindInfo(const char *name, int version, bool force_exact_match);
101 /** Wrapper function for GameScanner::FindLibrary */
102 static class GameLibrary *FindLibrary(const char *library, int version);
105 * Get the current active instance.
107 static class GameInstance *GetInstance() { return Game::instance; }
109 #if defined(ENABLE_NETWORK)
110 /** Wrapper function for GameScanner::HasGame */
111 static bool HasGame(const struct ContentInfo *ci, bool md5sum);
112 static bool HasGameLibrary(const ContentInfo *ci, bool md5sum);
114 static const char *FindInfoMainScript (const ContentInfo *ci);
115 static const char *FindLibraryMainScript (const ContentInfo *ci);
116 #endif
117 private:
118 static uint frame_counter; ///< Tick counter for the Game code.
119 static class GameInstance *instance; ///< Instance to the current active Game.
120 static const class GameInfo *info; ///< Current selected GameInfo.
123 #endif /* GAME_HPP */