summaryrefslogtreecommitdiff
path: root/lib/nes/app/application.cc
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-02-06 18:24:59 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-02-06 18:24:59 +0100
commitd060e3a50c987d10799ccc739bdbf9d7d7a13c10 (patch)
tree4b5585383ada85608b57bcf76e5828817962fddf /lib/nes/app/application.cc
parentdbed1c0fa5599b1b96c221b89b10f1e350351645 (diff)
implement settings
Diffstat (limited to 'lib/nes/app/application.cc')
-rw-r--r--lib/nes/app/application.cc41
1 files changed, 25 insertions, 16 deletions
diff --git a/lib/nes/app/application.cc b/lib/nes/app/application.cc
index 01d3f0b..015e641 100644
--- a/lib/nes/app/application.cc
+++ b/lib/nes/app/application.cc
@@ -21,15 +21,25 @@ namespace nes::app
popup->render(r);
}
+ if (preferences_.get_fps_counter())
+ {
+ r.render_rect(30, 29, 2, 1, color::fixed_black);
+ auto const attrs = text_attributes{}
+ .set_max_width(2)
+ .set_alignment(text_alignment::right);
+ r.render_text_format(32, 29, color::fixed_white, attrs, "{}", fps_counter.get_fps());
+ }
+
base.switch_buffers();
}
application::application(display& display, input_device_keyboard& keyboard, file_browser& file_browser)
- : display_{ display }
- , input_manager_{ keyboard }
+ : input_manager_{ keyboard }
, file_browser_{ file_browser }
+ , display_{ preferences_, display }
, screen_title_{ keyboard }
, screen_browser_{ keyboard, file_browser }
+ , screen_settings_{ input_manager_, preferences_ }
, screen_error_{ keyboard }
, screen_confirm_quit_{ keyboard }
{
@@ -38,6 +48,8 @@ namespace nes::app
auto application::frame(std::chrono::microseconds const elapsed_time) -> void
{
+ display_.fps_counter.frame(elapsed_time);
+
if (display_.popup)
{
auto const a = display_.popup->process_events();
@@ -99,21 +111,18 @@ namespace nes::app
}
case action::type::go_to_title:
{
- console_.clear();
- display_.screen = &screen_title_;
- display_.popup = nullptr;
+ go_to_screen(&screen_title_);
break;
}
case action::type::go_to_browser:
+ case action::type::confirm_quit:
{
- console_.clear();
- display_.screen = &screen_browser_;
- display_.popup = nullptr;
+ go_to_screen(&screen_browser_);
break;
}
case action::type::go_to_settings:
{
- // TODO
+ go_to_screen(&screen_settings_);
break;
}
case action::type::go_to_help:
@@ -132,13 +141,6 @@ namespace nes::app
display_.screen = nullptr;
break;
}
- case action::type::confirm_quit:
- {
- display_.popup = nullptr;
- display_.screen = &screen_browser_;
- console_.clear();
- break;
- }
case action::type::launch_game:
{
u8 buffer[sys::cartridge::max_file_size];
@@ -176,4 +178,11 @@ namespace nes::app
screen_error_.set_action(action);
display_.popup = &screen_error_;
}
+
+ auto application::go_to_screen(screen* screen) -> void
+ {
+ console_.clear();
+ display_.screen = screen;
+ display_.popup = nullptr;
+ }
} // namespace nes::app \ No newline at end of file