zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Zeni::Gamestate_Base Class Reference

The base class for all gamestates. More...

#include <Gamestate.h>

Inherited by Modern_State, Play_State, Play_State, Zeni::Console_State, Zeni::Gamestate_II, and Zeni::Widget_Gamestate.

Public Member Functions

 Gamestate_Base ()
 
virtual ~Gamestate_Base ()
 
const bool & is_pausable () const
 
virtual void on_cover ()
 Called when a Gamestate is pushed on top of this Gamestate in Game. More...
 
virtual void on_event (const SDL_Event &event)
 First check for events. Called by Game as part of the main gameloop. More...
 
virtual void on_pop ()
 Called when the Gamestate is popped off the stack in Game. More...
 
virtual void on_push ()
 Called when the Gamestate is pushed onto the stack in Game. More...
 
virtual void on_uncover ()
 Called when a Gamestate is popped off Game, making this Gamestate on top. More...
 
virtual void perform_logic ()
 Then perform logic. Called by Game as part of the main gameloop. More...
 
virtual void prerender ()
 No actual rendering, but any logic strictly necessary for rendering. More...
 
virtual void render ()
 Then render. Called by Game as part of the main gameloop. More...
 
void set_pausable (const bool &pausable_)
 

Static Public Member Functions

static char to_char (const SDL_Keysym &ks)
 Returns a character key corresponding to the current combination of keys pressed or the null character (0). More...
 
static SDL_Keycode to_sym (const String &text_version)
 Convert a text representation to an actual sym. More...
 
static String to_text (const SDL_Keycode &sym)
 Convert a sym to a text representation. More...
 

Protected Member Functions

