add research window

As seen from RollerCoaster Tycoon 1. This allows the player to change the priorities in a "no money" park. I find it also more logical than the two research panels being separated in finances and new ride windows.
This commit is contained in:
IntelOrca 2014-08-15 22:05:35 +01:00
parent e76f0db614
commit 62a24e5383
8 changed files with 691 additions and 4 deletions

View File

@ -119,6 +119,7 @@
<ClCompile Include="..\src\window_new_ride.c" />
<ClCompile Include="..\src\window_options.c" />
<ClCompile Include="..\src\window_peep.c" />
<ClCompile Include="..\src\window_research.c" />
<ClCompile Include="..\src\window_ride_list.c" />
<ClCompile Include="..\src\window_save_prompt.c" />
<ClCompile Include="..\src\window_staff.c" />

View File

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

View File

@ -215,6 +215,7 @@
#define RCT2_ADDRESS_CURRENT_PARK_RATING 0x01357CB0
#define RCT2_ADDRESS_PARK_RATING_HISTORY 0x01357CB2
#define RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY 0x01357CD2
#define RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT 0x01357CF4
#define RCT2_ADDRESS_OBJECTIVE_TYPE 0x013580F8
#define RCT2_ADDRESS_OBJECTIVE_YEAR 0x013580F9
#define RCT2_ADDRESS_OBJECTIVE_CURRENCY 0x013580FC
@ -250,6 +251,8 @@
#define RCT2_ADDRESS_SECURITY_COLOUR 0x01357BCF
#define RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES 0x01357CF2
#define RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY 0x013580E7
#define RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH 0x013580E8
#define RCT2_ADDRESS_MAP_SIZE 0x01358834
#define RCT2_ADDRESS_PARK_SIZE 0x013580EA

View File

@ -71,7 +71,7 @@ void park_init()
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, uint16) = 0;
_guestGenerationProbability = 0;
RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, uint16) = 0;
RCT2_GLOBAL(0x01357CF4, sint32) = -1;
RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, sint32) = -1;
for (i = 0; i < 20; i++)
RCT2_ADDRESS(0x01358102, uint8)[i] = 0;

View File

