diff options
author | yexo <yexo@openttd.org> | 2010-07-03 13:29:01 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-07-03 13:29:01 +0000 |
commit | fda69b2be3aa1a934c03d311e05d20e09cb53b09 (patch) | |
tree | 78514dd136e879c1451a81145804610a7d2a347a /src | |
parent | 44a49ac849de127c5729370958aeab4b6aa743ee (diff) | |
download | openttd-fda69b2be3aa1a934c03d311e05d20e09cb53b09.tar.xz |
(svn r20057) -Feature: customizable hotkeys for the terraform toolbar in scenario editor
Diffstat (limited to 'src')
-rw-r--r-- | src/hotkeys.cpp | 2 | ||||
-rw-r--r-- | src/terraform_gui.cpp | 38 |
2 files changed, 22 insertions, 18 deletions
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 3123a82ae..e130dd928 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -228,6 +228,7 @@ void SaveLoadHotkeyGroup(IniGroup *group, T *hotkey_list, bool save) } struct TerraformToolbarWindow; +struct ScenarioEditorLandscapeGenerationWindow; static void SaveLoadHotkeys(bool save) { @@ -242,6 +243,7 @@ static void SaveLoadHotkeys(bool save) SaveLoadHotkeyGroup(group, _##name##_hotkeys, save); SL_HOTKEYS(terraform, TerraformToolbarWindow); + SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow); #undef SL_HOTKEYS 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, |