From 79553ab1fa3d707612e80dd03bf95ca65fa0c411 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Tue, 4 Feb 2025 23:11:08 +0100 Subject: refactor file browser --- lib/nes/app/ui/action.hh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'lib/nes/app/ui/action.hh') diff --git a/lib/nes/app/ui/action.hh b/lib/nes/app/ui/action.hh index b701606..66f77f8 100644 --- a/lib/nes/app/ui/action.hh +++ b/lib/nes/app/ui/action.hh @@ -1,5 +1,6 @@ #pragma once +#include "nes/common/status.hh" #include namespace nes::app @@ -16,28 +17,41 @@ namespace nes::app go_to_settings, go_to_help, launch_game, + show_error, }; private: type type_{ type::none }; std::string_view file_name_; + status error_{ status::success }; public: explicit action() = default; - static auto go_to_title() -> action { return action{ type::go_to_title, "" }; } - static auto go_to_browser() -> action { return action{ type::go_to_browser, "" }; } - static auto go_to_settings() -> action { return action{ type::go_to_settings, "" }; } - static auto go_to_help() -> action { return action{ type::go_to_help, "" }; } - static auto launch_game(std::string_view const file_name) -> action { return action{ type::launch_game, file_name }; } + static auto go_to_title() -> action { return action{ type::go_to_title, "", status::success }; } + static auto go_to_browser() -> action { return action{ type::go_to_browser, "", status::success }; } + static auto go_to_settings() -> action { return action{ type::go_to_settings, "", status::success }; } + static auto go_to_help() -> action { return action{ type::go_to_help, "", status::success }; } + + static auto launch_game(std::string_view const file_name) -> action + { + return action{ type::launch_game, file_name, status::success }; + } + + static auto show_error(status const error) + { + return action{ type::show_error, "", error }; + } auto get_type() const -> type { return type_; } auto get_file_name() const -> std::string_view { return file_name_; } + auto get_error() const -> status { return error_; } private: - explicit action(type const type, std::string_view const file_name) + explicit action(type const type, std::string_view const file_name, status const error) : type_{ type } , file_name_{ file_name } + , error_{ error } { } }; -- cgit v1.3.1