Stage 6: Document::change() always refreshes derived data; ChangeType removed
change() now flushes drafts, re-syncs assets and shaders, rebuilds every label list and the uid index, and commits. Document::ChangeType, the switch in change(), the type parameter of edit_apply/edit_run/edit_push/assets_sync, Window::changeType and every per-call change type (about 40 sites) are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9f43a210c5
commit
2d0f70b1e5
25 files changed
+128
-202
No files matched your search
+26
-56
@@ -191,7 +191,7 @@ namespace anm2ed
|
||||
this->path = path;
|
||||
isValid = anm2.isValid;
|
||||
clean();
|
||||
change(Document::ALL);
|
||||
change();
|
||||
}
|
||||
|
||||
Document::Document(Document&& other) noexcept : DocumentData(std::move(other)), editTarget(other.editTarget) {}
|
||||
@@ -251,7 +251,7 @@ namespace anm2ed
|
||||
|
||||
void Document::texture_change(int id)
|
||||
{
|
||||
if (texture_get(id) && anm2.element_get(ElementType::SPRITESHEET, id)) change(SPRITESHEETS);
|
||||
if (texture_get(id) && anm2.element_get(ElementType::SPRITESHEET, id)) change();
|
||||
}
|
||||
|
||||
bool Document::texture_reload(int id)
|
||||
@@ -321,17 +321,14 @@ namespace anm2ed
|
||||
return true;
|
||||
}
|
||||
|
||||
void Document::assets_sync(ChangeType type)
|
||||
void Document::assets_sync()
|
||||
{
|
||||
if (type == ALL || type == SPRITESHEETS || type == TEXTURES)
|
||||
document::resources_sync(*this, ElementType::SPRITESHEET, textures, texturePaths,
|
||||
[&](int id, const std::filesystem::path& path)
|
||||
{ texture_set(id, resource::Image(path)); });
|
||||
if (type == ALL || type == SOUNDS)
|
||||
document::resources_sync(*this, ElementType::SOUND_ELEMENT, sounds, soundPaths,
|
||||
[&](int id, const std::filesystem::path& path)
|
||||
{ sound_set(id, resource::AudioData(path)); });
|
||||
if (type != ALL && type != SHADERS) return;
|
||||
document::resources_sync(*this, ElementType::SPRITESHEET, textures, texturePaths,
|
||||
[&](int id, const std::filesystem::path& path)
|
||||
{ texture_set(id, resource::Image(path)); });
|
||||
document::resources_sync(*this, ElementType::SOUND_ELEMENT, sounds, soundPaths,
|
||||
[&](int id, const std::filesystem::path& path)
|
||||
{ sound_set(id, resource::AudioData(path)); });
|
||||
|
||||
std::set<int> validShaderIds{};
|
||||
util::WorkingDirectory workingDirectory(directory_get());
|
||||
@@ -513,7 +510,7 @@ namespace anm2ed
|
||||
for (auto& region : spritesheet->children)
|
||||
if (region.type == ElementType::REGION && crops.contains(region.id)) region.crop = crops.at(region.id);
|
||||
|
||||
assets_sync(SPRITESHEETS);
|
||||
assets_sync();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -595,7 +592,7 @@ namespace anm2ed
|
||||
textures.erase(id);
|
||||
}
|
||||
|
||||
assets_sync(ALL);
|
||||
assets_sync();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -636,12 +633,13 @@ namespace anm2ed
|
||||
std::erase_if(spritesheetSaveHashes, is_invalid);
|
||||
}
|
||||
|
||||
void Document::change(ChangeType type)
|
||||
// Commits the pending edit and rebuilds everything derived from the model.
|
||||
void Document::change()
|
||||
{
|
||||
for (auto& [id, draft] : std::exchange(textureDrafts, {}))
|
||||
textures[id] = assets.image_add(std::move(draft));
|
||||
hash_set();
|
||||
assets_sync(type);
|
||||
assets_sync();
|
||||
|
||||
auto events_set = [&]()
|
||||
{
|
||||
@@ -688,39 +686,11 @@ namespace anm2ed
|
||||
document::element_name_get);
|
||||
};
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EVENTS:
|
||||
events_set();
|
||||
break;
|
||||
case SPRITESHEETS:
|
||||
spritesheets_set();
|
||||
regions_set();
|
||||
break;
|
||||
case SHADERS:
|
||||
shaders_set();
|
||||
break;
|
||||
case SOUNDS:
|
||||
sounds_set();
|
||||
break;
|
||||
case FRAMES:
|
||||
events_set();
|
||||
sounds_set();
|
||||
break;
|
||||
case ITEMS:
|
||||
spritesheets_set();
|
||||
break;
|
||||
case ANIMATIONS:
|
||||
case ALL:
|
||||
events_set();
|
||||
spritesheets_set();
|
||||
regions_set();
|
||||
shaders_set();
|
||||
sounds_set();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
events_set();
|
||||
spritesheets_set();
|
||||
regions_set();
|
||||
shaders_set();
|
||||
sounds_set();
|
||||
|
||||
snapshots.commit();
|
||||
index = UidIndex(anm2);
|
||||
@@ -728,11 +698,11 @@ namespace anm2ed
|
||||
|
||||
void Document::edit_begin(StringType label) { snapshots.push(localize.get(label)); }
|
||||
|
||||
edit::Uids Document::edit_run(StringType label, ChangeType type, const std::function<edit::Uids(Anm2&)>& operation)
|
||||
edit::Uids Document::edit_run(StringType label, const std::function<edit::Uids(Anm2&)>& operation)
|
||||
{
|
||||
edit_begin(label);
|
||||
auto uids = operation(anm2);
|
||||
change(type);
|
||||
change();
|
||||
return uids;
|
||||
}
|
||||
|
||||
@@ -752,7 +722,7 @@ namespace anm2ed
|
||||
{
|
||||
auto spritesheet = anm2.element_get(ElementType::SPRITESHEET, id);
|
||||
if (!spritesheet) return;
|
||||
assets_sync(TEXTURES);
|
||||
assets_sync();
|
||||
spritesheetHashes[id] = document::spritesheet_hash_get(*spritesheet, textures.contains(id) ? textures.at(id) : 0);
|
||||
}
|
||||
|
||||
@@ -936,7 +906,7 @@ namespace anm2ed
|
||||
toast_log(Level::INFO, TOAST_SPRITESHEET_INITIALIZED, element.id, path::to_utf8(element.path));
|
||||
}
|
||||
spritesheet.selection = added;
|
||||
change(Document::SPRITESHEETS);
|
||||
change();
|
||||
}
|
||||
|
||||
void Document::sounds_add(const std::vector<std::filesystem::path>& paths)
|
||||
@@ -961,7 +931,7 @@ namespace anm2ed
|
||||
toast_log(Level::INFO, TOAST_SOUND_INITIALIZED, element.id, path::to_utf8(element.path));
|
||||
}
|
||||
sound.selection = added;
|
||||
change(Document::SOUNDS);
|
||||
change();
|
||||
}
|
||||
|
||||
void Document::undo()
|
||||
@@ -969,7 +939,7 @@ namespace anm2ed
|
||||
if (!snapshots.undo()) return;
|
||||
document::frame_time_sync(*this);
|
||||
toast_log(Level::INFO, TOAST_UNDO, message);
|
||||
change(Document::ALL);
|
||||
change();
|
||||
}
|
||||
|
||||
void Document::redo()
|
||||
@@ -977,7 +947,7 @@ namespace anm2ed
|
||||
if (!snapshots.redo()) return;
|
||||
document::frame_time_sync(*this);
|
||||
toast_log(Level::INFO, TOAST_REDO, message);
|
||||
change(Document::ALL);
|
||||
change();
|
||||
}
|
||||
|
||||
bool Document::is_able_to_undo() { return !snapshots.undoStack.is_empty(); }
|
||||
|
||||
+5
-22
@@ -66,23 +66,6 @@ namespace anm2ed
|
||||
class Document : public DocumentData
|
||||
{
|
||||
public:
|
||||
enum ChangeType
|
||||
{
|
||||
INFO,
|
||||
LAYERS,
|
||||
NULLS,
|
||||
SPRITESHEETS,
|
||||
TEXTURES,
|
||||
SHADERS,
|
||||
EVENTS,
|
||||
ANIMATIONS,
|
||||
ITEMS,
|
||||
FRAMES,
|
||||
SOUNDS,
|
||||
ALL,
|
||||
COUNT
|
||||
};
|
||||
|
||||
enum class FrameReferenceFallback
|
||||
{
|
||||
NONE,
|
||||
@@ -112,7 +95,7 @@ namespace anm2ed
|
||||
Document(Document&&) noexcept;
|
||||
Document& operator=(Document&&) noexcept;
|
||||
bool save(const std::filesystem::path& = {}, std::string* = nullptr, Options = {});
|
||||
void assets_sync(ChangeType = ALL);
|
||||
void assets_sync();
|
||||
void texture_change(int);
|
||||
bool texture_reload(int);
|
||||
bool sound_reload(int);
|
||||
@@ -128,14 +111,14 @@ namespace anm2ed
|
||||
bool spritesheets_merge(const std::set<int>&, bool, bool, bool, origin::Type);
|
||||
void hash_set();
|
||||
void clean();
|
||||
void change(ChangeType);
|
||||
void change();
|
||||
void edit_begin(StringType);
|
||||
edit::Uids edit_run(StringType, ChangeType, const std::function<edit::Uids(Anm2&)>&);
|
||||
edit::Uids edit_run(StringType, const std::function<edit::Uids(Anm2&)>&);
|
||||
|
||||
// Snapshots for undo, runs the operation on the model, then commits; void operations select nothing.
|
||||
template <class Operation> edit::Uids edit_apply(StringType label, ChangeType type, Operation&& operation)
|
||||
template <class Operation> edit::Uids edit_apply(StringType label, Operation&& operation)
|
||||
{
|
||||
return edit_run(label, type,
|
||||
return edit_run(label,
|
||||
[&](Anm2& anm2) -> edit::Uids
|
||||
{
|
||||
if constexpr (std::is_void_v<std::invoke_result_t<Operation&, Anm2&>>)
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
manager.command_push({manager.selected, [paths, preset](Manager&, Document& document)
|
||||
{
|
||||
document.edit_apply(EDIT_MERGE_ANM2, Document::ALL,
|
||||
document.edit_apply(EDIT_MERGE_ANM2,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
for (auto& path : paths)
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace anm2ed::imgui::popup
|
||||
item.isShowRect = queuedAddItemIsShowRect;
|
||||
|
||||
int addId{-1};
|
||||
document.edit_apply(EDIT_ADD_ITEM, Document::ITEMS,
|
||||
document.edit_apply(EDIT_ADD_ITEM,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
addId = anm2.item_add((ItemType)queuedType, queuedAnimationIndex,
|
||||
|
||||
@@ -170,11 +170,9 @@ namespace anm2ed::imgui
|
||||
|
||||
if (ImGui::MenuItem(localize.get(LABEL_SCAN_AND_SET_REGIONS), nullptr, false, document && hasRegions))
|
||||
{
|
||||
manager.command_push({manager.selected, [](Manager&, Document& document)
|
||||
{
|
||||
document.edit_apply(EDIT_SCAN_AND_SET_REGIONS, Document::FRAMES,
|
||||
[](Anm2& anm2) { anm2.regions_scan(); });
|
||||
}});
|
||||
manager.command_push(
|
||||
{manager.selected, [](Manager&, Document& document)
|
||||
{ document.edit_apply(EDIT_SCAN_AND_SET_REGIONS, [](Anm2& anm2) { anm2.regions_scan(); }); }});
|
||||
toast_log(Level::INFO, TOAST_SCAN_AND_SET_REGIONS);
|
||||
}
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_WIZARD_SCAN_AND_SET_REGIONS));
|
||||
@@ -286,8 +284,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
if (queuedAnimationIndices.empty()) return;
|
||||
document.edit_apply(
|
||||
EDIT_GENERATE_REGIONS_FROM_ANIMATIONS,
|
||||
queuedMapping == RegionFrameMapping::SET ? Document::ALL : Document::SPRITESHEETS, [&](Anm2& anm2)
|
||||
EDIT_GENERATE_REGIONS_FROM_ANIMATIONS, [&](Anm2& anm2)
|
||||
{ anm2.regions_generate(queuedAnimationIndices, {}, queuedFormat, queuedMapping); });
|
||||
}});
|
||||
generateRegionsPopup.close();
|
||||
|
||||
@@ -1353,10 +1353,7 @@ namespace anm2ed::imgui
|
||||
frame_change_apply({.shearX = shear.x - frame->shear.x, .shearY = shear.y - frame->shear.y}, ChangeType::ADD);
|
||||
};
|
||||
auto frames_changed = [&]()
|
||||
{
|
||||
manager.command_push(
|
||||
{manager.selected, [](Manager&, Document& document) { document.change(Document::FRAMES); }});
|
||||
};
|
||||
{ manager.command_push({manager.selected, [](Manager&, Document& document) { document.change(); }}); };
|
||||
auto null_rect_change = [&](vec2 topLeft, vec2 rectSize)
|
||||
{
|
||||
topLeft = vec2(ivec2(topLeft));
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace anm2ed::imgui
|
||||
void animations_erase(Window& window, Document& document, const std::set<int>& indices, const std::set<int>& groupIds,
|
||||
StringType label)
|
||||
{
|
||||
document.edit_apply(label, window.changeType,
|
||||
document.edit_apply(label,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
animation_overlay_reset(document, indices);
|
||||
@@ -187,7 +187,7 @@ namespace anm2ed::imgui
|
||||
std::set<int> groupIds{};
|
||||
std::string errorString{};
|
||||
auto uids = document.edit_apply(
|
||||
edit, window.changeType,
|
||||
edit,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
auto uids = edit::animations_paste(anm2, text, start, targetGroupId, groupIds, &errorString);
|
||||
@@ -231,7 +231,7 @@ namespace anm2ed::imgui
|
||||
return -1;
|
||||
|
||||
int merged{-1};
|
||||
document.edit_apply(EDIT_MERGE_ANIMATIONS, Document::ANIMATIONS,
|
||||
document.edit_apply(EDIT_MERGE_ANIMATIONS,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
animation_overlay_reset(document, sources);
|
||||
@@ -276,7 +276,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto animations = window_container_get(window, document);
|
||||
if (!animations) return;
|
||||
document.edit_apply(EDIT_MOVE_ANIMATIONS, window.changeType,
|
||||
document.edit_apply(EDIT_MOVE_ANIMATIONS,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
animation_items_move(window, document, anm2, items,
|
||||
@@ -382,7 +382,7 @@ namespace anm2ed::imgui
|
||||
if (!group || (name.value_or(group->name) == group->name &&
|
||||
isExpanded.value_or(group->isExpanded) == group->isExpanded))
|
||||
return;
|
||||
document.edit_apply(edit, Document::ANIMATIONS,
|
||||
document.edit_apply(edit,
|
||||
[&](Anm2&)
|
||||
{
|
||||
group->name = name.value_or(group->name);
|
||||
@@ -475,7 +475,6 @@ namespace anm2ed::imgui
|
||||
Window window{};
|
||||
window.title = LABEL_ANIMATIONS_WINDOW;
|
||||
window.isOpen = &Settings::windowIsAnimations;
|
||||
window.changeType = Document::ANIMATIONS;
|
||||
window.containerType = ElementType::ANIMATIONS;
|
||||
window.elementType = ElementType::ANIMATION;
|
||||
window.childLabel = "##Animations Child";
|
||||
@@ -600,7 +599,7 @@ namespace anm2ed::imgui
|
||||
: selected && groupIds.contains(selected->groupId) ? selected->groupId
|
||||
: -1;
|
||||
|
||||
document.edit_apply(EDIT_ADD_ANIMATION, window.changeType,
|
||||
document.edit_apply(EDIT_ADD_ANIMATION,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
auto uids =
|
||||
@@ -693,7 +692,7 @@ namespace anm2ed::imgui
|
||||
|
||||
std::set<int> targetSet(targetIndices.begin(), targetIndices.end());
|
||||
auto groupId = element_child_next_id_get(*animations, ElementType::GROUP);
|
||||
document.edit_apply(EDIT_GROUP_ITEMS, window.changeType,
|
||||
document.edit_apply(EDIT_GROUP_ITEMS,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
auto uids = edit::animations_group(anm2, targetSet, localize.get(TEXT_NEW_GROUP));
|
||||
@@ -708,8 +707,7 @@ namespace anm2ed::imgui
|
||||
auto animations = window_container_get(window, document);
|
||||
auto animation = document.anm2.element_get(ElementType::ANIMATION, *document.animation.selection.begin());
|
||||
if (!animations || !animation) return;
|
||||
document.edit_apply(EDIT_DEFAULT_ANIMATION, window.changeType,
|
||||
[&](Anm2&) { animations->defaultAnimation = animation->name; });
|
||||
document.edit_apply(EDIT_DEFAULT_ANIMATION, [&](Anm2&) { animations->defaultAnimation = animation->name; });
|
||||
};
|
||||
window.body_update =
|
||||
[](Window& window, Manager& manager, Settings& settings, Resources&, Clipboard&, Document& document)
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace anm2ed::imgui
|
||||
queuedReference.groupId});
|
||||
if (state == edit_state::START || state == edit_state::COMPLETE) document.edit_begin(message);
|
||||
behavior(document, *frame, item, queuedReference);
|
||||
if (state == edit_state::END || state == edit_state::COMPLETE) document.change(Document::FRAMES);
|
||||
if (state == edit_state::END || state == edit_state::COMPLETE) document.change();
|
||||
}});
|
||||
};
|
||||
|
||||
|
||||
@@ -43,14 +43,12 @@ namespace anm2ed::imgui
|
||||
popup.end();
|
||||
}
|
||||
|
||||
Window item_window_make(StringType title, bool Settings::* isOpen, Document::ChangeType changeType,
|
||||
ElementType elementType, const char* childLabel, StringType addTooltip,
|
||||
StringType removeUnusedTooltip)
|
||||
Window item_window_make(StringType title, bool Settings::* isOpen, ElementType elementType, const char* childLabel,
|
||||
StringType addTooltip, StringType removeUnusedTooltip)
|
||||
{
|
||||
Window window{};
|
||||
window.title = title;
|
||||
window.isOpen = isOpen;
|
||||
window.changeType = changeType;
|
||||
window.containerType = ELEMENT_CONTAINERS[(int)elementType];
|
||||
window.elementType = elementType;
|
||||
window.childLabel = childLabel;
|
||||
@@ -65,9 +63,8 @@ namespace anm2ed::imgui
|
||||
|
||||
Window layers_window_register()
|
||||
{
|
||||
auto window =
|
||||
item_window_make(LABEL_LAYERS_WINDOW, &Settings::windowIsLayers, Document::LAYERS, ElementType::LAYER_ELEMENT,
|
||||
"##Layers Child", TOOLTIP_ADD_LAYER, TOOLTIP_REMOVE_UNUSED_LAYERS);
|
||||
auto window = item_window_make(LABEL_LAYERS_WINDOW, &Settings::windowIsLayers, ElementType::LAYER_ELEMENT,
|
||||
"##Layers Child", TOOLTIP_ADD_LAYER, TOOLTIP_REMOVE_UNUSED_LAYERS);
|
||||
window.addEdit = EDIT_ADD_LAYER;
|
||||
window.propertiesEdit = EDIT_SET_LAYER_PROPERTIES;
|
||||
window.pasteEdit = EDIT_PASTE_LAYERS;
|
||||
@@ -100,9 +97,8 @@ namespace anm2ed::imgui
|
||||
|
||||
Window nulls_window_register()
|
||||
{
|
||||
auto window =
|
||||
item_window_make(LABEL_NULLS_WINDOW, &Settings::windowIsNulls, Document::NULLS, ElementType::NULL_ELEMENT,
|
||||
"##Nulls Child", TOOLTIP_ADD_NULL, TOOLTIP_REMOVE_UNUSED_NULLS);
|
||||
auto window = item_window_make(LABEL_NULLS_WINDOW, &Settings::windowIsNulls, ElementType::NULL_ELEMENT,
|
||||
"##Nulls Child", TOOLTIP_ADD_NULL, TOOLTIP_REMOVE_UNUSED_NULLS);
|
||||
window.addEdit = EDIT_ADD_NULL;
|
||||
window.propertiesEdit = EDIT_SET_NULL_PROPERTIES;
|
||||
window.pasteEdit = EDIT_PASTE_NULLS;
|
||||
@@ -126,9 +122,8 @@ namespace anm2ed::imgui
|
||||
|
||||
Window events_window_register()
|
||||
{
|
||||
auto window =
|
||||
item_window_make(LABEL_EVENTS_WINDOW, &Settings::windowIsEvents, Document::EVENTS, ElementType::EVENT_ELEMENT,
|
||||
"##Events Child", TOOLTIP_ADD_EVENT, TOOLTIP_REMOVE_UNUSED_EVENTS);
|
||||
auto window = item_window_make(LABEL_EVENTS_WINDOW, &Settings::windowIsEvents, ElementType::EVENT_ELEMENT,
|
||||
"##Events Child", TOOLTIP_ADD_EVENT, TOOLTIP_REMOVE_UNUSED_EVENTS);
|
||||
window.addEdit = EDIT_ADD_EVENT;
|
||||
window.renameEdit = EDIT_RENAME_EVENT;
|
||||
window.pasteEdit = EDIT_PASTE_EVENTS;
|
||||
@@ -143,7 +138,7 @@ namespace anm2ed::imgui
|
||||
event.name = localize.get(TEXT_NEW_EVENT);
|
||||
auto events = window_container_get(window, document);
|
||||
if (!events) return;
|
||||
document.edit_apply(window.addEdit, window.changeType,
|
||||
document.edit_apply(window.addEdit,
|
||||
[&](Anm2&)
|
||||
{
|
||||
event.id = element_child_next_id_get(*events, ElementType::EVENT_ELEMENT);
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace anm2ed::imgui
|
||||
document.region.selection.clear();
|
||||
}
|
||||
}
|
||||
document.change(Document::SPRITESHEETS);
|
||||
document.change();
|
||||
}
|
||||
|
||||
toast_log(Level::INFO, TOAST_EXPORT_REGION, sourceRegion.name, pathString);
|
||||
@@ -218,7 +218,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, spritesheetId);
|
||||
if (!spritesheet) return;
|
||||
document.edit_apply(EDIT_MOVE_REGIONS, window.changeType,
|
||||
document.edit_apply(EDIT_MOVE_REGIONS,
|
||||
[&](Anm2&)
|
||||
{
|
||||
vector::move_indices_to_position(spritesheet->children, indices, targetIndex);
|
||||
@@ -384,7 +384,6 @@ namespace anm2ed::imgui
|
||||
Window window{};
|
||||
window.title = LABEL_REGIONS_WINDOW;
|
||||
window.isOpen = &Settings::windowIsRegions;
|
||||
window.changeType = Document::SPRITESHEETS;
|
||||
window.elementType = ElementType::REGION;
|
||||
window.childLabel = "##Regions Child";
|
||||
window.cardLines = REGION_CARD_LINES;
|
||||
@@ -451,13 +450,13 @@ namespace anm2ed::imgui
|
||||
};
|
||||
window.remove_unused = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
|
||||
{
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_REGIONS, window.changeType, [&](Anm2& anm2)
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_REGIONS, [&](Anm2& anm2)
|
||||
{ return edit::regions_remove_unused(anm2, document.spritesheet.reference); });
|
||||
};
|
||||
window.trim = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
|
||||
{
|
||||
auto& region = document.region;
|
||||
document.edit_apply(EDIT_TRIM_REGIONS, window.changeType,
|
||||
document.edit_apply(EDIT_TRIM_REGIONS,
|
||||
[&](Anm2&)
|
||||
{
|
||||
if (!document.regions_trim(document.spritesheet.reference, region.selection)) return;
|
||||
@@ -473,7 +472,7 @@ namespace anm2ed::imgui
|
||||
if (!spritesheet || clipboard.is_empty()) return;
|
||||
auto maxIdBefore = element_child_max_id_get(*spritesheet, ElementType::REGION);
|
||||
std::string errorString{};
|
||||
document.edit_apply(EDIT_PASTE_REGIONS, window.changeType,
|
||||
document.edit_apply(EDIT_PASTE_REGIONS,
|
||||
[&](Anm2& anm2)
|
||||
{
|
||||
edit::regions_paste(anm2, document.spritesheet.reference, clipboard.get(),
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace anm2ed::imgui
|
||||
if (shader)
|
||||
{
|
||||
shader->*member = path::backslash_replace(value);
|
||||
document.change(Document::SHADERS);
|
||||
document.change();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace anm2ed::imgui
|
||||
void shader_uniform_config_save(Document& document, Element& shaderElement, const resource::shader::Uniform& uniform)
|
||||
{
|
||||
resource::shader::uniform_config_save(shaderElement, uniform);
|
||||
document.change(Document::SHADERS);
|
||||
document.change();
|
||||
}
|
||||
|
||||
void shader_uniform_components_from_value_set(resource::shader::Uniform& uniform)
|
||||
@@ -312,7 +312,7 @@ namespace anm2ed::imgui
|
||||
shader.id = element_child_next_id_get(*shaders, ElementType::SHADER);
|
||||
shader.name = localize.get(TEXT_NEW_SHADER);
|
||||
|
||||
document.edit_apply(EDIT_ADD_SHADER, Document::SHADERS,
|
||||
document.edit_apply(EDIT_ADD_SHADER,
|
||||
[&](Anm2&)
|
||||
{
|
||||
shaders->children.push_back(shader);
|
||||
@@ -332,7 +332,7 @@ namespace anm2ed::imgui
|
||||
auto unused = document.anm2.element_unused(ElementType::SHADER);
|
||||
if (unused.empty()) return;
|
||||
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_SHADERS, Document::SHADERS,
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_SHADERS,
|
||||
[&](Anm2&)
|
||||
{
|
||||
for (auto id : unused)
|
||||
@@ -506,7 +506,7 @@ namespace anm2ed::imgui
|
||||
if (ImGui::BeginChild("##Shader Properties Child", popupSize))
|
||||
{
|
||||
if (propertiesPopup.isJustOpened) ImGui::SetKeyboardFocusHere();
|
||||
if (input_text_string(localize.get(BASIC_NAME), &shader->name)) document->change(Document::SHADERS);
|
||||
if (input_text_string(localize.get(BASIC_NAME), &shader->name)) document->change();
|
||||
|
||||
ImGui::SeparatorText(localize.get(LABEL_FILES));
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace anm2ed::imgui
|
||||
Window window{};
|
||||
window.title = LABEL_SOUNDS_WINDOW;
|
||||
window.isOpen = &Settings::windowIsSounds;
|
||||
window.changeType = Document::SOUNDS;
|
||||
window.containerType = ElementType::SOUNDS;
|
||||
window.elementType = ElementType::SOUND_ELEMENT;
|
||||
window.childLabel = "##Sounds Child";
|
||||
@@ -83,7 +82,7 @@ namespace anm2ed::imgui
|
||||
};
|
||||
window.reload = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
|
||||
{
|
||||
document.edit_apply(EDIT_RELOAD_SOUNDS, window.changeType,
|
||||
document.edit_apply(EDIT_RELOAD_SOUNDS,
|
||||
[&](Anm2&)
|
||||
{
|
||||
for (auto id : document.sound.selection)
|
||||
@@ -115,7 +114,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto sound = window_element_get(window, document, id);
|
||||
if (!sound) return;
|
||||
document.edit_apply(EDIT_REPLACE_SOUND, window.changeType,
|
||||
document.edit_apply(EDIT_REPLACE_SOUND,
|
||||
[&](Anm2&)
|
||||
{
|
||||
sound->path = window_asset_path_get(document, dialogPath);
|
||||
|
||||
@@ -364,11 +364,8 @@ namespace anm2ed::imgui
|
||||
manager.command_push(
|
||||
{manager.selected, [label](Manager&, Document& document) { document.edit_begin(label); }});
|
||||
};
|
||||
auto document_change_push = [&](Document::ChangeType changeType)
|
||||
{
|
||||
manager.command_push(
|
||||
{manager.selected, [changeType](Manager&, Document& document) { document.change(changeType); }});
|
||||
};
|
||||
auto document_change_push = [&]()
|
||||
{ manager.command_push({manager.selected, [](Manager&, Document& document) { document.change(); }}); };
|
||||
auto frame_change_apply_to = [&](const std::set<Reference>& frameReferences, FrameChange frameChange,
|
||||
ChangeType changeType = ChangeType::ADJUST)
|
||||
{
|
||||
@@ -651,7 +648,7 @@ namespace anm2ed::imgui
|
||||
change.pivotY = region->pivot.y;
|
||||
}
|
||||
frame_change_apply(change);
|
||||
document_change_push(Document::FRAMES);
|
||||
document_change_push();
|
||||
}
|
||||
}
|
||||
if (isMouseDown || isMouseMiddleDown) pan += mouseDelta;
|
||||
@@ -681,7 +678,7 @@ namespace anm2ed::imgui
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnd) document_change_push(Document::SPRITESHEETS);
|
||||
if (isEnd) document_change_push();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -715,7 +712,7 @@ namespace anm2ed::imgui
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnd) document_change_push(Document::FRAMES);
|
||||
if (isEnd) document_change_push();
|
||||
break;
|
||||
case tool::CROP:
|
||||
if ((isRegionEditTarget || isRegionInUse || selectedFrameToolReferences.empty()) &&
|
||||
@@ -758,7 +755,7 @@ namespace anm2ed::imgui
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnd) document_change_push(Document::SPRITESHEETS);
|
||||
if (isEnd) document_change_push();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -811,7 +808,7 @@ namespace anm2ed::imgui
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
if (isEnd) document_change_push(Document::FRAMES);
|
||||
if (isEnd) document_change_push();
|
||||
break;
|
||||
case tool::DRAW:
|
||||
case tool::ERASE:
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace anm2ed::imgui
|
||||
auto texture = document.texture_get(id);
|
||||
if (!spritesheet || (isWritten && !texture)) return;
|
||||
document.edit_apply(
|
||||
edit, window.changeType,
|
||||
edit,
|
||||
[&](Anm2&)
|
||||
{
|
||||
auto newPath = window_asset_path_get(document, dialogPath);
|
||||
@@ -77,13 +77,13 @@ namespace anm2ed::imgui
|
||||
}});
|
||||
}
|
||||
|
||||
void spritesheet_textures_edit(Document& document, StringType edit, Document::ChangeType changeType,
|
||||
const std::function<bool()>& behavior, StringType successToast, StringType failToast)
|
||||
void spritesheet_textures_edit(Document& document, StringType edit, const std::function<bool()>& behavior,
|
||||
StringType successToast, StringType failToast)
|
||||
{
|
||||
document.edit_begin(edit);
|
||||
auto isSuccess = behavior();
|
||||
toast_log(isSuccess ? Level::INFO : Level::ERROR, isSuccess ? successToast : failToast);
|
||||
document.change(changeType);
|
||||
document.change();
|
||||
}
|
||||
|
||||
Window spritesheets_window_register()
|
||||
@@ -91,7 +91,6 @@ namespace anm2ed::imgui
|
||||
Window window{};
|
||||
window.title = LABEL_SPRITESHEETS_WINDOW;
|
||||
window.isOpen = &Settings::windowIsSpritesheets;
|
||||
window.changeType = Document::SPRITESHEETS;
|
||||
window.containerType = ElementType::SPRITESHEETS;
|
||||
window.elementType = ElementType::SPRITESHEET;
|
||||
window.childLabel = "##Spritesheets Child";
|
||||
@@ -178,7 +177,7 @@ namespace anm2ed::imgui
|
||||
auto unused = document.anm2.element_unused(ElementType::SPRITESHEET);
|
||||
auto spritesheets = window_container_get(window, document);
|
||||
if (unused.empty() || !spritesheets) return;
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_SPRITESHEETS, window.changeType,
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_SPRITESHEETS,
|
||||
[&](Anm2&)
|
||||
{
|
||||
for (auto id : unused)
|
||||
@@ -192,7 +191,7 @@ namespace anm2ed::imgui
|
||||
window.reload = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
|
||||
{
|
||||
auto selected = document.spritesheet.selection;
|
||||
document.edit_apply(EDIT_RELOAD_SPRITESHEETS, window.changeType,
|
||||
document.edit_apply(EDIT_RELOAD_SPRITESHEETS,
|
||||
[&](Anm2&)
|
||||
{
|
||||
for (auto id : selected)
|
||||
@@ -295,7 +294,7 @@ namespace anm2ed::imgui
|
||||
regionOrigin = (origin::Type)settings.mergeSpritesheetsRegionOrigin](Manager&, Document& document)
|
||||
{
|
||||
spritesheet_textures_edit(
|
||||
document, EDIT_MERGE_SPRITESHEETS, Document::ALL,
|
||||
document, EDIT_MERGE_SPRITESHEETS,
|
||||
[&]()
|
||||
{
|
||||
if (!document.spritesheets_merge(ids, isAppendRight, isMakeRegions, isMakePrimaryRegion,
|
||||
@@ -329,14 +328,13 @@ namespace anm2ed::imgui
|
||||
auto result = window_popup_buttons_draw(manager, localize.get(BASIC_PACK),
|
||||
is_spritesheet_regions(document, window.editId), BASIC_CANCEL);
|
||||
if (result == PopupButton::CONFIRM)
|
||||
manager.command_push({manager.selected,
|
||||
[id = window.editId, padding = settings.packPadding](Manager&, Document& document)
|
||||
{
|
||||
spritesheet_textures_edit(
|
||||
document, EDIT_PACK_SPRITESHEET, Document::SPRITESHEETS,
|
||||
[&]() { return document.spritesheet_pack(id, padding); }, TOAST_PACK_SPRITESHEET,
|
||||
TOAST_PACK_SPRITESHEET_FAILED);
|
||||
}});
|
||||
manager.command_push(
|
||||
{manager.selected, [id = window.editId, padding = settings.packPadding](Manager&, Document& document)
|
||||
{
|
||||
spritesheet_textures_edit(
|
||||
document, EDIT_PACK_SPRITESHEET, [&]() { return document.spritesheet_pack(id, padding); },
|
||||
TOAST_PACK_SPRITESHEET, TOAST_PACK_SPRITESHEET_FAILED);
|
||||
}});
|
||||
if (result != PopupButton::NONE)
|
||||
{
|
||||
window.editId = -1;
|
||||
|
||||
@@ -209,13 +209,12 @@ namespace anm2ed::imgui
|
||||
std::set<Reference> drag_frame_references_get(const Reference&);
|
||||
// Queues an edit on the document; its result is selected (frames by default).
|
||||
template <class Operation>
|
||||
void edit_push(StringType label, Document::ChangeType type, Operation operation,
|
||||
std::function<void(Document&, const edit::Uids&)> select = {})
|
||||
void edit_push(StringType label, Operation operation, std::function<void(Document&, const edit::Uids&)> select = {})
|
||||
{
|
||||
command_push(
|
||||
[=, this](Manager&, Document& document) mutable
|
||||
{
|
||||
auto uids = document.edit_apply(label, type, operation);
|
||||
auto uids = document.edit_apply(label, operation);
|
||||
select ? select(document, uids) : frames_select_for(document, uids);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace anm2ed::imgui
|
||||
auto targetReference = reference;
|
||||
auto time = (int)document.frameTime;
|
||||
if (!animation || !command_item_reference_get(document, targetReference)) return;
|
||||
edit_push(EDIT_INSERT_FRAME, Document::FRAMES,
|
||||
[=](Anm2& anm2) { return edit::frame_insert(anm2, targetReference, time); });
|
||||
edit_push(EDIT_INSERT_FRAME, [=](Anm2& anm2) { return edit::frame_insert(anm2, targetReference, time); });
|
||||
}
|
||||
|
||||
void TimelineContext::frames_delete_action()
|
||||
@@ -16,7 +15,7 @@ namespace anm2ed::imgui
|
||||
auto selectedFrames = document.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
if (selectedFrames.empty()) return;
|
||||
edit_push(
|
||||
EDIT_DELETE_FRAMES, Document::FRAMES, [=](Anm2& anm2) { return edit::frames_delete(anm2, selectedFrames); },
|
||||
EDIT_DELETE_FRAMES, [=](Anm2& anm2) { return edit::frames_delete(anm2, selectedFrames); },
|
||||
[this](Document& document, const edit::Uids&) { frames_selection_set_reference_for(document); });
|
||||
}
|
||||
|
||||
@@ -25,7 +24,7 @@ namespace anm2ed::imgui
|
||||
auto selectedFrames = document.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
std::erase_if(selectedFrames, is_trigger_reference);
|
||||
if (selectedFrames.empty()) return;
|
||||
edit_push(EDIT_DUPLICATE_FRAMES, Document::FRAMES,
|
||||
edit_push(EDIT_DUPLICATE_FRAMES,
|
||||
[=, focus = reference](Anm2& anm2) { return edit::frames_duplicate(anm2, selectedFrames, focus); });
|
||||
}
|
||||
|
||||
@@ -46,8 +45,7 @@ namespace anm2ed::imgui
|
||||
auto selectedFrames = document.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
std::erase_if(selectedFrames, is_trigger_reference);
|
||||
if (!is_frames_reverse_available(selectedFrames)) return;
|
||||
edit_push(EDIT_REVERSE_FRAMES, Document::FRAMES,
|
||||
[=](Anm2& anm2) { return edit::frames_reverse(anm2, selectedFrames); });
|
||||
edit_push(EDIT_REVERSE_FRAMES, [=](Anm2& anm2) { return edit::frames_reverse(anm2, selectedFrames); });
|
||||
}
|
||||
|
||||
void TimelineContext::frames_bake()
|
||||
@@ -55,9 +53,8 @@ namespace anm2ed::imgui
|
||||
auto selectedFrames = document.frame_references_get(Document::FrameReferenceFallback::NONE);
|
||||
std::erase_if(selectedFrames, is_trigger_reference);
|
||||
if (selectedFrames.empty()) return;
|
||||
edit_push(EDIT_BAKE_FRAMES, Document::FRAMES,
|
||||
[=, interval = settings.bakeInterval, isRoundScale = settings.bakeIsRoundScale,
|
||||
isRoundRotation = settings.bakeIsRoundRotation](Anm2& anm2)
|
||||
edit_push(EDIT_BAKE_FRAMES, [=, interval = settings.bakeInterval, isRoundScale = settings.bakeIsRoundScale,
|
||||
isRoundRotation = settings.bakeIsRoundRotation](Anm2& anm2)
|
||||
{ return edit::frames_bake(anm2, selectedFrames, interval, isRoundScale, isRoundRotation); });
|
||||
}
|
||||
|
||||
@@ -114,7 +111,7 @@ namespace anm2ed::imgui
|
||||
document, *animation, bakeIntoOtherFramesTarget, isBakeIntoOtherFramesLayers, isBakeIntoOtherFramesNulls);
|
||||
edit::RootBakeOptions options{settings.bakeIsRoundScale, settings.bakeIsRoundRotation,
|
||||
settings.bakeIsMatchRootInterpolation, settings.bakeIsUseRootPivot};
|
||||
edit_push(EDIT_BAKE_INTO_OTHER_FRAMES, Document::FRAMES,
|
||||
edit_push(EDIT_BAKE_INTO_OTHER_FRAMES,
|
||||
[=](Anm2& anm2) { return edit::root_bake_into(anm2, selectedRootFrames, targetItems, options); });
|
||||
}
|
||||
|
||||
@@ -124,8 +121,7 @@ namespace anm2ed::imgui
|
||||
if (selectedFrames.size() != 1) return;
|
||||
auto targetReference = *selectedFrames.begin();
|
||||
auto time = frameSplitTimeAtCursor.value_or((int)std::floor(playback.time));
|
||||
edit_push(EDIT_SPLIT_FRAME, Document::FRAMES,
|
||||
[=](Anm2& anm2) { return edit::frame_split(anm2, targetReference, time); });
|
||||
edit_push(EDIT_SPLIT_FRAME, [=](Anm2& anm2) { return edit::frame_split(anm2, targetReference, time); });
|
||||
}
|
||||
|
||||
void TimelineContext::item_remove()
|
||||
@@ -136,7 +132,7 @@ namespace anm2ed::imgui
|
||||
if (row.type == LAYER || row.type == NULL_) (row.isGroup ? groupIds : ids)[row.type].insert(row.id);
|
||||
if (!animation || (ids.empty() && groupIds.empty())) return;
|
||||
edit_push(
|
||||
EDIT_REMOVE_ITEMS, Document::ITEMS, [=, animationIndex = reference.animationIndex](Anm2& anm2)
|
||||
EDIT_REMOVE_ITEMS, [=, animationIndex = reference.animationIndex](Anm2& anm2)
|
||||
{ return edit::items_remove(anm2, animationIndex, ids, groupIds); },
|
||||
[this](Document& document, const edit::Uids&)
|
||||
{
|
||||
@@ -176,7 +172,7 @@ namespace anm2ed::imgui
|
||||
for (auto itemReference : targetReferences)
|
||||
ids.insert(itemReference.itemID);
|
||||
edit_push(
|
||||
EDIT_GROUP_ITEMS, Document::ITEMS,
|
||||
EDIT_GROUP_ITEMS,
|
||||
[=, animationIndex = reference.animationIndex, type = targetReferences.front().itemType,
|
||||
name = std::string(localize.get(TEXT_NEW_GROUP))](Anm2& anm2)
|
||||
{ return edit::items_group(anm2, animationIndex, type, ids, name); },
|
||||
@@ -218,7 +214,7 @@ namespace anm2ed::imgui
|
||||
if (!tracks.empty()) selection_focus_set(moved, anm2, *tracks.begin());
|
||||
|
||||
edit_push(
|
||||
EDIT_MOVE_ITEMS, Document::ITEMS,
|
||||
EDIT_MOVE_ITEMS,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
return edit::items_move(anm2, animationIndex, targetType, ids, groupIds, target, isDropAfter,
|
||||
@@ -239,7 +235,7 @@ namespace anm2ed::imgui
|
||||
void TimelineContext::fit_animation_length()
|
||||
{
|
||||
if (!animation) return;
|
||||
edit_push(EDIT_FIT_ANIMATION_LENGTH, Document::ANIMATIONS, [animationIndex = reference.animationIndex](Anm2& anm2)
|
||||
edit_push(EDIT_FIT_ANIMATION_LENGTH, [animationIndex = reference.animationIndex](Anm2& anm2)
|
||||
{ return edit::animation_length_fit(anm2, animationIndex); });
|
||||
}
|
||||
|
||||
@@ -274,7 +270,7 @@ namespace anm2ed::imgui
|
||||
if (selectedFrames.empty()) return;
|
||||
frame_references_copy(selectedFrames);
|
||||
edit_push(
|
||||
EDIT_CUT_FRAMES, Document::FRAMES, [=](Anm2& anm2) { return edit::frames_delete(anm2, selectedFrames); },
|
||||
EDIT_CUT_FRAMES, [=](Anm2& anm2) { return edit::frames_delete(anm2, selectedFrames); },
|
||||
[this](Document& document, const edit::Uids&) { frames_selection_set_reference_for(document); });
|
||||
}
|
||||
|
||||
@@ -290,7 +286,7 @@ namespace anm2ed::imgui
|
||||
|
||||
auto errorString = std::make_shared<std::string>();
|
||||
edit_push(
|
||||
EDIT_PASTE_FRAMES, Document::FRAMES,
|
||||
EDIT_PASTE_FRAMES,
|
||||
[=, targetReference = reference,
|
||||
selectedFrames = document.frame_references_get(Document::FrameReferenceFallback::NONE),
|
||||
time = hoveredTime](Anm2& anm2)
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace anm2ed::imgui
|
||||
|
||||
Reference target{drag.animationIndex, targetType, targetID, -1, targetGroupType, targetGroupId};
|
||||
edit_push(
|
||||
EDIT_MOVE_FRAMES, Document::FRAMES,
|
||||
EDIT_MOVE_FRAMES,
|
||||
[frames = std::set<Reference>(drag.references.begin(), drag.references.end()), target, insertIndex](Anm2& anm2)
|
||||
{ return edit::frames_move(anm2, frames, target, insertIndex); },
|
||||
[=, this](Document& document, const edit::Uids& uids)
|
||||
@@ -424,7 +424,7 @@ namespace anm2ed::imgui
|
||||
if (ImGui::IsKeyDown(ImGuiMod_Alt))
|
||||
{
|
||||
auto targetReference = frameReference;
|
||||
edit_push(EDIT_FRAME_INTERPOLATION, Document::FRAMES,
|
||||
edit_push(EDIT_FRAME_INTERPOLATION,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
if (auto frame = anm2.element_get(targetReference))
|
||||
@@ -603,7 +603,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto item = command_item_reference_get(document, targetReference);
|
||||
if (targetType == TRIGGER && item) frames_sort_by_at_frame(*item);
|
||||
document.change(Document::FRAMES);
|
||||
document.change();
|
||||
});
|
||||
isDraggedFrameActive = false;
|
||||
draggedFrameReference = {};
|
||||
@@ -864,7 +864,7 @@ namespace anm2ed::imgui
|
||||
if (isLengthChanged && animation)
|
||||
{
|
||||
auto animationIndex = animationLengthEditIndex != -1 ? animationLengthEditIndex : currentAnimationIndex;
|
||||
edit_push(EDIT_ANIMATION_LENGTH, Document::ANIMATIONS,
|
||||
edit_push(EDIT_ANIMATION_LENGTH,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, animationIndex);
|
||||
@@ -882,7 +882,7 @@ namespace anm2ed::imgui
|
||||
if (ImGui::Checkbox(localize.get(LABEL_LOOP), &isLoop) && animation)
|
||||
{
|
||||
auto animationIndex = reference.animationIndex;
|
||||
edit_push(EDIT_LOOP, Document::ANIMATIONS,
|
||||
edit_push(EDIT_LOOP,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, animationIndex);
|
||||
@@ -901,7 +901,7 @@ namespace anm2ed::imgui
|
||||
ImGui::SetNextItemWidth(widgetSize.x);
|
||||
if (input_int_range(localize.get(LABEL_FPS), fps, FPS_MIN, FPS_MAX))
|
||||
{
|
||||
edit_push(EDIT_FPS, Document::INFO,
|
||||
edit_push(EDIT_FPS,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto info = element_first_get(anm2.root, ElementType::INFO);
|
||||
@@ -922,7 +922,7 @@ namespace anm2ed::imgui
|
||||
ImGui::SetNextItemWidth(widgetSize.x);
|
||||
if (input_text_string(localize.get(LABEL_AUTHOR), &createdBy))
|
||||
{
|
||||
edit_push(EDIT_AUTHOR, Document::INFO,
|
||||
edit_push(EDIT_AUTHOR,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto info = element_first_get(anm2.root, ElementType::INFO);
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace anm2ed::imgui
|
||||
auto targetAnimationIndex = groupAnimationIndex;
|
||||
auto targetType = groupType;
|
||||
auto targetId = groupId;
|
||||
edit_push(EDIT_RENAME_GROUP, Document::ITEMS,
|
||||
edit_push(EDIT_RENAME_GROUP,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, targetAnimationIndex);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace anm2ed::imgui
|
||||
|
||||
auto result = window_popup_buttons_draw(manager, localize.get(LABEL_MAKE_MANY_REGIONS));
|
||||
if (result == PopupButton::CONFIRM)
|
||||
edit_push(EDIT_GENERATE_REGIONS_FROM_ANIMATIONS, Document::ALL,
|
||||
edit_push(EDIT_GENERATE_REGIONS_FROM_ANIMATIONS,
|
||||
[targetFrames = makeManyRegionReferences, format = settings.generateRegionNameFormat,
|
||||
mapping = isMakeManyRegionsMapFrames ? RegionFrameMapping::SET : RegionFrameMapping::PRESERVE](
|
||||
Anm2& anm2) { anm2.regions_generate({}, targetFrames, format, mapping); });
|
||||
@@ -183,7 +183,7 @@ namespace anm2ed::imgui
|
||||
if (auto frame = command_frame_get(document, frameReference))
|
||||
frame->duration =
|
||||
std::clamp(frame->duration + resize.delta, FRAME_DURATION_MIN, FRAME_DURATION_MAX);
|
||||
document.change(Document::FRAMES);
|
||||
document.change();
|
||||
});
|
||||
}
|
||||
isResizeChordHeld[i] = isPressed;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto targetRow = row;
|
||||
auto targetAnimationIndex = reference.animationIndex;
|
||||
edit_push(EDIT_TOGGLE_GROUP_EXPANDED, Document::ITEMS,
|
||||
edit_push(EDIT_TOGGLE_GROUP_EXPANDED,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, targetAnimationIndex);
|
||||
@@ -139,7 +139,7 @@ namespace anm2ed::imgui
|
||||
auto targetType = type;
|
||||
auto targetGroupId = group->id;
|
||||
auto targetVisible = !isGroupVisible;
|
||||
edit_push(EDIT_TOGGLE_ITEM_VISIBILITY, Document::FRAMES,
|
||||
edit_push(EDIT_TOGGLE_ITEM_VISIBILITY,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto animation = anm2.element_get(ElementType::ANIMATION, targetAnimationIndex);
|
||||
@@ -403,7 +403,7 @@ namespace anm2ed::imgui
|
||||
auto targetID = id;
|
||||
auto targetGroupType = row.rootGroupType;
|
||||
auto targetGroupId = row.rootGroupId;
|
||||
edit_push(EDIT_TOGGLE_ITEM_VISIBILITY, Document::FRAMES,
|
||||
edit_push(EDIT_TOGGLE_ITEM_VISIBILITY,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
if (auto item = anm2.element_get(
|
||||
@@ -427,7 +427,7 @@ namespace anm2ed::imgui
|
||||
if (ImGui::ImageButton("##Rect Toggle", resources.icon_id_get(rectIcon), icon_size_get()))
|
||||
{
|
||||
auto nullID = id;
|
||||
edit_push(EDIT_TOGGLE_NULL_RECT, Document::FRAMES,
|
||||
edit_push(EDIT_TOGGLE_NULL_RECT,
|
||||
[=](Anm2& anm2)
|
||||
{
|
||||
auto nulls = anm2.element_get(ElementType::NULLS);
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace anm2ed::imgui
|
||||
auto target =
|
||||
reference == -1 || !container ? nullptr : child_id_get(*container, window.elementType, reference);
|
||||
if (!container || (reference != -1 && !target)) return;
|
||||
document.edit_apply(reference == -1 ? window.addEdit : window.propertiesEdit, window.changeType,
|
||||
document.edit_apply(reference == -1 ? window.addEdit : window.propertiesEdit,
|
||||
[&](Anm2&)
|
||||
{
|
||||
auto changed = edited;
|
||||
@@ -100,7 +100,7 @@ namespace anm2ed::imgui
|
||||
{
|
||||
auto element = window_element_get(window, document, key);
|
||||
if (!element || element->name == name) return;
|
||||
document.edit_apply(window.renameEdit, window.changeType,
|
||||
document.edit_apply(window.renameEdit,
|
||||
[&](Anm2&)
|
||||
{
|
||||
element->name = name;
|
||||
@@ -133,7 +133,7 @@ namespace anm2ed::imgui
|
||||
return;
|
||||
}
|
||||
|
||||
document.edit_apply(window.pasteEdit, window.changeType,
|
||||
document.edit_apply(window.pasteEdit,
|
||||
[&](Anm2&)
|
||||
{
|
||||
document.anm2 = std::move(pasted);
|
||||
@@ -152,7 +152,7 @@ namespace anm2ed::imgui
|
||||
auto unused = document.anm2.element_unused(window.elementType);
|
||||
auto container = window_container_get(window, document);
|
||||
if (unused.empty() || !container) return;
|
||||
document.edit_apply(window.removeUnusedEdit, window.changeType,
|
||||
document.edit_apply(window.removeUnusedEdit,
|
||||
[&](Anm2&)
|
||||
{
|
||||
for (auto id : unused)
|
||||
|
||||
@@ -96,7 +96,6 @@ namespace anm2ed::imgui
|
||||
|
||||
StringType title{};
|
||||
bool Settings::* isOpen{};
|
||||
Document::ChangeType changeType{};
|
||||
ElementType containerType{ElementType::UNKNOWN};
|
||||
ElementType elementType{ElementType::UNKNOWN};
|
||||
const char* childLabel{"##Window Child"};
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace anm2ed::imgui::wizard
|
||||
targets.references = {selectedItemReferences.begin(), selectedItemReferences.end()};
|
||||
else
|
||||
targets.animations = queuedAnimations;
|
||||
document.edit_apply(EDIT_CHANGE_FRAME_PROPERTIES, Document::FRAMES, [&](Anm2& anm2)
|
||||
document.edit_apply(EDIT_CHANGE_FRAME_PROPERTIES, [&](Anm2& anm2)
|
||||
{ return edit::frames_change_apply(anm2, targets, frameChange, changeType); });
|
||||
}});
|
||||
isChanged = true;
|
||||
|
||||
@@ -150,8 +150,7 @@ namespace anm2ed::imgui::wizard
|
||||
{
|
||||
edit::GridOptions options{queuedStartPosition, queuedSize, queuedPivot, queuedColumns,
|
||||
queuedCount, queuedDelay, queuedIsMakeRegions, queuedRegionNameFormat};
|
||||
document.edit_apply(EDIT_GENERATE_ANIMATION_FROM_GRID,
|
||||
queuedIsMakeRegions ? Document::ALL : Document::FRAMES, [&](Anm2& anm2)
|
||||
document.edit_apply(EDIT_GENERATE_ANIMATION_FROM_GRID, [&](Anm2& anm2)
|
||||
{ return edit::animation_grid_generate(anm2, queuedLayerReferences, options); });
|
||||
}});
|
||||
isEnd = true;
|
||||
|
||||
+3
-3
@@ -234,7 +234,7 @@ namespace anm2ed
|
||||
selected = std::clamp(selected, 0, (int)documents.size() - 1);
|
||||
pendingSelected = selected;
|
||||
|
||||
if (selected >= 0 && selected < (int)documents.size()) documents[selected].change(Document::ALL);
|
||||
if (selected >= 0 && selected < (int)documents.size()) documents[selected].change();
|
||||
}
|
||||
|
||||
void Manager::set(int index)
|
||||
@@ -250,7 +250,7 @@ namespace anm2ed
|
||||
selected = index;
|
||||
selection_history_push(selected);
|
||||
|
||||
if (auto document = get()) document->change(Document::ALL);
|
||||
if (auto document = get()) document->change();
|
||||
}
|
||||
|
||||
void Manager::item_properties_open(ElementType type, int id)
|
||||
@@ -339,7 +339,7 @@ namespace anm2ed
|
||||
{
|
||||
document->isForceDirty = true;
|
||||
document->path = document->path_from_autosave_get(path);
|
||||
document->change(Document::ALL);
|
||||
document->change();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user