Add virtual navigation buttons to game launcher
- Display < PREV and NEXT > buttons at bottom of screen when multiple pages exist - Buttons are touchable and respond to taps - Button dimensions: 150x40 at y=235 - PREV button: x=30, NEXT button: x=200 - Updated instructions to show 'Touch buttons or KEY0/KEY1' - Both KEY0/KEY1 and touch button presses navigate pages - Updated lib/ and emulator/ versions
This commit is contained in:
@@ -57,32 +57,64 @@ void GameLauncher::draw() {
|
||||
renderer->draw_string_scaled(50, y + 36, games[i].description, 1);
|
||||
}
|
||||
|
||||
// Draw pagination controls at bottom
|
||||
char nav_text[128];
|
||||
// Draw navigation buttons at bottom (only if multiple pages)
|
||||
if (total_pages > 1) {
|
||||
snprintf(nav_text, sizeof(nav_text), "KEY0: Next Page | KEY1: Select");
|
||||
int button_y = height - 65;
|
||||
|
||||
// Previous page button
|
||||
bool has_prev = (current_page > 0);
|
||||
gui->draw_button(window, 30, button_y, "< PREV", false, true);
|
||||
|
||||
// Next page button
|
||||
bool has_next = (current_page + 1 < total_pages);
|
||||
gui->draw_button(window, 200, button_y, "NEXT >", false, true);
|
||||
|
||||
// Draw instructions
|
||||
renderer->set_font(&font_5x5_obj);
|
||||
renderer->draw_string_scaled(30, height - 25, "Touch buttons or KEY0/KEY1", 1);
|
||||
} else {
|
||||
snprintf(nav_text, sizeof(nav_text), "KEY0: Navigate | KEY1: Select");
|
||||
// Single page - just show select instruction
|
||||
renderer->set_font(&font_5x5_obj);
|
||||
renderer->draw_string_scaled(30, height - 35, "KEY0: Navigate | KEY1: Select | Touch to play", 1);
|
||||
}
|
||||
|
||||
const char* instructions;
|
||||
if (input_manager->has_buttons()) {
|
||||
instructions = nav_text;
|
||||
} else {
|
||||
instructions = "Touch game to play";
|
||||
}
|
||||
renderer->set_font(&font_5x5_obj);
|
||||
renderer->draw_string_scaled(30, height - 35, instructions, 2);
|
||||
}
|
||||
|
||||
|
||||
bool GameLauncher::update(const InputEvent& event) {
|
||||
bool needs_refresh = false;
|
||||
int total_pages = get_total_pages();
|
||||
|
||||
switch (event.type) {
|
||||
case INPUT_TOUCH_DOWN: {
|
||||
printf("Touch at (%d,%d) in launcher\n", event.x, event.y);
|
||||
|
||||
// Check if touch is on navigation buttons (if multiple pages)
|
||||
if (total_pages > 1) {
|
||||
// Previous button: x [30-180], y [235-275]
|
||||
if (event.x >= PREV_BUTTON_X && event.x < PREV_BUTTON_X + BUTTON_WIDTH &&
|
||||
event.y >= NAV_BUTTON_Y && event.y < NAV_BUTTON_Y + BUTTON_HEIGHT) {
|
||||
if (current_page > 0) {
|
||||
current_page--;
|
||||
selected_index = get_page_start_index();
|
||||
needs_refresh = true;
|
||||
printf("Navigated to previous page: %d\n", current_page);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Next button: x [200-350], y [235-275]
|
||||
if (event.x >= NEXT_BUTTON_X && event.x < NEXT_BUTTON_X + BUTTON_WIDTH &&
|
||||
event.y >= NAV_BUTTON_Y && event.y < NAV_BUTTON_Y + BUTTON_HEIGHT) {
|
||||
if (current_page + 1 < total_pages) {
|
||||
current_page++;
|
||||
selected_index = get_page_start_index();
|
||||
needs_refresh = true;
|
||||
printf("Navigated to next page: %d\n", current_page);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if touch is on a game entry for current page
|
||||
int page_start = get_page_start_index();
|
||||
int page_end = get_page_end_index();
|
||||
@@ -110,7 +142,6 @@ bool GameLauncher::update(const InputEvent& event) {
|
||||
// Navigate within current page or switch pages
|
||||
int page_start = get_page_start_index();
|
||||
int page_end = get_page_end_index();
|
||||
int total_pages = get_total_pages();
|
||||
|
||||
// If multiple games on current page, navigate within page first
|
||||
if (page_end - page_start > 1) {
|
||||
|
||||
Reference in New Issue
Block a user