yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
palette_editor_catalog.cc
Go to the documentation of this file.
2
5#include "core/project.h"
6#include "util/i18n/tr.h"
7
8namespace yaze::editor {
9
11 const auto* owner = project();
12 const std::string path = owner ? owner->palette_catalog_file : "";
13 const std::string descriptor = owner ? owner->filepath : "";
14 if (owner != catalog_project_ || path != catalog_path_ ||
15 descriptor != catalog_project_file_ ||
18}
19
21 // Clear first: missing/invalid metadata cannot retain a prior session's names.
22 palette_catalog_.reset();
23 catalog_query_[0] = '\0';
25 catalog_use_ = 0;
30 if (catalog_path_.empty()) {
31 catalog_status_ = absl::FailedPreconditionError(
32 "No palette catalog is attached to this project.");
33 } else {
36 catalog_status_ = loaded.status();
37 if (loaded.ok())
38 palette_catalog_ = std::move(*loaded);
39 }
40 return catalog_status_;
41}
42
44 if (ImGui::Button(tr("Reload catalog")))
46 gui::AutoRegisterLastItem("button", "Reload palette catalog");
47 ImGui::SameLine();
48 ImGui::TextDisabled(tr("Project reference"));
49 if (!catalog_status_.ok()) {
50 ImGui::TextWrapped("%s", std::string(catalog_status_.message()).c_str());
51 return;
52 }
54 return;
55
56 ImGui::SetNextItemWidth(-1);
57 ImGui::InputTextWithHint("##PaletteCatalogSearch",
58 tr("Search names, sprites or sources"),
60 static constexpr const char* worlds[] = {
61 "", "light_world", "dark_world", "underworld", "special", "shared"};
62 static constexpr const char* uses[] = {"", "link_items", "npcs",
63 "enemies", "bosses", "environment",
64 "hud", "effects", "mixed"};
65 const float width = ImGui::GetContentRegionAvail().x;
66 ImGui::SetNextItemWidth(width * 0.48f);
67 ImGui::Combo(
68 "World##PaletteCatalog", &catalog_world_,
69 "All worlds\0Light World\0Dark World\0Underworld\0Special\0Shared\0");
70 ImGui::SetNextItemWidth(width * 0.48f);
71 ImGui::Combo(
72 "Use##PaletteCatalog", &catalog_use_,
73 "All uses\0Link and "
74 "items\0NPCs\0Enemies\0Bosses\0Environment\0HUD\0Effects\0Mixed\0");
75 const auto entries = palette_catalog_->Filter(
77 ImGui::TextDisabled(tr("%zu palette entries"), entries.size());
78 ImGui::BeginChild("PaletteCatalogEntries");
79 for (const auto* entry : entries) {
80 ImGui::PushID(entry->key.c_str());
81 if (ImGui::CollapsingHeader(entry->name.c_str())) {
82 ImGui::Text("%s[%d] | %s | %s", entry->group.c_str(), entry->index,
83 entry->world.c_str(), entry->use.c_str());
84 ImGui::TextWrapped("%s", entry->description.c_str());
85 if (entry->ownership == "asm")
86 ImGui::TextWrapped(
87 tr("Source-owned colors: a ROM palette edit may be replaced by the "
88 "next game build."));
89 ImGui::TextWrapped(tr("Provenance: %s"), entry->provenance.c_str());
90 for (const auto& usage : entry->usages) {
91 ImGui::Separator();
92 ImGui::Text("%s | OBJ row %d | %s", usage.name.c_str(),
93 usage.obj_row, usage.use.c_str());
94 ImGui::TextWrapped(tr("Context: %s"), usage.context.c_str());
95 ImGui::TextUnformatted(tr("Sprite sheet values / Yaze gfx indices:"));
96 for (const int sheet : usage.sprite_sheets) {
97 ImGui::BulletText("$%02X / $%02X", sheet, sheet + 0x73);
98 }
99 ImGui::TextWrapped(tr("Source: %s"), usage.source.c_str());
100 }
101 const bool available = GetPanelForGroup(entry->group) != nullptr;
102 ImGui::BeginDisabled(!available || !dependencies_.window_manager);
103 if (ImGui::Button(tr("Open palette"))) {
104 JumpToPalette(entry->group, entry->index);
105 show_catalog_ = false;
106 }
107 gui::AutoRegisterLastItem("button", "Open catalog palette");
108 ImGui::EndDisabled();
109 if (!available)
110 ImGui::TextDisabled(tr("This palette group has no editing panel."));
111 }
112 ImGui::PopID();
113 }
114 ImGui::EndChild();
115}
116} // namespace yaze::editor
static absl::StatusOr< PaletteCatalog > LoadForProject(const std::string &project_file, const std::string &catalog_file)
project::YazeProject * project() const
Definition editor.h:358
EditorDependencies dependencies_
Definition editor.h:370
std::optional< core::PaletteCatalog > palette_catalog_
const project::YazeProject * catalog_project_
PaletteGroupPanel * GetPanelForGroup(const std::string &group_name)
void JumpToPalette(const std::string &group_name, int palette_index)
Jump to a specific palette by group and index.
Editors are the view controllers for the application.
void AutoRegisterLastItem(const std::string &widget_type, const std::string &explicit_label, const std::string &description)
Automatically register the last ImGui item.
WorkspaceWindowManager * window_manager
Definition editor.h:182
std::string palette_catalog_file
Definition project.h:339
Automatic widget registration helpers for ImGui Test Engine integration.