summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-03 18:18:58 +0000
committeryexo <yexo@openttd.org>2010-07-03 18:18:58 +0000
commit243075a09658b696f55d348b1a6ae65a7098aa0e (patch)
tree24f6954821fb7aa84a9a5c5153b16d992d584f1e /src
parent2e0acdbb075b953acca4c067c0119de969a0d5fe (diff)
downloadopenttd-243075a09658b696f55d348b1a6ae65a7098aa0e.tar.xz
(svn r20063) -Feature: customizable hotkeys for the dock toolbar
Diffstat (limited to 'src')
-rw-r--r--src/dock_gui.cpp32
-rw-r--r--src/hotkeys.cpp2
2 files changed, 22 insertions, 12 deletions
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 935e5a16a..72e2b234d 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -28,6 +28,7 @@
#include "tilehighlight_func.h"
#include "company_base.h"
#include "station_type.h"
+#include "hotkeys.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -189,18 +190,9 @@ struct BuildDocksToolbarWindow : Window {
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
- switch (keycode) {
- case '1': BuildDocksClick_Canal(this); break;
- case '2': BuildDocksClick_Lock(this); break;
- case '3': BuildDocksClick_Demolish(this); break;
- case '4': BuildDocksClick_Depot(this); break;
- case '5': BuildDocksClick_Dock(this); break;
- case '6': BuildDocksClick_Buoy(this); break;
- case '7': BuildDocksClick_River(this); break;
- case 'B':
- case '8': BuildDocksClick_Aqueduct(this); break;
- default: return ES_NOT_HANDLED;
- }
+ int num = CheckHotkeyMatch(dockstoolbar_hotkeys, keycode, this);
+ if (num == -1) return ES_NOT_HANDLED;
+ this->OnClick(Point(), num, 1);
return ES_HANDLED;
}
@@ -254,8 +246,24 @@ struct BuildDocksToolbarWindow : Window {
VpSetPresizeRange(tile_from, tile_to);
}
+
+ static Hotkey<BuildDocksToolbarWindow> dockstoolbar_hotkeys[];
};
+const uint16 _dockstoolbar_aqueduct_keys[] = {'B', '8', 0};
+
+Hotkey<BuildDocksToolbarWindow> BuildDocksToolbarWindow::dockstoolbar_hotkeys[] = {
+ Hotkey<BuildDocksToolbarWindow>('1', "canal", DTW_CANAL),
+ Hotkey<BuildDocksToolbarWindow>('2', "lock", DTW_LOCK),
+ Hotkey<BuildDocksToolbarWindow>('3', "demolish", DTW_DEMOLISH),
+ Hotkey<BuildDocksToolbarWindow>('4', "depot", DTW_DEPOT),
+ Hotkey<BuildDocksToolbarWindow>('5', "dock", DTW_STATION),
+ Hotkey<BuildDocksToolbarWindow>('6', "buoy", DTW_BUOY),
+ Hotkey<BuildDocksToolbarWindow>('7', "river", DTW_RIVER),
+ Hotkey<BuildDocksToolbarWindow>(_dockstoolbar_aqueduct_keys, "aqueduct", DTW_BUILD_AQUEDUCT),
+ HOTKEY_LIST_END(BuildDocksToolbarWindow)
+};
+Hotkey<BuildDocksToolbarWindow> *_dockstoolbar_hotkeys = BuildDocksToolbarWindow::dockstoolbar_hotkeys;
/**
* Nested widget parts of docks toolbar, game version.
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp
index 6b0e1a993..dae73b5d2 100644
--- a/src/hotkeys.cpp
+++ b/src/hotkeys.cpp
@@ -232,6 +232,7 @@ struct TerraformToolbarWindow;
struct ScenarioEditorLandscapeGenerationWindow;
struct OrdersWindow;
struct BuildAirToolbarWindow;
+struct BuildDocksToolbarWindow;
static void SaveLoadHotkeys(bool save)
{
@@ -250,6 +251,7 @@ static void SaveLoadHotkeys(bool save)
SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow);
SL_HOTKEYS(order, OrdersWindow);
SL_HOTKEYS(airtoolbar, BuildAirToolbarWindow);
+ SL_HOTKEYS(dockstoolbar, BuildDocksToolbarWindow);
#undef SL_HOTKEYS