diff options
Diffstat (limited to 'lib/nes')
| -rw-r--r-- | lib/nes/app/file-browser.hh | 17 | ||||
| -rw-r--r-- | lib/nes/app/ui/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | lib/nes/app/ui/screen-browser.cc | 27 | ||||
| -rw-r--r-- | lib/nes/app/ui/screen-browser.hh | 2 | ||||
| -rw-r--r-- | lib/nes/app/ui/screen-settings.cc | 5 | ||||
| -rw-r--r-- | lib/nes/app/ui/screen-settings.hh | 16 |
6 files changed, 46 insertions, 23 deletions
diff --git a/lib/nes/app/file-browser.hh b/lib/nes/app/file-browser.hh index 1fc7616..3465000 100644 --- a/lib/nes/app/file-browser.hh +++ b/lib/nes/app/file-browser.hh @@ -18,27 +18,28 @@ namespace nes::app public: static constexpr auto max_name_length = u32{ 64 }; - enum class item_type + enum class entry_type { directory, file, }; - class item + /// An entry in a directory. + class entry { - item_type type_{ item_type::directory }; + entry_type type_{ entry_type::directory }; char name_[max_name_length + 1]{}; public: - explicit item() = default; + explicit entry() = default; - explicit item(item_type const type, std::string_view const name) + explicit entry(entry_type const type, std::string_view const name) : type_{ type } { std::copy_n(name.begin(), std::min(static_cast<u32>(name.length()), max_name_length), name_); } - auto get_type() const -> item_type { return type_; } + auto get_type() const -> entry_type { return type_; } auto get_name() const -> std::string_view { return name_; } }; @@ -55,8 +56,8 @@ namespace nes::app /// Go to directory entry at the given index. virtual auto seek(u32) -> void = 0; - /// Read the directory entry at the current index. - virtual auto read_next(item* out_item) -> bool = 0; + /// Read the directory entry at the current index and move the index forward by 1. + virtual auto read_next(entry* out_entry) -> bool = 0; /// Change the current working directory to the parent directory. virtual auto navigate_up() -> status = 0; diff --git a/lib/nes/app/ui/CMakeLists.txt b/lib/nes/app/ui/CMakeLists.txt index 37720c1..c43bb13 100644 --- a/lib/nes/app/ui/CMakeLists.txt +++ b/lib/nes/app/ui/CMakeLists.txt @@ -9,6 +9,8 @@ target_sources( screen-browser.cc screen-freeze.hh screen-freeze.cc + screen-settings.hh + screen-settings.cc screen-error.hh screen-error.cc screen-confirm-quit.hh diff --git a/lib/nes/app/ui/screen-browser.cc b/lib/nes/app/ui/screen-browser.cc index 4643e1c..1b515bd 100644 --- a/lib/nes/app/ui/screen-browser.cc +++ b/lib/nes/app/ui/screen-browser.cc @@ -8,16 +8,15 @@ namespace nes::app { auto screen_browser::selection_impl::render_item( - renderer& renderer, item const& item, i32 const x, i32 const y, u32 const width, - color const color) const -> void + renderer& renderer, item const& item, i32 const x, i32 const y, u32 const width, color const c) const -> void { - switch (item.base.get_type()) + switch (item.entry.get_type()) { - case file_browser::item_type::file: renderer.render_mask_tile(x, y, tiles::icon_cartridge, color); break; - case file_browser::item_type::directory: renderer.render_mask_tile(x, y, tiles::icon_directory, color); break; + case file_browser::entry_type::file: renderer.render_mask_tile(x, y, tiles::icon_cartridge, c); break; + case file_browser::entry_type::directory: renderer.render_mask_tile(x, y, tiles::icon_directory, c); break; } - renderer.render_text(x + 2, y, item.base.get_name(), color, text_attributes{} + renderer.render_text(x + 2, y, item.entry.get_name(), c, text_attributes{} .set_ellipsize_mode(ellipsize_mode::end) .set_max_width(width - 2)); } @@ -31,7 +30,7 @@ namespace nes::app if (page == 0) { items[count].is_parent = true; - items[count].base = file_browser::item{ file_browser::item_type::directory, "[Parent Directory]" }; + items[count].entry = file_browser::entry{ file_browser::entry_type::directory, "[Parent Directory]" }; count += 1; } else @@ -44,11 +43,11 @@ namespace nes::app file_browser_.seek(position); while (count < page_size) { - auto item = file_browser::item{}; - if (!file_browser_.read_next(&item)) { break; } + auto entry = file_browser::entry{}; + if (!file_browser_.read_next(&entry)) { break; } items[count].is_parent = false; - items[count].base = item; + items[count].entry = entry; count += 1; } @@ -125,18 +124,18 @@ namespace nes::app refresh(); if (navigation_steps_ > 0) { navigation_steps_ -= 1; } } - else if (selected->base.get_type() == file_browser::item_type::directory) + else if (selected->entry.get_type() == file_browser::entry_type::directory) { - if (auto const s = file_browser_.navigate(selected->base.get_name()); s != status::success) + if (auto const s = file_browser_.navigate(selected->entry.get_name()); s != status::success) { return action::show_error("Unable to navigate to directory", s); } refresh(); navigation_steps_ += 1; } - else if (selected->base.get_type() == file_browser::item_type::file) + else if (selected->entry.get_type() == file_browser::entry_type::file) { - return action::launch_game(selected->base.get_name()); + return action::launch_game(selected->entry.get_name()); } } } diff --git a/lib/nes/app/ui/screen-browser.hh b/lib/nes/app/ui/screen-browser.hh index 0ccf0b6..4ba6e73 100644 --- a/lib/nes/app/ui/screen-browser.hh +++ b/lib/nes/app/ui/screen-browser.hh @@ -16,7 +16,7 @@ namespace nes::app struct item { bool is_parent{ false }; - file_browser::item base{}; + file_browser::entry entry{}; }; class selection_impl final : public selection<item, page_size> diff --git a/lib/nes/app/ui/screen-settings.cc b/lib/nes/app/ui/screen-settings.cc new file mode 100644 index 0000000..4d32662 --- /dev/null +++ b/lib/nes/app/ui/screen-settings.cc @@ -0,0 +1,5 @@ +// +// Created by Hannes Schulze on 06.02.25. +// + +#include "screen-settings.hh" diff --git a/lib/nes/app/ui/screen-settings.hh b/lib/nes/app/ui/screen-settings.hh new file mode 100644 index 0000000..8f510ca --- /dev/null +++ b/lib/nes/app/ui/screen-settings.hh @@ -0,0 +1,16 @@ +// +// Created by Hannes Schulze on 06.02.25. +// + +#ifndef SCREEN_SETTINGS_HH +#define SCREEN_SETTINGS_HH + + + +class screen_settings { + +}; + + + +#endif //SCREEN_SETTINGS_HH |
