...............................................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);
std::set<int> 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;
}

View File

@@ -1,8 +1,8 @@
#include "animation_preview.h"
#include <algorithm>
#include <cstddef>
#include <filesystem>
#include <ranges>
#include <glm/gtc/type_ptr.hpp>
@@ -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))
{

View File

@@ -1,6 +1,7 @@
#include "animations.h"
#include <cstddef>
#include <ranges>
#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())

View File

@@ -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)

View File

@@ -1,6 +1,6 @@
#include "resources.h"
#include <cstddef>
#include <ranges>
#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()

View File

@@ -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{};