From 352594e1e3cbe0283f4ef91091bbbbc258977edc Mon Sep 17 00:00:00 2001 From: shweet Date: Thu, 13 Nov 2025 22:29:27 -0500 Subject: [PATCH] ...............................................Anm2Ed 2.0 --- src/anm2/anm2_sounds.cpp | 5 +---- src/imgui/window/animation_preview.cpp | 7 +++---- src/imgui/window/animations.cpp | 18 +++++++++--------- src/imgui/window/timeline.cpp | 11 +++++------ src/resources.cpp | 17 ++++------------- src/resources.h | 1 - 6 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/anm2/anm2_sounds.cpp b/src/anm2/anm2_sounds.cpp index e8b48ba..d8abbd9 100644 --- a/src/anm2/anm2_sounds.cpp +++ b/src/anm2/anm2_sounds.cpp @@ -33,11 +33,8 @@ namespace anm2ed::anm2 if (content.sounds.contains(trigger.soundID)) used.insert(trigger.soundID); std::set unused; - for (const auto& [id, sound] : content.sounds) - { - (void)sound; + for (auto& [id, sound] : content.sounds) if (!used.contains(id)) unused.insert(id); - } return unused; } diff --git a/src/imgui/window/animation_preview.cpp b/src/imgui/window/animation_preview.cpp index e93633d..cce9967 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -1,8 +1,8 @@ #include "animation_preview.h" #include -#include #include +#include #include @@ -53,11 +53,10 @@ namespace anm2ed::imgui { auto& format = settings.renderFormat; bool isSuccess{true}; - for (std::size_t index = 0; index < renderFrames.size(); ++index) + for (auto [i, frame] : std::views::enumerate(renderFrames)) { - auto& frame = renderFrames[index]; std::filesystem::path outputPath = - std::filesystem::path(path) / std::vformat(format, std::make_format_args(index)); + std::filesystem::path(path) / std::vformat(format, std::make_format_args(i)); if (!frame.write_png(outputPath)) { diff --git a/src/imgui/window/animations.cpp b/src/imgui/window/animations.cpp index c376dd9..675a9d8 100644 --- a/src/imgui/window/animations.cpp +++ b/src/imgui/window/animations.cpp @@ -1,6 +1,7 @@ #include "animations.h" #include +#include #include "toast.h" #include "vector_.h" @@ -47,13 +48,12 @@ namespace anm2ed::imgui { selection.start(anm2.animations.items.size()); - for (std::size_t index = 0; index < anm2.animations.items.size(); ++index) + for (auto [i, animation] : std::views::enumerate(anm2.animations.items)) { - auto& animation = anm2.animations.items[index]; - ImGui::PushID((int)index); + ImGui::PushID((int)i); auto isDefault = anm2.animations.defaultAnimation == animation.name; - auto isReferenced = reference.animationIndex == (int)index; + auto isReferenced = reference.animationIndex == (int)i; auto font = isDefault && isReferenced ? font::BOLD_ITALICS : isDefault ? font::BOLD @@ -61,14 +61,14 @@ namespace anm2ed::imgui : font::REGULAR; ImGui::PushFont(resources.fonts[font].get(), font::SIZE); - ImGui::SetNextItemSelectionUserData((int)index); - if (selectable_input_text(animation.name, std::format("###Document #{} Animation #{}", manager.selected, index), - animation.name, selection.contains((int)index))) + ImGui::SetNextItemSelectionUserData((int)i); + if (selectable_input_text(animation.name, std::format("###Document #{} Animation #{}", manager.selected, i), + animation.name, selection.contains((int)i))) { - reference = {(int)index}; + reference = {(int)i}; document.frames.clear(); } - if (ImGui::IsItemHovered()) hovered = (int)index; + if (ImGui::IsItemHovered()) hovered = (int)i; ImGui::PopFont(); if (ImGui::BeginItemTooltip()) diff --git a/src/imgui/window/timeline.cpp b/src/imgui/window/timeline.cpp index f2a2bdc..e9c895d 100644 --- a/src/imgui/window/timeline.cpp +++ b/src/imgui/window/timeline.cpp @@ -552,16 +552,15 @@ namespace anm2ed::imgui frames.selection.start(item->frames.size(), ImGuiMultiSelectFlags_ClearOnEscape); - for (std::size_t frameIndex = 0; frameIndex < item->frames.size(); ++frameIndex) + for (auto [i, frame] : std::views::enumerate(item->frames)) { - auto& frame = item->frames[frameIndex]; - ImGui::PushID((int)frameIndex); + ImGui::PushID((int)i); - auto frameReference = anm2::Reference{reference.animationIndex, type, id, (int)frameIndex}; + auto frameReference = anm2::Reference{reference.animationIndex, type, id, (int)i}; auto isFrameVisible = isVisible && frame.isVisible; auto isReferenced = reference == frameReference; auto isSelected = - (frames.selection.contains((int)frameIndex) && reference.itemType == type && reference.itemID == id) || + (frames.selection.contains((int)i) && reference.itemType == type && reference.itemID == id) || isReferenced; if (type == anm2::TRIGGER) frameTime = frame.atFrame; @@ -579,7 +578,7 @@ namespace anm2ed::imgui ImGui::PushStyleColor(ImGuiCol_HeaderHovered, isFrameVisible ? colorHovered : colorHoveredHidden); ImGui::SetNextItemAllowOverlap(); - ImGui::SetNextItemSelectionUserData((int)frameIndex); + ImGui::SetNextItemSelectionUserData((int)i); if (ImGui::Selectable("##Frame Button", true, ImGuiSelectableFlags_None, buttonSize)) { if (type == anm2::LAYER) diff --git a/src/resources.cpp b/src/resources.cpp index b386bca..f485608 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -1,6 +1,6 @@ #include "resources.h" -#include +#include #include "music.h" @@ -10,23 +10,14 @@ namespace anm2ed { Resources::Resources() { - for (std::size_t i = 0; i < font::COUNT; ++i) - { - const auto& fontInfo = font::FONTS[i]; + for (auto [i, fontInfo] : std::views::enumerate(font::FONTS)) fonts[i] = Font((void*)fontInfo.data, fontInfo.length, font::SIZE); - } - for (std::size_t i = 0; i < icon::COUNT; ++i) - { - const auto& iconInfo = icon::ICONS[i]; + for (auto [i, iconInfo] : std::views::enumerate(icon::ICONS)) icons[i] = Texture(iconInfo.data, iconInfo.length, iconInfo.size); - } - for (std::size_t i = 0; i < shader::COUNT; ++i) - { - const auto& shaderInfo = shader::SHADERS[i]; + for (auto [i, shaderInfo] : std::views::enumerate(shader::SHADERS)) shaders[i] = Shader(shaderInfo.vertex, shaderInfo.fragment); - } }; resource::Audio& Resources::music_track() diff --git a/src/resources.h b/src/resources.h index 46a67ff..7e7a0d8 100644 --- a/src/resources.h +++ b/src/resources.h @@ -15,7 +15,6 @@ namespace anm2ed public: resource::Font fonts[resource::font::COUNT]{}; resource::Texture icons[resource::icon::COUNT]{}; - resource::Texture backgroundTexture{}; resource::Shader shaders[resource::shader::COUNT]{}; resource::Audio music{};