17#include "absl/status/status.h"
18#include "absl/strings/str_cat.h"
19#include "absl/strings/str_format.h"
20#include "absl/time/clock.h"
21#include "absl/time/time.h"
31#include "imgui/imgui.h"
32#include "imgui/imgui_internal.h"
60 "Local draft. Nothing is uploaded or submitted.";
62 "Screenshot captured. Open Local files for its path.";
65 "Copied report to clipboard. Nothing was submitted.";
67 "Copied diagnostics to clipboard. Nothing was submitted.";
86 const ImGuiViewport* viewport = ImGui::GetMainViewport();
87 const ImVec2 work_size =
88 viewport !=
nullptr ? viewport->WorkSize : ImGui::GetIO().DisplaySize;
89 const ImVec2 center = viewport !=
nullptr
90 ? viewport->GetWorkCenter()
91 : ImVec2(work_size.x * 0.5f, work_size.y * 0.5f);
92 const ImVec2 max_size(
97 const ImVec2 initial_size(
100 return {center, initial_size, min_size, max_size};
104 float text_width = ImGui::CalcTextSize(label).x;
111 return text_width + ImGui::GetStyle().FramePadding.x * 2.0f;
115 float available_width) {
116 const float spacing = ImGui::GetStyle().ItemSpacing.x;
117 float used_width = 0.0f;
118 int rows = labels.empty() ? 0 : 1;
119 for (
const char* label : labels) {
121 if (used_width > 0.0f &&
122 used_width + spacing + button_width > available_width) {
124 used_width = button_width;
126 used_width += (used_width > 0.0f ? spacing : 0.0f) + button_width;
134 const float spacing = ImGui::GetStyle().ItemSpacing.x;
136 if (*used_width > 0.0f &&
137 *used_width + spacing + button_width <= available_width) {
139 *used_width += spacing + button_width;
142 *used_width = button_width;
146 const int layer_value =
object.GetLayerValue();
148 if (layer_value == 0) {
149 return "Upper layer (BG1)";
151 return layer_value == 1 ?
"Lower layer (BG2)" :
"Invalid selector";
153 switch (layer_value) {
157 return "BG2 overlay";
159 return "BG1 overlay";
166 static const char* kGroupNames[] = {
167 "HC/Sewers",
"Eastern",
"Desert",
"Hera",
"A-Tower",
"PoD",
"Swamp",
168 "Skull",
"Thieves",
"Ice",
"Misery",
"Turtle",
"GT",
170 constexpr size_t kCount =
sizeof(kGroupNames) /
sizeof(kGroupNames[0]);
171 return blockset < kCount ? kGroupNames[blockset] :
"Custom";
175 return absl::FormatTime(
"%Y%m%d-%H%M%S", absl::Now(), absl::LocalTimeZone());
179 return absl::FormatTime(
"%Y-%m-%d %H:%M:%S %Z", absl::Now(),
180 absl::LocalTimeZone());
184 const auto blocks = room.
blocks();
185 if (blocks.size() < 8) {
186 return "BG sheets: unavailable";
188 return absl::StrFormat(
189 "BG sheets: [%02X %02X %02X %02X %02X %02X %02X %02X]",
190 static_cast<int>(blocks[0]),
static_cast<int>(blocks[1]),
191 static_cast<int>(blocks[2]),
static_cast<int>(blocks[3]),
192 static_cast<int>(blocks[4]),
static_cast<int>(blocks[5]),
193 static_cast<int>(blocks[6]),
static_cast<int>(blocks[7]));
199 return absl::StrFormat(
200 "storage=special-table selector=%d (%s) routine=%d "
201 "legacy_both_bgs=%s "
204 semantics.draws_to_both_bgs ?
"yes" :
"no",
207 return absl::StrFormat(
208 "stream=%s draw_layer=%d effective_bg=%s routine=%d "
209 "legacy_both_bgs=%s "
215 semantics.routine_id, semantics.draws_to_both_bgs ?
"yes" :
"no",
232 size_t max_count, std::string_view prefix) {
233 std::string out = absl::StrFormat(
"%s count=%zu", std::string(prefix).c_str(),
235 const size_t preview_count = std::min<size_t>(tiles.size(), max_count);
236 for (
size_t i = 0; i < preview_count; ++i) {
237 const auto& tile = tiles[i];
238 out += absl::StrFormat(
" [%zu]=0x%03X/p%d/pr%d/h%d/v%d", i, tile.id_,
239 static_cast<int>(tile.palette_), tile.over_ ? 1 : 0,
240 tile.horizontal_mirror_ ? 1 : 0,
241 tile.vertical_mirror_ ? 1 : 0);
243 if (tiles.size() > preview_count) {
244 out += absl::StrFormat(
" ... %zu more", tiles.size() - preview_count);
251 std::vector<zelda3::ObjectDrawer::TileTrace>
writes;
259 if (bitmap !=
nullptr) {
260 gfx::Arena::Get().RetireBitmap(*bitmap);
269 if (rom ==
nullptr || !rom->
is_loaded()) {
270 return {.
summary =
"\nDrawer trace: unavailable (ROM not loaded)"};
274 if (selected_index >= objects.size()) {
275 return {.summary =
"\nDrawer trace: unavailable (stale selection)"};
279 "\nDrawer trace: unavailable (special-table object uses the "
280 "dedicated room pass)"};
295 for (
auto* buffer : {&bg1, &bg2}) {
296 buffer->EnsureBitmapInitialized();
297 buffer->bitmap().Fill(255);
298 buffer->ClearBuffer();
303 std::vector<zelda3::ObjectDrawer::TileTrace> trace;
304 absl::Status status = absl::NotFoundError(
"selected object not replayed");
305 bool selected_was_replayed =
false;
306 for (uint8_t pass = 0; pass < 3 && !selected_was_replayed; ++pass) {
307 for (
size_t index = 0; index < objects.size(); ++index) {
308 const auto& stored_obj = objects[index];
312 const uint8_t list_index =
313 std::min<uint8_t>(stored_obj.GetLayerValue(), 2);
314 if (list_index != pass) {
320 if (index == selected_index) {
323 drawer.
DrawObject(render_obj, bg1, bg2, palette_group,
326 selected_was_replayed =
true;
331 drawer.
DrawObject(render_obj, bg1, bg2, palette_group,
337 if (!status.ok() && !selected_was_replayed) {
342 return {.summary = absl::StrFormat(
"\nDrawer trace: unavailable (%s)",
343 std::string(status.message()).c_str())};
347 return {.summary =
"\nDrawer trace: status=ok writes=0"};
350 int min_x = std::numeric_limits<int>::max();
351 int min_y = std::numeric_limits<int>::max();
352 int max_x = std::numeric_limits<int>::min();
353 int max_y = std::numeric_limits<int>::min();
354 std::array<int, 3> layer_counts = {0, 0, 0};
355 std::set<std::tuple<int, int, uint8_t>> unique_cells;
356 for (
const auto& write : trace) {
357 min_x = std::min<int>(min_x, write.x_tile);
358 min_y = std::min<int>(min_y, write.y_tile);
359 max_x = std::max<int>(max_x, write.x_tile);
360 max_y = std::max<int>(max_y, write.y_tile);
361 if (write.layer < layer_counts.size()) {
362 ++layer_counts[write.layer];
364 unique_cells.insert({write.x_tile, write.y_tile, write.layer});
367 std::string out = absl::StrFormat(
368 "\nDrawer trace: status=ok context=room-stream-prefix+layout-tilewords "
369 "writes=%zu unique_cells=%zu "
370 "bounds_tiles=(%d,%d)..(%d,%d) layer_counts BG1=%d BG2=%d BG3=%d",
371 trace.size(), unique_cells.size(), min_x, min_y, max_x, max_y,
376 const size_t preview_count = std::min<size_t>(trace.size(), 12);
377 for (
size_t i = 0; i < preview_count; ++i) {
378 const auto& write = trace[i];
379 const int palette = (write.flags >> 3) & 0x7;
380 out += absl::StrFormat(
381 "\n write[%zu] %s tile=(%d,%d) id=0x%03X pal=%d pri=%d h=%d v=%d", i,
382 TraceLayerLabel(write.layer), write.x_tile, write.y_tile, write.tile_id,
383 palette, (write.flags & 0x4) ? 1 : 0, (write.flags & 0x1) ? 1 : 0,
384 (write.flags & 0x2) ? 1 : 0);
386 if (trace.size() > preview_count) {
387 out += absl::StrFormat(
"\n ... %zu more write(s)",
388 trace.size() - preview_count);
390 return {.summary = std::move(out), .writes = std::move(trace)};
400 if (palette_index < 0 || (palette_index & 0x0F) == 0) {
403 const uint8_t trace_palette =
static_cast<uint8_t
>((trace_flags >> 3) & 0x7);
404 return static_cast<uint8_t
>((palette_index >> 4) & 0x7) == trace_palette;
408 std::span<const zelda3::ObjectDrawer::TileTrace> trace,
410 constexpr std::array<std::pair<int, int>, 6> kPreferredOffsets = {
411 std::pair{4, 4}, std::pair{3, 3}, std::pair{0, 0},
412 std::pair{7, 7}, std::pair{0, 7}, std::pair{7, 0},
415 for (
size_t i = 0; i < trace.size(); ++i) {
416 const auto& write = trace[i];
417 const int tile_origin_x = write.x_tile * 8;
418 const int tile_origin_y = write.y_tile * 8;
419 const auto label = absl::StrFormat(
420 "object-trace[%zu] tile=(%d,%d) pal=%d", i, write.x_tile, write.y_tile,
421 static_cast<int>((write.flags >> 3) & 0x7));
423 for (
const auto& [dx, dy] : kPreferredOffsets) {
424 const int sample_x = tile_origin_x + dx;
425 const int sample_y = tile_origin_y + dy;
426 const auto comp = palette_debugger.
SamplePixelAt(sample_x, sample_y);
432 for (
int dy = 0; dy < 8; ++dy) {
433 for (
int dx = 0; dx < 8; ++dx) {
434 const int sample_x = tile_origin_x + dx;
435 const int sample_y = tile_origin_y + dy;
436 const auto comp = palette_debugger.
SamplePixelAt(sample_x, sample_y);
439 .
label = label, .x = sample_x, .y = sample_y};
445 if (!trace.empty()) {
446 const auto& write = trace.front();
448 .
label = absl::StrFormat(
"object-trace[0] tile=(%d,%d) pal=%d fallback",
449 write.x_tile, write.y_tile,
450 static_cast<int>((write.flags >> 3) & 0x7)),
451 .x = write.x_tile * 8 + 4,
452 .y = write.y_tile * 8 + 4};
459 std::span<const zelda3::ObjectDrawer::TileTrace> trace,
int selection_x_px,
460 int selection_y_px,
int selection_w_px,
int selection_h_px) {
462 return "trace: writes=0";
465 int min_x = std::numeric_limits<int>::max();
466 int min_y = std::numeric_limits<int>::max();
467 int max_x = std::numeric_limits<int>::min();
468 int max_y = std::numeric_limits<int>::min();
469 std::set<std::tuple<int, int, uint8_t>> unique_cells;
470 for (
const auto& write : trace) {
471 min_x = std::min<int>(min_x, write.x_tile);
472 min_y = std::min<int>(min_y, write.y_tile);
473 max_x = std::max<int>(max_x, write.x_tile);
474 max_y = std::max<int>(max_y, write.y_tile);
475 unique_cells.insert({write.x_tile, write.y_tile, write.layer});
478 const int trace_x_px = min_x * 8;
479 const int trace_y_px = min_y * 8;
480 const int trace_w_px = (max_x - min_x + 1) * 8;
481 const int trace_h_px = (max_y - min_y + 1) * 8;
482 return absl::StrFormat(
483 "trace: writes=%zu unique_cells=%zu bounds_px=(%d,%d,%d,%d) "
484 "delta_vs_selection_px=(%+d,%+d,%+d,%+d)",
485 trace.size(), unique_cells.size(), trace_x_px, trace_y_px, trace_w_px,
486 trace_h_px, trace_x_px - selection_x_px, trace_y_px - selection_y_px,
487 trace_w_px - selection_w_px, trace_h_px - selection_h_px);
491 std::string_view label) {
496 const auto [bounds_x, bounds_y, bounds_w, bounds_h] = door.
GetBounds();
497 const auto [editor_x, editor_y, editor_w, editor_h] = door.
GetEditorBounds();
498 const auto [encoded_b1, encoded_b2] = door.
EncodeBytes();
500 return absl::StrFormat(
502 "- type=%s (0x%02X)\n"
503 "- direction=%s (%d)\n"
505 "- tile_coords=(%d,%d) pixel_coords=(%d,%d)\n"
506 "- dims_tiles=(%d,%d) editor_dims_tiles=(%d,%d)\n"
507 "- bounds_px=(%d,%d,%d,%d) editor_bounds_px=(%d,%d,%d,%d)\n"
508 "- encoded=(0x%02X,0x%02X) original=(0x%02X,0x%02X)",
509 std::string(label).c_str(), index,
511 static_cast<int>(door.
type),
514 tile_y, pixel_x, pixel_y, dims.width_tiles, dims.height_tiles,
515 editor_dims.width_tiles, editor_dims.height_tiles, bounds_x, bounds_y,
516 bounds_w, bounds_h, editor_x, editor_y, editor_w, editor_h, encoded_b1,
525 return std::filesystem::path(rom.
filename()).filename().string();
527 const std::string title = rom.
title();
528 return title.empty() ?
"in-memory ROM" : title;
535 const std::string rom_path =
537 ? std::string(
"in-memory")
539 summary += absl::StrFormat(
544 summary +=
"ROM: unavailable";
548 summary += absl::StrFormat(
560 return absl::StrFormat(
"- [%s] palette=%d colors=%d %s",
565 return absl::StrFormat(
"- [%s] palette=%d %s", event.
location.c_str(),
569 return absl::StrFormat(
"- [%s] colors=%d %s", event.
location.c_str(),
572 return absl::StrFormat(
"- [%s] %s", event.
location.c_str(),
584 std::string entrance_context =
"Entrance:none";
586 const std::string entrance_id_text =
590 const std::string entrance_blockset_text =
591 entrance_blockset != 0xFF
592 ? absl::StrFormat(
"%02X",
static_cast<int>(entrance_blockset))
595 absl::StrFormat(
"Entrance:%s EB:%s", entrance_id_text.c_str(),
596 entrance_blockset_text.c_str());
599 std::string summary = absl::StrFormat(
600 "Room 0x%03X [%s] | B:%02X P:%02X->%02X L:%02X S:%02X | %s | Group:%s | "
601 "Floor1:%d Floor2:%d Effect:%d Tag1:%d Tag2:%d\n%s\n%s",
604 entrance_context, GetBlocksetGroupName(room.
blockset()), room.
floor1(),
607 BuildEffectiveBlockListSummary(room).c_str());
614 const auto link_diagnostics =
616 if (!link_diagnostics.links.empty() ||
617 !link_diagnostics.staircase_issues.empty()) {
618 summary +=
"\nConnectivity:";
619 for (
const auto& link : link_diagnostics.links) {
623 for (
const auto& issue : link_diagnostics.staircase_issues) {
642 std::string report =
"Dungeon Draw Issue Report\n";
644 report += absl::StrFormat(
645 "\nResolved palette group: 0x%02X\nInteraction mode: %s\nView: BG1=%s "
646 "BG2=%s Grid=%s Bounds=%s Sprites=%s Pots=%s Collision=%s Camera=%s",
658 if (!selected.empty()) {
659 report += absl::StrFormat(
"\nSelected objects: %zu", selected.size());
660 if (selected.size() == 1) {
662 const size_t index = selected.front();
663 if (index < objects.size()) {
664 const auto& obj = objects[index];
665 report += absl::StrFormat(
666 "\nObject: id=0x%03X name=%s pos=(%d,%d) size=0x%02X %s", obj.id_,
667 GetObjectName(obj.id_).c_str(), obj.x_, obj.y_, obj.size_,
668 BuildSelectedObjectSemanticsSummary(obj).c_str());
669 if (
auto tiles = obj.GetTiles(); tiles.ok()) {
671 report += FormatObjectTileSample(*tiles, 16,
"Descriptor tiles:");
673 if (obj.id_ == 0x00C4 || obj.id_ == 0x00DB) {
674 const bool uses_floor1 = obj.id_ == 0x00C4;
675 const uint8_t floor_pattern =
677 report += absl::StrFormat(
678 "\nFloor copy source: Floor %d (room.floor%d) pattern=%d",
679 uses_floor1 ? 1 : 2, uses_floor1 ? 1 : 2,
680 static_cast<int>(floor_pattern));
685 if (effective_tiles.has_value()) {
687 report += FormatObjectTileSample(*effective_tiles,
688 effective_tiles->size(),
689 "Effective floor-copy tiles:");
692 "\nEffective floor-copy tiles: unavailable "
693 "(ROM tables out of range)";
697 "\nEffective floor-copy tiles: unavailable (ROM not loaded)";
701 auto [bounds_x, bounds_y, bounds_w, bounds_h] =
703 bounds_w = std::max(bounds_w, 8);
704 bounds_h = std::max(bounds_h, 8);
705 const int origin_x = obj.x_ * 8;
706 const int origin_y = obj.y_ * 8;
707 const int center_x = bounds_x + std::max(0, (bounds_w / 2) - 1);
708 const int center_y = bounds_y + std::max(0, (bounds_h / 2) - 1);
709 report += absl::StrFormat(
710 "\nObject geometry: selection_bounds_px=(%d,%d,%d,%d) "
711 "object_origin_px=(%d,%d) center_px=(%d,%d)",
712 bounds_x, bounds_y, bounds_w, bounds_h, origin_x, origin_y,
714 const auto trace_report =
716 report += trace_report.summary;
719 auto append_sample = [&](std::string_view label,
int sample_x,
721 const auto comp = palette_debugger.SamplePixelAt(sample_x, sample_y);
722 palette_debugger.AddComparison(comp);
723 const std::string label_text(label);
724 if (comp.palette_index < 0) {
725 report += absl::StrFormat(
726 "\nComposite sample %s (%d,%d): RGB=(%d,%d,%d), after color "
727 "math; no palette index",
728 label_text, sample_x, sample_y, comp.actual_r, comp.actual_g,
732 report += absl::StrFormat(
733 "\nPalette sample %s (%d,%d): idx=%d expected=(%d,%d,%d) "
734 "actual=(%d,%d,%d) match=%s",
735 label_text.c_str(), sample_x, sample_y,
736 static_cast<int>(comp.palette_index),
737 static_cast<int>(comp.expected_r),
738 static_cast<int>(comp.expected_g),
739 static_cast<int>(comp.expected_b),
740 static_cast<int>(comp.actual_r),
static_cast<int>(comp.actual_g),
741 static_cast<int>(comp.actual_b), comp.matches ?
"yes" :
"no");
744 if (
auto trace_sample = ChooseObjectTracePaletteSample(
745 trace_report.writes, palette_debugger)) {
746 append_sample(trace_sample->label, trace_sample->x, trace_sample->y);
748 append_sample(
"selection-origin", bounds_x, bounds_y);
749 if (center_x != bounds_x || center_y != bounds_y) {
750 append_sample(
"selection-center", center_x, center_y);
754 report += absl::StrFormat(
755 "\nSelected object index %zu is stale; room currently has %zu "
756 "object(s). Reselect the object and report again if this issue "
758 index, objects.size());
765 switch (selected_entity.type) {
766 case EntityType::Door: {
767 const auto& doors = room.
GetDoors();
768 if (selected_entity.index < doors.size()) {
769 const auto& door = doors[selected_entity.index];
770 report += BuildDoorIssueSummary(door, selected_entity.index,
775 case EntityType::Sprite: {
777 if (selected_entity.index < sprites.size()) {
778 const auto& sprite = sprites[selected_entity.index];
779 report += absl::StrFormat(
780 "\nSelected entity: sprite id=0x%02X name=%s pos=(%d,%d) "
783 sprite.y(), sprite.layer());
787 case EntityType::Item: {
789 if (selected_entity.index < items.size()) {
790 const auto& item = items[selected_entity.index];
792 absl::StrFormat(
"\nSelected entity: pot item=0x%02X pos=(%d,%d)",
793 item.item, item.GetPixelX(), item.GetPixelY());
803 if (!palette_events.empty()) {
805 absl::StrFormat(
"\nPalette debug events: %zu", palette_events.size());
806 const size_t preview_count = std::min<size_t>(palette_events.size(), 4);
807 const size_t start = palette_events.size() - preview_count;
808 for (
size_t i = start; i < palette_events.size(); ++i) {
809 const auto&
event = palette_events[i];
811 report += FormatPaletteDebugEventForReport(event);
820 std::string report =
"Dungeon Selection Issue Report\n";
823 absl::StrFormat(
"\nInteraction mode: %s\nResolved palette group: 0x%02X",
828 if (!selected_objects.empty()) {
830 absl::StrFormat(
"\nSelected objects: %zu", selected_objects.size());
832 const size_t preview_count = std::min<size_t>(selected_objects.size(), 4);
833 for (
size_t i = 0; i < preview_count; ++i) {
834 const size_t index = selected_objects[i];
835 if (index >= objects.size()) {
836 report += absl::StrFormat(
837 "\n- object[%zu] unavailable; room currently has %zu object(s) "
838 "(selection is stale)",
839 index, objects.size());
842 const auto& obj = objects[index];
843 report += absl::StrFormat(
844 "\n- object[%zu] id=0x%03X name=%s pos=(%d,%d) size=0x%02X %s", index,
845 obj.id_, GetObjectName(obj.id_).c_str(), obj.x_, obj.y_, obj.size_,
846 BuildSelectedObjectSemanticsSummary(obj).c_str());
847 auto [bounds_x, bounds_y, bounds_w, bounds_h] =
849 bounds_w = std::max(bounds_w, 8);
850 bounds_h = std::max(bounds_h, 8);
851 report += absl::StrFormat(
852 "\n geometry: selection_bounds_px=(%d,%d,%d,%d) "
853 "object_origin_px=(%d,%d)",
854 bounds_x, bounds_y, bounds_w, bounds_h, obj.x_ * 8, obj.y_ * 8);
855 if (
auto tiles = obj.GetTiles(); tiles.ok() && !tiles->empty()) {
857 report += FormatObjectTileSample(*tiles, 10,
"tiles:");
859 const auto trace_report =
862 report += BuildObjectTraceBoundsSummary(trace_report.writes, bounds_x,
863 bounds_y, bounds_w, bounds_h);
865 if (selected_objects.size() > preview_count) {
866 report += absl::StrFormat(
"\n- ... %zu more object(s)",
867 selected_objects.size() - preview_count);
874 switch (selected_entity.type) {
875 case EntityType::Door: {
876 const auto& doors = room.
GetDoors();
877 if (selected_entity.index < doors.size()) {
878 const auto& door = doors[selected_entity.index];
879 report += BuildDoorIssueSummary(door, selected_entity.index,
885 case EntityType::Sprite: {
887 if (selected_entity.index < sprites.size()) {
888 const auto& sprite = sprites[selected_entity.index];
889 report += absl::StrFormat(
890 "\nSelected sprite[%zu]:\n"
895 selected_entity.index, sprite.id(),
902 case EntityType::Item: {
904 if (selected_entity.index < items.size()) {
905 const auto& item = items[selected_entity.index];
906 report += absl::StrFormat(
907 "\nSelected pot item[%zu]:\n"
909 "- pixel_pos=(%d,%d)",
910 selected_entity.index, item.item, item.GetPixelX(),
921 report +=
"\nNo active object or entity selection.";
930 if (!paths_or.ok()) {
959 if (!ImGui::CollapsingHeader(kIssueReportSectionPaths)) {
963 ImGui::TextWrapped(tr(
"Log target: %s"),
968 ImGui::TextWrapped(tr(
"Screenshot dir: %s"),
972 ImGui::TextWrapped(tr(
"Screenshot: %s"),
976 ImGui::TextWrapped(tr(
"Issue log: %s"),
983 const std::string_view message =
984 idle ? std::string_view(tr(kIssueReportStatusIdle))
986 const size_t line_end = message.find_first_of(
"\r\n");
987 std::string visible_line(message.substr(0, line_end));
988 if (line_end != std::string_view::npos) {
989 visible_line +=
"...";
992 idle ? ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled)
995 const ImVec2 start = ImGui::GetCursorScreenPos();
996 const ImVec2 size(std::max(ImGui::GetContentRegionAvail().x, 1.0f),
997 ImGui::GetTextLineHeight());
998 const ImVec2 end(start.x + size.x, start.y + size.y);
1001 ImGui::RenderTextEllipsis(ImGui::GetWindowDrawList(), start, end, end.x,
1002 visible_line.c_str(),
nullptr,
nullptr);
1005 if (ImGui::IsItemHovered()) {
1006 ImGui::BeginTooltip();
1007 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
1008 ImGui::TextUnformatted(message.data(), message.data() + message.size());
1009 ImGui::PopTextWrapPos();
1010 ImGui::EndTooltip();
1015 const std::string& title,
const std::string& summary,
1016 const std::string& kind_label,
const std::string& diagnostics,
int room_id,
1017 int default_category_index) {
1023 std::clamp(default_category_index, 0,
1033 return absl::OkStatus();
1037 const std::string& summary,
1038 const std::string& kind_label,
1039 const std::string& diagnostics,
1041 int default_category_index) {
1043 room_id, default_category_index);
1045 const IssueReportWindowLayout window_layout = GetIssueReportWindowLayout();
1046 ImGui::SetNextWindowPos(window_layout.center, ImGuiCond_Appearing,
1047 ImVec2(0.5f, 0.5f));
1048 ImGui::SetNextWindowSize(window_layout.initial_size, ImGuiCond_Appearing);
1049 ImGui::SetNextWindowSizeConstraints(window_layout.min_size,
1050 window_layout.max_size);
1053 ImGuiWindowFlags_NoSavedSettings)) {
1054#ifdef YAZE_WITH_GRPC
1056 ? kIssueReportCaptureButtonLabel
1057 : kIssueReportRecaptureButtonLabel;
1058 const std::array<const char*, 4> action_labels = {
1059 kIssueReportSaveButtonLabel, capture_label,
1060 kIssueReportCopyButtonLabel, kIssueReportCloseButtonLabel};
1062 const std::array<const char*, 3> action_labels = {
1063 kIssueReportSaveButtonLabel, kIssueReportCopyButtonLabel,
1064 kIssueReportCloseButtonLabel};
1066 const float footer_width =
1067 std::max(ImGui::GetContentRegionAvail().x, 1.0f);
1068 const int action_rows = CountWrappedIssueActionRows(
1069 std::span<const char* const>(action_labels), footer_width);
1070 const ImGuiStyle& style = ImGui::GetStyle();
1071 const float action_height =
1072 action_rows * ImGui::GetFrameHeight() +
1073 std::max(0, action_rows - 1) * style.ItemSpacing.y;
1074 const float footer_height = ImGui::GetTextLineHeightWithSpacing() +
1075 action_height + style.ItemSpacing.y * 2.0f +
1078 if (ImGui::BeginChild(
"##DungeonIssueReportBody",
1079 ImVec2(0.0f, -footer_height),
false,
1080 ImGuiWindowFlags_None)) {
1089 ImGui::TextUnformatted(tr(
"Category"));
1090 ImGui::SetNextItemWidth(
1091 std::max(ImGui::GetContentRegionAvail().x, 1.0f));
1092 const char* category_preview =
1094 if (ImGui::BeginCombo(
"##DungeonIssueCategory", category_preview)) {
1096 const bool selected =
1103 ImGui::SetItemDefaultFocus();
1109 ImGui::TextUnformatted(tr(
"Summary"));
1110 ImGui::SetNextItemWidth(
1111 std::max(ImGui::GetContentRegionAvail().x, 1.0f));
1112 if (ImGui::InputTextWithHint(
1113 "##DungeonIssueSummary", kIssueReportSummaryHint,
1118 ImGui::TextUnformatted(tr(
"Observed issue"));
1119 if (ImGui::InputTextMultiline(
"##DungeonIssueObserved",
1122 ImVec2(-1.0f, kIssueReportNotesHeight))) {
1128 if (ImGui::CollapsingHeader(kIssueReportSectionDiagnostics)) {
1129 ImGui::InputTextMultiline(
1130 kIssueReportPopupIdDiagnostics,
1133 ImVec2(-1.0f, kIssueReportDiagnosticsHeight),
1134 ImGuiInputTextFlags_ReadOnly);
1147 float used_action_width = 0.0f;
1148 PlaceNextIssueAction(kIssueReportSaveButtonLabel, footer_width,
1149 &used_action_width);
1159#ifdef YAZE_WITH_GRPC
1160 PlaceNextIssueAction(capture_label, footer_width, &used_action_width);
1163 ImVec2(GetIssueActionButtonWidth(capture_label), 0.0f))) {
1174 PlaceNextIssueAction(kIssueReportCopyButtonLabel, footer_width,
1175 &used_action_width);
1176 if (ImGui::Button(kIssueReportCopyButtonLabel)) {
1178 ImGui::SetClipboardText(report.c_str());
1182 PlaceNextIssueAction(kIssueReportCloseButtonLabel, footer_width,
1183 &used_action_width);
1184 if (ImGui::Button(kIssueReportCloseButtonLabel)) {
1186 ImGui::CloseCurrentPopup();
1199 report += absl::StrFormat(
1205 report += absl::StrFormat(
"Screenshot: %s\n",
1211 report +=
"\nDiagnostics:\n";
1217#ifdef YAZE_WITH_GRPC
1220 return absl::FailedPreconditionError(
1221 "Room canvas region is not available for screenshot capture");
1224 const std::string timestamp = BuildIssueTimestampSlug();
1228 if (!screenshot_path_or.ok()) {
1229 return screenshot_path_or.status();
1232 yaze::test::CaptureRegion region;
1238 auto artifact_or = yaze::test::CaptureHarnessScreenshotRegion(
1239 std::optional<yaze::test::CaptureRegion>(region),
1240 screenshot_path_or->string(),
1242 if (!artifact_or.ok()) {
1243 return artifact_or.status();
1248 return absl::OkStatus();
1250 return absl::UnimplementedError(
1251 "Screenshot capture is unavailable without YAZE_WITH_GRPC");
1268 if (!log_path_or.ok()) {
1269 return log_path_or.status();
1274 return absl::OkStatus();
1280 return absl::OkStatus();
1285 return absl::OkStatus();
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
const auto & vector() const
bool issue_report_popup_status_is_error_
std::string issue_report_popup_screenshot_dir_
int issue_report_category_index_
std::string BuildDrawIssueReport(const zelda3::Room &room, int room_id)
bool has_canvas_capture_region_
void MarkIssueReportDirty()
bool show_camera_quadrant_overlay_
std::string issue_report_popup_status_message_
bool IsBG1Visible(int room_id) const
std::string issue_report_popup_id_
std::string issue_report_popup_kind_
void RefreshIssueReportOutputTargets()
std::string BuildIssueReportClipboardText() const
std::string issue_report_popup_screenshot_path_
int issue_report_popup_room_id_
void SetIssueReportPopupStatus(std::string message, bool is_error)
char issue_report_summary_[256]
bool show_custom_collision_overlay_
DungeonObjectInteraction object_interaction_
void OpenIssueReportPopup(const std::string &title, const std::string &summary, const std::string &kind_label, const std::string &diagnostics, int room_id, int default_category_index)
absl::Status AppendIssueReportToLog()
std::string BuildRoomMetadataSummary(const zelda3::Room &room, int room_id) const
void DrawIssueReportStatusMessage() const
const project::YazeProject * project_
void DrawIssueReportStorageSummary() const
absl::Status EnsureIssueReportPersisted()
gfx::Bitmap * PrepareRoomCompositeBitmap(int room_id)
int canvas_capture_height_
std::string issue_report_popup_diagnostics_
gfx::PaletteGroup current_palette_group_
DungeonRoomStore * rooms_
absl::Status PrepareIssueReportPopup(const std::string &title, const std::string &summary, const std::string &kind_label, const std::string &diagnostics, int room_id, int default_category_index)
bool issue_report_popup_persisted_
EntityVisibility entity_visibility_
bool IsBG2Visible(int room_id) const
absl::Status CaptureIssueReportScreenshot()
char issue_report_notes_[2048]
std::string issue_report_popup_last_log_path_
std::string issue_report_popup_log_target_path_
int canvas_capture_width_
std::string issue_report_popup_title_
std::string BuildSelectionIssueReport(const zelda3::Room &room, int room_id) const
SelectedEntity GetSelectedEntity() const
std::vector< size_t > GetSelectedObjectIndices() const
InteractionModeManager & mode_manager()
bool HasEntitySelection() const
zelda3::Room * GetIfMaterialized(int room_id)
const char * GetModeName() const
Get mode name for debugging/UI.
std::vector< uint16_t > & buffer()
Represents a bitmap image optimized for SNES ROM hacking.
void ClosePersistentPopup(const std::string &popup_id)
void OpenPersistentPopup(const std::string &popup_id, std::function< void()> render_callback)
RAII guard for ImGui style colors.
static DimensionService & Get()
std::tuple< int, int, int, int > GetSelectionBoundsPixels(const RoomObject &obj) const
Draws dungeon objects to background buffers using game patterns.
void SetRoomFloorGraphics(uint8_t floor1, uint8_t floor2)
void SetBG1RevealMaskSource(gfx::BG1RevealMaskSource source)
absl::Status DrawObject(const RoomObject &object, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const gfx::PaletteGroup &palette_group, const DungeonState *state=nullptr, gfx::BackgroundBuffer *layout_bg1=nullptr, gfx::BackgroundBuffer *layout_bg2=nullptr)
Draw a room object to background buffers.
void ClearTraceCollector()
void SetTraceCollector(std::vector< TileTrace > *collector, bool trace_only=false)
static PaletteDebugger & Get()
const std::vector< PaletteDebugEvent > & GetEvents() const
ColorComparison SamplePixelAt(int x, int y) const
uint8_t GetLayerValue() const
const std::array< uint8_t, 0x10000 > & get_gfx_buffer() const
const std::vector< Door > & GetDoors() const
uint8_t spriteset() const
const std::vector< zelda3::Sprite > & GetSprites() const
const std::vector< RoomObject > & GetTileObjects() const
DungeonState * GetDungeonState()
int ResolveDungeonPaletteId() const
uint8_t render_entrance_blockset() const
uint8_t layout_id() const
const std::vector< PotItem > & GetPotItems() const
#define ICON_MD_ADD_A_PHOTO
#define ICON_MD_ASSIGNMENT
#define ICON_MD_CONTENT_COPY
#define ICON_MD_PHOTO_CAMERA
std::string BuildEffectiveBlockListSummary(const zelda3::Room &room)
constexpr char kIssueReportSummaryHint[]
constexpr char kIssueReportSaveButtonLabel[]
std::string BuildDoorIssueSummary(const zelda3::Room::Door &door, size_t index, std::string_view label)
constexpr float kIssueReportDialogMinHeight
IssueReportWindowLayout GetIssueReportWindowLayout()
std::string BuildIssueTimestampSlug()
std::string BuildObjectTraceBoundsSummary(std::span< const zelda3::ObjectDrawer::TileTrace > trace, int selection_x_px, int selection_y_px, int selection_w_px, int selection_h_px)
constexpr char kIssueReportCaptureButtonLabel[]
std::optional< PaletteSamplePoint > ChooseObjectTracePaletteSample(std::span< const zelda3::ObjectDrawer::TileTrace > trace, const zelda3::PaletteDebugger &palette_debugger)
constexpr float kIssueReportDialogWidth
constexpr char kIssueReportStatusCopiedDiagnostics[]
ObjectTraceReport BuildObjectTraceReport(Rom *rom, const zelda3::Room &room, size_t selected_index, const gfx::PaletteGroup &palette_group)
constexpr char kIssueReportPopupIdDiagnostics[]
std::string BuildRomDisplayName(const Rom &rom)
std::string BuildSelectedObjectSemanticsSummary(const zelda3::RoomObject &obj)
std::string BuildIssueTimestampDisplay()
constexpr char kIssueReportStatusSavedLog[]
void PlaceNextIssueAction(const char *label, float available_width, float *used_width)
constexpr float kIssueReportDialogMinWidth
constexpr char kIssueReportStatusIdle[]
std::string FormatPaletteDebugEventForReport(const zelda3::PaletteDebugEvent &event)
constexpr char kIssueReportSectionPaths[]
constexpr char kIssueReportRecaptureButtonLabel[]
constexpr char kIssueReportStatusCopiedReport[]
std::string BuildReportSessionSummary(const Rom *rom, const project::YazeProject *project)
constexpr char kIssueReportStatusSavedScreenshot[]
constexpr char kIssueReportCloseButtonLabel[]
constexpr float kIssueReportDiagnosticsHeight
constexpr char kIssueReportCopyButtonLabel[]
std::string FormatObjectTileSample(std::span< const gfx::TileInfo > tiles, size_t max_count, std::string_view prefix)
constexpr float kIssueReportDialogHeight
constexpr char kIssueReportSectionDiagnostics[]
const char * TraceLayerLabel(uint8_t layer)
float GetIssueActionButtonWidth(const char *label)
const char * GetBlocksetGroupName(uint8_t blockset)
const char * GetStoredPlacementLabel(const zelda3::RoomObject &object)
bool PaletteIndexMatchesTracePalette(int palette_index, uint8_t trace_flags)
int CountWrappedIssueActionRows(std::span< const char *const > labels, float available_width)
constexpr float kIssueReportNotesHeight
constexpr float kIssueReportDialogViewportMargin
Editors are the view controllers for the application.
std::string FormatDungeonConnectedLinkDescription(const DungeonConnectedRoomLink &link)
DungeonConnectedRoomLinkDiagnostics CollectDungeonConnectedRoomLinkDiagnostics(int room_id, const zelda3::Room &room, const std::function< bool(int, zelda3::DoorDirection)> &has_reciprocal_door)
const char * GetIssueCategoryLabel(int index)
constexpr std::array< const char *, 6 > kDungeonIssueCategoryLabels
absl::StatusOr< std::filesystem::path > AppendDungeonIssueLogEntry(const DungeonIssueLogEntry &entry)
absl::StatusOr< std::filesystem::path > BuildDungeonIssueScreenshotPath(int room_id, const std::string &category_label, const std::string ×tamp_slug)
absl::StatusOr< DungeonIssueReportPaths > ResolveDungeonIssueReportPaths()
std::string FormatDungeonStaircaseIssueDescription(const DungeonStaircaseIssue &issue)
std::optional< std::array< TileInfo, 8 > > DecodeDungeonFloorTilePattern(const std::vector< uint8_t > &rom_data, int tile_address, int tile_address_floor, uint8_t floor_graphics)
bool PrimaryButton(const char *label, const ImVec2 &size, const char *panel_id, const char *anim_id)
Draw a primary action button (accented color).
std::string ComputeRomHash(const uint8_t *data, size_t size)
ObjectLayerSemantics GetObjectLayerSemantics(const RoomObject &object)
std::string GetRoomLabel(int id)
Convenience function to get a room label.
RoomObject::LayerType MapRoomObjectListIndexToDrawLayer(uint8_t list_index)
const char * ObjectRenderRoutingToken(ObjectRenderRouting routing)
constexpr std::string_view GetDoorDirectionName(DoorDirection dir)
Get human-readable name for door direction.
bool UsesRoomObjectStream(const RoomObject &object)
constexpr int kRoomObjectTileAddress
std::string GetObjectName(int object_id)
constexpr std::string_view GetDoorTypeName(DoorType type)
Get human-readable name for door type.
constexpr int kNumberOfRooms
const char * EffectiveBgLayerLabel(EffectiveBgLayer layer)
constexpr int kRoomObjectTileAddressFloor
const char * ResolveSpriteName(uint16_t id)
#define RETURN_IF_ERROR(expr)
std::string observed_issue
std::string screenshot_path
std::string timestamp_display
std::string category_label
std::vector< zelda3::ObjectDrawer::TileTrace > writes
std::array< gfx::Bitmap *, 2 > bitmaps
~ScopedBitmapRetirement()
Represents a group of palettes.
Modern project structure with comprehensive settings consolidation.
bool project_opened() const
std::string GetDisplayName() const
Represents a door in a dungeon room.
std::tuple< int, int, int, int > GetEditorBounds() const
Get editor interaction bounds (x, y, width, height in pixels)
std::tuple< int, int, int, int > GetBounds() const
Get bounding rectangle (x, y, width, height in pixels)
uint8_t byte1
Original ROM byte 1 (position data)
DoorDimensions GetDimensions() const
Get door dimensions in tiles.
DoorType type
Door type (determines appearance/behavior)
std::pair< uint8_t, uint8_t > EncodeBytes() const
Encode door data for ROM storage.
DoorDirection direction
Which wall the door is on.
DoorDimensions GetEditorDimensions() const
Get editor interaction dimensions in tiles.
uint8_t position
Encoded position (5-bit, 0-31)
std::pair< int, int > GetPixelCoords() const
Get pixel coordinates for this door.
uint8_t byte2
Original ROM byte 2 (type + direction)
std::pair< int, int > GetTileCoords() const
Get tile coordinates for this door.