remove overlay window, add document overlay + over/under

This commit is contained in:
shweet committed 2026-08-07 14:42:16 -04:00
1 parent e32e781b46
commit a4b34cc0be
22 files changed
+261 -1381

No files matched your search

+13 -57
View File
@@ -95,10 +95,9 @@ namespace anm2ed
"", "", "EaseIn", "EaseOut", "EaseInOut"};
constexpr std::array<std::string_view, (std::size_t)Origin::COUNT> ORIGIN_VALUES = {"", "TopLeft", "Center"};
constexpr std::array<std::string_view, (std::size_t)OverlayDrawOrder::COUNT> OVERLAY_DRAW_ORDER_VALUES = {"Below",
"Above"};
constexpr std::string_view ANM2ED_GROUP_FRAME_BACKUP_TAG = "FrameRestore";
constexpr std::string_view SOURCE_DOCUMENT_TAG = "SourceDocument";
constexpr std::string_view LEGACY_OVERLAY_TAG = "Overlay";
void group_metadata_embed(Element&);
void group_metadata_extract(Element&, Flags);
@@ -234,7 +233,6 @@ namespace anm2ed
Element element{};
element.type = type;
element.tag = std::string(element_tag_get(type));
if (type == ElementType::OVERLAY) element.index = OVERLAY_DRAW_ORDER_ABOVE;
return element;
}
@@ -454,29 +452,6 @@ namespace anm2ed
int color_write(float value) { return math::float_to_uint8(value); }
int overlay_draw_order_get(const Element& element)
{
return element.index == OVERLAY_DRAW_ORDER_BELOW ? OVERLAY_DRAW_ORDER_BELOW : OVERLAY_DRAW_ORDER_ABOVE;
}
void overlay_draw_order_read(Element& out, const XMLElement* element)
{
if (out.type != ElementType::OVERLAY) return;
out.index = OVERLAY_DRAW_ORDER_ABOVE;
if (element)
{
element->QueryFloatAttribute("XOffset", &out.position.x);
element->QueryFloatAttribute("YOffset", &out.position.y);
}
out.tint.a = color_read(element, "Alpha", out.tint.a);
auto value = element ? element->Attribute("DrawOrder") : nullptr;
if (!value) return;
for (std::size_t i = 0; i < OVERLAY_DRAW_ORDER_VALUES.size(); ++i)
if (OVERLAY_DRAW_ORDER_VALUES[i] == value) out.index = (int)i;
}
Interpolation interpolation_read(const XMLElement* element, const char* attribute)
{
bool isFallback{};
@@ -552,7 +527,6 @@ namespace anm2ed
out.interpolation = interpolation_read(element);
out.origin = origin_read(element);
overlay_draw_order_read(out, element);
if (out.type == ElementType::REGION && out.origin == Origin::TOP_LEFT) out.pivot = {};
if (out.type == ElementType::REGION && out.origin == Origin::CENTER) out.pivot = out.size * 0.5f;
}
@@ -578,7 +552,14 @@ namespace anm2ed
auto child = element->FirstChildElement();
while (child)
{
auto childType = element_type_get(child->Name() ? child->Name() : "");
auto childName = std::string_view(child->Name() ? child->Name() : "");
if (childName == LEGACY_OVERLAY_TAG)
{
child = child->NextSiblingElement();
continue;
}
auto childType = element_type_get(childName);
if (childType == ElementType::FRAME && is_track(out))
{
Interpolation bakeInterpolation{};
@@ -647,8 +628,8 @@ namespace anm2ed
bool element_write_skip(const Element& element, ElementType parentType, Flags flags)
{
if (!is_track_child_valid(parentType, element.type)) return true;
if ((element.type == ElementType::OVERLAY || element.type == ElementType::SHADER ||
element.type == ElementType::UNIFORM || element.type == ElementType::COMPONENT) &&
if ((element.type == ElementType::SHADER || element.type == ElementType::UNIFORM ||
element.type == ElementType::COMPONENT) &&
!has_flag(flags, SERIALIZE_EXTENSIONS))
return true;
if (element.type == ElementType::SOUNDS && (!has_flag(flags, SERIALIZE_SOUNDS) || element.children.empty()))
@@ -709,22 +690,10 @@ namespace anm2ed
}
else if (element.type == ElementType::ANIMATIONS)
out->SetAttribute("DefaultAnimation", element.defaultAnimation.c_str());
else if (element.type == ElementType::SPRITESHEET || element.type == ElementType::OVERLAY)
else if (element.type == ElementType::SPRITESHEET)
{
out->SetAttribute("Id", element.id);
path_set(out, "Path", element.path);
if (element.type == ElementType::OVERLAY)
{
if (!element.isVisible) out->SetAttribute("Visible", element.isVisible);
if (element.position != glm::vec2())
{
out->SetAttribute("XOffset", element.position.x);
out->SetAttribute("YOffset", element.position.y);
}
if (color_write(element.tint.a) != 255) out->SetAttribute("Alpha", color_write(element.tint.a));
if (overlay_draw_order_get(element) == OVERLAY_DRAW_ORDER_BELOW)
out->SetAttribute("DrawOrder", OVERLAY_DRAW_ORDER_VALUES[OVERLAY_DRAW_ORDER_BELOW].data());
}
}
else if (element.type == ElementType::SHADER)
{
@@ -1047,23 +1016,10 @@ namespace anm2ed
}
else if (element.type == ElementType::ANIMATIONS)
hash_attr_append(hash, "DefaultAnimation", element.defaultAnimation);
else if (element.type == ElementType::SPRITESHEET || element.type == ElementType::OVERLAY)
else if (element.type == ElementType::SPRITESHEET)
{
hash_attr_append(hash, "Id", element.id);
hash_path_attr_append(hash, "Path", element.path);
if (element.type == ElementType::OVERLAY && !element.isVisible)
hash_attr_append(hash, "Visible", element.isVisible);
if (element.type == ElementType::OVERLAY)
{
if (element.position != glm::vec2())
{
hash_attr_append(hash, "XOffset", element.position.x);
hash_attr_append(hash, "YOffset", element.position.y);
}
if (color_write(element.tint.a) != 255) hash_attr_append(hash, "Alpha", color_write(element.tint.a));
if (overlay_draw_order_get(element) == OVERLAY_DRAW_ORDER_BELOW)
hash_attr_append(hash, "DrawOrder", OVERLAY_DRAW_ORDER_VALUES[OVERLAY_DRAW_ORDER_BELOW]);
}
}
else if (element.type == ElementType::SHADER)
{
-11
View File
@@ -22,7 +22,6 @@
X(CONTENT, "Content") \
X(SPRITESHEETS, "Spritesheets") \
X(SPRITESHEET, "Spritesheet") \
X(OVERLAY, "Overlay") \
X(SHADER, "Shader") \
X(UNIFORM, "Uniform") \
X(COMPONENT, "Component") \
@@ -110,16 +109,6 @@ namespace anm2ed
inline constexpr int APPEND_RIGHT = (int)SpritesheetMergeOrigin::APPEND_RIGHT;
inline constexpr int APPEND_BOTTOM = (int)SpritesheetMergeOrigin::APPEND_BOTTOM;
enum class OverlayDrawOrder
{
BELOW,
ABOVE,
COUNT
};
inline constexpr int OVERLAY_DRAW_ORDER_BELOW = (int)OverlayDrawOrder::BELOW;
inline constexpr int OVERLAY_DRAW_ORDER_ABOVE = (int)OverlayDrawOrder::ABOVE;
inline const glm::vec4 ROOT_COLOR = glm::vec4(0.140f, 0.310f, 0.560f, 1.000f);
inline const glm::vec4 ROOT_COLOR_ACTIVE = glm::vec4(0.240f, 0.520f, 0.880f, 1.000f);
inline const glm::vec4 ROOT_COLOR_HOVERED = glm::vec4(0.320f, 0.640f, 1.000f, 1.000f);
-3
View File
@@ -49,9 +49,6 @@ namespace anm2ed
X(ANM2_SAVE, ANM2) \
X(SOUND_OPEN, SOUND) \
X(SOUND_REPLACE, SOUND) \
X(OVERLAY_OPEN, PNG) \
X(OVERLAY_REPLACE, PNG) \
X(OVERLAY_PATH_SET, PNG) \
X(SPRITESHEET_OPEN, PNG) \
X(SPRITESHEET_REPLACE, PNG) \
X(SPRITESHEET_PATH_SET, PNG) \
+7 -304
View File
@@ -311,41 +311,6 @@ namespace anm2ed::document
return ids;
}
std::vector<std::string> overlay_labels_get(const Element* spritesheet)
{
std::vector<std::string> labels{};
if (!spritesheet) return labels;
for (auto& overlay : spritesheet->children)
if (overlay.type == ElementType::OVERLAY)
{
auto pathString = path::to_utf8(overlay.path);
labels.emplace_back(std::vformat(localize.get(FORMAT_OVERLAY), std::make_format_args(overlay.id, pathString)));
}
return labels;
}
std::vector<int> overlay_ids_get(const Element* spritesheet)
{
std::vector<int> ids{};
if (!spritesheet) return ids;
for (auto& overlay : spritesheet->children)
if (overlay.type == ElementType::OVERLAY) ids.emplace_back(overlay.id);
return ids;
}
int overlay_next_id_get(const Anm2& data)
{
int nextId{};
if (auto spritesheets = data.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
for (auto& overlay : spritesheet.children)
if (overlay.type == ElementType::OVERLAY) nextId = std::max(nextId, overlay.id + 1);
}
return nextId;
}
std::vector<std::string> sound_labels_get(const Anm2& data)
{
std::vector<std::string> labels{localize.get(BASIC_NONE)};
@@ -552,20 +517,18 @@ namespace anm2ed
Document::Document(Document&& other) noexcept
: path(std::move(other.path)), tabId(other.tabId), snapshots(std::move(other.snapshots)), current(snapshots.current),
playback(current.playback), animation(current.animation), event(current.event), frames(current.frames),
items(current.items), layer(current.layer), merge(current.merge), null(current.null), overlay(current.overlay),
region(current.region), sound(current.sound), spritesheet(current.spritesheet), textures(current.textures),
overlayTextures(current.overlayTextures), sounds(current.sounds), anm2(current.anm2),
reference(current.reference), groupReferences(current.groupReferences),
items(current.items), layer(current.layer), merge(current.merge), null(current.null), region(current.region),
sound(current.sound), spritesheet(current.spritesheet), textures(current.textures), sounds(current.sounds),
anm2(current.anm2), reference(current.reference), groupReferences(current.groupReferences),
frameTime(current.frameTime), message(current.message), regionBySpritesheet(std::move(other.regionBySpritesheet)),
changeAllFramePropertiesRegionId(other.changeAllFramePropertiesRegionId), previewZoom(other.previewZoom),
previewPan(other.previewPan), editorPan(other.editorPan), editorZoom(other.editorZoom),
overlayIndex(other.overlayIndex), hash(other.hash), saveHash(other.saveHash), autosaveHash(other.autosaveHash),
overlayIndex(other.overlayIndex), overlayDocumentId(other.overlayDocumentId), 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)), overlayHashes(std::move(other.overlayHashes)),
overlaySaveHashes(std::move(other.overlaySaveHashes)), texturePaths(std::move(other.texturePaths)),
overlayTexturePaths(std::move(other.overlayTexturePaths)), soundPaths(std::move(other.soundPaths)),
shaderVertexPaths(std::move(other.shaderVertexPaths)),
spritesheetSaveHashes(std::move(other.spritesheetSaveHashes)), texturePaths(std::move(other.texturePaths)),
soundPaths(std::move(other.soundPaths)), shaderVertexPaths(std::move(other.shaderVertexPaths)),
shaderFragmentPaths(std::move(other.shaderFragmentPaths)), shaders(std::move(other.shaders)),
isAnimationPreviewSet(other.isAnimationPreviewSet), isSpritesheetEditorSet(other.isSpritesheetEditorSet),
editTarget(other.editTarget)
@@ -655,13 +618,6 @@ namespace anm2ed
change(SPRITESHEETS);
}
void Document::overlay_texture_change(int id)
{
auto texture = overlay_texture_get(id);
if (!texture || !overlay_get(id)) return;
change(SPRITESHEETS);
}
bool Document::texture_reload(int id)
{
auto spritesheet = anm2.element_get(ElementType::SPRITESHEET, id);
@@ -673,17 +629,6 @@ namespace anm2ed
return true;
}
bool Document::overlay_texture_reload(int id)
{
auto overlay = overlay_get(id);
if (!overlay) return false;
util::WorkingDirectory workingDirectory(directory_get());
overlayTextures[id] = resource::Texture(path::case_insensitive_find(overlay->path));
overlayTexturePaths[id] = overlay->path;
return true;
}
bool Document::sound_reload(int id)
{
auto sound = anm2.element_get(ElementType::SOUND_ELEMENT, id);
@@ -759,7 +704,6 @@ namespace anm2ed
if (type == ALL || type == SPRITESHEETS || type == TEXTURES)
{
std::set<int> validIds{};
std::set<int> validOverlayIds{};
util::WorkingDirectory workingDirectory(directory_get());
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
@@ -774,19 +718,6 @@ namespace anm2ed
texturePaths[spritesheet.id] = spritesheet.path;
}
for (auto& overlay : spritesheet.children)
{
if (overlay.type != ElementType::OVERLAY) continue;
validOverlayIds.insert(overlay.id);
auto isOverlayReload = !overlayTextures.contains(overlay.id) || !overlayTexturePaths.contains(overlay.id) ||
overlayTexturePaths.at(overlay.id) != overlay.path;
if (isOverlayReload)
{
overlayTextures[overlay.id] = resource::Texture(path::case_insensitive_find(overlay.path));
overlayTexturePaths[overlay.id] = overlay.path;
}
}
auto shaderElement = document::shader_element_get(spritesheet);
if (!shaderElement || !shaderElement->isEnabled || shaderElement->fragment.empty())
{
@@ -818,17 +749,6 @@ namespace anm2ed
++it;
}
for (auto it = overlayTextures.begin(); it != overlayTextures.end();)
{
if (!validOverlayIds.contains(it->first))
{
overlayTexturePaths.erase(it->first);
it = overlayTextures.erase(it);
}
else
++it;
}
for (auto it = shaders.begin(); it != shaders.end();)
{
if (!validIds.contains(it->first))
@@ -885,18 +805,6 @@ namespace anm2ed
return it == textures.end() ? nullptr : &it->second;
}
resource::Texture* Document::overlay_texture_get(int id)
{
auto it = overlayTextures.find(id);
return it == overlayTextures.end() ? nullptr : &it->second;
}
const resource::Texture* Document::overlay_texture_get(int id) const
{
auto it = overlayTextures.find(id);
return it == overlayTextures.end() ? nullptr : &it->second;
}
resource::Audio* Document::sound_get(int id)
{
auto it = sounds.find(id);
@@ -1912,7 +1820,6 @@ namespace anm2ed
{
spritesheetHashes.clear();
spritesheetSaveHashes.clear();
overlay_hashes_reset();
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
if (spritesheet.type == ElementType::SPRITESHEET)
@@ -1956,65 +1863,6 @@ namespace anm2ed
}
}
void Document::overlay_hashes_reset()
{
overlayHashes.clear();
overlaySaveHashes.clear();
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
for (auto& overlay : spritesheet.children)
if (overlay.type == ElementType::OVERLAY)
{
auto currentHash = document::spritesheet_hash_get(overlay, overlay_texture_get(overlay.id));
overlayHashes[overlay.id] = currentHash;
overlaySaveHashes[overlay.id] = currentHash;
}
}
}
void Document::overlay_hashes_sync()
{
std::set<int> validIds{};
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
for (auto& overlay : spritesheet.children)
if (overlay.type == ElementType::OVERLAY) validIds.insert(overlay.id);
}
for (auto it = overlayHashes.begin(); it != overlayHashes.end();)
{
if (!validIds.contains(it->first))
it = overlayHashes.erase(it);
else
++it;
}
for (auto it = overlaySaveHashes.begin(); it != overlaySaveHashes.end();)
{
if (!validIds.contains(it->first))
it = overlaySaveHashes.erase(it);
else
++it;
}
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
for (auto& overlay : spritesheet.children)
if (overlay.type == ElementType::OVERLAY)
{
auto currentHash = document::spritesheet_hash_get(overlay, overlay_texture_get(overlay.id));
overlayHashes[overlay.id] = currentHash;
if (!overlaySaveHashes.contains(overlay.id)) overlaySaveHashes[overlay.id] = currentHash;
}
}
}
void Document::change(ChangeType type)
{
hash_set();
@@ -2033,12 +1881,6 @@ namespace anm2ed
{
spritesheet.labels_set(document::spritesheet_labels_get(anm2), document::spritesheet_ids_get(anm2));
spritesheet_hashes_sync();
if (auto currentSpritesheet = anm2.element_get(ElementType::SPRITESHEET, spritesheet.reference))
overlay.labels_set(document::overlay_labels_get(currentSpritesheet),
document::overlay_ids_get(currentSpritesheet));
else
overlay.labels_set({}, {});
overlay_hashes_sync();
};
auto sounds_set = [&]() { sound.labels_set(document::sound_labels_get(anm2), document::sound_ids_get(anm2)); };
@@ -2132,45 +1974,6 @@ namespace anm2ed
return false;
}
void Document::overlay_hash_update(int id)
{
auto overlay = overlay_get(id);
if (!overlay) return;
assets_sync(TEXTURES);
overlayHashes[id] = document::spritesheet_hash_get(*overlay, overlay_texture_get(id));
}
void Document::overlay_hash_set_saved(int id)
{
auto overlay = overlay_get(id);
if (!overlay) return;
assets_sync(TEXTURES);
auto currentHash = document::spritesheet_hash_get(*overlay, overlay_texture_get(id));
overlayHashes[id] = currentHash;
overlaySaveHashes[id] = currentHash;
}
bool Document::overlay_is_dirty(int id)
{
if (!overlay_get(id)) return false;
if (!overlayHashes.contains(id)) overlay_hash_update(id);
auto saveIt = overlaySaveHashes.find(id);
if (saveIt == overlaySaveHashes.end()) return false;
return overlayHashes.at(id) != saveIt->second;
}
bool Document::overlay_any_dirty()
{
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
for (auto& overlay : spritesheet.children)
if (overlay.type == ElementType::OVERLAY && overlay_is_dirty(overlay.id)) return true;
}
return false;
}
std::filesystem::path Document::directory_get() const { return path.parent_path(); }
std::filesystem::path Document::filename_get() const { return path.filename(); }
bool Document::is_valid() const { return isValid && !path.empty(); }
@@ -2367,41 +2170,6 @@ namespace anm2ed
Element* Document::animation_get() { return anm2.element_get(ElementType::ANIMATION, reference.animationIndex); }
Element* Document::spritesheet_get() { return anm2.element_get(ElementType::SPRITESHEET, spritesheet.reference); }
Element* Document::overlay_get(int id)
{
if (id == -1) id = overlay.reference;
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
if (auto overlay = element_child_id_get(spritesheet, ElementType::OVERLAY, id)) return overlay;
}
return nullptr;
}
const Element* Document::overlay_get(int id) const
{
if (id == -1) id = overlay.reference;
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
if (auto overlay = element_child_id_get(spritesheet, ElementType::OVERLAY, id)) return overlay;
}
return nullptr;
}
int Document::overlay_spritesheet_id_get(int id) const
{
if (auto spritesheets = anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
if (element_child_id_get(spritesheet, ElementType::OVERLAY, id)) return spritesheet.id;
}
return -1;
}
void Document::spritesheet_add(const std::filesystem::path& path)
{
spritesheets_add({path});
@@ -2466,71 +2234,6 @@ namespace anm2ed
change(Document::SPRITESHEETS);
}
void Document::overlay_add(int spritesheetId, const std::filesystem::path& path)
{
overlays_add(spritesheetId, {path});
}
void Document::overlays_add(int spritesheetId, const std::vector<std::filesystem::path>& paths)
{
struct LoadedOverlay
{
std::filesystem::path relativePath{};
resource::Texture texture{};
};
auto spritesheet = anm2.element_get(ElementType::SPRITESHEET, spritesheetId);
if (!spritesheet) return;
auto directory = directory_get();
std::vector<LoadedOverlay> loaded{};
for (auto& path : paths)
{
auto pathCopy = path;
auto storagePath = path::backslash_handle(pathCopy);
std::optional<WorkingDirectory> workingDirectory{};
if (!storagePath.is_absolute()) workingDirectory.emplace(directory);
auto loadPath = path::case_insensitive_find(storagePath);
auto texture = resource::Texture(loadPath);
if (!texture.is_valid())
{
auto pathUtf8 = path::to_utf8(pathCopy);
toasts.push(std::vformat(localize.get(TOAST_OVERLAY_INIT_FAILED), std::make_format_args(pathUtf8)));
logger.error(std::vformat(localize.get(TOAST_OVERLAY_INIT_FAILED, anm2ed::ENGLISH),
std::make_format_args(pathUtf8)));
continue;
}
loaded.push_back({.relativePath = path::backslash_replace(path::make_relative(storagePath, directory)),
.texture = std::move(texture)});
}
if (loaded.empty()) return;
anm2_snapshot(localize.get(EDIT_ADD_OVERLAY));
std::set<int> added{};
for (auto& loadedOverlay : loaded)
{
auto id = document::overlay_next_id_get(anm2);
auto overlayElement = element_make(ElementType::OVERLAY);
overlayElement.id = id;
overlayElement.path = loadedOverlay.relativePath;
auto pathString = path::to_utf8(overlayElement.path);
spritesheet->children.push_back(overlayElement);
overlayTextures[id] = std::move(loadedOverlay.texture);
overlayTexturePaths[id] = overlayElement.path;
added.insert(id);
overlay.reference = id;
overlay_hash_set_saved(id);
toasts.push(std::vformat(localize.get(TOAST_OVERLAY_INITIALIZED), std::make_format_args(id, pathString)));
logger.info(std::vformat(localize.get(TOAST_OVERLAY_INITIALIZED, anm2ed::ENGLISH),
std::make_format_args(id, pathString)));
}
overlay.selection = added;
editTarget = Document::EditTarget::OVERLAY;
change(Document::SPRITESHEETS);
}
void Document::sound_add(const std::filesystem::path& path)
{
sounds_add({path});
+1 -21
View File
@@ -50,7 +50,6 @@ namespace anm2ed
NONE,
FRAME,
REGION,
OVERLAY,
SPRITESHEET
};
@@ -82,12 +81,10 @@ namespace anm2ed
Storage& layer = current.layer;
Storage& merge = current.merge;
Storage& null = current.null;
Storage& overlay = current.overlay;
Storage& region = current.region;
Storage& sound = current.sound;
Storage& spritesheet = current.spritesheet;
std::map<int, resource::Texture>& textures = current.textures;
std::map<int, resource::Texture>& overlayTextures = current.overlayTextures;
std::map<int, resource::Audio>& sounds = current.sounds;
Anm2& anm2 = current.anm2;
Reference& reference = current.reference;
@@ -102,6 +99,7 @@ namespace anm2ed
glm::vec2 editorPan{};
float editorZoom{200};
int overlayIndex{-1};
uint64_t overlayDocumentId{};
uint64_t hash{};
uint64_t saveHash{};
@@ -112,10 +110,7 @@ namespace anm2ed
bool isForceDirty{false};
std::unordered_map<int, uint64_t> spritesheetHashes{};
std::unordered_map<int, uint64_t> spritesheetSaveHashes{};
std::unordered_map<int, uint64_t> overlayHashes{};
std::unordered_map<int, uint64_t> overlaySaveHashes{};
std::unordered_map<int, std::filesystem::path> texturePaths{};
std::unordered_map<int, std::filesystem::path> overlayTexturePaths{};
std::unordered_map<int, std::filesystem::path> soundPaths{};
std::unordered_map<int, std::filesystem::path> shaderVertexPaths{};
std::unordered_map<int, std::filesystem::path> shaderFragmentPaths{};
@@ -133,15 +128,11 @@ namespace anm2ed
void anm2_change(ChangeType);
void assets_sync(ChangeType = ALL);
void texture_change(int);
void overlay_texture_change(int);
bool texture_reload(int);
bool overlay_texture_reload(int);
bool sound_reload(int);
bool shader_reload(int, std::string* = nullptr);
resource::Texture* texture_get(int);
const resource::Texture* texture_get(int) const;
resource::Texture* overlay_texture_get(int);
const resource::Texture* overlay_texture_get(int) const;
resource::Audio* sound_get(int);
const resource::Audio* sound_get(int) const;
resource::Shader* shader_get(int);
@@ -168,12 +159,6 @@ namespace anm2ed
bool spritesheet_any_dirty();
void spritesheet_hashes_reset();
void spritesheet_hashes_sync();
void overlay_hash_update(int);
void overlay_hash_set_saved(int);
bool overlay_is_dirty(int);
bool overlay_any_dirty();
void overlay_hashes_reset();
void overlay_hashes_sync();
bool is_frame_reference_valid(Reference) const;
std::set<Reference> item_frame_references_get(Reference) const;
std::set<Reference> selected_item_frame_references_get() const;
@@ -185,15 +170,10 @@ namespace anm2ed
Element* frame_get();
Element* item_get();
Element* spritesheet_get();
Element* overlay_get(int = -1);
const Element* overlay_get(int = -1) const;
int overlay_spritesheet_id_get(int) const;
Element* animation_get();
void spritesheet_add(const std::filesystem::path&);
void spritesheets_add(const std::vector<std::filesystem::path>&);
void overlay_add(int, const std::filesystem::path&);
void overlays_add(int, const std::vector<std::filesystem::path>&);
void sound_add(const std::filesystem::path&);
void sounds_add(const std::vector<std::filesystem::path>&);
-1
View File
@@ -40,7 +40,6 @@ namespace anm2ed::imgui
if (settings.windowIsLayers) window_update(layers, manager, settings, resources, dialog, clipboard);
if (settings.windowIsNulls) window_update(nulls, manager, settings, resources, dialog, clipboard);
if (settings.windowIsOnionskin) onionskin.update(manager, settings);
if (settings.windowIsOverlays) window_update(overlays, manager, settings, resources, dialog, clipboard);
if (settings.windowIsShaders) shaders.update(manager, settings, resources, dialog);
if (settings.windowIsSounds) window_update(sounds, manager, settings, resources, dialog, clipboard);
if (settings.windowIsSpritesheetEditor) spritesheetEditor.update(manager, settings, resources);
-1
View File
@@ -26,7 +26,6 @@ namespace anm2ed::imgui
Window layers{layers_window_register()};
Window nulls{nulls_window_register()};
Onionskin onionskin;
Window overlays{overlays_window_register()};
ShadersWindow shaders;
SpritesheetEditor spritesheetEditor;
Window spritesheets{spritesheets_window_register()};
+2 -27
View File
@@ -181,7 +181,7 @@ namespace anm2ed::imgui
{
auto& document = manager.documents[i];
auto isDocumentDirty = document.is_dirty() || document.isForceDirty;
auto isSpritesheetDirty = document.spritesheet_any_dirty() || document.overlay_any_dirty();
auto isSpritesheetDirty = document.spritesheet_any_dirty();
auto isDirty = isDocumentDirty || isSpritesheetDirty;
if (!closePopup.is_open())
@@ -278,7 +278,7 @@ namespace anm2ed::imgui
auto filename = path::to_utf8(closeDocument.filename_get());
auto isDocumentDirty = closeDocument.is_dirty() || closeDocument.isForceDirty;
auto isSpritesheetDirty = closeDocument.spritesheet_any_dirty() || closeDocument.overlay_any_dirty();
auto isSpritesheetDirty = closeDocument.spritesheet_any_dirty();
auto promptLabel =
isDocumentDirty && isSpritesheetDirty
? LABEL_DOCUMENT_AND_SPRITESHEETS_MODIFIED_PROMPT
@@ -337,31 +337,6 @@ namespace anm2ed::imgui
std::make_format_args(id, pathString)));
}
}
for (auto& overlay : spritesheet.children)
{
if (overlay.type != ElementType::OVERLAY) continue;
auto overlayTexture = closeDocument.overlay_texture_get(overlay.id);
if (!overlayTexture || !closeDocument.overlay_is_dirty(overlay.id)) continue;
auto pathString = path::to_utf8(overlay.path);
auto savePath = closeDocument.directory_get() / overlay.path;
path::ensure_directory(savePath.parent_path());
if (overlayTexture->write_png(savePath))
{
closeDocument.overlay_hash_set_saved(overlay.id);
toasts.push(std::vformat(localize.get(TOAST_SAVE_OVERLAY),
std::make_format_args(overlay.id, pathString)));
logger.info(std::vformat(localize.get(TOAST_SAVE_OVERLAY, anm2ed::ENGLISH),
std::make_format_args(overlay.id, pathString)));
}
else
{
toasts.push(std::vformat(localize.get(TOAST_SAVE_OVERLAY_FAILED),
std::make_format_args(overlay.id, pathString)));
logger.error(std::vformat(localize.get(TOAST_SAVE_OVERLAY_FAILED, anm2ed::ENGLISH),
std::make_format_args(overlay.id, pathString)));
}
}
}
}
}
+168 -52
View File
@@ -3,11 +3,14 @@
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <filesystem>
#include <format>
#include <map>
#include <optional>
#include <string>
#include <system_error>
#include <vector>
#include <glm/gtc/type_ptr.hpp>
@@ -41,6 +44,87 @@ namespace anm2ed::imgui
constexpr auto TRIGGER_TEXT_COLOR_LIGHT = ImVec4(0.0f, 0.0f, 0.0f, 0.5f);
namespace
{
struct OverlayAnimationOption
{
uint64_t documentId{};
int animationIndex{-1};
std::string label{};
};
std::vector<OverlayAnimationOption> overlay_animation_options_get(Manager& manager)
{
std::vector<OverlayAnimationOption> options{{.label = std::string(localize.get(BASIC_NONE))}};
for (auto& document : manager.documents)
{
auto documentLabel = path::to_utf8(document.filename_get());
int animationIndex{};
if (auto animations = document.anm2.element_get(ElementType::ANIMATIONS))
for (auto& animation : animations->children)
{
if (animation.type != ElementType::ANIMATION) continue;
auto label = std::format("{} ({})", animation.name, documentLabel);
options.push_back({.documentId = document.tabId, .animationIndex = animationIndex, .label = label});
++animationIndex;
}
}
return options;
}
std::vector<const char*> overlay_animation_option_labels_get(std::vector<OverlayAnimationOption>& options)
{
std::vector<const char*> labels{};
labels.reserve(options.size());
for (auto& option : options)
labels.push_back(option.label.c_str());
return labels;
}
int overlay_animation_option_index_get(const Document& document, const std::vector<OverlayAnimationOption>& options)
{
if (document.overlayIndex == -1) return 0;
auto documentId = document.overlayDocumentId ? document.overlayDocumentId : document.tabId;
for (int i = 1; i < (int)options.size(); ++i)
if (options[i].documentId == documentId && options[i].animationIndex == document.overlayIndex) return i;
return -1;
}
Document* overlay_animation_document_get(Manager& manager, const Document& document)
{
if (document.overlayIndex == -1) return nullptr;
auto documentId = document.overlayDocumentId ? document.overlayDocumentId : document.tabId;
for (auto& candidate : manager.documents)
if (candidate.tabId == documentId) return &candidate;
return nullptr;
}
std::optional<vec4> animation_rects_merge(std::optional<vec4> rect, vec4 next)
{
if (next == vec4(-1.0f)) return rect;
if (!rect) return next;
auto minPoint = glm::min(vec2(rect->x, rect->y), vec2(next.x, next.y));
auto maxPoint = glm::max(vec2(rect->x + rect->z, rect->y + rect->w), vec2(next.x + next.z, next.y + next.w));
return vec4(minPoint, maxPoint - minPoint);
}
std::optional<vec4> animation_render_rect_get(Manager& manager, Document& document, Element* animation,
bool isRootTransform)
{
std::optional<vec4> rect{};
if (animation)
rect = animation_rects_merge(rect, document.anm2.animation_rect(*animation, isRootTransform));
if (auto overlayDocument = overlay_animation_document_get(manager, document))
if (auto overlayAnimation = overlayDocument->anm2.element_get(ElementType::ANIMATION, document.overlayIndex))
rect = animation_rects_merge(rect,
overlayDocument->anm2.animation_rect(*overlayAnimation, isRootTransform));
return rect;
}
std::filesystem::path render_destination_directory(const std::filesystem::path& path, int type)
{
if (type == render::PNGS) return path;
@@ -188,6 +272,7 @@ namespace anm2ed::imgui
auto& frameTime = document.frameTime;
auto& zoom = document.previewZoom;
auto& overlayIndex = document.overlayIndex;
auto& overlayDocumentId = document.overlayDocumentId;
auto& pan = document.previewPan;
auto stop_all_sounds = [&]()
@@ -211,6 +296,7 @@ namespace anm2ed::imgui
pan = savedPan;
zoom = savedZoom;
overlayIndex = savedOverlayIndex;
overlayDocumentId = savedOverlayDocumentId;
isSizeTrySet = true;
hasPendingZoomPanAdjust = false;
isCheckerPanInitialized = false;
@@ -405,7 +491,9 @@ namespace anm2ed::imgui
auto& gridOffset = settings.previewGridOffset;
auto& isGrid = settings.previewIsGrid;
auto& overlayTransparency = settings.previewOverlayTransparency;
auto& overlayDrawOrder = settings.previewOverlayDrawOrder;
auto& overlayIndex = document.overlayIndex;
auto& overlayDocumentId = document.overlayDocumentId;
auto& isRootTransform = settings.previewIsRootTransform;
auto& isPivots = settings.previewIsPivots;
auto& isAxes = settings.previewIsAxes;
@@ -550,11 +638,48 @@ namespace anm2ed::imgui
ImGui::ColorEdit4(localize.get(BASIC_COLOR), value_ptr(axesColor), ImGuiColorEditFlags_NoInputs);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_AXES_COLOR));
combo_negative_one_indexed(localize.get(LABEL_OVERLAY), &overlayIndex, document.animation.labels);
auto overlayOptions = overlay_animation_options_get(manager);
auto overlayLabels = overlay_animation_option_labels_get(overlayOptions);
auto overlayOptionIndex = overlay_animation_option_index_get(document, overlayOptions);
if (overlayOptionIndex == -1)
{
overlayIndex = -1;
overlayDocumentId = 0;
overlayOptionIndex = 0;
}
if (ImGui::Combo(localize.get(LABEL_OVERLAY), &overlayOptionIndex, overlayLabels.data(),
(int)overlayLabels.size()))
{
auto& option = overlayOptions[overlayOptionIndex];
overlayIndex = option.animationIndex;
overlayDocumentId = overlayIndex == -1 ? 0 : option.documentId;
}
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_OVERLAY));
ImGui::DragFloat(localize.get(BASIC_ALPHA), &overlayTransparency, DRAG_SPEED, 0, 255, "%.0f");
overlayDrawOrder = glm::clamp(overlayDrawOrder, (int)overlay_draw_order::OVER, (int)overlay_draw_order::UNDER);
overlayTransparency = glm::clamp(overlayTransparency, 0.0f, 100.0f);
auto orderIconSize = icon_size_get();
auto orderButtonWidth = orderIconSize.x + ImGui::GetStyle().FramePadding.x * 2.0f;
auto alphaWidth =
std::max(ImGui::GetContentRegionAvail().x - (orderButtonWidth * 2.0f) -
(ImGui::GetStyle().ItemSpacing.x * 2.0f),
ImGui::GetFrameHeight());
auto overlayIconTint = isLightTheme ? ImVec4(0.0f, 0.0f, 0.0f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
ImGui::PushItemWidth(alphaWidth);
ImGui::DragFloat("##Overlay Alpha", &overlayTransparency, DRAG_SPEED, 0, 100, "%.0f%%");
ImGui::PopItemWidth();
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_OVERLAY_ALPHA));
overlayTransparency = glm::clamp(overlayTransparency, 0.0f, 100.0f);
ImGui::SameLine();
radio_button_icon("##Overlay Over", &overlayDrawOrder, overlay_draw_order::OVER, resources.icons[icon::OVER].id,
orderIconSize, overlayIconTint);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_OVERLAY_OVER));
ImGui::SameLine();
radio_button_icon("##Overlay Under", &overlayDrawOrder, overlay_draw_order::UNDER,
resources.icons[icon::UNDER].id, orderIconSize, overlayIconTint);
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_OVERLAY_UNDER));
}
ImGui::EndChild();
@@ -600,6 +725,7 @@ namespace anm2ed::imgui
if (isRenderPreviewOverridden)
{
savedOverlayIndex = overlayIndex;
savedOverlayDocumentId = overlayDocumentId;
savedZoom = zoom;
savedPan = pan;
}
@@ -607,6 +733,7 @@ namespace anm2ed::imgui
if (settings.renderIsUseIsolatedAnimation)
{
overlayIndex = -1;
overlayDocumentId = 0;
settings.animationPreviewTransparent = true;
settings.timelineIsOnlyShowLayers = true;
settings.previewIsAxes = false;
@@ -619,12 +746,11 @@ namespace anm2ed::imgui
if (settings.renderIsUseAnimationBounds)
{
if (animation)
if (auto rect = anm2.animation_rect(*animation, isRootTransform); rect != vec4(-1.0f))
{
size_set(vec2(rect.z, rect.w) * settings.renderScale);
set_to_rect(zoom, pan, rect);
}
if (auto rect = animation_render_rect_get(manager, document, animation, isRootTransform))
{
size_set(vec2(rect->z, rect->w) * settings.renderScale);
set_to_rect(zoom, pan, *rect);
}
isSizeTrySet = false;
}
@@ -661,6 +787,7 @@ namespace anm2ed::imgui
pan = savedPan;
zoom = savedZoom;
overlayIndex = savedOverlayIndex;
overlayDocumentId = savedOverlayDocumentId;
isSizeTrySet = true;
hasPendingZoomPanAdjust = false;
isCheckerPanInitialized = false;
@@ -753,8 +880,9 @@ namespace anm2ed::imgui
}
auto referenceItemType = static_cast<ItemType>(reference.itemType);
auto is_layer_animation_selected = [&](int id)
auto is_layer_animation_selected = [&](Document& sampleDocument, int id)
{
if (&sampleDocument != &document) return false;
if (reference.animationIndex != -1 && referenceItemType == ItemType::LAYER && reference.itemID == id)
return true;
for (auto itemReference : document.items.references)
@@ -768,9 +896,13 @@ namespace anm2ed::imgui
return false;
};
auto render = [&](Element* animation, float time, vec3 colorOffset = {}, float alphaOffset = {},
auto render = [&](Document& sampleDocument, Element* animation, float time, vec3 colorOffset = {},
float alphaOffset = {},
const std::vector<OnionskinSample>* layeredOnions = nullptr, bool isIndexMode = false)
{
auto& sampleAnm2 = sampleDocument.anm2;
bool isActiveDocument = &sampleDocument == &document;
auto sample_time_for_item = [&](Element& item, const OnionskinSample& sample) -> std::optional<float>
{
if (!isIndexMode)
@@ -880,7 +1012,7 @@ namespace anm2ed::imgui
math::percent_to_unit(rootFrame.scale), rootFrame.rotation);
auto rootTransform = itemTransform * rootModel;
auto isSelected = referenceItemType == ItemType::ROOT && reference.groupType == groupType &&
auto isSelected = isActiveDocument && referenceItemType == ItemType::ROOT && reference.groupType == groupType &&
reference.groupId == group.id;
vec4 color = isOnion ? vec4(sampleColor, sampleAlpha) : isSelected ? color::RED : ROOT_COLOR;
auto icon = isAltIcons ? icon::TARGET_ALT : icon::TARGET;
@@ -915,12 +1047,11 @@ namespace anm2ed::imgui
return;
auto id = layerAnimation.layerId;
auto layer = anm2.element_get(ElementType::LAYER_ELEMENT, id);
auto layer = sampleAnm2.element_get(ElementType::LAYER_ELEMENT, id);
if (!layer) return;
auto spritesheet = anm2.element_get(ElementType::SPRITESHEET, layer->spritesheetId);
auto textureInfo = document.texture_get(layer->spritesheetId);
if (!spritesheet || !textureInfo || !textureInfo->is_valid()) return;
auto textureInfo = sampleDocument.texture_get(layer->spritesheetId);
if (!textureInfo || !textureInfo->is_valid()) return;
auto draw_layer = [&](float sampleTime, const glm::mat4& sampleTransform, vec3 sampleColor,
float sampleAlpha, bool isOnion)
@@ -933,7 +1064,7 @@ namespace anm2ed::imgui
auto texSize = vec2(texture.size);
if (texSize.x <= 0.0f || texSize.y <= 0.0f) return;
frame = anm2.frame_effective(id, frame);
frame = sampleAnm2.frame_effective(id, frame);
auto crop = frame.crop;
auto size = frame.size;
auto pivot = frame.pivot;
@@ -966,40 +1097,15 @@ namespace anm2ed::imgui
frameTint.a = std::max(0.0f, frameTint.a - (alphaOffset + sampleAlpha));
auto vertices = math::uv_vertices_get(uvMin, uvMax);
auto customShader = document.shader_get(layer->spritesheetId);
auto customShader = sampleDocument.shader_get(layer->spritesheetId);
auto& layerShader = customShader ? *customShader : shaderTexture;
auto overlay_draw = [&](const Element& overlay)
{
if (overlay.type != ElementType::OVERLAY) return;
if (!overlay.isVisible) return;
auto overlayTexture = document.overlay_texture_get(overlay.id);
if (!overlayTexture || !overlayTexture->is_valid()) return;
auto overlayTexSize = vec2(overlayTexture->size);
if (overlayTexSize.x <= 0.0f || overlayTexSize.y <= 0.0f) return;
auto overlayUvMin = (crop - overlay.position) / overlayTexSize;
auto overlayUvMax = (crop + size - overlay.position) / overlayTexSize;
auto overlayVertices = math::uv_vertices_get(overlayUvMin, overlayUvMax);
auto overlayTint = frameTint;
overlayTint.a *= overlay.tint.a;
texture_render(shaderTexture, overlayTexture->id, layerTransform, overlayTint, frameColorOffset,
overlayVertices.data(), vec2(overlayTexture->size), sampleTime);
};
for (auto& overlay : spritesheet->children)
if (overlay.index == OVERLAY_DRAW_ORDER_BELOW) overlay_draw(overlay);
texture_render(layerShader, texture.id, layerTransform, frameTint, frameColorOffset, vertices.data(),
vec2(texture.size), sampleTime);
for (auto& overlay : spritesheet->children)
if (overlay.index != OVERLAY_DRAW_ORDER_BELOW) overlay_draw(overlay);
auto color = isOnion ? vec4(sampleColor, 1.0f - sampleAlpha)
: is_layer_animation_selected(id) ? SELECTED_LAYER_BORDER_COLOR
: color::RED;
: is_layer_animation_selected(sampleDocument, id) ? SELECTED_LAYER_BORDER_COLOR
: color::RED;
if (isBorder) rect_render(shaderLine, layerTransform, layerModel, color);
@@ -1055,7 +1161,7 @@ namespace anm2ed::imgui
return;
auto id = nullAnimation.nullId;
auto nulls = anm2.element_get(ElementType::NULLS);
auto nulls = sampleAnm2.element_get(ElementType::NULLS);
auto nullInfo = nulls ? element_child_id_get(*nulls, ElementType::NULL_ELEMENT, id) : nullptr;
if (!nullInfo) return;
auto isShowRect = nullInfo->isShowRect;
@@ -1070,8 +1176,9 @@ namespace anm2ed::imgui
auto& size = isShowRect ? POINT_SIZE : TARGET_SIZE;
auto color = isOnion ? vec4(sampleColor, 1.0f - sampleAlpha)
: id == reference.itemID && referenceItemType == ItemType::NULL_ ? color::RED
: NULL_COLOR;
: isActiveDocument && id == reference.itemID && referenceItemType == ItemType::NULL_
? color::RED
: NULL_COLOR;
auto nullModel = math::quad_model_get(size, frame.position, size * 0.5f,
math::percent_to_unit(frame.scale), frame.rotation);
@@ -1109,12 +1216,19 @@ namespace anm2ed::imgui
if (animation)
{
auto layeredOnions = settings.onionskinIsEnabled ? &onionskinSamples : nullptr;
auto overlay_render = [&]()
{
if (auto overlayDocument = overlay_animation_document_get(manager, document))
if (auto overlayAnimation = overlayDocument->anm2.element_get(ElementType::ANIMATION, overlayIndex))
render(*overlayDocument, overlayAnimation, frameTime, {},
1.0f - math::percent_to_unit(overlayTransparency), layeredOnions,
settings.onionskinMode == (int)OnionskinMode::INDEX);
};
render(animation, frameTime, {}, 0.0f, layeredOnions, settings.onionskinMode == (int)OnionskinMode::INDEX);
if (auto overlayAnimation = anm2.element_get(ElementType::ANIMATION, overlayIndex))
render(overlayAnimation, frameTime, {}, 1.0f - math::uint8_to_float(overlayTransparency), layeredOnions,
settings.onionskinMode == (int)OnionskinMode::INDEX);
if (overlayDrawOrder == overlay_draw_order::UNDER) overlay_render();
render(document, animation, frameTime, {}, 0.0f, layeredOnions,
settings.onionskinMode == (int)OnionskinMode::INDEX);
if (overlayDrawOrder == overlay_draw_order::OVER) overlay_render();
}
if (manager.isRecording && renderFrameIndex < renderFrameCount)
@@ -1136,6 +1250,7 @@ namespace anm2ed::imgui
pan = savedPan;
zoom = savedZoom;
overlayIndex = savedOverlayIndex;
overlayDocumentId = savedOverlayDocumentId;
isSizeTrySet = true;
hasPendingZoomPanAdjust = false;
isCheckerPanInitialized = false;
@@ -1569,6 +1684,7 @@ namespace anm2ed::imgui
zoom = savedZoom;
settings = savedSettings;
overlayIndex = savedOverlayIndex;
overlayDocumentId = savedOverlayDocumentId;
isSizeTrySet = true;
hasPendingZoomPanAdjust = false;
isCheckerPanInitialized = false;
+2
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <filesystem>
#include "audio_stream.hpp"
@@ -22,6 +23,7 @@ namespace anm2ed::imgui
float savedZoom{};
glm::vec2 savedPan{};
int savedOverlayIndex{};
uint64_t savedOverlayDocumentId{};
glm::vec2 mousePos{};
glm::vec2 checkerPan{};
glm::vec2 checkerSyncPan{};
+6 -135
View File
@@ -61,17 +61,11 @@ namespace anm2ed::imgui
};
if (auto selectedLayerSpritesheet = selected_layer_spritesheet_get();
selectedLayerSpritesheet != -1 && document.editTarget != Document::EditTarget::REGION &&
document.editTarget != Document::EditTarget::OVERLAY && document.editTarget != Document::EditTarget::SPRITESHEET)
document.editTarget != Document::EditTarget::SPRITESHEET)
referenceSpritesheet = selectedLayerSpritesheet;
auto spritesheet = anm2.element_get(ElementType::SPRITESHEET, referenceSpritesheet);
auto baseTexture = document.texture_get(referenceSpritesheet);
auto activeOverlayId = -1;
auto activeOverlay = document.editTarget == Document::EditTarget::OVERLAY ? document.overlay_get() : nullptr;
if (activeOverlay && document.overlay_spritesheet_id_get(activeOverlay->id) == referenceSpritesheet)
activeOverlayId = activeOverlay->id;
else
activeOverlay = nullptr;
auto texture = activeOverlayId != -1 ? document.overlay_texture_get(activeOverlayId) : baseTexture;
auto texture = baseTexture;
auto& tool = settings.tool;
auto& shaderGrid = resources.shaders[shader::GRID];
auto& shaderTexture = resources.shaders[shader::TEXTURE];
@@ -244,24 +238,8 @@ namespace anm2ed::imgui
auto spritesheetModel = math::quad_model_get(viewTexture->size);
auto spritesheetTransform = transform * spritesheetModel;
auto overlay_draw = [&](const Element& overlay)
{
if (overlay.type != ElementType::OVERLAY) return;
if (!overlay.isVisible) return;
auto overlayTexture = document.overlay_texture_get(overlay.id);
if (!overlayTexture || !overlayTexture->is_valid()) return;
auto overlayTransform = transform * math::quad_model_get(overlayTexture->size, overlay.position);
texture_render(shaderTexture, overlayTexture->id, overlayTransform, vec4(1.0f, 1.0f, 1.0f, overlay.tint.a));
};
for (auto& overlay : spritesheet->children)
if (overlay.index == OVERLAY_DRAW_ORDER_BELOW) overlay_draw(overlay);
if (baseTexture && baseTexture->is_valid()) texture_render(shaderTexture, baseTexture->id, spritesheetTransform);
for (auto& overlay : spritesheet->children)
if (overlay.index != OVERLAY_DRAW_ORDER_BELOW) overlay_draw(overlay);
if (isGrid) grid_render(shaderGrid, zoom, pan, gridSize, gridOffset, gridColor);
if (isBorder)
@@ -328,18 +306,6 @@ namespace anm2ed::imgui
}
}
if (activeOverlay)
{
auto overlayTexture = document.overlay_texture_get(activeOverlayId);
if (overlayTexture && overlayTexture->is_valid())
{
auto overlayModel = math::quad_model_get(overlayTexture->size, activeOverlay->position);
auto overlayTransform = transform * overlayModel;
rect_render(dashedShader, overlayTransform, overlayModel, color::RED, BORDER_DASH_LENGTH, BORDER_DASH_GAP,
BORDER_DASH_OFFSET);
}
}
bool isFrameOnSpritesheet = isReferenceLayerOnSpritesheet;
if (isFrameOnSpritesheet && frame->regionId == -1)
{
@@ -429,11 +395,6 @@ namespace anm2ed::imgui
mousePos = position_translate(zoom, pan, to_ivec2(ImGui::GetMousePos()) - to_ivec2(cursorScreenPos));
auto textureMousePos = mousePos;
auto previousTextureMousePos = previousMousePos;
if (activeOverlay)
{
textureMousePos -= activeOverlay->position;
previousTextureMousePos -= activeOverlay->position;
}
auto snap_rect = [&](glm::vec2 minPoint, glm::vec2 maxPoint)
{
@@ -466,29 +427,6 @@ namespace anm2ed::imgui
auto fraction = current - glm::floor(current);
return glm::floor(value) + fraction;
};
auto overlayIsGridSnap = isGridSnap;
auto overlayGridSize = gridSize;
auto overlayGridOffset = gridOffset;
auto overlay_position_snap =
[overlayIsGridSnap, overlayGridSize, overlayGridOffset, clamp_vec2_to_int](vec2 value)
{
if (overlayIsGridSnap)
{
if (overlayGridSize.x != 0)
{
auto offsetX = (float)overlayGridOffset.x;
auto sizeX = (float)overlayGridSize.x;
value.x = std::round((value.x - offsetX) / sizeX) * sizeX + offsetX;
}
if (overlayGridSize.y != 0)
{
auto offsetY = (float)overlayGridOffset.y;
auto sizeY = (float)overlayGridSize.y;
value.y = std::round((value.y - offsetY) / sizeY) * sizeY + offsetY;
}
}
return clamp_vec2_to_int(value);
};
auto frame_snapshot_push = [&](StringType messageType, const std::set<Reference>& frameReferences)
{
auto message = std::string(localize.get(messageType));
@@ -506,12 +444,6 @@ namespace anm2ed::imgui
[message, queuedSpritesheet, queuedRegionIds](Manager&, Document& document)
{ document.regions_snapshot(message, queuedSpritesheet, queuedRegionIds); }});
};
auto overlay_snapshot_push = [&](StringType messageType)
{
auto message = std::string(localize.get(messageType));
manager.command_push(
{manager.selected, [message](Manager&, Document& document) { document.anm2_snapshot(message); }});
};
auto texture_snapshot_push = [&](StringType messageType)
{
auto message = std::string(localize.get(messageType));
@@ -693,36 +625,12 @@ namespace anm2ed::imgui
region.size = clamp_vec2_to_int(maxPoint - minPoint);
});
};
auto overlay_update = [&](int id, auto update)
{
auto queuedSpritesheet = referenceSpritesheet;
manager.command_push({manager.selected, [=](Manager&, Document& document)
{
auto spritesheet =
document.anm2.element_get(ElementType::SPRITESHEET, queuedSpritesheet);
if (!spritesheet) return;
auto overlay = element_child_id_get(*spritesheet, ElementType::OVERLAY, id);
if (!overlay) return;
update(*overlay);
}});
};
auto overlay_position_set = [&](int id, vec2 position)
{
overlay_update(id, [=](Element& overlay) { overlay.position = overlay_position_snap(position); });
};
auto overlay_position_offset = [&](int id, vec2 delta)
{
overlay_update(id,
[=](Element& overlay) { overlay.position = overlay_position_snap(overlay.position + delta); });
};
auto texture_line_apply = [&](ivec2 start, ivec2 end, vec4 color)
{
auto queuedSpritesheet = referenceSpritesheet;
auto queuedOverlay = activeOverlayId;
manager.command_push({manager.selected, [=](Manager&, Document& document)
{
auto texture = queuedOverlay != -1 ? document.overlay_texture_get(queuedOverlay)
: document.texture_get(queuedSpritesheet);
auto texture = document.texture_get(queuedSpritesheet);
if (!texture) return;
texture->pixel_line(start, end, color);
}});
@@ -730,15 +638,9 @@ namespace anm2ed::imgui
auto texture_change_push = [&]()
{
auto queuedSpritesheet = referenceSpritesheet;
auto queuedOverlay = activeOverlayId;
manager.command_push(
{manager.selected, [=](Manager&, Document& document)
{
if (queuedOverlay != -1)
document.overlay_texture_change(queuedOverlay);
else
document.texture_change(queuedSpritesheet);
}});
{ document.texture_change(queuedSpritesheet); }});
};
auto region_selection_set = [&](int id)
@@ -801,9 +703,7 @@ namespace anm2ed::imgui
auto& toolInfo = tool::INFO[useTool];
auto& areaType = toolInfo.areaType;
auto isRegionEditTarget = document.editTarget == Document::EditTarget::REGION;
auto isOverlayEditTarget = document.editTarget == Document::EditTarget::OVERLAY && activeOverlayId != -1;
auto selectedFrameToolReferences =
isRegionEditTarget || isOverlayEditTarget ? std::set<Reference>{} : selectedFrameReferences;
auto selectedFrameToolReferences = isRegionEditTarget ? std::set<Reference>{} : selectedFrameReferences;
bool isAreaAllowed = areaType == tool::ALL || areaType == tool::SPRITESHEET_EDITOR;
bool isFrameRequired =
!(useTool == tool::PAN || useTool == tool::DRAW || useTool == tool::ERASE || useTool == tool::COLOR_PICKER);
@@ -812,8 +712,7 @@ namespace anm2ed::imgui
(useTool == tool::CROP || useTool == tool::MOVE);
bool isFrameAvailable = !isFrameRequired || (frame && !isRegionInUse && !selectedFrameToolReferences.empty()) ||
(useTool == tool::CROP && !regionSelection.empty()) ||
(useTool == tool::MOVE && regionReference != -1) ||
(useTool == tool::MOVE && isOverlayEditTarget);
(useTool == tool::MOVE && regionReference != -1);
bool isSpritesheetRequired = useTool == tool::DRAW || useTool == tool::ERASE || useTool == tool::COLOR_PICKER;
bool isSpritesheetAvailable = !isSpritesheetRequired || (texture && texture->is_valid());
auto cursor = (isAreaAllowed && isFrameAvailable && isSpritesheetAvailable) ? toolInfo.cursor
@@ -848,34 +747,6 @@ namespace anm2ed::imgui
if (isMouseDown || isMouseMiddleDown) pan += mouseDelta;
break;
case tool::MOVE:
if (isOverlayEditTarget)
{
if (!activeOverlay) break;
if (isBegin) overlay_snapshot_push(EDIT_OVERLAY_MOVE);
if (isMouseClicked) cropAnchor = mousePos - activeOverlay->position;
if (isMouseDown) overlay_position_set(activeOverlayId, mousePos - cropAnchor);
if (isLeftPressed) overlay_position_offset(activeOverlayId, vec2(-stepX, 0));
if (isRightPressed) overlay_position_offset(activeOverlayId, vec2(stepX, 0));
if (isUpPressed) overlay_position_offset(activeOverlayId, vec2(0, -stepY));
if (isDownPressed) overlay_position_offset(activeOverlayId, vec2(0, stepY));
if (isDuring)
{
if (ImGui::BeginTooltip())
{
ImGui::TextUnformatted(
std::vformat(localize.get(FORMAT_POSITION),
std::make_format_args(activeOverlay->position.x, activeOverlay->position.y))
.c_str());
ImGui::EndTooltip();
}
}
if (isEnd) document_change_push(Document::SPRITESHEETS);
break;
}
if ((isRegionEditTarget || isRegionInUse || selectedFrameToolReferences.empty()) && regionReference != -1)
{
if (!spritesheet) break;
+23 -725
View File
@@ -543,6 +543,7 @@ namespace anm2ed::imgui
auto& selection = document.animation.selection;
auto& reference = document.reference;
auto& overlayIndex = document.overlayIndex;
auto& overlayDocumentId = document.overlayDocumentId;
int merged{-1};
document.anm2_snapshot(localize.get(EDIT_MERGE_ANIMATIONS));
@@ -550,7 +551,11 @@ namespace anm2ed::imgui
{
auto selected = quickSelection ? *quickSelection : std::set<int>(selection.begin(), selection.end());
auto isQuickGroupMerge = quickGroupSelection && !quickGroupSelection->empty();
if (selected.contains(overlayIndex)) overlayIndex = -1;
if ((overlayDocumentId == 0 || overlayDocumentId == document.tabId) && selected.contains(overlayIndex))
{
overlayIndex = -1;
overlayDocumentId = 0;
}
if (selected.size() > 1)
merged = anm2.animations_merge(*selected.begin(), selected);
@@ -574,7 +579,11 @@ namespace anm2ed::imgui
{
auto mergeSelection = window_animation_merge_indices_get(document, options.selection, options.reference);
if (mergeSelection.empty()) return -1;
if (mergeSelection.contains(overlayIndex)) overlayIndex = -1;
if ((overlayDocumentId == 0 || overlayDocumentId == document.tabId) && mergeSelection.contains(overlayIndex))
{
overlayIndex = -1;
overlayDocumentId = 0;
}
merged = anm2.animations_merge(options.reference, mergeSelection, options.type, options.isDeleteAnimationsAfter);
}
@@ -672,89 +681,6 @@ namespace anm2ed::imgui
}
}
void window_overlays_save(Document& document, const std::set<int>& ids)
{
if (ids.empty()) return;
for (auto& id : ids)
{
auto overlay = document.overlay_get(id);
auto texture = document.overlay_texture_get(id);
if (!overlay || !texture) continue;
auto pathString = path::to_utf8(overlay->path);
WorkingDirectory workingDirectory(document.directory_get());
path::ensure_directory(overlay->path.parent_path());
if (texture->write_png(overlay->path))
{
document.overlay_hash_set_saved(id);
toasts.push(std::vformat(localize.get(TOAST_SAVE_OVERLAY), std::make_format_args(id, pathString)));
logger.info(
std::vformat(localize.get(TOAST_SAVE_OVERLAY, anm2ed::ENGLISH), std::make_format_args(id, pathString)));
}
else
{
toasts.push(std::vformat(localize.get(TOAST_SAVE_OVERLAY_FAILED), std::make_format_args(id, pathString)));
logger.error(std::vformat(localize.get(TOAST_SAVE_OVERLAY_FAILED, anm2ed::ENGLISH),
std::make_format_args(id, pathString)));
}
}
}
int window_overlay_next_id_get(const Document& document)
{
int nextId{};
if (auto spritesheets = document.anm2.element_get(ElementType::SPRITESHEETS))
for (auto& spritesheet : spritesheets->children)
{
if (spritesheet.type != ElementType::SPRITESHEET) continue;
for (auto& overlay : spritesheet.children)
if (overlay.type == ElementType::OVERLAY) nextId = std::max(nextId, overlay.id + 1);
}
return nextId;
}
void window_overlays_context_actions_add(Window& window, Manager& manager, Settings& settings, Document& document,
Clipboard& clipboard, Actions& actions)
{
auto& selection = document.overlay.selection;
actions_undo_redo_add(actions, manager, document);
actions.separator();
actions.add(ACTION_PROPERTIES, [&]() { return selection.size() == 1 && (bool)window.properties; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.properties); });
actions.add(ACTION_OPEN_DIRECTORY, [&]() { return selection.size() == 1 && (bool)window.open; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.open); });
actions.add(ACTION_SET_FILE_PATH, [&]() { return selection.size() == 1 && (bool)window.path_set; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.path_set); });
actions.add(ACTION_ADD, [&]() { return (bool)window.add; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.add); });
actions.add(ACTION_REMOVE, [&]() { return !selection.empty() && (bool)window.remove; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.remove); },
TOOLTIP_REMOVE_OVERLAYS);
actions.add(ACTION_RELOAD, [&]() { return !selection.empty() && (bool)window.reload; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.reload); },
TOOLTIP_RELOAD_OVERLAYS);
actions.add(ACTION_REPLACE, [&]() { return selection.size() == 1 && (bool)window.replace; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.replace); },
TOOLTIP_REPLACE_OVERLAY);
actions.add(ACTION_SAVE, [&]() { return !selection.empty(); },
[&]()
{
if (settings.fileIsWarnOverwrite)
{
window.selection2 = selection;
window.popup2.open();
}
else if (window.save)
window_command_run(window, manager, settings, document, clipboard, window.save);
},
TOOLTIP_SAVE_OVERLAYS);
actions.separator();
actions.add(ACTION_COPY, [&]() { return !selection.empty() && (bool)window.copy; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.copy); });
actions.add(ACTION_PASTE, [&]() { return !clipboard.is_empty() && (bool)window.paste; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.paste); });
}
int window_footer_button_count_get(const Window& window)
{
int count{};
@@ -1622,6 +1548,7 @@ namespace anm2ed::imgui
auto& selection = document.animation.selection;
auto& reference = document.reference;
auto& overlayIndex = document.overlayIndex;
auto& overlayDocumentId = document.overlayDocumentId;
auto groupSelection = window.selection;
auto behavior = [&]()
@@ -1640,7 +1567,11 @@ namespace anm2ed::imgui
auto i = *it;
auto childIndex = window_animation_child_index_get(*items, i);
if (childIndex == -1) continue;
if (overlayIndex == i) overlayIndex = -1;
if ((overlayDocumentId == 0 || overlayDocumentId == document.tabId) && overlayIndex == i)
{
overlayIndex = -1;
overlayDocumentId = 0;
}
if (reference.animationIndex == i) reference.animationIndex = -1;
items->children.erase(items->children.begin() + childIndex);
}
@@ -1797,7 +1728,12 @@ namespace anm2ed::imgui
auto i = *it;
auto childIndex = window_animation_child_index_get(*items, i);
if (childIndex == -1) continue;
if (document.overlayIndex == i) document.overlayIndex = -1;
if ((document.overlayDocumentId == 0 || document.overlayDocumentId == document.tabId) &&
document.overlayIndex == i)
{
document.overlayIndex = -1;
document.overlayDocumentId = 0;
}
if (document.reference.animationIndex == i) document.reference.animationIndex = -1;
items->children.erase(items->children.begin() + childIndex);
}
@@ -2726,644 +2662,6 @@ namespace anm2ed::imgui
return window;
}
Window overlays_window_register()
{
Window window{};
window.title = LABEL_OVERLAYS_WINDOW;
window.isOpen = &Settings::windowIsOverlays;
window.changeType = Document::SPRITESHEETS;
window.elementType = ElementType::OVERLAY;
window.childLabel = "##Overlays Child";
window.footerRows = 2;
window.flags = 0;
window.isChildPaddingZero = true;
window.unavailableText = TEXT_SELECT_SPRITESHEET;
window.editElement = element_make(ElementType::OVERLAY);
window.popup = PopupHelper(LABEL_OVERLAY_PROPERTIES, POPUP_SMALL_NO_HEIGHT);
window.popup2 = PopupHelper(LABEL_TASKBAR_OVERWRITE_FILE, POPUP_SMALL_NO_HEIGHT);
window.storage_get = [](Document& document) -> Storage& { return document.overlay; };
window.is_available = [](Document& document)
{ return document.anm2.element_get(ElementType::SPRITESHEET, document.spritesheet.reference); };
window.add = [](Window& window, Manager&, Settings&, Document&, Clipboard&)
{
if (window.dialog) window.dialog->file_open(Dialog::OVERLAY_OPEN, true);
};
window.replace = [](Window& window, Manager&, Settings&, Document&, Clipboard&)
{
if (window.dialog) window.dialog->file_open(Dialog::OVERLAY_REPLACE);
};
window.path_set = [](Window& window, Manager&, Settings&, Document&, Clipboard&)
{
if (window.dialog) window.dialog->file_save(Dialog::OVERLAY_PATH_SET);
};
window.open = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
{
auto& selection = document.overlay.selection;
if (selection.size() != 1 || !window.dialog) return;
if (auto overlay = document.overlay_get(*selection.begin())) window_directory_open(*window.dialog, document, overlay->path);
};
window.properties = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
{
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, document.spritesheet.reference);
auto& selection = document.overlay.selection;
if (!spritesheet || selection.size() != 1) return;
auto id = *selection.begin();
if (!element_child_id_get(*spritesheet, ElementType::OVERLAY, id)) return;
document.editTarget = Document::EditTarget::OVERLAY;
document.overlay.reference = id;
document.region.reference = -1;
document.region.selection.clear();
window.popup.open();
};
window.remove = [](Window& window, Manager&, Settings&, Document& document, Clipboard&)
{
auto selected = document.overlay.selection;
if (selected.empty()) return;
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, document.spritesheet.reference);
if (!spritesheet) return;
auto behavior = [&]()
{
for (auto id : selected)
{
auto overlay = element_child_id_get(*spritesheet, ElementType::OVERLAY, id);
if (!overlay) continue;
auto pathString = path::to_utf8(overlay->path);
toasts.push(std::vformat(localize.get(TOAST_REMOVE_OVERLAY), std::make_format_args(id, pathString)));
logger.info(std::vformat(localize.get(TOAST_REMOVE_OVERLAY, anm2ed::ENGLISH),
std::make_format_args(id, pathString)));
element_child_id_erase(*spritesheet, ElementType::OVERLAY, id);
}
document.overlay.reference = -1;
document.overlay.selection.clear();
};
window_edit(window, document, localize.get(EDIT_REMOVE_OVERLAYS), behavior);
};
window.reload = [](Window&, Manager&, Settings&, Document& document, Clipboard&)
{
auto selected = document.overlay.selection;
if (selected.empty()) return;
document.textures_snapshot(localize.get(EDIT_RELOAD_OVERLAYS));
for (auto id : selected)
document.overlay_texture_reload(id);
document.change(Document::TEXTURES);
for (auto id : selected)
{
auto overlay = document.overlay_get(id);
if (!overlay) continue;
document.overlay_hash_set_saved(id);
auto pathString = path::to_utf8(overlay->path);
toasts.push(std::vformat(localize.get(TOAST_RELOAD_OVERLAY), std::make_format_args(id, pathString)));
logger.info(std::vformat(localize.get(TOAST_RELOAD_OVERLAY, anm2ed::ENGLISH),
std::make_format_args(id, pathString)));
}
};
window.save = [](Window&, Manager&, Settings&, Document& document, Clipboard&)
{
window_overlays_save(document, document.overlay.selection);
};
window.copy = [](Window&, Manager&, Settings&, Document& document, Clipboard& clipboard)
{
auto& selection = document.overlay.selection;
if (selection.empty()) return;
std::string clipboardText{};
for (auto id : selection)
if (auto overlay = document.overlay_get(id)) clipboardText += element_to_string(*overlay);
clipboard.set(clipboardText);
};
window.paste = [](Window& window, Manager&, Settings&, Document& document, Clipboard& clipboard)
{
if (clipboard.is_empty()) return;
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, document.spritesheet.reference);
if (!spritesheet) return;
tinyxml2::XMLDocument xmlDocument{};
std::string errorString{};
if (xmlDocument.Parse(clipboard.get().c_str()) != tinyxml2::XML_SUCCESS)
{
errorString = xmlDocument.ErrorStr();
toasts.push(std::vformat(localize.get(TOAST_DESERIALIZE_OVERLAYS_FAILED), std::make_format_args(errorString)));
logger.error(std::vformat(localize.get(TOAST_DESERIALIZE_OVERLAYS_FAILED, anm2ed::ENGLISH),
std::make_format_args(errorString)));
return;
}
std::vector<Element> pasted{};
for (auto xmlElement = xmlDocument.FirstChildElement("Overlay"); xmlElement;
xmlElement = xmlElement->NextSiblingElement("Overlay"))
{
auto overlay = element_read(xmlElement);
if (overlay.type == ElementType::OVERLAY) pasted.push_back(std::move(overlay));
}
if (pasted.empty())
{
errorString = "No valid Overlay(s).";
toasts.push(std::vformat(localize.get(TOAST_DESERIALIZE_OVERLAYS_FAILED), std::make_format_args(errorString)));
logger.error(std::vformat(localize.get(TOAST_DESERIALIZE_OVERLAYS_FAILED, anm2ed::ENGLISH),
std::make_format_args(errorString)));
return;
}
auto behavior = [&]()
{
std::set<int> added{};
for (auto overlay : pasted)
{
overlay.id = window_overlay_next_id_get(document);
overlay.path = path::backslash_handle(overlay.path);
added.insert(overlay.id);
spritesheet->children.push_back(std::move(overlay));
document.overlay_texture_reload(*added.rbegin());
}
document.overlay.selection = added;
document.overlay.reference = added.empty() ? -1 : *added.rbegin();
document.editTarget = Document::EditTarget::OVERLAY;
window.newElementId = document.overlay.reference;
};
window_edit(window, document, localize.get(EDIT_PASTE_OVERLAYS), behavior);
};
window.rows_update =
[](Window& window, Manager& manager, Settings& settings, Resources& resources, Clipboard& clipboard,
Document& document, ImVec2)
{
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, document.spritesheet.reference);
if (!spritesheet) return;
auto& selection = document.overlay.selection;
auto& reference = document.overlay.reference;
auto style = ImGui::GetStyle();
auto overlayChildSize = ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetTextLineHeightWithSpacing() * 4);
bool isContextMenuQueued{};
int contextMenuTargetId{-1};
StringType visibilityTooltip{STRING_UNDEFINED};
std::vector<int> ids{};
for (auto& overlay : spritesheet->children)
if (overlay.type == ElementType::OVERLAY) ids.push_back(overlay.id);
if (reference != -1 && std::ranges::find(ids, reference) == ids.end())
{
reference = -1;
selection.clear();
}
selection.start((int)ids.size());
if (ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_A, ImGuiInputFlags_RouteFocused))
{
selection.clear();
for (auto id : ids)
selection.insert(id);
}
if (ImGui::Shortcut(ImGuiKey_Escape, ImGuiInputFlags_RouteFocused))
{
selection.clear();
reference = -1;
}
int scrollTargetId = -1;
int arrowSelectionId = -1;
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) &&
(ImGui::IsKeyPressed(ImGuiKey_UpArrow, true) || ImGui::IsKeyPressed(ImGuiKey_DownArrow, true)))
{
auto nextId = window_arrow_selection_get(ids, reference, selection);
if (nextId != -1)
{
arrowSelectionId = nextId;
scrollTargetId = nextId;
}
}
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2());
for (auto& overlay : spritesheet->children)
{
if (overlay.type != ElementType::OVERLAY) continue;
auto id = overlay.id;
auto isNewOverlay = window.newElementId == id;
ImGui::PushID(id);
window_scroll_to_item(overlayChildSize.y, scrollTargetId == id);
if (scrollTargetId == id) ImGui::SetNextWindowFocus();
if (ImGui::BeginChild("##Overlay Child", overlayChildSize, ImGuiChildFlags_Borders))
{
auto isSelected = selection.contains(id) || arrowSelectionId == id;
auto isReferenced = id == reference || arrowSelectionId == id;
auto cursorPos = ImGui::GetCursorPos();
auto textureInfo = document.overlay_texture_get(id);
bool isValid = textureInfo && textureInfo->is_valid();
auto& texture = isValid ? *textureInfo : resources.icons[icon::NONE];
auto tintColor = !isValid ? ImVec4(1.0f, 0.25f, 0.25f, 1.0f)
: overlay.isVisible ? ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
: ImVec4(1.0f, 1.0f, 1.0f, 0.35f);
auto pathString = path::to_utf8(overlay.path);
auto pathCStr = pathString.c_str();
auto visibleButtonSize = icon_size_get();
ImGui::SetNextItemSelectionUserData(id);
ImGui::SetNextItemStorageID(id);
if (scrollTargetId == id) ImGui::SetKeyboardFocusHere();
auto isActivated =
ImGui::Selectable("##Overlay Selectable", isSelected, ImGuiSelectableFlags_AllowOverlap,
overlayChildSize);
auto isRowRightClicked = ImGui::IsItemClicked(ImGuiMouseButton_Right);
auto isClicked = ImGui::IsItemClicked(ImGuiMouseButton_Left) || isRowRightClicked;
if (isActivated || isClicked)
{
document.editTarget = Document::EditTarget::OVERLAY;
reference = id;
document.region.reference = -1;
document.region.selection.clear();
}
if (isRowRightClicked)
{
isContextMenuQueued = true;
contextMenuTargetId = id;
}
if (scrollTargetId == id) ImGui::SetItemDefaultFocus();
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && window.properties)
window_command_run(window, manager, settings, document, clipboard, window.properties);
auto imageSize = to_imvec2(vec2(overlayChildSize.y));
auto aspectRatio = texture.size.y != 0 ? (float)texture.size.x / texture.size.y : 1.0f;
if (imageSize.x / imageSize.y > aspectRatio)
imageSize.x = imageSize.y * aspectRatio;
else
imageSize.y = imageSize.x / aspectRatio;
ImGui::SetCursorPos(cursorPos);
ImGui::ImageWithBg(texture.id, imageSize, ImVec2(), ImVec2(1, 1), ImVec4(), tintColor);
ImGui::SetCursorPos(
ImVec2(overlayChildSize.y + style.ItemSpacing.x,
overlayChildSize.y - overlayChildSize.y / 2 - ImGui::GetTextLineHeight() / 2));
if (isReferenced) ImGui::PushFont(resources.fonts[font::ITALICS].get(), font::SIZE);
auto overlayLabel = std::vformat(localize.get(FORMAT_OVERLAY), std::make_format_args(id, pathCStr));
if (document.overlay_is_dirty(id))
overlayLabel =
std::vformat(localize.get(FORMAT_SPRITESHEET_NOT_SAVED), std::make_format_args(overlayLabel));
ImGui::TextUnformatted(overlayLabel.c_str());
if (isReferenced) ImGui::PopFont();
auto visibleIcon = overlay.isVisible ? icon::VISIBLE : icon::INVISIBLE;
auto visibleButtonPos =
ImVec2(overlayChildSize.x - visibleButtonSize.x - style.ItemSpacing.x,
overlayChildSize.y * 0.5f - visibleButtonSize.y * 0.5f);
ImGui::SetCursorPos(visibleButtonPos);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4());
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4());
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4());
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2());
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
if (ImGui::ImageButton("##Overlay Visible Toggle", resources.icons[visibleIcon].id, visibleButtonSize))
{
auto queuedId = id;
manager.command_push({manager.selected,
[queuedId](Manager&, Document& document)
{
auto behavior = [&]()
{
auto overlay = document.overlay_get(queuedId);
if (!overlay) return;
overlay->isVisible = !overlay->isVisible;
};
window_edit(document, Document::SPRITESHEETS,
localize.get(EDIT_TOGGLE_ITEM_VISIBILITY), behavior);
}});
}
auto isVisibleButtonHovered = ImGui::IsItemHovered();
auto isVisibleButtonRightClicked = ImGui::IsItemClicked(ImGuiMouseButton_Right);
if (isVisibleButtonRightClicked)
{
document.editTarget = Document::EditTarget::OVERLAY;
reference = id;
document.region.reference = -1;
document.region.selection.clear();
isContextMenuQueued = true;
contextMenuTargetId = id;
}
ImGui::PopStyleVar(2);
ImGui::PopStyleColor(3);
if (isVisibleButtonHovered)
visibilityTooltip =
overlay.isVisible ? TOOLTIP_ITEM_VISIBILITY_SHOWN : TOOLTIP_ITEM_VISIBILITY_HIDDEN;
}
ImGui::EndChild();
if (isNewOverlay)
{
ImGui::SetScrollHereY(0.5f);
window.newElementId = -1;
}
ImGui::PopID();
}
ImGui::PopStyleVar();
if (visibilityTooltip != STRING_UNDEFINED)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, window.tooltipWindowPadding);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, window.tooltipItemSpacing);
ImGui::SetTooltip("%s", localize.get(visibilityTooltip));
ImGui::PopStyleVar(2);
}
selection.finish();
if (contextMenuTargetId != -1)
{
document.editTarget = Document::EditTarget::OVERLAY;
if (!selection.contains(contextMenuTargetId)) selection = {contextMenuTargetId};
reference = contextMenuTargetId;
document.region.reference = -1;
document.region.selection.clear();
}
if (arrowSelectionId != -1)
{
document.editTarget = Document::EditTarget::OVERLAY;
selection = {arrowSelectionId};
reference = arrowSelectionId;
document.region.reference = -1;
document.region.selection.clear();
}
if (shortcut(manager.chords[SHORTCUT_CONFIRM], shortcut::FOCUSED) && reference != -1 && window.dialog)
if (auto overlay = document.overlay_get(reference)) window_directory_open(*window.dialog, document, overlay->path);
if (ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) &&
ImGui::IsMouseReleased(ImGuiMouseButton_Right) && !ImGui::IsAnyItemHovered())
isContextMenuQueued = true;
if (isContextMenuQueued) ImGui::OpenPopup("##Overlay Context Menu");
Actions actions{};
window_overlays_context_actions_add(window, manager, settings, document, clipboard, actions);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, window.tooltipWindowPadding);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, window.tooltipItemSpacing);
actions_popup_draw("##Overlay Context Menu", actions, settings);
ImGui::PopStyleVar(2);
};
window.context_update =
[](Window&, Manager&, Settings&, Resources&, Clipboard&, Document&) {};
window.footer_update =
[](Window& window, Manager& manager, Settings& settings, Resources&, Clipboard& clipboard, Document& document)
{
auto& selection = document.overlay.selection;
auto rowOneWidgetSize = widget_size_with_row_get(3);
Actions rowOneActions{};
rowOneActions.add(ACTION_ADD, [&]() { return (bool)window.add; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.add); },
TOOLTIP_ADD_OVERLAY);
rowOneActions.add(ACTION_RELOAD, [&]() { return !selection.empty() && (bool)window.reload; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.reload); },
TOOLTIP_RELOAD_OVERLAYS);
rowOneActions.add(ACTION_REPLACE, [&]() { return selection.size() == 1 && (bool)window.replace; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.replace); },
TOOLTIP_REPLACE_OVERLAY);
bool isSameLine{};
for (auto& action : rowOneActions.items)
action_button_draw(action, manager, settings, rowOneWidgetSize, isSameLine);
if (window.dialog && window.dialog->is_selected(Dialog::OVERLAY_OPEN))
{
auto paths = window.dialog->paths;
manager.command_push({manager.selected, [&window, paths](Manager&, Document& document)
{
document.overlays_add(document.spritesheet.reference, paths);
document.region.reference = -1;
document.region.selection.clear();
window.newElementId = document.overlay.reference;
}});
window.dialog->reset();
}
if (window.dialog && window.dialog->is_selected(Dialog::OVERLAY_REPLACE))
{
if (selection.size() == 1 && !window.dialog->path.empty())
{
auto id = *selection.begin();
auto dialogPath = window.dialog->path;
manager.command_push({manager.selected, [id, dialogPath](Manager&, Document& document)
{
auto behavior = [&]()
{
auto overlay = document.overlay_get(id);
if (!overlay) return;
overlay->path = window_asset_path_get(document, dialogPath);
document.overlay_texture_reload(id);
};
window_edit(document, Document::SPRITESHEETS, localize.get(EDIT_REPLACE_OVERLAY),
behavior);
if (auto overlay = document.overlay_get(id))
{
document.overlay_hash_set_saved(id);
auto pathString = path::to_utf8(overlay->path);
toasts.push(std::vformat(localize.get(TOAST_REPLACE_OVERLAY),
std::make_format_args(id, pathString)));
logger.info(std::vformat(localize.get(TOAST_REPLACE_OVERLAY, anm2ed::ENGLISH),
std::make_format_args(id, pathString)));
}
}});
}
window.dialog->reset();
}
if (window.dialog && window.dialog->is_selected(Dialog::OVERLAY_PATH_SET))
{
if (selection.size() == 1 && !window.dialog->path.empty())
{
auto id = *selection.begin();
auto dialogPath = window.dialog->path;
manager.command_push({manager.selected, [id, dialogPath](Manager&, Document& document)
{
auto behavior = [&]()
{
auto overlay = document.overlay_get(id);
auto texture = document.overlay_texture_get(id);
if (!overlay || !texture) return;
auto newPath = window_asset_path_get(document, dialogPath);
auto pathString = path::to_utf8(newPath);
WorkingDirectory workingDirectory(document.directory_get());
path::ensure_directory(newPath.parent_path());
if (!texture->write_png(newPath))
{
toasts.push(std::vformat(localize.get(TOAST_SAVE_OVERLAY_FAILED),
std::make_format_args(id, pathString)));
logger.error(
std::vformat(localize.get(TOAST_SAVE_OVERLAY_FAILED, anm2ed::ENGLISH),
std::make_format_args(id, pathString)));
return;
}
overlay->path = newPath;
document.overlayTexturePaths[id] = overlay->path;
document.overlay_hash_set_saved(id);
toasts.push(std::vformat(localize.get(TOAST_SAVE_OVERLAY),
std::make_format_args(id, pathString)));
logger.info(std::vformat(localize.get(TOAST_SAVE_OVERLAY, anm2ed::ENGLISH),
std::make_format_args(id, pathString)));
};
window_edit(document, Document::SPRITESHEETS, localize.get(EDIT_SET_OVERLAY_FILE_PATH),
behavior);
}});
}
window.dialog->reset();
}
auto rowTwoWidgetSize = widget_size_with_row_get(2);
Actions rowTwoActions{};
rowTwoActions.add(ACTION_REMOVE, [&]() { return !selection.empty() && (bool)window.remove; },
[&]() { window_command_run(window, manager, settings, document, clipboard, window.remove); },
TOOLTIP_REMOVE_OVERLAYS);
rowTwoActions.add(ACTION_SAVE, [&]() { return !selection.empty(); },
[&]()
{
if (settings.fileIsWarnOverwrite)
{
window.selection2 = selection;
window.popup2.open();
}
else if (window.save)
window_command_run(window, manager, settings, document, clipboard, window.save);
},
TOOLTIP_SAVE_OVERLAYS);
isSameLine = false;
for (auto& action : rowTwoActions.items)
action_button_draw(action, manager, settings, rowTwoWidgetSize, isSameLine);
if (shortcut(manager.chords[SHORTCUT_ADD], shortcut::FOCUSED) && window.add)
window_command_run(window, manager, settings, document, clipboard, window.add);
if (shortcut(manager.chords[SHORTCUT_REMOVE], shortcut::FOCUSED) && window.remove)
window_command_run(window, manager, settings, document, clipboard, window.remove);
if (shortcut(manager.chords[SHORTCUT_COPY], shortcut::FOCUSED) && window.copy)
window_command_run(window, manager, settings, document, clipboard, window.copy);
if (shortcut(manager.chords[SHORTCUT_PASTE], shortcut::FOCUSED) && window.paste)
window_command_run(window, manager, settings, document, clipboard, window.paste);
};
window.popup_update =
[](Window& window, Manager& manager, Settings&, Resources&, Clipboard&, Document& document)
{
window.popup.trigger();
if (ImGui::BeginPopupModal(window.popup.label(), &window.popup.isOpen, ImGuiWindowFlags_NoResize))
{
auto spritesheetReference = document.spritesheet.reference;
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, spritesheetReference);
auto targetOverlay = document.overlay.reference == -1
? nullptr
: spritesheet ? element_child_id_get(*spritesheet, ElementType::OVERLAY,
document.overlay.reference)
: nullptr;
bool isOverlayInvalid = !spritesheet || !targetOverlay;
if (isOverlayInvalid)
window.popup.close();
else
{
if (window.popup.isJustOpened) window.editElement = *targetOverlay;
auto& overlay = window.editElement;
auto childSize = child_size_get(4);
if (ImGui::BeginChild("##Child", childSize, ImGuiChildFlags_Borders))
{
ImGui::DragFloat2(localize.get(BASIC_OFFSET), value_ptr(overlay.position), DRAG_SPEED, 0.0f, 0.0f,
math::vec2_format_get(overlay.position));
int alpha = std::clamp(math::float_to_uint8(overlay.tint.a), 0, 255);
if (ImGui::SliderInt(localize.get(BASIC_ALPHA), &alpha, 0, 255))
overlay.tint.a = math::uint8_to_float(alpha);
int drawOrder = overlay.index == OVERLAY_DRAW_ORDER_BELOW ? OVERLAY_DRAW_ORDER_BELOW
: OVERLAY_DRAW_ORDER_ABOVE;
ImGui::SeparatorText(localize.get(LABEL_OVERLAY_DRAW_ORDER));
ImGui::RadioButton(localize.get(LABEL_OVERLAY_DRAW_ORDER_BELOW), &drawOrder, OVERLAY_DRAW_ORDER_BELOW);
ImGui::SameLine();
ImGui::RadioButton(localize.get(LABEL_OVERLAY_DRAW_ORDER_ABOVE), &drawOrder, OVERLAY_DRAW_ORDER_ABOVE);
overlay.index = drawOrder;
}
ImGui::EndChild();
auto widgetSize = widget_size_with_row_get(2);
shortcut(manager.chords[SHORTCUT_CONFIRM]);
if (ImGui::Button(localize.get(BASIC_CONFIRM), widgetSize))
{
auto editedOverlay = overlay;
auto editedReference = document.overlay.reference;
auto editedSpritesheetReference = spritesheetReference;
manager.command_push({manager.selected, [&window, editedOverlay, editedReference,
editedSpritesheetReference](Manager&, Document& document) mutable
{
auto spritesheet =
document.anm2.element_get(ElementType::SPRITESHEET, editedSpritesheetReference);
if (!spritesheet) return;
auto target =
element_child_id_get(*spritesheet, ElementType::OVERLAY, editedReference);
if (!target) return;
auto set = [&]()
{
target->position = editedOverlay.position;
target->tint.a = editedOverlay.tint.a;
target->index = editedOverlay.index == OVERLAY_DRAW_ORDER_BELOW
? OVERLAY_DRAW_ORDER_BELOW
: OVERLAY_DRAW_ORDER_ABOVE;
document.overlay.reference = editedReference;
document.overlay.selection = {editedReference};
document.editTarget = Document::EditTarget::OVERLAY;
};
window_edit(window, document, localize.get(EDIT_SET_OVERLAY_PROPERTIES), set);
}});
window.popup.close();
}
ImGui::SameLine();
shortcut(manager.chords[SHORTCUT_CANCEL]);
if (ImGui::Button(localize.get(BASIC_CANCEL), widgetSize)) window.popup.close();
}
ImGui::EndPopup();
}
window.popup.end();
window.popup2.trigger();
if (ImGui::BeginPopupModal(window.popup2.label(), &window.popup2.isOpen, ImGuiWindowFlags_NoResize))
{
ImGui::TextUnformatted(localize.get(LABEL_OVERWRITE_CONFIRMATION));
auto widgetSize = widget_size_with_row_get(2);
if (ImGui::Button(localize.get(BASIC_YES), widgetSize))
{
auto queuedSelection = window.selection2;
manager.command_push({manager.selected, [queuedSelection](Manager&, Document& document) mutable
{ window_overlays_save(document, queuedSelection); }});
window.selection2.clear();
window.popup2.close();
}
ImGui::SameLine();
if (ImGui::Button(localize.get(BASIC_NO), widgetSize))
{
window.selection2.clear();
window.popup2.close();
}
ImGui::EndPopup();
}
window.popup2.end();
};
return window;
}
Window spritesheets_window_register()
{
Window window{};
-1
View File
@@ -139,6 +139,5 @@ namespace anm2ed::imgui
Window layers_window_register();
Window nulls_window_register();
Window events_window_register();
Window overlays_window_register();
void window_update(Window&, Manager&, Settings&, Resources&, Dialog&, Clipboard&);
}
+10
View File
@@ -67,6 +67,14 @@ namespace anm2ed::resource::icon
inline constexpr auto HIDE_LAYERS_DATA = R"(
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M20.0833 15.1999L21.2854 15.9212C21.5221 16.0633 21.5989 16.3704 21.4569 16.6072C21.4146 16.6776 21.3557 16.7365 21.2854 16.7787L12.5144 22.0412C12.1977 22.2313 11.8021 22.2313 11.4854 22.0412L2.71451 16.7787C2.47772 16.6366 2.40093 16.3295 2.54301 16.0927C2.58523 16.0223 2.64413 15.9634 2.71451 15.9212L3.9166 15.1999L11.9999 20.0499L20.0833 15.1999ZM20.0833 10.4999L21.2854 11.2212C21.5221 11.3633 21.5989 11.6704 21.4569 11.9072C21.4146 11.9776 21.3557 12.0365 21.2854 12.0787L11.9999 17.6499L2.71451 12.0787C2.47772 11.9366 2.40093 11.6295 2.54301 11.3927C2.58523 11.3223 2.64413 11.2634 2.71451 11.2212L3.9166 10.4999L11.9999 15.3499L20.0833 10.4999ZM12.5144 1.30864L21.2854 6.5712C21.5221 6.71327 21.5989 7.0204 21.4569 7.25719C21.4146 7.32757 21.3557 7.38647 21.2854 7.42869L11.9999 12.9999L2.71451 7.42869C2.47772 7.28662 2.40093 6.97949 2.54301 6.7427C2.58523 6.67232 2.64413 6.61343 2.71451 6.5712L11.4854 1.30864C11.8021 1.11864 12.1977 1.11864 12.5144 1.30864ZM11.9999 3.33233L5.88723 6.99995L11.9999 10.6676L18.1126 6.99995L11.9999 3.33233Z"/></svg>
)";
inline constexpr auto OVER_DATA = R"(
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M11 3C11.5523 3 12 3.44772 12 4V6H17C17.5523 6 18 6.44772 18 7V12H20C20.5523 12 21 12.4477 21 13V20C21 20.5523 20.5523 21 20 21H13C12.4477 21 12 20.5523 12 20V18H7C6.44772 18 6 17.5523 6 17V12H4C3.44772 12 3 11.5523 3 11V4C3 3.44772 3.44772 3 4 3H11ZM16 8H8V16H16V8Z"></path></svg>
)";
inline constexpr auto UNDER_DATA = R"(
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M11 3C11.5523 3 12 3.44772 12 4V6H17C17.5523 6 18 6.44772 18 7V12H20C20.5523 12 21 12.4477 21 13V20C21 20.5523 20.5523 21 20 21H13C12.4477 21 12 20.5523 12 20V18H7C6.44772 18 6 17.5523 6 17V12H4C3.44772 12 3 11.5523 3 11V4C3 3.44772 3.44772 3 4 3H11ZM16 8H12V11C12 11.5523 11.5523 12 11 12H8V16H12V13C12 12.4477 12.4477 12 13 12H16V8Z"></path></svg>
)";
inline constexpr auto SHOW_RECT_DATA = R"(
@@ -192,6 +200,8 @@ namespace anm2ed::resource::icon
X(HIDE_UNUSED, HIDE_UNUSED_DATA, SIZE_NORMAL) \
X(SHOW_LAYERS, SHOW_LAYERS_DATA, SIZE_NORMAL) \
X(HIDE_LAYERS, HIDE_LAYERS_DATA, SIZE_NORMAL) \
X(OVER, OVER_DATA, SIZE_NORMAL) \
X(UNDER, UNDER_DATA, SIZE_NORMAL) \
X(PAN, PAN_DATA, SIZE_NORMAL) \
X(MOVE, MOVE_DATA, SIZE_NORMAL) \
X(ROTATE, ROTATE_DATA, SIZE_NORMAL) \
+4 -29
View File
@@ -108,7 +108,6 @@ namespace anm2ed
X(EDIT_ADD_ITEM, "Add Item", "Añadir Item", "Добавить предмет", "添加物品", "항목 추가") \
X(EDIT_ADD_LAYER, "Add Layer", "Añadir Capa", "Добавить слой", "添加动画层", "레이어 추가") \
X(EDIT_ADD_NULL, "Add Null", "Añadir Null", "Добавить нуль", "添加Null", "Null 추가") \
X(EDIT_ADD_OVERLAY, "Add Overlay", "Add Overlay", "Add Overlay", "Add Overlay", "Add Overlay") \
X(EDIT_ADD_SPRITESHEET, "Add Spritesheet", "Añadir Spritesheet", "Добавить спрайт-лист", "添加图集", "스프라이트 시트 추가") \
X(EDIT_ADD_SOUND, "Add Sound", "Añadir Sonido", "Добавить звук", "添加声音", "사운드 추가") \
X(EDIT_ADD_TRIGGER_SOUND, "Add Trigger Sound", "Añadir Sonido del Trigger", "Добавить звук триггера", "添加事件触发器声音", "트리거 사운드 추가") \
@@ -165,10 +164,8 @@ namespace anm2ed
X(EDIT_PASTE_LAYERS, "Paste Layer(s)", "Pegar Capa(s)", "Вставить слои", "粘贴动画层", "레이어 붙여넣기") \
X(EDIT_PASTE_REGIONS, "Paste Region(s)", "Pegar Región(es)", "Вставить регионы", "粘贴区域", "영역 붙여넣기") \
X(EDIT_PASTE_NULLS, "Paste Null(s)", "Pegar Null(s)", "Вставить нули", "粘贴Null", "Null 붙여넣기") \
X(EDIT_PASTE_OVERLAYS, "Paste Overlay(s)", "Paste Overlay(s)", "Paste Overlay(s)", "Paste Overlay(s)", "Paste Overlay(s)") \
X(EDIT_PASTE_SOUNDS, "Paste Sound(s)", "Pegar Sonido(s)", "Вставить звук(и)", "粘贴声音", "사운드 붙여넣기") \
X(EDIT_PASTE_SPRITESHEETS, "Paste Spritesheet(s)", "Pegar Spritesheet(s)", "Вставить спрайт-листы", "粘贴图集", "스프라이트 시트 붙여넣기") \
X(EDIT_RELOAD_OVERLAYS, "Reload Overlay(s)", "Reload Overlay(s)", "Reload Overlay(s)", "Reload Overlay(s)", "Reload Overlay(s)") \
X(EDIT_RELOAD_SPRITESHEETS, "Reload Spritesheet(s)", "Recargar Spritesheet(s)", "Перезагрузить спрайт-листы", "重新加载图集", "스프라이트 시트 다시 불러오기") \
X(EDIT_RELOAD_SOUNDS, "Reload Sound(s)", "Recargar Sonido(s)", "Перезагрузить звук(и)", "重新加载声音", "사운드 다시 불러오기") \
X(EDIT_REMOVE_ANIMATIONS, "Remove Animation(s)", "Remover Animacion(es)", "Удалить анимации", "删除动画层", "애니메이션 제거") \
@@ -180,14 +177,10 @@ namespace anm2ed
X(EDIT_REMOVE_UNUSED_NULLS, "Remove Unused Nulls", "Remover Nulls No Utilizados", "Удалить неизпользуемые нули", "删除未使用的Null", "미사용 Null 제거") \
X(EDIT_REMOVE_UNUSED_SOUNDS, "Remove Unused Sounds", "Remover Sonidos No Utilizados", "Удалить неизпользуемые звуки", "删除未使用的声音", "미사용 사운드 제거") \
X(EDIT_REMOVE_UNUSED_SPRITESHEETS, "Remove Unused Spritesheets", "Remover Spritesheets No Utilizadas", "Удалить неизпользуемые спрайт-листы", "删除未使用的图集", "미사용 스프라이트 시트 제거") \
X(EDIT_REMOVE_OVERLAYS, "Remove Overlay(s)", "Remove Overlay(s)", "Remove Overlay(s)", "Remove Overlay(s)", "Remove Overlay(s)") \
X(EDIT_RENAME_GROUP, "Rename Group", "Renombrar grupo", "Переименовать группу", "重命名组", "그룹 이름 바꾸기") \
X(EDIT_RENAME_EVENT, "Rename Event", "Renombrar Evento", "Переименовать событие", "重命名事件", "이벤트 이름 바꾸기") \
X(EDIT_REPLACE_SPRITESHEET, "Replace Spritesheet", "Reemplazar Spritesheet", "Заменить спрайт-лист", "替换图集", "스프라이트 시트 교체") \
X(EDIT_REPLACE_OVERLAY, "Replace Overlay", "Replace Overlay", "Replace Overlay", "Replace Overlay", "Replace Overlay") \
X(EDIT_REPLACE_SOUND, "Replace Sound", "Reemplazar Sonido", "Заменить звук", "替换声音", "사운드 교체") \
X(EDIT_SET_OVERLAY_FILE_PATH, "Set Overlay File Path", "Set Overlay File Path", "Set Overlay File Path", "Set Overlay File Path", "Set Overlay File Path") \
X(EDIT_SET_OVERLAY_PROPERTIES, "Set Overlay Properties", "Set Overlay Properties", "Set Overlay Properties", "Set Overlay Properties", "Set Overlay Properties") \
X(EDIT_SET_SPRITESHEET_FILE_PATH, "Set Spritesheet File Path", "Set Spritesheet File Path", "Set Spritesheet File Path", "Set Spritesheet File Path", "Set Spritesheet File Path") \
X(EDIT_SET_LAYER_PROPERTIES, "Set Layer Properties", "Establecer Propiedades de Capa", "Установить свойства слоя", "更改动画层属性", "레이어 속성 설정") \
X(EDIT_SET_REGION_PROPERTIES, "Set Region Properties", "Establecer propiedades de región", "Установить свойства региона", "更改区域属性", "영역 속성 설정") \
@@ -196,7 +189,6 @@ namespace anm2ed
X(EDIT_SCAN_AND_SET_REGIONS, "Scan and Set Regions", "Escanear y establecer regiones", "Сканировать и установить регионы", "扫描并设置区域", "영역 스캔 및 설정") \
X(EDIT_REGION_CROP, "Region Crop", "Recorte de región", "Обрезка региона", "区域裁剪", "영역 자르기") \
X(EDIT_REGION_MOVE, "Region Pivot", "Pivote de región", "Пивот региона", "区域枢轴", "영역 피벗") \
X(EDIT_OVERLAY_MOVE, "Overlay Offset", "Overlay Offset", "Overlay Offset", "Overlay Offset", "Overlay Offset") \
X(EDIT_SPLIT_FRAME, "Split Frame", "Dividir Frame", "Разделить кадр", "拆分帧", "프레임 분할") \
X(EDIT_SHORTEN_FRAME, "Shorten Frame", "Acortar Frame", "Укоротить кадр", "缩短帧时长", "프레임 단축") \
X(EDIT_TOGGLE_ITEM_VISIBILITY, "Toggle Item Visibility", "Alternar Visibilidad de item", "Переключить видимость предмета", "物品可见", "항목 표시/숨기기") \
@@ -221,7 +213,6 @@ namespace anm2ed
X(FORMAT_LOOP, "Loop: {0}", "Loop: {0}", "Цикл: {0}", "循环: {0}", "반복: {0}") \
X(FORMAT_NOT_SAVED, "{0} [Not Saved]", "{0} [Not Saved]", "{0} [Не сохранено]", "{0} [未保存]", "{0} [저장되지 않음]") \
X(FORMAT_NULL, "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}") \
X(FORMAT_OVERLAY, "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}") \
X(FORMAT_PIVOT, "Pivot: ({0}, {1})", "Pivote", "Точка вращения: ({0}, {1})", "枢轴: ({0}, {1})", "중심점: ({0}, {1})") \
X(FORMAT_POSITION, "Position: ({0}, {1})", "Posicion: ({0}, {1})", "Позиция: ({0}, {1})", "位置: ({0}, {1})", "위치: ({0}, {1})") \
X(FORMAT_POSITION_SPACED, "Position: ({0:3}, {1:3})", "Posicion: ({0:3}, {1:3})", "Позиция: ({0:3}, {1:3})", "位置: ({0:3}, {1:3})", "위치: ({0:3}, {1:3})") \
@@ -366,11 +357,6 @@ namespace anm2ed
X(LABEL_OUTPUT_DIRECTORY, "Directory", "Directorio", "Директория", "目录", "디렉터리") \
X(LABEL_OUTPUT_PATH, "Path", "Ruta", "Путь", "路径", "경로") \
X(LABEL_OVERLAY, "Overlay", "Overlay", "Наложение", "动画叠加", "오버레이") \
X(LABEL_OVERLAY_DRAW_ORDER, "Draw Order", "Draw Order", "Draw Order", "Draw Order", "Draw Order") \
X(LABEL_OVERLAY_DRAW_ORDER_ABOVE, "Above", "Above", "Above", "Above", "Above") \
X(LABEL_OVERLAY_DRAW_ORDER_BELOW, "Below", "Below", "Below", "Below", "Below") \
X(LABEL_OVERLAY_PROPERTIES, "Overlay Properties", "Overlay Properties", "Overlay Properties", "Overlay Properties", "Overlay Properties") \
X(LABEL_OVERLAYS_WINDOW, "Overlays###Overlays", "Overlays###Overlays", "Overlays###Overlays", "Overlays###Overlays", "Overlays###Overlays") \
X(LABEL_OVERWRITE_CONFIRMATION, "Are you sure? This will overwrite the existing file.", "¿Estas Seguro? Esto sobreescribira el archivo existente.", "Вы уверены? Это перезапишет существующий файл.", "你确定吗? 这样会覆盖原本的文件.", "저장하시겠습니까? 기존 파일을 덮어쓰게 됩니다.") \
X(LABEL_OVERWRITE_WARNING, "Overwrite Warning", "Alerta de Sobreescribir", "Предупреждение о перезаписи", "覆盖提醒", "덮어쓰기 경고") \
X(LABEL_SERIALIZATION, "Serialization", "Serialization", "Serialization", "Serialization", "Serialization") \
@@ -523,7 +509,6 @@ namespace anm2ed
X(TOAST_DESERIALIZE_LAYERS_FAILED, "Failed to deserialize layer(s):", "Falla al deserializar capas(s):", "Не удалось десериализировать слои: {0}", "反序列化动画层失败: {0}", "레이어 역직렬화 실패: {0}") \
X(TOAST_DESERIALIZE_REGIONS_FAILED, "Failed to deserialize region(s): {0}", "Falla al deserializar región(es): {0}", "Не удалось десериализировать регионы: {0}", "反序列化区域失败: {0}", "영역 역직렬화 실패: {0}") \
X(TOAST_DESERIALIZE_NULLS_FAILED, "Failed to deserialize null(s): {0}", "Falla al deserializar null(s): {0}", "Не удалось десериализировать нули: {0}", "反序列化Null失败: {0}", "Null 역직렬화 실패: {0}") \
X(TOAST_DESERIALIZE_OVERLAYS_FAILED, "Failed to deserialize overlay(s): {0}", "Failed to deserialize overlay(s): {0}", "Failed to deserialize overlay(s): {0}", "Failed to deserialize overlay(s): {0}", "Failed to deserialize overlay(s): {0}") \
X(TOAST_DESERIALIZE_SPRITESHEETS_FAILED, "Failed to deserialize spritesheet(s): {0}", "Falla al deserializar spritesheet(s): {0}", "Не удалось десериализировать спрайт-листы: {0}", "反序列化图集失败: {0}", "스프라이트 시트 역직렬화 실패: {0}") \
X(TOAST_EXPORT_RENDERED_ANIMATION, "Exported rendered animation to: {0}", "Se ha exportado la animacion renderizada a: {0}", "Рендерированные анимации экспортированы в: {0}", "渲染动画导出至: {0}", "{0}에 렌더링 된 애니메이션을 내보내기 했습니다.") \
X(TOAST_EXPORT_RENDERED_ANIMATION_FAILED, "Could not output rendered animation: {0}", "No se pudo emitir la animacion renderizada: {0}", "Не удалось вывести рендерированную анимацию: {0}", "无法输出渲染动画: {0}", "{0}에 렌더링 된 애니메이션을 내보내기 할 수 없습니다.") \
@@ -531,8 +516,6 @@ namespace anm2ed
X(TOAST_EXPORT_RENDERED_FRAMES_FAILED, "Could not export frames to: {0}", "No se pdo exportar Frames a: {0}", "Не удалось экспортировать кадры в: {0}", "无法导出帧至: {0}", "프레임을 내보내기 할 수 없습니다. {0}") \
X(TOAST_EXPORT_SPRITESHEET, "Exported spritesheet to: {0}", "Se ha exportado spritesheet a: {0}", "Спрайт-лист экспортирован в: {0}", "导出图集至: {0}", "{0}에 스프라이트 시트를 내보내기 했습니다.") \
X(TOAST_EXPORT_SPRITESHEET_FAILED, "Could not export spritesheet to: {0}", "No se pudo exportar spritesheet a: {0}", "Не удалось экспортировать спрайт-лист в: {0}", "无法导出图集至: {0}", "{0}에 스프라이트 시트를 내보내기 할 수 없습니다.") \
X(TOAST_OVERLAY_INIT_FAILED, "Failed to initialize overlay: {0}", "Failed to initialize overlay: {0}", "Failed to initialize overlay: {0}", "Failed to initialize overlay: {0}", "Failed to initialize overlay: {0}") \
X(TOAST_OVERLAY_INITIALIZED, "Initialized overlay #{0}: {1}", "Initialized overlay #{0}: {1}", "Initialized overlay #{0}: {1}", "Initialized overlay #{0}: {1}", "Initialized overlay #{0}: {1}") \
X(TOAST_ADD_SPRITESHEET_FAILED, "Failed to add spritesheet! Open a document first.", "¡Error a añadir spritesheet! Abre un documento primero.", "Не удалось добавить спрайт-лист! Сначала откройте документ.", "无法添加图集!请先打开文档。", "스프라이트 시트를 추가할 수 없습니다! 먼저 문서를 여세요.") \
X(TOAST_ADD_SOUND_FAILED, "Failed to add sound! Open a document first.", "¡Error al añadir sonido! Abre un documento primero.", "Не удалось добавить звук! Сначала откройте документ.", "无法添加声音!请先打开文档。", "사운드를 추가할 수 없습니다! 먼저 문서를 여세요.") \
X(TOAST_INVALID_FFMPEG, "Unable to run FFmpeg. Make sure the executable exists, has the proper permissions, and is a valid FFmpeg executable.", "No se pudo ejecutar FFmpeg. Asegúrate de que el ejecutable exista, tenga los permisos adecuados y sea un FFmpeg válido.", "Не удалось запустить FFmpeg. Убедитесь, что исполняемый файл существует, имеет нужные права и является корректным исполняемым FFmpeg.", "无法运行 FFmpeg。请确保可执行文件存在,具有正确的权限,并且是有效的 FFmpeg 可执行文件。", "FFmpeg을 실행할 수 없습니다. 실행 파일이 존재하고 올바른 권한을 가지며 유효한 FFmpeg 실행 파일인지 확인하세요.") \
@@ -544,7 +527,6 @@ namespace anm2ed
X(TOAST_REDO, "Redo: {0}", "Rehacer: {0}", "Повтор: {0}", "重做: {0}", "다시 실행: {0}") \
X(ERROR_FILE_NOT_FOUND, "File not found!", "¡Archivo no encontrado!", "Файл не найден!", "找不到文件!", "파일을 찾을 수 없습니다!") \
X(ERROR_FILE_PERMISSIONS, "File does not have write permissions!", "¡El archivo no tiene permisos de escritura!", "У файла нет прав на запись!", "文件没有写入权限!", "파일에 쓰기 권한이 없습니다!") \
X(TOAST_RELOAD_OVERLAY, "Reloaded overlay #{0}: {1}", "Reloaded overlay #{0}: {1}", "Reloaded overlay #{0}: {1}", "Reloaded overlay #{0}: {1}", "Reloaded overlay #{0}: {1}") \
X(TOAST_RELOAD_SPRITESHEET, "Reloaded spritesheet #{0}: {1}", "Se ha recargado spritesheet #{0}: {1}", "Спрайт-лист #{0} перезагружен: {1}", "重新加载了图集 #{0}: {1}", "{0}번 스프라이트 시트 다시 불러옴: {1}") \
X(TOAST_MERGE_SPRITESHEETS, "Merged selected spritesheets.", "Spritesheets seleccionados combinados.", "Выбранные спрайт-листы объединены.", "已合并所选图集。", "선택된 스프라이트 시트를 병합했습니다.") \
X(TOAST_MERGE_SPRITESHEETS_FAILED, "Failed to merge selected spritesheets.", "No se pudieron combinar los spritesheets seleccionados.", "Не удалось объединить выбранные спрайт-листы.", "合并所选图集失败。", "선택된 스프라이트 시트 병합에 실패했습니다.") \
@@ -552,15 +534,11 @@ namespace anm2ed
X(TOAST_PACK_SPRITESHEET_FAILED, "Failed to pack spritesheet.", "No se pudo empaquetar el spritesheet.", "Не удалось упаковать спрайт-лист.", "图集打包失败。", "스프라이트 시트 패킹에 실패했습니다.") \
X(TOAST_RELOAD_SOUND, "Reloaded sound #{0}: {1}", "Se ha recargado sonido #{0}: {1}", "Звук #{0} перезагружен: {1}", "重新加载了声音 #{0}: {1}", "{0}번 사운드 다시 불러옴: {1}") \
X(TOAST_SCAN_AND_SET_REGIONS, "Matched regionless frames to candidate regions.", "Se emparejaron frames sin region con regiones candidatas.", "Кадры без региона сопоставлены с подходящими регионами.", "已将无区域帧匹配到候选区域。", "영역이 없는 프레임을 후보 영역에 매칭했습니다.") \
X(TOAST_REMOVE_OVERLAY, "Removed overlay #{0}: {1}", "Removed overlay #{0}: {1}", "Removed overlay #{0}: {1}", "Removed overlay #{0}: {1}", "Removed overlay #{0}: {1}") \
X(TOAST_REMOVE_SPRITESHEET, "Removed spritesheet #{0}: {1}", "Se ha removido spritesheet #{0}: {1}", "Спрайт-лист #{0} удален: {1}", "去除了图集 #{0}: {1}", "{0}번 스프라이트 시트 제거됨: {1}") \
X(TOAST_REPLACE_OVERLAY, "Replaced overlay #{0}: {1}", "Replaced overlay #{0}: {1}", "Replaced overlay #{0}: {1}", "Replaced overlay #{0}: {1}", "Replaced overlay #{0}: {1}") \
X(TOAST_REPLACE_SPRITESHEET, "Replaced spritesheet #{0}: {1}", "Se ha reemplazado spritesheet #{0}: {1}", "Спрайт-лист #{0} заменен: {1}", "替换了图集 #{0}: {1}", "{0}번 스프라이트 시트 교체됨: {1}") \
X(TOAST_REPLACE_SOUND, "Replaced sound #{0}: {1}", "Se ha reemplazado sonido #{0}: {1}", "Звук #{0} заменен: {1}", "已替换声音 #{0}: {1}", "{0}번 사운드 교체됨: {1}") \
X(TOAST_SAVE_DOCUMENT, "Saved document to: {0}", "Documento Guardado en: {0}", "Документ сохранен в: {0}", "保存文件至: {0}", "{0}에 파일을 저장했습니다.") \
X(TOAST_SAVE_DOCUMENT_FAILED, "Could not save document to: {0} ({1})", "No se pudo guardar el documento en: {0} ({1})", "Не удалось сохранить документ в: {0} ({1})", "无法保存文件至: {0} ({1})", "{0}에 파일을 저장할 수 없습니다.") \
X(TOAST_SAVE_OVERLAY, "Saved overlay #{0}: {1}", "Saved overlay #{0}: {1}", "Saved overlay #{0}: {1}", "Saved overlay #{0}: {1}", "Saved overlay #{0}: {1}") \
X(TOAST_SAVE_OVERLAY_FAILED, "Unable to save overlay #{0}: {1}", "Unable to save overlay #{0}: {1}", "Unable to save overlay #{0}: {1}", "Unable to save overlay #{0}: {1}", "Unable to save overlay #{0}: {1}") \
X(TOAST_SAVE_SPRITESHEET, "Saved spritesheet #{0}: {1}", "Spritesheet Guardada #{0}: {1}", "Спрайт-лист #{0} сохранен: {1}", "已保存图集 #{0}: {1}", "{1}에 {0}번 스프라이트 시트를 저장했습니다.") \
X(TOAST_SAVE_SPRITESHEET_FAILED, "Unable to save spritesheet #{0}: {1}", "No se pudo guardar spritesheet #{0}: {1}", "Не удалось сохранить спрайт-лист #{0}: {1}", "无法保存图集 #{0}: {1}", "{0}번 스프라이트 시트를 저장할 수 없습니다. {1}") \
X(TOAST_SOUNDS_DESERIALIZE_ERROR, "Failed to deserialize sound(s): {0}", "Error al deserializar sonido(s): {0}", "Не удалось десериализировать звуки: {0}", "反序列化声音失败: {0}", "사운드 역직렬화 실패: {0}") \
@@ -580,7 +558,6 @@ namespace anm2ed
X(TOOLTIP_ADD_LAYER, "Add a layer.", "Añadir una capa.", "Добавить слой.", "添加一个动画层.", "레이어를 추가합니다.") \
X(TOOLTIP_ADD_NULL, "Add a null.", "Añadir Null.", "Добавить нуль.", "添加一个Null.", "Null을 추가합니다.") \
X(TOOLTIP_ADD_SPRITESHEET, "Add a new spritesheet.", "Añadir nueva spritesheet.", "Добавить новый спрайт-лист.", "添加一个新图集.", "새 스프라이트 시트를 추가합니다.") \
X(TOOLTIP_ADD_OVERLAY, "Add a new overlay to the selected spritesheet.", "Add a new overlay to the selected spritesheet.", "Add a new overlay to the selected spritesheet.", "Add a new overlay to the selected spritesheet.", "Add a new overlay to the selected spritesheet.") \
X(TOOLTIP_ADD_VALUES, "Add the specified values onto each frame.\n(Boolean/mapped values will simply be set.)", "Añadir los valores especifiados a cada Frame.\n(Los valores booleanos/mapeados simplemente se estableceran.)", "Добавить указанные значения к каждому кадру.\n(Булевы/сопоставленные значения будут просто установлены.)", "将指定的数值添加到每一帧上. (布尔/映射值将直接被设置.)", "각 프레임의 속성에 지정한 값을 더합니다.\n(불리언/매핑 값은 그대로 설정됩니다.)") \
X(TOOLTIP_ADJUST, "Set the value of each specified value onto the frame's equivalent.", "Ajustar el valor de cada valor especificado a el equivalente del Frame.", "Установить значение каждого указанного значения к эквиваленту кадра.", "将每个指定的数值设置到对应帧的相等的属性上.", "지정된 각 값을 프레임의 대응 값으로 설정합니다.") \
X(TOOLTIP_ALL_ITEMS_VISIBLE, "All items are visible. Press to only show layers.", "Todos los items son visibles. Presiona solo para mostrar capas.", "Все предметы видимы. Нажмите, чтобы только показать слои.", "所有物品均可见. 点击即可仅显示动画层.", "모든 항목이 표시됩니다. 레이어만 표시하려면 누르세요.") \
@@ -673,8 +650,10 @@ namespace anm2ed
X(TOOLTIP_GENERATE_REGION_NAME_FORMAT, "Set the names of the generated regions.\n{} is the frame number.", "Define los nombres de las regiones generadas.\n{} es el número de frame.", "Задаёт имена создаваемых регионов.\n{} — номер кадра.", "设置生成区域的名称。\n{} 是帧编号。", "생성된 영역의 이름을 설정합니다.\n{}는 프레임 번호입니다.") \
X(TOOLTIP_PACK_SPRITESHEET, "Pack the spritesheet by its regions and rebuild the texture.", "Empaqueta el spritesheet por sus regiones y reconstruye la textura.", "Упаковать спрайт-лист по его регионам и пересобрать текстуру.", "按区域打包图集并重建纹理。", "영역 기준으로 스프라이트 시트를 패킹하고 텍스처를 다시 만듭니다.") \
X(TOOLTIP_OUTPUT_PATH, "Set the output path or directory for the animation.", "Ajusta la ruta de salida o el directiorio de la animacion.", "Установить путь или директорию вывода для анимации.", "更改动画的输出路径/目录.", "애니메이션의 출력 경로 또는 디렉터리를 설정합니다.") \
X(TOOLTIP_OVERLAY, "Set an animation to be drawn over the current animation.", "Ajusta una animacion para ser dibujada sobre la animacion actual.", "Установить анимацию, которая будет выведена над текущей анимацией.", "设置一个当前动画的覆盖动画.", "현재 애니메이션 위에 그려질 애니메이션을 설정합니다.") \
X(TOOLTIP_OVERLAY_ALPHA, "Set the alpha of the overlayed animation.", "Ajusta el alpha de la animacion en Overlay", "Установить прозрачность наложенной анимации.", "更改覆盖动画的透明度.", "오버레이된 애니메이션의 불투명도를 설정합니다.") \
X(TOOLTIP_OVERLAY, "Set an animation to draw with the current animation.", "Selecciona una animacion para dibujarla junto a la animacion actual.", "Выбрать анимацию, которая будет рисоваться вместе с текущей анимацией.", "设置一个与当前动画一起绘制的动画.", "현재 애니메이션과 함께 그릴 애니메이션을 설정합니다.") \
X(TOOLTIP_OVERLAY_ALPHA, "Change overlay alpha.", "Cambia el alpha del overlay.", "Изменить прозрачность оверлея.", "更改覆盖动画的透明度.", "오버레이 알파를 변경합니다.") \
X(TOOLTIP_OVERLAY_OVER, "Draw the overlay animation above the current animation.", "Dibuja la animacion overlay encima de la animacion actual.", "Рисовать оверлей-анимацию поверх текущей анимации.", "在当前动画上方绘制覆盖动画.", "오버레이 애니메이션을 현재 애니메이션 위에 그립니다.") \
X(TOOLTIP_OVERLAY_UNDER, "Draw the overlay animation below the current animation.", "Dibuja la animacion overlay debajo de la animacion actual.", "Рисовать оверлей-анимацию под текущей анимацией.", "在当前动画下方绘制覆盖动画.", "오버레이 애니메이션을 현재 애니메이션 아래에 그립니다.") \
X(TOOLTIP_OVERWRITE_WARNING, "A warning will be shown when saving/overwriting a file.", "Una advertencia se mostrara cuando se este guardando/sobreguardando un archivo.", "При сохранении/перезаписи файла будет показано предупреждение.", "保存或覆盖文件时会提示确认。", "저장하거나 덮어쓸 때 경고가 표시됩니다.") \
X(TOOLTIP_EXTENDED_FORMAT, "Use extended Anm2Ed .anm2 format.\nThis is NOT compatible with The Binding of Isaac: Rebirth!", "Use extended Anm2Ed .anm2 format.\nThis is NOT compatible with The Binding of Isaac: Rebirth!", "Use extended Anm2Ed .anm2 format.\nThis is NOT compatible with The Binding of Isaac: Rebirth!", "Use extended Anm2Ed .anm2 format.\nThis is NOT compatible with The Binding of Isaac: Rebirth!", "Use extended Anm2Ed .anm2 format.\nThis is NOT compatible with The Binding of Isaac: Rebirth!") \
X(TOOLTIP_PAUSE_ANIMATION, "Pause the animation.", "Pausa la animacion.", "Поставить анимацию на паузу.", "暂停动画.", "애니메이션을 일시정지합니다.") \
@@ -690,7 +669,6 @@ namespace anm2ed
X(TOOLTIP_USE_ANIMATION_BOUNDS, "Render using the animation's bounds instead of the preview viewport.", "Render using the animation's bounds instead of the preview viewport.", "Render using the animation's bounds instead of the preview viewport.", "Render using the animation's bounds instead of the preview viewport.", "Render using the animation's bounds instead of the preview viewport.") \
X(TOOLTIP_USE_ISOLATED_ANIMATION, "Render only animation layers with a transparent background and preview helpers hidden.", "Render only animation layers with a transparent background and preview helpers hidden.", "Render only animation layers with a transparent background and preview helpers hidden.", "Render only animation layers with a transparent background and preview helpers hidden.", "Render only animation layers with a transparent background and preview helpers hidden.") \
X(TOOLTIP_RENDER_FPS, "Set the exported animation frame rate.", "Set the exported animation frame rate.", "Set the exported animation frame rate.", "Set the exported animation frame rate.", "Set the exported animation frame rate.") \
X(TOOLTIP_RELOAD_OVERLAYS, "Reloads the selected overlays.", "Reloads the selected overlays.", "Reloads the selected overlays.", "Reloads the selected overlays.", "Reloads the selected overlays.") \
X(TOOLTIP_RELOAD_SPRITESHEETS, "Reloads the selected spritesheets.", "Recarga la spritesheet seleccionada.", "Перезагружает выбранные спрайт-листы.", "重新加载所选图集.", "선택한 스프라이트 시트를 다시 불러옵니다.") \
X(TOOLTIP_RELOAD_SOUNDS, "Reloads the selected sounds.", "Recarga los sonidos seleccionados.", "Перезагружает выбранные звуки.", "重新加载所选声音.", "선택한 사운드를 다시 불러옵니다.") \
X(TOOLTIP_REMOVE_ANIMATION, "Remove the selected animation(s).", "Remueve la(s) animacion(es) seleccionada(s).", "Удалить выбранные анимации.", "去除所选动画.", "선택한 애니메이션을 제거합니다.") \
@@ -702,12 +680,10 @@ namespace anm2ed
X(TOOLTIP_REMOVE_UNUSED_NULLS, "Remove unused nulls (i.e., ones not used in any animation.)", "Remueve nulls no utilizados (i. e., aquellos no usados en ninguna animacion.)", "Удалить неиспользуемые нули (т. е. нули, которые не используются ни одной анимацией.)", "去除未使用的Null (未被任何动画使用的那些.)", "사용되지 않는 Null(어떤 애니메이션에서도 사용되지 않는 것)을 제거합니다.") \
X(TOOLTIP_REMOVE_UNUSED_SOUNDS, "Remove unused sounds (i.e., ones not used in any trigger.)", "Remueve sonidos no utilizados (i. e., aquellos no usados en ningun trigger.)", "Удалить неиспользуемые звуки (т. е. звуки, которые не используются ни одным триггером.)", "去除未使用的声音 (未被任何触发器使用的那些.)", "사용되지 않는 사운드(어떤 트리거에서도 사용되지 않는 것)를 제거합니다.") \
X(TOOLTIP_REMOVE_UNUSED_SPRITESHEETS, "Remove all unused spritesheets (i.e., not used in any layer.).", "Remueve todos los spritesheets no utilizados (i. e., aquellos no usados en ninguna capa.)", "Удалить неиспользуемые спрайт-листы (т. е. те, которые не используются ни одним слоем.)", "去除未使用的图集 (未被任何动画层使用的那些.)", "사용되지 않는 모든 스프라이트 시트(어떤 레이어에서도 사용되지 않는 것)를 제거합니다.") \
X(TOOLTIP_REMOVE_OVERLAYS, "Remove the selected overlays.", "Remove the selected overlays.", "Remove the selected overlays.", "Remove the selected overlays.", "Remove the selected overlays.") \
X(TOOLTIP_RENDER_BUTTON, "Render the animation using the current settings.", "Renderiza la animacion usando la configuracion actual", "Рендерировать анимацию, используя текущие настройки.", "应用当前设置去渲染动画.", "현재 설정으로 애니메이션을 렌더링합니다.") \
X(TOOLTIP_RENDER_TYPE, "Set the type of the output.", "Ajusta el tipo de la salida", "Установить тип вывода.", "设置输出的类型.", "출력 유형을 설정합니다.") \
X(TOOLTIP_REPEAT_DELAY, "Set how often, after repeating begins, key inputs will be fired.", "Ajusta que tanto, despues de que empieza la repeticion, seran disparadas las entradas clave.", "Установить, как часто после начала повторения будут срабатывать нажатия клавиш.", "更改键盘按键开启重复时, 重复的速率.", "반복 입력이 시작된 후 입력이 얼마나 자주 들어갈지 설정합니다.") \
X(TOOLTIP_REPLACE_SPRITESHEET, "Replace the selected spritesheet with a new one.", "Reemplaza la spritesheet seleccionada con una nueva.", "Заменить выбранный спрайт-лист на новый.", "替换所选旧图集为新图集.", "선택된 스프라이트 시트를 새 시트로 교체합니다.") \
X(TOOLTIP_REPLACE_OVERLAY, "Replace the selected overlay with a new one.", "Replace the selected overlay with a new one.", "Replace the selected overlay with a new one.", "Replace the selected overlay with a new one.", "Replace the selected overlay with a new one.") \
X(TOOLTIP_REPLACE_SOUND, "Replace the selected sound with a new one.", "Reemplaza el sonido seleccionado con uno nuevo.", "Заменяет выбранный звук новым.", "用新的声音替换所选声音.", "선택한 사운드를 새 사운드로 교체합니다.") \
X(TOOLTIP_ROOT_TRANSFORM, "Root frames will transform the rest of the animation.", "Los Frames root transformaran el resto de la animacion.", "Корневые кадры трансформируют остаток анимации.", "与“根”有关的帧会跟随整个动画而变换.", "Root 프레임이 나머지 애니메이션을 변형합니다.") \
X(TOOLTIP_ROTATION, "Change the rotation of the frame.", "Cambia la rotacion del Frame.", "Изменить поворот кадра.", "更改此帧的旋转.", "프레임의 회전값을 변경합니다.") \
@@ -715,7 +691,6 @@ namespace anm2ed
X(TOOLTIP_ROUND_SCALE, "Scale will be rounded to the nearest whole number.", "La escala sera aproximada al numero entero mas cercano.", "Масштаб будет округлен к самому близкому целому числу.", "缩放数值会被取整.", "비율을 가장 가까운 정수로 반올림합니다.") \
X(TOOLTIP_ROWS, "Set how many rows the spritesheet will have.", "Ajusta cuantas filas tendra el spritsheet.", "Установить сколько рядов будет иметь спрайт-лист.", "设置图集的行数量.", "스프라이트 시트의 행 수를 설정합니다.") \
X(TOOLTIP_SAVE_SPRITESHEETS, "Save the selected spritesheets.", "Guarda los spritesheets seleccionados.", "Сохранить выбранные спрайт-листы.", "保存所选图集.", "선택한 스프라이트 시트를 저장합니다.") \
X(TOOLTIP_SAVE_OVERLAYS, "Save the selected overlays.", "Save the selected overlays.", "Save the selected overlays.", "Save the selected overlays.", "Save the selected overlays.") \
X(TOOLTIP_SCALE, "Change the scale of the frame, in percent.", "Cambia la escala del Frame, en porcentaje.", "Изменить масштаб кадра.", "修改此帧的缩放.", "프레임의 비율을 변경합니다.") \
X(TOOLTIP_SCALE_OUTPUT, "Set the output scale of the animation.", "Ajusta la escala de salida de la animacion.", "Установить масштаб анимации при выводе.", "设置输出动画的缩放.", "애니메이션의 출력 비율을 설정합니다.") \
X(TOOLTIP_SETTINGS_SAVE, "Use the configured settings.", "Usa las opciones configuradas.", "Использовать настроенные настройки.", "应用更改的设置.", "구성된 설정을 사용합니다.") \
-6
View File
@@ -111,12 +111,6 @@ Size=563,353
Collapsed=0
DockId=0x00000014,1
[Window][###Overlays]
Pos=1347,369
Size=563,353
Collapsed=0
DockId=0x00000014,2
[Table][0xE5891919,5]
Column 0 Weight=1.3608
Column 1 Weight=0.8522
+2 -2
View File
@@ -129,7 +129,8 @@ namespace anm2ed
X(PREVIEW_IS_BORDER, previewIsBorder, STRING_UNDEFINED, BOOL, false) \
X(PREVIEW_IS_ALT_ICONS, previewIsAltIcons, STRING_UNDEFINED, BOOL, false) \
X(PREVIEW_IS_TRANSPARENT, animationPreviewTransparent, STRING_UNDEFINED, BOOL, false) \
X(PREVIEW_OVERLAY_TRANSPARENCY, previewOverlayTransparency, STRING_UNDEFINED, FLOAT, 255) \
X(PREVIEW_OVERLAY_TRANSPARENCY, previewOverlayTransparency, STRING_UNDEFINED, FLOAT, 100.0f) \
X(PREVIEW_OVERLAY_DRAW_ORDER, previewOverlayDrawOrder, STRING_UNDEFINED, INT, types::overlay_draw_order::OVER) \
X(PREVIEW_START_ZOOM, previewStartZoom, STRING_UNDEFINED, FLOAT, 200.0f) \
X(PREVIEW_GRID_SIZE, previewGridSize, STRING_UNDEFINED, IVEC2, {32, 32}) \
X(PREVIEW_GRID_OFFSET, previewGridOffset, STRING_UNDEFINED, IVEC2, {}) \
@@ -272,7 +273,6 @@ namespace anm2ed
X(WINDOW_LAYERS, windowIsLayers, LABEL_LAYERS_WINDOW, BOOL, true) \
X(WINDOW_NULLS, windowIsNulls, LABEL_NULLS_WINDOW, BOOL, true) \
X(WINDOW_ONIONSKIN, windowIsOnionskin, LABEL_ONIONSKIN_WINDOW, BOOL, true) \
X(WINDOW_OVERLAYS, windowIsOverlays, LABEL_OVERLAYS_WINDOW, BOOL, true) \
X(WINDOW_PREVIEW, windowIsSpritesheets, LABEL_SPRITESHEETS_WINDOW, BOOL, true) \
X(WINDOW_SHADERS, windowIsShaders, LABEL_SHADERS_WINDOW, BOOL, true) \
X(WINDOW_SOUNDS, windowIsSounds, LABEL_SOUNDS_WINDOW, BOOL, true) \
-1
View File
@@ -206,7 +206,6 @@ namespace anm2ed::snapshots
void step_textures_seed(SnapshotStep& step, const Snapshot& snapshot)
{
step.textures = SnapshotStepValue<SnapshotTextureMap>{snapshot.textures, {}};
step.overlayTextures = SnapshotStepValue<SnapshotOverlayTextureMap>{snapshot.overlayTextures, {}};
}
SnapshotStep step_anm2_seed(const Snapshot& snapshot, const std::string& message)
-5
View File
@@ -59,12 +59,10 @@ namespace anm2ed
Storage layer{};
Storage merge{};
Storage null{};
Storage overlay{};
Storage region{};
Storage sound{};
Storage spritesheet{};
std::map<int, resource::Texture> textures{};
std::map<int, resource::Texture> overlayTextures{};
std::map<int, resource::Audio> sounds{};
Anm2 anm2{};
Reference reference{};
@@ -74,7 +72,6 @@ namespace anm2ed
};
using SnapshotTextureMap = std::map<int, resource::Texture>;
using SnapshotOverlayTextureMap = std::map<int, resource::Texture>;
using SnapshotSoundMap = std::map<int, resource::Audio>;
#define SNAPSHOT_STEP_STATE_FIELDS \
@@ -86,7 +83,6 @@ namespace anm2ed
X(Storage, layer) \
X(Storage, merge) \
X(Storage, null) \
X(Storage, overlay) \
X(Storage, region) \
X(Storage, sound) \
X(Storage, spritesheet) \
@@ -96,7 +92,6 @@ namespace anm2ed
#define SNAPSHOT_STEP_RESOURCE_FIELDS \
X(SnapshotTextureMap, textures) \
X(SnapshotOverlayTextureMap, overlayTextures) \
X(SnapshotSoundMap, sounds)
struct SnapshotStep
+9
View File
@@ -59,6 +59,15 @@ namespace anm2ed::types::source
};
}
namespace anm2ed::types::overlay_draw_order
{
enum Type
{
OVER,
UNDER
};
}
namespace anm2ed::types::merge
{
enum Type
+13
View File
@@ -227,6 +227,19 @@ namespace anm2ed::imgui
return edit::NONE;
}
bool radio_button_icon(const char* label, int* value, int buttonValue, ImTextureID texture, ImVec2 size, ImVec4 tint)
{
bool isSelected = value && *value == buttonValue;
if (isSelected) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive));
bool isActivated =
ImGui::ImageButton(label, texture, size, ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), tint);
if (isSelected) ImGui::PopStyleColor();
if (isActivated && value) *value = buttonValue;
return isActivated;
}
bool input_int_range(const char* label, int& value, int min, int max, int step, int stepFast,
ImGuiInputTextFlags flags)
{
+1
View File
@@ -27,6 +27,7 @@ namespace anm2ed::imgui
const char* = "%.3f", ImGuiSliderFlags = 0);
types::edit::Type color_edit3_persistent(const char*, glm::vec3*, ImGuiColorEditFlags = 0);
types::edit::Type color_edit4_persistent(const char*, glm::vec4*, ImGuiColorEditFlags = 0);
bool radio_button_icon(const char*, int*, int, ImTextureID, ImVec2, ImVec4 = ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
bool combo_negative_one_indexed(const std::string&, int*, std::vector<const char*>&);
bool combo_id_mapped(const std::string&, int*, const std::vector<int>&, std::vector<const char*>&);
}