From 1eda151c704278e17de7b0ee88849342706b2bbc Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 10:04:40 +0200 Subject: [PATCH 1/5] Added basic code for banner window --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/window.h | 2 + src/window_banner.c | 211 ++++++++++++++++++++++++++++++ src/window_cheats.c | 4 +- 5 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 src/window_banner.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 3c13ff3f2b..ba0b2c85a4 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -96,6 +96,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 00a17f947b..e542a6e094 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -281,6 +281,9 @@ Source Files + + Windows + diff --git a/src/window.h b/src/window.h index 1aefaf65e4..21d7321eb4 100644 --- a/src/window.h +++ b/src/window.h @@ -275,6 +275,7 @@ enum { WC_CHANGE_KEYBOARD_SHORTCUT = 37, WC_MAP = 38, WC_TITLE_LOGO = 39, + WC_BANNER = 40, WC_EDITOR_OBJECT_SELECTION = 42, WC_EDITOR_INVENTION_LIST = 43, WC_EDITOR_SCENARIO_OPTIONS = 45, @@ -345,6 +346,7 @@ void window_guest_list_open(); void window_park_entrance_open(); void window_park_objective_open(); void window_ride_list_open(); +void window_banner_open(); void window_cheats_open(); void window_guest_list_init_vars_a(); diff --git a/src/window_banner.c b/src/window_banner.c new file mode 100644 index 0000000000..d8fc973a20 --- /dev/null +++ b/src/window_banner.c @@ -0,0 +1,211 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John, Dennis Devriendt + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +#include +#include "addresses.h" +#include "strings.h" +#include "widget.h" +#include "window.h" + +static enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_VIEWPORT, + WIDX_BANNER_TEXT, + WIDX_BANNER_NO_ENTRY, + WIDX_BANNER_DEMOLISH, + WIDX_MAIN_COLOR, + WIDX_TEXT_COLOR_DROPDOWN, + WIDX_TEXT_COLOR_DROPDOWN_BUTTON +}; + +static rct_widget window_banner_widgets[] = { + { WWT_FRAME, 0, 0, 112, 0, 95, 0x0FFFFFFFF, 65535}, // panel / background + { WWT_CAPTION, 0, 1, 111, 1, 14, 0xBA9, STR_WINDOW_TITLE_TIP}, // title bar + { WWT_CLOSEBOX, 0, 100, 110, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP}, // close x button + { WWT_VIEWPORT, 1, 3, 87, 17, 76, 0x0FFFFFFFE, 65535}, // tab content panel + { WWT_FLATBTN, 1, 88, 111, 19, 42, 0x1430, STR_CHANGE_BANNER_TEXT_TIP}, // change banner button + { WWT_FLATBTN, 1, 88, 111, 43, 66, 0x143A, STR_SET_AS_NO_ENTRY_BANNER_TIP}, // no entry button + { WWT_FLATBTN, 1, 88, 111, 67, 90, 0x142D, STR_DEMOLISH_BANNER_TIP}, // demolish button + { WWT_COLORBTN, 1, 5, 16, 80, 91, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP}, // high money + { WWT_DROPDOWN, 1, 43, 81, 80, 91, 0x0FFFFFFFF, 65535}, // high money + { WWT_DROPDOWN_BUTTON, 1, 70, 80, 81, 90, 0x36C, STR_SELECT_TEXT_COLOR_TIP}, // high money + { WIDGETS_END }, +}; + +static void window_banner_emptysub() { } +static void window_banner_mouseup(); +static void window_banner_mousedown(); +static void window_banner_dropdown(); +static void window_banner_textinput(); +static void window_banner_invalidate(); +static void window_banner_paint(); + +static uint32 window_banner_events[] = { + window_banner_emptysub, + window_banner_mouseup, + window_banner_emptysub, + window_banner_mousedown, + window_banner_dropdown, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_textinput, + 0x006BA7B5, //sub_6BA7B5 + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_invalidate, + window_banner_paint, + window_banner_emptysub +}; + +/** +* +* rct2: 0x006BA305 +*/ +void window_banner_open() +{ + rct_window* w; + + // Check if window is already open + w = window_bring_to_front_by_id(WC_BANNER, 0); + if (w != NULL) + return; + + w = window_create_auto_pos(113, 96, window_banner_events, WC_BANNER, 0); + w->widgets = window_banner_widgets; + w->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_BANNER_TEXT) | + (1 << WIDX_BANNER_NO_ENTRY) | + (1 << WIDX_BANNER_DEMOLISH) | + (1 << WIDX_MAIN_COLOR) | + (1 << WIDX_TEXT_COLOR_DROPDOWN) | + (1 << WIDX_TEXT_COLOR_DROPDOWN_BUTTON); + + window_init_scroll_widgets(w); + w->colours[0] = 24; + w->colours[1] = 24; + w->colours[2] = 24; + + // loc_6BA43E + w->flags |= WF_TRANSPARENT; + window_invalidate(w); +} + +static void window_banner_mouseup() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_BANNER_DEMOLISH: + RCT2_CALLPROC_EBPSAFE(0x006BA739); + break; + case WIDX_BANNER_TEXT: + RCT2_CALLPROC_EBPSAFE(0x006BA6BC); + break; + case WIDX_BANNER_NO_ENTRY: + RCT2_CALLPROC_EBPSAFE(0x006BA64D); + break; + } +} + +static void window_banner_mousedown() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_MAIN_COLOR: + RCT2_CALLPROC_EBPSAFE(0x006BA528); + break; + case WIDX_TEXT_COLOR_DROPDOWN_BUTTON: + RCT2_CALLPROC_EBPSAFE(0x006BA563); + break; + } +} + +static void window_banner_dropdown() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_MAIN_COLOR) + RCT2_CALLPROC_EBPSAFE(0x006BA548); + else if (widgetIndex == WIDX_TEXT_COLOR_DROPDOWN_BUTTON) + RCT2_CALLPROC_EBPSAFE(0x006BA5D0); +} + +static void window_banner_textinput() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_BANNER_TEXT) { + RCT2_CALLPROC_EBPSAFE(0x006BA6D8); + } +} + +static void window_banner_invalidate() +{ + RCT2_CALLPROC_EBPSAFE(0x006BA44D); +} + +static void window_banner_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + window_draw_widgets(w, dpi); + + // Draw viewport + if (w->viewport != NULL) { + window_draw_viewport(dpi, w); + } +} diff --git a/src/window_cheats.c b/src/window_cheats.c index 4e9b188f53..50385e2ad3 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,7 +28,6 @@ #include "widget.h" #include "window.h" - #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -207,6 +206,9 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } + + window_park_entrance_open(); + window_banner_open(); } static void window_cheats_guests_mouseup() From 3eff5ebf6f005a3f9ebd0e4434f8ecbf0b30a1cb Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 10:04:40 +0200 Subject: [PATCH 2/5] Added basic code for banner window --- src/window.h | 2 + src/window_banner.c | 211 ++++++++++++++++++++++++++++++++++++++++++++ src/window_cheats.c | 4 +- 3 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 src/window_banner.c diff --git a/src/window.h b/src/window.h index 956507fa1e..01ce98f35c 100644 --- a/src/window.h +++ b/src/window.h @@ -275,6 +275,7 @@ enum { WC_CHANGE_KEYBOARD_SHORTCUT = 37, WC_MAP = 38, WC_TITLE_LOGO = 39, + WC_BANNER = 40, WC_EDITOR_OBJECT_SELECTION = 42, WC_EDITOR_INVENTION_LIST = 43, WC_EDITOR_SCENARIO_OPTIONS = 45, @@ -349,6 +350,7 @@ void window_park_guests_open(); void window_park_objective_open(); void window_park_rating_open(); void window_ride_list_open(); +void window_banner_open(); void window_cheats_open(); void window_guest_list_init_vars_a(); diff --git a/src/window_banner.c b/src/window_banner.c new file mode 100644 index 0000000000..d8fc973a20 --- /dev/null +++ b/src/window_banner.c @@ -0,0 +1,211 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John, Dennis Devriendt + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +#include +#include "addresses.h" +#include "strings.h" +#include "widget.h" +#include "window.h" + +static enum WINDOW_CLEAR_SCENERY_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_VIEWPORT, + WIDX_BANNER_TEXT, + WIDX_BANNER_NO_ENTRY, + WIDX_BANNER_DEMOLISH, + WIDX_MAIN_COLOR, + WIDX_TEXT_COLOR_DROPDOWN, + WIDX_TEXT_COLOR_DROPDOWN_BUTTON +}; + +static rct_widget window_banner_widgets[] = { + { WWT_FRAME, 0, 0, 112, 0, 95, 0x0FFFFFFFF, 65535}, // panel / background + { WWT_CAPTION, 0, 1, 111, 1, 14, 0xBA9, STR_WINDOW_TITLE_TIP}, // title bar + { WWT_CLOSEBOX, 0, 100, 110, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP}, // close x button + { WWT_VIEWPORT, 1, 3, 87, 17, 76, 0x0FFFFFFFE, 65535}, // tab content panel + { WWT_FLATBTN, 1, 88, 111, 19, 42, 0x1430, STR_CHANGE_BANNER_TEXT_TIP}, // change banner button + { WWT_FLATBTN, 1, 88, 111, 43, 66, 0x143A, STR_SET_AS_NO_ENTRY_BANNER_TIP}, // no entry button + { WWT_FLATBTN, 1, 88, 111, 67, 90, 0x142D, STR_DEMOLISH_BANNER_TIP}, // demolish button + { WWT_COLORBTN, 1, 5, 16, 80, 91, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP}, // high money + { WWT_DROPDOWN, 1, 43, 81, 80, 91, 0x0FFFFFFFF, 65535}, // high money + { WWT_DROPDOWN_BUTTON, 1, 70, 80, 81, 90, 0x36C, STR_SELECT_TEXT_COLOR_TIP}, // high money + { WIDGETS_END }, +}; + +static void window_banner_emptysub() { } +static void window_banner_mouseup(); +static void window_banner_mousedown(); +static void window_banner_dropdown(); +static void window_banner_textinput(); +static void window_banner_invalidate(); +static void window_banner_paint(); + +static uint32 window_banner_events[] = { + window_banner_emptysub, + window_banner_mouseup, + window_banner_emptysub, + window_banner_mousedown, + window_banner_dropdown, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_textinput, + 0x006BA7B5, //sub_6BA7B5 + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_emptysub, + window_banner_invalidate, + window_banner_paint, + window_banner_emptysub +}; + +/** +* +* rct2: 0x006BA305 +*/ +void window_banner_open() +{ + rct_window* w; + + // Check if window is already open + w = window_bring_to_front_by_id(WC_BANNER, 0); + if (w != NULL) + return; + + w = window_create_auto_pos(113, 96, window_banner_events, WC_BANNER, 0); + w->widgets = window_banner_widgets; + w->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_BANNER_TEXT) | + (1 << WIDX_BANNER_NO_ENTRY) | + (1 << WIDX_BANNER_DEMOLISH) | + (1 << WIDX_MAIN_COLOR) | + (1 << WIDX_TEXT_COLOR_DROPDOWN) | + (1 << WIDX_TEXT_COLOR_DROPDOWN_BUTTON); + + window_init_scroll_widgets(w); + w->colours[0] = 24; + w->colours[1] = 24; + w->colours[2] = 24; + + // loc_6BA43E + w->flags |= WF_TRANSPARENT; + window_invalidate(w); +} + +static void window_banner_mouseup() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_BANNER_DEMOLISH: + RCT2_CALLPROC_EBPSAFE(0x006BA739); + break; + case WIDX_BANNER_TEXT: + RCT2_CALLPROC_EBPSAFE(0x006BA6BC); + break; + case WIDX_BANNER_NO_ENTRY: + RCT2_CALLPROC_EBPSAFE(0x006BA64D); + break; + } +} + +static void window_banner_mousedown() +{ + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_MAIN_COLOR: + RCT2_CALLPROC_EBPSAFE(0x006BA528); + break; + case WIDX_TEXT_COLOR_DROPDOWN_BUTTON: + RCT2_CALLPROC_EBPSAFE(0x006BA563); + break; + } +} + +static void window_banner_dropdown() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_MAIN_COLOR) + RCT2_CALLPROC_EBPSAFE(0x006BA548); + else if (widgetIndex == WIDX_TEXT_COLOR_DROPDOWN_BUTTON) + RCT2_CALLPROC_EBPSAFE(0x006BA5D0); +} + +static void window_banner_textinput() +{ + short widgetIndex; + + __asm mov widgetIndex, dx; + + if (widgetIndex == WIDX_BANNER_TEXT) { + RCT2_CALLPROC_EBPSAFE(0x006BA6D8); + } +} + +static void window_banner_invalidate() +{ + RCT2_CALLPROC_EBPSAFE(0x006BA44D); +} + +static void window_banner_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + window_draw_widgets(w, dpi); + + // Draw viewport + if (w->viewport != NULL) { + window_draw_viewport(dpi, w); + } +} diff --git a/src/window_cheats.c b/src/window_cheats.c index 4e9b188f53..50385e2ad3 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,7 +28,6 @@ #include "widget.h" #include "window.h" - #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -207,6 +206,9 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } + + window_park_entrance_open(); + window_banner_open(); } static void window_cheats_guests_mouseup() From 6eb635fd2b7592281b79b796cf5d1fd276cec8ea Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 10:15:10 +0200 Subject: [PATCH 3/5] master project files --- projects/openrct2.vcxproj | 4 ---- projects/openrct2.vcxproj.filters | 4 ---- 2 files changed, 8 deletions(-) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 094b40be3e..8438e163f6 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -98,11 +98,7 @@ -<<<<<<< HEAD -======= - ->>>>>>> 1eda151c704278e17de7b0ee88849342706b2bbc diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index c505b74ce7..c11377bf77 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -281,7 +281,6 @@ Source Files -<<<<<<< HEAD Windows @@ -289,9 +288,6 @@ Windows -======= - ->>>>>>> 1eda151c704278e17de7b0ee88849342706b2bbc Windows From 6ddeb610f0dadf403eeedf1e60183c5f2ab8f4e1 Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 20:59:41 +0200 Subject: [PATCH 4/5] Some additions to window_banner --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 +++ src/window_banner.c | 35 +++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 8438e163f6..0bb32ba58a 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -84,6 +84,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index c11377bf77..973add4e53 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -290,6 +290,9 @@ Windows + + Windows + diff --git a/src/window_banner.c b/src/window_banner.c index d8fc973a20..e3766a829d 100644 --- a/src/window_banner.c +++ b/src/window_banner.c @@ -20,7 +20,9 @@ #include #include "addresses.h" +#include "config.h" #include "strings.h" +#include "viewport.h" #include "widget.h" #include "window.h" @@ -80,7 +82,7 @@ static uint32 window_banner_events[] = { window_banner_emptysub, window_banner_emptysub, window_banner_textinput, - 0x006BA7B5, //sub_6BA7B5 + 0x006BA7B5, window_banner_emptysub, window_banner_emptysub, window_banner_emptysub, @@ -96,10 +98,16 @@ static uint32 window_banner_events[] = { */ void window_banner_open() { + rct_windownumber windownumber; rct_window* w; + rct_viewport *viewport; + rct_widget *viewportWidget; + + //__asm mov windownumber, ax // not quite right I think + windownumber = 0; // Check if window is already open - w = window_bring_to_front_by_id(WC_BANNER, 0); + w = window_bring_to_front_by_id(WC_BANNER, windownumber); if (w != NULL) return; @@ -114,13 +122,30 @@ void window_banner_open() (1 << WIDX_TEXT_COLOR_DROPDOWN) | (1 << WIDX_TEXT_COLOR_DROPDOWN_BUTTON); + w->number = windownumber; window_init_scroll_widgets(w); w->colours[0] = 24; w->colours[1] = 24; w->colours[2] = 24; - // loc_6BA43E - w->flags |= WF_TRANSPARENT; + /* + TODO: MISSING CODE 006BA377 -> 006BA3F6, need the banner map element + */ + + // Create viewport + viewportWidget = &window_banner_widgets[WIDX_VIEWPORT]; + viewport_create( + w, + w->x + viewportWidget->left + 1, + w->y + viewportWidget->top + 1, + (viewportWidget->right - viewportWidget->left) - 2, + (viewportWidget->bottom - viewportWidget->top) - 2, + 100, // TODO: needs banner map position + 100 // TODO: needs banner map position + ); + + w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0; + w->flags |= WF_2 | WF_TRANSPARENT; window_invalidate(w); } @@ -151,10 +176,8 @@ static void window_banner_mouseup() static void window_banner_mousedown() { short widgetIndex; - rct_window *w; __asm mov widgetIndex, dx - __asm mov w, esi switch (widgetIndex) { case WIDX_MAIN_COLOR: From b280675ab57a6a549292cb250ff4f5f4230c56ce Mon Sep 17 00:00:00 2001 From: ddevrien Date: Fri, 9 May 2014 21:03:00 +0200 Subject: [PATCH 5/5] cleanup --- src/window_cheats.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/window_cheats.c b/src/window_cheats.c index 50385e2ad3..4e9b188f53 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -28,6 +28,7 @@ #include "widget.h" #include "window.h" + #define WW 200 #define WH 128 #define CHEATS_MONEY_INCREMENT 10000 @@ -206,9 +207,6 @@ static void window_cheats_money_mouseup() window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0); break; } - - window_park_entrance_open(); - window_banner_open(); } static void window_cheats_guests_mouseup()