Skip to content

Commit

Permalink
Rewrote calculations for menu centering
Browse files Browse the repository at this point in the history
The centering is still off, but only by 1 pixel, so it's negligible.
Still need to test on mobile.

Fixes #154
  • Loading branch information
AlexKhayrullin committed Mar 14, 2021
1 parent e2b082b commit 6d2272c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions SonicTimeTwisted.gmx/scripts/menu_fn_set_scripts.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)));
Expand Down
2 changes: 2 additions & 0 deletions SonicTimeTwisted.gmx/scripts/menu_fn_step_default.gml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ switch(state)
}
if(timer >= 10)
{
internal__menu_slide_offset_x = 0;
timer = 0;
state = 2;
}
Expand Down Expand Up @@ -246,6 +247,7 @@ switch(state)
}
if(timer >= 10)
{
internal__menu_slide_offset_x = 0;
timer = 0;
state = 2;
}
Expand Down

0 comments on commit 6d2272c

Please sign in to comment.