@ -237,6 +237,7 @@ enum {
STR_SHOPS_AND_STALLS = 975,
STR_RESTROOMS_AND_INFORMATION_KIOSKS = 976,
STR_RESEARCH_AND_DEVELOPMENT = 983,
STR_RAISE_COST_AMOUNT = 984,
STR_LOWER_COST_AMOUNT = 985,
STR_COST_AMOUNT = 986,
@ -511,7 +512,29 @@ enum {
STR_RESEARCH_COST_PER_MONTH = 2265,
STR_RESEARCH_PRIORITIES = 2266,
STR_RESEARCH_TYPE_LABEL = 2269,
STR_RESEARCH_PROGRESS_LABEL = 2270,
STR_RESEARCH_EXPECTED_LABEL = 2271,
STR_RESEARCH_RIDE_LABEL = 2272,
STR_RESEARCH_SCENERY_LABEL = 2273,
STR_RESEARCH_SHOW_DETAILS_TIP = 2274,
STR_FINANCES_RESEARCH = 2275,
STR_RESEARCH_AND_DEVELOPMENT_TIP = 2276,
STR_RESEARCH_UNKNOWN = 2277,
STR_TRANSPORT_RIDE = 2278,
STR_GENTLE_RIDE = 2279,
STR_ROLLER_COASTER = 2280,
STR_THRILL_RIDE = 2281,
STR_WATER_RIDE = 2282,
STR_SHOP_STALL = 2283,
STR_SCENERY_THEMEING = 2284,
STR_INITIAL_RESEARCH = 2285,
STR_DESIGNING = 2286,
STR_COMPLETING_DESIGN = 2287,
STR_UNKNOWN = 2288,
STR_SELECT_SCENARIO = 2291,

View File

@ -287,6 +287,7 @@ enum {
WC_CLEAR_SCENERY = 50,
WC_MANAGE_TRACK_DESIGN = 89,
WC_CHEATS = 110,
WC_RESEARCH = 111
} WINDOW_CLASS;
enum PROMPT_MODE {
@ -376,6 +377,7 @@ void window_new_campaign_open(int campaignType);
void window_ride_list_open();
void window_banner_open();
void window_cheats_open();
void window_research_open();
void window_guest_list_init_vars_a();
void window_guest_list_init_vars_b();

View File

@ -48,7 +48,8 @@ enum {
WIDX_GUESTS,
WIDX_CLEAR_SCENERY,
WIDX_FASTFORWARD
WIDX_FASTFORWARD,
WIDX_RESEARCH
};
typedef enum {
@ -93,8 +94,8 @@ static rct_widget window_game_top_toolbar_widgets[] = {
{ WWT_TRNBTN, 3, 0x0230, 0x024D, 0, 27, 0x20000000 | SPR_TOOLBAR_GUESTS, STR_GUESTS_TIP }, // Guests
{ WWT_TRNBTN, 2, 0x0230, 0x024D, 0, 27, 0x20000000 | SPR_TOOLBAR_CLEAR_SCENERY, STR_CLEAR_SCENERY_TIP }, // Clear scenery
{ WWT_TRNBTN, 0, 0x001E, 0x003B, 0, 27, 0x20000000 | 0x15F9, STR_NONE }, // Fast forward
{ WWT_TRNBTN, 0, 0x001E, 0x003B, 0, 27, 0x20000000 | 0x15F9, STR_NONE }, // Fast forward
{ WWT_TRNBTN, 3, 0x001E, 0x003B, 0, 27, 0x20000000 | 0x15F9, 2275 }, // Research
{ WIDGETS_END },
};
@ -275,6 +276,9 @@ static void window_game_top_toolbar_mouseup()
case WIDX_GUESTS:
window_guest_list_open();
break;
case WIDX_RESEARCH:
window_research_open();
break;
}
}
@ -488,6 +492,10 @@ static void window_game_top_toolbar_invalidate()
window_game_top_toolbar_widgets[WIDX_RIDES].right = x;
x -= 29;
window_game_top_toolbar_widgets[WIDX_RIDES].left = x;
x -= 1;
window_game_top_toolbar_widgets[WIDX_RESEARCH].right = x;
x -= 29;
window_game_top_toolbar_widgets[WIDX_RESEARCH].left = x;
x -= 11;
window_game_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].right = x;
x -= 29;
@ -559,4 +567,10 @@ static void window_game_top_toolbar_paint()
imgId++;
imgId |= (RCT2_GLOBAL(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8) << 19) | 0xA0000000 | (RCT2_GLOBAL(RCT2_ADDRESS_MECHANIC_COLOUR, uint8) << 24);
gfx_draw_sprite(dpi, imgId, x, y, 0);
// Draw research button
x = w->x + window_game_top_toolbar_widgets[WIDX_RESEARCH].left - 1;
y = w->y + window_game_top_toolbar_widgets[WIDX_RESEARCH].top - 1;
imgId = SPR_TAB_FINANCES_RESEARCH_0;
gfx_draw_sprite(dpi, imgId, x, y, 0);
}

641
src/window_research.c Normal file
View File