virtual void on_active (const SDL_ActiveEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_controller_axis (const SDL_ControllerAxisEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_controller_button (const SDL_ControllerButtonEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_controller_device (const SDL_ControllerDeviceEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_key (const SDL_KeyboardEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_mouse_button (const SDL_MouseButtonEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_mouse_motion (const SDL_MouseMotionEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_quit (const SDL_QuitEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_system_wm_event (const SDL_SysWMEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_user_event (const SDL_UserEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_video_expose (const SDL_ExposeEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 
virtual void on_video_resize (const SDL_ResizeEvent &event)
 Override this input callback in your Gamestates. See SDL documentation for details. More...
 

Friends

class Gamestate
 

Detailed Description

The base class for all gamestates.

Gamestate_Base provides virtual functions to be overridden by derived classes. It is expected that all input handling will be done in the provided callback functions. It is required that all rendering be done in the render function.

Note
You can ignore any callback functions you aren't using.
Author
bazald

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

Definition at line 82 of file Gamestate.h.

Constructor & Destructor Documentation

Zeni::Gamestate_Base::Gamestate_Base ( )
inline

Definition at line 89 of file Gamestate.h.

virtual Zeni::Gamestate_Base::~Gamestate_Base ( )
inlinevirtual

Definition at line 90 of file Gamestate.h.

Member Function Documentation

const bool & Zeni::Gamestate_Base::is_pausable ( ) const
inline

Definition at line 25 of file Gamestate.hxx.

Referenced by Zeni::Gamestate::is_pausable().

void Zeni::Gamestate_Base::on_active ( const SDL_ActiveEvent &  event)
protectedvirtual
void Zeni::Gamestate_Base::on_controller_axis ( const SDL_ControllerAxisEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 115 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_controller_button ( const SDL_ControllerButtonEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 118 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_controller_device ( const SDL_ControllerDeviceEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 121 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_cover ( )
virtual

Called when a Gamestate is pushed on top of this Gamestate in Game.

Reimplemented in Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >.

Definition at line 1104 of file Gamestate.cpp.

Referenced by Zeni::Gamestate::on_cover().

void Zeni::Gamestate_Base::on_key ( const SDL_KeyboardEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Reimplemented in Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >, Zeni::Popup_State, and Zeni::Widget_Gamestate.

Definition at line 99 of file Gamestate.cpp.

References Zeni::get_Game(), SDL_KeyboardEvent::keysym, Zeni::Game::push_Popup_Menu_State(), SDL_PRESSED, SDLK_ESCAPE, SDL_KeyboardEvent::state, and SDL_Keysym::sym.

Referenced by on_event(), and Zeni::Widget_Gamestate::on_key().

void Zeni::Gamestate_Base::on_mouse_button ( const SDL_MouseButtonEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Reimplemented in Zeni::Widget_Gamestate.

Definition at line 107 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_mouse_motion ( const SDL_MouseMotionEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Reimplemented in Zeni::Widget_Gamestate.

Definition at line 104 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_pop ( )
virtual

Called when the Gamestate is popped off the stack in Game.

Reimplemented in Zeni::Popup_Menu_State, Zeni::Popup_State, and Zeni::Widget_Gamestate.

Definition at line 1110 of file Gamestate.cpp.

Referenced by Zeni::Gamestate::on_pop().

void Zeni::Gamestate_Base::on_push ( )
virtual

Called when the Gamestate is pushed onto the stack in Game.

Reimplemented in Zeni::Popup_Menu_State, Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >, Zeni::Gamestate_II, Zeni::Widget_Gamestate, and Zeni::Popup_State.

Definition at line 1101 of file Gamestate.cpp.

Referenced by Zeni::Gamestate::on_push().

void Zeni::Gamestate_Base::on_quit ( const SDL_QuitEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 124 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_system_wm_event ( const SDL_SysWMEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 127 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_uncover ( )
virtual

Called when a Gamestate is popped off Game, making this Gamestate on top.

Reimplemented in Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >, and Zeni::Gamestate_II.

Definition at line 1107 of file Gamestate.cpp.

Referenced by Zeni::Gamestate::on_uncover().

void Zeni::Gamestate_Base::on_user_event ( const SDL_UserEvent event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 181 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_video_expose ( const SDL_ExposeEvent &  event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 177 of file Gamestate.cpp.

Referenced by on_event().

void Zeni::Gamestate_Base::on_video_resize ( const SDL_ResizeEvent &  event)
protectedvirtual

Override this input callback in your Gamestates. See SDL documentation for details.

Definition at line 170 of file Gamestate.cpp.

References Zeni::Video::change_resolution(), and Zeni::Video::save().

Referenced by on_event().

virtual void Zeni::Gamestate_Base::perform_logic ( )
inlinevirtual

Then perform logic. Called by Game as part of the main gameloop.

Reimplemented in Zeni::Popup_Pause_State, Zeni::Title_State< PLAY_STATE, INSTRUCTIONS_STATE >, Zeni::Popup_State, and Zeni::Widget_Gamestate.

Definition at line 101 of file Gamestate.h.

Referenced by Zeni::Gamestate::perform_logic().

virtual void Zeni::Gamestate_Base::prerender ( )
inlinevirtual

No actual rendering, but any logic strictly necessary for rendering.

Reimplemented in Zeni::Popup_State.

Definition at line 103 of file Gamestate.h.

Referenced by Zeni::Popup_State::prerender(), and Zeni::Gamestate::prerender().

void Zeni::Gamestate_Base::render ( )
virtual

Then render. Called by Game as part of the main gameloop.

Reimplemented in Zeni::Popup_Pause_State, Zeni::Popup_State, and Zeni::Widget_Gamestate.

Definition at line 1093 of file Gamestate.cpp.

References Zeni::get_Video(), Zeni::Logo::render(), and Zeni::Video::set_2d().

Referenced by Zeni::Gamestate::render().

void Zeni::Gamestate_Base::set_pausable ( const bool &  pausable_)
inline

Definition at line 29 of file Gamestate.hxx.

SDL_Keycode Zeni::Gamestate_Base::to_sym ( const String text_version)
static

Convert a text representation to an actual sym.

Definition at line 338 of file Gamestate.cpp.

References SC, SC0, SC1, SC10, SDLK_0, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_a, SDLK_AC_BACK, SDLK_AC_BOOKMARKS, SDLK_AC_FORWARD, SDLK_AC_HOME, SDLK_AC_REFRESH, SDLK_AC_SEARCH, SDLK_AC_STOP, SDLK_AGAIN, SDLK_ALTERASE, SDLK_AMPERSAND, SDLK_APPLICATION, SDLK_ASTERISK, SDLK_AT, SDLK_AUDIOMUTE, SDLK_AUDIONEXT, SDLK_AUDIOPLAY, SDLK_AUDIOPREV, SDLK_AUDIOSTOP, SDLK_b, SDLK_BACKQUOTE, SDLK_BACKSLASH, SDLK_BACKSPACE, SDLK_BRIGHTNESSDOWN, SDLK_BRIGHTNESSUP, SDLK_c, SDLK_CALCULATOR, SDLK_CANCEL, SDLK_CAPSLOCK, SDLK_CARET, SDLK_CLEAR, SDLK_CLEARAGAIN, SDLK_COLON, SDLK_COMMA, SDLK_COMPUTER, SDLK_COPY, SDLK_CRSEL, SDLK_CURRENCYSUBUNIT, SDLK_CURRENCYUNIT, SDLK_CUT, SDLK_d, SDLK_DECIMALSEPARATOR, SDLK_DELETE, SDLK_DISPLAYSWITCH, SDLK_DOLLAR, SDLK_DOWN, SDLK_e, SDLK_EJECT, SDLK_END, SDLK_EQUALS, SDLK_ESCAPE, SDLK_EXCLAIM, SDLK_EXECUTE, SDLK_EXSEL, SDLK_f, SDLK_F1, SDLK_F10, SDLK_F11, SDLK_F12, SDLK_F13, SDLK_F14, SDLK_F15, SDLK_F16, SDLK_F17, SDLK_F18, SDLK_F19, SDLK_F2, SDLK_F20, SDLK_F21, SDLK_F22, SDLK_F23, SDLK_F24, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_FIND, SDLK_g, SDLK_GREATER, SDLK_h, SDLK_HASH, SDLK_HELP, SDLK_HOME, SDLK_i, SDLK_INSERT, SDLK_j, SDLK_k, SDLK_KBDILLUMDOWN, SDLK_KBDILLUMTOGGLE, SDLK_KBDILLUMUP, SDLK_KP_0, SDLK_KP_00, SDLK_KP_000, SDLK_KP_1, SDLK_KP_2, SDLK_KP_3, SDLK_KP_4, SDLK_KP_5, SDLK_KP_6, SDLK_KP_7, SDLK_KP_8, SDLK_KP_9, SDLK_KP_A, SDLK_KP_AMPERSAND, SDLK_KP_AT, SDLK_KP_B, SDLK_KP_BACKSPACE, SDLK_KP_BINARY, SDLK_KP_C, SDLK_KP_CLEAR, SDLK_KP_CLEARENTRY, SDLK_KP_COLON, SDLK_KP_COMMA, SDLK_KP_D, SDLK_KP_DBLAMPERSAND, SDLK_KP_DBLVERTICALBAR, SDLK_KP_DECIMAL, SDLK_KP_DIVIDE, SDLK_KP_E, SDLK_KP_ENTER, SDLK_KP_EQUALS, SDLK_KP_EQUALSAS400, SDLK_KP_EXCLAM, SDLK_KP_F, SDLK_KP_GREATER, SDLK_KP_HASH, SDLK_KP_HEXADECIMAL, SDLK_KP_LEFTBRACE, SDLK_KP_LEFTPAREN, SDLK_KP_LESS, SDLK_KP_MEMADD, SDLK_KP_MEMCLEAR, SDLK_KP_MEMDIVIDE, SDLK_KP_MEMMULTIPLY, SDLK_KP_MEMRECALL, SDLK_KP_MEMSTORE, SDLK_KP_MEMSUBTRACT, SDLK_KP_MINUS, SDLK_KP_MULTIPLY, SDLK_KP_OCTAL, SDLK_KP_PERCENT, SDLK_KP_PERIOD, SDLK_KP_PLUS, SDLK_KP_PLUSMINUS, SDLK_KP_POWER, SDLK_KP_RIGHTBRACE, SDLK_KP_RIGHTPAREN, SDLK_KP_SPACE, SDLK_KP_TAB, SDLK_KP_VERTICALBAR, SDLK_KP_XOR, SDLK_l, SDLK_LALT, SDLK_LCTRL, SDLK_LEFT, SDLK_LEFTBRACKET, SDLK_LEFTPAREN, SDLK_LESS, SDLK_LGUI, SDLK_LSHIFT, SDLK_m, SDLK_MAIL, SDLK_MEDIASELECT, SDLK_MENU, SDLK_MINUS, SDLK_MODE, SDLK_MUTE, SDLK_n, SDLK_NUMLOCKCLEAR, SDLK_o, SDLK_OPER, SDLK_OUT, SDLK_p, SDLK_PAGEDOWN, SDLK_PAGEUP, SDLK_PASTE, SDLK_PAUSE, SDLK_PERCENT, SDLK_PERIOD, SDLK_PLUS, SDLK_POWER, SDLK_PRINTSCREEN, SDLK_PRIOR, SDLK_q, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL, SDLK_r, SDLK_RALT, SDLK_RCTRL, SDLK_RETURN, SDLK_RETURN2, SDLK_RGUI, SDLK_RIGHT, SDLK_RIGHTBRACKET, SDLK_RIGHTPAREN, SDLK_RSHIFT, SDLK_s, SDLK_SCROLLLOCK, SDLK_SELECT, SDLK_SEMICOLON, SDLK_SEPARATOR, SDLK_SLASH, SDLK_SLEEP, SDLK_SPACE, SDLK_STOP, SDLK_SYSREQ, SDLK_t, SDLK_TAB, SDLK_THOUSANDSSEPARATOR, SDLK_u, SDLK_UNDERSCORE, SDLK_UNDO, SDLK_UNKNOWN, SDLK_UP, SDLK_v, SDLK_VOLUMEDOWN, SDLK_VOLUMEUP, SDLK_w, SDLK_WWW, SDLK_x, SDLK_y, and SDLK_z.

String Zeni::Gamestate_Base::to_text ( const SDL_Keycode sym)
static

Convert a sym to a text representation.

Definition at line 715 of file Gamestate.cpp.

References SC, SC0, SC1, SC10, SDLK_0, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_a, SDLK_AC_BACK, SDLK_AC_BOOKMARKS, SDLK_AC_FORWARD, SDLK_AC_HOME, SDLK_AC_REFRESH, SDLK_AC_SEARCH, SDLK_AC_STOP, SDLK_AGAIN, SDLK_ALTERASE, SDLK_AMPERSAND, SDLK_APPLICATION, SDLK_ASTERISK, SDLK_AT, SDLK_AUDIOMUTE, SDLK_AUDIONEXT, SDLK_AUDIOPLAY, SDLK_AUDIOPREV, SDLK_AUDIOSTOP, SDLK_b, SDLK_BACKQUOTE, SDLK_BACKSLASH, SDLK_BACKSPACE, SDLK_BRIGHTNESSDOWN, SDLK_BRIGHTNESSUP, SDLK_c, SDLK_CALCULATOR, SDLK_CANCEL, SDLK_CAPSLOCK, SDLK_CARET, SDLK_CLEAR, SDLK_CLEARAGAIN, SDLK_COLON, SDLK_COMMA, SDLK_COMPUTER, SDLK_COPY, SDLK_CRSEL, SDLK_CURRENCYSUBUNIT, SDLK_CURRENCYUNIT, SDLK_CUT, SDLK_d, SDLK_DECIMALSEPARATOR, SDLK_DELETE, SDLK_DISPLAYSWITCH, SDLK_DOLLAR, SDLK_DOWN, SDLK_e, SDLK_EJECT, SDLK_END, SDLK_EQUALS, SDLK_ESCAPE, SDLK_EXCLAIM, SDLK_EXECUTE, SDLK_EXSEL, SDLK_f, SDLK_F1, SDLK_F10, SDLK_F11, SDLK_F12, SDLK_F13, SDLK_F14, SDLK_F15, SDLK_F16, SDLK_F17, SDLK_F18, SDLK_F19, SDLK_F2, SDLK_F20, SDLK_F21, SDLK_F22, SDLK_F23, SDLK_F24, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_FIND, SDLK_g, SDLK_GREATER, SDLK_h, SDLK_HASH, SDLK_HELP, SDLK_HOME, SDLK_i, SDLK_INSERT, SDLK_j, SDLK_k, SDLK_KBDILLUMDOWN, SDLK_KBDILLUMTOGGLE, SDLK_KBDILLUMUP, SDLK_KP_0, SDLK_KP_00, SDLK_KP_000, SDLK_KP_1, SDLK_KP_2, SDLK_KP_3, SDLK_KP_4, SDLK_KP_5, SDLK_KP_6, SDLK_KP_7, SDLK_KP_8, SDLK_KP_9, SDLK_KP_A, SDLK_KP_AMPERSAND, SDLK_KP_AT, SDLK_KP_B, SDLK_KP_BACKSPACE, SDLK_KP_BINARY, SDLK_KP_C, SDLK_KP_CLEAR, SDLK_KP_CLEARENTRY, SDLK_KP_COLON, SDLK_KP_COMMA, SDLK_KP_D, SDLK_KP_DBLAMPERSAND, SDLK_KP_DBLVERTICALBAR, SDLK_KP_DECIMAL, SDLK_KP_DIVIDE, SDLK_KP_E, SDLK_KP_ENTER, SDLK_KP_EQUALS, SDLK_KP_EQUALSAS400, SDLK_KP_EXCLAM, SDLK_KP_F, SDLK_KP_GREATER, SDLK_KP_HASH, SDLK_KP_HEXADECIMAL, SDLK_KP_LEFTBRACE, SDLK_KP_LEFTPAREN, SDLK_KP_LESS, SDLK_KP_MEMADD, SDLK_KP_MEMCLEAR, SDLK_KP_MEMDIVIDE, SDLK_KP_MEMMULTIPLY, SDLK_KP_MEMRECALL, SDLK_KP_MEMSTORE, SDLK_KP_MEMSUBTRACT, SDLK_KP_MINUS, SDLK_KP_MULTIPLY, SDLK_KP_OCTAL, SDLK_KP_PERCENT, SDLK_KP_PERIOD, SDLK_KP_PLUS, SDLK_KP_PLUSMINUS, SDLK_KP_POWER, SDLK_KP_RIGHTBRACE, SDLK_KP_RIGHTPAREN, SDLK_KP_SPACE, SDLK_KP_TAB, SDLK_KP_VERTICALBAR, SDLK_KP_XOR, SDLK_l, SDLK_LALT, SDLK_LCTRL, SDLK_LEFT, SDLK_LEFTBRACKET, SDLK_LEFTPAREN, SDLK_LESS, SDLK_LGUI, SDLK_LSHIFT, SDLK_m, SDLK_MAIL, SDLK_MEDIASELECT, SDLK_MENU, SDLK_MINUS, SDLK_MODE, SDLK_MUTE, SDLK_n, SDLK_NUMLOCKCLEAR, SDLK_o, SDLK_OPER, SDLK_OUT, SDLK_p, SDLK_PAGEDOWN, SDLK_PAGEUP, SDLK_PASTE, SDLK_PAUSE, SDLK_PERCENT, SDLK_PERIOD, SDLK_PLUS, SDLK_POWER, SDLK_PRINTSCREEN, SDLK_PRIOR, SDLK_q, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL, SDLK_r, SDLK_RALT, SDLK_RCTRL, SDLK_RETURN, SDLK_RETURN2, SDLK_RGUI, SDLK_RIGHT, SDLK_RIGHTBRACKET, SDLK_RIGHTPAREN, SDLK_RSHIFT, SDLK_s, SDLK_SCROLLLOCK, SDLK_SELECT, SDLK_SEMICOLON, SDLK_SEPARATOR, SDLK_SLASH, SDLK_SLEEP, SDLK_SPACE, SDLK_STOP, SDLK_SYSREQ, SDLK_t, SDLK_TAB, SDLK_THOUSANDSSEPARATOR, SDLK_u, SDLK_UNDERSCORE, SDLK_UNDO, SDLK_UP, SDLK_v, SDLK_VOLUMEDOWN, SDLK_VOLUMEUP, SDLK_w, SDLK_WWW, SDLK_x, SDLK_y, and SDLK_z.

Friends And Related Function Documentation

friend class Gamestate
friend

Definition at line 83 of file Gamestate.h.


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