From 66c302eb3dbcd74c8bf831c39efb8290d187e58c Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 14 Feb 2015 18:26:59 +0000 Subject: [PATCH] use new create_window_centred function --- src/interface/window.c | 2 +- src/windows/about.c | 4 +--- src/windows/demolish_ride_prompt.c | 8 +------- src/windows/editor_inventions_list.c | 4 +--- src/windows/editor_object_selection.c | 4 +--- src/windows/editor_objective_options.c | 4 +--- src/windows/editor_scenario_options.c | 4 +--- src/windows/mapgen.c | 4 +--- src/windows/music_credits.c | 4 +--- src/windows/publisher_credits.c | 4 +--- src/windows/save_prompt.c | 26 ++++++++++++-------------- src/windows/staff_fire_prompt.c | 8 +------- src/windows/text_input.c | 4 +--- src/windows/title_scenarioselect.c | 4 +--- src/windows/track_manage.c | 4 +--- 15 files changed, 26 insertions(+), 62 deletions(-) diff --git a/src/interface/window.c b/src/interface/window.c index 5c3c0c4d86..a6b3a056e3 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -462,7 +462,7 @@ rct_window *window_create_centred(int width, int height, uint32 *event_handlers, int x, y; x = (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width) / 2; - y = (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height) / 2; + y = max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height) / 2); return window_create(x, y, width, height, event_handlers, cls, flags); } diff --git a/src/windows/about.c b/src/windows/about.c index 78922b0c05..f6c82139d0 100644 --- a/src/windows/about.c +++ b/src/windows/about.c @@ -89,9 +89,7 @@ void window_about_open() if (window != NULL) return; - window = window_create( - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2 - 200, - max(28, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 165), + window = window_create_centred( 400, 330, (uint32*)window_about_events, diff --git a/src/windows/demolish_ride_prompt.c b/src/windows/demolish_ride_prompt.c index fc2d9aad4f..dca45ce62f 100644 --- a/src/windows/demolish_ride_prompt.c +++ b/src/windows/demolish_ride_prompt.c @@ -93,13 +93,7 @@ void window_ride_demolish_prompt_open(int rideIndex){ if (w != NULL) return; - // Find center of the screen. - int screen_height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16); - int screen_width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16); - int x = screen_width / 2 - WW / 2; - int y = screen_height / 2 - WH / 2; - - w = window_create(x, y, WW, WH, (uint32*)window_ride_demolish_events, WC_DEMOLISH_RIDE_PROMPT, 0); + w = window_create_centred(WW, WH, (uint32*)window_ride_demolish_events, WC_DEMOLISH_RIDE_PROMPT, 0); w->widgets = window_ride_demolish_widgets; w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_CANCEL) | (1 << WIDX_DEMOLISH); window_init_scroll_widgets(w); diff --git a/src/windows/editor_inventions_list.c b/src/windows/editor_inventions_list.c index fc2fd22967..5b9790843e 100644 --- a/src/windows/editor_inventions_list.c +++ b/src/windows/editor_inventions_list.c @@ -415,9 +415,7 @@ void window_editor_inventions_list_open() sub_685901(); - w = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 600) / 2, - max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 400) / 2), + w = window_create_centred( 600, 400, (uint32*)window_editor_inventions_list_events, diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index df902e41ee..57a0940249 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -207,9 +207,7 @@ void window_editor_object_selection_open() if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) window_editor_object_selection_select_default_objects(); - window = window_create( - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2 - 300, - max(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 200, 28), + window = window_create_centred( 600, 400, (uint32*)window_editor_object_selection_events, diff --git a/src/windows/editor_objective_options.c b/src/windows/editor_objective_options.c index d417c30436..abea327c67 100644 --- a/src/windows/editor_objective_options.c +++ b/src/windows/editor_objective_options.c @@ -254,9 +254,7 @@ void window_editor_objective_options_open() if (w != NULL) return; - w = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 450) / 2, - max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 228) / 2), + w = window_create_centred( 450, 228, (uint32*)window_objective_options_main_events, diff --git a/src/windows/editor_scenario_options.c b/src/windows/editor_scenario_options.c index 9ce4e60535..bbcdccbb80 100644 --- a/src/windows/editor_scenario_options.c +++ b/src/windows/editor_scenario_options.c @@ -339,9 +339,7 @@ void window_editor_scenario_options_open() if (w != NULL) return; - w = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 280) / 2, - max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 148) / 2), + w = window_create_centred( 280, 148, window_editor_scenario_options_page_events[0], diff --git a/src/windows/mapgen.c b/src/windows/mapgen.c index a704ba1eb4..9803bae4d7 100644 --- a/src/windows/mapgen.c +++ b/src/windows/mapgen.c @@ -264,9 +264,7 @@ rct_window *window_mapgen_open() w = window_bring_to_front_by_class(WC_MAPGEN); if (w == NULL) { - w = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 300) / 2, - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 200) / 2, + w = window_create_centred( 300, 200, window_mapgen_page_events[0], diff --git a/src/windows/music_credits.c b/src/windows/music_credits.c index 63158c5bbe..2c8891308c 100644 --- a/src/windows/music_credits.c +++ b/src/windows/music_credits.c @@ -88,9 +88,7 @@ void window_music_credits_open() if (window != NULL) return; - window = window_create( - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2 - 255, - max(28, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 157), + window = window_create_centred( 510, 314, (uint32*)window_music_credits_events, diff --git a/src/windows/publisher_credits.c b/src/windows/publisher_credits.c index 1a77ac8a52..37896872ce 100644 --- a/src/windows/publisher_credits.c +++ b/src/windows/publisher_credits.c @@ -88,9 +88,7 @@ void window_publisher_credits_open() if (window != NULL) return; - window = window_create( - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2 - 210, - max(28, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 192), + window = window_create_centred( 420, 384, (uint32*)window_publisher_credits_events, diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index 5bbc3daca1..f849e37bbd 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -109,7 +109,7 @@ static void* window_save_prompt_events[] = { */ void window_save_prompt_open() { - int stringId, x, y; + int stringId, width, height; rct_window* window; unsigned short prompt_mode; rct_widget *widgets; @@ -135,8 +135,8 @@ void window_save_prompt_open() (1 << WQIDX_CLOSE) | (1 << WQIDX_OK) | (1 << WQIDX_CANCEL); - x = 177; - y = 34; + width = 177; + height = 34; } else { widgets = window_save_prompt_widgets; enabled_widgets = @@ -144,19 +144,17 @@ void window_save_prompt_open() (1 << WIDX_SAVE) | (1 << WIDX_DONT_SAVE) | (1 << WIDX_CANCEL); - x = 260; - y = 50; + width = 260; + height = 50; } - window = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - x / 2, - max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - y / 2), - x, - y, - (uint32*)window_save_prompt_events, - WC_SAVE_PROMPT, - WF_TRANSPARENT | WF_STICK_TO_FRONT - ); + window = window_create_centred( + width, + height, + (uint32*)window_save_prompt_events, + WC_SAVE_PROMPT, + WF_TRANSPARENT | WF_STICK_TO_FRONT + ); window->widgets = widgets; window->enabled_widgets = enabled_widgets; diff --git a/src/windows/staff_fire_prompt.c b/src/windows/staff_fire_prompt.c index f39248d39e..ce6ca7909c 100644 --- a/src/windows/staff_fire_prompt.c +++ b/src/windows/staff_fire_prompt.c @@ -91,13 +91,7 @@ void window_staff_fire_prompt_open(rct_peep* peep){ return; } - // Find center of the screen. - int screen_height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16); - int screen_width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16); - int x = screen_width / 2 - WW / 2; - int y = screen_height / 2 - WH / 2; - - rct_window* w = window_create(x, y, WW, WH, (uint32*)0x992C3C, 0x1A, 0); + rct_window* w = window_create_centred(WW, WH, (uint32*)0x992C3C, 0x1A, 0); w->widgets = window_staff_fire_widgets; w->enabled_widgets |= (1 << WIDX_CLOSE) | (1 << WIDX_YES) | (1 << WIDX_CANCEL); diff --git a/src/windows/text_input.c b/src/windows/text_input.c index a5291e1328..951f15b92a 100644 --- a/src/windows/text_input.c +++ b/src/windows/text_input.c @@ -130,9 +130,7 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t int height = no_lines * 10 + WH; // Window will be in the center of the screen - rct_window* w = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - WW / 2, - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - height / 2, + rct_window* w = window_create_centred( WW, height, (uint32*)window_text_input_events, diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index ab4bc96da2..bb5c841920 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -111,9 +111,7 @@ void window_scenarioselect_open() // Load scenario list scenario_load_list(); - window = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - 305, - max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 167), + window = window_create_centred( 610, 334, (uint32*)window_scenarioselect_events, diff --git a/src/windows/track_manage.c b/src/windows/track_manage.c index 17a60a0818..5da91f3f94 100644 --- a/src/windows/track_manage.c +++ b/src/windows/track_manage.c @@ -150,9 +150,7 @@ void window_track_manage_open() window_close_by_class(WC_MANAGE_TRACK_DESIGN); - w = window_create( - max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 250) / 2), - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 44) / 2, + w = window_create_centred( 250, 44, (uint32*)window_track_manage_events,