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
@@ -15,7 +15,6 @@ namespace anm2ed::imgui
|
||||
X(ACTION_REDO, SHORTCUT_STRING_REDO, SHORTCUT_REDO) \
|
||||
X(ACTION_ADD, BASIC_ADD, SHORTCUT_ADD) \
|
||||
X(ACTION_REMOVE, BASIC_REMOVE, SHORTCUT_REMOVE) \
|
||||
X(ACTION_REMOVE_UNUSED, BASIC_REMOVE_UNUSED, SHORTCUT_REMOVE) \
|
||||
X(ACTION_DUPLICATE, BASIC_DUPLICATE, SHORTCUT_DUPLICATE) \
|
||||
X(ACTION_MERGE, BASIC_MERGE, SHORTCUT_MERGE) \
|
||||
X(ACTION_GROUP, BASIC_GROUP, SHORTCUT_GROUP) \
|
||||
@@ -47,7 +46,7 @@ namespace anm2ed::imgui
|
||||
#define X(name, label, shortcut) name,
|
||||
ACTIONS(X)
|
||||
#undef X
|
||||
ACTION_COUNT
|
||||
ACTION_COUNT
|
||||
};
|
||||
|
||||
struct ActionInfo
|
||||
|
||||
@@ -836,7 +836,7 @@ namespace anm2ed::imgui
|
||||
// The events triggers (the animation's and its children's) fire on this frame.
|
||||
std::string names{};
|
||||
if (animation && !isOnlyShowLayers && !manager.isRecording)
|
||||
for (const auto& [source, trigger] :
|
||||
for (const auto& [source, trigger, layerId] :
|
||||
model::animation_triggers_get(model, *animation, (int)frameTime, document.library_resolver_get()))
|
||||
for (auto eventId : trigger.eventIds)
|
||||
if (auto event = model::item_get(source->content.events, eventId))
|
||||
|
||||
+11
-16
@@ -159,8 +159,8 @@ namespace anm2ed::imgui
|
||||
// Layers and nulls: properties popup, add, remove unused, copy and paste.
|
||||
template <class Item, class ItemsGet>
|
||||
void track_items_actions_add(Actions& actions, Panel& panel, SelectionKind kind, ElementType type,
|
||||
StringType addTooltip, StringType removeUnusedTooltip, StringType removeUnusedEdit,
|
||||
StringType pasteEdit, StringType pasteFailToast, ItemsGet items_get)
|
||||
StringType addTooltip, StringType pasteEdit, StringType pasteFailToast,
|
||||
ItemsGet items_get)
|
||||
{
|
||||
auto selection = panel.document.selected_ids_get(kind);
|
||||
auto& manager = panel.manager;
|
||||
@@ -168,9 +168,7 @@ namespace anm2ed::imgui
|
||||
ACTION_PROPERTIES, [selection]() { return selection.size() == 1; },
|
||||
[&manager, type, selection]() { manager.item_properties_open(type, *selection.begin()); });
|
||||
actions.add(ACTION_ADD, {}, [&manager, type]() { manager.item_properties_open(type, -1); }, addTooltip);
|
||||
actions.add(
|
||||
ACTION_REMOVE_UNUSED, {}, [&panel, type, removeUnusedEdit, items_get]()
|
||||
{ items_unused_remove(panel, type, removeUnusedEdit, items_get); }, removeUnusedTooltip);
|
||||
content_remove_action_add(actions, panel, type, kind);
|
||||
items_clipboard_actions_add<Item>(actions, panel, kind, pasteEdit, pasteFailToast, items_get);
|
||||
}
|
||||
|
||||
@@ -182,8 +180,8 @@ namespace anm2ed::imgui
|
||||
{
|
||||
Actions actions{};
|
||||
track_items_actions_add<model::Layer>(actions, panel, SelectionKind::LAYERS, ElementType::LAYER_ELEMENT,
|
||||
TOOLTIP_ADD_LAYER, TOOLTIP_REMOVE_UNUSED_LAYERS, EDIT_REMOVE_UNUSED_LAYERS,
|
||||
EDIT_PASTE_LAYERS, TOAST_DESERIALIZE_LAYERS_FAILED, layers_get);
|
||||
TOOLTIP_ADD_LAYER, EDIT_PASTE_LAYERS, TOAST_DESERIALIZE_LAYERS_FAILED,
|
||||
layers_get);
|
||||
ListRows rows{.label_get = [&](int id) { return layer_label_get(*model::item_get(layers, id)); },
|
||||
.is_invalid = [&](int id)
|
||||
{ return document.is_layer_animation_missing(*model::item_get(layers, id)); },
|
||||
@@ -195,7 +193,7 @@ namespace anm2ed::imgui
|
||||
layer_source_tooltip_draw(document, *layer);
|
||||
},
|
||||
.activate = [&](int id) { manager.item_properties_open(ElementType::LAYER_ELEMENT, id); }};
|
||||
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED}},
|
||||
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::LAYERS, item_ids_get(layers), rows); });
|
||||
}
|
||||
ImGui::End();
|
||||
@@ -217,8 +215,8 @@ namespace anm2ed::imgui
|
||||
{
|
||||
Actions actions{};
|
||||
track_items_actions_add<model::Null>(actions, panel, SelectionKind::NULLS, ElementType::NULL_ELEMENT,
|
||||
TOOLTIP_ADD_NULL, TOOLTIP_REMOVE_UNUSED_NULLS, EDIT_REMOVE_UNUSED_NULLS,
|
||||
EDIT_PASTE_NULLS, TOAST_DESERIALIZE_NULLS_FAILED, nulls_get);
|
||||
TOOLTIP_ADD_NULL, EDIT_PASTE_NULLS, TOAST_DESERIALIZE_NULLS_FAILED,
|
||||
nulls_get);
|
||||
ListRows rows{.label_get =
|
||||
[&](int id)
|
||||
{
|
||||
@@ -228,7 +226,7 @@ namespace anm2ed::imgui
|
||||
.tooltip_draw = [&](int id) { item_tooltip_draw(resources, model::item_get(nulls, id)->name, id); },
|
||||
.activate = [&](int id) { manager.item_properties_open(ElementType::NULL_ELEMENT, id); },
|
||||
.isFocusItalic = true};
|
||||
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED}},
|
||||
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::NULLS, item_ids_get(nulls), rows); });
|
||||
}
|
||||
ImGui::End();
|
||||
@@ -275,10 +273,7 @@ namespace anm2ed::imgui
|
||||
});
|
||||
},
|
||||
TOOLTIP_ADD_EVENT);
|
||||
actions.add(
|
||||
ACTION_REMOVE_UNUSED, {},
|
||||
[&panel]() { items_unused_remove(panel, ElementType::EVENT_ELEMENT, EDIT_REMOVE_UNUSED_EVENTS, events_get); },
|
||||
TOOLTIP_REMOVE_UNUSED_EVENTS);
|
||||
content_remove_action_add(actions, panel, ElementType::EVENT_ELEMENT, SelectionKind::EVENTS);
|
||||
items_clipboard_actions_add<model::Event>(actions, panel, SelectionKind::EVENTS, EDIT_PASTE_EVENTS,
|
||||
TOAST_DESERIALIZE_EVENTS_FAILED, events_get);
|
||||
ListRows rows{.label_get = [&](int id) { return model::item_get(events, id)->name; },
|
||||
@@ -299,7 +294,7 @@ namespace anm2ed::imgui
|
||||
},
|
||||
.tooltip_draw = [&](int id)
|
||||
{ item_tooltip_draw(resources, model::item_get(events, id)->name, id); }};
|
||||
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED}},
|
||||
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::EVENTS, item_ids_get(events), rows); });
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
@@ -51,10 +51,7 @@ namespace anm2ed::imgui
|
||||
actions.add(ACTION_OPEN_DIRECTORY, isOne,
|
||||
[&]() { directory_open(dialog, document, model::item_get(libraries, *selection.begin())->path); });
|
||||
actions.add(ACTION_ADD, {}, [&]() { dialog.file_open(Dialog::LIBRARY_OPEN, true); }, TOOLTIP_LIBRARY_ADD);
|
||||
actions.add(
|
||||
ACTION_REMOVE_UNUSED, {},
|
||||
[&]() { items_unused_remove(panel, ElementType::LIBRARY, EDIT_REMOVE_UNUSED_LIBRARIES, libraries_get); },
|
||||
TOOLTIP_REMOVE_UNUSED_LIBRARIES);
|
||||
content_remove_action_add(actions, panel, ElementType::LIBRARY, SelectionKind::LIBRARIES);
|
||||
actions.add(
|
||||
ACTION_RELOAD, [selection]() { return !selection.empty(); },
|
||||
[&]()
|
||||
@@ -115,7 +112,7 @@ namespace anm2ed::imgui
|
||||
.activate = open,
|
||||
.cardLines = LIBRARY_CARD_LINES};
|
||||
list_panel_draw(
|
||||
panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD, ACTION_OPEN}},
|
||||
panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD, ACTION_OPEN}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::LIBRARIES, item_ids_get(libraries), rows); }, true);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
@@ -17,6 +17,7 @@ using namespace glm;
|
||||
namespace anm2ed::imgui
|
||||
{
|
||||
constexpr float SCROLL_CENTER = 0.5f;
|
||||
constexpr std::size_t REMOVE_LINES_MAX = 10;
|
||||
constexpr float TOOLTIP_PADDING_MULTIPLIER = 4.0f;
|
||||
constexpr float PREVIEW_VIEWPORT_FRACTION = 0.5f;
|
||||
constexpr const char* CONTEXT_MENU_LABEL = "##Context Menu";
|
||||
@@ -273,6 +274,151 @@ namespace anm2ed::imgui
|
||||
}
|
||||
|
||||
// The list in a bordered child with its context menu and shortcuts, then the footer buttons.
|
||||
// The confirmation's lines: the items by name, then what goes with them.
|
||||
std::vector<std::string> remove_lines_get(const model::Model& model, ElementType type, const std::set<int>& ids,
|
||||
int spritesheetId)
|
||||
{
|
||||
auto& content = model.content;
|
||||
std::vector<std::string> lines{};
|
||||
auto names_add = [&](const auto& items, auto&& name_get)
|
||||
{
|
||||
for (auto id : ids)
|
||||
if (auto item = model::item_get(items, id)) lines.push_back(std::format("\"{}\"", name_get(*item)));
|
||||
};
|
||||
auto name_get = [](const auto& item) { return item.name; };
|
||||
auto path_get = [](const auto& item) { return path::to_utf8(item.path); };
|
||||
auto count_add = [&](StringType format, int count)
|
||||
{
|
||||
if (count > 0) lines.push_back(localize_format(format, count));
|
||||
};
|
||||
auto layers_add = [&](StringType format, auto&& is_removed)
|
||||
{
|
||||
std::set<int> layerIds{};
|
||||
for (const auto& layer : content.layers)
|
||||
if (is_removed(layer))
|
||||
{
|
||||
layerIds.insert(layer.id);
|
||||
lines.push_back(localize_format(format, layer.name));
|
||||
}
|
||||
return layerIds;
|
||||
};
|
||||
auto uses = model.uses_count(type, ids, spritesheetId);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ElementType::LAYER_ELEMENT:
|
||||
names_add(content.layers, name_get);
|
||||
count_add(FORMAT_REMOVE_TRACKS, uses);
|
||||
break;
|
||||
case ElementType::NULL_ELEMENT:
|
||||
names_add(content.nulls, name_get);
|
||||
count_add(FORMAT_REMOVE_TRACKS, uses);
|
||||
break;
|
||||
case ElementType::EVENT_ELEMENT:
|
||||
case ElementType::SOUND_ELEMENT:
|
||||
{
|
||||
auto isEvent = type == ElementType::EVENT_ELEMENT;
|
||||
if (isEvent)
|
||||
names_add(content.events, name_get);
|
||||
else
|
||||
names_add(content.sounds, path_get);
|
||||
count_add(FORMAT_REMOVE_TRIGGER_USES, uses);
|
||||
// Triggers whose every event and sound goes.
|
||||
int emptied{};
|
||||
for (auto [index, animation] : model.animations_get())
|
||||
for (const auto& trigger : animation->triggers.frames)
|
||||
{
|
||||
auto& own = isEvent ? trigger.eventIds : trigger.soundIds;
|
||||
auto& other = isEvent ? trigger.soundIds : trigger.eventIds;
|
||||
emptied +=
|
||||
other.empty() && !own.empty() && std::ranges::all_of(own, [&](int id) { return ids.contains(id); });
|
||||
}
|
||||
count_add(FORMAT_REMOVE_TRIGGERS_EMPTY, emptied);
|
||||
break;
|
||||
}
|
||||
case ElementType::SHADER:
|
||||
names_add(content.shaders, name_get);
|
||||
count_add(FORMAT_REMOVE_SHADER_USES, uses);
|
||||
break;
|
||||
case ElementType::REGION:
|
||||
if (auto spritesheet = model::item_get(content.spritesheets, spritesheetId))
|
||||
names_add(spritesheet->regions, name_get);
|
||||
count_add(FORMAT_REMOVE_REGION_USES, uses);
|
||||
break;
|
||||
case ElementType::SPRITESHEET:
|
||||
{
|
||||
names_add(content.spritesheets, path_get);
|
||||
auto layerIds = layers_add(FORMAT_REMOVE_LAYER, [&](const model::Layer& layer)
|
||||
{ return !layer.is_animation() && ids.contains(layer.spritesheetId); });
|
||||
count_add(FORMAT_REMOVE_TRACKS, model.uses_count(ElementType::LAYER_ELEMENT, layerIds));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
names_add(content.libraries, path_get);
|
||||
layers_add(FORMAT_REMOVE_FLATTENED_LAYER,
|
||||
[&](const model::Layer& layer) { return ids.contains(layer.libraryId); });
|
||||
break;
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
void content_remove_apply(Panel& panel)
|
||||
{
|
||||
command_push(panel,
|
||||
[removal = panel.state.removal](Document& document)
|
||||
{
|
||||
document.edit_apply(EDIT_REMOVE_ITEMS,
|
||||
[&](model::Model& model)
|
||||
{
|
||||
return edit::content_remove(
|
||||
model, removal.type, removal.ids, removal.spritesheetId,
|
||||
document.library_resolver_get(), document.spritesheet_path_resolver_get());
|
||||
});
|
||||
document.selected_clear(removal.kind);
|
||||
});
|
||||
}
|
||||
|
||||
// Removes the selected content items; when anything uses them, it asks first, saying what goes with them.
|
||||
void content_remove_action_add(Actions& actions, Panel& panel, ElementType type, SelectionKind kind,
|
||||
int spritesheetId)
|
||||
{
|
||||
auto selection = panel.document.selected_ids_get(kind);
|
||||
actions.add(
|
||||
ACTION_REMOVE, [selection]() { return !selection.empty(); },
|
||||
[&panel, type, kind, selection, spritesheetId]()
|
||||
{
|
||||
auto& model = panel.document.model;
|
||||
panel.state.removal = {type, kind, selection, spritesheetId,
|
||||
remove_lines_get(model, type, selection, spritesheetId)};
|
||||
if (model.uses_count(type, selection, spritesheetId) > 0)
|
||||
panel.state.removePopup.open();
|
||||
else
|
||||
content_remove_apply(panel);
|
||||
},
|
||||
TOOLTIP_REMOVE_CONTENT);
|
||||
}
|
||||
|
||||
void content_remove_popup_draw(Panel& panel)
|
||||
{
|
||||
auto& popup = panel.state.removePopup;
|
||||
popup.trigger();
|
||||
if (!ImGui::BeginPopupModal(popup.label(), &popup.isOpen, ImGuiWindowFlags_NoResize)) return popup.end();
|
||||
auto& removal = panel.state.removal;
|
||||
ImGui::TextUnformatted(localize.get(TEXT_REMOVE_LIST));
|
||||
auto& lines = removal.lines;
|
||||
for (std::size_t i = 0; i < std::min(lines.size(), REMOVE_LINES_MAX); ++i)
|
||||
ImGui::BulletText("%s", lines[i].c_str());
|
||||
if (lines.size() > REMOVE_LINES_MAX)
|
||||
ImGui::BulletText("%s", localize_format(FORMAT_REMOVE_MORE, (int)(lines.size() - REMOVE_LINES_MAX)).c_str());
|
||||
ImGui::Spacing();
|
||||
ImGui::TextUnformatted(localize.get(TEXT_REMOVE_CONFIRM));
|
||||
auto result = popup_buttons_draw(panel.manager, localize.get(BASIC_REMOVE));
|
||||
if (result == PopupButton::CONFIRM) content_remove_apply(panel);
|
||||
if (result != PopupButton::NONE) popup.close();
|
||||
ImGui::EndPopup();
|
||||
popup.end();
|
||||
}
|
||||
|
||||
void list_panel_draw(Panel& panel, Actions& actions, const Footer& footer, const std::function<void()>& list,
|
||||
bool isCards, Actions* footerActions)
|
||||
{
|
||||
@@ -306,6 +452,7 @@ namespace anm2ed::imgui
|
||||
if (auto action = std::ranges::find(buttons.items, type, &Action::type); action != buttons.items.end())
|
||||
action_button_draw(*action, manager, settings, widgetSize, isSameLine);
|
||||
}
|
||||
content_remove_popup_draw(panel);
|
||||
}
|
||||
|
||||
void tooltip_name_draw(Resources& resources, const std::string& name)
|
||||
|
||||
+11
-16
@@ -50,6 +50,16 @@ namespace anm2ed::imgui
|
||||
MultiSelectStorage selection{};
|
||||
ImVec2 tooltipPadding{};
|
||||
ImVec2 tooltipSpacing{};
|
||||
PopupHelper removePopup{PopupHelper(LABEL_REMOVE_IN_USE, POPUP_SMALL_NO_HEIGHT)};
|
||||
// A removal waiting on its confirmation, since what it removes is in use.
|
||||
struct Removal
|
||||
{
|
||||
ElementType type{};
|
||||
SelectionKind kind{};
|
||||
std::set<int> ids{};
|
||||
int spritesheetId{-1};
|
||||
std::vector<std::string> lines{};
|
||||
} removal{};
|
||||
};
|
||||
|
||||
// Everything a panel draws with, for one frame. Commands get the document again when they run.
|
||||
@@ -104,6 +114,7 @@ namespace anm2ed::imgui
|
||||
void directory_open(Dialog&, Document&, const std::filesystem::path&);
|
||||
std::filesystem::path asset_path_get(Document&, const std::filesystem::path&);
|
||||
PopupButton popup_buttons_draw(Manager&, const char*, bool = true, StringType = BASIC_CANCEL);
|
||||
void content_remove_action_add(Actions&, Panel&, ElementType, SelectionKind, int = -1);
|
||||
|
||||
struct SpritesheetsPanel
|
||||
{
|
||||
@@ -223,20 +234,4 @@ namespace anm2ed::imgui
|
||||
[&panel, kind, pasteEdit, failToast, items_get]()
|
||||
{ items_paste<Item>(panel, kind, pasteEdit, failToast, items_get); });
|
||||
}
|
||||
|
||||
// Removes content items no animation (or layer, for spritesheets) uses.
|
||||
template <class ItemsGet>
|
||||
void items_unused_remove(const Panel& panel, ElementType type, StringType edit, ItemsGet items_get)
|
||||
{
|
||||
command_push(
|
||||
panel,
|
||||
[type, edit, items_get](Document& document)
|
||||
{
|
||||
auto unused = document.model.unused_get(type);
|
||||
if (unused.empty()) return;
|
||||
document.edit_apply(
|
||||
edit, [&](model::Model& model)
|
||||
{ std::erase_if(items_get(model), [&](const auto& item) { return unused.contains(item.id); }); });
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -414,18 +414,7 @@ namespace anm2ed::imgui
|
||||
Actions actions{};
|
||||
actions.add(ACTION_PROPERTIES, isOne, [&]() { region_properties_open(regions, document, *selection.begin()); });
|
||||
actions.add(ACTION_ADD, {}, [&]() { region_properties_open(regions, document, -1); }, TOOLTIP_ADD_REGION);
|
||||
actions.add(
|
||||
ACTION_REMOVE_UNUSED, {},
|
||||
[&]()
|
||||
{
|
||||
command_push(panel,
|
||||
[spritesheetId](Document& document)
|
||||
{
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_REGIONS, [&](model::Model& model)
|
||||
{ return edit::regions_remove_unused(model, spritesheetId); });
|
||||
});
|
||||
},
|
||||
TOOLTIP_REMOVE_UNUSED_REGIONS);
|
||||
content_remove_action_add(actions, panel, ElementType::REGION, SelectionKind::REGIONS, spritesheetId);
|
||||
actions.add(
|
||||
ACTION_TRIM, [selection]() { return !selection.empty(); },
|
||||
[&]()
|
||||
@@ -519,7 +508,7 @@ namespace anm2ed::imgui
|
||||
.drag_drop_update = [&](int id, int index) { return region_drag_drop_update(panel, id, index); },
|
||||
.cardLines = REGION_CARD_LINES};
|
||||
list_panel_draw(
|
||||
panel, actions, {{ACTION_ADD, ACTION_EXPORT, ACTION_REMOVE_UNUSED}},
|
||||
panel, actions, {{ACTION_ADD, ACTION_EXPORT, ACTION_REMOVE}},
|
||||
[&]()
|
||||
{
|
||||
content_list_draw(panel, SelectionKind::REGIONS, item_ids_get(spritesheet->regions), rows);
|
||||
|
||||
@@ -333,10 +333,7 @@ namespace anm2ed::imgui
|
||||
});
|
||||
},
|
||||
TOOLTIP_ADD_SHADER);
|
||||
actions.add(
|
||||
ACTION_REMOVE_UNUSED, {},
|
||||
[&]() { items_unused_remove(panel, ElementType::SHADER, EDIT_REMOVE_UNUSED_SHADERS, shaders_get); },
|
||||
TOOLTIP_REMOVE_UNUSED_SHADERS);
|
||||
content_remove_action_add(actions, panel, ElementType::SHADER, SelectionKind::SHADERS);
|
||||
actions.add(
|
||||
ACTION_RELOAD, [selection]() { return !selection.empty(); },
|
||||
[&]()
|
||||
@@ -379,7 +376,7 @@ namespace anm2ed::imgui
|
||||
.activate = properties_open,
|
||||
.cardLines = SHADER_CARD_LINES};
|
||||
list_panel_draw(
|
||||
panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD}},
|
||||
panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::SHADERS, item_ids_get(items), rows); }, true);
|
||||
|
||||
propertiesPopup.trigger();
|
||||
|
||||
@@ -67,10 +67,7 @@ namespace anm2ed::imgui
|
||||
actions.add(ACTION_PLAY, isOne, [&]() { play(*selection.begin()); }, STRING_UNDEFINED, -1);
|
||||
actions.add(ACTION_OPEN_DIRECTORY, isOne, [&]() { open(*selection.begin()); });
|
||||
actions.add(ACTION_ADD, {}, [&]() { dialog.file_open(Dialog::SOUND_OPEN, true); }, TOOLTIP_SOUND_ADD);
|
||||
actions.add(
|
||||
ACTION_REMOVE_UNUSED, {},
|
||||
[&]() { items_unused_remove(panel, ElementType::SOUND_ELEMENT, EDIT_REMOVE_UNUSED_SOUNDS, sounds_get); },
|
||||
TOOLTIP_REMOVE_UNUSED_SOUNDS);
|
||||
content_remove_action_add(actions, panel, ElementType::SOUND_ELEMENT, SelectionKind::SOUNDS);
|
||||
actions.add(
|
||||
ACTION_RELOAD, [selection]() { return !selection.empty(); },
|
||||
[&]()
|
||||
@@ -132,7 +129,7 @@ namespace anm2ed::imgui
|
||||
.activate = open,
|
||||
.cardLines = SOUND_CARD_LINES};
|
||||
list_panel_draw(
|
||||
panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD, ACTION_REPLACE}},
|
||||
panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD, ACTION_REPLACE}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::SOUNDS, item_ids_get(sounds), rows); }, true);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
@@ -241,31 +241,7 @@ namespace anm2ed::imgui
|
||||
actions.add(ACTION_OPEN_DIRECTORY, isOne, [&]() { open(*selection.begin()); });
|
||||
actions.add(ACTION_SET_FILE_PATH, isOne, [&]() { dialog.file_save(Dialog::SPRITESHEET_PATH_SET); });
|
||||
actions.add(ACTION_ADD, {}, [&]() { dialog.file_open(Dialog::SPRITESHEET_OPEN, true); }, TOOLTIP_ADD_SPRITESHEET);
|
||||
actions.add(
|
||||
ACTION_REMOVE_UNUSED, {},
|
||||
[&]()
|
||||
{
|
||||
command_push(panel,
|
||||
[](Document& document)
|
||||
{
|
||||
auto unused = document.model.unused_get(ElementType::SPRITESHEET);
|
||||
if (unused.empty()) return;
|
||||
document.edit_apply(EDIT_REMOVE_UNUSED_SPRITESHEETS,
|
||||
[&](model::Model& model)
|
||||
{
|
||||
std::erase_if(model.content.spritesheets,
|
||||
[&](const model::Spritesheet& spritesheet)
|
||||
{
|
||||
if (!unused.contains(spritesheet.id)) return false;
|
||||
toast_log(Level::INFO, TOAST_REMOVE_SPRITESHEET,
|
||||
spritesheet.id,
|
||||
path::to_utf8(spritesheet.path));
|
||||
return true;
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
TOOLTIP_REMOVE_UNUSED_SPRITESHEETS);
|
||||
content_remove_action_add(actions, panel, ElementType::SPRITESHEET, SelectionKind::SPRITESHEETS);
|
||||
actions.add(
|
||||
ACTION_RELOAD, isAny,
|
||||
[&]() { command_push(panel, [selection](Document& document) { document.spritesheets_reload(selection); }); },
|
||||
@@ -365,7 +341,7 @@ namespace anm2ed::imgui
|
||||
.activate = open,
|
||||
.cardLines = SPRITESHEET_CARD_LINES};
|
||||
list_panel_draw(
|
||||
panel, actions, {{ACTION_ADD, ACTION_RELOAD, ACTION_REPLACE}, {ACTION_REMOVE_UNUSED, ACTION_SAVE}},
|
||||
panel, actions, {{ACTION_ADD, ACTION_RELOAD, ACTION_REPLACE}, {ACTION_REMOVE, ACTION_SAVE}},
|
||||
[&]() { content_list_draw(panel, SelectionKind::SPRITESHEETS, item_ids_get(items), rows); }, true);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
Reference in new issue
Block a user