OpenXcom  1.0
Open-source clone of the original X-Com
Game.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <list>
21 #include <string>
22 #include <SDL.h>
23 
24 namespace OpenXcom
25 {
26 
27 class State;
28 class Screen;
29 class Cursor;
30 class Language;
31 class SavedGame;
32 class Mod;
33 class FpsCounter;
34 
41 class Game
42 {
43 private:
44  SDL_Event _event;
45  Screen *_screen;
46  Cursor *_cursor;
47  Language *_lang;
48  std::list<State*> _states, _deleted;
49  SavedGame *_save;
50  Mod *_mod;
51  bool _quit, _init;
52  FpsCounter *_fpsCounter;
53  bool _mouseActive;
54  static const double VOLUME_GRADIENT;
55 
56 public:
58  Game(const std::string &title);
60  ~Game();
62  void run();
64  void quit();
66  void setVolume(int sound, int music, int ui);
68  static double volumeExponent(int volume);
70  Screen *getScreen() const;
72  Cursor *getCursor() const;
74  FpsCounter *getFpsCounter() const;
76  void setState(State *state);
78  void pushState(State *state);
80  void popState();
82  Language *getLanguage() const;
84  SavedGame *getSavedGame() const;
86  void setSavedGame(SavedGame *save);
88  Mod *getMod() const;
90  void loadMods();
92  void setMouseActive(bool active);
94  bool isState(State *state) const;
96  bool isQuitting() const;
98  void loadLanguages();
100  void initAudio();
101 };
102 
103 }
Cursor * getCursor() const
Gets the game&#39;s cursor.
Definition: Game.cpp:390
void run()
Starts the game&#39;s state machine.
Definition: Game.cpp:140
A game state that receives user input and reacts accordingly.
Definition: State.h:44
void loadLanguages()
Loads the default and current language.
Definition: Game.cpp:527
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
void loadMods()
Loads the mods specified in the game options.
Definition: Game.cpp:484
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
void popState()
Pops the last state from the state stack.
Definition: Game.cpp:437
void initAudio()
Sets up the audio.
Definition: Game.cpp:607
FpsCounter * getFpsCounter() const
Gets the FpsCounter.
Definition: Game.cpp:399
SavedGame * getSavedGame() const
Gets the currently loaded saved game.
Definition: Game.cpp:457
void quit()
Quits the game.
Definition: Game.cpp:322
void setState(State *state)
Resets the state stack to a new state.
Definition: Game.cpp:410
Language * getLanguage() const
Gets the currently loaded language.
Definition: Game.cpp:448
Contains strings used throughout the game for localization.
Definition: Language.h:39
bool isState(State *state) const
Returns whether current state is the param state.
Definition: Game.cpp:509
void setMouseActive(bool active)
Sets whether the mouse cursor is activated.
Definition: Game.cpp:498
void setSavedGame(SavedGame *save)
Sets a new saved game for the game.
Definition: Game.cpp:466
Screen * getScreen() const
Gets the game&#39;s display screen.
Definition: Game.cpp:381
Game(const std::string &title)
Creates a new game and initializes SDL.
Definition: Game.cpp:53
static double volumeExponent(int volume)
Adjusts a linear volume level to an exponential one.
Definition: Game.cpp:372
Mouse cursor that replaces the system cursor.
Definition: Cursor.h:32
The core of the game engine, manages the game&#39;s entire contents and structure.
Definition: Game.h:41
Mod * getMod() const
Gets the currently loaded mod.
Definition: Game.cpp:476
void pushState(State *state)
Pushes a new state into the state stack.
Definition: Game.cpp:425
Counts the amount of frames each second and displays them in a NumberText surface.
Definition: FpsCounter.h:33
void setVolume(int sound, int music, int ui)
Sets the game&#39;s audio volume.
Definition: Game.cpp:340
~Game()
Cleans up all the game&#39;s resources and shuts down SDL.
Definition: Game.cpp:111
A display screen, handles rendering onto the game window.
Definition: Screen.h:38
bool isQuitting() const
Returns whether the game is shutting down.
Definition: Game.cpp:518
Definition: BaseInfoState.cpp:40