diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 451f65345a..6b0c460d07 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ C650B2191CCABBDD00B4D91C /* S4Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2151CCABBDD00B4D91C /* S4Importer.cpp */; }; C650B21A1CCABBDD00B4D91C /* tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2171CCABBDD00B4D91C /* tables.cpp */; }; C650B21C1CCABC4400B4D91C /* ConvertCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B21B1CCABC4400B4D91C /* ConvertCommand.cpp */; }; + C6575A371D46AFBA00C3E79F /* debug_paint.c in Sources */ = {isa = PBXBuildFile; fileRef = C6575A361D46AFBA00C3E79F /* debug_paint.c */; }; C686F8AC1CDBC37E009F9BFC /* banner.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8981CDBC37E009F9BFC /* banner.c */; }; C686F8AD1CDBC37E009F9BFC /* entrance.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8991CDBC37E009F9BFC /* entrance.c */; }; C686F8AE1CDBC37E009F9BFC /* fence.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F89A1CDBC37E009F9BFC /* fence.c */; }; @@ -397,6 +398,7 @@ C650B2171CCABBDD00B4D91C /* tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tables.cpp; sourceTree = ""; usesTabs = 0; }; C650B2181CCABBDD00B4D91C /* Tables.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = Tables.h; sourceTree = ""; usesTabs = 0; }; C650B21B1CCABC4400B4D91C /* ConvertCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertCommand.cpp; sourceTree = ""; usesTabs = 0; }; + C6575A361D46AFBA00C3E79F /* debug_paint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = debug_paint.c; sourceTree = ""; }; C686F8981CDBC37E009F9BFC /* banner.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = banner.c; sourceTree = ""; }; C686F8991CDBC37E009F9BFC /* entrance.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = entrance.c; sourceTree = ""; }; C686F89A1CDBC37E009F9BFC /* fence.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fence.c; sourceTree = ""; }; @@ -1594,6 +1596,7 @@ D44271921CC81B3200D84D28 /* cheats.c */, D44271931CC81B3200D84D28 /* clear_scenery.c */, D45B202C1D1E92DB00B67CC7 /* custom_currency.c */, + C6575A361D46AFBA00C3E79F /* debug_paint.c */, D44271941CC81B3200D84D28 /* demolish_ride_prompt.c */, D44271951CC81B3200D84D28 /* dropdown.c */, D44271961CC81B3200D84D28 /* dropdown.h */, @@ -2229,6 +2232,7 @@ D44272A51CC81B3200D84D28 /* particle.c in Sources */, D44272811CC81B3200D84D28 /* server_start.c in Sources */, D44272611CC81B3200D84D28 /* finances.c in Sources */, + C6575A371D46AFBA00C3E79F /* debug_paint.c in Sources */, D442722D1CC81B3200D84D28 /* utf8.c in Sources */, C686F9461CDBC3B7009F9BFC /* swinging_inverter_ship.c in Sources */, D442720B1CC81B3200D84D28 /* font.c in Sources */, diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 4389bd3955..dce866ca99 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4207,6 +4207,11 @@ STR_5895 :Save Track STR_5896 :Track save failed! STR_5897 :Window limit: STR_5898 :{BLACK}Can't load the track, the file might be {newline}corrupted, broken or missing! +STR_5899 :Toggle paint debug window +STR_5900 :Use original drawing code +STR_5901 :Show segment heights +STR_5902 :Show bounding boxes +STR_5903 :Show paint debug window ############# # Scenarios # diff --git a/openrct2.vcxproj b/openrct2.vcxproj index 89e292a8ee..91b965c2ce 100644 --- a/openrct2.vcxproj +++ b/openrct2.vcxproj @@ -279,6 +279,7 @@ + diff --git a/src/config.h b/src/config.h index 12ab76b984..e211374c29 100644 --- a/src/config.h +++ b/src/config.h @@ -79,6 +79,7 @@ enum { SHORTCUT_WINDOWED_MODE_TOGGLE, SHORTCUT_SHOW_MULTIPLAYER, SHORTCUT_PAINT_ORIGINAL_TOGGLE, + SHORTCUT_DEBUG_PAINT_TOGGLE, SHORTCUT_COUNT }; diff --git a/src/interface/console.c b/src/interface/console.c index 939d9dadb1..f49d3140ef 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -41,7 +41,6 @@ #include "console.h" #include "window.h" #include "viewport.h" -#include "../paint/map_element/map_element.h" #define CONSOLE_BUFFER_SIZE 8192 #define CONSOLE_BUFFER_2_SIZE 256 @@ -668,15 +667,9 @@ static int cc_get(const utf8 **argv, int argc) else if (strcmp(argv[0], "window_scale") == 0) { console_printf("window_scale %.3f", gConfigGeneral.window_scale); } - else if (strcmp(argv[0], "paint_segments") == 0) { - console_printf("paint_segments %d", gShowSupportSegmentHeights); - } else if (strcmp(argv[0], "window_limit") == 0) { console_printf("window_limit %d", gConfigGeneral.window_limit); } - else if (strcmp(argv[0], "paint_bounds") == 0) { - console_printf("paint_bounds %d", gPaintBoundingBoxes); - } else { console_writeline_warning("Invalid variable."); } @@ -845,20 +838,10 @@ static int cc_set(const utf8 **argv, int argc) platform_trigger_resize(); console_execute_silent("get window_scale"); } - else if (strcmp(argv[0], "paint_segments") == 0 && invalidArguments(&invalidArgs, int_valid[0])) { - gShowSupportSegmentHeights = (bool)(int_val[0]); - gfx_invalidate_screen(); - console_execute_silent("get paint_segments"); - } else if (strcmp(argv[0], "window_limit") == 0 && invalidArguments(&invalidArgs, int_valid[0])) { window_set_window_limit(int_val[0]); console_execute_silent("get window_limit"); } - else if (strcmp(argv[0], "paint_bounds") == 0 && invalidArguments(&invalidArgs, int_valid[0])) { - gPaintBoundingBoxes = (bool)(int_val[0]); - gfx_invalidate_screen(); - console_execute_silent("get paint_bounds"); - } else if (invalidArgs) { console_writeline_error("Invalid arguments."); } @@ -1046,9 +1029,7 @@ utf8* console_variable_table[] = { "no_test_crashes", "location", "window_scale", - "paint_segments", "window_limit", - "paint_bounds", }; utf8* console_window_table[] = { "object_selection", diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c index 7cd2e7b0af..641df08845 100644 --- a/src/interface/keyboard_shortcut.c +++ b/src/interface/keyboard_shortcut.c @@ -547,9 +547,20 @@ static void shortcut_show_multiplayer() static void shortcut_orginal_painting_toggle() { gUseOriginalRidePaint = !gUseOriginalRidePaint; + window_invalidate_by_class(WC_DEBUG_PAINT); gfx_invalidate_screen(); } +static void shortcut_debug_paint_toggle() +{ + rct_window * window = window_find_by_class(WC_DEBUG_PAINT); + if (window != NULL) { + window_close(window); + } else { + window_debug_paint_open(); + } +} + static const shortcut_action shortcut_table[SHORTCUT_COUNT] = { shortcut_close_top_most_window, shortcut_close_all_floating_windows, @@ -601,6 +612,7 @@ static const shortcut_action shortcut_table[SHORTCUT_COUNT] = { shortcut_windowed_mode_toggle, shortcut_show_multiplayer, shortcut_orginal_painting_toggle, + shortcut_debug_paint_toggle, }; #pragma endregion diff --git a/src/interface/window.h b/src/interface/window.h index df3f48c384..fa7d8a75a8 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -461,6 +461,7 @@ enum { WC_SERVER_LIST = 127, WC_SERVER_START = 128, WC_CUSTOM_CURRENCY_CONFIG = 129, + WC_DEBUG_PAINT = 130, // Only used for colour schemes WC_STAFF = 220, @@ -688,6 +689,7 @@ void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_ rct_window *window_mapgen_open(); rct_window *window_loadsave_open(int type, char *defaultName); rct_window *window_changelog_open(); +void window_debug_paint_open(); void window_editor_main_open(); void window_editor_bottom_toolbar_open(); diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index e3114f5120..f8c2823314 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -3330,6 +3330,11 @@ enum { STR_TRACK_SAVE_FAILED = 5896, STR_WINDOW_LIMIT = 5897, STR_TRACK_LOAD_FAILED_ERROR = 5898, + STR_SHORTCUT_DEBUG_PAINT_TOGGLE = 5899, + STR_DEBUG_PAINT_USE_OLD_DRAWING = 5900, + STR_DEBUG_PAINT_SHOW_SEGMENT_HEIGHTS = 5901, + STR_DEBUG_PAINT_SHOW_BOUND_BOXES = 5902, + STR_DEBUG_DROPDOWN_DEBUG_PAINT = 5903, // 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/debug_paint.c b/src/windows/debug_paint.c new file mode 100644 index 0000000000..9ddf7e8819 --- /dev/null +++ b/src/windows/debug_paint.c @@ -0,0 +1,140 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include "../addresses.h" +#include "../input.h" +#include "../interface/widget.h" +#include "../interface/window.h" +#include "../localisation/localisation.h" +#include "../sprites.h" +#include "../world/map.h" +#include "../interface/themes.h" +#include "../paint/map_element/map_element.h" +#include "../ride/track_paint.h" +#include "../paint/paint.h" + +enum WINDOW_DEBUG_PAINT_WIDGET_IDX +{ + WIDX_BACKGROUND, + WIDX_TOGGLE_OLD_DRAWING, + WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS, + WIDX_TOGGLE_SHOW_BOUND_BOXES, +}; + +#define WINDOW_WIDTH (200) +#define WINDOW_HEIGHT (8 + 15 + 15 + 11 + 8) + +static rct_widget window_debug_paint_widgets[] = { + { WWT_FRAME, 0, 0, WINDOW_WIDTH - 1, 0, WINDOW_HEIGHT - 1, 0xFFFFFFFF, STR_NONE}, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8, 8 + 11, STR_DEBUG_PAINT_USE_OLD_DRAWING, STR_NONE}, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15, 8 + 15 + 11, STR_DEBUG_PAINT_SHOW_SEGMENT_HEIGHTS, STR_NONE}, + { WWT_CHECKBOX, 1, 8, WINDOW_WIDTH - 8, 8 + 15 + 15, 8 + 15 + 15 + 11, STR_DEBUG_PAINT_SHOW_BOUND_BOXES, STR_NONE}, + { WIDGETS_END }, +}; + +static void window_debug_paint_mouseup(rct_window * w, int widgetIndex); +static void window_debug_paint_invalidate(rct_window * w); +static void window_debug_paint_paint(rct_window * w, rct_drawpixelinfo * dpi); + +static rct_window_event_list window_debug_paint_events = { + NULL, + window_debug_paint_mouseup, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + window_debug_paint_invalidate, + window_debug_paint_paint, + NULL +}; + +void window_debug_paint_open() +{ + rct_window * window; + + // Check if window is already open + if (window_find_by_class(WC_DEBUG_PAINT) != NULL) + return; + + window = window_create( + 16, + gScreenHeight - 16 - 33 - WINDOW_HEIGHT, + WINDOW_WIDTH, + WINDOW_HEIGHT, + &window_debug_paint_events, + WC_DEBUG_PAINT, + WF_STICK_TO_FRONT | WF_TRANSPARENT + ); + + window->widgets = window_debug_paint_widgets; + window->enabled_widgets = (1 << WIDX_TOGGLE_OLD_DRAWING) | (1 << WIDX_TOGGLE_SHOW_BOUND_BOXES) | (1 << WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS); + window_init_scroll_widgets(window); + window_push_others_below(window); + + window->colours[0] = COLOUR_BLACK | COLOUR_FLAG_TRANSLUCENT; + window->colours[1] = COLOUR_GREY; +} + +static void window_debug_paint_mouseup(rct_window * w, int widgetIndex) +{ + switch (widgetIndex) { + case WIDX_TOGGLE_OLD_DRAWING: + gUseOriginalRidePaint = !gUseOriginalRidePaint; + gfx_invalidate_screen(); + break; + + case WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS: + gShowSupportSegmentHeights = !gShowSupportSegmentHeights; + gfx_invalidate_screen(); + break; + + case WIDX_TOGGLE_SHOW_BOUND_BOXES: + gPaintBoundingBoxes = !gPaintBoundingBoxes; + gfx_invalidate_screen(); + break; + } +} + +static void window_debug_paint_invalidate(rct_window * w) +{ + widget_set_checkbox_value(w, WIDX_TOGGLE_OLD_DRAWING, gUseOriginalRidePaint); + widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_SEGMENT_HEIGHTS, gShowSupportSegmentHeights); + widget_set_checkbox_value(w, WIDX_TOGGLE_SHOW_BOUND_BOXES, gPaintBoundingBoxes); +} + +static void window_debug_paint_paint(rct_window * w, rct_drawpixelinfo * dpi) +{ + window_draw_widgets(w, dpi); +} diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 6b158e199a..6763bdebb4 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -105,7 +105,10 @@ typedef enum { DDIDX_TILE_INSPECTOR = 1, DDIDX_OBJECT_SELECTION = 2, DDIDX_INVENTIONS_LIST = 3, - DDIDX_SCENARIO_OPTIONS = 4 + DDIDX_SCENARIO_OPTIONS = 4, + DDIDX_DEBUG_PAINT = 5, + + TOP_TOOLBAR_DEBUG_COUNT } TOP_TOOLBAR_DEBUG_DDIDX; typedef enum { @@ -2934,11 +2937,18 @@ void top_toolbar_rotate_menu_dropdown(short dropdownIndex) void top_toolbar_init_debug_menu(rct_window* w, rct_widget* widget) { - gDropdownItemsFormat[0] = STR_DEBUG_DROPDOWN_CONSOLE; - gDropdownItemsFormat[1] = STR_DEBUG_DROPDOWN_TILE_INSPECTOR; - gDropdownItemsFormat[2] = STR_DEBUG_DROPDOWN_OBJECT_SELECTION; - gDropdownItemsFormat[3] = STR_DEBUG_DROPDOWN_INVENTIONS_LIST; - gDropdownItemsFormat[4] = STR_DEBUG_DROPDOWN_SCENARIO_OPTIONS; + gDropdownItemsFormat[DDIDX_CONSOLE] = STR_TOGGLE_OPTION; + gDropdownItemsArgs[DDIDX_CONSOLE] = STR_DEBUG_DROPDOWN_CONSOLE; + gDropdownItemsFormat[DDIDX_TILE_INSPECTOR] = STR_TOGGLE_OPTION; + gDropdownItemsArgs[DDIDX_TILE_INSPECTOR] = STR_DEBUG_DROPDOWN_TILE_INSPECTOR; + gDropdownItemsFormat[DDIDX_OBJECT_SELECTION] = STR_TOGGLE_OPTION; + gDropdownItemsArgs[DDIDX_OBJECT_SELECTION] = STR_DEBUG_DROPDOWN_OBJECT_SELECTION; + gDropdownItemsFormat[DDIDX_INVENTIONS_LIST] = STR_TOGGLE_OPTION; + gDropdownItemsArgs[DDIDX_INVENTIONS_LIST] = STR_DEBUG_DROPDOWN_INVENTIONS_LIST; + gDropdownItemsFormat[DDIDX_SCENARIO_OPTIONS] = STR_TOGGLE_OPTION; + gDropdownItemsArgs[DDIDX_SCENARIO_OPTIONS] = STR_DEBUG_DROPDOWN_SCENARIO_OPTIONS; + gDropdownItemsFormat[DDIDX_DEBUG_PAINT] = STR_TOGGLE_OPTION; + gDropdownItemsArgs[DDIDX_DEBUG_PAINT] = STR_DEBUG_DROPDOWN_DEBUG_PAINT; window_dropdown_show_text( w->x + widget->left, @@ -2946,9 +2956,10 @@ void top_toolbar_init_debug_menu(rct_window* w, rct_widget* widget) widget->bottom - widget->top + 1, w->colours[0] | 0x80, DROPDOWN_FLAG_STAY_OPEN, - 5 + TOP_TOOLBAR_DEBUG_COUNT ); + dropdown_set_checked(DDIDX_DEBUG_PAINT, window_find_by_class(WC_DEBUG_PAINT) != NULL); gDropdownDefaultIndex = DDIDX_CONSOLE; } @@ -2989,6 +3000,13 @@ void top_toolbar_debug_menu_dropdown(short dropdownIndex) case DDIDX_SCENARIO_OPTIONS: window_editor_scenario_options_open(); break; + case DDIDX_DEBUG_PAINT: + if (window_find_by_class(WC_DEBUG_PAINT) == NULL) { + window_debug_paint_open(); + } else { + window_close_by_class(WC_DEBUG_PAINT); + } + break; } } }