summaryrefslogtreecommitdiff
path: root/src/hotkeys.h
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-03 20:14:56 +0000
committeryexo <yexo@openttd.org>2010-07-03 20:14:56 +0000
commit4012f85eec50f9e0c7af17d4ba13852a87a02590 (patch)
treeeb39cb20475eee3a419b3fe024f96facb73902ad /src/hotkeys.h
parent4f51623d122faa068e30224a9351ecb290a70029 (diff)
downloadopenttd-4012f85eec50f9e0c7af17d4ba13852a87a02590.tar.xz
(svn r20067) -Add: special modifier (GLOBAL) to mark hotkeys as global hotkeys
Diffstat (limited to 'src/hotkeys.h')
-rw-r--r--src/hotkeys.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/hotkeys.h b/src/hotkeys.h
index b8b1e0984..e63cc573f 100644
--- a/src/hotkeys.h
+++ b/src/hotkeys.h
@@ -52,7 +52,7 @@ struct Hotkey {
} else {
this->callback = new CallbackWrapper(callback);
}
- if (default_keycode != 0) *this->keycodes.Append() = default_keycode;
+ if (default_keycode != 0) this->AddKeycode(default_keycode);
}
/**
@@ -74,7 +74,7 @@ struct Hotkey {
const uint16 *keycode = default_keycodes;
while (*keycode != 0) {
- this->keycodes.Include(*keycode);
+ this->AddKeycode(*keycode);
keycode++;
}
}
@@ -107,13 +107,14 @@ struct Hotkey {
* @param list The list with hotkeys to check
* @param keycode The keycode that was pressed
* @param w The window-pointer to give to the callback function (if any).
+ * @param global_only Limit the search to hotkeys defined as 'global'.
* @return The number of the matching hotkey or -1.
*/
template<class T>
-int CheckHotkeyMatch(Hotkey<T> *list, uint16 keycode, T *w)
+int CheckHotkeyMatch(Hotkey<T> *list, uint16 keycode, T *w, bool global_only = false)
{
while (list->num != -1) {
- if (list->keycodes.Contains(keycode)) {
+ if (list->keycodes.Contains(keycode | WKC_GLOBAL_HOTKEY) || (!global_only && list->keycodes.Contains(keycode))) {
if (list->callback != NULL) (w->*(list->callback->callback))(-1);
return list->num;
}