From 1e6c9ddfd85d59b4df8b754e02d078cf71be9698 Mon Sep 17 00:00:00 2001 From: "Miso Zmiric (Mike Squinter)" Date: Mon, 24 Nov 2014 16:38:19 +0000 Subject: [PATCH] map cheat window to shortcut, hide fast forward button, fix toolbar autolayout --- src/config.c | 3 +- src/config.h | 1 + src/input.c | 2 + src/interface/keyboard_shortcut.c | 16 +++++++- src/windows/game_top_toolbar.c | 62 +++++++++++++++++++++++-------- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/src/config.c b/src/config.c index 3f3710a8a1..53f11dac90 100644 --- a/src/config.c +++ b/src/config.c @@ -69,7 +69,8 @@ static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = { // New SDL_SCANCODE_MINUS, // SHORTCUT_REDUCE_GAME_SPEED, - SDL_SCANCODE_EQUALS // SHORTCUT_INCREASE_GAME_SPEED, + SDL_SCANCODE_EQUALS, // SHORTCUT_INCREASE_GAME_SPEED, + 0x0200 | 0x0400 | SDL_SCANCODE_C // SHORTCUT_OPEN_CHEAT_WINDOW, }; general_configuration_t gGeneral_config; diff --git a/src/config.h b/src/config.h index 28f6ea9e13..3098031780 100644 --- a/src/config.h +++ b/src/config.h @@ -69,6 +69,7 @@ enum { // New SHORTCUT_REDUCE_GAME_SPEED, SHORTCUT_INCREASE_GAME_SPEED, + SHORTCUT_OPEN_CHEAT_WINDOW, SHORTCUT_COUNT }; diff --git a/src/input.c b/src/input.c index 4600842d16..34bea3b9ca 100644 --- a/src/input.c +++ b/src/input.c @@ -1106,6 +1106,8 @@ void game_handle_keyboard_input() RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 1; if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 2; + if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT]) + RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 4; if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) game_handle_key_scroll(); } diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index 4cdf414c51..0ee2609432 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -407,6 +407,19 @@ static void shortcut_increase_game_speed() game_increase_game_speed(); } +static void shortcut_open_cheat_window() +{ + rct_window *window; + + // Check if window is already open + window = window_find_by_class(WC_CHEATS); + if (window != NULL) { + window_close(window); + return; + } + window_cheats_open(); +} + static const shortcut_action shortcut_table[SHORTCUT_COUNT] = { shortcut_close_top_most_window, shortcut_close_all_floating_windows, @@ -441,7 +454,8 @@ static const shortcut_action shortcut_table[SHORTCUT_COUNT] = { shortcut_show_map, shortcut_screenshot, shortcut_reduce_game_speed, - shortcut_increase_game_speed + shortcut_increase_game_speed, + shortcut_open_cheat_window }; #pragma endregion diff --git a/src/windows/game_top_toolbar.c b/src/windows/game_top_toolbar.c index b6a6463867..4b2c2ccbe7 100644 --- a/src/windows/game_top_toolbar.c +++ b/src/windows/game_top_toolbar.c @@ -52,7 +52,7 @@ enum { WIDX_GUESTS, WIDX_CLEAR_SCENERY, - WIDX_FASTFORWARD, + //WIDX_FASTFORWARD, WIDX_RESEARCH }; @@ -85,7 +85,7 @@ static rct_widget window_game_top_toolbar_widgets[] = { { WWT_TRNBTN, 3, 0x0230, 0x024D, 0, 27, 0x20000000 | SPR_TOOLBAR_GUESTS, STR_GUESTS_TIP }, // Guests { WWT_TRNBTN, 2, 0x0230, 0x024D, 0, 27, 0x20000000 | SPR_TOOLBAR_CLEAR_SCENERY, STR_CLEAR_SCENERY_TIP }, // Clear scenery - { WWT_TRNBTN, 0, 0x001E, 0x003B, 0, 27, 0x20000000 | 0x15F9, STR_NONE }, // Fast forward + //{ WWT_TRNBTN, 0, 0x001E, 0x003B, 0, 27, 0x20000000 | 0x15F9, STR_NONE }, // Fast forward { WWT_TRNBTN, 3, 0x001E, 0x003B, 0, 27, 0x20000000 | 0x15F9, 2275 }, // Research { WIDGETS_END }, }; @@ -166,7 +166,7 @@ void window_game_top_toolbar_open() (1 << WIDX_STAFF) | (1 << WIDX_GUESTS) | (1 << WIDX_CLEAR_SCENERY) | - (1ULL << WIDX_FASTFORWARD) | + //(1ULL << WIDX_FASTFORWARD) | (1ULL << WIDX_RESEARCH); window_init_scroll_widgets(window); @@ -193,14 +193,14 @@ static void window_game_top_toolbar_mouseup() // Not sure where this was done in the original code w->pressed_widgets ^= (1 << WIDX_PAUSE); break; - case WIDX_FASTFORWARD: - // This is an excellent place to add in debugging statements and - // print routines, that will be triggered when you press the - // button in the game. Use "git update-index --skip-worktree - // src/window_game_top_toolbar" to avoid committing these changes to - // version control. - window_cheats_open(); - break; + // case WIDX_FASTFORWARD: + // // This is an excellent place to add in debugging statements and + // // print routines, that will be triggered when you press the + // // button in the game. Use "git update-index --skip-worktree + // // src/window_game_top_toolbar" to avoid committing these changes to + // // version control. + // window_cheats_open(); + // break; case WIDX_ZOOM_OUT: if ((mainWindow = window_get_main()) != NULL) @@ -411,6 +411,38 @@ static void window_game_top_toolbar_invalidate() window_game_top_toolbar_widgets[WIDX_CLEAR_SCENERY].right = x; x -= 29; window_game_top_toolbar_widgets[WIDX_CLEAR_SCENERY].left = x; + x = 0; + window_game_top_toolbar_widgets[WIDX_PAUSE].left = x; + x += 29; + window_game_top_toolbar_widgets[WIDX_PAUSE].right = x; + x += 1; + // window_game_top_toolbar_widgets[WIDX_FASTFORWARD].left = x; + // x += 29; + // window_game_top_toolbar_widgets[WIDX_FASTFORWARD].right = x; + x += 1; + window_game_top_toolbar_widgets[WIDX_FILE_MENU].left = x; + x += 29; + window_game_top_toolbar_widgets[WIDX_FILE_MENU].right = x; + x += 11; + window_game_top_toolbar_widgets[WIDX_ZOOM_OUT].left = x; + x += 29; + window_game_top_toolbar_widgets[WIDX_ZOOM_OUT].right = x; + x += 1; + window_game_top_toolbar_widgets[WIDX_ZOOM_IN].left = x; + x += 29; + window_game_top_toolbar_widgets[WIDX_ZOOM_IN].right = x; + x += 1; + window_game_top_toolbar_widgets[WIDX_ROTATE].left = x; + x += 29; + window_game_top_toolbar_widgets[WIDX_ROTATE].right = x; + x += 1; + window_game_top_toolbar_widgets[WIDX_VIEW_MENU].left = x; + x += 29; + window_game_top_toolbar_widgets[WIDX_VIEW_MENU].right = x; + x += 1; + window_game_top_toolbar_widgets[WIDX_MAP].left = x; + x += 29; + window_game_top_toolbar_widgets[WIDX_MAP].right = x; // Footpath button pressed down if (window_find_by_class(WC_FOOTPATH) == NULL) @@ -419,10 +451,10 @@ static void window_game_top_toolbar_invalidate() w->pressed_widgets |= (1 << WIDX_PATH); // Fast forward button pressed down - if (0) - w->pressed_widgets |= (1 << WIDX_FASTFORWARD); - else - w->pressed_widgets &= ~(1 << WIDX_FASTFORWARD); + // if (0) + // w->pressed_widgets |= (1 << WIDX_FASTFORWARD); + // else + // w->pressed_widgets &= ~(1 << WIDX_FASTFORWARD); // Zoomed out/in disable. Not sure where this code is in the original. if (window_get_main()->viewport->zoom == 0){