From 719ca2ddd2ea29a458f1371617eba9f12e39e8eb Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 7 Oct 2014 20:57:02 +0100 Subject: [PATCH] Added start of window_staff_fire. Refactored some of window_staff_peep --- src/interface/window.h | 1 + src/localisation/string_ids.h | 2 + src/window_staff_fire.c | 144 ++++++++++++++++++++++++++++++++++ src/windows/staff.c | 73 +++-------------- 4 files changed, 156 insertions(+), 64 deletions(-) create mode 100644 src/window_staff_fire.c diff --git a/src/interface/window.h b/src/interface/window.h index 1242215e0d..7a47b7ccc2 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -480,6 +480,7 @@ void window_shortcut_keys_open(); void window_shortcut_change_open(int selected_key); void window_guest_open(rct_peep* peep); void window_staff_open(rct_peep* peep); +void window_staff_fire_open(rct_peep* peep); void window_park_awards_open(); void window_park_entrance_open(); void window_park_guests_open(); diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index ec9639b635..9e8bb66060 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -439,6 +439,8 @@ enum { STR_TOO_MANY_STAFF_IN_GAME = 1707, + STR_YES = 1710, + STR_CANT_RENAME_PARK = 1717, STR_PARK_NAME = 1718, STR_ENTER_PARK_NAME = 1719, diff --git a/src/window_staff_fire.c b/src/window_staff_fire.c new file mode 100644 index 0000000000..fdf729ef47 --- /dev/null +++ b/src/window_staff_fire.c @@ -0,0 +1,144 @@ +/***************************************************************************** +* 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 "peep.h" +#include "string_ids.h" +#include "sprite.h" +#include "sprites.h" +#include "widget.h" +#include "window.h" +#include "staff.h" + +#define WW 200 +#define WH 100 + +enum WINDOW_STAFF_FIRE_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_YES, + WIDX_CANCEL +}; + +// 0x9AFB4C +static rct_widget window_staff_fire_widgets[] = { + { WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE }, + { WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_OPTIONS, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 0, WW-13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, + { WWT_DROPDOWN_BUTTON, 0, 10, 94, WH - 20, WH - 9, STR_YES, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 0, WW - 95, WW - 11, WH - 10, WH - 9, STR_SAVE_PROMPT_CANCEL, STR_NONE }, + { WIDGETS_END } +}; + +static void window_staff_fire_emptysub(){} +static void window_staff_fire_mouseup(); +static void window_staff_fire_paint(); + +//0x9A3F7C +static void* window_staff_fire_events[] = { + window_staff_fire_emptysub, + window_staff_fire_mouseup, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_emptysub, + window_staff_fire_paint, + window_staff_fire_emptysub +}; +/** Based off of rct2: 0x6C0A77 */ +void window_staff_fire_open(rct_peep* peep){ + // Check if the confirm window already exists. + if (window_bring_to_front_by_id(WC_FIRE_PROMPT, peep->sprite_index)) { + 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); + w->widgets = window_staff_fire_widgets; + w->enabled_widgets |= (1 << WIDX_CLOSE) | (1 << WIDX_YES) | (1 << WIDX_CANCEL); + + window_init_scroll_widgets(w); + + w->flags |= WF_TRANSPARENT; + w->number = peep->sprite_index; + w->colours[0] = 0x9A; +} + + +/** +* +* rct2: 0x006C0B40 +*/ +static void window_shortcut_change_mouseup(){ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex){ + case WIDX_YES: + //6c0b5b + break; + case WIDX_CANCEL: + case WIDX_CLOSE: + window_close(w); + } +} + +/** +* +* rct2: 0x006C0AF2 +*/ +static void window_shortcut_change_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + + //To be finished +} \ No newline at end of file diff --git a/src/windows/staff.c b/src/windows/staff.c index 48f06650cd..dff237d3d3 100644 --- a/src/windows/staff.c +++ b/src/windows/staff.c @@ -289,47 +289,19 @@ void window_staff_open(rct_peep* peep) void window_staff_disable_widgets(rct_window* w) { rct_peep* peep = &g_sprite_list[w->number].peep; + uint64 disabled_widgets = 0; - int eax = 0 | 0x80; - - if (peep->staff_type == 2) { - eax |= 0x20; + if (peep_can_be_picked_up(peep)){ + if (w->disabled_widgets & (1 << WIDX_PICKUP)) + window_invalidate(w); } - - //RCT2_CALLFUNC_X(0x698827, 0, 0, 0, 0, 0, 0, 0); - // sub_698827 - // This is here due to needing the Carry Flag. - - int CF = 0; - int res = RCT2_GLOBAL(0x982004 + peep->state, uint8) & 1; - - if (res == 0) { - CF = 1; - } - else { - eax = eax & eax; - } - - // end sub_698827 - - int a = 0; - - // pop esi - if (CF == 1 && w->page == 0) { - eax |= 0x400; //or eax, 400h - - a = w->disabled_widgets & (1 << 0xA); //bt dword ptr[esi + 10h], 0Ah - - } - - if (a == 0) { - CF = w->disabled_widgets & (1 << 0xA); //bt dword ptr [esi+10h], 0Ah - if (CF == 1) { + else{ + disabled_widgets = (1 << WIDX_PICKUP); + if (!(w->disabled_widgets & (1 << WIDX_PICKUP))) window_invalidate(w); - } } - w->disabled_widgets = eax; + w->disabled_widgets = disabled_widgets; } /** @@ -349,33 +321,6 @@ void window_staff_overview_close() } } -/** rct2: 0x6C0A77 */ -void window_staff_fire(rct_window* w) -{ - // Check if the confirm window already exists. - if (window_bring_to_front_by_id(0x1A, w->number)) { - 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 - 100; - int y = screen_height/2 - 50; - - rct_window* window_prompt = window_create(x, y, 200, 100, (uint32*)0x992C3C, 0x1A, 0); - window_prompt->widgets = (rct_widget*)0x9AFB4C; - window_prompt->enabled_widgets |= 0x4; - window_prompt->enabled_widgets |= 0x8; - window_prompt->enabled_widgets |= 0x10; - - window_init_scroll_widgets(window_prompt); - - window_prompt->flags |= 0x10; - window_prompt->number = w->number; - window_prompt->colours[0] = 0x9A; -} - /** * Mostly similar to window_peep_set_page. * rct2: 0x006BE023 @@ -461,7 +406,7 @@ void window_staff_overview_mouseup() RCT2_CALLPROC_X(0x0069A42F, 0, 0, 0, 0, (int)peep, 0, 0); break; case WIDX_FIRE: // 0xE - window_staff_fire(w); + window_staff_fire_open(peep); break; case WIDX_RENAME: // 0xC // 6BE4BC