summaryrefslogtreecommitdiff
path: root/src/terraform_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/terraform_gui.cpp')
-rw-r--r--src/terraform_gui.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 32de9e0ba..f4a9426a3 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -578,17 +578,6 @@ static void EditorTerraformClick_Transmitter(Window *w)
HandlePlacePushButton(w, ETTW_PLACE_TRANSMITTER, SPR_CURSOR_TRANSMITTER, HT_RECT, PlaceProc_Transmitter);
}
-static const uint16 _editor_terraform_keycodes[] = {
- 'D',
- 'Q',
- 'W',
- 'E',
- 'R',
- 'T',
- 'Y'
-};
-
-typedef void OnButtonClick(Window *w);
static OnButtonClick * const _editor_terraform_button_proc[] = {
EditorTerraformClick_Dynamite,
EditorTerraformClick_LowerBigLand,
@@ -666,13 +655,10 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
- for (uint i = 0; i != lengthof(_editor_terraform_keycodes); i++) {
- if (keycode == _editor_terraform_keycodes[i]) {
- _editor_terraform_button_proc[i](this);
- return ES_HANDLED;
- }
- }
- return ES_NOT_HANDLED;
+ int num = CheckHotkeyMatch(terraform_editor_hotkeys, keycode, this);
+ if (num == -1) return ES_NOT_HANDLED;
+ this->OnClick(Point(), num, 1);
+ return ES_HANDLED;
}
virtual void OnClick(Point pt, int widget, int click_count)
@@ -751,8 +737,24 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
this->RaiseButtons();
this->SetDirty();
}
+
+ static Hotkey<ScenarioEditorLandscapeGenerationWindow> terraform_editor_hotkeys[];
+};
+
+Hotkey<ScenarioEditorLandscapeGenerationWindow> ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys[] = {
+ Hotkey<ScenarioEditorLandscapeGenerationWindow>('D', "dynamite", ETTW_DEMOLISH),
+ Hotkey<ScenarioEditorLandscapeGenerationWindow>('Q', "lower", ETTW_LOWER_LAND),
+ Hotkey<ScenarioEditorLandscapeGenerationWindow>('W', "raise", ETTW_RAISE_LAND),
+ Hotkey<ScenarioEditorLandscapeGenerationWindow>('E', "level", ETTW_LEVEL_LAND),
+ Hotkey<ScenarioEditorLandscapeGenerationWindow>('R', "rocky", ETTW_PLACE_ROCKS),
+ Hotkey<ScenarioEditorLandscapeGenerationWindow>('T', "desertlighthouse", ETTW_PLACE_DESERT_LIGHTHOUSE),
+ Hotkey<ScenarioEditorLandscapeGenerationWindow>('Y', "transmitter", ETTW_PLACE_TRANSMITTER),
+ HOTKEY_LIST_END(ScenarioEditorLandscapeGenerationWindow)
};
+Hotkey<ScenarioEditorLandscapeGenerationWindow> *_terraform_editor_hotkeys = ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys;
+
+
static const WindowDesc _scen_edit_land_gen_desc(
WDP_AUTO, 0, 0,
WC_SCEN_LAND_GEN, WC_NONE,