From 6d2272c3cdce655739f3f5d0967eeac685b16980 Mon Sep 17 00:00:00 2001 From: AlexKhayrullin Date: Sun, 14 Mar 2021 13:05:58 +0200 Subject: [PATCH] Rewrote calculations for menu centering The centering is still off, but only by 1 pixel, so it's negligible. Still need to test on mobile. Fixes #154 --- .../scripts/menu_fn_set_scripts.gml | 17 ++++++++++------- .../scripts/menu_fn_step_default.gml | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/SonicTimeTwisted.gmx/scripts/menu_fn_set_scripts.gml b/SonicTimeTwisted.gmx/scripts/menu_fn_set_scripts.gml index 07ee8d033..b1977fecf 100644 --- a/SonicTimeTwisted.gmx/scripts/menu_fn_set_scripts.gml +++ b/SonicTimeTwisted.gmx/scripts/menu_fn_set_scripts.gml @@ -11,15 +11,17 @@ if(DEVICE_INFO & DEVICE_TYPE_SMARTPHONE) } var view_height = view_hview[view_current]; -internal__draw_menu_buttons_offset_x = (view_width - button_width)/2; internal__draw_menu_buttons_offset_y = (view_height - min(internal__button_count, button_page_count)*button_slot_height)/2; +internal__draw_menu_rect_x_center = view_width/2; +internal__draw_menu_rect_y_center = view_height/2; + +internal__draw_menu_buttons_offset_x = internal__draw_menu_rect_x_center - (button_width/2); internal__draw_menu_rect_x1 = internal__draw_menu_buttons_offset_x - margin; internal__draw_menu_rect_x2 = internal__draw_menu_buttons_offset_x + button_width + margin; -internal__draw_menu_rect_x_center = view_width/2; + internal__draw_menu_rect_y1 = internal__draw_menu_buttons_offset_y - margin; internal__draw_menu_rect_y2 = internal__draw_menu_buttons_offset_y + (min(internal__button_count, button_page_count) * button_slot_height) + margin; -internal__draw_menu_rect_y_center = view_height/2; if(argument1 == -1) { @@ -55,12 +57,13 @@ if(is_touchscreen) scroll = 0; scroll_target = 0; scrollable = internal__button_count > button_page_count; + if(scrollable) { - internal__draw_menu_buttons_offset_x = internal__draw_menu_buttons_offset_x - margin; - internal__draw_menu_rect_x1 = internal__draw_menu_rect_x1 - margin; - internal__draw_menu_rect_x2 = internal__draw_menu_rect_x2 + margin; - internal__draw_menu_rect_x_center = view_width/2 - margin; + internal__draw_menu_rect_x_center -= margin; + internal__draw_menu_buttons_offset_x -= margin; + internal__draw_menu_rect_x1 -= margin; + internal__draw_menu_rect_x2 += margin; scroll_max = internal__button_count - button_page_count; scroll_target = min(scroll_max, max(0, scroll_anchor - (button_page_count div 2))); diff --git a/SonicTimeTwisted.gmx/scripts/menu_fn_step_default.gml b/SonicTimeTwisted.gmx/scripts/menu_fn_step_default.gml index d9da6f4d0..57ea7448b 100644 --- a/SonicTimeTwisted.gmx/scripts/menu_fn_step_default.gml +++ b/SonicTimeTwisted.gmx/scripts/menu_fn_step_default.gml @@ -209,6 +209,7 @@ switch(state) } if(timer >= 10) { + internal__menu_slide_offset_x = 0; timer = 0; state = 2; } @@ -246,6 +247,7 @@ switch(state) } if(timer >= 10) { + internal__menu_slide_offset_x = 0; timer = 0; state = 2; }