(svn r20062) -Feature: customizable hotkeys for the airport toolbar

This commit is contained in:
yexo 2010-07-03 18:10:18 +00:00
parent cf3fb937ab
commit 2e0acdbb07
2 changed files with 15 additions and 5 deletions

View File

@ -26,6 +26,7 @@
#include "newgrf_airport.h" #include "newgrf_airport.h"
#include "widgets/dropdown_type.h" #include "widgets/dropdown_type.h"
#include "core/geometry_func.hpp" #include "core/geometry_func.hpp"
#include "hotkeys.h"
#include "table/sprites.h" #include "table/sprites.h"
#include "table/strings.h" #include "table/strings.h"
@ -106,11 +107,9 @@ struct BuildAirToolbarWindow : Window {
virtual EventState OnKeyPress(uint16 key, uint16 keycode) virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{ {
switch (keycode) { int num = CheckHotkeyMatch(airtoolbar_hotkeys, keycode, this);
case '1': BuildAirClick_Airport(this); break; if (num == -1) return ES_NOT_HANDLED;
case '2': BuildAirClick_Demolish(this); break; this->OnClick(Point(), num, 1);
default: return ES_NOT_HANDLED;
}
return ES_HANDLED; return ES_HANDLED;
} }
@ -138,8 +137,17 @@ struct BuildAirToolbarWindow : Window {
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR); DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
DeleteWindowById(WC_SELECT_STATION, 0); DeleteWindowById(WC_SELECT_STATION, 0);
} }
static Hotkey<BuildAirToolbarWindow> airtoolbar_hotkeys[];
}; };
Hotkey<BuildAirToolbarWindow> BuildAirToolbarWindow::airtoolbar_hotkeys[] = {
Hotkey<BuildAirToolbarWindow>('1', "airport", ATW_AIRPORT),
Hotkey<BuildAirToolbarWindow>('2', "demolish", ATW_DEMOLISH),
HOTKEY_LIST_END(BuildAirToolbarWindow)
};
Hotkey<BuildAirToolbarWindow> *_airtoolbar_hotkeys = BuildAirToolbarWindow::airtoolbar_hotkeys;
static const NWidgetPart _nested_air_toolbar_widgets[] = { static const NWidgetPart _nested_air_toolbar_widgets[] = {
NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),

View File

@ -231,6 +231,7 @@ struct MainWindow;
struct TerraformToolbarWindow; struct TerraformToolbarWindow;
struct ScenarioEditorLandscapeGenerationWindow; struct ScenarioEditorLandscapeGenerationWindow;
struct OrdersWindow; struct OrdersWindow;
struct BuildAirToolbarWindow;
static void SaveLoadHotkeys(bool save) static void SaveLoadHotkeys(bool save)
{ {
@ -248,6 +249,7 @@ static void SaveLoadHotkeys(bool save)
SL_HOTKEYS(terraform, TerraformToolbarWindow); SL_HOTKEYS(terraform, TerraformToolbarWindow);
SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow); SL_HOTKEYS(terraform_editor, ScenarioEditorLandscapeGenerationWindow);
SL_HOTKEYS(order, OrdersWindow); SL_HOTKEYS(order, OrdersWindow);
SL_HOTKEYS(airtoolbar, BuildAirToolbarWindow);
#undef SL_HOTKEYS #undef SL_HOTKEYS