Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Checkout the game submodules (without their desktop-only nested submodules)
run: |
git submodule update --init components/jk/OpenJKDF2 components/mgs/mgs_reversing components/mgs/psyz components/tpm/tpm-decomp components/genesis/gwenesis components/pico8/femto8 components/nes/nofrendo components/gbc/gnuboy components/msx/fmsx components/sms/smsplus components/doom/prboom components/darkforces/TheForceEngine components/emulink
git submodule update --init components/jk/OpenJKDF2 components/mgs/mgs_reversing components/mgs/psyz components/tpm/tpm-decomp components/genesis/gwenesis components/pico8/femto8 components/nes/nofrendo components/gbc/gnuboy components/msx/fmsx components/sms/smsplus components/doom/prboom components/darkforces/TheForceEngine components/emulink components/emu-ui
# ScummVM's history is large: only the pinned commit
git submodule update --init --depth 1 components/scummvm/scummvm

Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@
path = components/emulink
url = https://github.com/esp-cpp/emulink.git
branch = main
[submodule "components/emu-ui"]
path = components/emu-ui
url = https://github.com/esp-cpp/emu-ui.git
branch = main
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ has the details.
main/ app_main, Cart base class, per-game carts
components/
tab5-emu/ HAL (Tab5Emu): display / PPA video path, audio, SD, input
gui/ LVGL launcher (rom list + boxart + settings)
menu/ LVGL in-game pause menu (resume/reset/save/load/quit)
emu-ui/ the launcher's and the pause menu's screens (shared with esp-box-emu)
gui/ the launcher: the games, boxart and settings for emu-ui
menu/ the in-game pause menu (resume/reset/save/load/quit) on emu-ui
rom_info/ metadata.csv parsing
statistics/ frame timing
jk/ OpenJKDF2 port: engine submodule + ESP32 platform layer + glue
Expand Down
1 change: 1 addition & 0 deletions components/emu-ui
Submodule emu-ui added at bf14c6
2 changes: 1 addition & 1 deletion components/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
idf_component_register(
INCLUDE_DIRS "include"
SRC_DIRS "src"
REQUIRES lvgl timer logger rom_info settings tab5-emu)
REQUIRES lvgl emu-ui timer logger rom_info settings tab5-emu app_update esp_app_format)
19 changes: 0 additions & 19 deletions components/gui/include/console_art.hpp

This file was deleted.

79 changes: 27 additions & 52 deletions components/gui/include/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

#include <atomic>
#include <filesystem>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <string_view>
#include <unordered_map>
#include <vector>

#include "lvgl.h"
Expand All @@ -14,20 +16,23 @@
#include "high_resolution_timer.hpp"
#include "logger.hpp"

#include "console_art.hpp"
#include "emu-ui/launcher.hpp"

#include "rom_info.hpp"
#include "settings.hpp"
#include "tab5-emu.hpp"

/// The launcher GUI: a list of games (from metadata.csv on the SD card),
/// grouped under a header per console, with the selected game's boxart and
/// console, plus settings (volume, brightness, video scaling, resume), which
/// are kept in AppSettings. Hand-written LVGL, laid out for the Tab5's
/// 1280x720 landscape screen.
/// The launcher: the games in metadata.csv on the SD card, grouped by
/// console, with the selected game's boxart, a console picker and the
/// settings (kept in AppSettings). The screens are emu-ui's (shared with
/// esp-box-emu); this is the Tab5's side of them: the games, the images,
/// the settings and the USB drive.
class Gui {
public:
struct Config {
std::string metadata_filename = "metadata.csv";
/// Where the carts keep their save states (the list shows each game's count)
std::string save_dir{std::string(Tab5Emu::mount_point) + "/saves"};
espp::Logger::Verbosity log_level{espp::Logger::Verbosity::WARN};
};

Expand All @@ -51,6 +56,8 @@ class Gui {
void resume();

void update_rom_list();
/// Give the launcher rom_infos_ (with their save counts), keeping `selected_path` selected
void show_games(const std::string &selected_path);
/// Re-read metadata.csv even if its modification time did not change (FAT
/// times are coarse, and without a set clock they may not move at all).
void reload_rom_list() {
Expand Down Expand Up @@ -93,61 +100,29 @@ class Gui {
Snapshot snapshot();

protected:
void init_ui();
void deinit_ui();
void update_shared_state();
void select_rom(int index);
void build_list(int keep_rom);
void step_console(int dir);
void update_filter_marker();
void open_console_picker();
void close_console_picker();
static void picker_event(lv_event_t *e);
std::vector<emu_ui::Row> settings_rows();
void set_usb_drive(bool on);
void update();

void on_volume(const std::vector<uint8_t> &data);
void on_battery(const std::vector<uint8_t> &data);

static void event_callback(lv_event_t *e);

std::vector<RomInfo> rom_infos_;
std::atomic<int> focused_rom_{-1};

lv_obj_t *screen_{nullptr};
lv_group_t *group_{nullptr}; ///< gamepad / keyboard focus order
lv_obj_t *rom_list_{nullptr};
lv_obj_t *boxart_{nullptr};
lv_draw_buf_t *boxart_buf_{nullptr}; ///< decoded boxart the image widget shows
void load_boxart(const std::string &path);
/// Decode a JPEG on the SD card into a new RGB565 draw buffer (nullptr if it cannot)
lv_draw_buf_t *decode_image(const std::string &path);
const void *cover(size_t index);
const void *console_art(const std::string &key);

// the console the selected game runs on: its SD card art, or a badge
lv_obj_t *console_area_{nullptr};
lv_draw_buf_t *console_art_buf_{nullptr};
int shown_console_{-1};
void show_console(Console console);
void add_console_header(Console console);
lv_obj_t *title_label_{nullptr};
lv_obj_t *play_button_{nullptr};
lv_obj_t *volume_slider_{nullptr};
lv_obj_t *brightness_slider_{nullptr};
lv_obj_t *mute_switch_{nullptr};
lv_obj_t *usb_switch_{nullptr};
lv_obj_t *usb_label_{nullptr};
void set_usb_drive(bool on);
lv_obj_t *video_dropdown_{nullptr};
lv_obj_t *resume_switch_{nullptr};
lv_obj_t *battery_label_{nullptr};
std::vector<lv_obj_t *> rom_buttons_; ///< per game (rom_infos_ index); nullptr if filtered out

// the console filter: the Console whose games the list shows, -1 all
int filter_{-1};
lv_obj_t *picker_{nullptr}; ///< the console picker, while it is open
lv_group_t *picker_group_{nullptr};
std::vector<int> picker_consoles_; ///< the picker's rows: Console, -1 all
std::vector<RomInfo> rom_infos_;
std::atomic<int> focused_rom_{-1};
std::unique_ptr<emu_ui::Launcher> launcher_;
lv_draw_buf_t *boxart_buf_{nullptr}; ///< the selected game's decoded boxart
/// boxart/consoles/<key>.jpg, decoded once (nullptr: there is none)
std::map<std::string, lv_draw_buf_t *> console_art_;
std::string usb_note_;
bool usb_drive_shown_{false};

std::string metadata_filename_;
std::string save_dir_;
std::unordered_map<std::string, int> save_counts_; ///< per rom stem (emu_ui::count_saves)
std::filesystem::file_time_type metadata_last_modified_{};

std::atomic<bool> paused_{false};
Expand Down
135 changes: 0 additions & 135 deletions components/gui/src/console_art.cpp

This file was deleted.

Loading
Loading