diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-02-04 23:39:24 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-02-04 23:39:24 +0100 |
| commit | 64308c9e520dbd8e72b675d0ba064ecdaf9bd494 (patch) | |
| tree | ff8dc176d62340df9565e424f19b9d6349c4e8b8 /lib/nes/app/ui/screen-error.cc | |
| parent | 79553ab1fa3d707612e80dd03bf95ca65fa0c411 (diff) | |
add error handling to ui
Diffstat (limited to 'lib/nes/app/ui/screen-error.cc')
| -rw-r--r-- | lib/nes/app/ui/screen-error.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/nes/app/ui/screen-error.cc b/lib/nes/app/ui/screen-error.cc new file mode 100644 index 0000000..67a3244 --- /dev/null +++ b/lib/nes/app/ui/screen-error.cc @@ -0,0 +1,38 @@ +#include "nes/app/ui/screen-error.hh" +#include "nes/app/graphics/renderer.hh" +#include "nes/app/graphics/color.hh" +#include "nes/app/input/input-device-keyboard.hh" + +namespace nes::app +{ + screen_error::screen_error(input_device_keyboard& keyboard) + : keyboard_{ keyboard } + { + } + + auto screen_error::render(renderer& renderer) -> void + { + // TODO: Nicer box + renderer.render_rect(2, 9, 28, 5, color::background_secondary); + + auto const attrs = text_attributes{} + .set_alignment(text_alignment::center) + .set_ellipsize_mode(ellipsize_mode::end) + .set_max_width(26); + renderer.render_text_format(16, 10, color::foreground_primary, attrs, "{}:", message_); + renderer.render_text(16, 12, to_string(error_), color::foreground_primary, attrs); + } + + auto screen_error::process_events() -> action + { + while (auto const event = keyboard_.poll_event()) + { + if (event == input_event::key_down(key::enter)) + { + return action::close_popup(); + } + } + + return action{}; + } +} // namespace nes::app
\ No newline at end of file |