@ -0,0 +1,641 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* 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 "finance.h"
#include "game.h"
#include "news_item.h"
#include "string_ids.h"
#include "sprites.h"
#include "widget.h"
#include "window.h"
#include "window_dropdown.h"
enum {
WINDOW_RESEARCH_PAGE_DEVELOPMENT,
WINDOW_RESEARCH_PAGE_FUNDING,
WINDOW_RESEARCH_PAGE_COUNT
};
enum {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_PAGE_BACKGROUND,
WIDX_TAB_1,
WIDX_TAB_2,
WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP,
WIDX_LAST_DEVELOPMENT_GROUP,
WIDX_LAST_DEVELOPMENT_BUTTON,
WIDX_FUNDING_GROUP = 6,
WIDX_RESEARCH_FUNDING,
WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON,
WIDX_PRIORITIES_GROUP,
WIDX_TRANSPORT_RIDES,
WIDX_GENTLE_RIDES,
WIDX_ROLLER_COASTERS,
WIDX_THRILL_RIDES,
WIDX_WATER_RIDES,
WIDX_SHOPS_AND_STALLS,
WIDX_SCENERY_AND_THEMING,
};
#pragma region Widgets
static rct_widget window_research_development_widgets[] = {
{ WWT_FRAME, 0, 0, 299, 0, 195, 0xFFFFFFFF, STR_NONE },
{ WWT_CAPTION, 0, 1, 298, 1, 14, STR_RESEARCH_AND_DEVELOPMENT, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, 287, 297, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
{ WWT_RESIZE, 1, 0, 299, 43, 195, 0xFFFFFFFF, STR_NONE },
{ WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, STR_RESEARCH_AND_DEVELOPMENT_TIP },
{ WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, STR_FINANCES_RESEARCH },
{ WWT_GROUPBOX, 2, 3, 292, 47, 116, 2267, STR_NONE },
{ WWT_GROUPBOX, 2, 3, 292, 124, 188, 2268, STR_NONE },
{ WWT_FLATBTN, 2, 265, 288, 161, 184, 0xFFFFFFFF, STR_RESEARCH_SHOW_DETAILS_TIP },
{ WIDGETS_END },
};
static rct_widget window_research_funding_widgets[] = {
{ WWT_FRAME, 0, 0, 319, 0, 206, 0xFFFFFFFF, STR_NONE },
{ WWT_CAPTION, 0, 1, 318, 1, 14, STR_RESEARCH_FUNDING, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, 307, 317, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
{ WWT_RESIZE, 1, 0, 319, 43, 206, 0xFFFFFFFF, STR_NONE },
{ WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, STR_RESEARCH_AND_DEVELOPMENT_TIP },
{ WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, STR_FINANCES_RESEARCH },
{ WWT_GROUPBOX, 2, 3, 316, 47, 91, STR_RESEARCH_FUNDING_, STR_NONE },
{ WWT_DROPDOWN, 2, 8, 167, 59, 70, 0xFFFFFFFF, STR_SELECT_LEVEL_OF_RESEARCH_AND_DEVELOPMENT },
{ WWT_DROPDOWN_BUTTON, 2, 156, 166, 60, 69, 876, STR_SELECT_LEVEL_OF_RESEARCH_AND_DEVELOPMENT },
{ WWT_GROUPBOX, 2, 3, 316, 96, 202, STR_RESEARCH_PRIORITIES, STR_NONE },
{ WWT_CHECKBOX, 2, 8, 311, 108, 119, STR_RESEARCH_TRANSPORT_RIDES, STR_RESEARCH_NEW_TRANSPORT_RIDES },
{ WWT_CHECKBOX, 2, 8, 311, 121, 132, STR_RESEARCH_GENTLE_RIDES, STR_RESEARCH_NEW_GENTLE_RIDES },
{ WWT_CHECKBOX, 2, 8, 311, 134, 145, STR_RESEARCH_ROLLER_COASTERS, STR_RESEARCH_NEW_ROLLER_COASTERS },
{ WWT_CHECKBOX, 2, 8, 311, 147, 158, STR_RESEARCH_THRILL_RIDES, STR_RESEARCH_NEW_THRILL_RIDES },
{ WWT_CHECKBOX, 2, 8, 311, 160, 171, STR_RESEARCH_WATER_RIDES, STR_RESEARCH_NEW_WATER_RIDES },
{ WWT_CHECKBOX, 2, 8, 311, 173, 184, STR_RESEARCH_SHOPS_AND_STALLS, STR_RESEARCH_NEW_SHOPS_AND_STALLS },
{ WWT_CHECKBOX, 2, 8, 311, 186, 197, STR_RESEARCH_SCENERY_AND_THEMING, STR_RESEARCH_NEW_SCENERY_AND_THEMING },
{ WIDGETS_END },
};
static rct_widget *window_research_page_widgets[] = {
window_research_development_widgets,
window_research_funding_widgets
};
#pragma endregion
#pragma region Events
static void window_research_emptysub() { }
static void window_research_development_mouseup();
static void window_research_development_update(rct_window *w);
static void window_research_development_invalidate();
static void window_research_development_paint();
static void window_research_funding_mouseup();
static void window_research_funding_mousedown(int widgetIndex, rct_window*w, rct_widget* widget);
static void window_research_funding_dropdown();
static void window_research_funding_update(rct_window *w);
static void window_research_funding_invalidate();
static void window_research_funding_paint();
//
static void* window_research_development_events[] = {
window_research_emptysub,
window_research_development_mouseup,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_development_update,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_development_invalidate,
window_research_development_paint,
window_research_emptysub
};
// 0x009890E8
static void* window_research_funding_events[] = {
window_research_emptysub,
window_research_funding_mouseup,
window_research_emptysub,
window_research_funding_mousedown,
window_research_funding_dropdown,
window_research_emptysub,
window_research_funding_update,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_emptysub,
window_research_funding_invalidate,
window_research_funding_paint,
window_research_emptysub
};
static void* window_research_page_events[] = {
window_research_development_events,
window_research_funding_events
};
#pragma endregion
#pragma region Enabled widgets
static uint32 window_research_page_enabled_widgets[] = {
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2),
(1 << WIDX_CLOSE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_TAB_2) |
(1 << WIDX_RESEARCH_FUNDING) |
(1 << WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON) |
(1 << WIDX_TRANSPORT_RIDES) |
(1 << WIDX_GENTLE_RIDES) |
(1 << WIDX_ROLLER_COASTERS) |
(1 << WIDX_THRILL_RIDES) |
(1 << WIDX_WATER_RIDES) |
(1 << WIDX_SHOPS_AND_STALLS) |
(1 << WIDX_SCENERY_AND_THEMING)
};
#pragma endregion
const int window_research_tab_animation_loops[] = { 16, 16 };
static void window_research_set_page(rct_window *w, int page);
static void window_research_set_pressed_tab(rct_window *w);
static void window_research_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w);
void window_research_open()
{
rct_window *w;
w = window_bring_to_front_by_id(WC_RESEARCH, 0);
if (w == NULL) {
w = window_create_auto_pos(530, 257, window_research_page_events[0], WC_RESEARCH, WF_10);
w->widgets = window_research_page_widgets[0];
w->enabled_widgets = window_research_page_enabled_widgets[0];
w->number = 0;
w->page = 0;
w->frame_no = 0;
w->disabled_widgets = 0;
w->colours[0] = 1;
w->colours[1] = 19;
w->colours[2] = 19;
RCT2_CALLPROC_EBPSAFE(0x00684BAE);
}
w->page = 0;
window_invalidate(w);
w->width = 300;
w->height = 196;
window_invalidate(w);
w->widgets = window_research_page_widgets[0];
w->enabled_widgets = window_research_page_enabled_widgets[0];
w->var_020 = RCT2_GLOBAL(0x00988E3C, uint32);
w->event_handlers = window_research_page_events[0];
w->pressed_widgets = 0;
w->disabled_widgets = 0;
window_init_scroll_widgets(w);
}
#pragma region Development page
/**
*
* rct2: 0x006B6B38
*/
static void window_research_development_mouseup()
{
short widgetIndex;
rct_window *w;
window_mouse_up_get_registers(w, widgetIndex);
switch (widgetIndex) {
case WIDX_CLOSE:
window_close(w);
break;
case WIDX_TAB_1:
case WIDX_TAB_2:
window_research_set_page(w, widgetIndex - WIDX_TAB_1);
break;
case WIDX_LAST_DEVELOPMENT_BUTTON:
news_item_open_subject(NEWS_ITEM_RESEARCH, RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, sint32));
break;
}
}
/**
*
* rct2: 0x0069CBA6
*/
static void window_research_development_update(rct_window *w)
{
// Tab animation
if (++w->frame_no >= window_research_tab_animation_loops[w->page])
w->frame_no = 0;
widget_invalidate(w->classification, w->number, WIDX_TAB_1);
}
/**
*
* rct2: 0x006B6819
*/
static void window_research_development_invalidate()
{
rct_window *w;
window_get_register(w);
if (w->widgets != window_research_page_widgets[WINDOW_RESEARCH_PAGE_DEVELOPMENT]) {
w->widgets = window_research_page_widgets[WINDOW_RESEARCH_PAGE_DEVELOPMENT];
window_init_scroll_widgets(w);
}
window_research_set_pressed_tab(w);
window_research_development_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_EMPTY;
uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32);
if (typeId != 0xFFFFFFFF) {
window_research_development_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
window_research_development_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].image = typeId >= 0x10000 ? 5189 : 5191;
}
}
/**
*
* rct2: 0x006B689B
*/
static void window_research_development_paint()
{
rct_window *w;
rct_drawpixelinfo *dpi;
int x, y;
rct_string_id stringId;
window_paint_get_registers(w, dpi);
window_draw_widgets(w, dpi);
window_research_draw_tab_images(dpi, w);
x = w->x + 10;
y = w->y + window_research_development_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].top + 12;
// Research type
stringId = STR_RESEARCH_UNKNOWN;
if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) {
stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(0x013580E6, uint8);
if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) {
uint32 typeId = RCT2_GLOBAL(0x013580E0, uint32);
if (typeId >= 0x10000) {
uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFFFF) * 4, uint8*);
if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000)
stringId = RCT2_GLOBAL(rideEntry, uint16);
else
stringId = (typeId & 0xFF00) + 2;
} else {
uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*);
stringId = RCT2_GLOBAL(sceneryEntry, uint16);
}
}
}
gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0);
y += 25;
// Progress
stringId = 2285 + RCT2_GLOBAL(0x01357CF3, uint8);
gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0);
y += 15;
// Expected
RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN;
if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) {
uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8);
if (expectedDay != 255) {
RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay;
RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8);
RCT2_GLOBAL(0x013CE952, uint16) = 2289;
}
}
gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y);
// Last development
x = w->x + 10;
y = w->y + window_research_development_widgets[WIDX_LAST_DEVELOPMENT_GROUP].top + 12;
uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32);
if (typeId != 0xFFFFFFFF) {
if (typeId >= 0x10000) {
uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFFFF) * 4, uint8*);
if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000)
stringId = RCT2_GLOBAL(rideEntry, uint16);
else
stringId = (typeId & 0xFF00) + 2;
} else {
uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*);
stringId = RCT2_GLOBAL(sceneryEntry, uint16);
}
gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 266, STR_RESEARCH_RIDE_LABEL, 0);
}
}
#pragma endregion
#pragma region Funding page
/**
*
* rct2: 0x0069DB3F
*/
static void window_research_funding_mouseup()
{
rct_window * w;
short widgetIndex;
int activeResearchTypes;
window_mouse_up_get_registers(w, widgetIndex);
switch (widgetIndex) {
case WIDX_CLOSE:
window_close(w);
break;
case WIDX_TAB_1:
case WIDX_TAB_2:
window_research_set_page(w, widgetIndex - WIDX_TAB_1);
break;
case WIDX_TRANSPORT_RIDES:
case WIDX_GENTLE_RIDES:
case WIDX_ROLLER_COASTERS:
case WIDX_THRILL_RIDES:
case WIDX_WATER_RIDES:
case WIDX_SHOPS_AND_STALLS:
case WIDX_SCENERY_AND_THEMING:
activeResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint16);
activeResearchTypes ^= 1 << (widgetIndex - WIDX_TRANSPORT_RIDES);
game_do_command(0, (1 << 8) | 1, 0, activeResearchTypes, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0);
break;
}
}
/**
*
* rct2: 0x0069DB66
*/
static void window_research_funding_mousedown(int widgetIndex, rct_window *w, rct_widget* widget)
{
rct_widget *dropdownWidget;
int i;
if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON)
return;
dropdownWidget = widget - 1;
for (i = 0; i < 4; i++) {
gDropdownItemsFormat[i] = 1142;
gDropdownItemsArgs[i] = STR_NO_FUNDING + i;
}
window_dropdown_show_text_custom_width(
w->x + dropdownWidget->left,
w->y + dropdownWidget->top,
dropdownWidget->bottom - dropdownWidget->top + 1,
w->colours[1],
0x80,
4,
dropdownWidget->right - dropdownWidget->left - 3
);
int currentResearchLevel = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
gDropdownItemsChecked = (1 << currentResearchLevel);
}
/**
*
* rct2: 0x0069DB6D
*/
static void window_research_funding_dropdown()
{
rct_window *w;
short widgetIndex;
short dropdownIndex;
window_dropdown_get_registers(w, widgetIndex, dropdownIndex);
if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON || dropdownIndex == -1)
return;
game_do_command(0, 1, 0, dropdownIndex, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0);
window_invalidate(w);
}
/**
*
* rct2: 0x0069DC23
*/
static void window_research_funding_update(rct_window *w)
{
// Tab animation
if (++w->frame_no >= window_research_tab_animation_loops[w->page])
w->frame_no = 0;
widget_invalidate(w->classification, w->number, WIDX_TAB_2);
}
/**
*
* rct2: 0x0069DA64
*/
static void window_research_funding_invalidate()
{
rct_window *w;
window_get_register(w);
if (w->widgets != window_research_page_widgets[WINDOW_RESEARCH_PAGE_FUNDING]) {
w->widgets = window_research_page_widgets[WINDOW_RESEARCH_PAGE_FUNDING];
window_init_scroll_widgets(w);
}
window_research_set_pressed_tab(w);
if ((RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
window_research_funding_widgets[WIDX_FUNDING_GROUP].type = WWT_EMPTY;
window_research_funding_widgets[WIDX_RESEARCH_FUNDING].type = WWT_EMPTY;
window_research_funding_widgets[WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON].type = WWT_EMPTY;
} else {
window_research_funding_widgets[WIDX_FUNDING_GROUP].type = WWT_GROUPBOX;
window_research_funding_widgets[WIDX_RESEARCH_FUNDING].type = WWT_DROPDOWN;
window_research_funding_widgets[WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON].type = WWT_DROPDOWN_BUTTON;
// Current funding
int currentResearchLevel = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
window_research_funding_widgets[WIDX_RESEARCH_FUNDING].image = STR_NO_FUNDING + currentResearchLevel;
}
// Checkboxes
int activeResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint16);
int uncompletedResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_UNCOMPLETED_RESEARCH_TYPES, uint16);
for (int i = 0; i < 7; i++) {
int mask = 1 << i;
int widgetMask = 1 << (i + WIDX_TRANSPORT_RIDES);
// Set checkbox disabled if research type is complete
if (uncompletedResearchTypes & mask) {
w->disabled_widgets &= ~widgetMask;
// Set checkbox ticked if research type is active
if (activeResearchTypes & mask)
w->pressed_widgets |= widgetMask;
else
w->pressed_widgets &= ~widgetMask;
} else {
w->disabled_widgets |= widgetMask;
w->pressed_widgets &= ~widgetMask;
}
}
}
/**
*
* rct2: 0x0069DAF0
*/
static void window_research_funding_paint()
{
rct_window *w;
rct_drawpixelinfo *dpi;
window_paint_get_registers(w, dpi);
window_draw_widgets(w, dpi);
window_research_draw_tab_images(dpi, w);
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
int currentResearchLevel = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
money32 currentResearchCostPerWeek = research_cost_table[currentResearchLevel];
gfx_draw_string_left(dpi, STR_RESEARCH_COST_PER_MONTH, &currentResearchCostPerWeek, 0, w->x + 10, w->y + 77);
}
}
#pragma endregion
#pragma region Common
/**
*
* rct2: 0x0069CAC5
*/
static void window_research_set_page(rct_window *w, int page)
{
w->page = page;
w->frame_no = 0;
if (w->viewport != NULL) {
w->viewport->width = 0;
w->viewport = NULL;
}
w->enabled_widgets = window_research_page_enabled_widgets[page];
w->var_020 = RCT2_ADDRESS(0x00988E3C, uint32)[page];
w->event_handlers = window_research_page_events[page];
w->widgets = window_research_page_widgets[page];
w->disabled_widgets = 0;
w->pressed_widgets = 0;
window_invalidate(w);
if (w->page == WINDOW_RESEARCH_PAGE_DEVELOPMENT) {
w->width = 300;
w->height = 196;
} else {
w->width = 320;
w->height = 207;
}
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0);
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_init_scroll_widgets(w);
window_invalidate(w);
}
static void window_research_set_pressed_tab(rct_window *w)
{
int i;
for (i = 0; i < WINDOW_RESEARCH_PAGE_COUNT; i++)
w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i));
w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page);
}
static void window_research_draw_tab_image(rct_drawpixelinfo *dpi, rct_window *w, int page, int spriteIndex)
{
int widgetIndex = WIDX_TAB_1 + page;
if (!(w->disabled_widgets & (1LL << widgetIndex))) {
if (w->page == page) {
int frame = w->frame_no / 2;
if (page == WINDOW_RESEARCH_PAGE_DEVELOPMENT)
frame %= 8;
spriteIndex += frame;
}
gfx_draw_sprite(dpi, spriteIndex, w->x + w->widgets[widgetIndex].left, w->y + w->widgets[widgetIndex].top, 0);
}
}
static void window_research_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w)
{
window_research_draw_tab_image(dpi, w, WINDOW_RESEARCH_PAGE_DEVELOPMENT, SPR_TAB_FINANCES_RESEARCH_0);
window_research_draw_tab_image(dpi, w, WINDOW_RESEARCH_PAGE_FUNDING, SPR_TAB_FINANCES_SUMMARY_0);
}
#pragma endregion