Index: town_gui.cpp =================================================================== --- town_gui.cpp (revision 27096) +++ town_gui.cpp (working copy) @@ -39,6 +39,15 @@ #include "safeguards.h" +#include "hotkeys.h" + +bool TownExecuteAction(Town *town, uint action){ + if(!(action == HK_STATUE && HasBit(town->statues, _current_company))){ //don't built statue when there is one + return DoCommandP(town->xy, town->index, action, CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS)); + } + return false; +} + typedef GUIList GUITownList; static const NWidgetPart _nested_town_authority_widgets[] = { @@ -281,13 +290,32 @@ { this->SetDirty(); } + + virtual EventState OnHotkey(int hotkey) + { + TownExecuteAction(this->town, hotkey); + return ES_NOT_HANDLED; + } + + static HotkeyList hotkeys; }; +static Hotkey town_hotkeys[] = { + Hotkey((uint16)0, "small_advert", HK_SADVERT), + Hotkey((uint16)0, "medium_advert", HK_MADVERT), + Hotkey(WKC_CTRL | 'D', "large_advert", HK_LADVERT), + Hotkey(WKC_CTRL | 'S', "build_statue", HK_STATUE), + Hotkey(WKC_CTRL | 'F', "fund_buildings", HK_FUND), + HOTKEY_LIST_END +}; +HotkeyList TownAuthorityWindow::hotkeys("town_gui", town_hotkeys); + static WindowDesc _town_authority_desc( WDP_AUTO, "view_town_authority", 317, 222, WC_TOWN_AUTHORITY, WC_NONE, 0, - _nested_town_authority_widgets, lengthof(_nested_town_authority_widgets) + _nested_town_authority_widgets, lengthof(_nested_town_authority_widgets), + &TownAuthorityWindow::hotkeys ); static void ShowTownAuthorityWindow(uint town) @@ -528,8 +556,24 @@ DoCommandP(0, this->window_number, 0, CMD_RENAME_TOWN | CMD_MSG(STR_ERROR_CAN_T_RENAME_TOWN), NULL, str); } + + virtual EventState OnHotkey(int hotkey) + { + if(hotkey == WID_TV_CB) ShowCBTownWindow(this->window_number); + return Window::OnHotkey(hotkey); + } + + static HotkeyList hotkeys; }; +static Hotkey town_window_hotkeys[] = { + Hotkey((uint16)0, "location", WID_TV_CENTER_VIEW), + Hotkey((uint16)0, "local_authority", WID_TV_SHOW_AUTHORITY), + Hotkey((uint16)0, "cb_window", WID_TV_CB), + HOTKEY_LIST_END +}; +HotkeyList TownViewWindow::hotkeys("town_window", town_window_hotkeys); + static const NWidgetPart _nested_town_game_view_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), @@ -558,7 +602,8 @@ WDP_AUTO, "view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL, WC_TOWN_VIEW, WC_NONE, 0, - _nested_town_game_view_widgets, lengthof(_nested_town_game_view_widgets) + _nested_town_game_view_widgets, lengthof(_nested_town_game_view_widgets), + &TownViewWindow::hotkeys ); static const NWidgetPart _nested_town_editor_view_widgets[] = { Index: widgets/town_widget.h =================================================================== --- widgets/town_widget.h (revision 27096) +++ widgets/town_widget.h (working copy) @@ -62,4 +62,13 @@ WID_TF_LAYOUT_RANDOM, ///< Selection for a randomly chosen town layout. }; +enum TownHK { + HK_SADVERT, + HK_MADVERT, + HK_LADVERT, + HK_ROADS, + HK_STATUE, + HK_FUND, +}; + #endif /* WIDGETS_TOWN_WIDGET_H */