From 2dc315f2285a0b335cbe8d00e100cd164bdd34e5 Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 5 Sep 2016 21:04:22 +0100 Subject: [PATCH] Integrate gKeyboardShortcutChangeId --- src/interface/keyboard_shortcut.c | 4 +++- src/interface/keyboard_shortcut.h | 3 +++ src/windows/shortcut_key_change.c | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index ca2f053930..b6c9091e54 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -31,6 +31,8 @@ #include "../platform/platform.h" #include "../ride/track_paint.h" +uint8 gKeyboardShortcutChangeId; + typedef void (*shortcut_action)(); static const shortcut_action shortcut_table[SHORTCUT_COUNT]; @@ -52,7 +54,7 @@ void keyboard_shortcut_set(int key) } // Map shortcut to this key - gShortcutKeys[RCT2_GLOBAL(0x009DE511, uint8)] = key; + gShortcutKeys[gKeyboardShortcutChangeId] = key; window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST); config_shortcut_keys_save(); diff --git a/src/interface/keyboard_shortcut.h b/src/interface/keyboard_shortcut.h index 5de37cfeff..67dbfefddf 100644 --- a/src/interface/keyboard_shortcut.h +++ b/src/interface/keyboard_shortcut.h @@ -19,6 +19,9 @@ #define SHORTCUT_UNDEFINED 0xFFFF +/** The current shortcut being changed. */ +extern uint8 gKeyboardShortcutChangeId; + void keyboard_shortcut_set(int key); void keyboard_shortcut_handle(int key); void keyboard_shortcut_handle_command(int shortcutIndex); diff --git a/src/windows/shortcut_key_change.c b/src/windows/shortcut_key_change.c index 6f675f1c94..2306641641 100644 --- a/src/windows/shortcut_key_change.c +++ b/src/windows/shortcut_key_change.c @@ -16,10 +16,11 @@ #include "../addresses.h" #include "../config.h" +#include "../interface/keyboard_shortcut.h" +#include "../interface/themes.h" #include "../interface/window.h" #include "../interface/widget.h" #include "../localisation/localisation.h" -#include "../interface/themes.h" extern const rct_string_id ShortcutStringIds[]; @@ -80,7 +81,7 @@ void window_shortcut_change_open(int selected_key){ // Move this to window_shortcut_change_open window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); // Save the item we are selecting for new window - RCT2_GLOBAL(0x9DE511, uint8) = selected_key; + gKeyboardShortcutChangeId = selected_key; rct_window* w = window_create_auto_pos(WW, WH, &window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0); w->widgets = window_shortcut_change_widgets; @@ -117,6 +118,6 @@ static void window_shortcut_change_paint(rct_window *w, rct_drawpixelinfo *dpi) int x = w->x + 125; int y = w->y + 30; - set_format_arg(0, rct_string_id, ShortcutStringIds[RCT2_GLOBAL(0x009DE511, uint8)]); + set_format_arg(0, rct_string_id, ShortcutStringIds[gKeyboardShortcutChangeId]); gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, 242, STR_SHORTCUT_CHANGE_PROMPT, RCT2_GLOBAL(0x9DEB8D, uint8)); }