add item fixes

This commit is contained in:
2025-12-18 23:56:15 -05:00
parent 82c5dcc176
commit 4574ff0f84
8 changed files with 23 additions and 19 deletions

View File

@@ -72,7 +72,7 @@ namespace anm2ed::anm2
Item* item_get(int, Type, int = -1);
Reference layer_animation_add(Reference = {}, std::string = {}, int = 0,
types::destination::Type = types::destination::ALL);
Reference null_animation_add(Reference = {}, std::string = {}, types::destination::Type = types::destination::ALL);
Reference null_animation_add(Reference = {}, std::string = {}, bool = false, types::destination::Type = types::destination::ALL);
Frame* frame_get(int, Type, int, int = -1);
void merge(const Anm2&, const std::filesystem::path&, const std::filesystem::path&);

View File

@@ -31,7 +31,7 @@ namespace anm2ed::anm2
}
Reference Anm2::layer_animation_add(Reference reference, std::string name, int spritesheetID,
destination::Type locale)
destination::Type destination)
{
auto id = reference.itemID == -1 ? map::next_id_get(content.layers) : reference.itemID;
auto& layer = content.layers[id];
@@ -45,12 +45,12 @@ namespace anm2ed::anm2
animation->layerOrder.push_back(id);
};
if (locale == destination::ALL)
if (destination == destination::ALL)
{
for (auto& animation : animations.items)
if (!animation.layerAnimations.contains(id)) add(&animation, id);
}
else if (locale == destination::THIS)
else if (destination == destination::THIS)
{
if (auto animation = animation_get(reference.animationIndex))
if (!animation->layerAnimations.contains(id)) add(animation, id);
@@ -59,26 +59,27 @@ namespace anm2ed::anm2
return {reference.animationIndex, LAYER, id};
}
Reference Anm2::null_animation_add(Reference reference, std::string name, destination::Type locale)
Reference Anm2::null_animation_add(Reference reference, std::string name, bool isShowRect, destination::Type destination)
{
auto id = reference.itemID == -1 ? map::next_id_get(content.nulls) : reference.itemID;
auto& null = content.nulls[id];
null.name = !name.empty() ? name : null.name;
null.isShowRect = isShowRect;
auto add = [&](Animation* animation, int id) { animation->nullAnimations[id] = Item(); };
if (locale == destination::ALL)
if (destination == destination::ALL)
{
for (auto& animation : animations.items)
if (!animation.nullAnimations.contains(id)) add(&animation, id);
}
else if (locale == destination::THIS)
else if (destination == destination::THIS)
{
if (auto animation = animation_get(reference.animationIndex))
if (!animation->nullAnimations.contains(id)) add(animation, id);
}
return {reference.animationIndex, LAYER, id};
return {reference.animationIndex, NULL_, id};
}
}

View File

@@ -39,7 +39,6 @@ namespace anm2ed::anm2
std::vector<std::string> Anm2::spritesheet_labels_get()
{
std::vector<std::string> labels{};
labels.emplace_back(localize.get(BASIC_NONE));
for (auto& [id, spritesheet] : content.spritesheets)
{
auto pathString = path::to_utf8(spritesheet.path);

View File

@@ -175,7 +175,8 @@ namespace anm2ed::imgui
if (propertiesPopup.isJustOpened) ImGui::SetKeyboardFocusHere();
input_text_string(localize.get(BASIC_NAME), &layer.name);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ITEM_NAME));
combo_negative_one_indexed(localize.get(LABEL_SPRITESHEET), &layer.spritesheetID, document.spritesheet.labels);
ImGui::Combo(localize.get(LABEL_SPRITESHEET), &layer.spritesheetID, document.spritesheet.labels.data(), (int)document.spritesheet.labels.size());
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_SPRITESHEET));
}
ImGui::EndChild();

View File

