2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2014-10-07 18:57:38 +02:00
|
|
|
/*****************************************************************************
|
2016-05-04 19:24:41 +02:00
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/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.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
2014-10-07 18:57:38 +02:00
|
|
|
|
2017-06-11 13:30:00 +02:00
|
|
|
#include <openrct2/config/Config.h>
|
2017-08-06 21:20:05 +02:00
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2017-08-12 23:06:12 +02:00
|
|
|
#include <openrct2-ui/input/KeyboardShortcuts.h>
|
2017-08-04 00:21:54 +02:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2017-08-09 23:08:55 +02:00
|
|
|
#include <openrct2/interface/window.h>
|
|
|
|
#include <openrct2/interface/widget.h>
|
|
|
|
#include <openrct2/localisation/localisation.h>
|
2017-08-04 00:21:54 +02:00
|
|
|
}
|
2014-10-07 18:57:38 +02:00
|
|
|
|
|
|
|
#define WW 250
|
|
|
|
#define WH 60
|
|
|
|
|
|
|
|
enum WINDOW_SHORTCUT_CHANGE_WIDGET_IDX {
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLE,
|
|
|
|
WIDX_CLOSE,
|
2014-10-07 18:57:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// 0x9DE4E0
|
|
|
|
static rct_widget window_shortcut_change_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE },
|
|
|
|
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_SHORTCUT_CHANGE_TITLE, STR_WINDOW_TITLE_TIP },
|
|
|
|
{ WWT_CLOSEBOX, 0, WW-13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
|
|
|
|
{ WIDGETS_END }
|
2014-10-07 18:57:38 +02:00
|
|
|
};
|
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_shortcut_change_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_shortcut_change_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2014-10-07 18:57:38 +02:00
|
|
|
|
2017-05-11 11:45:59 +02:00
|
|
|
// 0x9A3F7C
|
2015-07-10 02:39:16 +02:00
|
|
|
static rct_window_event_list window_shortcut_change_events = {
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_shortcut_change_mouseup,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_shortcut_change_paint,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr
|
2014-10-07 18:57:38 +02:00
|
|
|
};
|
|
|
|
|
2017-06-11 16:16:47 +02:00
|
|
|
rct_window * window_shortcut_change_open(sint32 selected_key)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Move this to window_shortcut_change_open
|
|
|
|
window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
|
|
|
|
// Save the item we are selecting for new window
|
|
|
|
gKeyboardShortcutChangeId = selected_key;
|
2017-06-11 16:16:47 +02:00
|
|
|
rct_window * w = window_create_centred(WW, WH, &window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0);
|
2014-10-07 18:57:38 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets = window_shortcut_change_widgets;
|
|
|
|
w->enabled_widgets = (1ULL << WIDX_CLOSE);
|
|
|
|
window_init_scroll_widgets(w);
|
2017-06-11 16:16:47 +02:00
|
|
|
return w;
|
2014-10-07 18:57:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E3AE0
|
|
|
|
*/
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_shortcut_change_mouseup(rct_window *w, rct_widgetindex widgetIndex)
|
2015-07-10 02:39:16 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
switch (widgetIndex){
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
}
|
2014-10-07 18:57:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006E3A9F
|
|
|
|
*/
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_shortcut_change_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_draw_widgets(w, dpi);
|
2014-10-07 18:57:38 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 x = w->x + 125;
|
|
|
|
sint32 y = w->y + 30;
|
2014-10-07 18:57:38 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
set_format_arg(0, rct_string_id, ShortcutStringIds[gKeyboardShortcutChangeId]);
|
|
|
|
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, 242, STR_SHORTCUT_CHANGE_PROMPT, COLOUR_BLACK);
|
2015-12-21 05:03:37 +01:00
|
|
|
}
|