summaryrefslogtreecommitdiff
path: root/app/sdl/state.hh
blob: f67a5f9052be0c67782a6ce75b155310dec33768 (plain)
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
#pragma once

#include "nes/common/status.hh"
#include "nes/app/application.hh"
#include "impl/display-sdl.hh"
#include "impl/input-device-keyboard-sdl.hh"
#include "impl/file-browser-posix.hh"
#include <chrono>
#include <optional>

#include <SDL3/SDL.h>

namespace nes::app::sdl
{
	/// Manages the SDL application lifecycle.
	class state
	{
		status status_{ status::success };
		SDL_Window* window_{ nullptr };
		SDL_Renderer* renderer_{ nullptr };
		SDL_Texture* texture_{ nullptr };
		std::optional<std::chrono::steady_clock::time_point> last_time_point_;
		display_sdl display_;
		input_device_keyboard_sdl keyboard_;
		file_browser_posix file_browser_;
		application application_;

	public:
		explicit state();
		~state();

		auto get_status() const -> status { return status_; }

		auto handle_event(SDL_Event* event) -> void;
		auto handle_iterate() -> void;
	};
} // namespace nes::app::sdl