summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-06-15 15:31:22 +0000
committerfrosch <frosch@openttd.org>2013-06-15 15:31:22 +0000
commitfef30983e643943df24a7090a7175cfa66f3ba15 (patch)
tree5129b4c530168788d3a4ebec180d3c910c37b942 /src/ai
parentee4e68bd5e4882397bc023040a2977047d22ccb7 (diff)
downloadopenttd-fef30983e643943df24a7090a7175cfa66f3ba15.tar.xz
(svn r25414) -Codechange: Move handling of global hotkeys to HotkeyList.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_gui.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index d172780a8..01803d767 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1402,6 +1402,19 @@ NWidgetBase *MakeCompanyButtonRowsAIDebug(int *biggest_index)
return MakeCompanyButtonRows(biggest_index, WID_AID_COMPANY_BUTTON_START, WID_AID_COMPANY_BUTTON_END, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP);
}
+/**
+ * Handler for global hotkeys of the AIDebugWindow.
+ * @param hotkey Hotkey
+ * @return ES_HANDLED if hotkey was accepted.
+ */
+static EventState AIDebugGlobalHotkeys(int hotkey)
+{
+ if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
+ Window *w = ShowAIDebugWindow(INVALID_COMPANY);
+ if (w == NULL) return ES_NOT_HANDLED;
+ return w->OnHotkey(hotkey);
+}
+
static Hotkey aidebug_hotkeys[] = {
Hotkey('1', "company_1", WID_AID_COMPANY_BUTTON_START),
Hotkey('2', "company_2", WID_AID_COMPANY_BUTTON_START + 1),
@@ -1427,7 +1440,7 @@ static Hotkey aidebug_hotkeys[] = {
Hotkey(WKC_RETURN, "continue", WID_AID_CONTINUE_BTN),
HOTKEY_LIST_END
};
-HotkeyList AIDebugWindow::hotkeys("aidebug", aidebug_hotkeys);
+HotkeyList AIDebugWindow::hotkeys("aidebug", aidebug_hotkeys, AIDebugGlobalHotkeys);
/** Widgets for the AI debug window. */
static const NWidgetPart _nested_ai_debug_widgets[] = {
@@ -1502,18 +1515,6 @@ Window *ShowAIDebugWindow(CompanyID show_company)
}
/**
- * Handler for global AI debug window hotkeys.
- */
-EventState AIDebugGlobalHotkeys(uint16 key, uint16 keycode)
-{
- int num = AIDebugWindow::hotkeys.CheckMatch(keycode, true);
- if (num == -1) return ES_NOT_HANDLED;
- Window *w = ShowAIDebugWindow(INVALID_COMPANY);
- if (w == NULL) return ES_NOT_HANDLED;
- return w->OnHotkey(num);
-}
-
-/**
* Reset the AI windows to their initial state.
*/
void InitializeAIGui()