JNGL
work.hpp
Go to the documentation of this file.
1 // Copyright 2012-2021 Jan Niklas Hasse <[email protected]>
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 
10 namespace jngl {
11 
13 class Work : public Job {
14 public:
18  virtual void onBackEvent();
19 
23  virtual void onQuitEvent();
24 
29  virtual void onPauseEvent();
30 
32  virtual void onLoad();
33 };
34 
37 
40 
42 template <class T, class... Args>
43 void setWork(Args&&... args) {
44  setWork(std::make_shared<T>(std::forward<Args>(args)...));
45 }
46 
48 [[deprecated("Use setWork(std::shared_ptr<Work>) instead")]]
49 void setWork(Work*);
50 
56 
57 } // namespace jngl
Background job which stays part of the main loop independent of the active jngl::Work.
Definition: job.hpp:15
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 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: App.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()