From d060e3a50c987d10799ccc739bdbf9d7d7a13c10 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Thu, 6 Feb 2025 18:24:59 +0100 Subject: implement settings --- lib/nes/app/ui/screen-settings.hh | 67 +++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 16 deletions(-) (limited to 'lib/nes/app/ui/screen-settings.hh') diff --git a/lib/nes/app/ui/screen-settings.hh b/lib/nes/app/ui/screen-settings.hh index 8f510ca..8910c5c 100644 --- a/lib/nes/app/ui/screen-settings.hh +++ b/lib/nes/app/ui/screen-settings.hh @@ -1,16 +1,51 @@ -// -// Created by Hannes Schulze on 06.02.25. -// - -#ifndef SCREEN_SETTINGS_HH -#define SCREEN_SETTINGS_HH - - - -class screen_settings { - -}; - - - -#endif //SCREEN_SETTINGS_HH +#pragma once + +#include "nes/app/ui/screen.hh" +#include "nes/app/ui/selection.hh" + +namespace nes::app +{ + class input_manager; + class preferences; + + /// Screen used to configure various emulator options. + class screen_settings final : public screen + { + static constexpr auto page_size = u32{ 8 }; + + enum class item + { + controller_1, + controller_2, + fps_counter, + }; + + class selection_impl final : public selection + { + input_manager& input_manager_; + preferences& preferences_; + + public: + explicit selection_impl(input_manager& input_manager, preferences& preferences) + : selection{ 2, 5, 28 } + , input_manager_{ input_manager } + , preferences_{ preferences } + { + } + + protected: + auto render_item(renderer&, item const&, i32 x, i32 y, u32 width, color) const -> void override; + auto load_page(item(&)[page_size], u32 page) -> u32 override; + }; + + input_manager& input_manager_; + preferences& preferences_; + selection_impl selection_; + + public: + explicit screen_settings(input_manager&, preferences&); + + auto render(renderer&) -> void override; + auto process_events() -> action override; + }; +} // namespace nes::app \ No newline at end of file -- cgit v1.3.1