From a22f0a53fb9ae9487bb5739ec454145747f739dd Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 4 May 2019 21:48:02 +0000 Subject: [PATCH] Use localised strings for guest debug tab --- data/language/en-GB.txt | 9 +++- src/openrct2-ui/windows/Guest.cpp | 67 +++++++++++++-------------- src/openrct2/localisation/StringIds.h | 9 +++- 3 files changed, 49 insertions(+), 36 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index accce90de3..a6290f01b1 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3757,7 +3757,14 @@ STR_6306 :{SMALLFONT}{BLACK}Experimental option to use multiple threads to re STR_6307 :Colour scheme: {BLACK}{STRINGID} STR_6308 :“{STRINGID}{OUTLINE}{TOPAZ}”{NEWLINE}{STRINGID} STR_6309 :Reconnect -STR_6310 :{WINDOW_COLOUR_2}{STRING}: {BLACK}{STRING} +STR_6310 :{WINDOW_COLOUR_2}Position: {BLACK}{INT32} {INT32} {INT32} +STR_6311 :{WINDOW_COLOUR_2}Next: {BLACK}{INT32} {INT32} {INT32} +STR_6312 :(surface) +STR_6313 :(slope {INT32}) +STR_6314 :{WINDOW_COLOUR_2}Dest: {BLACK}{INT32}, {INT32} tolerance {INT32} +STR_6315 :{WINDOW_COLOUR_2}Pathfind Goal: {BLACK}{INT32}, {INT32}, {INT32} dir {INT32} +STR_6316 :{WINDOW_COLOUR_2}Pathfind history: +STR_6317 :{BLACK}{INT32}, {INT32}, {INT32} dir {INT32} ############# # Scenarios # diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 546b9a3d2d..41bf1dbb3a 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -2050,14 +2050,11 @@ void window_guest_debug_update(rct_window* w) window_invalidate(w); } -static void draw_debug_label(rct_drawpixelinfo* dpi, int32_t x, int32_t y, const char* label, const char* value) -{ - const char* args[2] = { label, value }; - gfx_draw_string_left(dpi, STR_PEEP_DEBUG_LABEL, args, 0, x, y); -} - void window_guest_debug_paint(rct_window* w, rct_drawpixelinfo* dpi) { + char buffer[512]{}; + char buffer2[512]{}; + window_draw_widgets(w, dpi); window_guest_overview_tab_paint(w, dpi); window_guest_stats_tab_paint(w, dpi); @@ -2070,44 +2067,46 @@ void window_guest_debug_paint(rct_window* w, rct_drawpixelinfo* dpi) auto peep = GET_PEEP(w->number); auto x = w->x + window_guest_debug_widgets[WIDX_PAGE_BACKGROUND].left + 4; auto y = w->y + window_guest_debug_widgets[WIDX_PAGE_BACKGROUND].top + 4; - - char buffer[512]{}; - snprintf(buffer, sizeof(buffer), "%i, %i, %i", peep->x, peep->y, peep->z); - draw_debug_label(dpi, x, y, "Position", buffer); - y += LIST_ROW_HEIGHT; - - snprintf(buffer, sizeof(buffer), "%u, %u, %u", peep->next_x, peep->next_y, peep->next_z); - if (peep->GetNextIsSurface()) - safe_strcat(buffer, " (surface)", sizeof(buffer)); - if (peep->GetNextIsSloped()) { - char slopeBuf[32]{}; - snprintf(slopeBuf, sizeof(slopeBuf), " (slope %u)", peep->GetNextDirection()); - safe_strcat(buffer, slopeBuf, sizeof(buffer)); + int32_t args[] = { peep->x, peep->y, peep->x }; + gfx_draw_string_left(dpi, STR_PEEP_DEBUG_POSITION, args, 0, x, y); } - draw_debug_label(dpi, x, y, "Next", buffer); y += LIST_ROW_HEIGHT; - - snprintf( - buffer, sizeof(buffer), "%u, %u, tolerance %u", peep->destination_x, peep->destination_y, peep->destination_tolerance); - draw_debug_label(dpi, x, y, "Dest", buffer); + { + int32_t args[] = { peep->next_x, peep->next_y, peep->next_z }; + format_string(buffer, sizeof(buffer), STR_PEEP_DEBUG_NEXT, args); + if (peep->GetNextIsSurface()) + { + format_string(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SURFACE, nullptr); + safe_strcat(buffer, buffer2, sizeof(buffer)); + } + if (peep->GetNextIsSloped()) + { + int32_t args2[1] = { peep->GetNextDirection() }; + format_string(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SLOPE, args2); + safe_strcat(buffer, buffer2, sizeof(buffer)); + } + gfx_draw_string(dpi, buffer, 0, x, y); + } y += LIST_ROW_HEIGHT; - - snprintf( - buffer, sizeof(buffer), "%u, %u, %u dir %u", peep->pathfind_goal.x, peep->pathfind_goal.y, peep->pathfind_goal.z, - peep->pathfind_goal.direction); - draw_debug_label(dpi, x, y, "Pathfind Goal", buffer); + { + int32_t args[] = { peep->destination_x, peep->destination_y, peep->destination_tolerance }; + gfx_draw_string_left(dpi, STR_PEEP_DEBUG_DEST, args, 0, x, y); + } y += LIST_ROW_HEIGHT; - - draw_debug_label(dpi, x, y, "Pathfind history", nullptr); + { + int32_t args[] = { peep->pathfind_goal.x, peep->pathfind_goal.y, peep->pathfind_goal.z, peep->pathfind_goal.direction }; + gfx_draw_string_left(dpi, STR_PEEP_DEBUG_PATHFIND_GOAL, args, 0, x, y); + } + y += LIST_ROW_HEIGHT; + gfx_draw_string_left(dpi, STR_PEEP_DEBUG_PATHFIND_HISTORY, nullptr, 0, x, y); y += LIST_ROW_HEIGHT; x += 10; for (auto& point : peep->pathfind_history) { - auto o = utf8_insert_codepoint(buffer, FORMAT_BLACK); - snprintf(buffer + o, sizeof(buffer) - o, "%u, %u, %u dir %u", point.x, point.y, point.z, point.direction); - gfx_draw_string(dpi, buffer, PALETTE_INDEX_10, x, y); + int32_t args[] = { point.x, point.y, point.z, point.direction }; + gfx_draw_string_left(dpi, STR_PEEP_DEBUG_PATHFIND_HISTORY_ITEM, args, 0, x, y); y += LIST_ROW_HEIGHT; } x -= 10; diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 79d4a7f15b..0b31ebc581 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3943,7 +3943,14 @@ enum STR_MULTIPLAYER_RECONNECT = 6309, - STR_PEEP_DEBUG_LABEL = 6310, + STR_PEEP_DEBUG_POSITION = 6310, + STR_PEEP_DEBUG_NEXT = 6311, + STR_PEEP_DEBUG_NEXT_SURFACE = 6312, + STR_PEEP_DEBUG_NEXT_SLOPE = 6313, + STR_PEEP_DEBUG_DEST = 6314, + STR_PEEP_DEBUG_PATHFIND_GOAL = 6315, + STR_PEEP_DEBUG_PATHFIND_HISTORY = 6316, + STR_PEEP_DEBUG_PATHFIND_HISTORY_ITEM = 6317, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768