From eaec44e8965633764c7f73ca190b89421f9cd73c Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 24 Apr 2014 20:26:05 +0100 Subject: [PATCH] refactor window flags --- src/window.c | 14 +++++++------- src/window.h | 4 ++-- src/window_dropdown.c | 2 +- src/window_game_bottom_toolbar.c | 8 +++++++- src/window_game_top_toolbar.c | 8 +++++++- src/window_main.c | 8 +++++++- src/window_title_exit.c | 8 +++++--- src/window_title_logo.c | 2 +- src/window_title_menu.c | 8 +++++--- src/window_title_scenarioselect.c | 2 +- src/window_tooltip.c | 2 +- 11 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/window.c b/src/window.c index 317e7e5ae3..ca03fed6dd 100644 --- a/src/window.c +++ b/src/window.c @@ -109,7 +109,7 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han if (RCT2_NEW_WINDOW == &(RCT2_FIRST_WINDOW[12])) { // Close least recently used window for (w = RCT2_FIRST_WINDOW; w < RCT2_NEW_WINDOW; w++) - if (!(w->flags & (WF_0 | WF_1 | WF_9))) + if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT | WF_9))) break; window_close(w); @@ -118,16 +118,16 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han w = RCT2_NEW_WINDOW; // Flags - if (flags & WF_0) { + if (flags & WF_STICK_TO_BACK) { for (; w >= RCT2_FIRST_WINDOW + 1; w--) { - if ((w - 1)->flags & WF_1) + if ((w - 1)->flags & WF_STICK_TO_FRONT) continue; - if ((w - 1)->flags & WF_0) + if ((w - 1)->flags & WF_STICK_TO_BACK) break; } - } else if (!(flags & WF_1)) { + } else if (!(flags & WF_STICK_TO_FRONT)) { for (; w >= RCT2_FIRST_WINDOW + 1; w--) { - if (!((w - 1)->flags & WF_1)) + if (!((w - 1)->flags & WF_STICK_TO_FRONT)) break; } } @@ -143,7 +143,7 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han w->flags = flags; // Play sound - if (!(flags & (WF_0 | WF_1))) + if (!(flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) sound_play_panned(40, x + (width / 2)); w->number = 0; diff --git a/src/window.h b/src/window.h index 0b163c5ded..afb2b8b7c1 100644 --- a/src/window.h +++ b/src/window.h @@ -186,8 +186,8 @@ typedef enum { WF_DISABLE_VP_SCROLL = 1 << 9, */ - WF_0 = (1 << 0), - WF_1 = (1 << 1), + WF_STICK_TO_BACK = (1 << 0), + WF_STICK_TO_FRONT = (1 << 1), WF_TRANSPARENT = (1 << 4), WF_5 = (1 << 5), WF_RESIZABLE = (1 << 8), diff --git a/src/window_dropdown.c b/src/window_dropdown.c index bd3c2105a5..0aecd65450 100644 --- a/src/window_dropdown.c +++ b/src/window_dropdown.c @@ -239,7 +239,7 @@ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 fl window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1, window_dropdown_events, WC_DROPDOWN, - 0x02 + WF_STICK_TO_FRONT ); w->widgets = window_dropdown_widgets; if (colour & 0x80) diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 02efcc0374..874be85acb 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -114,7 +114,13 @@ void window_game_bottom_toolbar_open() { rct_window* window; - window = window_create(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 32, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 32, window_game_bottom_toolbar_events, WC_BOTTOM_TOOLBAR, 0x32); + window = window_create( + 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 32, + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 32, + window_game_bottom_toolbar_events, + WC_BOTTOM_TOOLBAR, + WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_5 + ); window->widgets = window_game_bottom_toolbar_widgets; window->enabled_widgets |= (1 << WIDX_LEFT_OUTSET) | diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index 47fbe45d98..25dde9bf47 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -120,7 +120,13 @@ void window_game_top_toolbar_open() { rct_window* window; - window = window_create(0, 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 28, window_game_top_toolbar_events, WC_TOP_TOOLBAR, 0x32); + window = window_create( + 0, 0, + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 28, + window_game_top_toolbar_events, + WC_TOP_TOOLBAR, + WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_5 + ); window->widgets = window_game_top_toolbar_widgets; window->enabled_widgets |= (1 | 2 | 4 | 8 | 0x10 | 0x20 | 0x40 | 0x80 | 0x100 | 0x200 | 0x400 | 0x800 | 0x1000 | 0x2000 | 0x4000 | 0x8000 | 0x10000 | 0x20000); diff --git a/src/window_main.c b/src/window_main.c index 1beb21e1d9..ba79333998 100644 --- a/src/window_main.c +++ b/src/window_main.c @@ -38,7 +38,13 @@ void window_main_open() main_widgets[0].right = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16); main_widgets[0].bottom = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16); - window = window_create(0, 0, window_main_widgets[0].right, window_main_widgets[0].bottom, 0x0097C0BC, WC_MAIN_WINDOW, 0x01); + window = window_create( + 0, 0, + window_main_widgets[0].right, window_main_widgets[0].bottom, + 0x0097C0BC, + WC_MAIN_WINDOW, + WF_STICK_TO_BACK + ); window->widgets = main_widgets; // RCT2_CALLPROC_X(0x006EB009, window->x, window->y, 0x4000000, 0x0FFF0FFF, window, 0, 0); diff --git a/src/window_title_exit.c b/src/window_title_exit.c index 2d042d3a36..bcfe070da5 100644 --- a/src/window_title_exit.c +++ b/src/window_title_exit.c @@ -38,9 +38,11 @@ void window_title_exit_open() rct_window* window; window = window_create( - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 40, - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 64, - 40, 64, 0x0097BEFC, WC_TITLE_EXIT, 0x02 + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 40, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 64, + 40, 64, + 0x0097BEFC, + WC_TITLE_EXIT, + WF_STICK_TO_FRONT ); window->widgets = window_title_exit_widgets; window->enabled_widgets |= 1; diff --git a/src/window_title_logo.c b/src/window_title_logo.c index 354a824b1b..2fde8c1fc6 100644 --- a/src/window_title_logo.c +++ b/src/window_title_logo.c @@ -44,7 +44,7 @@ void window_title_logo_open() packs++; // Create the window - window = window_create(0, 0, 200, 106 + (10 * packs), 0x0097BF6C, WC_TITLE_LOGO, 0x02); + window = window_create(0, 0, 200, 106 + (10 * packs), 0x0097BF6C, WC_TITLE_LOGO, WF_STICK_TO_FRONT); window->widgets = 0x009A9658; // mouse move bug in original game, keep this address and no crash happens window_init_scroll_widgets(window); window->flags |= 16; diff --git a/src/window_title_menu.c b/src/window_title_menu.c index 1434e1fe96..265e2501ac 100644 --- a/src/window_title_menu.c +++ b/src/window_title_menu.c @@ -89,9 +89,11 @@ void window_title_menu_open() rct_window* window; window = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 328) / 2, - RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 142, - 328, 82, window_title_menu_events, WC_TITLE_MENU, 0x02 + (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 328) / 2, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 142, + 328, 82, + window_title_menu_events, + WC_TITLE_MENU, + WF_STICK_TO_FRONT ); window->widgets = window_title_menu_widgets; window->enabled_widgets |= (8 | 4 | 2 | 1); diff --git a/src/window_title_scenarioselect.c b/src/window_title_scenarioselect.c index 3f7630e170..00556c1ee2 100644 --- a/src/window_title_scenarioselect.c +++ b/src/window_title_scenarioselect.c @@ -118,7 +118,7 @@ void window_scenarioselect_open() 334, window_scenarioselect_events, WC_SCENARIO_SELECT, - 0x400 | 0x02 + WF_STICK_TO_FRONT | WF_10 ); window->widgets = window_scenarioselect_widgets; diff --git a/src/window_tooltip.c b/src/window_tooltip.c index c3cb6aab49..00127affb3 100644 --- a/src/window_tooltip.c +++ b/src/window_tooltip.c @@ -141,7 +141,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y x = clamp(0, x - (width / 2), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width); y = clamp(22, y + 26, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height - 40); - w = window_create(x, y, width, height, window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_1); + w = window_create(x, y, width, height, window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT); w->widgets = window_tooltip_widgets; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) = 0;