@@ -1783,13 +1783,16 @@ namespace anm2ed::imgui
{
input_text_string(localize.get(BASIC_NAME), &addItemName);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_ITEM_NAME));
ImGui::BeginDisabled(type != anm2::LAYER);
if (type == anm2::LAYER)
{
combo_negative_one_indexed(localize.get(LABEL_SPRITESHEET), &addItemSpritesheetID,
document.spritesheet.labels);
ImGui::Combo(localize.get(LABEL_SPRITESHEET), &addItemSpritesheetID, document.spritesheet.labels.data(), (int)document.spritesheet.labels.size());
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_LAYER_SPRITESHEET));
}
ImGui::EndDisabled();
else if (type == anm2::NULL_)
{
ImGui::Checkbox(localize.get(LABEL_RECT), &addItemIsShowRect);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_NULL_RECT));
}
}
ImGui::EndDisabled();
}
@@ -1838,9 +1841,9 @@ namespace anm2ed::imgui
document.snapshot(localize.get(EDIT_ADD_ITEM));
if (type == anm2::LAYER)
addReference = anm2.layer_animation_add({reference.animationIndex, anm2::LAYER, addItemID}, addItemName,
addItemSpritesheetID - 1, (destination::Type)destination);
addItemSpritesheetID, (destination::Type)destination);
else if (type == anm2::NULL_)
addReference = anm2.null_animation_add({reference.animationIndex, anm2::LAYER, addItemID}, addItemName,
addReference = anm2.null_animation_add({reference.animationIndex, anm2::NULL_, addItemID}, addItemName, addItemIsShowRect,
(destination::Type)destination);
document.change(Document::ITEMS);

View File

@@ -26,7 +26,7 @@ namespace anm2ed::imgui
PopupHelper propertiesPopup{PopupHelper(LABEL_TIMELINE_PROPERTIES_POPUP, POPUP_NORMAL)};
PopupHelper bakePopup{PopupHelper(LABEL_TIMELINE_BAKE_POPUP, POPUP_SMALL_NO_HEIGHT)};
std::string addItemName{"New Item"};
bool addItemIsRect{};
bool addItemIsShowRect{};
int addItemID{-1};
int addItemSpritesheetID{-1};
int hoveredTime{};

View File

@@ -498,7 +498,7 @@ namespace anm2ed
X(TOOLTIP_NEW_ITEM, "Create a new item.", "Crea un nuevo item.", "Создать новый предмет.", "创造一个新物品.", "새 항목을 만듭니다.") \
X(TOOLTIP_NO_UNUSED_ITEMS, "There are no unused items to use.", "No hay items sin utilizar para usar.", "Нет неиспользуемых предметов, которые использовать.", "没有可用的未使用物品.", "사용하지 않는 항목이 없습니다.") \
X(TOOLTIP_NULL_NAME, "Set the null's name.", "Ajusta el nombre del Null.", "Назвать этот нуль.", "更改Null的名字.", "Null의 이름을 설정합니다.") \
X(TOOLTIP_NULL_RECT, "The null will have a rectangle show around it.", "Null tendra una guia de rectangulo alrededor.", "Около этого нуля будет прямоугольник.", "此Null周围会显示一个方框.", "Null의 주변에 사각형 표시니다.") \
X(TOOLTIP_NULL_RECT, "Toggle to show the null as a rectangle.", "Alterna para mostrar el null como un rectangulo.", "Переключите, чтобы показывать null как прямоугольник.", "切换以将此Null显示为方框.", "Null 사각형으로 표시하도록 전환합니다.") \
X(TOOLTIP_NULL_RECT_HIDDEN, "The null's rectangle is hidden. Press to show it.", "La guia de rectangulo de Null esta oculta. Presiona para mostrarla.", "Прямоугольник этого нуля скрыт. Нажмите, чтобы его показать.", "此Null的方框已隐藏. 点击以显示.", "Null의 사각형이 숨겨져 있습니다. 표시하려면 누르세요.") \
X(TOOLTIP_NULL_RECT_SHOWN, "The null's rectangle is shown. Press to hide it.", "La guia de rectangulo de Null esta visible. Presiona para ocultarla.", "Прямоугольник этого нуля видим. Нажмите, чтобы его скрыть.", "此Null的方框当前可见. 点击以隐藏.", "Null의 사각형이 표시되어 있습니다. 숨기려면 누르세요.") \
X(TOOLTIP_NULL_TYPE, "Add a null item.", "Añade un item Null.", "Добавить нулевой предмет.", "添加一个Null物品.", "Null 항목을 추가합니다.") \

View File

@@ -40,6 +40,6 @@ Alternatively, if you have subscribed to the mod, you can find the latest releas
[h3]Happy animating![/h3]
[img]https://files.catbox.moe/4auc1c.gif[/img]
</description>
<version>2.8</version>
<version>2.9</version>
<visibility>Public</visibility>
</metadata>