From 93d49e314ed181d2bb5611fcb56bfda7b1be5dce Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 20 Aug 2015 12:13:08 +0200 Subject: [PATCH] Fix file menu for editor, restore menu order, add shortcut for quick saving --- data/language/english_uk.txt | 1 + src/config.c | 1 + src/config.h | 1 + src/interface/keyboard_shortcut.c | 16 ++++++++++++++++ src/localisation/string_ids.h | 4 +++- src/windows/shortcut_keys.c | 3 ++- src/windows/top_toolbar.c | 32 +++++++++++++++---------------- 7 files changed, 40 insertions(+), 18 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 01ac55132a..180217eb18 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -3851,3 +3851,4 @@ STR_5509 :{SMALLFONT}{BLACK}Allows loading scenarios and saves that have an i STR_5510 :Default sound device STR_5511 :(UNKNOWN) STR_5512 :Save Game As +STR_5513 :(Quick) save game diff --git a/src/config.c b/src/config.c index 304bb22e98..0a95bb5679 100644 --- a/src/config.c +++ b/src/config.c @@ -974,6 +974,7 @@ static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = { SDL_SCANCODE_DOWN, // SHORTCUT_SCROLL_MAP_DOWN SDL_SCANCODE_RIGHT, // SHORTCUT_SCROLL_MAP_RIGHT SDL_SCANCODE_C, // SHORTCUT_OPEN_CHAT_WINDOW + CTRL | SDL_SCANCODE_F10, // SHORTCUT_QUICK_SAVE_GAME }; #define SHORTCUT_FILE_VERSION 1 diff --git a/src/config.h b/src/config.h index b472fb7e3e..8cbe69fd83 100644 --- a/src/config.h +++ b/src/config.h @@ -77,6 +77,7 @@ enum { SHORTCUT_SCROLL_MAP_DOWN, SHORTCUT_SCROLL_MAP_RIGHT, SHORTCUT_OPEN_CHAT_WINDOW, + SHORTCUT_QUICK_SAVE_GAME, SHORTCUT_COUNT }; diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index f45998020c..0d5e71df6b 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -500,6 +500,21 @@ static void shortcut_open_chat_window() chat_toggle(); } +static void shortcut_quick_save_game() +{ + log_error("quicksave"); + // Do a quick save in playing mode and a regular save in Scenario Editor mode. In other cases, don't do anything. + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) == SCREEN_FLAGS_PLAYING) { + log_error("quicksave2"); + tool_cancel(); + save_game(); + } + else if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) { + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; + window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, s6Info->name); + } +} + static const shortcut_action shortcut_table[SHORTCUT_COUNT] = { shortcut_close_top_most_window, shortcut_close_all_floating_windows, @@ -545,6 +560,7 @@ static const shortcut_action shortcut_table[SHORTCUT_COUNT] = { NULL, NULL, shortcut_open_chat_window, + shortcut_quick_save_game, }; #pragma endregion diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 40c7dead82..80ec47ade7 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -114,7 +114,6 @@ enum { STR_CANT_RAISE_LAND_HERE = 880, STR_LOAD_GAME = 882, - STR_SAVE_GAME_AS = 5512, STR_SAVE_GAME = 883, STR_LOAD_LANDSCAPE = 884, STR_SAVE_LANDSCAPE = 885, @@ -2059,6 +2058,9 @@ enum { STR_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM = 5508, STR_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM_TIP = 5509, + STR_SAVE_GAME_AS = 5512, + STR_SHORTCUT_QUICK_SAVE_GAME = 5513, + // 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_keys.c b/src/windows/shortcut_keys.c index 0499330cea..02d2cd295d 100644 --- a/src/windows/shortcut_keys.c +++ b/src/windows/shortcut_keys.c @@ -131,6 +131,7 @@ const rct_string_id ShortcutStringIds[] = { STR_SHORTCUT_SCROLL_MAP_DOWN, STR_SHORTCUT_SCROLL_MAP_RIGHT, STR_SEND_MESSAGE, + STR_SHORTCUT_QUICK_SAVE_GAME, }; /** @@ -262,4 +263,4 @@ static void window_shortcut_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, i RCT2_GLOBAL(0x13CE956, uint16) = templateStringId; gfx_draw_string_left(dpi, format, (void*)0x13CE952, 0, 0, y - 1); } -} \ No newline at end of file +} diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index b7035a4a73..bf0127ced1 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -72,9 +72,9 @@ enum { }; typedef enum { - DDIDX_SAVE_GAME = 0, - DDIDX_SAVE_GAME_AS = 1, - DDIDX_LOAD_GAME = 2, + DDIDX_LOAD_GAME = 0, + DDIDX_SAVE_GAME = 1, + DDIDX_SAVE_GAME_AS = 2, // separator DDIDX_ABOUT = 4, DDIDX_OPTIONS = 5, @@ -378,9 +378,9 @@ static void window_top_toolbar_mousedown(int widgetIndex, rct_window*w, rct_widg gDropdownItemsFormat[9] = STR_EXIT_OPENRCT2; numItems = 10; } else { - gDropdownItemsFormat[0] = STR_SAVE_GAME; - gDropdownItemsFormat[1] = STR_SAVE_GAME_AS; - gDropdownItemsFormat[2] = STR_LOAD_GAME; + gDropdownItemsFormat[0] = STR_LOAD_GAME; + gDropdownItemsFormat[1] = STR_SAVE_GAME; + gDropdownItemsFormat[2] = STR_SAVE_GAME_AS; gDropdownItemsFormat[3] = 0; gDropdownItemsFormat[4] = STR_ABOUT; gDropdownItemsFormat[5] = STR_OPTIONS; @@ -487,6 +487,12 @@ static void window_top_toolbar_dropdown(rct_window *w, int widgetIndex, int drop { switch (widgetIndex) { case WIDX_FILE_MENU: + + // Quicksave is only available in the normal game. Skip one position to avoid incorrect mappings in the menus of the other modes. + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_SCENARIO_EDITOR) && dropdownIndex > DDIDX_LOAD_GAME) + dropdownIndex += 1; + + // Track designer and track designs manager start with About, not Load/save if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) dropdownIndex += DDIDX_ABOUT; @@ -494,6 +500,10 @@ static void window_top_toolbar_dropdown(rct_window *w, int widgetIndex, int drop case DDIDX_LOAD_GAME: game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 0, 0); break; + case DDIDX_SAVE_GAME: + tool_cancel(); + save_game(); + break; case DDIDX_SAVE_GAME_AS: if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) { rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; @@ -504,16 +514,6 @@ static void window_top_toolbar_dropdown(rct_window *w, int widgetIndex, int drop save_game_as(); } break; - case DDIDX_SAVE_GAME: - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) { - rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; - window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, s6Info->name); - } - else { - tool_cancel(); - save_game(); - } - break; case DDIDX_ABOUT: window_about_open(); break;