Spice up the option screen

main
En Yi 2025-08-23 16:13:45 +08:00
parent 18064ddf3c
commit 0088fd64de
1 changed files with 59 additions and 47 deletions

View File

@ -50,61 +50,75 @@ static void options_scene_render_func(Scene_t* scene)
KeyBindInfo_t keybind_info;
char buffer[64];
int y_offset = 16;
int y_offset = 32;
uint16_t line = 0;
Sprite_t* level_board = get_sprite(&scene->engine->assets, "lvl_board");
#define TITLE_FONT_SIZE 40
#define FONT_SIZE 24
#define FONT_COLOUR BLACK
float start_x = scene->engine->intended_window_size.x / 2;
start_x -= level_board->frame_size.x / 2;
Font* menu_font = get_font(&scene->engine->assets, "MenuFont");
BeginTextureMode(scene->layers.render_layers[0].layer_tex);
ClearBackground((Color){0,0,0,0});
draw_sprite(level_board, 0, (Vector2){start_x,0},0, false);
Vector2 title_size = MeasureTextEx(*menu_font, "Options", TITLE_FONT_SIZE, 4);
DrawTextEx(*menu_font, "Options", (Vector2){start_x + title_size.x/2,y_offset}, TITLE_FONT_SIZE, 4, BLACK);
y_offset += TITLE_FONT_SIZE;
start_x += 32;
if (line == data->curr_selection)
{
DrawText(">>", 0, y_offset, 12, WHITE);
DrawTextEx(*menu_font, ">>", (Vector2){start_x,y_offset}, FONT_SIZE, 4, BLACK);
}
float vol = GetMasterVolume();
sprintf(buffer, "Volume : %.1f", vol);
DrawText(buffer, 32, y_offset, 12, WHITE);
y_offset += 12;
DrawTextEx(*menu_font, buffer, (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
y_offset += FONT_SIZE;
line++;
sc_array_foreach(&data->keybinds_info, keybind_info) {
if (line == data->curr_selection)
{
DrawText(">>", 0, y_offset, 12, WHITE);
DrawTextEx(*menu_font, ">>", (Vector2){start_x,y_offset}, FONT_SIZE, 4, BLACK);
}
if (keybind_info.key == keybind_info.original_key)
{
sprintf(buffer, "%s : %s", keybind_info.action_name, keybind_info.key_name);
DrawText(buffer, 32, y_offset, 12, WHITE);
DrawTextEx(*menu_font, buffer, (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
}
else
{
sprintf(buffer, "%s : %s => %s", keybind_info.action_name, keybind_info.original_key_name, keybind_info.key_name);
DrawText(buffer, 32, y_offset, 12, BLUE);
DrawTextEx(*menu_font, buffer, (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLUE);
}
y_offset += 12;
y_offset += FONT_SIZE;
line++;
}
y_offset += FONT_SIZE;
if (line == data->curr_selection)
{
DrawText(">>", 0, y_offset, 12, WHITE);
DrawTextEx(*menu_font, ">>", (Vector2){start_x, y_offset}, FONT_SIZE, 4, BLACK);
}
DrawText("Apply", 32, y_offset, 12, WHITE);
y_offset += 12;
DrawTextEx(*menu_font, "Apply", (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
y_offset += FONT_SIZE;
line++;
if (line == data->curr_selection)
{
DrawText(">>", 0, y_offset, 12, WHITE);
DrawTextEx(*menu_font, ">>", (Vector2){start_x,y_offset}, FONT_SIZE, 4, BLACK);
}
DrawText("Return", 32, y_offset, 12, WHITE);
y_offset += 12;
DrawTextEx(*menu_font, "Return", (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
y_offset += FONT_SIZE;
line++;
if (data->mode == OPTIONS_KEYBIND_MODE)
{
y_offset += 36;
DrawText("Press a Key...", 32, y_offset, 12, WHITE);
y_offset += FONT_SIZE;
DrawTextEx(*menu_font, "Press a Key...", (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
}
EndTextureMode();
@ -149,7 +163,6 @@ static void wait_for_keymap_input(Scene_t* scene)
static void exec_component_function(Scene_t* scene, uint16_t sel)
{
OptionSceneData_t* data = &(CONTAINER_OF(scene, OptionScene_t, scene)->data);
printf("Sel: %u\n", sel);
if (sel == 0)
{
// Volume option, does nothing
@ -166,7 +179,6 @@ static void exec_component_function(Scene_t* scene, uint16_t sel)
sel -= n_binds;
if (sel == 0)
{
printf("Keybind ready\n");
// OK will propagate to the engine
KeyBindInfo_t info;
sc_array_foreach(&data->keybinds_info, info)