Merge pull request #545 from duncanspumpkin/demolish_ride_prompt

Added demolish ride prompt
This commit is contained in:
Ted John 2014-11-02 13:15:36 +00:00
commit eb35bd508c
6 changed files with 168 additions and 34 deletions

View File

@ -101,6 +101,7 @@
<ClCompile Include="..\src\windows\banner.c" />
<ClCompile Include="..\src\windows\cheats.c" />
<ClCompile Include="..\src\windows\clear_scenery.c" />
<ClCompile Include="..\src\windows\demolish_ride_prompt.c" />
<ClCompile Include="..\src\windows\dropdown.c" />
<ClCompile Include="..\src\windows\error.c" />
<ClCompile Include="..\src\windows\finances.c" />
@ -291,4 +292,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -382,7 +382,6 @@
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\drawing\rain.c">
<Filter>Source\Drawing</Filter>
</ClCompile>
@ -393,9 +392,6 @@
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\libspeex\resample.c">
<Filter>Libraries\lodepng</Filter>
</ClCompile>
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
@ -431,6 +427,10 @@
<ClCompile Include="..\src\windows\map_tooltip.c">
<Filter>Source\Windows</Filter>
</ClCompile>
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\windows\demolish_ride_prompt.c">
<Filter>Source\Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\management\award.h">
@ -629,4 +629,4 @@
<Filter>Source\World</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>

View File

@ -499,6 +499,7 @@ void window_finances_open();
void window_finances_research_open();
void window_new_campaign_open(sint16 campaignType);
rct_window *window_ride_main_open(int rideIndex);
void window_ride_demolish_prompt_open(int rideIndex);
void window_ride_construct(rct_window *w);
void window_ride_list_open();
void window_track_place_open();

View File

@ -144,6 +144,9 @@ enum {
STR_CONSTRUCTION = 990,
STR_DEMOLISH_RIDE_TIP = 992,
STR_DEMOLISH_RIDE = 993,
STR_DEMOLISH = 994,
STR_DEMOLISH_RIDE_ID = 995,
STR_OVERALL_VIEW = 996,
STR_VIEW_SELECTION = 997,
@ -679,6 +682,8 @@ enum {
STR_MONTH_NOVEMBER = STR_MONTH_JANUARY + 10,
STR_MONTH_DECEMBER = STR_MONTH_JANUARY + 11,
STR_CANT_DEMOLISH_RIDE = 2248,
STR_RESEARCH_TRANSPORT_RIDES = 2253,
STR_RESEARCH_GENTLE_RIDES = 2254,
STR_RESEARCH_ROLLER_COASTERS = 2255,

View File

@ -0,0 +1,154 @@
/*****************************************************************************
* 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 "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../sprites.h"
#include "../world/sprite.h"
#define WW 200
#define WH 100
enum WINDOW_RIDE_DEMOLISH_WIDGET_IDX {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_DEMOLISH,
WIDX_CANCEL
};
// 0x009AEBA0
static rct_widget window_ride_demolish_widgets[] = {
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE },
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_DEMOLISH_RIDE, 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_DEMOLISH, STR_NONE },
{ WWT_DROPDOWN_BUTTON, 0, WW - 95, WW - 11, WH - 20, WH - 9, STR_SAVE_PROMPT_CANCEL, STR_NONE },
{ WIDGETS_END }
};
static void window_ride_demolish_emptysub(){}
static void window_ride_demolish_mouseup();
static void window_ride_demolish_paint();
//0x0098E2E4
static void* window_ride_demolish_events[] = {
window_ride_demolish_emptysub,
window_ride_demolish_mouseup,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_emptysub,
window_ride_demolish_paint,
window_ride_demolish_emptysub
};
/** Based off of rct2: 0x006B486A */
void window_ride_demolish_prompt_open(int rideIndex){
rct_window *w;
w = window_bring_to_front_by_number(WC_DEMOLISH_RIDE_PROMPT, rideIndex);
if (w != NULL)
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;
w = window_create(x, y, WW, WH, (uint32*)window_ride_demolish_events, WC_DEMOLISH_RIDE_PROMPT, 0);
w->widgets = window_ride_demolish_widgets;
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_CANCEL) | (1 << WIDX_DEMOLISH);
window_init_scroll_widgets(w);
w->flags |= WF_TRANSPARENT;
w->number = rideIndex;
w->colours[0] = 154;
}
/**
*
* rct2: 0x006B4933
*/
static void window_ride_demolish_mouseup(){
short widgetIndex;
rct_window *w;
window_widget_get_registers(w, widgetIndex);
switch (widgetIndex){
case WIDX_DEMOLISH:
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, rct_string_id) = STR_CANT_DEMOLISH_RIDE;
game_do_command(0, 1, 0, w->number, GAME_COMMAND_7, 0, 0);
break;
case WIDX_CANCEL:
case WIDX_CLOSE:
window_close(w);
}
}
/**
*
* rct2: 0x006B48E5
*/
static void window_ride_demolish_paint(){
rct_window *w;
rct_drawpixelinfo *dpi;
window_paint_get_registers(w, dpi);
window_draw_widgets(w, dpi);
rct_ride* ride = GET_RIDE(w->number);
RCT2_GLOBAL(0x13CE952, uint16) = ride->name;
RCT2_GLOBAL(0x13CE954, uint32) = ride->name_arguments;
int x = w->x + WW / 2;
int y = w->y + (WH / 2) - 3;
gfx_draw_string_centred_wrapped(dpi, (void*)0x13CE952, x, y, WW - 4, STR_DEMOLISH_RIDE_ID, 0);
}

View File

@ -1437,33 +1437,6 @@ static void window_ride_locate(rct_window *w)
window_scroll_to_location(mainWindow, x, y, z);
}
/**
*
* rct2: 0x006B486A
*/
static void window_ride_demolish(rct_window *w)
{
rct_window *demolishWindow;
int x, y, screenWidth, screenHeight;
demolishWindow = window_bring_to_front_by_number(WC_DEMOLISH_RIDE_PROMPT, w->number);
if (demolishWindow != NULL)
return;
screenWidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16);
screenHeight = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16);
x = screenWidth / 2 - 100;
y = max(28, screenHeight / 2 - 50);
demolishWindow = window_create(x, y, 200, 100, (uint32*)0x0098E2E4, WC_DEMOLISH_RIDE_PROMPT, 0);
demolishWindow->widgets = (rct_widget*)0x009AEBA0;
demolishWindow->enabled_widgets = 4 | 8 | 16;
window_init_scroll_widgets(demolishWindow);
demolishWindow->flags |= WF_TRANSPARENT;
demolishWindow->number = w->number;
demolishWindow->colours[0] = 154;
}
/**
*
* rct2: 0x006AF17E
@ -1501,7 +1474,7 @@ static void window_ride_main_mouseup()
window_ride_locate(w);
break;
case WIDX_DEMOLISH:
window_ride_demolish(w);
window_ride_demolish_prompt_open(w->number);
break;
}
}