miscellaneous sloppa fixes

This commit is contained in:
2026-04-20 13:54:49 -04:00
parent bfe9e3e982
commit d39a1dac3c
11 changed files with 172 additions and 109 deletions
+3 -22
View File
@@ -1,5 +1,6 @@
#include "document.hpp" #include "document.hpp"
#include <new>
#include <utility> #include <utility>
#include <format> #include <format>
@@ -86,28 +87,8 @@ namespace anm2ed
Document& Document::operator=(Document&& other) noexcept Document& Document::operator=(Document&& other) noexcept
{ {
if (this != &other) if (this != &other)
{ this->~Document();
path = std::move(other.path); new (this) Document(std::move(other));
snapshots = std::move(other.snapshots);
previewZoom = other.previewZoom;
previewPan = other.previewPan;
editorPan = other.editorPan;
editorZoom = other.editorZoom;
overlayIndex = other.overlayIndex;
regionBySpritesheet = std::move(other.regionBySpritesheet);
changeAllFramePropertiesRegionId = other.changeAllFramePropertiesRegionId;
hash = other.hash;
saveHash = other.saveHash;
autosaveHash = other.autosaveHash;
lastAutosaveTime = other.lastAutosaveTime;
isValid = other.isValid;
isOpen = other.isOpen;
isForceDirty = other.isForceDirty;
spritesheetHashes = std::move(other.spritesheetHashes);
spritesheetSaveHashes = std::move(other.spritesheetSaveHashes);
isAnimationPreviewSet = other.isAnimationPreviewSet;
isSpritesheetEditorSet = other.isSpritesheetEditorSet;
}
return *this; return *this;
} }
+5 -1
View File
@@ -39,7 +39,10 @@ namespace anm2ed::imgui
if (type == anm2::LAYER && document.reference.itemID != -1) if (type == anm2::LAYER && document.reference.itemID != -1)
{ {
auto spritesheetID = document.anm2.content.layers.at(document.reference.itemID).spritesheetID; if (auto layerIt = document.anm2.content.layers.find(document.reference.itemID);
layerIt != document.anm2.content.layers.end())
{
auto spritesheetID = layerIt->second.spritesheetID;
auto regionIt = document.regionBySpritesheet.find(spritesheetID); auto regionIt = document.regionBySpritesheet.find(spritesheetID);
if (regionIt != document.regionBySpritesheet.end() && !regionIt->second.ids.empty() && if (regionIt != document.regionBySpritesheet.end() && !regionIt->second.ids.empty() &&
!regionIt->second.labels.empty()) !regionIt->second.labels.empty())
@@ -48,6 +51,7 @@ namespace anm2ed::imgui
regionIds = regionIt->second.ids; regionIds = regionIt->second.ids;
} }
} }
}
if (frames.size() <= 1) if (frames.size() <= 1)
{ {
+7
View File
@@ -482,6 +482,13 @@ namespace anm2ed::imgui
if (ImGui::BeginPopupModal(propertiesPopup.label(), &propertiesPopup.isOpen, ImGuiWindowFlags_NoResize)) if (ImGui::BeginPopupModal(propertiesPopup.label(), &propertiesPopup.isOpen, ImGuiWindowFlags_NoResize))
{ {
if (!spritesheet || (reference != -1 && !spritesheet->regions.contains(reference)))
{
propertiesPopup.close();
ImGui::EndPopup();
return;
}
auto childSize = child_size_get(5); auto childSize = child_size_get(5);
auto& region = reference == -1 ? editRegion : spritesheet->regions.at(reference); auto& region = reference == -1 ? editRegion : spritesheet->regions.at(reference);
+12 -7
View File
@@ -227,10 +227,13 @@ namespace anm2ed::imgui
} }
} }
auto layerIt = anm2.content.layers.find(reference.itemID);
bool isReferenceLayerOnSpritesheet =
frame && reference.itemID > -1 && layerIt != anm2.content.layers.end() &&
layerIt->second.spritesheetID == referenceSpritesheet;
int highlightedRegionId = -1; int highlightedRegionId = -1;
if (frame && reference.itemID > -1 && if (isReferenceLayerOnSpritesheet && frame->regionID != -1 && spritesheet->regions.contains(frame->regionID))
anm2.content.layers.at(reference.itemID).spritesheetID == referenceSpritesheet && frame->regionID != -1 &&
spritesheet->regions.contains(frame->regionID))
{ {
highlightedRegionId = frame->regionID; highlightedRegionId = frame->regionID;
} }
@@ -271,8 +274,7 @@ namespace anm2ed::imgui
} }
} }
bool isFrameOnSpritesheet = bool isFrameOnSpritesheet = isReferenceLayerOnSpritesheet;
frame && reference.itemID > -1 && anm2.content.layers.at(reference.itemID).spritesheetID == referenceSpritesheet;
if (isFrameOnSpritesheet && frame->regionID == -1) if (isFrameOnSpritesheet && frame->regionID == -1)
{ {
auto frameModel = math::quad_model_get(frame->size, frame->crop); auto frameModel = math::quad_model_get(frame->size, frame->crop);
@@ -338,6 +340,10 @@ namespace anm2ed::imgui
auto isMod = ImGui::IsKeyDown(ImGuiMod_Shift); auto isMod = ImGui::IsKeyDown(ImGuiMod_Shift);
auto frame = document.frame_get(); auto frame = document.frame_get();
auto layerIt = anm2.content.layers.find(reference.itemID);
bool isReferenceLayerOnSpritesheet =
frame && reference.itemID > -1 && layerIt != anm2.content.layers.end() &&
layerIt->second.spritesheetID == referenceSpritesheet;
auto useTool = tool; auto useTool = tool;
auto step = isMod ? STEP_FAST : STEP; auto step = isMod ? STEP_FAST : STEP;
auto stepX = isGridSnap ? step * gridSize.x : step; auto stepX = isGridSnap ? step * gridSize.x : step;
@@ -440,8 +446,7 @@ namespace anm2ed::imgui
{ {
regionReference = hoveredRegionId; regionReference = hoveredRegionId;
regionSelection = {hoveredRegionId}; regionSelection = {hoveredRegionId};
if (frame && reference.itemID > -1 && if (isReferenceLayerOnSpritesheet)
anm2.content.layers.at(reference.itemID).spritesheetID == referenceSpritesheet)
{ {
DOCUMENT_EDIT(document, localize.get(EDIT_FRAME_REGION), Document::FRAMES, DOCUMENT_EDIT(document, localize.get(EDIT_FRAME_REGION), Document::FRAMES,
{ {
+66 -31
View File
@@ -653,17 +653,33 @@ namespace anm2ed::imgui
ImGui::PushID(index); ImGui::PushID(index);
auto item = animation ? animation->item_get(type, id) : nullptr; auto item = animation ? animation->item_get(type, id) : nullptr;
if (type != anm2::NONE && !item)
{
ImGui::PopID();
return;
}
auto isVisible = item ? item->isVisible : false; auto isVisible = item ? item->isVisible : false;
auto& isOnlyShowLayers = settings.timelineIsOnlyShowLayers; auto& isOnlyShowLayers = settings.timelineIsOnlyShowLayers;
if (isOnlyShowLayers && type != anm2::LAYER) isVisible = false; if (isOnlyShowLayers && type != anm2::LAYER) isVisible = false;
auto isReferenced = reference.itemType == type && reference.itemID == id; auto isReferenced = reference.itemType == type && reference.itemID == id;
auto label = type == anm2::LAYER ? std::vformat(localize.get(FORMAT_LAYER), auto label = [&]() -> std::string
std::make_format_args(id, anm2.content.layers[id].name, {
anm2.content.layers[id].spritesheetID)) if (type == anm2::LAYER)
: type == anm2::NULL_ {
? std::vformat(localize.get(FORMAT_NULL), std::make_format_args(id, anm2.content.nulls[id].name)) auto it = anm2.content.layers.find(id);
: localize.get(anm2::TYPE_STRINGS[type]); if (it == anm2.content.layers.end()) return localize.get(anm2::TYPE_STRINGS[type]);
return std::vformat(localize.get(FORMAT_LAYER),
std::make_format_args(id, it->second.name, it->second.spritesheetID));
}
if (type == anm2::NULL_)
{
auto it = anm2.content.nulls.find(id);
if (it == anm2.content.nulls.end()) return localize.get(anm2::TYPE_STRINGS[type]);
return std::vformat(localize.get(FORMAT_NULL), std::make_format_args(id, it->second.name));
}
return localize.get(anm2::TYPE_STRINGS[type]);
}();
auto icon = anm2::TYPE_ICONS[type]; auto icon = anm2::TYPE_ICONS[type];
auto iconTintCurrent = isLightTheme && type == anm2::NONE ? ImVec4(1.0f, 1.0f, 1.0f, 1.0f) : itemIconTint; auto iconTintCurrent = isLightTheme && type == anm2::NONE ? ImVec4(1.0f, 1.0f, 1.0f, 1.0f) : itemIconTint;
auto baseColorVec = item_color_vec(type); auto baseColorVec = item_color_vec(type);
@@ -699,7 +715,9 @@ namespace anm2ed::imgui
ImGui::SetNextItemStorageID(id); ImGui::SetNextItemStorageID(id);
if (ImGui::Selectable("##Item Button", isReferenced, ImGuiSelectableFlags_SelectOnClick, itemSize)) if (ImGui::Selectable("##Item Button", isReferenced, ImGuiSelectableFlags_SelectOnClick, itemSize))
{ {
if (type == anm2::LAYER) document.spritesheet.reference = anm2.content.layers[id].spritesheetID; if (type == anm2::LAYER)
if (auto it = anm2.content.layers.find(id); it != anm2.content.layers.end())
document.spritesheet.reference = it->second.spritesheetID;
reference_set_item(type, id); reference_set_item(type, id);
} }
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
@@ -743,7 +761,9 @@ namespace anm2ed::imgui
} }
case anm2::LAYER: case anm2::LAYER:
{ {
auto& layer = anm2.content.layers[id]; auto it = anm2.content.layers.find(id);
if (it == anm2.content.layers.end()) break;
auto& layer = it->second;
ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE); ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE);
ImGui::TextUnformatted(layer.name.c_str()); ImGui::TextUnformatted(layer.name.c_str());
ImGui::PopFont(); ImGui::PopFont();
@@ -760,7 +780,9 @@ namespace anm2ed::imgui
} }
case anm2::NULL_: case anm2::NULL_:
{ {
auto& nullInfo = anm2.content.nulls[id]; auto it = anm2.content.nulls.find(id);
if (it == anm2.content.nulls.end()) break;
auto& nullInfo = it->second;
ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE); ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE);
ImGui::TextUnformatted(nullInfo.name.c_str()); ImGui::TextUnformatted(nullInfo.name.c_str());
ImGui::PopFont(); ImGui::PopFont();
@@ -853,7 +875,9 @@ namespace anm2ed::imgui
if (type == anm2::NULL_) if (type == anm2::NULL_)
{ {
auto& null = anm2.content.nulls.at(id); if (auto it = anm2.content.nulls.find(id); it != anm2.content.nulls.end())
{
auto& null = it->second;
auto& isShowRect = null.isShowRect; auto& isShowRect = null.isShowRect;
auto rectIcon = isShowRect ? icon::SHOW_RECT : icon::HIDE_RECT; auto rectIcon = isShowRect ? icon::SHOW_RECT : icon::HIDE_RECT;
ImGui::SetCursorPos( ImGui::SetCursorPos(
@@ -866,6 +890,7 @@ namespace anm2ed::imgui
ImGui::SetItemTooltip("%s", isShowRect ? localize.get(TOOLTIP_NULL_RECT_SHOWN) ImGui::SetItemTooltip("%s", isShowRect ? localize.get(TOOLTIP_NULL_RECT_SHOWN)
: localize.get(TOOLTIP_NULL_RECT_HIDDEN)); : localize.get(TOOLTIP_NULL_RECT_HIDDEN));
} }
}
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
@@ -1229,7 +1254,9 @@ namespace anm2ed::imgui
bool isDifferentItem = reference.itemType != type || reference.itemID != id; bool isDifferentItem = reference.itemType != type || reference.itemID != id;
if (ImGui::Selectable("##Frame Button", isSelected, ImGuiSelectableFlags_None, buttonSize)) if (ImGui::Selectable("##Frame Button", isSelected, ImGuiSelectableFlags_None, buttonSize))
{ {
if (type == anm2::LAYER) document.spritesheet.reference = anm2.content.layers[id].spritesheetID; if (type == anm2::LAYER)
if (auto it = anm2.content.layers.find(id); it != anm2.content.layers.end())
document.spritesheet.reference = it->second.spritesheetID;
if (type != anm2::TRIGGER) if (type != anm2::TRIGGER)
{ {
@@ -1275,11 +1302,12 @@ namespace anm2ed::imgui
frameDragDrop.type = type; frameDragDrop.type = type;
frameDragDrop.itemID = id; frameDragDrop.itemID = id;
frameDragDrop.animationIndex = reference.animationIndex; frameDragDrop.animationIndex = reference.animationIndex;
frameSelectionLocked.clear();
auto append_valid_indices = [&](const auto& container) auto append_valid_indices = [&](const auto& container)
{ {
for (auto idx : container) for (auto idx : container)
if (idx >= 0 && idx < (int)item->frames.size()) frameDragDrop.selection.push_back(idx); if (idx >= 0 && idx < (int)item->frames.size()) frameSelectionLocked.push_back(idx);
}; };
if (isReferenced) append_valid_indices(frames.selection); if (isReferenced) append_valid_indices(frames.selection);
@@ -1287,27 +1315,26 @@ namespace anm2ed::imgui
auto contains_index = [&](const std::vector<int>& container, int index) auto contains_index = [&](const std::vector<int>& container, int index)
{ return std::find(container.begin(), container.end(), index) != container.end(); }; { return std::find(container.begin(), container.end(), index) != container.end(); };
if ((!contains_index(frameDragDrop.selection, (int)i) || frameDragDrop.selection.size() <= 1) && if ((!contains_index(frameSelectionLocked, (int)i) || frameSelectionLocked.size() <= 1) &&
frameSelectionSnapshotReference.animationIndex == reference.animationIndex && frameSelectionSnapshotReference.animationIndex == reference.animationIndex &&
frameSelectionSnapshotReference.itemType == type && frameSelectionSnapshotReference.itemID == id && frameSelectionSnapshotReference.itemType == type && frameSelectionSnapshotReference.itemID == id &&
contains_index(frameSelectionSnapshot, (int)i)) contains_index(frameSelectionSnapshot, (int)i))
{ {
frameDragDrop.selection = frameSelectionSnapshot; frameSelectionLocked = frameSelectionSnapshot;
frames.selection.clear(); frames.selection.clear();
for (int idx : frameSelectionSnapshot) for (int idx : frameSelectionSnapshot)
if (idx >= 0 && idx < (int)item->frames.size()) frames.selection.insert(idx); if (idx >= 0 && idx < (int)item->frames.size()) frames.selection.insert(idx);
frameSelectionLocked = frameDragDrop.selection;
isFrameSelectionLocked = true; isFrameSelectionLocked = true;
} }
if (frameDragDrop.selection.empty()) frameDragDrop.selection.push_back((int)i); if (frameSelectionLocked.empty()) frameSelectionLocked.push_back((int)i);
std::sort(frameDragDrop.selection.begin(), frameDragDrop.selection.end()); std::sort(frameSelectionLocked.begin(), frameSelectionLocked.end());
frameDragDrop.selection.erase( frameSelectionLocked.erase(std::unique(frameSelectionLocked.begin(), frameSelectionLocked.end()),
std::unique(frameDragDrop.selection.begin(), frameDragDrop.selection.end()), frameSelectionLocked.end());
frameDragDrop.selection.end());
ImGui::SetDragDropPayload(FRAME_DRAG_PAYLOAD_ID, &frameDragDrop, sizeof(FrameDragDrop)); frameDragDropPayload = {type, id, reference.animationIndex};
ImGui::SetDragDropPayload(FRAME_DRAG_PAYLOAD_ID, &frameDragDropPayload, sizeof(frameDragDropPayload));
ImGui::EndDragDropSource(); ImGui::EndDragDropSource();
} }
@@ -1315,7 +1342,7 @@ namespace anm2ed::imgui
{ {
if (auto payload = ImGui::AcceptDragDropPayload(FRAME_DRAG_PAYLOAD_ID)) if (auto payload = ImGui::AcceptDragDropPayload(FRAME_DRAG_PAYLOAD_ID))
{ {
auto source = static_cast<const FrameDragDrop*>(payload->Data); auto source = static_cast<const FrameDragDropPayload*>(payload->Data);
auto sameAnimation = source && source->animationIndex == reference.animationIndex; auto sameAnimation = source && source->animationIndex == reference.animationIndex;
auto sourceItem = auto sourceItem =
sameAnimation && animation ? animation->item_get(source->type, source->itemID) : nullptr; sameAnimation && animation ? animation->item_get(source->type, source->itemID) : nullptr;
@@ -1333,7 +1360,7 @@ namespace anm2ed::imgui
if (source && sourceItem && targetItem && source->type != anm2::TRIGGER && type != anm2::TRIGGER) if (source && sourceItem && targetItem && source->type != anm2::TRIGGER && type != anm2::TRIGGER)
{ {
std::vector<int> indices = source->selection; std::vector<int> indices = frameSelectionLocked;
if (indices.empty()) indices.push_back((int)i); if (indices.empty()) indices.push_back((int)i);
std::sort(indices.begin(), indices.end()); std::sort(indices.begin(), indices.end());
indices.erase(std::unique(indices.begin(), indices.end()), indices.end()); indices.erase(std::unique(indices.begin(), indices.end()), indices.end());
@@ -1387,7 +1414,8 @@ namespace anm2ed::imgui
document.frameTime = time_from_index(targetItem, reference.frameIndex); document.frameTime = time_from_index(targetItem, reference.frameIndex);
if (type == anm2::LAYER) if (type == anm2::LAYER)
{ {
document.spritesheet.reference = anm2.content.layers[id].spritesheetID; if (auto it = anm2.content.layers.find(id); it != anm2.content.layers.end())
document.spritesheet.reference = it->second.spritesheetID;
} }
} }
} }
@@ -1496,6 +1524,7 @@ namespace anm2ed::imgui
draggedFrameStart = -1; draggedFrameStart = -1;
draggedFrameStartDuration = -1; draggedFrameStartDuration = -1;
isDraggedFrameSnapshot = false; isDraggedFrameSnapshot = false;
frameSelectionLocked.clear();
if (type == anm2::TRIGGER) item->frames_sort_by_at_frame(); if (type == anm2::TRIGGER) item->frames_sort_by_at_frame();
} }
} }
@@ -1858,18 +1887,23 @@ namespace anm2ed::imgui
if (type == anm2::LAYER) if (type == anm2::LAYER)
{ {
auto& layer = anm2.content.layers[id]; if (auto it = anm2.content.layers.find(id); it != anm2.content.layers.end())
auto label = {
std::vformat(localize.get(FORMAT_LAYER), std::make_format_args(id, layer.name, layer.spritesheetID)); auto& layer = it->second;
auto label = std::vformat(localize.get(FORMAT_LAYER),
std::make_format_args(id, layer.name, layer.spritesheetID));
if (ImGui::Selectable(label.c_str(), isSelected)) if (ImGui::Selectable(label.c_str(), isSelected))
{ {
addItemID = id; addItemID = id;
addItemSpritesheetID = layer.spritesheetID; addItemSpritesheetID = layer.spritesheetID;
} }
} }
}
else if (type == anm2::NULL_) else if (type == anm2::NULL_)
{ {
auto& null = anm2.content.nulls[id]; if (auto it = anm2.content.nulls.find(id); it != anm2.content.nulls.end())
{
auto& null = it->second;
auto label = std::vformat(localize.get(FORMAT_NULL), std::make_format_args(id, null.name)); auto label = std::vformat(localize.get(FORMAT_NULL), std::make_format_args(id, null.name));
if (ImGui::Selectable(label.c_str(), isSelected)) if (ImGui::Selectable(label.c_str(), isSelected))
{ {
@@ -1877,6 +1911,7 @@ namespace anm2ed::imgui
addItemIsShowRect = null.isShowRect; addItemIsShowRect = null.isShowRect;
} }
} }
}
ImGui::PopID(); ImGui::PopID();
} }
@@ -2009,16 +2044,16 @@ namespace anm2ed::imgui
auto isNextFrame = shortcut(manager.chords[SHORTCUT_NEXT_FRAME], shortcut::GLOBAL); auto isNextFrame = shortcut(manager.chords[SHORTCUT_NEXT_FRAME], shortcut::GLOBAL);
if (isPreviousFrame) if (isPreviousFrame)
if (auto item = document.item_get(); !item->frames.empty()) if (auto item = document.item_get(); item && !item->frames.empty())
reference.frameIndex = glm::clamp(--reference.frameIndex, 0, (int)item->frames.size() - 1); reference.frameIndex = glm::clamp(--reference.frameIndex, 0, (int)item->frames.size() - 1);
if (isNextFrame) if (isNextFrame)
if (auto item = document.item_get(); !item->frames.empty()) if (auto item = document.item_get(); item && !item->frames.empty())
reference.frameIndex = glm::clamp(++reference.frameIndex, 0, (int)item->frames.size() - 1); reference.frameIndex = glm::clamp(++reference.frameIndex, 0, (int)item->frames.size() - 1);
if (isPreviousFrame || isNextFrame) if (isPreviousFrame || isNextFrame)
{ {
if (auto item = document.item_get(); !item->frames.empty()) if (auto item = document.item_get(); item && !item->frames.empty())
{ {
frames_selection_set_reference(); frames_selection_set_reference();
document.frameTime = item->frame_time_from_index_get(reference.frameIndex); document.frameTime = item->frame_time_from_index_get(reference.frameIndex);
+8 -1
View File
@@ -15,7 +15,13 @@ namespace anm2ed::imgui
anm2::Type type{anm2::NONE}; anm2::Type type{anm2::NONE};
int itemID{-1}; int itemID{-1};
int animationIndex{-1}; int animationIndex{-1};
std::vector<int> selection{}; };
struct FrameDragDropPayload
{
anm2::Type type{anm2::NONE};
int itemID{-1};
int animationIndex{-1};
}; };
class Timeline class Timeline
@@ -39,6 +45,7 @@ namespace anm2ed::imgui
bool frameFocusRequested{}; bool frameFocusRequested{};
int frameFocusIndex{-1}; int frameFocusIndex{-1};
FrameDragDrop frameDragDrop{}; FrameDragDrop frameDragDrop{};
FrameDragDropPayload frameDragDropPayload{};
std::vector<int> frameSelectionSnapshot{}; std::vector<int> frameSelectionSnapshot{};
std::vector<int> frameSelectionLocked{}; std::vector<int> frameSelectionLocked{};
bool isFrameSelectionLocked{}; bool isFrameSelectionLocked{};
@@ -234,10 +234,14 @@ namespace anm2ed::imgui::wizard
const Storage* regionStorage = nullptr; const Storage* regionStorage = nullptr;
if (itemType == anm2::LAYER && document.reference.itemID != -1) if (itemType == anm2::LAYER && document.reference.itemID != -1)
{ {
auto spritesheetID = document.anm2.content.layers.at(document.reference.itemID).spritesheetID; if (auto layerIt = document.anm2.content.layers.find(document.reference.itemID);
layerIt != document.anm2.content.layers.end())
{
auto spritesheetID = layerIt->second.spritesheetID;
auto regionIt = document.regionBySpritesheet.find(spritesheetID); auto regionIt = document.regionBySpritesheet.find(spritesheetID);
if (regionIt != document.regionBySpritesheet.end()) regionStorage = &regionIt->second; if (regionIt != document.regionBySpritesheet.end()) regionStorage = &regionIt->second;
} }
}
auto regionIds = regionStorage && !regionStorage->ids.empty() ? regionStorage->ids : fallbackIds; auto regionIds = regionStorage && !regionStorage->ids.empty() ? regionStorage->ids : fallbackIds;
auto regionLabels = regionStorage && !regionStorage->labels.empty() ? regionStorage->labels : fallbackLabels; auto regionLabels = regionStorage && !regionStorage->labels.empty() ? regionStorage->labels : fallbackLabels;
if (itemType != anm2::LAYER || std::find(regionIds.begin(), regionIds.end(), regionId) == regionIds.end()) regionId = -1; if (itemType != anm2::LAYER || std::find(regionIds.begin(), regionIds.end(), regionId) == regionIds.end()) regionId = -1;
@@ -289,10 +293,13 @@ namespace anm2ed::imgui::wizard
if (isFlipXSet) frameChange.isFlipX = std::make_optional(isFlipX); if (isFlipXSet) frameChange.isFlipX = std::make_optional(isFlipX);
if (isFlipYSet) frameChange.isFlipY = std::make_optional(isFlipY); if (isFlipYSet) frameChange.isFlipY = std::make_optional(isFlipY);
if (auto item = document.item_get())
{
DOCUMENT_EDIT(document, localize.get(EDIT_CHANGE_FRAME_PROPERTIES), Document::FRAMES, DOCUMENT_EDIT(document, localize.get(EDIT_CHANGE_FRAME_PROPERTIES), Document::FRAMES,
document.item_get()->frames_change(frameChange, itemType, changeType, frames)); item->frames_change(frameChange, itemType, changeType, frames));
isChanged = true; isChanged = true;
}
}; };
ImGui::Separator(); ImGui::Separator();
@@ -57,9 +57,13 @@ namespace anm2ed::imgui::wizard
if (document.reference.itemType == anm2::LAYER) if (document.reference.itemType == anm2::LAYER)
{ {
auto& texture = auto layerIt = document.anm2.content.layers.find(document.reference.itemID);
document.anm2.content.spritesheets[document.anm2.content.layers[document.reference.itemID].spritesheetID] if (layerIt != document.anm2.content.layers.end())
.texture; {
auto spritesheetIt = document.anm2.content.spritesheets.find(layerIt->second.spritesheetID);
if (spritesheetIt != document.anm2.content.spritesheets.end())
{
auto& texture = spritesheetIt->second.texture;
auto index = std::clamp((int)(time * (count - 1)), 0, (count - 1)); auto index = std::clamp((int)(time * (count - 1)), 0, (count - 1));
auto row = index / columns; auto row = index / columns;
@@ -73,6 +77,8 @@ namespace anm2ed::imgui::wizard
texture_render(shaderTexture, texture.id, transform, vec4(1.0f), {}, texture_render(shaderTexture, texture.id, transform, vec4(1.0f), {},
math::uv_vertices_get(uvMin, uvMax).data()); math::uv_vertices_get(uvMin, uvMax).data());
} }
}
}
unbind(); unbind();
+6 -2
View File
@@ -199,8 +199,10 @@ namespace anm2ed
{ {
if (id == -1) if (id == -1)
editLayer = anm2::Layer(); editLayer = anm2::Layer();
else if (auto it = document->anm2.content.layers.find(id); it != document->anm2.content.layers.end())
editLayer = it->second;
else else
editLayer = document->anm2.content.layers.at(id); return;
document->layer.reference = id; document->layer.reference = id;
@@ -224,8 +226,10 @@ namespace anm2ed
{ {
if (id == -1) if (id == -1)
editNull = anm2::Null(); editNull = anm2::Null();
else if (auto it = document->anm2.content.nulls.find(id); it != document->anm2.content.nulls.end())
editNull = it->second;
else else
editNull = document->anm2.content.nulls.at(id); return;
document->null.reference = id; document->null.reference = id;
+9 -2
View File
@@ -1,6 +1,7 @@
#include "socket.hpp" #include "socket.hpp"
#include <cerrno> #include <cerrno>
#include <climits>
namespace anm2ed namespace anm2ed
{ {
@@ -203,7 +204,12 @@ namespace anm2ed
while (totalSent < size) while (totalSent < size)
{ {
auto sent = ::send(handle, bytes + totalSent, static_cast<int>(size - totalSent), 0); auto chunkSize = static_cast<int>(std::min<size_t>(size - totalSent, static_cast<size_t>(INT_MAX)));
#ifdef MSG_NOSIGNAL
auto sent = ::send(handle, bytes + totalSent, chunkSize, MSG_NOSIGNAL);
#else
auto sent = ::send(handle, bytes + totalSent, chunkSize, 0);
#endif
if (sent <= 0) if (sent <= 0)
{ {
lastError = socket_last_error(); lastError = socket_last_error();
@@ -229,7 +235,8 @@ namespace anm2ed
while (totalReceived < size) while (totalReceived < size)
{ {
auto received = ::recv(handle, bytes + totalReceived, static_cast<int>(size - totalReceived), 0); auto chunkSize = static_cast<int>(std::min<size_t>(size - totalReceived, static_cast<size_t>(INT_MAX)));
auto received = ::recv(handle, bytes + totalReceived, chunkSize, 0);
if (received <= 0) if (received <= 0)
{ {
lastError = socket_last_error(); lastError = socket_last_error();
+1 -1
View File
@@ -53,6 +53,6 @@ Alternatively, if you have subscribed to the mod, you can find the latest releas
[h3]Happy animating![/h3] [h3]Happy animating![/h3]
[img]https://files.catbox.moe/4auc1c.gif[/img] [img]https://files.catbox.moe/4auc1c.gif[/img]
</description> </description>
<version>2.16</version> <version>2.17</version>
<visibility>Public</visibility> <visibility>Public</visibility>
</metadata> </metadata>