Remove items in use; drop Remove Unused
Every content window's Remove (the Delete key) takes the selection out with
what refers to it: a layer's or null's tracks in every animation, a
spritesheet's plain layers (and regions), an event or sound from its triggers
(dropping triggers left with neither), a shader or region from its frames
(which keep the region's rectangle), and a library's layers, flattened into
plain ones. When anything is in use it asks first, listing what goes ("This
will remove:" ... "Are you sure?"). Remove Unused is gone; Remove takes its
place in each footer.
One reference walk (model.cpp) counts uses and finds unused items, so
shaders on null and root frames count, and an animation layer's unused
spritesheet doesn't. Flattening can be limited to some layers, merging only
their children's triggers, which now record the layer they fired through.
edit::content_remove does the removal; Document::spritesheet_path_resolver_get
is shared with saving.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c9d68781d0
commit
065dd522f3
22 files changed
+475
-224
No files matched your search
+17
-12
@@ -229,22 +229,26 @@ namespace anm2ed
|
||||
return false;
|
||||
}
|
||||
|
||||
// A library's spritesheet path, made relative to this document (for flattening its animation layers).
|
||||
edit::SpritesheetPathGet Document::spritesheet_path_resolver_get() const
|
||||
{
|
||||
return [this](const model::Model& source, const std::filesystem::path& spritesheetPath)
|
||||
{
|
||||
for (const auto& [libraryPath, library] : libraries)
|
||||
if (&library.model == &source)
|
||||
return path::backslash_replace(
|
||||
path::make_relative(document::absolute_path_get(libraryPath.parent_path(), spritesheetPath),
|
||||
std::filesystem::absolute(directory_get())));
|
||||
return spritesheetPath;
|
||||
};
|
||||
}
|
||||
|
||||
// Writes the document; a Rebirth document's game copy has its animation layers flattened into plain layers.
|
||||
bool Document::file_write(const std::filesystem::path& path, std::string* errorString, Options options)
|
||||
{
|
||||
std::optional<model::Model> game{};
|
||||
if (!options.isJson && std::ranges::any_of(model.content.layers, &model::Layer::is_animation))
|
||||
game = edit::animation_layers_flatten(
|
||||
model, library_resolver_get(),
|
||||
[&](const model::Model& source, const std::filesystem::path& spritesheetPath)
|
||||
{
|
||||
for (const auto& [libraryPath, library] : libraries)
|
||||
if (&library.model == &source)
|
||||
return path::backslash_replace(
|
||||
path::make_relative(document::absolute_path_get(libraryPath.parent_path(), spritesheetPath),
|
||||
std::filesystem::absolute(directory_get())));
|
||||
return spritesheetPath;
|
||||
});
|
||||
game = edit::animation_layers_flatten(model, library_resolver_get(), spritesheet_path_resolver_get());
|
||||
options.gameModel = game ? &*game : nullptr;
|
||||
return model::model_save(model, path, errorString, options);
|
||||
}
|
||||
@@ -571,7 +575,8 @@ namespace anm2ed
|
||||
int index) const
|
||||
{
|
||||
std::vector<const resource::AudioData*> result{};
|
||||
for (const auto& [source, trigger] : model::animation_triggers_get(model, animation, time, library_resolver_get()))
|
||||
for (const auto& [source, trigger, layerId] :
|
||||
model::animation_triggers_get(model, animation, time, library_resolver_get()))
|
||||
{
|
||||
if (trigger.soundIds.empty()) continue;
|
||||
auto count = trigger.soundIds.size();
|
||||
|
||||
Reference in new issue
Block a user