JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
work.hpp
Go to the documentation of this file.
1// Copyright 2012-2024 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
4#pragma once
5
6#include "job.hpp"
7
8#include <memory>
9
10namespace jngl {
11
13class Work : public Job {
14public:
39 virtual void onBackEvent();
40
54 virtual void onQuitEvent();
55
62 virtual void onControllerBack();
63
68 virtual void onPauseEvent();
69
71 virtual void onLoad();
72};
73
76
79
81template <class T, class... Args>
82void setWork(Args&&... args) {
84}
85
87[[deprecated("Use setWork(std::shared_ptr<Work>) instead")]]
89
95
96} // namespace jngl
Background job which stays part of the main loop independent of the active jngl::Work.
Definition job.hpp:19
Active state of the game, e.g. a menu or the game itself.
Definition work.hpp:13
virtual void onPauseEvent()
Gets called when the main window loses focus or the app is put in the background.
virtual void onQuitEvent()
Gets called when the user closes the main window or quit() has been called.
virtual void onControllerBack()
Gets called when the "Back" button is pressed on any connected controller (Android only)
virtual void onLoad()
Gets called when the Work is activated by App::mainLoop()
virtual void onBackEvent()
Gets called on Android's "back" gesture or when the Esc key is pressed.
Contains jngl::Job class and related functions.
JNGL's main namespace.
void resetFrameLimiter()
Resets the automatic frame limiter of App::mainLoop().
std::shared_ptr< Work > getWork()
Returns the current active Work or nullptr if none has been set.
void setWork(std::shared_ptr< Work > work)
Sets the passed Work to be active in App::mainLoop()