OpenXcom
1.0
Open-source clone of the original X-Com
|
The core of the game engine, manages the game's entire contents and structure. More...
#include <Game.h>
Public Member Functions | |
Game (const std::string &title) | |
Creates a new game and initializes SDL. More... | |
~Game () | |
Cleans up all the game's resources and shuts down SDL. More... | |
void | run () |
Starts the game's state machine. More... | |
void | quit () |
Quits the game. More... | |
void | setVolume (int sound, int music, int ui) |
Sets the game's audio volume. More... | |
Screen * | getScreen () const |
Gets the game's display screen. More... | |
Cursor * | getCursor () const |
Gets the game's cursor. More... | |
FpsCounter * | getFpsCounter () const |
Gets the FpsCounter. More... | |
void | setState (State *state) |
Resets the state stack to a new state. More... | |
void | pushState (State *state) |
Pushes a new state into the state stack. More... | |
void | popState () |
Pops the last state from the state stack. More... | |
Language * | getLanguage () const |
Gets the currently loaded language. More... | |
void | loadLanguage (const std::string &filename) |
Loads a new language for the game. More... | |
ResourcePack * | getResourcePack () const |
Gets the currently loaded resource pack. More... | |
void | setResourcePack (ResourcePack *res) |
Sets a new resource pack for the game. More... | |
SavedGame * | getSavedGame () const |
Gets the currently loaded saved game. More... | |
void | setSavedGame (SavedGame *save) |
Sets a new saved game for the game. More... | |
Ruleset * | getRuleset () const |
Gets the currently loaded ruleset. More... | |
void | loadRuleset () |
Loads a new ruleset for the game. More... | |
void | setMouseActive (bool active) |
Sets whether the mouse cursor is activated. More... | |
bool | isState (State *state) const |
Returns whether current state is the param state. More... | |
bool | isQuitting () const |
Returns whether the game is shutting down. More... | |
void | defaultLanguage () |
Sets up the default language. More... | |
void | initAudio () |
Sets up the audio. More... | |
Static Public Member Functions | |
static double | volumeExponent (int volume) |
Adjusts a linear volume level to an exponential one. | |
The core of the game engine, manages the game's entire contents and structure.
Takes care of encapsulating all the core SDL commands, provides access to all the game's resources and contains a stack state machine to handle all the initializations, events and blits of each state, as well as transitions.
OpenXcom::Game::Game | ( | const std::string & | title | ) |
Creates a new game and initializes SDL.
Starts up SDL with all the subsystems and SDL_mixer for audio processing, creates the display screen and sets up the cursor.
title | Title of the game window. |
OpenXcom::Game::~Game | ( | ) |
Cleans up all the game's resources and shuts down SDL.
Deletes the display screen, cursor, states and shuts down all the SDL subsystems.
void OpenXcom::Game::defaultLanguage | ( | ) |
Sets up the default language.
Loads the most appropriate language given current system and game options.
Cursor * OpenXcom::Game::getCursor | ( | ) | const |
Gets the game's cursor.
Returns the mouse cursor used by the game.
FpsCounter * OpenXcom::Game::getFpsCounter | ( | ) | const |
Language * OpenXcom::Game::getLanguage | ( | ) | const |
Gets the currently loaded language.
Returns the language currently in use by the game.
ResourcePack * OpenXcom::Game::getResourcePack | ( | ) | const |
Gets the currently loaded resource pack.
Returns the resource pack currently in use by the game.
Ruleset * OpenXcom::Game::getRuleset | ( | ) | const |
Gets the currently loaded ruleset.
Returns the ruleset currently in use by the game.
SavedGame * OpenXcom::Game::getSavedGame | ( | ) | const |
Gets the currently loaded saved game.
Returns the saved game currently in use by the game.
Screen * OpenXcom::Game::getScreen | ( | ) | const |
Gets the game's display screen.
Returns the display screen used by the game.
void OpenXcom::Game::initAudio | ( | ) |
Sets up the audio.
Initializes the audio subsystem.
bool OpenXcom::Game::isQuitting | ( | ) | const |
Returns whether the game is shutting down.
Checks if the game is currently quitting.
bool OpenXcom::Game::isState | ( | State * | state | ) | const |
Returns whether current state is the param state.
Returns whether current state is *state.
state | The state to test against the stack state |
void OpenXcom::Game::loadLanguage | ( | const std::string & | filename | ) |
Loads a new language for the game.
Changes the language currently in use by the game.
filename | Filename of the language file. |
void OpenXcom::Game::loadRuleset | ( | ) |
Loads a new ruleset for the game.
Loads the rulesets specified in the game options.
void OpenXcom::Game::popState | ( | ) |
Pops the last state from the state stack.
Pops the last state from the top of the stack.
Since states can't actually be deleted mid-cycle, it's moved into a separate queue which is cleared at the start of every cycle, so the transition is seamless.
void OpenXcom::Game::pushState | ( | State * | state | ) |
Pushes a new state into the state stack.
Pushes a new state into the top of the stack and initializes it.
The new state will be used once the next game cycle starts.
state | Pointer to the new state. |
void OpenXcom::Game::quit | ( | ) |
Quits the game.
Stops the state machine and the game is shut down.
void OpenXcom::Game::run | ( | ) |
Starts the game's state machine.
The state machine takes care of passing all the events from SDL to the active state, running any code within and blitting all the states and cursor to the screen.
This is run indefinitely until the game quits.
void OpenXcom::Game::setMouseActive | ( | bool | active | ) |
Sets whether the mouse cursor is activated.
Sets whether the mouse is activated.
If it is, mouse events are processed, otherwise they are ignored and the cursor is hidden.
active | Is mouse activated? |
void OpenXcom::Game::setResourcePack | ( | ResourcePack * | res | ) |
Sets a new resource pack for the game.
Sets a new resource pack for the game to use.
res | Pointer to the resource pack. |
void OpenXcom::Game::setSavedGame | ( | SavedGame * | save | ) |
Sets a new saved game for the game.
Sets a new saved game for the game to use.
save | Pointer to the saved game. |
void OpenXcom::Game::setState | ( | State * | state | ) |
Resets the state stack to a new state.
Pops all the states currently in stack and pushes in the new state.
A shortcut for cleaning up all the old states when they're not necessary like in one-way transitions.
state | Pointer to the new state. |
void OpenXcom::Game::setVolume | ( | int | sound, |
int | music, | ||
int | ui | ||
) |