|
OpenEnroth 731eccc
|
#include <EngineController.h>
Public Types | |
| using | GameRoutine = std::function< void()> |
Public Member Functions | |
| EngineController (EngineControlStateHandle state) | |
| ~EngineController () | |
| void | tick (int count=1) |
| void | postEvent (std::unique_ptr< PlatformEvent > event) |
| void | pressKey (PlatformKey key) |
| void | pressAutoRepeatedKey (PlatformKey key) |
| void | releaseKey (PlatformKey key) |
| void | pressButton (PlatformMouseButton button, int x, int y) |
| void | releaseButton (PlatformMouseButton button, int x, int y) |
| void | moveMouse (int x, int y) |
| void | pressAndReleaseKey (PlatformKey key) |
| void | pressAndReleaseButton (PlatformMouseButton button, int x, int y) |
| void | pressGuiButton (std::string_view buttonId) |
| void | goToGame () |
| void | goToInventory (int characterIndex) |
| void | goToMainMenu () |
| void | startNewGame () |
| void | skipLoadingScreen () |
| Blob | saveGame () |
| void | loadGame (const Blob &savedGame) |
| void | runGameRoutine (GameRoutine routine) |
| void | resizeWindow (int w, int h) |
| void | restAndHeal () |
| Actor * | spawnMonster (Vec3f position, MonsterId id) |
| void | teleportTo (MapId map, Vec3f position, int viewYaw) |
| void | castSpell (int characterIndex, SpellId spell) |
Private Member Functions | |
| void | goToGameOrMainMenu () |
| GUIButton * | existingButton (std::string_view buttonId) |
Private Attributes | |
| EngineControlStateHandle | _state |
This is the interface to be used from a control routine to control the game thread.
Most errors are reported as exceptions (derived from std::runtime_error) because the main way to use this class is from unit tests.
| using EngineController::GameRoutine = std::function<void()> |
|
explicit |
|
default |
| void EngineController::castSpell | ( | int | characterIndex, |
| SpellId | spell | ||
| ) |
|
private |
| void EngineController::goToGame | ( | ) |
Closes all menus and goes to the game screen. Will fail if main menu is currently open.
|
private |
| void EngineController::goToInventory | ( | int | characterIndex | ) |
| void EngineController::goToMainMenu | ( | ) |
Opens main menu no matter the current game state.
| void EngineController::loadGame | ( | const Blob & | savedGame | ) |
Loads the game by opening up the load game menu and actually clicking all the buttons.
| savedGame | Blob containing saved game data. |
| void EngineController::moveMouse | ( | int | x, |
| int | y | ||
| ) |
| void EngineController::postEvent | ( | std::unique_ptr< PlatformEvent > | event | ) |
| void EngineController::pressAndReleaseButton | ( | PlatformMouseButton | button, |
| int | x, | ||
| int | y | ||
| ) |
| void EngineController::pressAndReleaseKey | ( | PlatformKey | key | ) |
| void EngineController::pressAutoRepeatedKey | ( | PlatformKey | key | ) |
| void EngineController::pressButton | ( | PlatformMouseButton | button, |
| int | x, | ||
| int | y | ||
| ) |
| void EngineController::pressGuiButton | ( | std::string_view | buttonId | ) |
Presses a GUI button identified by the provided id by sending a mouse press and release event.
| buttonId | Button id. |
| Exception | If the button with the provided id doesn't exist. |
| void EngineController::pressKey | ( | PlatformKey | key | ) |
| void EngineController::releaseButton | ( | PlatformMouseButton | button, |
| int | x, | ||
| int | y | ||
| ) |
| void EngineController::releaseKey | ( | PlatformKey | key | ) |
| void EngineController::resizeWindow | ( | int | w, |
| int | h | ||
| ) |
| void EngineController::restAndHeal | ( | ) |
Opens up the rest menu, presses the "rest and heal for 8 hours" button, and waits out the rest period.
| void EngineController::runGameRoutine | ( | GameRoutine | routine | ) |
Runs the provided routine in game thread and returns once it's finished. This is mainly for running OpenGL code as the corresponding context is bound in the main thread.
| routine | Routine to run. |
| void EngineController::skipLoadingScreen | ( | ) |
Waits for the loading screen to complete.
| Exception | If there is no loading screen. |
| position | Position to spawn a monster at. |
| id | Id of the monster to spawn. |
| void EngineController::startNewGame | ( | ) |
Start new game no matter the current game state.
| void EngineController::tick | ( | int | count = 1 | ) |
Passes execution to the game thread for the provided number of frames. This function provides a coroutine-like interface for control routines as calling tick basically suspends the control routine until the next frame.
| count | Number of frames to suspend the control routine for. |
|
private |