From 23bb18deea3b0e27e60748921610d03d7a30d6b4 Mon Sep 17 00:00:00 2001 From: hgn Date: Mon, 24 Mar 2025 02:19:28 +0000 Subject: [PATCH] Fix world map centering --- src/menu.c | 13 +++++++++---- src/world_map.c | 33 --------------------------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/src/menu.c b/src/menu.c index d6d2ad3..d381f62 100644 --- a/src/menu.c +++ b/src/menu.c @@ -788,15 +788,17 @@ void menu_gui( ui_context *ctx ) [k_menu_main_guide ] = "Guides" }; + i32 main_index_before = menu.main_index; + if( mtab ) { menu.main_index += mtab; - if( menu.main_index == -1 ) - menu.main_index ++; + if( menu.main_index < 0 ) + menu.main_index = 0; - if( menu.main_index == VG_ARRAY_LEN(opts) ) - menu.main_index --; + if( menu.main_index >= VG_ARRAY_LEN(opts) ) + menu.main_index = VG_ARRAY_LEN(opts)-1; vg_audio_lock(); vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 ); @@ -877,6 +879,9 @@ void menu_gui( ui_context *ctx ) /* PAGE map */ if( menu.main_index == k_menu_main_map ) { + if( menu.main_index != main_index_before ) + world_map_initialize_view(); + menu_backable_to_exit = (vg_input.display_input_method == k_input_method_kbm); menu.bg_blur = 0; diff --git a/src/world_map.c b/src/world_map.c index 2a89476..8dd0dd9 100644 --- a/src/world_map.c +++ b/src/world_map.c @@ -52,39 +52,6 @@ static void respawn_map_draw_icon( vg_camera *cam, enum gui_icon icon, v3f pos, gui_draw_icon( icon, (v2f){ v[0]*0.5f+0.5f,v[1]*0.5f+0.5f }, size ); } -static void world_map_select_close(void) -{ -#if 0 - world_map.sel_spawn = world_map.close_spawn; - gui_helper_reset( k_gui_helper_mode_default ); - - vg_str text; - if( gui_new_helper( input_button_list[k_srbind_maccept], &text ) ) - vg_strcat( &text, "Spawn Here" ); - if( gui_new_helper( input_button_list[k_srbind_mback], &text ) ) - vg_strcat( &text, "Back" ); -#endif -} - -static void world_map_help_normal(void) -{ -#if 0 - gui_helper_reset( k_gui_helper_mode_default ); - - vg_str text; - if( gui_new_helper( input_joy_list[k_srjoystick_steer], &text ) ) - vg_strcat( &text, "Move" ); - - if( gui_new_helper( input_button_list[k_srbind_maccept], &text ) ) - vg_strcat( &text, "Select" ); - -#if 0 - if( gui_new_helper( input_button_list[k_srbind_mback], &text ) ) - vg_strcat( &text, "Exit" ); -#endif -#endif -} - void world_map_initialize_view(void) { world_instance *world = &_world.main; -- 2.25.1