zenilib: Zeni::Game Class Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Public Attributes | Friends | List of all members
Zeni::Game Class Reference
Zenilib

The Gamestate Stack. More...

`#include <Game.h>`

Inherits Zeni::Singleton< Game >.

## Classes

struct | Controller_Mouse

## Public Member Functions

Console_State & | get_console ()
| Get a reference to the Console_State. More...
Sint16 | get_controller_axis_state (const int &which, const SDL_GameControllerAxis &axis) const
| Get the state of a joystick axis. More...
bool | get_controller_button_state (const int &which, const SDL_GameControllerButton &button) const
| Get the state of a joystick button. More...
size_t | get_fps () const
| Get the current approximation of the frames displayed per second. More...
bool | get_key_state (const int &key) const
| Get the state of a key. More...
bool | get_mouse_button_state (const int &button) const
| Get the state of a mouse button. More...
Gamestate | get_top ()
| Get a reference to the current Gamestate. More...
bool | is_console_active () const
void | on_event (const SDL_Event &event)
| Called in main, calls the function by the same name in the current Gamestate. More...
void | perform_logic ()
| Called in main, calls the function by the same name in the current Gamestate. More...
Gamestate | pop_state ()
| Pop a Gamestate off the stack. Pop the current Gamestate with caution. All members will instantly become invalid. More...
void | prerender ()
| Called in main, calls the function by the same name in the current Gamestate. More...
void | push_Popup_Menu_State ()
void | push_Popup_Pause_State ()
void | push_state (const Gamestate &state)
| Push a new Gamestate onto the stack. More...
void | render ()
| Called in main, calls the function by the same name in the current Gamestate. More...
void | replace_Popup_Menu_State_Factory (Popup_Menu_State_Factory *const popup_menu_state_factory)
void | replace_Popup_Pause_State_Factory (Popup_Pause_State_Factory *const popup_pause_state_factory)
void | run ()
size_t | size () const
| Get the current size of the Gamestate stack. More...
void | write_to_console (const String &text)
| Write text to the console when in Debug mode. More...
Public Member Functions inherited from Zeni::Singleton< Game >
void | fax_post_reinit (Event::Handler *const &handler)
void | fax_pre_uninit (Event::Handler *const &handler)
void | give_post_reinit (Event::Handler *const &handler)
void | give_pre_uninit (Event::Handler *const &handler)
void | lend_post_reinit (Event::Handler *const &handler)
void | lend_pre_uninit (Event::Handler *const &handler)

## Public Attributes

struct Zeni::Game::Controller_Mouse | controller_mouse

## Friends

class | Singleton< Game >

## Additional Inherited Members

Static Public Member Functions inherited from Zeni::Singleton< Game >
static void | completely_destroy ()
static void | destroy ()
static Game & | get ()
static bool | is_initialized ()
static void | remove_post_reinit (Event::Handler *const &handler)
static void | remove_pre_uninit (Event::Handler *const &handler)
Protected Member Functions inherited from Zeni::Singleton< Game >
| Singleton ()
virtual | ~Singleton ()

## Detailed Description

The Gamestate Stack.

This singleton is a stack of Gamestates. The main function continually refers to the Game singleton to get the current Gamestate.

Author
  bazald

Contact: bazal.nosp@m.d@ze.nosp@m.nipex.nosp@m..com

Definition at line 71 of file Game.h.

## Member Function Documentation

Console_State & Zeni::Game::get_console | ( |  | ) |

Get a reference to the Console_State.

Definition at line 63 of file Game.cpp.

Sint16 Zeni::Game::get_controller_axis_state | ( | const int & | which,
|  | const SDL_GameControllerAxis & | axis
| ) |  | const

Get the state of a joystick axis.

Definition at line 301 of file Game.cpp.

bool Zeni::Game::get_controller_button_state | ( | const int & | which,
|  | const SDL_GameControllerButton & | button
| ) |  | const

