From aedf18776c8e4b57f0f8304f0fdd7c0ad543dd6c Mon Sep 17 00:00:00 2001 From: hgn Date: Tue, 11 Jan 2022 23:21:23 +0000 Subject: [PATCH] added simple settings window --- fishladder.c | 125 +++++++++++++++++++++++++++++++++++------- maps/dev_settings.map | 10 ++++ 2 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 maps/dev_settings.map diff --git a/fishladder.c b/fishladder.c index 08406bc..5948f62 100644 --- a/fishladder.c +++ b/fishladder.c @@ -388,27 +388,27 @@ m3x3f m_mdl; static int colour_set_id = 0; -static void colour_code_v3( char const cc, v3f target ) +static v3f colour_sets[][4] = { - static v3f colour_sets[][4] = - { - { { 1.0f, 0.9f, 0.3f }, // Yellow - { 0.4f, 0.8f, 1.00f }, // Blue - { 0.2f, 0.9f, 0.14f }, // Green - { 0.882f, 0.204f, 0.922f } // Pink - }, - { { 1.0f, 0.9f, 0.3f }, // Yellow - { 0.4f, 0.8f, 1.00f }, // Blue - { 0.85f, 0.85f, 0.85f }, // Weiss - { 0.2f, 0.2f, 0.2f } // Black/Gray - }, - { { 1.0f, 0.9f, 0.3f }, // Yellow - { 0.827f, 0.373f, 0.718f }, // Pink - { 0.0f, 0.353f, 0.71f }, // Blue - { 0.863f, 0.196f, 0.125f } // Red - }, - }; + { { 1.0f, 0.9f, 0.3f }, // Yellow + { 0.4f, 0.8f, 1.00f }, // Blue + { 0.2f, 0.9f, 0.14f }, // Green + { 0.882f, 0.204f, 0.922f } // Pink + }, + { { 1.0f, 0.9f, 0.3f }, // Yellow + { 0.4f, 0.8f, 1.00f }, // Blue + { 0.85f, 0.85f, 0.85f }, // Weiss + { 0.2f, 0.2f, 0.2f } // Black/Gray + }, + { { 1.0f, 0.9f, 0.3f }, // Yellow + { 0.827f, 0.373f, 0.718f }, // Pink + { 0.0f, 0.353f, 0.71f }, // Blue + { 0.863f, 0.196f, 0.125f } // Red + }, +}; +static void colour_code_v3( char const cc, v3f target ) +{ if( cc >= 'a' && cc <= 'z' ) { int id = cc - 'a'; @@ -2953,7 +2953,92 @@ void vg_render(void) */ } -void vg_ui(void) {} +void vg_ui(void) +{ + if( world.st.state == k_game_state_settings ) + { + gui_group_id( 35 ); + + ui_global_ctx.cursor[2] = 225; + gui_fill_y(); + gui_align_right(); + + gui_new_node(); + { + gui_capture_mouse( 200 ); + + gui_fill_rect( ui_global_ctx.cursor, 0xC0202020 ); + ui_rect_pad( ui_global_ctx.cursor, 8 ); + + ui_global_ctx.cursor[3] = 25; + + gui_new_node(); + { + gui_text( "Settings", 3 ); + } + gui_end(); + + // Colour scheme selection + ui_global_ctx.cursor[1] += 30; + + gui_text( "Colour Scheme", 2 ); + ui_global_ctx.cursor[1] += 25; + + gui_new_node(); + { + ui_global_ctx.cursor[2] = 50; + + for( int i = 0; i < 4; i ++ ) + { + gui_new_node(); + { + // Convert to RGB + u32 rgb = 0xff000000; + + for( int j = 0; j < 3; j ++ ) + rgb |= (u32)(colour_sets[ colour_set_id ][i][j]*255.0f) << j * 8; + + gui_fill_rect( ui_global_ctx.cursor, rgb ); + } + gui_end_right(); + } + } + gui_end_down(); + + gui_new_node(); + { + ui_global_ctx.cursor[2] = 25; + if( gui_button( 0 ) == k_button_click ) + { + if( colour_set_id > 0 ) + colour_set_id --; + } + gui_text( "<", 2 ); + gui_end_right(); + + ui_global_ctx.cursor[2] = 150; + gui_new_node(); + { + ui_global_ctx.cursor[0] += 45; + ui_global_ctx.cursor[1] += 6; + gui_text( (const char *[]){ "Normal", "Extra1", "Extra2" }[ colour_set_id ], 2 ); + } + gui_end_right(); + + ui_global_ctx.cursor[2] = 25; + if( gui_button( 1 ) == k_button_click ) + { + if( colour_set_id < vg_list_size( colour_sets )-1 ) + colour_set_id ++; + } + gui_text( ">", 2 ); + gui_end_down(); + } + gui_end_down(); + } + gui_end(); + } +} #if STEAM_LEADERBOARDS void leaderboard_dispatch_score(void) diff --git a/maps/dev_settings.map b/maps/dev_settings.map new file mode 100644 index 0000000..8f0bf71 --- /dev/null +++ b/maps/dev_settings.map @@ -0,0 +1,10 @@ +##############; +##############; +## ##; +## ##; +## ##; +## ##; +## ##; +## ##; +##############; +##############; -- 2.25.1