...............................................Anm2Ed 2.0

This commit is contained in:
2025-11-13 22:29:27 -05:00
parent 9af0135a3a
commit 352594e1e3
6 changed files with 22 additions and 37 deletions

View File

@@ -33,11 +33,8 @@ namespace anm2ed::anm2
if (content.sounds.contains(trigger.soundID)) used.insert(trigger.soundID); if (content.sounds.contains(trigger.soundID)) used.insert(trigger.soundID);
std::set<int> unused; std::set<int> unused;
for (const auto& [id, sound] : content.sounds) for (auto& [id, sound] : content.sounds)
{
(void)sound;
if (!used.contains(id)) unused.insert(id); if (!used.contains(id)) unused.insert(id);
}
return unused; return unused;
} }

View File

@@ -1,8 +1,8 @@
#include "animation_preview.h" #include "animation_preview.h"
#include <algorithm> #include <algorithm>
#include <cstddef>
#include <filesystem> #include <filesystem>
#include <ranges>
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
@@ -53,11 +53,10 @@ namespace anm2ed::imgui
{ {
auto& format = settings.renderFormat; auto& format = settings.renderFormat;
bool isSuccess{true}; 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 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)) if (!frame.write_png(outputPath))
{ {

View File

@@ -1,6 +1,7 @@
#include "animations.h" #include "animations.h"
#include <cstddef> #include <cstddef>
#include <ranges>
#include "toast.h" #include "toast.h"
#include "vector_.h" #include "vector_.h"
@@ -47,13 +48,12 @@ namespace anm2ed::imgui
{ {
selection.start(anm2.animations.items.size()); 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)i);
ImGui::PushID((int)index);
auto isDefault = anm2.animations.defaultAnimation == animation.name; 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 auto font = isDefault && isReferenced ? font::BOLD_ITALICS
: isDefault ? font::BOLD : isDefault ? font::BOLD
@@ -61,14 +61,14 @@ namespace anm2ed::imgui
: font::REGULAR; : font::REGULAR;
ImGui::PushFont(resources.fonts[font].get(), font::SIZE); ImGui::PushFont(resources.fonts[font].get(), font::SIZE);
ImGui::SetNextItemSelectionUserData((int)index); ImGui::SetNextItemSelectionUserData((int)i);
if (selectable_input_text(animation.name, std::format("###Document #{} Animation #{}", manager.selected, index), if (selectable_input_text(animation.name, std::format("###Document #{} Animation #{}", manager.selected, i),
animation.name, selection.contains((int)index))) animation.name, selection.contains((int)i)))
{ {
reference = {(int)index}; reference = {(int)i};
document.frames.clear(); document.frames.clear();
} }
if (ImGui::IsItemHovered()) hovered = (int)index; if (ImGui::IsItemHovered()) hovered = (int)i;
ImGui::PopFont(); ImGui::PopFont();
if (ImGui::BeginItemTooltip()) if (ImGui::BeginItemTooltip())

View File

@@ -552,16 +552,15 @@ namespace anm2ed::imgui
frames.selection.start(item->frames.size(), ImGuiMultiSelectFlags_ClearOnEscape); 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)i);
ImGui::PushID((int)frameIndex);
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 isFrameVisible = isVisible && frame.isVisible;
auto isReferenced = reference == frameReference; auto isReferenced = reference == frameReference;
auto isSelected = 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; isReferenced;
if (type == anm2::TRIGGER) frameTime = frame.atFrame; if (type == anm2::TRIGGER) frameTime = frame.atFrame;
@@ -579,7 +578,7 @@ namespace anm2ed::imgui
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, isFrameVisible ? colorHovered : colorHoveredHidden); ImGui::PushStyleColor(ImGuiCol_HeaderHovered, isFrameVisible ? colorHovered : colorHoveredHidden);
ImGui::SetNextItemAllowOverlap(); ImGui::SetNextItemAllowOverlap();
ImGui::SetNextItemSelectionUserData((int)frameIndex); ImGui::SetNextItemSelectionUserData((int)i);
if (ImGui::Selectable("##Frame Button", true, ImGuiSelectableFlags_None, buttonSize)) if (ImGui::Selectable("##Frame Button", true, ImGuiSelectableFlags_None, buttonSize))
{ {
if (type == anm2::LAYER) if (type == anm2::LAYER)

View File

@@ -1,6 +1,6 @@
#include "resources.h" #include "resources.h"
#include <cstddef> #include <ranges>
#include "music.h" #include "music.h"
@@ -10,23 +10,14 @@ namespace anm2ed
{ {
Resources::Resources() Resources::Resources()
{ {
for (std::size_t i = 0; i < font::COUNT; ++i) for (auto [i, fontInfo] : std::views::enumerate(font::FONTS))
{
const auto& fontInfo = font::FONTS[i];
fonts[i] = Font((void*)fontInfo.data, fontInfo.length, font::SIZE); fonts[i] = Font((void*)fontInfo.data, fontInfo.length, font::SIZE);
}
for (std::size_t i = 0; i < icon::COUNT; ++i) for (auto [i, iconInfo] : std::views::enumerate(icon::ICONS))
{
const auto& iconInfo = icon::ICONS[i];
icons[i] = Texture(iconInfo.data, iconInfo.length, iconInfo.size); icons[i] = Texture(iconInfo.data, iconInfo.length, iconInfo.size);
}
for (std::size_t i = 0; i < shader::COUNT; ++i) for (auto [i, shaderInfo] : std::views::enumerate(shader::SHADERS))
{
const auto& shaderInfo = shader::SHADERS[i];
shaders[i] = Shader(shaderInfo.vertex, shaderInfo.fragment); shaders[i] = Shader(shaderInfo.vertex, shaderInfo.fragment);
}
}; };
resource::Audio& Resources::music_track() resource::Audio& Resources::music_track()

View File

@@ -15,7 +15,6 @@ namespace anm2ed
public: public:
resource::Font fonts[resource::font::COUNT]{}; resource::Font fonts[resource::font::COUNT]{};
resource::Texture icons[resource::icon::COUNT]{}; resource::Texture icons[resource::icon::COUNT]{};
resource::Texture backgroundTexture{};
resource::Shader shaders[resource::shader::COUNT]{}; resource::Shader shaders[resource::shader::COUNT]{};
resource::Audio music{}; resource::Audio music{};