38ffdac749
- GameLauncher now displays only 4 games per page to keep menu in bounds - Added page navigation with page indicator (Page X/Y) - KEY0 navigates between pages and within page - KEY1 selects the highlighted game - Touch selection works on current page only - Helper methods: get_total_pages(), get_page_start_index(), get_page_end_index() - Updated both lib/ and emulator/ versions for consistency
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
// Copy of game_launcher.h for emulator build
|
|
#include <stdint.h>
|
|
#include <vector>
|
|
#include <functional>
|
|
#include "input_event.h"
|
|
#include "game.h"
|
|
|
|
class LowLevelRenderer;
|
|
class LowLevelGUI;
|
|
class InputManager;
|
|
|
|
struct GameEntry {
|
|
const char* name;
|
|
const char* description;
|
|
std::function<Game*(uint16_t, uint16_t, LowLevelRenderer*, LowLevelGUI*, InputManager*)> factory;
|
|
};
|
|
|
|
class GameLauncher {
|
|
public:
|
|
GameLauncher(uint16_t width, uint16_t height, LowLevelRenderer* renderer, LowLevelGUI* gui, InputManager* input_manager);
|
|
|
|
void register_game(const char* name, const char* description,
|
|
std::function<Game*(uint16_t, uint16_t, LowLevelRenderer*, LowLevelGUI*, InputManager*)> factory);
|
|
|
|
void draw();
|
|
bool update(const InputEvent& event);
|
|
Game* get_selected_game();
|
|
void reset();
|
|
bool is_game_selected() const { return selected_game != nullptr; }
|
|
|
|
private:
|
|
uint16_t width;
|
|
uint16_t height;
|
|
LowLevelRenderer* renderer;
|
|
LowLevelGUI* gui;
|
|
InputManager* input_manager;
|
|
std::vector<GameEntry> games;
|
|
int selected_index;
|
|
Game* selected_game;
|
|
int current_page;
|
|
|
|
static const int MENU_Y_START = 60;
|
|
static const int MENU_ITEM_HEIGHT = 40;
|
|
static const int MENU_PADDING = 10;
|
|
static const int GAMES_PER_PAGE = 4;
|
|
|
|
int get_total_pages() const;
|
|
int get_page_start_index() const;
|
|
int get_page_end_index() const;
|
|
};
|