Fix world map centering
authorhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 02:19:28 +0000 (02:19 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 02:19:28 +0000 (02:19 +0000)
src/menu.c
src/world_map.c

index d6d2ad3e34007d51d29c9a8750bb9572e84f2729..d381f62b60c332df6741909b7916906e30570f6f 100644 (file)
@@ -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;
 
index 2a89476fb38bf528e4dad1e66227bf59acebba32..8dd0dd9aa2cd717ff9f2aad87378f1bd64f87e00 100644 (file)
@@ -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;