14 const std::string& catalog_key) {
15 if (binding.
role !=
"draw")
16 return absl::InvalidArgumentError(
"Only draw bindings can be imported");
21 return frames.status();
24 asset.catalog_key = catalog_key;
25 asset.draw_adapter = binding.
adapter;
26 asset.source_path = binding.
path;
27 asset.source_label = binding.
label;
33 sprite.sprName = binding.
label +
" (draw copy)";
34 sprite.userRoutines.emplace_back(
35 "Import provenance",
"; Draw-data copy from " + binding.
path +
" : " +
37 "\n; Source ASM remains authoritative. Graphics "
38 "and timing require authoring.\n");
39 sprite.editor.Frames = std::move(*frames);
40 sprite.animations.clear();
41 sprite.animations.emplace_back(0, sprite.editor.Frames.size() - 1, 6,
42 "Preview (author timing)");
46 visible.push_back(
"sprite.custom_editor");
50 return absl::OkStatus();
60 const std::string path =
61 owner && !owner->sprite_catalog_file.empty()
62 ? owner->GetAbsolutePath(owner->sprite_catalog_file)
64 const std::string root =
65 owner && !owner->sprite_source_root.empty()
66 ? owner->GetAbsolutePath(owner->sprite_source_root)
96 "Choose a sprite catalog for this project.");
120 ImGui::TextUnformatted(tr(
"Sprite Catalog — read-only"));
123 tr(
"Open a Yaze project to browse its custom sprite catalog."));
126 if (ImGui::Button(tr(
"Choose catalog..."))) {
128 {{{
"Sprite catalog",
"json"}}});
135 if (ImGui::Button(tr(
"Choose source root..."))) {
143 if (ImGui::Button(tr(
"Reload catalog")))
146 tr(
"Save the project to retain these paths. Source files and ROM data "
147 "are not changed."));
148 ImGui::TextWrapped(
"%s: %s", tr(
"Catalog"),
catalog_path_.c_str());
159 for (
size_t i = 0; i < families.size(); ++i) {
160 const auto& family = families[i];
163 for (
const auto& variant : family.variants) {
169 ImGui::PushID(family.key.c_str());
170 if (ImGui::Selectable(family.name.c_str(),
178 ImGui::TextDisabled(
"$%02X", family.main_id);
183 ImGui::Text(
"%s ($%02X)", family.name.c_str(), family.main_id);
184 for (
const auto& variant : family.variants) {
185 ImGui::PushID(variant.key.c_str());
186 if (ImGui::Selectable(variant.name.c_str(),
193 ImGui::TextDisabled(
"$%02X", variant.authored_subtype);
196 if (ImGui::InputInt(tr(
"Inspect raw subtype (decimal)"),
204 ImGui::Text(
"%s: %s", tr(
"Resolved variant"), result.variant->name.c_str());
205 ImGui::TextWrapped(
"%s", result.explanation.c_str());
207 tr(
"Preview unavailable in catalog. Import literal draw tables to edit a "
208 "copy in Custom Sprites. Select "
209 "the correct graphics sheets there; catalog graphics are not bound."));
211 tr(
"Source remains read-only. Placement and runtime generation are "
215 [
this, &result](
const std::vector<zelda3::SpriteSourceBinding>& sources) {
216 for (
const auto& binding : sources) {
217 ImGui::PushID(binding.role.c_str());
218 if (ImGui::SmallButton(tr(
"View source")))
220 if (binding.role ==
"draw") {
222 if (ImGui::SmallButton(tr(
"Import draw copy"))) {
224 binding, result.variant ? result.variant->key :
"");
228 ImGui::TextWrapped(
"%s: %s — %s", binding.role.c_str(),
229 binding.label.c_str(), binding.path.c_str());
233 ImGui::PushID(
"family_sources");
234 draw_bindings(family.sources);
236 if (result.variant) {
237 ImGui::PushID(
"variant_sources");
238 draw_bindings(result.variant->sources);
247 if (ImGui::BeginChild(
"CatalogSource", ImVec2(0, 0),
true,
248 ImGuiWindowFlags_HorizontalScrollbar)) {
251 ImGui::GetTextLineHeightWithSpacing());
254 ImGuiListClipper clipper;
256 while (clipper.Step()) {
257 for (
int line = clipper.DisplayStart; line < clipper.DisplayEnd;
259 ImGui::Text(
"%s %5d %s",
project::YazeProject * project() const
virtual void SetDependencies(const EditorDependencies &deps)
EditorDependencies dependencies_
std::string catalog_source_root_
std::vector< project::SpriteAssetBinding > custom_sprite_bindings_
std::optional< zelda3::SpriteSourceDocument > catalog_source_
std::optional< zelda3::SpriteCatalog > sprite_catalog_
absl::Status source_check_status_
std::string catalog_path_
absl::Status ImportCatalogDraw(const zelda3::SpriteSourceBinding &binding, const std::string &catalog_key="")
void RefreshCatalogIfChanged()
bool catalog_scroll_to_label_
std::vector< zsprite::ZSprite > custom_sprites_
absl::Status ReloadSpriteCatalog()
size_t catalog_session_id_
absl::Status catalog_status_
void SetDependencies(const EditorDependencies &deps) override
absl::Status catalog_source_status_
const project::YazeProject * catalog_project_
absl::Status OpenCatalogSource(const zelda3::SpriteSourceBinding &binding)
ImGuiTextFilter catalog_filter_
int catalog_family_index_
void SetVisibleWindows(size_t session_id, const std::vector< std::string > &window_ids)
Set which panels should be visible for a session.
std::vector< std::string > GetVisibleWindowIds(size_t session_id) const
Get list of currently visible panel IDs for a session.
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
static std::string ShowOpenFolderDialog()
ShowOpenFolderDialog opens a file dialog and returns the selected folder path. Uses global feature fl...
static absl::StatusOr< SpriteCatalog > Load(const std::string &path)
std::string ComputeSourceArtifactSha256(std::string_view content)
absl::StatusOr< std::vector< zsprite::Frame > > ImportDrawAsset(const std::vector< std::string > &lines, size_t first_line, const std::string &adapter)
Editors are the view controllers for the application.
absl::StatusOr< SpriteSourceDocument > ReadSpriteSource(const std::string &source_root, const SpriteSourceBinding &binding)
#define RETURN_IF_ERROR(expr)
Unified dependency container for all editor types.
WorkspaceWindowManager * window_manager
std::string sprite_catalog_file
std::string GetAbsolutePath(const std::string &relative_path) const
std::string sprite_source_root