2014-04-03 04:08:06 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2014-04-03 04:08:06 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2014-04-03 04:08:06 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2014-04-03 04:08:06 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-01-03 00:13:37 +01:00
|
|
|
#include <openrct2-ui/interface/Widget.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2-ui/windows/Window.h>
|
|
|
|
#include <openrct2/Context.h>
|
2017-12-12 14:52:57 +01:00
|
|
|
#include <openrct2/Intro.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/config/Config.h>
|
|
|
|
#include <openrct2/localisation/Localisation.h>
|
|
|
|
#include <openrct2/sprites.h>
|
2014-04-03 04:08:06 +02:00
|
|
|
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format off
|
2017-03-11 21:47:06 +01:00
|
|
|
enum WINDOW_TITLE_EXIT_WIDGET_IDX {
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_EXIT,
|
2017-03-11 21:47:06 +01:00
|
|
|
};
|
|
|
|
|
2014-04-03 04:08:06 +02:00
|
|
|
static rct_widget window_title_exit_widgets[] = {
|
2020-08-29 04:31:31 +02:00
|
|
|
MakeWidget({0, 0}, {40, 64}, WWT_IMGBTN, WindowColour::Tertiary, SPR_MENU_EXIT, STR_EXIT),
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WIDGETS_END },
|
2014-04-03 04:08:06 +02:00
|
|
|
};
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_title_exit_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_title_exit_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2014-04-29 22:10:57 +02:00
|
|
|
|
2020-09-28 20:36:15 +02:00
|
|
|
static rct_window_event_list window_title_exit_events([](auto& events)
|
|
|
|
{
|
|
|
|
events.mouse_up = &window_title_exit_mouseup;
|
|
|
|
events.paint = &window_title_exit_paint;
|
|
|
|
});
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format on
|
2014-04-29 22:10:57 +02:00
|
|
|
|
2014-04-03 04:08:06 +02:00
|
|
|
/**
|
|
|
|
* Creates the window containing the exit button on the title screen.
|
|
|
|
* rct2: 0x0066B624 (part of 0x0066B3E8)
|
|
|
|
*/
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* window_title_exit_open()
|
2014-04-03 04:08:06 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_window* window;
|
2014-04-03 04:08:06 +02:00
|
|
|
|
2020-11-04 05:52:23 +01:00
|
|
|
window = WindowCreate(
|
2019-10-19 13:07:03 +02:00
|
|
|
ScreenCoordsXY(context_get_width() - 40, context_get_height() - 64), 40, 64, &window_title_exit_events, WC_TITLE_EXIT,
|
2018-06-22 23:21:44 +02:00
|
|
|
WF_STICK_TO_BACK | WF_TRANSPARENT);
|
2017-06-06 23:24:18 +02:00
|
|
|
window->widgets = window_title_exit_widgets;
|
|
|
|
window->enabled_widgets |= (1ULL << WIDX_EXIT);
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowInitScrollWidgets(window);
|
2017-08-06 05:22:00 +02:00
|
|
|
|
|
|
|
return window;
|
2014-04-21 11:27:48 +02:00
|
|
|
}
|
2014-04-29 22:10:57 +02:00
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0066B83C
|
|
|
|
*/
|
|
|
|
static void window_title_exit_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
2014-04-29 22:10:57 +02:00
|
|
|
{
|
2020-07-26 15:32:53 +02:00
|
|
|
if (gIntroState != IntroState::None)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2014-04-29 22:10:57 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_EXIT:
|
|
|
|
context_quit();
|
|
|
|
// game_do_command(0, 1, 0, 0, 5, 3, 0);
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
};
|
2014-04-29 22:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x0066B836
|
|
|
|
*/
|
|
|
|
static void window_title_exit_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2014-04-29 22:10:57 +02:00
|
|
|
{
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowDrawWidgets(w, dpi);
|
2015-05-12 16:13:30 +02:00
|
|
|
}
|