1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 12:33:17 +01:00

Add paint debug window

This commit is contained in:
Marijn van der Werf
2016-07-25 23:49:39 +02:00
parent 67d4ff83e5
commit dd756cb8be
8 changed files with 167 additions and 19 deletions

View File

@@ -79,6 +79,7 @@ enum {
SHORTCUT_WINDOWED_MODE_TOGGLE,
SHORTCUT_SHOW_MULTIPLAYER,
SHORTCUT_PAINT_ORIGINAL_TOGGLE,
SHORTCUT_DEBUG_PAINT_TOGGLE,
SHORTCUT_COUNT
};

View File

@@ -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",

View File

@@ -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

View File

@@ -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();

View File

@@ -3330,6 +3330,10 @@ 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,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768

140
src/windows/debug_paint.c Normal file
View File

@@ -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,
};
static const int WINDOW_WIDTH = 200;
static const int 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);
}