App::IGameMode class

An interface that represents a mode in the game, that can receive mouse/keyboard input and update every frame.

There can be only an active game mode at a time; modes are managed using the IGameModeManager class. When a game mode is set as active, the OnEnter() method is called; when the mode is no longer active, the OnExit() method will be called.

Derived classes

class DefaultGameMode
A class that provides default implementation for all the methods in a IGameMode.
class GameSpace
class IGameModeObject
Same as App::IGameMode, but this one includes a Cast method similar to the one in the Object class.
class cCellModeStrategy
class cCreatureModeStrategy
class cScenarioMode
class Editors::cEditor
Main class for editors.

Constructors, destructors, conversion operators

~IGameMode() virtual

Public functions

auto AddRef() -> int pure virtual
Increases the reference count and returns it.
auto Release() -> int pure virtual
Decreases the reference count and returns it.
auto func0Ch() -> bool pure virtual
auto Initialize(IGameModeManager* pManager) -> bool pure virtual
This method is called once on every game mode when all modes have been added.
auto Dispose() -> bool pure virtual
This method is called once on every game mode when the game closes.
auto OnEnter() -> bool pure virtual
This method is called when the game mode is set as active, and therefore, entered.
auto OnExit() -> void pure virtual
This method is called when a different game mode is set as active, and therefore, this game mode is exited (no longer active).
auto func20h(int) -> void* pure virtual
auto OnKeyDown(int virtualKey, KeyModifiers modifiers) -> bool pure virtual
An event listener called every time a key is pressed while this mode is active.
auto OnKeyUp(int virtualKey, KeyModifiers modifiers) -> bool pure virtual
An event listener called every time a key is released while this mode is active.
auto OnMouseDown(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) -> bool pure virtual
An event listener called every time a mouse key is pressed while this mode is active.
auto OnMouseUp(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) -> bool pure virtual
An event listener called every time a mouse key is released while this mode is active.
auto OnMouseMove(float mouseX, float mouseY, MouseState mouseState) -> bool pure virtual
An event listener called every time the mouse is moved while this mode is active.
auto OnMouseWheel(int wheelDelta, float mouseX, float mouseY, MouseState mouseState) -> bool pure virtual
An event listener called every time the mouse wheel is moved while this mode is active.
auto Update(float delta1, float delta2) -> void pure virtual
An event listener called every game loop.

Function documentation

int App::IGameMode::Release() pure virtual

Decreases the reference count and returns it.

If the reference count reaches 0, 'delete this' is called.

bool App::IGameMode::Initialize(IGameModeManager* pManager) pure virtual

This method is called once on every game mode when all modes have been added.

Parameters
pManager The GameModeManager that has called this method.

This should take care of all initializations and setups that are required.

bool App::IGameMode::Dispose() pure virtual

This method is called once on every game mode when the game closes.

This should reverse everything the Initialize method did.

bool App::IGameMode::OnKeyDown(int virtualKey, KeyModifiers modifiers) pure virtual

An event listener called every time a key is pressed while this mode is active.

Parameters
virtualKey The VK code of the key.
modifiers The modifiers (Ctrl, Alt and Shift) currently being pressed. They use the enum values UTFWin::kModifier....
Returns Whether the event was handled or not.

bool App::IGameMode::OnKeyUp(int virtualKey, KeyModifiers modifiers) pure virtual

An event listener called every time a key is released while this mode is active.

Parameters
virtualKey The VK code of the key.
modifiers The modifiers (Ctrl, Alt and Shift) currently being pressed. They use the enum values UTFWin::kModifier....
Returns Whether the event was handled or not.

bool App::IGameMode::OnMouseDown(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) pure virtual

An event listener called every time a mouse key is pressed while this mode is active.

Parameters
mouseButton The button that was pressed.
mouseX The X position of the mouse.
mouseY The Y position of the mouse.
mouseState The state of the mouse.
Returns Whether the event was handled or not.

bool App::IGameMode::OnMouseUp(MouseButton mouseButton, float mouseX, float mouseY, MouseState mouseState) pure virtual

An event listener called every time a mouse key is released while this mode is active.

Parameters
mouseButton The button that was released.
mouseX The X position of the mouse.
mouseY The Y position of the mouse.
mouseState The state of the mouse.
Returns Whether the event was handled or not.

bool App::IGameMode::OnMouseMove(float mouseX, float mouseY, MouseState mouseState) pure virtual

An event listener called every time the mouse is moved while this mode is active.

Parameters
mouseX The X position of the mouse.
mouseY The Y position of the mouse.
mouseState The state of the mouse.
Returns Whether the event was handled or not.

bool App::IGameMode::OnMouseWheel(int wheelDelta, float mouseX, float mouseY, MouseState mouseState) pure virtual

An event listener called every time the mouse wheel is moved while this mode is active.

Parameters
wheelDelta The amount of units the wheel moved. This is a multiple of UTFWin::kMouseWheelDelta.
mouseX The X position of the mouse.
mouseY The Y position of the mouse.
mouseState The state of the mouse.
Returns Whether the event was handled or not.

void App::IGameMode::Update(float delta1, float delta2) pure virtual

An event listener called every game loop.

Parameters
delta1 The amount of seconds elapsed since this the last update.
delta2 Usually the same as delta1.