summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-03 18:10:18 +0000
committeryexo <yexo@openttd.org>2010-07-03 18:10:18 +0000
commit2e0acdbb075b953acca4c067c0119de969a0d5fe (patch)
tree5bc6d770ebc60e202dc41b1c396854a071c61078
parentcf3fb937ab4e6f75b63fc02008f9f5fb0745e5e9 (diff)
downloadopenttd-2e0acdbb075b953acca4c067c0119de969a0d5fe.tar.xz
(svn r20062) -Feature: customizable hotkeys for the airport toolbar
-rw-r--r--src/airport_gui.cpp18
-rw-r--r--src/hotkeys.cpp2
2 files changed, 15 insertions, 5 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 336c3ea6f..942f50180 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -26,6 +26,7 @@
#include "newgrf_airport.h"
#include "widgets/dropdown_type.h"
#include "core/geometry_func.hpp"
+#include "hotkeys.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -106,11 +107,9 @@ struct BuildAirToolbarWindow : Window {
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
- switch (keycode) {
- case '1': BuildAirClick_Airport(this); break;
- case '2': BuildAirClick_Demolish(this); break;
- default: return ES_NOT_HANDLED;
- }
+ int num = CheckHotkeyMatch(airtoolbar_hotkeys, keycode, this);
+ if (num == -1) return ES_NOT_HANDLED;
+ this->OnClick(Point(), num, 1);
return ES_HANDLED;
}
@@ -138,7 +137,16 @@ struct BuildAirToolbarWindow : Window {
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
DeleteWindowById(WC_SELECT_STATION, 0);
}
+
+ static Hotkey<BuildAirToolbarWindow> airtoolbar_hotkeys[];
+};
+
+Hotkey<BuildAirToolbarWindow> BuildAirToolbarWindow::airtoolbar_hotkeys[] = {
+ Hotkey<BuildAirToolbarWindow>('1', "airport", ATW_AIRPORT),
+ Hotkey<BuildAirToolbarWindow>('2', "demolish", ATW_DEMOLISH),
+ HOTKEY_LIST_END(BuildAirToolbarWindow)
};
+Hotkey<BuildAirToolbarWindow> *_airtoolbar_hotkeys = BuildAirToolbarWindow::airtoolbar_hotkeys;
static const NWidgetPart _nested_air_toolbar_widgets[] = {
NWidget(NWID_HORIZONTAL),
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp
index 6856fc10e..6b0e1a993 100644
--- a/src/hotkeys.cpp
+++ b/src/hotkeys.cpp
@@ -231,6 +231,7 @@ struct MainWindow;
struct TerraformToolbarWindow;
struct ScenarioEditorLandscapeGenerationWindow;
struct OrdersWindow;
+struct BuildAirToolbarWindow;
static void SaveLoadHotkeys(bool save)
{
@@ -248,6 +249,7 @@ static void SaveLoadHotkeys(bool save)
SL_HOTKEYS(terraform, TerraformToolbarWindow);
SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow);
SL_HOTKEYS(order, OrdersWindow);
+ SL_HOTKEYS(airtoolbar, BuildAirToolbarWindow);
#undef SL_HOTKEYS