24 std::copy(binding->sheets.begin(), binding->sheets.end(),
current_sheets_);
34 const std::array<uint8_t, 8>& sheets,
35 const std::array<project::SpritePaletteBinding, 8>& rows) {
37 return absl::FailedPreconditionError(
"Select a sprite asset");
39 updated.sheets = sheets;
40 updated.palette_rows = rows;
41 auto validation = updated;
42 if (validation.zsm_path.empty())
43 validation.zsm_path =
"unsaved.zsm";
47 return parsed.status();
53 return absl::OkStatus();
58 std::filesystem::absolute(path).lexically_normal().string();
74 return absl::OkStatus();
82 return absl::FailedPreconditionError(
"Select a sprite asset");
84 std::filesystem::absolute(path).lexically_normal().string();
94 if (!loaded.ok() && result.ok())
106 if (!asset || asset->source_path.empty()) {
115 {
"draw", asset->source_path, asset->source_label, asset->draw_adapter});
119 asset->source_sha256)
121 "Draw source changed since import. Edited asset preserved; review "
130 return absl::FailedPreconditionError(
"Select a sprite asset");
145 if (!current || !ImGui::CollapsingHeader(
"Asset bindings"))
148 "Save the ZSM, then save the project to retain these bindings.");
149 if (!current->catalog_key.empty())
150 ImGui::TextWrapped(
"Catalog: %s", current->catalog_key.c_str());
151 if (!current->source_path.empty()) {
152 ImGui::TextWrapped(
"Source: %s : %s", current->source_path.c_str(),
153 current->source_label.c_str());
154 ImGui::TextWrapped(
"Adapter: %s", current->draw_adapter.c_str());
155 if (ImGui::Button(
"Check source hash"))
159 ?
"Source matched at last check"
162 constexpr const char* groups[] = {
"auto",
"global_sprites",
"sprites_aux1",
163 "sprites_aux2",
"sprites_aux3"};
164 auto rows = current->palette_rows;
165 bool changed =
false;
166 for (
int i = 0; i < 8; ++i) {
168 ImGui::Text(
"OAM palette %d", i);
170 for (
int j = 0; j < 5; ++j)
171 if (rows[i].group == groups[j])
173 if (ImGui::Combo(
"Group", &group, groups, 5)) {
174 rows[i].group = groups[group];
177 if (rows[i].group !=
"auto" &&
178 ImGui::InputInt(
"Palette index", &rows[i].index)) {
179 rows[i].index = std::clamp(rows[i].index, 0, 255);
project::YazeProject * project() const
absl::Status OpenSpriteAsset(const std::string &path)
int current_custom_sprite_index_
std::vector< project::SpriteAssetBinding > custom_sprite_bindings_
absl::Status ReloadProjectSpriteAssets()
void DrawSpriteAssetBindings()
const zsprite::ZSprite * current_custom_sprite() const
absl::Status source_check_status_
void BeginUndoTransaction()
absl::StatusOr< std::string > ExportCurrentSpriteDraw()
bool preview_needs_update_
void LoadZsmFile(const std::string &path)
void ApplyCurrentSpriteBinding()
absl::Status palette_binding_status_
std::string behavior_candidate_
uint8_t current_sheets_[8]
absl::Status SaveSpriteAsset(const std::string &path)
std::vector< zsprite::ZSprite > custom_sprites_
int current_animation_index_
const project::SpriteAssetBinding * current_sprite_binding() const
absl::Status behavior_status_
void SaveZsmFile(const std::string &path)
void CommitUndoTransaction()
absl::Status graphics_binding_status_
absl::Status CheckCurrentSpriteSource()
std::vector< std::string > custom_sprite_paths_
absl::Status SetSpriteGraphics(const std::array< uint8_t, 8 > &sheets, const std::array< project::SpritePaletteBinding, 8 > &rows)
std::string ComputeSourceArtifactSha256(std::string_view content)
absl::StatusOr< std::string > ExportDrawTables(const zsprite::ZSprite &sprite)
absl::Status ValidateDrawAdapter(const zsprite::ZSprite &sprite, const std::string &adapter)
Editors are the view controllers for the application.
nlohmann::json SpriteAssetToJson(const SpriteAssetBinding &asset)
absl::StatusOr< SpriteAssetBinding > SpriteAssetFromJson(const nlohmann::json &value)
absl::StatusOr< SpriteSourceDocument > ReadSpriteSource(const std::string &source_root, const SpriteSourceBinding &binding)
#define RETURN_IF_ERROR(expr)
std::vector< SpriteAssetBinding > sprite_assets
std::string GetAbsolutePath(const std::string &relative_path) const