Conflicts:
	src/window_peep.c
This commit is contained in:
hexdec 2014-08-17 16:30:01 +02:00
commit 7071f68670
4 changed files with 253 additions and 152 deletions

View File

@ -123,6 +123,7 @@
<ClCompile Include="..\src\window_ride_list.c" />
<ClCompile Include="..\src\window_save_prompt.c" />
<ClCompile Include="..\src\window_staff.c" />
<ClCompile Include="..\src\window_staff_peep.c" />
<ClCompile Include="..\src\window_title_exit.c" />
<ClCompile Include="..\src\window_title_logo.c" />
<ClCompile Include="..\src\window_main.c" />

View File

@ -368,6 +368,9 @@
<ClCompile Include="..\src\window_research.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_staff_peep.c">
<Filter>Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@ -112,38 +112,6 @@ void* window_peep_page_events[] = {
window_peep_overview_events
};
// 0x992AEC
static void* window_peep_staff_events[] = {
(void*)0x6BDFF8,
(void*)0x6BDF55,
(void*)0x6BE558,
(void*)0x6BDF98,
(void*)0x6BDFA3,
window_peep_emptysub,
(void*)0x6BE602,
window_peep_emptysub,
window_peep_emptysub,
(void*)0x6BDFD8,
(void*)0x6BDFC3,
window_peep_emptysub,
window_peep_emptysub,
(void*)0x6BDFAE,
window_peep_emptysub,
window_peep_emptysub,
window_peep_emptysub,
window_peep_emptysub,
window_peep_emptysub,
(void*)0x6BDFED,
(void*)0x6BE5FC,
window_peep_emptysub,
window_peep_emptysub,
window_peep_emptysub,
window_peep_emptysub,
(void*)0x6BDD91,
(void*)0x6BDEAF,
window_peep_emptysub
};
uint32 window_peep_page_enabled_widgets[] = {
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
@ -161,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;
@ -205,122 +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: 0x006BED21
*
*/
void sub_6BED21(rct_window* w, rct_peep* peep)
{
int eax = 0 | 0x80;
if (peep->staff_type == 2) {
eax |= 0x20;
}
//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) {
window_invalidate(w);
}
}
w->disabled_widgets = eax;
}
/**
* Create the window for a specific peep.
*
* rct2: 0x006BEF1B
*/
rct_window* sub_6BEF1B(rct_peep* peep)
{
int eax = peep->sprite_index;
int ecx = 0x38ae7; // class and flags
rct_window* w = window_create_auto_pos(190, 180, (uint32*)window_peep_staff_events, ecx, 0);
w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*);
w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32);
w->number = eax;
w->page = 0;
w->var_482 = 0;
w->frame_no = 0;
RCT2_GLOBAL((int*)w + 0x496, uint16) = 0; // missing, var_494 should perhaps be uint16?
sub_6BED21(w, peep);
w->min_width = 190;
w->min_height = 180;
w->max_width = 500;
w->max_height = 450;
w->flags = 8;
w->colours[0] = 1;
w->colours[1] = 4;
w->colours[2] = 4;
return w;
}
/**
*
* 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 = sub_6BEF1B(peep);
}
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;
sub_6BED21(w, peep);
//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);
}
}

247
src/window_staff_peep.c Normal file
View File

@ -0,0 +1,247 @@
/*****************************************************************************
* 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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#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
};
// 0x992AEC
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: 0x006BED21
*
*/
void sub_6BED21(rct_window* w, rct_peep* peep)
{
int eax = 0 | 0x80;
if (peep->staff_type == 2) {
eax |= 0x20;
}
//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) {
window_invalidate(w);
}
}
w->disabled_widgets = eax;
}
/**
* Create the window for a specific peep.
*
* rct2: 0x006BEF1B
*/
rct_window* sub_6BEF1B(rct_peep* peep)
{
int eax = peep->sprite_index;
int ecx = 0x38ae7; // class and flags
rct_window* w = window_create_auto_pos(190, 180, (uint32*)window_staff_peep_overview_events, ecx, 0);
w->widgets = RCT2_GLOBAL(0x9AF81C, rct_widget*);
w->enabled_widgets = RCT2_GLOBAL(0x9929B0, uint32);
w->number = eax;
w->page = 0;
w->var_482 = 0;
w->frame_no = 0;
RCT2_GLOBAL((int*)w + 0x496, uint16) = 0; // missing, var_494 should perhaps be uint16?
sub_6BED21(w, peep);
w->min_width = 190;
w->min_height = 180;
w->max_width = 500;
w->max_height = 450;
w->flags = 8;
w->colours[0] = 1;
w->colours[1] = 4;
w->colours[2] = 4;
return w;
}
/**
*
* 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 = sub_6BEF1B(peep);
}
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);
sub_6BED21(w, peep);
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);
}
}