OpenRCT2/src/openrct2-ui/windows/ShortcutKeys.cpp

565 lines
17 KiB
C++
Raw Normal View History

2014-10-05 15:21:35 +02:00
/*****************************************************************************
* Copyright (c) 2014-2022 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
2014-10-05 15:21:35 +02:00
2020-07-15 01:40:29 +02:00
#include "../input/ShortcutManager.h"
2017-08-06 05:22:00 +02:00
#include "Window.h"
2017-08-04 00:21:54 +02:00
2018-01-03 00:13:37 +01:00
#include <openrct2-ui/interface/Widget.h>
2018-03-19 23:28:40 +01:00
#include <openrct2/drawing/Drawing.h>
2021-12-12 00:06:06 +01:00
#include <openrct2/localisation/Formatter.h>
2018-06-22 23:21:44 +02:00
#include <openrct2/localisation/Localisation.h>
2021-01-13 02:57:43 +01:00
#include <openrct2/sprites.h>
2014-10-05 15:21:35 +02:00
2021-01-13 01:59:07 +01:00
using namespace OpenRCT2;
2020-07-15 01:40:29 +02:00
using namespace OpenRCT2::Ui;
2022-07-31 14:22:58 +02:00
static constexpr const StringId WINDOW_TITLE = STR_SHORTCUTS_TITLE;
2020-05-09 17:05:01 +02:00
static constexpr const int32_t WW = 420;
static constexpr const int32_t WH = 280;
2020-05-09 17:05:01 +02:00
static constexpr const int32_t WW_SC_MAX = 1200;
static constexpr const int32_t WH_SC_MAX = 800;
2014-10-05 15:21:35 +02:00
enum WindowShortcutWidgetIdx
2021-01-13 01:59:07 +01:00
{
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
2021-01-13 02:57:43 +01:00
WIDX_TAB_CONTENT_PANEL,
WIDX_SCROLL,
2021-01-13 02:57:43 +01:00
WIDX_RESET,
WIDX_TAB_0,
2014-10-05 15:21:35 +02:00
};
2021-01-13 01:59:07 +01:00
// clang-format off
2014-10-05 15:21:35 +02:00
static rct_widget window_shortcut_widgets[] = {
2020-05-09 16:44:21 +02:00
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
2021-01-13 02:57:43 +01:00
MakeWidget({0, 43}, {350, 287}, WindowWidgetType::Resize, WindowColour::Secondary),
MakeWidget({4, 47}, {412, 245}, WindowWidgetType::Scroll, WindowColour::Primary, SCROLL_VERTICAL, STR_SHORTCUT_LIST_TIP ),
MakeWidget({4, WH-15}, {150, 12}, WindowWidgetType::Button, WindowColour::Primary, STR_SHORTCUT_ACTION_RESET, STR_SHORTCUT_ACTION_RESET_TIP),
2021-09-26 11:11:42 +02:00
WIDGETS_END,
2014-10-05 15:21:35 +02:00
};
2021-01-13 01:59:07 +01:00
// clang-format on
2014-10-05 15:21:35 +02:00
2022-07-31 14:22:58 +02:00
static constexpr const StringId CHANGE_WINDOW_TITLE = STR_SHORTCUT_CHANGE_TITLE;
2021-01-13 01:59:07 +01:00
static constexpr const int32_t CHANGE_WW = 250;
2021-02-23 22:34:32 +01:00
static constexpr const int32_t CHANGE_WH = 80;
enum
{
WIDX_REMOVE = 3
};
2021-01-13 01:59:07 +01:00
// clang-format off
static rct_widget window_shortcut_change_widgets[] = {
WINDOW_SHIM(CHANGE_WINDOW_TITLE, CHANGE_WW, CHANGE_WH),
MakeWidget({ 75, 56 }, { 100, 14 }, WindowWidgetType::Button, WindowColour::Primary, STR_SHORTCUT_REMOVE, STR_SHORTCUT_REMOVE_TIP),
2021-09-26 11:11:42 +02:00
WIDGETS_END,
};
2021-01-13 01:59:07 +01:00
// clang-format on
2021-01-13 01:59:07 +01:00
class ChangeShortcutWindow final : public Window
{
2021-01-13 01:59:07 +01:00
private:
2021-02-23 22:34:32 +01:00
std::string _shortcutId;
2022-07-31 14:22:58 +02:00
StringId _shortcutLocalisedName{};
2021-01-13 01:59:07 +01:00
std::string _shortcutCustomName;
2020-07-15 01:40:29 +02:00
2021-01-13 01:59:07 +01:00
public:
static ChangeShortcutWindow* Open(std::string_view shortcutId)
2020-07-15 01:40:29 +02:00
{
2021-01-13 01:59:07 +01:00
auto& shortcutManager = GetShortcutManager();
auto registeredShortcut = shortcutManager.GetShortcut(shortcutId);
if (registeredShortcut != nullptr)
2020-07-15 01:40:29 +02:00
{
window_close_by_class(WindowClass::ChangeKeyboardShortcut);
auto w = WindowCreate<ChangeShortcutWindow>(
WindowClass::ChangeKeyboardShortcut, CHANGE_WW, CHANGE_WH, WF_CENTRE_SCREEN);
2021-01-13 01:59:07 +01:00
if (w != nullptr)
2020-07-15 01:40:29 +02:00
{
2021-02-23 22:34:32 +01:00
w->_shortcutId = shortcutId;
2021-01-13 01:59:07 +01:00
w->_shortcutLocalisedName = registeredShortcut->LocalisedName;
w->_shortcutCustomName = registeredShortcut->CustomName;
shortcutManager.SetPendingShortcutChange(registeredShortcut->Id);
return w;
2020-07-15 01:40:29 +02:00
}
}
2021-01-13 01:59:07 +01:00
return nullptr;
}
2020-07-15 01:40:29 +02:00
2021-01-13 01:59:07 +01:00
void OnOpen() override
{
widgets = window_shortcut_change_widgets;
WindowInitScrollWidgets(*this);
2020-07-15 01:40:29 +02:00
}
2021-01-13 01:59:07 +01:00
void OnClose() override
2020-07-15 01:40:29 +02:00
{
2021-01-13 01:59:07 +01:00
auto& shortcutManager = GetShortcutManager();
shortcutManager.SetPendingShortcutChange({});
NotifyShortcutKeysWindow();
}
2022-08-21 18:49:23 +02:00
void OnMouseUp(WidgetIndex widgetIndex) override
2021-01-13 01:59:07 +01:00
{
switch (widgetIndex)
2020-07-15 01:40:29 +02:00
{
2021-01-13 01:59:07 +01:00
case WIDX_CLOSE:
Close();
break;
2021-02-23 22:34:32 +01:00
case WIDX_REMOVE:
Remove();
break;
2020-07-15 01:40:29 +02:00
}
}
2018-02-01 18:49:14 +01:00
2021-01-13 01:59:07 +01:00
void OnDraw(rct_drawpixelinfo& dpi) override
{
2021-01-13 01:59:07 +01:00
DrawWidgets(dpi);
2020-07-15 01:40:29 +02:00
2021-01-13 01:59:07 +01:00
ScreenCoordsXY stringCoords(windowPos.x + 125, windowPos.y + 30);
2014-10-05 15:21:35 +02:00
2021-01-13 01:59:07 +01:00
auto ft = Formatter();
if (_shortcutCustomName.empty())
{
2022-07-31 14:22:58 +02:00
ft.Add<StringId>(_shortcutLocalisedName);
2021-01-13 01:59:07 +01:00
}
else
{
2022-07-31 14:22:58 +02:00
ft.Add<StringId>(STR_STRING);
2021-01-13 01:59:07 +01:00
ft.Add<const char*>(_shortcutCustomName.c_str());
}
DrawTextWrapped(&dpi, stringCoords, 242, STR_SHORTCUT_CHANGE_PROMPT, ft, { TextAlignment::CENTRE });
}
2014-10-05 15:38:15 +02:00
2021-01-13 01:59:07 +01:00
private:
void NotifyShortcutKeysWindow();
2021-02-23 22:34:32 +01:00
void Remove()
{
auto& shortcutManager = GetShortcutManager();
auto* shortcut = shortcutManager.GetShortcut(_shortcutId);
if (shortcut != nullptr)
{
shortcut->Current.clear();
shortcutManager.SaveUserBindings();
2021-02-23 22:34:32 +01:00
}
Close();
}
2021-01-13 01:59:07 +01:00
};
class ShortcutKeysWindow final : public Window
2014-10-05 15:38:15 +02:00
{
2021-01-13 01:59:07 +01:00
private:
struct ShortcutStringPair
2018-06-22 23:21:44 +02:00
{
2021-01-13 01:59:07 +01:00
std::string ShortcutId;
2022-07-31 15:04:08 +02:00
::StringId StringId = STR_NONE;
2021-01-13 01:59:07 +01:00
std::string CustomString;
std::string Binding;
};
2021-01-13 02:57:43 +01:00
struct ShortcutTabDesc
{
std::string_view IdGroup;
uint32_t ImageId;
uint32_t ImageDivisor;
uint32_t ImageNumFrames;
};
std::vector<ShortcutTabDesc> _tabs;
std::vector<rct_widget> _widgets;
2021-01-13 01:59:07 +01:00
std::vector<ShortcutStringPair> _list;
int_fast16_t _highlightedItem;
2021-01-13 02:57:43 +01:00
size_t _currentTabIndex{};
uint32_t _tabAnimationIndex{};
2021-01-13 01:59:07 +01:00
public:
void OnOpen() override
{
2021-01-13 02:57:43 +01:00
InitialiseTabs();
InitialiseWidgets();
2021-01-13 01:59:07 +01:00
InitialiseList();
min_width = WW;
min_height = WH;
max_width = WW_SC_MAX;
max_height = WH_SC_MAX;
}
2014-10-05 15:38:15 +02:00
2021-01-13 01:59:07 +01:00
void OnResize() override
{
window_set_resize(*this, min_width, min_height, max_width, max_height);
2021-01-13 01:59:07 +01:00
}
2021-01-13 02:57:43 +01:00
void OnUpdate() override
{
// Remove highlight when the mouse is not hovering over the list
if (_highlightedItem != -1 && !WidgetIsHighlighted(*this, WIDX_SCROLL))
{
_highlightedItem = -1;
InvalidateWidget(WIDX_SCROLL);
}
2021-01-13 02:57:43 +01:00
_tabAnimationIndex++;
2022-08-21 18:49:23 +02:00
InvalidateWidget(static_cast<WidgetIndex>(WIDX_TAB_0 + _currentTabIndex));
2021-01-13 02:57:43 +01:00
}
2022-08-21 18:49:23 +02:00
void OnMouseUp(WidgetIndex widgetIndex) override
2021-01-13 01:59:07 +01:00
{
switch (widgetIndex)
{
case WIDX_CLOSE:
Close();
break;
case WIDX_RESET:
ResetAll();
break;
2021-01-13 02:57:43 +01:00
default:
{
auto tabIndex = static_cast<size_t>(widgetIndex - WIDX_TAB_0);
if (tabIndex < _tabs.size())
{
SetTab(tabIndex);
}
}
2021-01-13 01:59:07 +01:00
}
}
2021-01-13 01:59:07 +01:00
void OnPrepareDraw() override
{
widgets[WIDX_BACKGROUND].right = width - 1;
widgets[WIDX_BACKGROUND].bottom = height - 1;
widgets[WIDX_TITLE].right = width - 2;
widgets[WIDX_CLOSE].right = width - 3;
widgets[WIDX_CLOSE].left = width - 13;
2021-01-13 02:57:43 +01:00
widgets[WIDX_TAB_CONTENT_PANEL].right = width - 1;
widgets[WIDX_TAB_CONTENT_PANEL].bottom = height - 1;
2021-01-13 01:59:07 +01:00
widgets[WIDX_SCROLL].right = width - 5;
2021-01-13 02:57:43 +01:00
widgets[WIDX_SCROLL].bottom = height - 19;
widgets[WIDX_RESET].top = height - 16;
widgets[WIDX_RESET].bottom = height - 5;
2022-08-21 18:49:23 +02:00
window_align_tabs(this, WIDX_TAB_0, static_cast<WidgetIndex>(WIDX_TAB_0 + _tabs.size()));
2021-01-13 02:57:43 +01:00
// Set selected tab
for (size_t i = 0; i < _tabs.size(); i++)
{
2022-08-21 18:49:23 +02:00
SetWidgetPressed(static_cast<WidgetIndex>(WIDX_TAB_0 + i), false);
2021-01-13 02:57:43 +01:00
}
2022-08-21 18:49:23 +02:00
SetWidgetPressed(static_cast<WidgetIndex>(WIDX_TAB_0 + _currentTabIndex), true);
2021-01-13 01:59:07 +01:00
}
2014-10-05 15:38:15 +02:00
2021-01-13 01:59:07 +01:00
void OnDraw(rct_drawpixelinfo& dpi) override
{
DrawWidgets(dpi);
2021-01-13 02:57:43 +01:00
DrawTabImages(dpi);
2021-01-13 01:59:07 +01:00
}
2021-01-13 01:59:07 +01:00
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
{
2021-01-17 17:11:52 +01:00
auto h = static_cast<int32_t>(_list.size() * SCROLLABLE_ROW_HEIGHT);
auto bottom = std::max(0, h - widgets[WIDX_SCROLL].bottom + widgets[WIDX_SCROLL].top + 21);
if (bottom < scrolls[0].v_top)
{
scrolls[0].v_top = bottom;
Invalidate();
}
return { 0, h };
2021-01-13 01:59:07 +01:00
}
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
{
auto index = static_cast<int_fast16_t>((screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT);
if (static_cast<size_t>(index) < _list.size())
2021-01-13 01:59:07 +01:00
{
_highlightedItem = index;
Invalidate();
}
else
{
_highlightedItem = -1;
}
2021-01-13 01:59:07 +01:00
}
2021-01-13 01:59:07 +01:00
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
{
auto selectedItem = static_cast<size_t>((screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT);
if (selectedItem < _list.size())
{
// Is this a separator?
if (!_list[selectedItem].ShortcutId.empty())
{
auto& shortcut = _list[selectedItem];
ChangeShortcutWindow::Open(shortcut.ShortcutId);
}
}
}
2021-01-13 01:59:07 +01:00
void OnScrollDraw(int32_t scrollIndex, rct_drawpixelinfo& dpi) override
{
auto dpiCoords = ScreenCoordsXY{ dpi.x, dpi.y };
gfx_fill_rect(
&dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.width - 1, dpi.height - 1 } }, ColourMapA[colours[1]].mid_light);
2021-01-13 01:59:07 +01:00
// TODO: the line below is a workaround for what is presumably a bug with dpi->width
// see https://github.com/OpenRCT2/OpenRCT2/issues/11238 for details
const auto scrollWidth = width - SCROLLBAR_WIDTH - 10;
2015-10-20 20:16:30 +02:00
2021-01-13 01:59:07 +01:00
for (size_t i = 0; i < _list.size(); ++i)
{
auto y = static_cast<int32_t>(1 + i * SCROLLABLE_ROW_HEIGHT);
if (y > dpi.y + dpi.height)
{
break;
}
2021-01-13 01:59:07 +01:00
if (y + SCROLLABLE_ROW_HEIGHT < dpi.y)
{
continue;
}
2021-01-13 01:59:07 +01:00
// Is this a separator?
if (_list[i].ShortcutId.empty())
{
DrawSeparator(dpi, y, scrollWidth);
}
else
{
auto isHighlighted = _highlightedItem == static_cast<int_fast16_t>(i);
2021-01-13 01:59:07 +01:00
DrawItem(dpi, y, scrollWidth, _list[i], isHighlighted);
}
}
}
2015-10-20 20:16:30 +02:00
2021-01-13 01:59:07 +01:00
void RefreshBindings()
{
InitialiseList();
}
2021-01-13 01:59:07 +01:00
private:
2021-01-13 02:57:43 +01:00
bool IsInCurrentTab(const RegisteredShortcut& shortcut)
{
auto groupFilter = _tabs[_currentTabIndex].IdGroup;
auto group = shortcut.GetTopLevelGroup();
if (groupFilter.empty())
{
// Check it doesn't belong in any other tab
for (const auto& tab : _tabs)
{
if (!tab.IdGroup.empty())
{
if (tab.IdGroup == group)
{
return false;
}
}
}
return true;
}
2021-09-15 22:22:15 +02:00
return group == groupFilter;
2021-01-13 02:57:43 +01:00
}
2021-01-13 01:59:07 +01:00
void InitialiseList()
{
2021-01-13 22:09:18 +01:00
// Get shortcuts and sort by group
auto shortcuts = GetShortcutsForCurrentTab();
std::stable_sort(shortcuts.begin(), shortcuts.end(), [](const RegisteredShortcut* a, const RegisteredShortcut* b) {
return a->GetGroup().compare(b->GetGroup()) < 0;
});
2021-01-13 02:57:43 +01:00
2021-01-13 22:09:18 +01:00
// Create list items with a separator between each group
2021-01-13 01:59:07 +01:00
_list.clear();
size_t index = 0;
std::string group;
2021-01-13 22:09:18 +01:00
for (const auto* shortcut : shortcuts)
{
2021-01-13 22:09:18 +01:00
if (group.empty())
2021-01-13 01:59:07 +01:00
{
2021-01-13 22:09:18 +01:00
group = shortcut->GetGroup();
}
else
{
auto groupName = shortcut->GetGroup();
if (group != groupName)
2021-01-13 01:59:07 +01:00
{
2021-01-13 22:09:18 +01:00
// Add separator
group = groupName;
_list.emplace_back();
2021-01-13 01:59:07 +01:00
}
}
2021-01-13 22:09:18 +01:00
ShortcutStringPair ssp;
ssp.ShortcutId = shortcut->Id;
ssp.StringId = shortcut->LocalisedName;
ssp.CustomString = shortcut->CustomName;
ssp.Binding = shortcut->GetDisplayString();
2021-01-13 22:09:18 +01:00
_list.push_back(std::move(ssp));
index++;
2021-01-13 02:57:43 +01:00
}
Invalidate();
}
2021-01-13 22:09:18 +01:00
std::vector<const RegisteredShortcut*> GetShortcutsForCurrentTab()
{
std::vector<const RegisteredShortcut*> result;
auto& shortcutManager = GetShortcutManager();
for (const auto& shortcut : shortcutManager.Shortcuts)
{
if (IsInCurrentTab(shortcut.second))
2021-01-13 22:09:18 +01:00
{
result.push_back(&shortcut.second);
2021-01-13 22:09:18 +01:00
}
}
return result;
}
2021-01-13 02:57:43 +01:00
void InitialiseTabs()
{
_tabs.clear();
_tabs.push_back({ "interface", SPR_TAB_GEARS_0, 2, 4 });
2021-01-13 21:49:24 +01:00
_tabs.push_back({ "view", SPR_G2_VIEW, 0, 0 });
2021-01-13 02:57:43 +01:00
_tabs.push_back({ "window", SPR_TAB_PARK_ENTRANCE, 0, 0 });
_tabs.push_back({ {}, SPR_TAB_WRENCH_0, 2, 16 });
}
void InitialiseWidgets()
{
_widgets.clear();
_widgets.insert(_widgets.begin(), std::begin(window_shortcut_widgets), std::end(window_shortcut_widgets) - 1);
int32_t x = 3;
for (size_t i = 0; i < _tabs.size(); i++)
{
auto tab = MakeTab({ x, 17 }, STR_NONE);
_widgets.push_back(tab);
x += 31;
}
2021-09-26 11:11:42 +02:00
_widgets.push_back(WIDGETS_END);
2021-01-13 02:57:43 +01:00
widgets = _widgets.data();
WindowInitScrollWidgets(*this);
2021-01-13 02:57:43 +01:00
}
void SetTab(size_t index)
{
if (_currentTabIndex != index)
{
_currentTabIndex = index;
_tabAnimationIndex = 0;
InitialiseList();
}
2021-01-13 01:59:07 +01:00
}
2021-01-13 01:59:07 +01:00
void ResetAll()
{
auto& shortcutManager = GetShortcutManager();
for (const auto& item : _list)
{
2021-01-13 01:59:07 +01:00
auto shortcut = shortcutManager.GetShortcut(item.ShortcutId);
if (shortcut != nullptr)
{
shortcut->Current = shortcut->Default;
}
}
2021-01-13 01:59:07 +01:00
shortcutManager.SaveUserBindings();
RefreshBindings();
}
2021-01-13 02:57:43 +01:00
void DrawTabImages(rct_drawpixelinfo& dpi) const
{
for (size_t i = 0; i < _tabs.size(); i++)
{
DrawTabImage(dpi, i);
}
}
void DrawTabImage(rct_drawpixelinfo& dpi, size_t tabIndex) const
{
const auto& tabDesc = _tabs[tabIndex];
2022-08-21 18:49:23 +02:00
auto widgetIndex = static_cast<WidgetIndex>(WIDX_TAB_0 + tabIndex);
2021-01-13 02:57:43 +01:00
if (!IsWidgetDisabled(widgetIndex))
{
auto imageId = tabDesc.ImageId;
if (imageId != 0)
{
if (tabIndex == _currentTabIndex && tabDesc.ImageDivisor != 0 && tabDesc.ImageNumFrames != 0)
{
auto frame = _tabAnimationIndex / tabDesc.ImageDivisor;
imageId += frame % tabDesc.ImageNumFrames;
}
const auto& widget = widgets[widgetIndex];
gfx_draw_sprite(&dpi, ImageId(imageId), windowPos + ScreenCoordsXY{ widget.left, widget.top });
2021-01-13 02:57:43 +01:00
}
}
}
2021-01-13 01:59:07 +01:00
void DrawSeparator(rct_drawpixelinfo& dpi, int32_t y, int32_t scrollWidth)
{
const int32_t top = y + (SCROLLABLE_ROW_HEIGHT / 2) - 1;
gfx_fill_rect(&dpi, { { 0, top }, { scrollWidth, top } }, ColourMapA[colours[0]].mid_dark);
gfx_fill_rect(&dpi, { { 0, top + 1 }, { scrollWidth, top + 1 } }, ColourMapA[colours[0]].lightest);
}
void DrawItem(
rct_drawpixelinfo& dpi, int32_t y, int32_t scrollWidth, const ShortcutStringPair& shortcut, bool isHighlighted)
{
auto format = STR_BLACK_STRING;
if (isHighlighted)
{
format = STR_WINDOW_COLOUR_2_STRINGID;
gfx_filter_rect(&dpi, { 0, y - 1, scrollWidth, y + (SCROLLABLE_ROW_HEIGHT - 2) }, FilterPaletteID::PaletteDarken1);
}
2021-01-17 17:13:56 +01:00
auto bindingOffset = (scrollWidth * 2) / 3;
auto ft = Formatter();
2022-07-31 14:22:58 +02:00
ft.Add<StringId>(STR_SHORTCUT_ENTRY_FORMAT);
2020-12-16 01:15:20 +01:00
if (shortcut.CustomString.empty())
{
2022-07-31 14:22:58 +02:00
ft.Add<StringId>(shortcut.StringId);
2020-12-16 01:15:20 +01:00
}
else
{
2022-07-31 14:22:58 +02:00
ft.Add<StringId>(STR_STRING);
2020-12-16 01:15:20 +01:00
ft.Add<const char*>(shortcut.CustomString.c_str());
}
DrawTextEllipsised(&dpi, { 0, y - 1 }, bindingOffset, format, ft);
2021-01-13 01:59:07 +01:00
if (!shortcut.Binding.empty())
{
ft = Formatter();
2022-07-31 14:22:58 +02:00
ft.Add<StringId>(STR_STRING);
2021-01-13 01:59:07 +01:00
ft.Add<const char*>(shortcut.Binding.c_str());
DrawTextEllipsised(&dpi, { bindingOffset, y - 1 }, 150, format, ft);
2021-01-13 01:59:07 +01:00
}
}
};
void ChangeShortcutWindow::NotifyShortcutKeysWindow()
{
auto w = window_find_by_class(WindowClass::KeyboardShortcutList);
2021-01-13 01:59:07 +01:00
if (w != nullptr)
{
static_cast<ShortcutKeysWindow*>(w)->RefreshBindings();
}
}
2021-01-13 01:59:07 +01:00
rct_window* WindowShortcutKeysOpen()
2021-01-13 01:59:07 +01:00
{
auto w = window_bring_to_front_by_class(WindowClass::KeyboardShortcutList);
2021-01-13 01:59:07 +01:00
if (w == nullptr)
{
w = WindowCreate<ShortcutKeysWindow>(WindowClass::KeyboardShortcutList, WW, WH, WF_RESIZABLE);
2021-01-13 01:59:07 +01:00
}
return w;
}