(svn r25410) -Codechange: Put all hotkeys of a window into a static HotkeyList member.
This commit is contained in:
@@ -221,7 +221,7 @@ struct TerraformToolbarWindow : Window {
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = CheckHotkeyMatch(terraform_hotkeys, keycode);
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
this->OnClick(Point(), num, 1);
|
||||
return ES_HANDLED;
|
||||
@@ -295,10 +295,10 @@ struct TerraformToolbarWindow : Window {
|
||||
this->RaiseButtons();
|
||||
}
|
||||
|
||||
static Hotkey terraform_hotkeys[];
|
||||
static HotkeyList hotkeys;
|
||||
};
|
||||
|
||||
Hotkey TerraformToolbarWindow::terraform_hotkeys[] = {
|
||||
static Hotkey terraform_hotkeys[] = {
|
||||
Hotkey('Q' | WKC_GLOBAL_HOTKEY, "lower", WID_TT_LOWER_LAND),
|
||||
Hotkey('W' | WKC_GLOBAL_HOTKEY, "raise", WID_TT_RAISE_LAND),
|
||||
Hotkey('E' | WKC_GLOBAL_HOTKEY, "level", WID_TT_LEVEL_LAND),
|
||||
@@ -309,7 +309,7 @@ Hotkey TerraformToolbarWindow::terraform_hotkeys[] = {
|
||||
Hotkey('P', "placeobject", WID_TT_PLACE_OBJECT),
|
||||
HOTKEY_LIST_END
|
||||
};
|
||||
Hotkey *_terraform_hotkeys = TerraformToolbarWindow::terraform_hotkeys;
|
||||
HotkeyList TerraformToolbarWindow::hotkeys("terraform", terraform_hotkeys);
|
||||
|
||||
static const NWidgetPart _nested_terraform_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
@@ -380,7 +380,7 @@ Window *ShowTerraformToolbar(Window *link)
|
||||
|
||||
EventState TerraformToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = CheckHotkeyMatch(_terraform_hotkeys, keycode, true);
|
||||
int num = TerraformToolbarWindow::hotkeys.CheckMatch(keycode, true);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowTerraformToolbar(NULL);
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
@@ -574,7 +574,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
|
||||
|
||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = CheckHotkeyMatch(terraform_editor_hotkeys, keycode);
|
||||
int num = this->hotkeys.CheckMatch(keycode);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
this->OnClick(Point(), num, 1);
|
||||
return ES_HANDLED;
|
||||
@@ -724,10 +724,10 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
|
||||
DeleteWindowById(WC_BUILD_OBJECT, 0);
|
||||
}
|
||||
|
||||
static Hotkey terraform_editor_hotkeys[];
|
||||
static HotkeyList hotkeys;
|
||||
};
|
||||
|
||||
Hotkey ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys[] = {
|
||||
static Hotkey terraform_editor_hotkeys[] = {
|
||||
Hotkey('D' | WKC_GLOBAL_HOTKEY, "dynamite", WID_ETT_DEMOLISH),
|
||||
Hotkey('Q' | WKC_GLOBAL_HOTKEY, "lower", WID_ETT_LOWER_LAND),
|
||||
Hotkey('W' | WKC_GLOBAL_HOTKEY, "raise", WID_ETT_RAISE_LAND),
|
||||
@@ -738,7 +738,7 @@ Hotkey ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys[] = {
|
||||
HOTKEY_LIST_END
|
||||
};
|
||||
|
||||
Hotkey *_terraform_editor_hotkeys = ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys;
|
||||
HotkeyList ScenarioEditorLandscapeGenerationWindow::hotkeys("terraform_editor", terraform_editor_hotkeys);
|
||||
|
||||
static WindowDesc _scen_edit_land_gen_desc(
|
||||
WDP_AUTO, "toolbar_landscape_scen", 0, 0,
|
||||
@@ -758,7 +758,7 @@ Window *ShowEditorTerraformToolbar()
|
||||
|
||||
EventState TerraformToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode)
|
||||
{
|
||||
int num = CheckHotkeyMatch(_terraform_editor_hotkeys, keycode, true);
|
||||
int num = ScenarioEditorLandscapeGenerationWindow::hotkeys.CheckMatch(keycode, true);
|
||||
if (num == -1) return ES_NOT_HANDLED;
|
||||
Window *w = ShowEditorTerraformToolbar();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
|
Reference in New Issue
Block a user