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-2023 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:
18 virtual void onBackEvent();
19
23 virtual void onQuitEvent();
24
31 virtual void onControllerBack();
32
37 virtual void onPauseEvent();
38
40 virtual void onLoad();
41};
42
45
48
50template <class T, class... Args>
51void setWork(Args&&... args) {
52 setWork(std::make_shared<T>(std::forward<Args>(args)...));
53}
54
56[[deprecated("Use setWork(std::shared_ptr<Work>) instead")]]
58
64
65} // namespace jngl
Background job which stays part of the main loop independent of the active jngl::Work.
Definition: job.hpp:16
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 when the "back" button is pressed (important on Android)
Contains jngl::Job class and related functions.
JNGL's main namespace.
Definition: Achievement.hpp:10
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()