From aa0709c439810c9b2987d599ff642af6c14f5531 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 17 Aug 2014 11:01:34 +0100 Subject: [PATCH 1/2] Fixed clicking on peep causing hybrid --- src/window_peep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/window_peep.c b/src/window_peep.c index 72be7b5007..44ed2e0bc7 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -129,7 +129,8 @@ uint32 window_peep_page_enabled_widgets[] = { void window_peep_open(rct_peep* peep){ if (peep->type == PEEP_TYPE_STAFF){ - RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0); + window_staff_peep_open(peep); + return; } rct_window* window; From b0d39bbf0eeef84bc11c381a707d9d3fbc2244a1 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sun, 17 Aug 2014 11:45:43 +0100 Subject: [PATCH 2/2] Added sepearte file for staff_peep_window --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/window_peep.c | 32 ------ src/window_staff_peep.c | 157 ++++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 32 deletions(-) create mode 100644 src/window_staff_peep.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 55b64865eb..ce7c4ed569 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -123,6 +123,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 65ac515497..6ae0ef6755 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -368,6 +368,9 @@ Windows + + Windows + diff --git a/src/window_peep.c b/src/window_peep.c index 44ed2e0bc7..570e8cddcf 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -174,35 +174,3 @@ void window_peep_open(rct_peep* peep){ window_init_scroll_widgets(window); RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); } - -/** -* -* rct2: 0x006BEE98 -*/ -void window_staff_peep_open(rct_peep* peep) -{ - rct_window* w = window_bring_to_front_by_id(WC_PEEP, peep->sprite_index); - if (!w) { - int eax, ebx, ecx, edx, esi, edi; - - eax = peep->sprite_index; - ecx = WC_PEEP; - edx = peep->sprite_index; - - RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); - w = (rct_window*)esi; - } - - int PEEP_BACKGROUND_IDX = 0; - w->widgets = RCT2_GLOBAL(0x992998, rct_widget*); - w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32); - w->var_020 = RCT2_GLOBAL(0x9929BC, uint32); - w->event_handlers = (uint32*)RCT2_GLOBAL(0x9929A4, uint32); - w->pressed_widgets = 0; - RCT2_CALLPROC_X(0x006BED21, 0, 0, 0, 0, (int)w, 0, 0); - window_init_scroll_widgets(w); - RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0); - if (g_sprite_list[w->number].peep.state == PEEP_STATE_PICKED) { - RCT2_CALLPROC_X(w->event_handlers[1], 0, 0, 0, 10, (int)w, 0, 0); - } -} \ No newline at end of file diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c new file mode 100644 index 0000000000..774569b0f2 --- /dev/null +++ b/src/window_staff_peep.c @@ -0,0 +1,157 @@ +/***************************************************************************** +* Copyright (c) 2014 Ted John, Duncan Frost +* 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 "addresses.h" +#include "game.h" +#include "peep.h" +#include "string_ids.h" +#include "sprite.h" +#include "sprites.h" +#include "widget.h" +#include "window.h" +#include "window_dropdown.h" + +enum WINDOW_STAFF_PEEP_PAGE { + WINDOW_STAFF_PEEP_OVERVIEW, + WINDOW_STAFF_PEEP_OPTIONS, + WINDOW_STAFF_PEEP_STATISTICS, +}; + +enum WINDOW_STAFF_PEEP_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_RESIZE, + WIDX_TAB_1, + WIDX_TAB_2, + WIDX_TAB_3, + WIDX_TAB_4, + WIDX_VIEWPORT, + WIDX_BTM_LABEL, + WIDX_PATROL, + WIDX_RENAME, + WIDX_LOCATE, + WIDX_FIRE +}; + +void window_staff_peep_emptysub(){}; + +rct_widget window_staff_peep_overview_widgets[] = { + { WWT_FRAME, 0, 0, 189, 0, 179, 0x0FFFFFFFF, STR_NONE }, // Panel / Background + { WWT_CAPTION, 0, 1, 188, 1, 14, 0x361, STR_WINDOW_TITLE_TIP }, // Title + { WWT_CLOSEBOX, 0, 177, 187, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP }, // Close x button + { WWT_RESIZE, 1, 0, 189, 43, 179, 0x0FFFFFFFF, STR_NONE }, // Resize + { WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1939 }, // Tab 1 + { WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1945}, // Tab 2 + { WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 2348}, // Tab 3 + { WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, STR_NONE}, // Tab 4 + { WWT_VIEWPORT, 1, 3, 164, 47, 166, 0x0FFFFFFFF, STR_NONE}, // Viewport + { WWT_12, 1, 3, 164, 167, 177, 0x0FFFFFFFF, STR_NONE }, // Label at bottom of viewport + { WWT_FLATBTN, 1, 165, 188, 45, 68, 0x1436, 1706}, // Pickup Button + { WWT_FLATBTN, 1, 165, 188, 69, 92, 0x1437, 1708}, // Patrol Button + { WWT_FLATBTN, 1, 165, 188, 93, 116, 0x1430, 1056}, // Rename Button + { WWT_FLATBTN, 1, 165, 188, 117, 140, 0x142F, 1027}, // Locate Button + { WWT_FLATBTN, 1, 165, 188, 141, 164, 0x142D, 1705}, // Fire Button + { WIDGETS_END }, +}; + +rct_widget *window_staff_peep_page_widgets[] = { + window_staff_peep_overview_widgets +}; + +static void* window_staff_peep_overview_events[] = { + (void*)0x6BDFF8, + (void*)0x6BDF55, + (void*)0x6BE558, + (void*)0x6BDF98, + (void*)0x6BDFA3, + window_staff_peep_emptysub, + (void*)0x6BE602, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDFD8, + (void*)0x6BDFC3, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDFAE, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDFED, + (void*)0x6BE5FC, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + window_staff_peep_emptysub, + (void*)0x6BDD91, //Invalidate + (void*)0x6BDEAF, //Paint + (void*)0x6BE62A +}; + +void* window_staff_peep_page_events[] = { + window_staff_peep_overview_events +}; + +uint32 window_staff_peep_page_enabled_widgets[] = { + (1 << WIDX_CLOSE) | + (1 << WIDX_TAB_1) | + (1 << WIDX_TAB_2) | + (1 << WIDX_TAB_3) | + (1 << WIDX_PATROL) | + (1 << WIDX_RENAME) | + (1 << WIDX_LOCATE) | + (1 << WIDX_FIRE) | + (1 << 14) +}; + +/** +* +* rct2: 0x006BEE98 +*/ +void window_staff_peep_open(rct_peep* peep) +{ + rct_window* w = window_bring_to_front_by_id(WC_PEEP, peep->sprite_index); + if (!w) { + int eax, ebx, ecx, edx, esi, edi; + + eax = peep->sprite_index; + ecx = WC_PEEP; + edx = peep->sprite_index; + + RCT2_CALLFUNC_X(0x006BEF1B, &eax, &ebx, &ecx, &edx, &esi, &edi, (int*)peep); + w = (rct_window*)esi; + } + w->page = 0; + window_invalidate(w); + + w->widgets = window_staff_peep_overview_widgets; + w->enabled_widgets = window_staff_peep_page_enabled_widgets[0]; + w->var_020 = RCT2_GLOBAL(0x9929BC, uint32); + w->event_handlers = window_staff_peep_page_events[0]; + w->pressed_widgets = 0; + RCT2_CALLPROC_X(0x006BED21, 0, 0, 0, 0, (int)w, 0, 0); + window_init_scroll_widgets(w); + RCT2_CALLPROC_X(0x006BEDA3, 0, 0, 0, 0, (int)w, 0, 0); + if (g_sprite_list[w->number].peep.state == PEEP_STATE_PICKED) { + RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_UP], 0, 0, 0, 10, (int)w, 0, 0); + } +} \ No newline at end of file