Spice up the option screen
parent
18064ddf3c
commit
0088fd64de
|
@ -50,61 +50,75 @@ static void options_scene_render_func(Scene_t* scene)
|
||||||
|
|
||||||
KeyBindInfo_t keybind_info;
|
KeyBindInfo_t keybind_info;
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
int y_offset = 16;
|
int y_offset = 32;
|
||||||
uint16_t line = 0;
|
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);
|
BeginTextureMode(scene->layers.render_layers[0].layer_tex);
|
||||||
ClearBackground((Color){0,0,0,0});
|
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)
|
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();
|
float vol = GetMasterVolume();
|
||||||
sprintf(buffer, "Volume : %.1f", vol);
|
sprintf(buffer, "Volume : %.1f", vol);
|
||||||
DrawText(buffer, 32, y_offset, 12, WHITE);
|
DrawTextEx(*menu_font, buffer, (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
|
||||||
y_offset += 12;
|
y_offset += FONT_SIZE;
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
sc_array_foreach(&data->keybinds_info, keybind_info) {
|
sc_array_foreach(&data->keybinds_info, keybind_info) {
|
||||||
if (line == data->curr_selection)
|
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)
|
if (keybind_info.key == keybind_info.original_key)
|
||||||
{
|
{
|
||||||
sprintf(buffer, "%s : %s", keybind_info.action_name, keybind_info.key_name);
|
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
|
else
|
||||||
{
|
{
|
||||||
sprintf(buffer, "%s : %s => %s", keybind_info.action_name, keybind_info.original_key_name, keybind_info.key_name);
|
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++;
|
line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
y_offset += FONT_SIZE;
|
||||||
if (line == data->curr_selection)
|
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);
|
DrawTextEx(*menu_font, "Apply", (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
|
||||||
y_offset += 12;
|
y_offset += FONT_SIZE;
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
if (line == data->curr_selection)
|
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);
|
DrawTextEx(*menu_font, "Return", (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
|
||||||
y_offset += 12;
|
y_offset += FONT_SIZE;
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
if (data->mode == OPTIONS_KEYBIND_MODE)
|
if (data->mode == OPTIONS_KEYBIND_MODE)
|
||||||
{
|
{
|
||||||
y_offset += 36;
|
y_offset += FONT_SIZE;
|
||||||
DrawText("Press a Key...", 32, y_offset, 12, WHITE);
|
DrawTextEx(*menu_font, "Press a Key...", (Vector2){start_x+32, y_offset}, FONT_SIZE, 4, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndTextureMode();
|
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)
|
static void exec_component_function(Scene_t* scene, uint16_t sel)
|
||||||
{
|
{
|
||||||
OptionSceneData_t* data = &(CONTAINER_OF(scene, OptionScene_t, scene)->data);
|
OptionSceneData_t* data = &(CONTAINER_OF(scene, OptionScene_t, scene)->data);
|
||||||
printf("Sel: %u\n", sel);
|
|
||||||
if (sel == 0)
|
if (sel == 0)
|
||||||
{
|
{
|
||||||
// Volume option, does nothing
|
// Volume option, does nothing
|
||||||
|
@ -166,7 +179,6 @@ static void exec_component_function(Scene_t* scene, uint16_t sel)
|
||||||
sel -= n_binds;
|
sel -= n_binds;
|
||||||
if (sel == 0)
|
if (sel == 0)
|
||||||
{
|
{
|
||||||
printf("Keybind ready\n");
|
|
||||||
// OK will propagate to the engine
|
// OK will propagate to the engine
|
||||||
KeyBindInfo_t info;
|
KeyBindInfo_t info;
|
||||||
sc_array_foreach(&data->keybinds_info, info)
|
sc_array_foreach(&data->keybinds_info, info)
|
||||||
|
|
Loading…
Reference in New Issue