diff --git a/src/input.c b/src/input.c index 96a0f19bfd..091f1b53c2 100644 --- a/src/input.c +++ b/src/input.c @@ -1453,9 +1453,7 @@ void title_handle_keyboard_input() window_text_input_key(w, key); } - if (key == gShortcutKeys[SHORTCUT_SCREENSHOT]) { - keyboard_shortcut_handle_command(SHORTCUT_SCREENSHOT); - } + keyboard_shortcut_handle(key); } } } diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index acb482889f..28b992f9c6 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -14,21 +14,22 @@ *****************************************************************************/ #pragma endregion +#include "../audio/audio.h" #include "../config.h" #include "../game.h" #include "../editor.h" +#include "../input.h" #include "../interface/chat.h" #include "../interface/screenshot.h" -#include "../input.h" #include "../localisation/localisation.h" #include "../network/network.h" -#include "keyboard_shortcut.h" -#include "viewport.h" -#include "window.h" -#include "widget.h" -#include "../audio/audio.h" #include "../platform/platform.h" #include "../ride/track_paint.h" +#include "../title.h" +#include "keyboard_shortcut.h" +#include "viewport.h" +#include "widget.h" +#include "window.h" uint8 gKeyboardShortcutChangeId; @@ -59,18 +60,25 @@ void keyboard_shortcut_set(int key) config_shortcut_keys_save(); } +static int keyboard_shortcut_get_from_key(int key) +{ + for (int i = 0; i < SHORTCUT_COUNT; i++) { + if (key == gShortcutKeys[i]) { + return i; + } + } + return -1; +} + /** * * rct2: 0x006E3E68 */ void keyboard_shortcut_handle(int key) { - int i; - for (i = 0; i < SHORTCUT_COUNT; i++) { - if (key == gShortcutKeys[i]) { - keyboard_shortcut_handle_command(i); - break; - } + int shortcut = keyboard_shortcut_get_from_key(key); + if (shortcut != -1) { + keyboard_shortcut_handle_command(shortcut); } } @@ -141,9 +149,10 @@ static void shortcut_close_all_floating_windows() static void shortcut_cancel_construction_mode() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; - window = window_find_by_class(WC_ERROR); + rct_window *window = window_find_by_class(WC_ERROR); if (window != NULL) window_close(window); else if (gInputFlags & INPUT_FLAG_TOOL_ACTIVE) @@ -152,10 +161,8 @@ static void shortcut_cancel_construction_mode() static void shortcut_pause_game() { - rct_window *window; - - if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + if (!(gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER))) { + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 0); @@ -165,11 +172,12 @@ static void shortcut_pause_game() static void shortcut_zoom_view_out() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 2); @@ -180,11 +188,12 @@ static void shortcut_zoom_view_out() static void shortcut_zoom_view_in() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 3); @@ -195,22 +204,29 @@ static void shortcut_zoom_view_in() static void shortcut_rotate_view_clockwise() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + rct_window* w = window_get_main(); window_rotate_camera(w, 1); } static void shortcut_rotate_view_anticlockwise() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + rct_window* w = window_get_main(); window_rotate_camera(w, -1); } static void shortcut_rotate_construction_object() { - rct_window *w; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; // Rotate scenery - w = window_find_by_class(WC_SCENERY); + rct_window *w = window_find_by_class(WC_SCENERY); if (w != NULL && !widget_is_disabled(w, 25) && w->widgets[25].type != WWT_EMPTY) { window_event_mouse_up_call(w, 25); return; @@ -250,86 +266,130 @@ static void shortcut_rotate_construction_object() static void shortcut_underground_view_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_UNDERGROUND_INSIDE); } static void shortcut_remove_base_land_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_HIDE_BASE); } static void shortcut_remove_vertical_land_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_HIDE_VERTICAL); } static void shortcut_remove_top_bottom_toolbar_toggle() { - if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) - return; - - if (window_find_by_class(WC_TOP_TOOLBAR) != NULL) { - window_close(window_find_by_class(WC_DROPDOWN)); - window_close(window_find_by_class(WC_TOP_TOOLBAR)); - window_close(window_find_by_class(WC_BOTTOM_TOOLBAR)); - } else { - if (gScreenFlags == 0) { - window_top_toolbar_open(); - window_game_bottom_toolbar_open(); + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) { + if (window_find_by_class(WC_TITLE_LOGO) != NULL) { + window_close(window_find_by_class(WC_TITLE_LOGO)); + window_close(window_find_by_class(WC_TITLE_OPTIONS)); + window_close(window_find_by_class(WC_TITLE_MENU)); + window_close(window_find_by_class(WC_TITLE_EXIT)); + gTitleHideVersionInfo = true; } else { - window_top_toolbar_open(); - window_editor_bottom_toolbar_open(); + title_create_windows(); + } + } else { + if (window_find_by_class(WC_TOP_TOOLBAR) != NULL) { + window_close(window_find_by_class(WC_DROPDOWN)); + window_close(window_find_by_class(WC_TOP_TOOLBAR)); + window_close(window_find_by_class(WC_BOTTOM_TOOLBAR)); + } else { + if (gScreenFlags == 0) { + window_top_toolbar_open(); + window_game_bottom_toolbar_open(); + } else { + window_top_toolbar_open(); + window_editor_bottom_toolbar_open(); + } } } + gfx_invalidate_screen(); } static void shortcut_see_through_rides_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_SEETHROUGH_RIDES); } static void shortcut_see_through_scenery_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_SEETHROUGH_SCENERY); } static void shortcut_see_through_paths_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_SEETHROUGH_PATHS); } static void shortcut_invisible_supports_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_INVISIBLE_SUPPORTS); } static void shortcut_invisible_people_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_INVISIBLE_PEEPS); } static void shortcut_height_marks_on_land_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_LAND_HEIGHTS); } static void shortcut_height_marks_on_ride_tracks_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_TRACK_HEIGHTS); } static void shortcut_height_marks_on_paths_toggle() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + toggle_view_flag(VIEWPORT_FLAG_PATH_HEIGHTS); } static void shortcut_adjust_land() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 7); @@ -340,11 +400,12 @@ static void shortcut_adjust_land() static void shortcut_adjust_water() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 8); @@ -355,11 +416,12 @@ static void shortcut_adjust_water() static void shortcut_build_scenery() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 9); @@ -370,11 +432,12 @@ static void shortcut_build_scenery() static void shortcut_build_paths() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 10); @@ -385,11 +448,12 @@ static void shortcut_build_paths() static void shortcut_build_new_ride() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)) { if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 11); @@ -400,6 +464,9 @@ static void shortcut_build_new_ride() static void shortcut_show_financial_information() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) if (!(gParkFlags & PARK_FLAGS_NO_MONEY)) window_finances_open(); @@ -407,6 +474,9 @@ static void shortcut_show_financial_information() static void shortcut_show_research_information() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { if (gConfigInterface.toolbar_show_research) window_research_open(); @@ -417,10 +487,11 @@ static void shortcut_show_research_information() static void shortcut_show_rides_list() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 12); @@ -430,10 +501,11 @@ static void shortcut_show_rides_list() static void shortcut_show_park_information() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 13); @@ -443,10 +515,11 @@ static void shortcut_show_park_information() static void shortcut_show_guest_list() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 15); @@ -456,10 +529,11 @@ static void shortcut_show_guest_list() static void shortcut_show_staff_list() { - rct_window *window; + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - window = window_find_by_class(WC_TOP_TOOLBAR); + rct_window *window = window_find_by_class(WC_TOP_TOOLBAR); if (window != NULL) { window_invalidate(window); window_event_mouse_up_call(window, 14); @@ -469,12 +543,18 @@ static void shortcut_show_staff_list() static void shortcut_show_recent_messages() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) window_news_open(); } static void shortcut_show_map() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) window_map_open(); @@ -487,25 +567,29 @@ static void shortcut_screenshot() static void shortcut_reduce_game_speed() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + if (network_get_mode() == NETWORK_MODE_NONE) game_reduce_game_speed(); } static void shortcut_increase_game_speed() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + if (network_get_mode() == NETWORK_MODE_NONE) game_increase_game_speed(); } static void shortcut_open_cheat_window() { - rct_window *window; - if (gScreenFlags != SCREEN_FLAGS_PLAYING) return; // Check if window is already open - window = window_find_by_class(WC_CHEATS); + rct_window *window = window_find_by_class(WC_CHEATS); if (window != NULL) { window_close(window); return; @@ -515,6 +599,9 @@ static void shortcut_open_cheat_window() static void shortcut_open_chat_window() { + if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) + return; + chat_toggle(); } diff --git a/src/interface/window.c b/src/interface/window.c index 21d0513633..18a5faa9aa 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -2150,6 +2150,8 @@ void window_resize_gui(int width, int height) if (optionsWind != NULL) { optionsWind->x = width - 80; } + + gfx_invalidate_screen(); } /** diff --git a/src/rct2.c b/src/rct2.c index 98830b8b1b..0d4cb21075 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -295,7 +295,7 @@ void rct2_draw(rct_drawpixelinfo *dpi) chat_draw(dpi); console_draw(dpi); - if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) { + if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gTitleHideVersionInfo) { DrawOpenRCT2(dpi, 0, gScreenHeight - 20); } diff --git a/src/title.c b/src/title.c index 5c7eddc507..3972c7a272 100644 --- a/src/title.c +++ b/src/title.c @@ -44,6 +44,9 @@ #include "windows/error.h" static const int gRandomShowcase = 0; + +bool gTitleHideVersionInfo = false; + sint32 gTitleScriptCommand = -1; uint8 gTitleScriptSave = 0xFF; sint32 gTitleScriptSkipTo = -1; @@ -88,8 +91,6 @@ static uint8 *generate_random_script(); #pragma endregion -static void title_create_windows(); - static uint8 *title_script_load(); /** @@ -129,6 +130,7 @@ void title_load() //stop_other_sounds(); viewport_init_all(); news_item_init_queue(); + window_main_open(); title_create_windows(); title_init_showcase(); gfx_invalidate_screen(); @@ -147,14 +149,14 @@ void title_load() * tutorial, toolbox and exit. * rct2: 0x0066B5C0 (part of 0x0066B3E8) */ -static void title_create_windows() +void title_create_windows() { - window_main_open(); window_title_menu_open(); window_title_exit_open(); window_title_options_open(); window_title_logo_open(); window_resize_gui(gScreenWidth, gScreenHeight); + gTitleHideVersionInfo = false; } /** diff --git a/src/title.h b/src/title.h index 03cd06aadf..151b58dbc3 100644 --- a/src/title.h +++ b/src/title.h @@ -34,12 +34,15 @@ enum { TITLE_SCRIPT_LOADRCT1, }; +extern bool gTitleHideVersionInfo; + extern sint32 gTitleScriptCommand; extern uint8 gTitleScriptSave; extern sint32 gTitleScriptSkipTo; extern sint32 gTitleScriptSkipLoad; void title_load(); +void title_create_windows(); void title_update(); void title_skip_from_beginning(); void title_script_get_line(SDL_RWops *file, char *parts);