Fix render issues with fonts
This commit is contained in:
@@ -259,7 +259,7 @@ int main()
|
|||||||
// Initialize standard I/O for debugging with timeout
|
// Initialize standard I/O for debugging with timeout
|
||||||
// This prevents hanging when USB is not connected
|
// This prevents hanging when USB is not connected
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
sleep_ms(5000); // Wait for USB connection (if present)
|
sleep_ms(100); // Wait for USB connection (if present)
|
||||||
|
|
||||||
printf("\n=== %s Demo ===\n", BOARD_NAME);
|
printf("\n=== %s Demo ===\n", BOARD_NAME);
|
||||||
printf("Starting dual-core system...\n");
|
printf("Starting dual-core system...\n");
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Font font_tama_mini02_obj(reinterpret_cast<const unsigned char*>(font_tama_mini0
|
|||||||
Font font_zxpix_obj(reinterpret_cast<const unsigned char*>(font_zxpix), 96, 6, 8);
|
Font font_zxpix_obj(reinterpret_cast<const unsigned char*>(font_zxpix), 96, 6, 8);
|
||||||
|
|
||||||
LowLevelRenderer::LowLevelRenderer(uint8_t* buffer, int width, int height)
|
LowLevelRenderer::LowLevelRenderer(uint8_t* buffer, int width, int height)
|
||||||
: bit_buffer(buffer), V_WIDTH(width), V_HEIGHT(height), current_font(nullptr),
|
: bit_buffer(buffer), V_WIDTH(width), V_HEIGHT(height), current_font(&font_5x5_obj),
|
||||||
clipping_enabled(false), clip_x(0), clip_y(0), clip_width(width), clip_height(height), text_color(true) {}
|
clipping_enabled(false), clip_x(0), clip_y(0), clip_width(width), clip_height(height), text_color(true) {}
|
||||||
|
|
||||||
void LowLevelRenderer::set_font(const Font* font) {
|
void LowLevelRenderer::set_font(const Font* font) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// Simple demo game to test the launcher
|
// Simple demo game to test the launcher
|
||||||
|
|
||||||
#include "demo_game.h"
|
#include "demo_game.h"
|
||||||
|
#include "board_config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -53,7 +54,11 @@ void DemoGame::draw() {
|
|||||||
|
|
||||||
// Instructions
|
// Instructions
|
||||||
if (tap_count < 3) {
|
if (tap_count < 3) {
|
||||||
|
#ifdef BUTTON_KEY0_PIN
|
||||||
|
renderer->draw_string(width/2 - 80, y + 80, "Tap or press 3 times", true);
|
||||||
|
#else
|
||||||
renderer->draw_string(width/2 - 80, y + 80, "Tap 3 times to exit", true);
|
renderer->draw_string(width/2 - 80, y + 80, "Tap 3 times to exit", true);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
renderer->draw_string(width/2 - 70, y + 80, "Exiting to menu...", true);
|
renderer->draw_string(width/2 - 70, y + 80, "Exiting to menu...", true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,12 +220,20 @@ void TicTacToeGame::draw() {
|
|||||||
} else {
|
} else {
|
||||||
renderer->draw_string(20, 40, "TIE GAME!", true);
|
renderer->draw_string(20, 40, "TIE GAME!", true);
|
||||||
}
|
}
|
||||||
|
#ifdef BUTTON_KEY0_PIN
|
||||||
renderer->draw_string(20, 55, "Touch or KEY0 to restart", true);
|
renderer->draw_string(20, 55, "Touch or KEY0 to restart", true);
|
||||||
|
#else
|
||||||
|
renderer->draw_string(20, 55, "Touch to restart", true);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
char turn_text[30];
|
char turn_text[30];
|
||||||
snprintf(turn_text, sizeof(turn_text), "Turn: %s", state.current_player == 1 ? "X" : "O");
|
snprintf(turn_text, sizeof(turn_text), "Turn: %s", state.current_player == 1 ? "X" : "O");
|
||||||
renderer->draw_string(20, 40, turn_text, true);
|
renderer->draw_string(20, 40, turn_text, true);
|
||||||
|
#ifdef BUTTON_KEY0_PIN
|
||||||
renderer->draw_string(20, 55, "Touch cell or use keys", true);
|
renderer->draw_string(20, 55, "Touch cell or use keys", true);
|
||||||
|
#else
|
||||||
|
renderer->draw_string(20, 55, "Touch cell to play", true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw game board (use same layout as touch detection!)
|
// Draw game board (use same layout as touch detection!)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// Menu system for selecting and launching games
|
// Menu system for selecting and launching games
|
||||||
|
|
||||||
#include "game_launcher.h"
|
#include "game_launcher.h"
|
||||||
|
#include "board_config.h"
|
||||||
#include "display/low_level_render.h"
|
#include "display/low_level_render.h"
|
||||||
#include "display/low_level_gui.h"
|
#include "display/low_level_gui.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -27,27 +28,25 @@ void GameLauncher::register_game(const char* name, const char* description,
|
|||||||
|
|
||||||
void GameLauncher::draw() {
|
void GameLauncher::draw() {
|
||||||
// Draw main window
|
// Draw main window
|
||||||
gui->draw_new_window(10, 10, width - 20, height - 20, "Game Launcher");
|
LowLevelWindow* window = gui->draw_new_window(10, 10, width - 20, height - 20, "Game Launcher");
|
||||||
|
|
||||||
|
renderer->set_font(&font_5x5_obj);
|
||||||
|
|
||||||
// Draw title
|
// Draw title
|
||||||
renderer->draw_string(30, 30, "Select a Game:", true);
|
renderer->draw_string_scaled(30, 40, "Select a Game:", 2);
|
||||||
|
|
||||||
// Draw game list
|
// Draw game list with GUI buttons
|
||||||
for (size_t i = 0; i < games.size(); i++) {
|
for (size_t i = 0; i < games.size(); i++) {
|
||||||
int y = MENU_Y_START + (i * MENU_ITEM_HEIGHT);
|
int y = MENU_Y_START + (i * MENU_ITEM_HEIGHT);
|
||||||
|
|
||||||
// Highlight selected item
|
// Draw button (pressed/highlighted if selected)
|
||||||
if ((int)i == selected_index) {
|
bool is_selected = ((int)i == selected_index);
|
||||||
// Draw selection box
|
gui->draw_button(window, 20, y, games[i].name, is_selected, true);
|
||||||
renderer->draw_rectangle(20, y - 5, width - 40, MENU_ITEM_HEIGHT - 10, true, 2);
|
|
||||||
renderer->draw_string(30, y + 2, ">", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw game name
|
// Draw description below button
|
||||||
renderer->draw_string(45, y + 2, games[i].name, true);
|
renderer->set_font(&font_5x5_obj); // Restore small font for description
|
||||||
|
renderer->set_text_color(true); // Normal text color
|
||||||
// Draw description (smaller, below name)
|
renderer->draw_string_scaled(50, y + 36, games[i].description, 1);
|
||||||
renderer->draw_string(45, y + 15, games[i].description, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw instructions at bottom
|
// Draw instructions at bottom
|
||||||
@@ -57,7 +56,8 @@ void GameLauncher::draw() {
|
|||||||
#else
|
#else
|
||||||
instructions = "Touch game to play";
|
instructions = "Touch game to play";
|
||||||
#endif
|
#endif
|
||||||
renderer->draw_string(30, height - 35, instructions, true);
|
renderer->set_font(&font_5x5_obj);
|
||||||
|
renderer->draw_string_scaled(30, height - 35, instructions, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameLauncher::update(const InputEvent& event) {
|
bool GameLauncher::update(const InputEvent& event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user