Mercurial > hg > openttd
changeset 12088:7f4295a66bff draft
(svn r16497) -Feature [FS#2870]: Q/W/E/D will now open the landscape toolbar and select appropriate tool
author | smatz <smatz@openttd.org> |
---|---|
date | Mon, 01 Jun 2009 14:36:36 +0000 |
parents | 6a834ab923fc |
children | 482bdd64bbe8 |
files | src/terraform_gui.cpp src/terraform_gui.h src/toolbar_gui.cpp |
diffstat | 3 files changed, 34 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -350,20 +350,20 @@ _terraform_widgets, _nested_terraform_widgets, lengthof(_nested_terraform_widgets) ); -void ShowTerraformToolbar(Window *link) +Window *ShowTerraformToolbar(Window *link) { - if (!Company::IsValidID(_local_company)) return; + if (!Company::IsValidID(_local_company)) return NULL; Window *w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0); - if (link == NULL) return; + if (link == NULL) return w; if (w == NULL) { w = FindWindowById(WC_SCEN_LAND_GEN, 0); + if (w == NULL) return NULL; } else { w->top = 22; w->SetDirty(); } - if (w == NULL) return; /* Align the terraform toolbar under the main toolbar and put the linked * toolbar to left of it @@ -371,6 +371,18 @@ link->top = w->top; link->left = w->left - link->width; link->SetDirty(); + + return w; +} + +void ShowTerraformToolbarWithTool(uint16 key, uint16 keycode) +{ + Window *w = FindWindowById(WC_SCEN_LAND_GEN, 0); + + if (w == NULL) w = ShowTerraformToolbar(NULL); + if (w == NULL) return; + + w->OnKeyPress(key, keycode); } static byte _terraform_size = 1; @@ -774,7 +786,17 @@ _scen_edit_land_gen_widgets, _nested_scen_edit_land_gen_widgets, lengthof(_nested_scen_edit_land_gen_widgets) ); -void ShowEditorTerraformToolbar() +Window *ShowEditorTerraformToolbar() +{ + return AllocateWindowDescFront<ScenarioEditorLandscapeGenerationWindow>(&_scen_edit_land_gen_desc, 0); +} + +void ShowEditorTerraformToolbarWithTool(uint16 key, uint16 keycode) { - AllocateWindowDescFront<ScenarioEditorLandscapeGenerationWindow>(&_scen_edit_land_gen_desc, 0); + Window *w = FindWindowById(WC_SCEN_LAND_GEN, 0); + + if (w == NULL) w = ShowEditorTerraformToolbar(); + if (w == NULL) return; + + w->OnKeyPress(key, keycode); }
--- a/src/terraform_gui.h +++ b/src/terraform_gui.h @@ -9,7 +9,9 @@ void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2); -void ShowTerraformToolbar(Window *link = NULL); -void ShowEditorTerraformToolbar(); +Window *ShowTerraformToolbar(Window *link = NULL); +void ShowTerraformToolbarWithTool(uint16 key, uint16 keycode); +Window *ShowEditorTerraformToolbar(); +void ShowEditorTerraformToolbarWithTool(uint16 key, uint16 keycode); #endif /* GUI_H */
--- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1096,6 +1096,7 @@ case WKC_CTRL | WKC_ALT | 'C': if (!_networking) ShowCheatWindow(); break; case 'A': if (CanBuildVehicleInfrastructure(VEH_TRAIN)) ShowBuildRailToolbar(_last_built_railtype, 4); break; // Invoke Autorail case 'L': ShowTerraformToolbar(); break; + case 'Q': case 'W': case 'E': case 'D': ShowTerraformToolbarWithTool(key, keycode); break; case 'M': ShowSmallMap(); break; case 'V': ShowExtraViewPortWindow(); break; default: return ES_NOT_HANDLED; @@ -1303,6 +1304,7 @@ case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(this); break; case 'L': ShowEditorTerraformToolbar(); break; + case 'Q': case 'W': case 'E': case 'D': ShowEditorTerraformToolbarWithTool(key, keycode); break; case 'M': ShowSmallMap(); break; case 'V': ShowExtraViewPortWindow(); break; default: return ES_NOT_HANDLED;