Get the state of a joystick button.

Definition at line 313 of file Game.cpp.

Referenced by Zeni::Gamestate_II::fire_missed_events().

size_t Zeni::Game::get_fps | ( |  | ) | const

inline

Get the current approximation of the frames displayed per second.

Definition at line 41 of file Game.hxx.

bool Zeni::Game::get_key_state | ( | const int & | key | ) | const

Get the state of a key.

Definition at line 287 of file Game.cpp.

Referenced by Zeni::Gamestate_II::fire_missed_events(), Zeni::Text_Box::on_key(), and Zeni::Gamestate_Base::to_char().

bool Zeni::Game::get_mouse_button_state | ( | const int & | button | ) | const

Get the state of a mouse button.

Definition at line 294 of file Game.cpp.

Referenced by Zeni::Gamestate_II::fire_missed_events().

Gamestate Zeni::Game::get_top | ( |  | ) |

inline

Get a reference to the current Gamestate.

Definition at line 30 of file Game.hxx.

bool Zeni::Game::is_console_active | ( |  | ) | const

Definition at line 598 of file Game.cpp.

void Zeni::Game::on_event | ( | const SDL_Event & | event | ) |

Called in main, calls the function by the same name in the current Gamestate.

Definition at line 123 of file Game.cpp.

References SDL_ControllerAxisEvent::axis, SDL_MouseButtonEvent::button, SDL_ControllerButtonEvent::button, SDL_Event::button, SDL_Event::caxis, SDL_Event::cbutton, SDL_Event::cdevice, Zeni::Controllers::device_added(), Zeni::Controllers::get_controller_index(), Zeni::get_Controllers(), SDL_Event::key, SDL_KeyboardEvent::keysym, memcpy, Zeni::Gamestate::on_event(), SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_KEYDOWN, SDL_KEYUP, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_Keysym::sym, SDL_Event::type, SDL_ControllerAxisEvent::value, SDL_ControllerAxisEvent::which, SDL_ControllerButtonEvent::which, and SDL_ControllerDeviceEvent::which.

void Zeni::Game::perform_logic | ( |  | ) |

Called in main, calls the function by the same name in the current Gamestate.

Definition at line 210 of file Game.cpp.

References Zeni::Gamestate::perform_logic().

Gamestate Zeni::Game::pop_state | ( |  | ) |

Pop a Gamestate off the stack. Pop the current Gamestate with caution. All members will instantly become invalid.

Definition at line 90 of file Game.cpp.

References Zeni::Gamestate::on_pop().

Referenced by Zeni::Popup_Pause_State::on_active(), and Zeni::Popup_State::on_key().

void Zeni::Game::prerender | ( |  | ) |

Called in main, calls the function by the same name in the current Gamestate.

Definition at line 235 of file Game.cpp.

References Zeni::Gamestate::prerender().

Referenced by engine_draw_frame().

void Zeni::Game::push_Popup_Menu_State | ( |  | ) |

Definition at line 547 of file Game.cpp.

Referenced by Zeni::Gamestate_II::on_event(), and Zeni::Gamestate_Base::on_key().

void Zeni::Game::push_Popup_Pause_State | ( |  | ) |

Definition at line 551 of file Game.cpp.

Referenced by Zeni::Gamestate_Base::on_active().

void Zeni::Game::push_state | ( | const Gamestate & | state | ) |

Push a new Gamestate onto the stack.

Definition at line 76 of file Game.cpp.

Referenced by main2(), Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::Play_Button::on_accept(), Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::Instructions_Button::on_accept(), and Zeni::Popup_Menu_State::Configure_Video_Button::on_accept().

void Zeni::Game::render | ( |  | ) |

Called in main, calls the function by the same name in the current Gamestate.

Definition at line 260 of file Game.cpp.

References Zeni::Gamestate::render().

Referenced by engine_draw_frame().

