summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-04 11:28:16 +0000
committeryexo <yexo@openttd.org>2010-07-04 11:28:16 +0000
commit063909962ae557203a799bcc6c30f51dec4cc592 (patch)
tree08e11746c87957a81d333546b277115ad0d2d421
parent19f86951d9d463fdba12d3ccaa3438d61f7275e1 (diff)
downloadopenttd-063909962ae557203a799bcc6c30f51dec4cc592.tar.xz
(svn r20074) -Fix (r20065): highscore window should use the same hotkey for quit as the toolbar
-rw-r--r--src/highscore_gui.cpp11
-rw-r--r--src/hotkeys.h2
-rw-r--r--src/main_gui.cpp11
3 files changed, 19 insertions, 5 deletions
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp
index 94486a4f2..004648b56 100644
--- a/src/highscore_gui.cpp
+++ b/src/highscore_gui.cpp
@@ -22,6 +22,7 @@
#include "company_base.h"
#include "strings_func.h"
#include "openttd.h"
+#include "hotkeys.h"
enum HighscoreWidgets {
HSW_BACKGROUND,
@@ -66,6 +67,11 @@ struct EndGameHighScoreBaseWindow : Window {
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
+ /* All keys are 'handled' by this window but we want to make
+ * sure that 'quit' still works correctly. Not handling the
+ * quit key is enough so the main toolbar can handle it. */
+ if (IsQuitKey(keycode)) return ES_NOT_HANDLED;
+
switch (keycode) {
/* Keys for telling we want to go on */
case WKC_RETURN:
@@ -74,11 +80,6 @@ struct EndGameHighScoreBaseWindow : Window {
delete this;
return ES_HANDLED;
- /* Allow CTRL-Q to work like ALT-F4 in all cases */
- case 'Q' | WKC_CTRL:
- case 'Q' | WKC_META:
- return ES_NOT_HANDLED;
-
default:
/* We want to handle all keys; we don't want windows in
* the background to open. Especially the ones that do
diff --git a/src/hotkeys.h b/src/hotkeys.h
index 240894b8d..79740f3d4 100644
--- a/src/hotkeys.h
+++ b/src/hotkeys.h
@@ -124,6 +124,8 @@ int CheckHotkeyMatch(Hotkey<T> *list, uint16 keycode, T *w, bool global_only = f
return -1;
}
+bool IsQuitKey(uint16 keycode);
+
void LoadHotkeysFromConfig();
void SaveHotkeysToConfig();
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index b5c770530..80ea150f8 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -467,6 +467,17 @@ Hotkey<MainWindow> MainWindow::global_hotkeys[] = {
};
Hotkey<MainWindow> *_global_hotkeys = MainWindow::global_hotkeys;
+/**
+ * Does the given keycode match one of the keycodes bound to 'quit game'?
+ * @param keycode The keycode that was pressed by the user.
+ * @return True iff the keycode matches one of the hotkeys for 'quit'.
+ */
+bool IsQuitKey(uint16 keycode)
+{
+ int num = CheckHotkeyMatch<MainWindow>(_global_hotkeys, keycode, NULL);
+ return num == GHK_QUIT;
+}
+
void ShowSelectGameWindow();