mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r25412) -Codechange: Make use of Window::OnHotkey
This commit is contained in:
parent
6291383823
commit
5cb174c6b8
|
@ -1306,23 +1306,6 @@ struct AIDebugWindow : public Window {
|
|||
}
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
{
|
||||
EventState state = ES_NOT_HANDLED;
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num != -1) {
|
||||
if (this->show_break_box && num == WID_AID_BREAK_STR_EDIT_BOX) {
|
||||
this->SetFocusedWidget(WID_AID_BREAK_STR_EDIT_BOX);
|
||||
SetFocusedWindow(this);
|
||||
state = ES_HANDLED;
|
||||
} else if (this->show_break_box || num < WID_AID_BREAK_STRING_WIDGETS) {
|
||||
this->OnClick(Point(), num, 1);
|
||||
state = ES_HANDLED;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
virtual void OnEditboxChanged(int wid)
|
||||
{
|
||||
if (wid == WID_AID_BREAK_STR_EDIT_BOX) {
|
||||
|
@ -1494,7 +1477,8 @@ static WindowDesc _ai_debug_desc(
|
|||
WDP_AUTO, "script_debug", 600, 450,
|
||||
WC_AI_DEBUG, WC_NONE,
|
||||
0,
|
||||
_nested_ai_debug_widgets, lengthof(_nested_ai_debug_widgets)
|
||||
_nested_ai_debug_widgets, lengthof(_nested_ai_debug_widgets),
|
||||
&AIDebugWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -1524,7 +1508,7 @@ EventState AIDebugGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowAIDebugWindow(INVALID_COMPANY);
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -100,14 +100,6 @@ struct BuildAirToolbarWindow : Window {
|
|||
}
|
||||
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
this->OnClick(Point(), num, 1);
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
{
|
||||
switch (this->last_user_action) {
|
||||
|
@ -170,7 +162,8 @@ static WindowDesc _air_toolbar_desc(
|
|||
WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
|
||||
WC_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets)
|
||||
_nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets),
|
||||
&BuildAirToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -195,7 +188,7 @@ EventState AirportToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildAirToolbar();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
class BuildAirportWindow : public PickerWindowBase {
|
||||
|
|
|
@ -164,14 +164,6 @@ struct BuildDocksToolbarWindow : Window {
|
|||
this->last_clicked_widget = (DockToolbarWidgets)widget;
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
this->OnClick(Point(), num, 1);
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
{
|
||||
switch (this->last_clicked_widget) {
|
||||
|
@ -318,7 +310,8 @@ static WindowDesc _build_docks_toolbar_desc(
|
|||
WDP_ALIGN_TOOLBAR, "toolbar_water", 0, 0,
|
||||
WC_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets)
|
||||
_nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets),
|
||||
&BuildDocksToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -342,7 +335,7 @@ EventState DockToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildDocksToolbar();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -206,13 +206,6 @@ static const struct NWidgetPart _nested_main_window_widgets[] = {
|
|||
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1),
|
||||
};
|
||||
|
||||
static WindowDesc _main_window_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WC_MAIN_WINDOW, WC_NONE,
|
||||
0,
|
||||
_nested_main_window_widgets, lengthof(_nested_main_window_widgets)
|
||||
);
|
||||
|
||||
enum {
|
||||
GHK_QUIT,
|
||||
GHK_ABANDON,
|
||||
|
@ -245,7 +238,7 @@ struct MainWindow : Window
|
|||
static const uint LINKGRAPH_REFRESH_PERIOD = 0xff;
|
||||
static const uint LINKGRAPH_DELAY = 0xf;
|
||||
|
||||
MainWindow() : Window(&_main_window_desc)
|
||||
MainWindow(WindowDesc *desc) : Window(desc)
|
||||
{
|
||||
this->InitNested(0);
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
|
@ -287,10 +280,9 @@ struct MainWindow : Window
|
|||
}
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == GHK_QUIT) {
|
||||
if (hotkey == GHK_QUIT) {
|
||||
HandleExitGameRequest();
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
@ -301,7 +293,7 @@ struct MainWindow : Window
|
|||
* assertions that are hard to trigger and debug */
|
||||
if (HasModalProgress()) return ES_NOT_HANDLED;
|
||||
|
||||
switch (num) {
|
||||
switch (hotkey) {
|
||||
case GHK_ABANDON:
|
||||
/* No point returning from the main menu to itself */
|
||||
if (_game_mode == GM_MENU) return ES_HANDLED;
|
||||
|
@ -328,13 +320,13 @@ struct MainWindow : Window
|
|||
|
||||
if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
|
||||
|
||||
switch (num) {
|
||||
switch (hotkey) {
|
||||
case GHK_CENTER:
|
||||
case GHK_CENTER_ZOOM: {
|
||||
Point pt = GetTileBelowCursor();
|
||||
if (pt.x != -1) {
|
||||
bool instant = (num == GHK_CENTER_ZOOM && this->viewport->zoom != _settings_client.gui.zoom_min);
|
||||
if (num == GHK_CENTER_ZOOM) MaxZoomInOut(ZOOM_IN, this);
|
||||
bool instant = (hotkey == GHK_CENTER_ZOOM && this->viewport->zoom != _settings_client.gui.zoom_min);
|
||||
if (hotkey == GHK_CENTER_ZOOM) MaxZoomInOut(ZOOM_IN, this);
|
||||
ScrollMainWindowTo(pt.x, pt.y, -1, instant);
|
||||
}
|
||||
break;
|
||||
|
@ -368,7 +360,7 @@ struct MainWindow : Window
|
|||
case GHK_TOGGLE_TRANSPARENCY + 7:
|
||||
case GHK_TOGGLE_TRANSPARENCY + 8:
|
||||
/* Transparency toggle hot keys */
|
||||
ToggleTransparency((TransparencyOption)(num - GHK_TOGGLE_TRANSPARENCY));
|
||||
ToggleTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_TRANSPARENCY));
|
||||
MarkWholeScreenDirty();
|
||||
break;
|
||||
|
||||
|
@ -381,7 +373,7 @@ struct MainWindow : Window
|
|||
case GHK_TOGGLE_INVISIBILITY + 6:
|
||||
case GHK_TOGGLE_INVISIBILITY + 7:
|
||||
/* Invisibility toggle hot keys */
|
||||
ToggleInvisibilityWithTransparency((TransparencyOption)(num - GHK_TOGGLE_INVISIBILITY));
|
||||
ToggleInvisibilityWithTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_INVISIBILITY));
|
||||
MarkWholeScreenDirty();
|
||||
break;
|
||||
|
||||
|
@ -521,6 +513,14 @@ static Hotkey global_hotkeys[] = {
|
|||
};
|
||||
HotkeyList MainWindow::hotkeys("global", global_hotkeys);
|
||||
|
||||
static WindowDesc _main_window_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WC_MAIN_WINDOW, WC_NONE,
|
||||
0,
|
||||
_nested_main_window_widgets, lengthof(_nested_main_window_widgets),
|
||||
&MainWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
* Does the given keycode match one of the keycodes bound to 'quit game'?
|
||||
* @param keycode The keycode that was pressed by the user.
|
||||
|
@ -547,7 +547,7 @@ void SetupColoursAndInitialWindow()
|
|||
memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
|
||||
}
|
||||
|
||||
new MainWindow;
|
||||
new MainWindow(&_main_window_desc);
|
||||
|
||||
/* XXX: these are not done */
|
||||
switch (_game_mode) {
|
||||
|
|
|
@ -1436,11 +1436,11 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED;
|
||||
|
||||
switch (this->hotkeys.CheckMatch(keycode)) {
|
||||
switch (hotkey) {
|
||||
case OHK_SKIP: this->OrderClick_Skip(); break;
|
||||
case OHK_DELETE: this->OrderClick_Delete(); break;
|
||||
case OHK_GOTO: this->OrderClick_Goto(); break;
|
||||
|
@ -1619,7 +1619,8 @@ static WindowDesc _orders_train_desc(
|
|||
WDP_AUTO, "view_vehicle_orders_train", 384, 100,
|
||||
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_orders_train_widgets, lengthof(_nested_orders_train_widgets)
|
||||
_nested_orders_train_widgets, lengthof(_nested_orders_train_widgets),
|
||||
&OrdersWindow::hotkeys
|
||||
);
|
||||
|
||||
/** Nested widget definition for "your" orders (non-train). */
|
||||
|
@ -1691,7 +1692,8 @@ static WindowDesc _orders_desc(
|
|||
WDP_AUTO, "view_vehicle_orders", 384, 100,
|
||||
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_orders_widgets, lengthof(_nested_orders_widgets)
|
||||
_nested_orders_widgets, lengthof(_nested_orders_widgets),
|
||||
&OrdersWindow::hotkeys
|
||||
);
|
||||
|
||||
/** Nested widget definition for competitor orders. */
|
||||
|
@ -1717,7 +1719,8 @@ static WindowDesc _other_orders_desc(
|
|||
WDP_AUTO, "view_vehicle_orders_competitor", 384, 86,
|
||||
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_other_orders_widgets, lengthof(_nested_other_orders_widgets)
|
||||
_nested_other_orders_widgets, lengthof(_nested_other_orders_widgets),
|
||||
&OrdersWindow::hotkeys
|
||||
);
|
||||
|
||||
void ShowOrdersWindow(const Vehicle *v)
|
||||
|
|
|
@ -597,13 +597,10 @@ struct BuildRailToolbarWindow : Window {
|
|||
if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
this->OnClick(Point(), num, 1);
|
||||
MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
|
||||
return ES_HANDLED;
|
||||
return Window::OnHotkey(hotkey);
|
||||
}
|
||||
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
|
@ -824,7 +821,8 @@ static WindowDesc _build_rail_desc(
|
|||
WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0,
|
||||
WC_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_rail_widgets, lengthof(_nested_build_rail_widgets)
|
||||
_nested_build_rail_widgets, lengthof(_nested_build_rail_widgets),
|
||||
&BuildRailToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
|
||||
|
@ -855,7 +853,7 @@ EventState RailToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildRailToolbar(_last_built_railtype);
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
|
||||
|
|
|
@ -473,13 +473,10 @@ struct BuildRoadToolbarWindow : Window {
|
|||
if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == -1 || this->GetWidget<NWidgetBase>(num) == NULL) return ES_NOT_HANDLED;
|
||||
this->OnClick(Point(), num, 1);
|
||||
MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
|
||||
return ES_HANDLED;
|
||||
return Window::OnHotkey(hotkey);
|
||||
}
|
||||
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
|
@ -717,7 +714,8 @@ static WindowDesc _build_road_desc(
|
|||
WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
|
||||
WC_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_road_widgets, lengthof(_nested_build_road_widgets)
|
||||
_nested_build_road_widgets, lengthof(_nested_build_road_widgets),
|
||||
&BuildRoadToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
static const NWidgetPart _nested_build_tramway_widgets[] = {
|
||||
|
@ -756,7 +754,8 @@ static WindowDesc _build_tramway_desc(
|
|||
WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
|
||||
WC_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets)
|
||||
_nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets),
|
||||
&BuildRoadToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -782,7 +781,7 @@ EventState RoadToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildRoadToolbar(_last_built_roadtype);
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
static const NWidgetPart _nested_build_road_scen_widgets[] = {
|
||||
|
@ -816,7 +815,8 @@ static WindowDesc _build_road_scen_desc(
|
|||
WDP_AUTO, "toolbar_road_scen", 0, 0,
|
||||
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_road_scen_widgets, lengthof(_nested_build_road_scen_widgets)
|
||||
_nested_build_road_scen_widgets, lengthof(_nested_build_road_scen_widgets),
|
||||
&BuildRoadToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -835,7 +835,7 @@ EventState RoadToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildRoadScenToolbar();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
struct BuildRoadDepotWindow : public PickerWindowBase {
|
||||
|
|
|
@ -281,16 +281,19 @@ struct SignListWindow : Window, SignList {
|
|||
}
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
EventState state = ES_NOT_HANDLED;
|
||||
if (this->hotkeys.CheckMatch(keycode) == SLHK_FOCUS_FILTER_BOX) {
|
||||
switch (hotkey) {
|
||||
case SLHK_FOCUS_FILTER_BOX:
|
||||
this->SetFocusedWidget(WID_SIL_FILTER_TEXT);
|
||||
SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
|
||||
state = ES_HANDLED;
|
||||
break;
|
||||
|
||||
default:
|
||||
return ES_NOT_HANDLED;
|
||||
}
|
||||
|
||||
return state;
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
virtual void OnEditboxChanged(int widget)
|
||||
|
@ -374,7 +377,8 @@ static WindowDesc _sign_list_desc(
|
|||
WDP_AUTO, "list_signs", 358, 138,
|
||||
WC_SIGN_LIST, WC_NONE,
|
||||
0,
|
||||
_nested_sign_list_widgets, lengthof(_nested_sign_list_widgets)
|
||||
_nested_sign_list_widgets, lengthof(_nested_sign_list_widgets),
|
||||
&SignListWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -393,7 +397,7 @@ EventState SignListGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowSignList();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -219,14 +219,6 @@ struct TerraformToolbarWindow : Window {
|
|||
}
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
this->OnClick(Point(), num, 1);
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||
{
|
||||
switch (this->last_user_action) {
|
||||
|
@ -346,7 +338,8 @@ static WindowDesc _terraform_desc(
|
|||
WDP_MANUAL, "toolbar_landscape", 0, 0,
|
||||
WC_SCEN_LAND_GEN, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_terraform_widgets, lengthof(_nested_terraform_widgets)
|
||||
_nested_terraform_widgets, lengthof(_nested_terraform_widgets),
|
||||
&TerraformToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -384,7 +377,7 @@ EventState TerraformToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowTerraformToolbar(NULL);
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
||||
static byte _terraform_size = 1;
|
||||
|
@ -572,14 +565,6 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
|
|||
} while (--n);
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
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)
|
||||
{
|
||||
if (widget < WID_ETT_BUTTONS_START) return;
|
||||
|
@ -744,7 +729,8 @@ static WindowDesc _scen_edit_land_gen_desc(
|
|||
WDP_AUTO, "toolbar_landscape_scen", 0, 0,
|
||||
WC_SCEN_LAND_GEN, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_scen_edit_land_gen_widgets, lengthof(_nested_scen_edit_land_gen_widgets)
|
||||
_nested_scen_edit_land_gen_widgets, lengthof(_nested_scen_edit_land_gen_widgets),
|
||||
&ScenarioEditorLandscapeGenerationWindow::hotkeys
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -762,5 +748,5 @@ EventState TerraformToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode)
|
|||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowEditorTerraformToolbar();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
return w->OnKeyPress(key, keycode);
|
||||
return w->OnHotkey(num);
|
||||
}
|
||||
|
|
|
@ -1660,9 +1660,9 @@ struct MainToolbarWindow : Window {
|
|||
if (cbf != CBF_NONE) this->last_started_action = cbf;
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
switch (this->hotkeys.CheckMatch(keycode)) {
|
||||
switch (hotkey) {
|
||||
case MTHK_PAUSE: ToolbarPauseClick(this); break;
|
||||
case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
|
||||
case MTHK_SETTINGS: ShowGameOptions(); break;
|
||||
|
@ -1868,7 +1868,8 @@ static WindowDesc _toolb_normal_desc(
|
|||
WDP_MANUAL, NULL, 640, 22,
|
||||
WC_MAIN_TOOLBAR, WC_NONE,
|
||||
WDF_NO_FOCUS,
|
||||
_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets)
|
||||
_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
|
||||
&MainToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
|
||||
|
@ -2006,10 +2007,10 @@ struct ScenarioEditorToolbarWindow : Window {
|
|||
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
|
||||
}
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
CallBackFunction cbf = CBF_NONE;
|
||||
switch (this->hotkeys.CheckMatch(keycode)) {
|
||||
switch (hotkey) {
|
||||
case MTEHK_PAUSE: ToolbarPauseClick(this); break;
|
||||
case MTEHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
|
||||
case MTEHK_SETTINGS: ShowGameOptions(); break;
|
||||
|
@ -2179,7 +2180,8 @@ static WindowDesc _toolb_scen_desc(
|
|||
WDP_MANUAL, NULL, 640, 22,
|
||||
WC_MAIN_TOOLBAR, WC_NONE,
|
||||
WDF_NO_FOCUS,
|
||||
_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets)
|
||||
_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
|
||||
&ScenarioEditorToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
/** Allocate the toolbar. */
|
||||
|
|
Loading…
Reference in New Issue