void Zeni::Game::replace_Popup_Menu_State_Factory | ( | Popup_Menu_State_Factory *const | popup_menu_state_factory | ) |

Definition at line 555 of file Game.cpp.

References assert.

void Zeni::Game::replace_Popup_Pause_State_Factory | ( | Popup_Pause_State_Factory *const | popup_pause_state_factory | ) |

Definition at line 561 of file Game.cpp.

References assert.

void Zeni::Game::run | ( |  | ) |

Definition at line 325 of file Game.cpp.

References Zeni::Video::begin_prerender(), Zeni::Video::begin_render(), SDL_MouseButtonEvent::button, SDL_Event::button, SDL_Event::common, destroy(), Zeni::Controllers::detect_removed(), e, Zeni::Video::end_render(), Zeni::Random::frand_lte(), Zeni::get_Controllers(), Zeni::Window::get_height(), Zeni::Time::get_seconds_since(), Zeni::get_Sound(), Zeni::get_Sound_Source_Pool(), Zeni::get_Video(), Zeni::Window::get_width(), Zeni::get_Window(), gui, int, SDL_Event::key, SDL_KeyboardEvent::keysym, max, min, SDL_Keysym::mod, NASTY_MAX_RATE, NASTY_MIN_RATE, NASTY_RATE_CUTOFF, NASTY_ZERO_STEP_FREQUENCY, Zeni::Random::rand_lt(), Zeni::render(), SDL_Keysym::scancode, SDL_BUTTON_LEFT, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP, SDL_GetModState(), SDL_GetMouseState(), SDL_GetWindowID(), SDL_KEYDOWN, SDL_KEYUP, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_PollEvent(), SDL_QUIT, SDL_SCANCODE_ESCAPE, SDL_WarpMouseInWindow(), SDL_WINDOWEVENT, SDL_WINDOWEVENT_CLOSE, SDLK_BACKQUOTE, SDLK_ESCAPE, SDLK_F4, SDLK_LALT, SDLK_LCTRL, SDLK_LGUI, SDLK_LSHIFT, SDLK_q, SDLK_RALT, SDLK_RCTRL, SDLK_RGUI, SDLK_RSHIFT, SDL_KeyboardEvent::state, SDL_MouseButtonEvent::state, SDL_Keysym::sym, SDL_CommonEvent::timestamp, SDL_CommonEvent::type, u, Zeni::Sound::update(), Zeni::Sound_Source_Pool::update(), SDL_Event::wheel, SDL_MouseButtonEvent::which, SDL_MouseWheelEvent::which, SDL_MouseWheelEvent::windowID, Zeni::Point2f::x, SDL_MouseButtonEvent::x, SDL_MouseWheelEvent::x, Zeni::Point2f::y, SDL_MouseButtonEvent::y, and SDL_MouseWheelEvent::y.

Referenced by main2().

size_t Zeni::Game::size | ( |  | ) | const

inline

Get the current size of the Gamestate stack.

Definition at line 37 of file Game.hxx.

void Zeni::Game::write_to_console | ( | const String & | text | ) |

Write text to the console when in Debug mode.

Definition at line 69 of file Game.cpp.

References Zeni::Console_State::write_to_log().

## Friends And Related Function Documentation

friend class Singleton< Game >

friend

Definition at line 72 of file Game.h.

## Member Data Documentation

struct Zeni::Game::Controller_Mouse Zeni::Game::controller_mouse

Referenced by Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::on_cover(), Zeni::Widget_Gamestate::on_pop(), Zeni::Widget_Gamestate::on_push(), Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::on_push(), and Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >::on_uncover().

The documentation for this class was generated from the following files:

- zenilib/jni/external/zenilib/zeni_rest/Zeni/Game.h
- zenilib/jni/external/zenilib/zeni_rest/Game.cpp
- zenilib/jni/external/zenilib/zeni_rest/Zeni/Game.hxx