File: IStateHandler.h

package info (click to toggle)
jazz2-native 3.5.0-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 16,912 kB
  • sloc: cpp: 172,557; xml: 113; python: 36; makefile: 5; sh: 2
file content (44 lines) | stat: -rw-r--r-- 1,472 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include "../Main.h"
#include "../nCine/Input/InputEvents.h"
#include "../nCine/Primitives/Vector2.h"

#include <memory>

#include <Base/TypeInfo.h>

namespace Jazz2
{
	/** @brief Base interface of a state handler, only one handler runs at a time */
	class IStateHandler : public std::enable_shared_from_this<IStateHandler>
	{
		DEATH_RUNTIME_OBJECT();

	public:
		IStateHandler() {}
		virtual ~IStateHandler() {}

		IStateHandler(const IStateHandler&) = delete;
		IStateHandler& operator=(const IStateHandler&) = delete;

		/** @brief Returns viewport size of the handler */
		virtual nCine::Vector2i GetViewSize() const { return {}; }

		/** @brief Called at the beginning of each frame */
		virtual void OnBeginFrame() {}
		/** @brief Called at the end of each frame */
		virtual void OnEndFrame() {}
		/** @brief Called when the viewport needs to be initialized (e.g., when the resolution is changed) */
		virtual void OnInitializeViewport(std::int32_t width, std::int32_t height) {}

		/** @brief Called when a key is pressed */
		virtual void OnKeyPressed(const nCine::KeyboardEvent& event) {}
		/** @brief Called when a key is released */
		virtual void OnKeyReleased(const nCine::KeyboardEvent& event) {}
		/** @brief Called when a text input is detected */
		virtual void OnTextInput(const nCine::TextInputEvent& event) {}
		/** @brief Called when a touch event is triggered */
		virtual void OnTouchEvent(const nCine::TouchEvent& event) {}
	};
}