From 48028fcfc4fc6ba3719ade041d63313da9ebb674 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 16 Jul 2015 16:42:46 +0100 Subject: [PATCH] fix #1631, fix #1632 --- data/language/english_uk.txt | 1 + src/interface/keyboard_shortcut.c | 21 +++++++++++++++++++++ src/interface/keyboard_shortcut.h | 1 + src/localisation/string_ids.h | 2 ++ src/windows/shortcut_key_change.c | 6 ++++-- src/windows/shortcut_keys.c | 25 ++++++------------------- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 2fdada2e4f..363baf0fee 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3800,3 +3800,4 @@ STR_5463 :Goal: Have fun! STR_5464 :General STR_5465 :Climate STR_5466 :Staff +STR_5467 :ALT + diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index 3241fff1ad..948dde6dd9 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -22,6 +22,7 @@ #include "../config.h" #include "../game.h" #include "../input.h" +#include "../localisation/localisation.h" #include "keyboard_shortcut.h" #include "viewport.h" #include "window.h" @@ -75,6 +76,26 @@ void keyboard_shortcut_handle_command(int shortcutIndex) shortcut_table[shortcutIndex](); } +void keyboard_shortcut_format_string(char *buffer, uint16 shortcutKey) +{ + char *formatBuffer[256]; + + *buffer = 0; + if (shortcutKey & 0x100) { + format_string(formatBuffer, STR_SHIFT_PLUS, NULL); + strcat(buffer, formatBuffer); + } + if (shortcutKey & 0x200) { + format_string(formatBuffer, STR_CTRL_PLUS, NULL); + strcat(buffer, formatBuffer); + } + if (shortcutKey & 0x400) { + format_string(formatBuffer, STR_ALT_PLUS, NULL); + strcat(buffer, formatBuffer); + } + strcat(buffer, SDL_GetScancodeName(shortcutKey & 0xFF)); +} + #pragma region Shortcut Commands static void toggle_view_flag(int viewportFlag) diff --git a/src/interface/keyboard_shortcut.h b/src/interface/keyboard_shortcut.h index e735a85592..d9e4e20535 100644 --- a/src/interface/keyboard_shortcut.h +++ b/src/interface/keyboard_shortcut.h @@ -24,5 +24,6 @@ void keyboard_shortcut_set(int key); void keyboard_shortcut_handle(int key); void keyboard_shortcut_handle_command(int shortcutIndex); +void keyboard_shortcut_format_string(char *buffer, uint16 shortcutKey); #endif \ No newline at end of file diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index b3041369f3..8f6afbe503 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -1795,6 +1795,8 @@ enum { STR_CHEAT_CLIMATE_GROUP = 5465, STR_CHEAT_STAFF_GROUP = 5466, + STR_ALT_PLUS = 5467, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/windows/shortcut_key_change.c b/src/windows/shortcut_key_change.c index bb9209490e..912b1c8309 100644 --- a/src/windows/shortcut_key_change.c +++ b/src/windows/shortcut_key_change.c @@ -25,6 +25,8 @@ #include "../localisation/localisation.h" #include "../interface/themes.h" +extern const rct_string_id ShortcutStringIds[]; + #define WW 250 #define WH 60 @@ -119,6 +121,6 @@ static void window_shortcut_change_paint(rct_window *w, rct_drawpixelinfo *dpi) int x = w->x + 125; int y = w->y + 30; - RCT2_GLOBAL(0x13CE952, uint16) = 2493 + RCT2_GLOBAL(0x9DE511, uint8); - gfx_draw_string_centred_wrapped(dpi, (void*)0x13CE952, x, y, 242, 2785, RCT2_GLOBAL(0x9DEB8D, uint8)); + RCT2_GLOBAL(0x13CE952, uint16) = ShortcutStringIds[RCT2_GLOBAL(0x009DE511, uint8)]; + gfx_draw_string_centred_wrapped(dpi, (void*)0x013CE952, x, y, 242, 2785, RCT2_GLOBAL(0x9DEB8D, uint8)); } \ No newline at end of file diff --git a/src/windows/shortcut_keys.c b/src/windows/shortcut_keys.c index 6f17099807..bbd60b47fe 100644 --- a/src/windows/shortcut_keys.c +++ b/src/windows/shortcut_keys.c @@ -24,6 +24,7 @@ #include "../interface/widget.h" #include "../localisation/localisation.h" #include "../platform/platform.h" +#include "../interface/keyboard_shortcut.h" #include "../interface/themes.h" #define WW 340 @@ -247,27 +248,13 @@ static void window_shortcut_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, i gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x2000031); } - RCT2_GLOBAL(0x13CE954, uint16) = ShortcutStringIds[i]; - RCT2_GLOBAL(0x13CE956, uint16) = 0; - RCT2_GLOBAL(0x13CE958, uint16) = 0; - - uint16 shortcut_entry = gShortcutKeys[i]; - if (shortcut_entry != 0xFFFF) { - rct_string_id templateStringId = 2525; - const char *scanCodeName = SDL_GetScancodeName(shortcut_entry & 0xFF); - char *templateString = (char*)language_get_string(templateStringId); - strcpy(templateString, scanCodeName); - - RCT2_GLOBAL(0x13CE958, uint16) = templateStringId; - - // Display the modifer - if (shortcut_entry & 0x100) - RCT2_GLOBAL(0x13CE956, uint16) = STR_SHIFT_PLUS; - else if (shortcut_entry & 0x200) - RCT2_GLOBAL(0x13CE956, uint16) = STR_CTRL_PLUS; - } + rct_string_id templateStringId = 2525; + char *templateString = (char*)language_get_string(templateStringId); + keyboard_shortcut_format_string(templateString, gShortcutKeys[i]); RCT2_GLOBAL(0x13CE952, uint16) = STR_SHORTCUT_ENTRY_FORMAT; + RCT2_GLOBAL(0x13CE954, uint16) = ShortcutStringIds[i]; + RCT2_GLOBAL(0x13CE956, uint16) = templateStringId; gfx_draw_string_left(dpi, format, (void*)0x13CE952, 0, 0, y - 1); } } \ No newline at end of file