2014-05-02 23:21:08 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* 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 "game.h"
|
|
|
|
#include "rct2.h"
|
2014-05-19 21:04:28 +02:00
|
|
|
#include "string_ids.h"
|
2014-05-02 23:21:08 +02:00
|
|
|
#include "sprites.h"
|
|
|
|
#include "tutorial.h"
|
|
|
|
#include "widget.h"
|
|
|
|
#include "window.h"
|
2014-05-06 23:04:09 +02:00
|
|
|
#include "audio.h"
|
2014-05-24 21:01:10 +02:00
|
|
|
#include "config.h"
|
2014-05-02 23:21:08 +02:00
|
|
|
|
2014-05-19 21:10:32 +02:00
|
|
|
enum WINDOW_SAVE_PROMPT_WIDGET_IDX {
|
2014-05-02 23:21:08 +02:00
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLE,
|
|
|
|
WIDX_CLOSE,
|
2014-05-23 11:30:19 +02:00
|
|
|
WIDX_LABEL,
|
2014-05-02 23:21:08 +02:00
|
|
|
WIDX_SAVE,
|
|
|
|
WIDX_DONT_SAVE,
|
|
|
|
WIDX_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_save_prompt_widgets[] = {
|
2014-05-24 01:00:58 +02:00
|
|
|
{ WWT_FRAME, 0, 0, 259, 0, 49, STR_NONE, STR_NONE }, // panel / background
|
2014-05-02 23:21:08 +02:00
|
|
|
{ WWT_CAPTION, 0, 1, 258, 1, 14, 0, STR_WINDOW_TITLE_TIP }, // title bar
|
2014-05-24 01:00:58 +02:00
|
|
|
{ WWT_CLOSEBOX, 0, 247, 257, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
|
2014-05-23 11:30:19 +02:00
|
|
|
{ WWT_12, 0, 2, 257, 19, 30, 0, STR_NONE }, // question/label
|
2014-05-23 23:05:13 +02:00
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 8, 85, 35, 46, STR_SAVE_PROMPT_SAVE, STR_NONE }, // save
|
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 91, 168, 35, 46, STR_SAVE_PROMPT_DONT_SAVE, STR_NONE }, // don't save
|
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 174, 251, 35, 46, STR_SAVE_PROMPT_CANCEL, STR_NONE }, // cancel
|
2014-05-02 23:21:08 +02:00
|
|
|
{ WIDGETS_END },
|
|
|
|
};
|
|
|
|
|
2014-05-24 01:00:58 +02:00
|
|
|
enum WINDOW_QUIT_PROMPT_WIDGET_IDX {
|
|
|
|
WQIDX_BACKGROUND,
|
|
|
|
WQIDX_TITLE,
|
|
|
|
WQIDX_CLOSE,
|
|
|
|
WQIDX_OK,
|
|
|
|
WQIDX_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_quit_prompt_widgets[] = {
|
|
|
|
{ WWT_FRAME, 0, 0, 176, 0, 33, STR_NONE, STR_NONE }, // panel / background
|
|
|
|
{ WWT_CAPTION, 0, 1, 175, 1, 14, STR_QUIT_GAME, STR_WINDOW_TITLE_TIP }, // title bar
|
|
|
|
{ WWT_CLOSEBOX, 0, 164, 174, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
|
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 8, 85, 19, 30, STR_OK, STR_NONE }, // ok
|
|
|
|
{ WWT_DROPDOWN_BUTTON, 0, 91, 168, 19, 30, STR_CANCEL, STR_NONE }, // cancel
|
|
|
|
{ WIDGETS_END },
|
|
|
|
};
|
|
|
|
|
2014-05-02 23:21:08 +02:00
|
|
|
static void window_save_prompt_emptysub() { }
|
|
|
|
static void window_save_prompt_close();
|
|
|
|
static void window_save_prompt_mouseup();
|
|
|
|
static void window_save_prompt_paint();
|
|
|
|
|
2014-05-12 03:18:08 +02:00
|
|
|
static void* window_save_prompt_events[] = {
|
2014-05-02 23:21:08 +02:00
|
|
|
window_save_prompt_close,
|
|
|
|
window_save_prompt_mouseup,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_emptysub,
|
|
|
|
window_save_prompt_paint,
|
|
|
|
window_save_prompt_emptysub
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066DCBE
|
|
|
|
*/
|
|
|
|
void window_save_prompt_open()
|
|
|
|
{
|
2014-05-24 01:00:58 +02:00
|
|
|
int stringId, x, y;
|
2014-05-02 23:21:08 +02:00
|
|
|
rct_window* window;
|
2014-05-24 01:00:58 +02:00
|
|
|
unsigned short prompt_mode;
|
|
|
|
rct_widget *widgets;
|
|
|
|
uint64 enabled_widgets;
|
|
|
|
|
|
|
|
prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16);
|
2014-05-02 23:21:08 +02:00
|
|
|
|
|
|
|
// Check if window is already open
|
|
|
|
window = window_bring_to_front_by_id(WC_SAVE_PROMPT, 0);
|
|
|
|
if (window == NULL) {
|
2014-05-24 01:00:58 +02:00
|
|
|
if (prompt_mode == PM_QUIT) {
|
|
|
|
widgets = window_quit_prompt_widgets;
|
|
|
|
enabled_widgets =
|
|
|
|
(1 << WQIDX_CLOSE) |
|
|
|
|
(1 << WQIDX_OK) |
|
|
|
|
(1 << WQIDX_CANCEL);
|
|
|
|
x = 177;
|
|
|
|
y = 34;
|
|
|
|
} else {
|
|
|
|
widgets = window_save_prompt_widgets;
|
|
|
|
enabled_widgets =
|
|
|
|
(1 << WIDX_CLOSE) |
|
|
|
|
(1 << WIDX_SAVE) |
|
|
|
|
(1 << WIDX_DONT_SAVE) |
|
|
|
|
(1 << WIDX_CANCEL);
|
|
|
|
x = 260;
|
|
|
|
y = 50;
|
|
|
|
}
|
|
|
|
|
2014-05-02 23:21:08 +02:00
|
|
|
window = window_create(
|
2014-05-24 01:00:58 +02:00
|
|
|
(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - x/2,
|
|
|
|
max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - y/2),
|
|
|
|
x,
|
|
|
|
y,
|
2014-05-12 03:18:08 +02:00
|
|
|
(uint32*)window_save_prompt_events,
|
2014-05-02 23:21:08 +02:00
|
|
|
WC_SAVE_PROMPT,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
|
2014-05-24 01:00:58 +02:00
|
|
|
window->widgets = widgets;
|
|
|
|
window->enabled_widgets = enabled_widgets;
|
2014-05-02 23:21:08 +02:00
|
|
|
window_init_scroll_widgets(window);
|
|
|
|
window->colours[0] = 154;
|
|
|
|
window->flags |= WF_TRANSPARENT;
|
|
|
|
|
|
|
|
// Pause the game
|
|
|
|
RCT2_GLOBAL(0x009DEA6E, uint8) |= 2;
|
2014-05-06 23:04:09 +02:00
|
|
|
pause_sounds();
|
2014-05-02 23:21:08 +02:00
|
|
|
window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0);
|
|
|
|
}
|
|
|
|
|
2014-05-24 01:00:58 +02:00
|
|
|
stringId = prompt_mode + STR_LOAD_GAME;
|
2014-05-02 23:21:08 +02:00
|
|
|
if (stringId == STR_LOAD_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
|
|
|
|
stringId = STR_LOAD_LANDSCAPE;
|
|
|
|
if (stringId == STR_QUIT_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
|
|
|
|
stringId = STR_QUIT_SCENARIO_EDITOR;
|
|
|
|
window_save_prompt_widgets[WIDX_TITLE].image = stringId;
|
2014-05-24 01:00:58 +02:00
|
|
|
window_save_prompt_widgets[WIDX_LABEL].image = prompt_mode + STR_SAVE_BEFORE_LOADING;
|
2014-05-02 23:21:08 +02:00
|
|
|
|
2014-05-24 21:01:10 +02:00
|
|
|
if (!gGeneral_config.confirmation_prompt) {
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) {
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) {
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) {
|
|
|
|
RCT2_CALLPROC_EBPSAFE(0x0066EE54);
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
tutorial_stop();
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) {
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 23:21:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066DF17
|
|
|
|
*/
|
|
|
|
static void window_save_prompt_close()
|
|
|
|
{
|
|
|
|
// Unpause the game
|
|
|
|
RCT2_GLOBAL(0x009DEA6E, uint8) &= ~2;
|
2014-05-06 23:04:09 +02:00
|
|
|
unpause_sounds();
|
2014-05-02 23:21:08 +02:00
|
|
|
window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066DDF2
|
|
|
|
*/
|
|
|
|
static void window_save_prompt_mouseup()
|
|
|
|
{
|
|
|
|
short widgetIndex;
|
|
|
|
rct_window *w;
|
2014-05-24 01:00:58 +02:00
|
|
|
short prompt_mode;
|
2014-05-02 23:21:08 +02:00
|
|
|
|
2014-05-19 22:53:14 +02:00
|
|
|
#ifdef _MSC_VER
|
2014-05-02 23:21:08 +02:00
|
|
|
__asm mov widgetIndex, dx
|
2014-05-19 22:53:14 +02:00
|
|
|
#else
|
|
|
|
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
2014-05-02 23:21:08 +02:00
|
|
|
__asm mov w, esi
|
2014-05-19 22:53:14 +02:00
|
|
|
#else
|
|
|
|
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
|
|
|
#endif
|
|
|
|
|
2014-05-24 01:00:58 +02:00
|
|
|
prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16);
|
|
|
|
|
|
|
|
if (prompt_mode == PM_QUIT) {
|
|
|
|
switch (widgetIndex) {
|
|
|
|
case WQIDX_OK:
|
|
|
|
rct2_finish();
|
|
|
|
break;
|
2014-05-24 21:01:10 +02:00
|
|
|
case WQIDX_CLOSE:
|
2014-05-24 01:00:58 +02:00
|
|
|
case WQIDX_CANCEL:
|
|
|
|
window_close(w);
|
|
|
|
window_save_prompt_close();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
switch (widgetIndex) {
|
|
|
|
case WIDX_SAVE:
|
|
|
|
// TODO to avoid data loss, treat SAVE as CANCEL
|
|
|
|
RCT2_ERROR("%s", "TODO\n");
|
|
|
|
window_close(w);
|
|
|
|
window_save_prompt_close();
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case WIDX_DONT_SAVE:
|
|
|
|
break;
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
case WIDX_CANCEL:
|
|
|
|
window_close(w);
|
|
|
|
window_save_prompt_close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) {
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
|
|
|
}
|
2014-05-02 23:21:08 +02:00
|
|
|
|
2014-05-24 01:00:58 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) {
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) {
|
|
|
|
RCT2_CALLPROC_EBPSAFE(0x0066EE54);
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
tutorial_stop();
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) {
|
|
|
|
game_load_or_quit_no_save_prompt();
|
|
|
|
return;
|
2014-05-23 11:30:19 +02:00
|
|
|
}
|
2014-05-02 23:21:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void window_save_prompt_paint()
|
|
|
|
{
|
|
|
|
rct_window *w;
|
|
|
|
rct_drawpixelinfo *dpi;
|
|
|
|
|
2014-05-19 22:53:14 +02:00
|
|
|
#ifdef _MSC_VER
|
2014-05-02 23:21:08 +02:00
|
|
|
__asm mov w, esi
|
2014-05-19 22:53:14 +02:00
|
|
|
#else
|
|
|
|
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
2014-05-02 23:21:08 +02:00
|
|
|
__asm mov dpi, edi
|
2014-05-19 22:53:14 +02:00
|
|
|
#else
|
|
|
|
__asm__ ( "mov %[dpi], edi " : [dpi] "+m" (dpi) );
|
|
|
|
#endif
|
|
|
|
|
2014-05-02 23:21:08 +02:00
|
|
|
|
|
|
|
window_draw_widgets(w, dpi);
|
|
|
|
}
|