From c11b404392933560a876e2f1c3cbdb62d4d15deb Mon Sep 17 00:00:00 2001 From: shweet Date: Mon, 9 Mar 2026 23:09:37 -0400 Subject: [PATCH] let's actually stage those changes... --- .vscode/launch.json | 6 +- .vscode/tasks.json | 12 +- CMakeLists.txt | 23 +- CMakeSettings.json | 6 +- src/anm2/animation.cpp | 10 +- src/anm2/animation.hpp | 2 +- src/anm2/animations.cpp | 4 +- src/anm2/animations.hpp | 2 +- src/anm2/anm2.cpp | 14 +- src/anm2/anm2.hpp | 8 +- src/anm2/anm2_animations.cpp | 4 +- src/anm2/anm2_events.cpp | 4 +- src/anm2/anm2_items.cpp | 8 +- src/anm2/anm2_layers.cpp | 4 +- src/anm2/anm2_nulls.cpp | 4 +- src/anm2/anm2_sounds.cpp | 8 +- src/anm2/anm2_spritesheets.cpp | 8 +- src/anm2/anm2_type.hpp | 4 +- src/anm2/content.cpp | 2 +- src/anm2/content.hpp | 10 +- src/anm2/event.cpp | 4 +- src/anm2/frame.cpp | 6 +- src/anm2/frame.hpp | 4 +- src/anm2/info.cpp | 4 +- src/anm2/item.cpp | 6 +- src/anm2/item.hpp | 2 +- src/anm2/layer.cpp | 4 +- src/anm2/null.cpp | 4 +- src/anm2/sound.cpp | 8 +- src/anm2/sound.hpp | 2 +- src/anm2/spritesheet.cpp | 10 +- src/anm2/spritesheet.hpp | 8 +- src/anm2_new/anm2.cpp | 603 ++++++++++++++++++ src/anm2_new/anm2.hpp | 90 +++ src/canvas.cpp | 4 +- src/canvas.hpp | 6 +- src/clipboard.cpp | 2 +- src/dialog.cpp | 10 +- src/document.cpp | 10 +- src/document.hpp | 2 +- src/framebuffer.cpp | 4 +- src/imgui/dockspace.cpp | 2 +- src/imgui/dockspace.hpp | 32 +- src/imgui/documents.cpp | 12 +- src/imgui/documents.hpp | 10 +- src/imgui/imgui_.cpp | 6 +- src/imgui/imgui_.hpp | 4 +- src/imgui/taskbar.cpp | 14 +- src/imgui/taskbar.hpp | 24 +- src/imgui/toast.cpp | 6 +- src/imgui/window/animation_preview.cpp | 31 +- src/imgui/window/animation_preview.hpp | 10 +- src/imgui/window/animations.cpp | 10 +- src/imgui/window/animations.hpp | 10 +- src/imgui/window/events.cpp | 10 +- src/imgui/window/events.hpp | 8 +- src/imgui/window/frame_properties.cpp | 8 +- src/imgui/window/frame_properties.hpp | 4 +- src/imgui/window/layers.cpp | 10 +- src/imgui/window/layers.hpp | 8 +- src/imgui/window/nulls.cpp | 10 +- src/imgui/window/nulls.hpp | 8 +- src/imgui/window/onionskin.cpp | 6 +- src/imgui/window/onionskin.hpp | 2 +- src/imgui/window/regions.cpp | 20 +- src/imgui/window/regions.hpp | 8 +- src/imgui/window/sounds.cpp | 10 +- src/imgui/window/sounds.hpp | 10 +- src/imgui/window/spritesheet_editor.cpp | 12 +- src/imgui/window/spritesheet_editor.hpp | 8 +- src/imgui/window/spritesheets.cpp | 14 +- src/imgui/window/spritesheets.hpp | 10 +- src/imgui/window/timeline.cpp | 8 +- src/imgui/window/timeline.hpp | 10 +- src/imgui/window/tools.cpp | 8 +- src/imgui/window/tools.hpp | 8 +- src/imgui/window/welcome.cpp | 6 +- src/imgui/window/welcome.hpp | 8 +- src/imgui/wizard/about.cpp | 4 +- src/imgui/wizard/about.hpp | 2 +- .../wizard/change_all_frame_properties.cpp | 4 +- .../wizard/change_all_frame_properties.hpp | 4 +- src/imgui/wizard/configure.cpp | 4 +- src/imgui/wizard/configure.hpp | 2 +- .../wizard/generate_animation_from_grid.cpp | 6 +- .../wizard/generate_animation_from_grid.hpp | 8 +- src/imgui/wizard/render_animation.cpp | 12 +- src/imgui/wizard/render_animation.hpp | 6 +- src/imgui_new/anm2_window.cpp | 16 + src/imgui_new/anm2_window.hpp | 12 + src/loader.cpp | 16 +- src/loader.hpp | 4 +- src/log.cpp | 6 +- src/main.cpp | 4 +- src/manager.cpp | 14 +- src/manager.hpp | 6 +- src/playback.cpp | 2 +- src/render.cpp | 30 +- src/render.hpp | 4 +- src/resource/audio.cpp | 4 +- src/resource/audio_stream.cpp | 2 +- src/resource/font.cpp | 2 +- src/resource/shader.cpp | 4 +- src/resource/strings.cpp | 2 +- src/resource/texture.cpp | 6 +- src/resources.cpp | 6 +- src/resources.hpp | 10 +- src/settings.cpp | 6 +- src/settings.hpp | 10 +- src/snapshots.cpp | 2 +- src/snapshots.hpp | 6 +- src/socket.cpp | 2 +- src/state.cpp | 34 +- src/state.hpp | 2 +- src/storage.cpp | 2 +- src/storage.hpp | 2 +- src/tool.hpp | 6 +- src/types.hpp | 2 +- src/util/file_.cpp | 2 +- src/util/math_.cpp | 4 +- src/util/path_.cpp | 2 +- src/util/process_.cpp | 2 +- src/util/sdl.cpp | 4 +- src/util/string_.cpp | 2 +- src/util/time_.cpp | 2 +- src/util/working_directory.cpp | 6 +- src/util/xml_.cpp | 6 +- 127 files changed, 1200 insertions(+), 427 deletions(-) create mode 100644 src/anm2_new/anm2.cpp create mode 100644 src/anm2_new/anm2.hpp create mode 100644 src/imgui_new/anm2_window.cpp create mode 100644 src/imgui_new/anm2_window.hpp diff --git a/.vscode/launch.json b/.vscode/launch.json index dd8dffe..ad226b0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "name": "Debug", "type": "cppdbg", "request": "launch", - "program": "${workspaceFolder}/build/anm2ed", + "program": "${workspaceFolder}/out/build/linux-debug/bin/anm2ed", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", @@ -28,7 +28,7 @@ "name": "Release", "type": "cppdbg", "request": "launch", - "program": "${workspaceFolder}/build-release/anm2ed", + "program": "${workspaceFolder}/out/build/linux-release/bin/anm2ed", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", @@ -48,4 +48,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 98e27be..fb2d21f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,9 +2,9 @@ "version": "2.0.0", "tasks": [ { - "label": "build", + "label": "build-debug", "type": "shell", - "command": "cmake --build build --target anm2ed", + "command": "cmake -S . -B out/build/linux-debug -DCMAKE_BUILD_TYPE=Debug && cmake --build out/build/linux-debug --target anm2ed", "group": { "kind": "build", "isDefault": true @@ -16,11 +16,17 @@ { "label": "build-release", "type": "shell", - "command": "cmake -S . -B build-release -DCMAKE_BUILD_TYPE=Release && cmake --build build-release --target anm2ed", + "command": "cmake -S . -B out/build/linux-release -DCMAKE_BUILD_TYPE=Release && cmake --build out/build/linux-release --target anm2ed", "group": "build", "problemMatcher": [ "$gcc" ] + }, + { + "label": "build", + "dependsOn": "build-debug", + "group": "build", + "problemMatcher": [] } ] } diff --git a/CMakeLists.txt b/CMakeLists.txt index e961728..74eda3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,23 +87,30 @@ set(TINYXML2_SRC external/tinyxml2/tinyxml2.cpp) file(GLOB PROJECT_SRC CONFIGURE_DEPENDS src/anm2/*.cpp - src/anm2/*.h + src/anm2/*.hpp src/resource/*.cpp - src/resource/*.h + src/resource/*.hpp src/imgui/*.cpp - src/imgui/*.h + src/imgui/*.hpp src/imgui/window/*.cpp - src/imgui/window/*.h + src/imgui/window/*.hpp src/imgui/wizard/*.cpp - src/imgui/wizard/*.h + src/imgui/wizard/*.hpp src/util/*.cpp - src/util/*.h + src/util/*.hpp src/window/*.cpp - src/window/*.h + src/window/*.hpp src/*.cpp - src/*.h) + src/*.hpp) add_executable(${PROJECT_NAME} ${GLAD_SRC} ${IMGUI_SRC} ${TINYXML2_SRC} ${PROJECT_SRC}) +set_target_properties( + ${PROJECT_NAME} + PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/bin") target_compile_definitions(${PROJECT_NAME} PRIVATE IMGUI_DISABLE_OBSOLETE_FUNCTIONS IMGUI_DEBUG_PARANOID IMGUI_ENABLE_DOCKING) diff --git a/CMakeSettings.json b/CMakeSettings.json index ec980c3..0694331 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,7 +1,7 @@ { "configurations": [ { - "name": "x64-Debug", + "name": "windows-debug", "generator": "Ninja", "configurationType": "Debug", "inheritEnvironments": [ @@ -12,7 +12,7 @@ "cmakeCommandArgs": "-DCMAKE_BUILD_TYPE=\"Debug\"" }, { - "name": "x64-Release", + "name": "windows-release", "generator": "Ninja", "configurationType": "Release", "inheritEnvironments": [ @@ -23,4 +23,4 @@ "cmakeCommandArgs": "-DCMAKE_BUILD_TYPE=\"Release\"" } ] -} \ No newline at end of file +} diff --git a/src/anm2/animation.cpp b/src/anm2/animation.cpp index 5dd221d..8808703 100644 --- a/src/anm2/animation.cpp +++ b/src/anm2/animation.cpp @@ -1,9 +1,9 @@ -#include "animation.h" +#include "animation.hpp" -#include "map_.h" -#include "math_.h" -#include "unordered_map_.h" -#include "xml_.h" +#include "map_.hpp" +#include "math_.hpp" +#include "unordered_map_.hpp" +#include "xml_.hpp" #include using namespace anm2ed::util; diff --git a/src/anm2/animation.hpp b/src/anm2/animation.hpp index 9725a90..727f73e 100644 --- a/src/anm2/animation.hpp +++ b/src/anm2/animation.hpp @@ -3,7 +3,7 @@ #include #include -#include "item.h" +#include "item.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2/animations.cpp b/src/anm2/animations.cpp index 10d9208..ff698e5 100644 --- a/src/anm2/animations.cpp +++ b/src/anm2/animations.cpp @@ -1,6 +1,6 @@ -#include "animations.h" +#include "animations.hpp" -#include "xml_.h" +#include "xml_.hpp" using namespace tinyxml2; using namespace anm2ed::types; diff --git a/src/anm2/animations.hpp b/src/anm2/animations.hpp index 2db0454..29bf0f0 100644 --- a/src/anm2/animations.hpp +++ b/src/anm2/animations.hpp @@ -1,6 +1,6 @@ #pragma once -#include "animation.h" +#include "animation.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2/anm2.cpp b/src/anm2/anm2.cpp index 9c80f54..c9e9585 100644 --- a/src/anm2/anm2.cpp +++ b/src/anm2/anm2.cpp @@ -1,15 +1,15 @@ -#include "anm2.h" +#include "anm2.hpp" #include #include #include -#include "file_.h" -#include "map_.h" -#include "time_.h" -#include "vector_.h" -#include "working_directory.h" -#include "xml_.h" +#include "file_.hpp" +#include "map_.hpp" +#include "time_.hpp" +#include "vector_.hpp" +#include "working_directory.hpp" +#include "xml_.hpp" using namespace tinyxml2; using namespace anm2ed::types; diff --git a/src/anm2/anm2.hpp b/src/anm2/anm2.hpp index e931450..3ffe3ff 100644 --- a/src/anm2/anm2.hpp +++ b/src/anm2/anm2.hpp @@ -4,11 +4,11 @@ #include #include -#include "types.h" +#include "types.hpp" -#include "animations.h" -#include "content.h" -#include "info.h" +#include "animations.hpp" +#include "content.hpp" +#include "info.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2/anm2_animations.cpp b/src/anm2/anm2_animations.cpp index 4920d5f..1cfb030 100644 --- a/src/anm2/anm2_animations.cpp +++ b/src/anm2/anm2_animations.cpp @@ -1,6 +1,6 @@ -#include "anm2.h" +#include "anm2.hpp" -#include "vector_.h" +#include "vector_.hpp" using namespace anm2ed::util; using namespace anm2ed::types; diff --git a/src/anm2/anm2_events.cpp b/src/anm2/anm2_events.cpp index d7ae12c..13a7300 100644 --- a/src/anm2/anm2_events.cpp +++ b/src/anm2/anm2_events.cpp @@ -1,8 +1,8 @@ -#include "anm2.h" +#include "anm2.hpp" #include -#include "map_.h" +#include "map_.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/anm2/anm2_items.cpp b/src/anm2/anm2_items.cpp index aed2f7b..b62cb87 100644 --- a/src/anm2/anm2_items.cpp +++ b/src/anm2/anm2_items.cpp @@ -1,8 +1,8 @@ -#include "anm2.h" +#include "anm2.hpp" -#include "map_.h" -#include "types.h" -#include "unordered_map_.h" +#include "map_.hpp" +#include "types.hpp" +#include "unordered_map_.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/anm2/anm2_layers.cpp b/src/anm2/anm2_layers.cpp index 14ec4a1..1490abf 100644 --- a/src/anm2/anm2_layers.cpp +++ b/src/anm2/anm2_layers.cpp @@ -1,8 +1,8 @@ -#include "anm2.h" +#include "anm2.hpp" #include -#include "map_.h" +#include "map_.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/anm2/anm2_nulls.cpp b/src/anm2/anm2_nulls.cpp index 126c7a9..57ae2e0 100644 --- a/src/anm2/anm2_nulls.cpp +++ b/src/anm2/anm2_nulls.cpp @@ -1,8 +1,8 @@ -#include "anm2.h" +#include "anm2.hpp" #include -#include "map_.h" +#include "map_.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/anm2/anm2_sounds.cpp b/src/anm2/anm2_sounds.cpp index 5d7e146..425a457 100644 --- a/src/anm2/anm2_sounds.cpp +++ b/src/anm2/anm2_sounds.cpp @@ -1,8 +1,8 @@ -#include "anm2.h" +#include "anm2.hpp" -#include "map_.h" -#include "path_.h" -#include "working_directory.h" +#include "map_.hpp" +#include "path_.hpp" +#include "working_directory.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/anm2/anm2_spritesheets.cpp b/src/anm2/anm2_spritesheets.cpp index 45d1fff..e4b55ae 100644 --- a/src/anm2/anm2_spritesheets.cpp +++ b/src/anm2/anm2_spritesheets.cpp @@ -1,4 +1,4 @@ -#include "anm2.h" +#include "anm2.hpp" #include #include @@ -8,9 +8,9 @@ #include #include -#include "map_.h" -#include "path_.h" -#include "working_directory.h" +#include "map_.hpp" +#include "path_.hpp" +#include "working_directory.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/anm2/anm2_type.hpp b/src/anm2/anm2_type.hpp index 7ac3615..d80ced3 100644 --- a/src/anm2/anm2_type.hpp +++ b/src/anm2/anm2_type.hpp @@ -1,7 +1,7 @@ #pragma once -#include "icon.h" -#include "strings.h" +#include "icon.hpp" +#include "strings.hpp" #include #include diff --git a/src/anm2/content.cpp b/src/anm2/content.cpp index 6d0e25a..cd5f0ac 100644 --- a/src/anm2/content.cpp +++ b/src/anm2/content.cpp @@ -1,4 +1,4 @@ -#include "content.h" +#include "content.hpp" using namespace tinyxml2; diff --git a/src/anm2/content.hpp b/src/anm2/content.hpp index 551aa44..17094bf 100644 --- a/src/anm2/content.hpp +++ b/src/anm2/content.hpp @@ -2,11 +2,11 @@ #include -#include "event.h" -#include "layer.h" -#include "null.h" -#include "sound.h" -#include "spritesheet.h" +#include "event.hpp" +#include "layer.hpp" +#include "null.hpp" +#include "sound.hpp" +#include "spritesheet.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2/event.cpp b/src/anm2/event.cpp index 7427897..cfb9f03 100644 --- a/src/anm2/event.cpp +++ b/src/anm2/event.cpp @@ -1,6 +1,6 @@ -#include "event.h" +#include "event.hpp" -#include "xml_.h" +#include "xml_.hpp" using namespace anm2ed::util; using namespace tinyxml2; diff --git a/src/anm2/frame.cpp b/src/anm2/frame.cpp index 736c882..7295b97 100644 --- a/src/anm2/frame.cpp +++ b/src/anm2/frame.cpp @@ -1,7 +1,7 @@ -#include "frame.h" +#include "frame.hpp" -#include "math_.h" -#include "xml_.h" +#include "math_.hpp" +#include "xml_.hpp" using namespace anm2ed::util; using namespace tinyxml2; diff --git a/src/anm2/frame.hpp b/src/anm2/frame.hpp index c642296..bb33a1f 100644 --- a/src/anm2/frame.hpp +++ b/src/anm2/frame.hpp @@ -4,8 +4,8 @@ #include #include -#include "anm2_type.h" -#include "types.h" +#include "anm2_type.hpp" +#include "types.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2/info.cpp b/src/anm2/info.cpp index 2ea0433..d137288 100644 --- a/src/anm2/info.cpp +++ b/src/anm2/info.cpp @@ -1,6 +1,6 @@ -#include "info.h" +#include "info.hpp" -#include "xml_.h" +#include "xml_.hpp" using namespace anm2ed::util; using namespace tinyxml2; diff --git a/src/anm2/item.cpp b/src/anm2/item.cpp index 6c1afd7..08ba283 100644 --- a/src/anm2/item.cpp +++ b/src/anm2/item.cpp @@ -1,9 +1,9 @@ -#include "item.h" +#include "item.hpp" #include #include -#include "vector_.h" -#include "xml_.h" +#include "vector_.hpp" +#include "xml_.hpp" using namespace anm2ed::util; using namespace tinyxml2; diff --git a/src/anm2/item.hpp b/src/anm2/item.hpp index 5e1e082..0ca0a12 100644 --- a/src/anm2/item.hpp +++ b/src/anm2/item.hpp @@ -3,7 +3,7 @@ #include #include -#include "frame.h" +#include "frame.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2/layer.cpp b/src/anm2/layer.cpp index 5dbe7ba..3c29702 100644 --- a/src/anm2/layer.cpp +++ b/src/anm2/layer.cpp @@ -1,6 +1,6 @@ -#include "layer.h" +#include "layer.hpp" -#include "xml_.h" +#include "xml_.hpp" using namespace anm2ed::util; using namespace tinyxml2; diff --git a/src/anm2/null.cpp b/src/anm2/null.cpp index 272228a..6873424 100644 --- a/src/anm2/null.cpp +++ b/src/anm2/null.cpp @@ -1,6 +1,6 @@ -#include "null.h" +#include "null.hpp" -#include "xml_.h" +#include "xml_.hpp" using namespace anm2ed::util; using namespace tinyxml2; diff --git a/src/anm2/sound.cpp b/src/anm2/sound.cpp index 95c3323..b90ef4f 100644 --- a/src/anm2/sound.cpp +++ b/src/anm2/sound.cpp @@ -1,8 +1,8 @@ -#include "sound.h" +#include "sound.hpp" -#include "path_.h" -#include "working_directory.h" -#include "xml_.h" +#include "path_.hpp" +#include "working_directory.hpp" +#include "xml_.hpp" using namespace anm2ed::resource; using namespace anm2ed::util; diff --git a/src/anm2/sound.hpp b/src/anm2/sound.hpp index 4a55e33..3271b58 100644 --- a/src/anm2/sound.hpp +++ b/src/anm2/sound.hpp @@ -3,7 +3,7 @@ #include #include -#include "audio.h" +#include "audio.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2/spritesheet.cpp b/src/anm2/spritesheet.cpp index bd9a0c5..5c9034f 100644 --- a/src/anm2/spritesheet.cpp +++ b/src/anm2/spritesheet.cpp @@ -1,4 +1,4 @@ -#include "spritesheet.h" +#include "spritesheet.hpp" #include #include @@ -6,10 +6,10 @@ #include #include -#include "map_.h" -#include "path_.h" -#include "working_directory.h" -#include "xml_.h" +#include "map_.hpp" +#include "path_.hpp" +#include "working_directory.hpp" +#include "xml_.hpp" using namespace anm2ed::resource; using namespace anm2ed::util; diff --git a/src/anm2/spritesheet.hpp b/src/anm2/spritesheet.hpp index b51ecf3..4a906f1 100644 --- a/src/anm2/spritesheet.hpp +++ b/src/anm2/spritesheet.hpp @@ -8,10 +8,10 @@ #include #include -#include "texture.h" -#include "anm2_type.h" -#include "types.h" -#include "origin.h" +#include "texture.hpp" +#include "anm2_type.hpp" +#include "types.hpp" +#include "origin.hpp" namespace anm2ed::anm2 { diff --git a/src/anm2_new/anm2.cpp b/src/anm2_new/anm2.cpp new file mode 100644 index 0000000..ce237dd --- /dev/null +++ b/src/anm2_new/anm2.cpp @@ -0,0 +1,603 @@ +#include "anm2.hpp" + +#include +#include +#include +#include + +#include "../log.hpp" +#include "../util/path_.hpp" +#include "../util/working_directory.hpp" +#include "../util/xml_.hpp" + +using namespace tinyxml2; +using namespace anm2ed::util; + +namespace anm2ed::resource::anm2_new +{ + Anm2::Item::Item(XMLElement* element, Type _type) + { + if (!element) return; + + type = _type; + + auto isFrameOwnerType = + _type == ROOT_ANIMATION || _type == LAYER_ANIMATION || _type == NULL_ANIMATION || _type == TRIGGERS; + auto isFrameLikeElement = + element->Name() && (std::strcmp(element->Name(), "Frame") == 0 || std::strcmp(element->Name(), "Trigger") == 0); + + if (isFrameOwnerType && isFrameLikeElement) + { + ownerType = _type; + type = _type == TRIGGERS ? TRIGGER : FRAME; + + switch (_type) + { + case ROOT_ANIMATION: + case NULL_ANIMATION: + element->QueryFloatAttribute("XPosition", &position.x); + element->QueryFloatAttribute("YPosition", &position.y); + element->QueryFloatAttribute("XScale", &scale.x); + element->QueryFloatAttribute("YScale", &scale.y); + element->QueryIntAttribute("Delay", &duration); + element->QueryBoolAttribute("Visible", &isVisible); + xml::query_color_attribute(element, "RedTint", tint.r); + xml::query_color_attribute(element, "GreenTint", tint.g); + xml::query_color_attribute(element, "BlueTint", tint.b); + xml::query_color_attribute(element, "AlphaTint", tint.a); + xml::query_color_attribute(element, "RedOffset", colorOffset.r); + xml::query_color_attribute(element, "GreenOffset", colorOffset.g); + xml::query_color_attribute(element, "BlueOffset", colorOffset.b); + element->QueryFloatAttribute("Rotation", &rotation); + element->QueryBoolAttribute("Interpolated", &isInterpolated); + break; + case LAYER_ANIMATION: + element->QueryIntAttribute("RegionId", ®ionID); + element->QueryFloatAttribute("XPosition", &position.x); + element->QueryFloatAttribute("YPosition", &position.y); + element->QueryFloatAttribute("XPivot", &pivot.x); + element->QueryFloatAttribute("YPivot", &pivot.y); + element->QueryFloatAttribute("XCrop", &crop.x); + element->QueryFloatAttribute("YCrop", &crop.y); + element->QueryFloatAttribute("Width", &size.x); + element->QueryFloatAttribute("Height", &size.y); + element->QueryFloatAttribute("XScale", &scale.x); + element->QueryFloatAttribute("YScale", &scale.y); + element->QueryIntAttribute("Delay", &duration); + element->QueryBoolAttribute("Visible", &isVisible); + xml::query_color_attribute(element, "RedTint", tint.r); + xml::query_color_attribute(element, "GreenTint", tint.g); + xml::query_color_attribute(element, "BlueTint", tint.b); + xml::query_color_attribute(element, "AlphaTint", tint.a); + xml::query_color_attribute(element, "RedOffset", colorOffset.r); + xml::query_color_attribute(element, "GreenOffset", colorOffset.g); + xml::query_color_attribute(element, "BlueOffset", colorOffset.b); + element->QueryFloatAttribute("Rotation", &rotation); + element->QueryBoolAttribute("Interpolated", &isInterpolated); + break; + case TRIGGERS: + { + element->QueryIntAttribute("EventId", &eventID); + element->QueryIntAttribute("AtFrame", &atFrame); + int soundID{}; + if (element->QueryIntAttribute("SoundId", &soundID) == XML_SUCCESS) soundIDs.push_back(soundID); + for (auto* child = element->FirstChildElement("Sound"); child; child = child->NextSiblingElement("Sound")) + if (child->QueryIntAttribute("Id", &soundID) == XML_SUCCESS) soundIDs.push_back(soundID); + break; + } + default: + break; + } + + return; + } + + switch (_type) + { + case INFO: + xml::query_string_attribute(element, "CreatedBy", &createdBy); + xml::query_string_attribute(element, "CreatedOn", &createdOn); + element->QueryIntAttribute("Fps", &fps); + element->QueryIntAttribute("Version", &version); + break; + case SPRITESHEET: + element->QueryIntAttribute("Id", &id); + xml::query_path_attribute(element, "Path", &path); + path = util::path::lower_case_backslash_handle(path); + texture = Texture(path); + break; + case REGION: + { + element->QueryIntAttribute("Id", &id); + xml::query_string_attribute(element, "Name", &name); + element->QueryFloatAttribute("XCrop", &crop.x); + element->QueryFloatAttribute("YCrop", &crop.y); + element->QueryFloatAttribute("Width", &size.x); + element->QueryFloatAttribute("Height", &size.y); + + auto* origin = element->Attribute("Origin"); + if (origin && std::string(origin) == "TopLeft") + pivot = {}; + else if (origin && std::string(origin) == "Center") + pivot = glm::vec2((int)(size.x / 2.0f), (int)(size.y / 2.0f)); + else + { + element->QueryFloatAttribute("XPivot", &pivot.x); + element->QueryFloatAttribute("YPivot", &pivot.y); + } + break; + } + case LAYER: + element->QueryIntAttribute("Id", &id); + xml::query_string_attribute(element, "Name", &name); + element->QueryIntAttribute("SpritesheetId", &spritesheetID); + break; + case NULL_: + element->QueryIntAttribute("Id", &id); + xml::query_string_attribute(element, "Name", &name); + element->QueryBoolAttribute("ShowRect", &isShowRect); + break; + case EVENT: + element->QueryIntAttribute("Id", &id); + xml::query_string_attribute(element, "Name", &name); + break; + case SOUND: + element->QueryIntAttribute("Id", &id); + xml::query_path_attribute(element, "Path", &path); + path = util::path::lower_case_backslash_handle(path); + sound = Audio(path); + break; + case ANIMATION: + xml::query_string_attribute(element, "Name", &name); + element->QueryIntAttribute("FrameNum", &frameNum); + element->QueryBoolAttribute("Loop", &isLoop); + break; + case ROOT_ANIMATION: + case TRIGGERS: + break; + case LAYER_ANIMATION: + element->QueryIntAttribute("LayerId", &itemID); + element->QueryBoolAttribute("Visible", &isVisible); + break; + case NULL_ANIMATION: + element->QueryIntAttribute("NullId", &itemID); + element->QueryBoolAttribute("Visible", &isVisible); + break; + case FRAME: + case TRIGGER: + default: + break; + } + } + + XMLElement* Anm2::Item::to_element(XMLDocument& document) const + { + switch (type) + { + case INFO: + { + auto* element = document.NewElement("Info"); + element->SetAttribute("CreatedBy", createdBy.c_str()); + element->SetAttribute("CreatedOn", createdOn.c_str()); + element->SetAttribute("Fps", fps); + element->SetAttribute("Version", version); + return element; + } + case SPRITESHEET: + { + auto* element = document.NewElement("Spritesheet"); + element->SetAttribute("Id", id); + auto pathString = util::path::to_utf8(path); + element->SetAttribute("Path", pathString.c_str()); + return element; + } + case REGION: + { + auto* element = document.NewElement("Region"); + element->SetAttribute("Id", id); + element->SetAttribute("Name", name.c_str()); + element->SetAttribute("XCrop", crop.x); + element->SetAttribute("YCrop", crop.y); + element->SetAttribute("Width", size.x); + element->SetAttribute("Height", size.y); + element->SetAttribute("XPivot", pivot.x); + element->SetAttribute("YPivot", pivot.y); + return element; + } + case LAYER: + { + auto* element = document.NewElement("Layer"); + element->SetAttribute("Id", id); + element->SetAttribute("Name", name.c_str()); + element->SetAttribute("SpritesheetId", spritesheetID); + return element; + } + case NULL_: + { + auto* element = document.NewElement("Null"); + element->SetAttribute("Id", id); + element->SetAttribute("Name", name.c_str()); + if (isShowRect) element->SetAttribute("ShowRect", isShowRect); + return element; + } + case EVENT: + { + auto* element = document.NewElement("Event"); + element->SetAttribute("Id", id); + element->SetAttribute("Name", name.c_str()); + return element; + } + case SOUND: + { + auto* element = document.NewElement("Sound"); + element->SetAttribute("Id", id); + auto pathString = util::path::to_utf8(path); + element->SetAttribute("Path", pathString.c_str()); + return element; + } + case ANIMATION: + { + auto* element = document.NewElement("Animation"); + element->SetAttribute("Name", name.c_str()); + element->SetAttribute("FrameNum", frameNum); + element->SetAttribute("Loop", isLoop); + return element; + } + case ROOT_ANIMATION: + return document.NewElement("RootAnimation"); + case LAYER_ANIMATION: + { + auto* element = document.NewElement("LayerAnimation"); + element->SetAttribute("LayerId", itemID); + element->SetAttribute("Visible", isVisible); + return element; + } + case NULL_ANIMATION: + { + auto* element = document.NewElement("NullAnimation"); + element->SetAttribute("NullId", itemID); + element->SetAttribute("Visible", isVisible); + return element; + } + case TRIGGERS: + return document.NewElement("Triggers"); + case TRIGGER: + { + auto* element = document.NewElement("Trigger"); + if (eventID != -1) element->SetAttribute("EventId", eventID); + for (auto soundID : soundIDs) + { + if (soundID == -1) continue; + auto* soundElement = element->InsertNewChildElement("Sound"); + soundElement->SetAttribute("Id", soundID); + } + element->SetAttribute("AtFrame", atFrame); + return element; + } + case FRAME: + { + auto* element = document.NewElement("Frame"); + + if (ownerType == LAYER_ANIMATION && regionID != -1) element->SetAttribute("RegionId", regionID); + element->SetAttribute("XPosition", position.x); + element->SetAttribute("YPosition", position.y); + + if (ownerType == LAYER_ANIMATION) + { + element->SetAttribute("XPivot", pivot.x); + element->SetAttribute("YPivot", pivot.y); + element->SetAttribute("XCrop", crop.x); + element->SetAttribute("YCrop", crop.y); + element->SetAttribute("Width", size.x); + element->SetAttribute("Height", size.y); + } + + element->SetAttribute("XScale", scale.x); + element->SetAttribute("YScale", scale.y); + element->SetAttribute("Delay", duration); + element->SetAttribute("Visible", isVisible); + element->SetAttribute("RedTint", (int)glm::clamp(tint.r * 255.0f, 0.0f, 255.0f)); + element->SetAttribute("GreenTint", (int)glm::clamp(tint.g * 255.0f, 0.0f, 255.0f)); + element->SetAttribute("BlueTint", (int)glm::clamp(tint.b * 255.0f, 0.0f, 255.0f)); + element->SetAttribute("AlphaTint", (int)glm::clamp(tint.a * 255.0f, 0.0f, 255.0f)); + element->SetAttribute("RedOffset", (int)glm::clamp(colorOffset.r * 255.0f, 0.0f, 255.0f)); + element->SetAttribute("GreenOffset", (int)glm::clamp(colorOffset.g * 255.0f, 0.0f, 255.0f)); + element->SetAttribute("BlueOffset", (int)glm::clamp(colorOffset.b * 255.0f, 0.0f, 255.0f)); + element->SetAttribute("Rotation", rotation); + element->SetAttribute("Interpolated", isInterpolated); + + return element; + } + default: + break; + } + + return document.NewElement("Item"); + } + + std::string Anm2::Item::to_string() const + { + XMLDocument document; + document.InsertEndChild(to_element(document)); + return xml::document_to_string(document); + } + + Anm2::Anm2(const std::filesystem::path& path) + { + XMLDocument document; + auto pathString = util::path::to_utf8(path); + + if (document.LoadFile(pathString.c_str()) != XML_SUCCESS) + { + logger.error(std::format("Failed to initialize anm2: {} ({})", pathString, document.ErrorStr())); + isValid = false; + return; + } + + WorkingDirectory workingDirectory(path, WorkingDirectory::FILE); + + this->path = path; + isValid = true; + + auto item_add = [&](Item item) { items.emplace_back(std::move(item)); }; + + if (auto* root = document.RootElement()) + { + if (auto* infoElement = root->FirstChildElement("Info")) item_add(Item(infoElement, INFO)); + + if (auto* contentElement = root->FirstChildElement("Content")) + { + if (auto* spritesheetsElement = contentElement->FirstChildElement("Spritesheets")) + { + for (auto* child = spritesheetsElement->FirstChildElement("Spritesheet"); child; + child = child->NextSiblingElement("Spritesheet")) + { + auto spritesheet = Item(child, SPRITESHEET); + auto spritesheetID = spritesheet.id; + item_add(spritesheet); + + for (auto* regionChild = child->FirstChildElement("Region"); regionChild; + regionChild = regionChild->NextSiblingElement("Region")) + { + auto region = Item(regionChild, REGION); + region.itemID = spritesheetID; + item_add(region); + } + } + } + + if (auto* layersElement = contentElement->FirstChildElement("Layers")) + for (auto* child = layersElement->FirstChildElement("Layer"); child; + child = child->NextSiblingElement("Layer")) + item_add(Item(child, LAYER)); + + if (auto* nullsElement = contentElement->FirstChildElement("Nulls")) + for (auto* child = nullsElement->FirstChildElement("Null"); child; child = child->NextSiblingElement("Null")) + item_add(Item(child, NULL_)); + + if (auto* eventsElement = contentElement->FirstChildElement("Events")) + for (auto* child = eventsElement->FirstChildElement("Event"); child; + child = child->NextSiblingElement("Event")) + item_add(Item(child, EVENT)); + + if (auto* soundsElement = contentElement->FirstChildElement("Sounds")) + for (auto* child = soundsElement->FirstChildElement("Sound"); child; + child = child->NextSiblingElement("Sound")) + item_add(Item(child, SOUND)); + } + + if (auto* animationsElement = root->FirstChildElement("Animations")) + { + int animationIndex = 0; + for (auto* animationElement = animationsElement->FirstChildElement("Animation"); animationElement; + animationElement = animationElement->NextSiblingElement("Animation")) + { + auto animation = Item(animationElement, ANIMATION); + animation.id = animationIndex++; + item_add(animation); + + if (auto* rootAnimationElement = animationElement->FirstChildElement("RootAnimation")) + { + Item rootAnimation{}; + rootAnimation.type = ROOT_ANIMATION; + rootAnimation.animationID = animation.id; + item_add(rootAnimation); + + for (auto* frameElement = rootAnimationElement->FirstChildElement("Frame"); frameElement; + frameElement = frameElement->NextSiblingElement("Frame")) + { + auto frame = Item(frameElement, ROOT_ANIMATION); + frame.animationID = animation.id; + frame.ownerID = -1; + item_add(frame); + } + } + + if (auto* layerAnimationsElement = animationElement->FirstChildElement("LayerAnimations")) + { + for (auto* layerAnimationElement = layerAnimationsElement->FirstChildElement("LayerAnimation"); + layerAnimationElement; + layerAnimationElement = layerAnimationElement->NextSiblingElement("LayerAnimation")) + { + auto layerAnimation = Item(layerAnimationElement, LAYER_ANIMATION); + layerAnimation.animationID = animation.id; + item_add(layerAnimation); + + for (auto* frameElement = layerAnimationElement->FirstChildElement("Frame"); frameElement; + frameElement = frameElement->NextSiblingElement("Frame")) + { + auto frame = Item(frameElement, LAYER_ANIMATION); + frame.animationID = animation.id; + frame.ownerID = layerAnimation.itemID; + item_add(frame); + } + } + } + + if (auto* nullAnimationsElement = animationElement->FirstChildElement("NullAnimations")) + { + for (auto* nullAnimationElement = nullAnimationsElement->FirstChildElement("NullAnimation"); + nullAnimationElement; nullAnimationElement = nullAnimationElement->NextSiblingElement("NullAnimation")) + { + auto nullAnimation = Item(nullAnimationElement, NULL_ANIMATION); + nullAnimation.animationID = animation.id; + item_add(nullAnimation); + + for (auto* frameElement = nullAnimationElement->FirstChildElement("Frame"); frameElement; + frameElement = frameElement->NextSiblingElement("Frame")) + { + auto frame = Item(frameElement, NULL_ANIMATION); + frame.animationID = animation.id; + frame.ownerID = nullAnimation.itemID; + item_add(frame); + } + } + } + + if (auto* triggersElement = animationElement->FirstChildElement("Triggers")) + { + Item triggers{}; + triggers.type = TRIGGERS; + triggers.animationID = animation.id; + item_add(triggers); + + for (auto* triggerElement = triggersElement->FirstChildElement("Trigger"); triggerElement; + triggerElement = triggerElement->NextSiblingElement("Trigger")) + { + auto trigger = Item(triggerElement, TRIGGERS); + trigger.animationID = animation.id; + trigger.ownerID = -1; + item_add(trigger); + } + } + } + } + } + + logger.info(std::format("Initialized anm2: {}", pathString)); + } + + XMLElement* Anm2::to_element(XMLDocument& document) const + { + auto* root = document.NewElement("AnimatedActor"); + auto add_frames = [&](XMLElement* parent, Type ownerType, int animationID, int ownerID) + { + for (auto& item : items) + { + if (item.type != FRAME && item.type != TRIGGER) continue; + if (item.ownerType != ownerType) continue; + if (item.animationID != animationID) continue; + if (item.ownerID != ownerID) continue; + parent->InsertEndChild(item.to_element(document)); + } + }; + + const Item* info = nullptr; + for (auto& item : items) + if (item.type == INFO) + { + info = &item; + break; + } + if (info) root->InsertEndChild(info->to_element(document)); + + auto* contentElement = document.NewElement("Content"); + auto* spritesheetsElement = document.NewElement("Spritesheets"); + auto* layersElement = document.NewElement("Layers"); + auto* nullsElement = document.NewElement("Nulls"); + auto* eventsElement = document.NewElement("Events"); + auto* soundsElement = document.NewElement("Sounds"); + + for (auto& item : items) + { + if (item.type != SPRITESHEET) continue; + auto* spritesheetElement = item.to_element(document); + for (auto& region : items) + if (region.type == REGION && region.itemID == item.id) + spritesheetElement->InsertEndChild(region.to_element(document)); + spritesheetsElement->InsertEndChild(spritesheetElement); + } + + for (auto& item : items) + if (item.type == LAYER) layersElement->InsertEndChild(item.to_element(document)); + + for (auto& item : items) + if (item.type == NULL_) nullsElement->InsertEndChild(item.to_element(document)); + + for (auto& item : items) + if (item.type == EVENT) eventsElement->InsertEndChild(item.to_element(document)); + + for (auto& item : items) + if (item.type == SOUND) soundsElement->InsertEndChild(item.to_element(document)); + + contentElement->InsertEndChild(spritesheetsElement); + contentElement->InsertEndChild(layersElement); + contentElement->InsertEndChild(nullsElement); + contentElement->InsertEndChild(eventsElement); + if (soundsElement->FirstChildElement("Sound")) contentElement->InsertEndChild(soundsElement); + root->InsertEndChild(contentElement); + + auto* animationsElement = document.NewElement("Animations"); + + for (auto& animation : items) + { + if (animation.type != ANIMATION) continue; + auto* animationElement = animation.to_element(document); + + auto* rootAnimationElement = document.NewElement("RootAnimation"); + add_frames(rootAnimationElement, ROOT_ANIMATION, animation.id, -1); + animationElement->InsertEndChild(rootAnimationElement); + + auto* layerAnimationsElement = document.NewElement("LayerAnimations"); + for (auto& layerAnimation : items) + { + if (layerAnimation.type != LAYER_ANIMATION || layerAnimation.animationID != animation.id) continue; + auto* layerAnimationElement = layerAnimation.to_element(document); + add_frames(layerAnimationElement, LAYER_ANIMATION, animation.id, layerAnimation.itemID); + layerAnimationsElement->InsertEndChild(layerAnimationElement); + } + animationElement->InsertEndChild(layerAnimationsElement); + + auto* nullAnimationsElement = document.NewElement("NullAnimations"); + for (auto& nullAnimation : items) + { + if (nullAnimation.type != NULL_ANIMATION || nullAnimation.animationID != animation.id) continue; + auto* nullAnimationElement = nullAnimation.to_element(document); + add_frames(nullAnimationElement, NULL_ANIMATION, animation.id, nullAnimation.itemID); + nullAnimationsElement->InsertEndChild(nullAnimationElement); + } + animationElement->InsertEndChild(nullAnimationsElement); + + auto* triggersElement = document.NewElement("Triggers"); + add_frames(triggersElement, TRIGGERS, animation.id, -1); + animationElement->InsertEndChild(triggersElement); + + animationsElement->InsertEndChild(animationElement); + } + + root->InsertEndChild(animationsElement); + return root; + } + + bool Anm2::serialize(const std::filesystem::path& path, std::string* errorString) const + { + XMLDocument document; + document.InsertEndChild(to_element(document)); + + auto pathString = util::path::to_utf8(path); + if (document.SaveFile(pathString.c_str()) != XML_SUCCESS) + { + if (errorString) *errorString = document.ErrorStr(); + return false; + } + + return true; + } + + std::string Anm2::to_string() const + { + XMLDocument document; + document.InsertEndChild(to_element(document)); + return xml::document_to_string(document); + } +} diff --git a/src/anm2_new/anm2.hpp b/src/anm2_new/anm2.hpp new file mode 100644 index 0000000..ace6406 --- /dev/null +++ b/src/anm2_new/anm2.hpp @@ -0,0 +1,90 @@ +#pragma once + +#include +#include +#include +#include + +#include "../resource/audio.hpp" +#include "../resource/texture.hpp" + +#include + +namespace anm2ed::resource::anm2_new +{ + class Anm2 + { + public: + enum Type + { + NONE, + INFO, + SPRITESHEET, + REGION, + LAYER, + NULL_, + EVENT, + SOUND, + ANIMATION, + ROOT_ANIMATION, + LAYER_ANIMATION, + NULL_ANIMATION, + TRIGGERS, + FRAME, + TRIGGER + }; + + class Item + { + public: + Type type{NONE}; + Type ownerType{NONE}; + std::string name{}; + bool isInterpolated{false}; + bool isLoop{false}; + bool isVisible{false}; + bool isShowRect{false}; + glm::vec2 crop{}; + glm::vec2 pivot{}; + glm::vec2 position{}; + glm::vec2 scale{100, 100}; + glm::vec2 size{}; + glm::vec3 colorOffset{}; + glm::vec4 tint{1, 1, 1, 1}; + int atFrame{-1}; + int duration{1}; + int eventID{-1}; + int fps{30}; + int frameNum{1}; + int id{-1}; + int itemID{-1}; + int ownerID{-1}; + int animationID{-1}; + int spritesheetID{-1}; + int regionID{-1}; + int version{0}; + float rotation{}; + resource::Texture texture{}; + resource::Audio sound{}; + std::filesystem::path path{}; + std::string createdBy{}; + std::string createdOn{}; + std::vector soundIDs{}; + + Item() = default; + Item(tinyxml2::XMLElement*, Type); + tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&) const; + std::string to_string() const; + }; + + std::vector items{}; + std::filesystem::path path{}; + bool isValid{false}; + + Anm2() = default; + Anm2(const std::filesystem::path&); + tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&) const; + bool serialize(const std::filesystem::path&, std::string* = nullptr) const; + std::string to_string() const; + }; +} diff --git a/src/canvas.cpp b/src/canvas.cpp index 6ef189b..5d18447 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -1,4 +1,4 @@ -#include "canvas.h" +#include "canvas.hpp" #include #include @@ -6,7 +6,7 @@ #include #include -#include "math_.h" +#include "math_.hpp" using namespace glm; using namespace anm2ed::resource; diff --git a/src/canvas.hpp b/src/canvas.hpp index 79a2cc6..f99dde7 100644 --- a/src/canvas.hpp +++ b/src/canvas.hpp @@ -3,10 +3,10 @@ #include #include -#include "framebuffer.h" -#include "shader.h" +#include "framebuffer.hpp" +#include "shader.hpp" -#include "types.h" +#include "types.hpp" namespace anm2ed { diff --git a/src/clipboard.cpp b/src/clipboard.cpp index 4aa232d..f5d1ec3 100644 --- a/src/clipboard.cpp +++ b/src/clipboard.cpp @@ -1,4 +1,4 @@ -#include "clipboard.h" +#include "clipboard.hpp" #include diff --git a/src/dialog.cpp b/src/dialog.cpp index 895c018..520efca 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -1,19 +1,19 @@ -#include "dialog.h" +#include "dialog.hpp" #ifdef _WIN32 #include #elif __unix__ #else - #include "log.h" - #include "strings.h" - #include "toast.h" + #include "log.hpp" + #include "strings.hpp" + #include "toast.hpp" #endif #include #include #include -#include "path_.h" +#include "path_.hpp" using namespace anm2ed::util; diff --git a/src/document.cpp b/src/document.cpp index fd280f8..ed7413e 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1,13 +1,13 @@ -#include "document.h" +#include "document.hpp" #include #include -#include "log.h" -#include "path_.h" -#include "strings.h" -#include "toast.h" +#include "log.hpp" +#include "path_.hpp" +#include "strings.hpp" +#include "toast.hpp" using namespace anm2ed::anm2; using namespace anm2ed::imgui; diff --git a/src/document.hpp b/src/document.hpp index 530a14e..5e16874 100644 --- a/src/document.hpp +++ b/src/document.hpp @@ -4,7 +4,7 @@ #include #include -#include "snapshots.h" +#include "snapshots.hpp" #include diff --git a/src/framebuffer.cpp b/src/framebuffer.cpp index 0ef0c25..eb393b7 100644 --- a/src/framebuffer.cpp +++ b/src/framebuffer.cpp @@ -1,6 +1,6 @@ -#include "framebuffer.h" +#include "framebuffer.hpp" -#include "texture.h" +#include "texture.hpp" using namespace anm2ed::resource; using namespace glm; diff --git a/src/imgui/dockspace.cpp b/src/imgui/dockspace.cpp index 398982e..fe81350 100644 --- a/src/imgui/dockspace.cpp +++ b/src/imgui/dockspace.cpp @@ -1,4 +1,4 @@ -#include "dockspace.h" +#include "dockspace.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/dockspace.hpp b/src/imgui/dockspace.hpp index eca62f3..8bdfd90 100644 --- a/src/imgui/dockspace.hpp +++ b/src/imgui/dockspace.hpp @@ -1,21 +1,21 @@ #pragma once -#include "documents.h" -#include "taskbar.h" -#include "window/animation_preview.h" -#include "window/animations.h" -#include "window/regions.h" -#include "window/events.h" -#include "window/frame_properties.h" -#include "window/layers.h" -#include "window/nulls.h" -#include "window/onionskin.h" -#include "window/sounds.h" -#include "window/spritesheet_editor.h" -#include "window/spritesheets.h" -#include "window/timeline.h" -#include "window/tools.h" -#include "window/welcome.h" +#include "documents.hpp" +#include "taskbar.hpp" +#include "window/animation_preview.hpp" +#include "window/animations.hpp" +#include "window/regions.hpp" +#include "window/events.hpp" +#include "window/frame_properties.hpp" +#include "window/layers.hpp" +#include "window/nulls.hpp" +#include "window/onionskin.hpp" +#include "window/sounds.hpp" +#include "window/spritesheet_editor.hpp" +#include "window/spritesheets.hpp" +#include "window/timeline.hpp" +#include "window/tools.hpp" +#include "window/welcome.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/documents.cpp b/src/imgui/documents.cpp index cdd442f..05b5d4d 100644 --- a/src/imgui/documents.cpp +++ b/src/imgui/documents.cpp @@ -1,13 +1,13 @@ -#include "documents.h" +#include "documents.hpp" #include #include -#include "path_.h" -#include "strings.h" -#include "time_.h" -#include "toast.h" -#include "log.h" +#include "path_.hpp" +#include "strings.hpp" +#include "time_.hpp" +#include "toast.hpp" +#include "log.hpp" using namespace anm2ed::resource; using namespace anm2ed::types; diff --git a/src/imgui/documents.hpp b/src/imgui/documents.hpp index 3ac52a2..319cb2e 100644 --- a/src/imgui/documents.hpp +++ b/src/imgui/documents.hpp @@ -1,10 +1,10 @@ #pragma once -#include "manager.h" -#include "resources.h" -#include "settings.h" -#include "strings.h" -#include "taskbar.h" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" +#include "strings.hpp" +#include "taskbar.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/imgui_.cpp b/src/imgui/imgui_.cpp index 7aa98df..fc3f1d9 100644 --- a/src/imgui/imgui_.cpp +++ b/src/imgui/imgui_.cpp @@ -6,9 +6,9 @@ #include #include -#include "imgui_.h" -#include "path_.h" -#include "strings.h" +#include "imgui_.hpp" +#include "path_.hpp" +#include "strings.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/imgui/imgui_.hpp b/src/imgui/imgui_.hpp index 9923156..cff5a5c 100644 --- a/src/imgui/imgui_.hpp +++ b/src/imgui/imgui_.hpp @@ -8,8 +8,8 @@ #include #include -#include "strings.h" -#include "types.h" +#include "strings.hpp" +#include "types.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/taskbar.cpp b/src/imgui/taskbar.cpp index 1955c47..28ca282 100644 --- a/src/imgui/taskbar.cpp +++ b/src/imgui/taskbar.cpp @@ -1,4 +1,4 @@ -#include "taskbar.h" +#include "taskbar.hpp" #include #include @@ -7,12 +7,12 @@ #include -#include "document.h" -#include "log.h" -#include "path_.h" -#include "strings.h" -#include "toast.h" -#include "types.h" +#include "document.hpp" +#include "log.hpp" +#include "path_.hpp" +#include "strings.hpp" +#include "toast.hpp" +#include "types.hpp" using namespace anm2ed::resource; using namespace anm2ed::types; diff --git a/src/imgui/taskbar.hpp b/src/imgui/taskbar.hpp index cd171e7..56e5a5d 100644 --- a/src/imgui/taskbar.hpp +++ b/src/imgui/taskbar.hpp @@ -1,18 +1,18 @@ #pragma once -#include "canvas.h" -#include "dialog.h" -#include "imgui_.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" -#include "strings.h" +#include "canvas.hpp" +#include "dialog.hpp" +#include "imgui_.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" +#include "strings.hpp" -#include "wizard/about.h" -#include "wizard/change_all_frame_properties.h" -#include "wizard/configure.h" -#include "wizard/generate_animation_from_grid.h" -#include "wizard/render_animation.h" +#include "wizard/about.hpp" +#include "wizard/change_all_frame_properties.hpp" +#include "wizard/configure.hpp" +#include "wizard/generate_animation_from_grid.hpp" +#include "wizard/render_animation.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/toast.cpp b/src/imgui/toast.cpp index 39646f0..9e3274a 100644 --- a/src/imgui/toast.cpp +++ b/src/imgui/toast.cpp @@ -1,9 +1,9 @@ -#include "toast.h" +#include "toast.hpp" -#include "log.h" +#include "log.hpp" #include -#include "types.h" +#include "types.hpp" using namespace anm2ed::types; diff --git a/src/imgui/window/animation_preview.cpp b/src/imgui/window/animation_preview.cpp index e821ba3..e4a7a20 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -1,4 +1,4 @@ -#include "animation_preview.h" +#include "animation_preview.hpp" #include #include @@ -10,14 +10,14 @@ #include -#include "imgui_.h" -#include "log.h" -#include "math_.h" -#include "path_.h" -#include "strings.h" -#include "toast.h" -#include "tool.h" -#include "types.h" +#include "imgui_.hpp" +#include "log.hpp" +#include "math_.hpp" +#include "path_.hpp" +#include "strings.hpp" +#include "toast.hpp" +#include "tool.hpp" +#include "types.hpp" using namespace anm2ed::types; using namespace anm2ed::util; @@ -265,11 +265,16 @@ namespace anm2ed::imgui { if (auto trigger = animation->triggers.frame_generate(playback.time, anm2::TRIGGER); trigger.isVisible) { - auto soundID = trigger.soundIDs.size() > 1 - ? (int)trigger.soundIDs[math::random_in_range(0, trigger.soundIDs.size())] - : (int)trigger.soundIDs.front(); + if (!trigger.soundIDs.empty()) + { + auto soundIndex = trigger.soundIDs.size() > 1 + ? (size_t)math::random_in_range(0.0f, (float)trigger.soundIDs.size()) + : (size_t)0; + soundIndex = std::min(soundIndex, trigger.soundIDs.size() - 1); + auto soundID = trigger.soundIDs[soundIndex]; - if (anm2.content.sounds.contains(soundID)) anm2.content.sounds[soundID].audio.play(false, mixer); + if (anm2.content.sounds.contains(soundID)) anm2.content.sounds[soundID].audio.play(false, mixer); + } } } } diff --git a/src/imgui/window/animation_preview.hpp b/src/imgui/window/animation_preview.hpp index 7c0773b..7645a4f 100644 --- a/src/imgui/window/animation_preview.hpp +++ b/src/imgui/window/animation_preview.hpp @@ -2,11 +2,11 @@ #include -#include "audio_stream.h" -#include "canvas.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "audio_stream.hpp" +#include "canvas.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/animations.cpp b/src/imgui/window/animations.cpp index 9d55ffc..52fcf6c 100644 --- a/src/imgui/window/animations.cpp +++ b/src/imgui/window/animations.cpp @@ -1,12 +1,12 @@ -#include "animations.h" +#include "animations.hpp" #include #include -#include "log.h" -#include "strings.h" -#include "toast.h" -#include "vector_.h" +#include "log.hpp" +#include "strings.hpp" +#include "toast.hpp" +#include "vector_.hpp" using namespace anm2ed::util; using namespace anm2ed::resource; diff --git a/src/imgui/window/animations.hpp b/src/imgui/window/animations.hpp index 82be436..10fa2ff 100644 --- a/src/imgui/window/animations.hpp +++ b/src/imgui/window/animations.hpp @@ -1,10 +1,10 @@ #pragma once -#include "clipboard.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" -#include "strings.h" +#include "clipboard.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" +#include "strings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/events.cpp b/src/imgui/window/events.cpp index d7ed3f8..b0a9f59 100644 --- a/src/imgui/window/events.cpp +++ b/src/imgui/window/events.cpp @@ -1,11 +1,11 @@ -#include "events.h" +#include "events.hpp" #include -#include "log.h" -#include "map_.h" -#include "strings.h" -#include "toast.h" +#include "log.hpp" +#include "map_.hpp" +#include "strings.hpp" +#include "toast.hpp" using namespace anm2ed::util; using namespace anm2ed::resource; diff --git a/src/imgui/window/events.hpp b/src/imgui/window/events.hpp index 5d956c5..710d284 100644 --- a/src/imgui/window/events.hpp +++ b/src/imgui/window/events.hpp @@ -1,9 +1,9 @@ #pragma once -#include "clipboard.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "clipboard.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/frame_properties.cpp b/src/imgui/window/frame_properties.cpp index 8951f49..c40c214 100644 --- a/src/imgui/window/frame_properties.cpp +++ b/src/imgui/window/frame_properties.cpp @@ -1,13 +1,13 @@ -#include "frame_properties.h" +#include "frame_properties.hpp" #include #include #include #include -#include "math_.h" -#include "strings.h" -#include "types.h" +#include "math_.hpp" +#include "strings.hpp" +#include "types.hpp" using namespace anm2ed::util::math; using namespace anm2ed::types; diff --git a/src/imgui/window/frame_properties.hpp b/src/imgui/window/frame_properties.hpp index a5d6640..3ff82b7 100644 --- a/src/imgui/window/frame_properties.hpp +++ b/src/imgui/window/frame_properties.hpp @@ -2,8 +2,8 @@ #include -#include "manager.h" -#include "wizard/change_all_frame_properties.h" +#include "manager.hpp" +#include "wizard/change_all_frame_properties.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/layers.cpp b/src/imgui/window/layers.cpp index 0c2a5de..2fa8105 100644 --- a/src/imgui/window/layers.cpp +++ b/src/imgui/window/layers.cpp @@ -1,11 +1,11 @@ -#include "layers.h" +#include "layers.hpp" #include -#include "log.h" -#include "map_.h" -#include "strings.h" -#include "toast.h" +#include "log.hpp" +#include "map_.hpp" +#include "strings.hpp" +#include "toast.hpp" using namespace anm2ed::util; using namespace anm2ed::resource; diff --git a/src/imgui/window/layers.hpp b/src/imgui/window/layers.hpp index f977fb9..4e190c5 100644 --- a/src/imgui/window/layers.hpp +++ b/src/imgui/window/layers.hpp @@ -1,9 +1,9 @@ #pragma once -#include "clipboard.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "clipboard.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/nulls.cpp b/src/imgui/window/nulls.cpp index 4dad0ca..abb4c08 100644 --- a/src/imgui/window/nulls.cpp +++ b/src/imgui/window/nulls.cpp @@ -1,11 +1,11 @@ -#include "nulls.h" +#include "nulls.hpp" #include -#include "log.h" -#include "map_.h" -#include "strings.h" -#include "toast.h" +#include "log.hpp" +#include "map_.hpp" +#include "strings.hpp" +#include "toast.hpp" using namespace anm2ed::resource; using namespace anm2ed::util; diff --git a/src/imgui/window/nulls.hpp b/src/imgui/window/nulls.hpp index de0c547..ceb32fe 100644 --- a/src/imgui/window/nulls.hpp +++ b/src/imgui/window/nulls.hpp @@ -1,9 +1,9 @@ #pragma once -#include "clipboard.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "clipboard.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/onionskin.cpp b/src/imgui/window/onionskin.cpp index 1c460df..944cd12 100644 --- a/src/imgui/window/onionskin.cpp +++ b/src/imgui/window/onionskin.cpp @@ -1,9 +1,9 @@ -#include "onionskin.h" +#include "onionskin.hpp" #include -#include "imgui_.h" -#include "strings.h" +#include "imgui_.hpp" +#include "strings.hpp" using namespace anm2ed::types; using namespace glm; diff --git a/src/imgui/window/onionskin.hpp b/src/imgui/window/onionskin.hpp index df3847c..dd9489d 100644 --- a/src/imgui/window/onionskin.hpp +++ b/src/imgui/window/onionskin.hpp @@ -1,6 +1,6 @@ #pragma once -#include "manager.h" +#include "manager.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/regions.cpp b/src/imgui/window/regions.cpp index 8be4840..38ef50e 100644 --- a/src/imgui/window/regions.cpp +++ b/src/imgui/window/regions.cpp @@ -1,4 +1,4 @@ -#include "regions.h" +#include "regions.hpp" #include #include @@ -6,16 +6,16 @@ #include #include -#include "document.h" -#include "log.h" -#include "map_.h" -#include "math_.h" -#include "path_.h" -#include "strings.h" -#include "toast.h" -#include "vector_.h" +#include "document.hpp" +#include "log.hpp" +#include "map_.hpp" +#include "math_.hpp" +#include "path_.hpp" +#include "strings.hpp" +#include "toast.hpp" +#include "vector_.hpp" -#include "../../util/map_.h" +#include "../../util/map_.hpp" using namespace anm2ed::types; using namespace anm2ed::resource; diff --git a/src/imgui/window/regions.hpp b/src/imgui/window/regions.hpp index 8827467..54e3f28 100644 --- a/src/imgui/window/regions.hpp +++ b/src/imgui/window/regions.hpp @@ -1,9 +1,9 @@ #pragma once -#include "clipboard.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "clipboard.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/sounds.cpp b/src/imgui/window/sounds.cpp index c0fd99d..3beb8d3 100644 --- a/src/imgui/window/sounds.cpp +++ b/src/imgui/window/sounds.cpp @@ -1,13 +1,13 @@ -#include "sounds.h" +#include "sounds.hpp" #include #include #include -#include "log.h" -#include "path_.h" -#include "strings.h" -#include "toast.h" +#include "log.hpp" +#include "path_.hpp" +#include "strings.hpp" +#include "toast.hpp" using namespace anm2ed::util; using namespace anm2ed::types; diff --git a/src/imgui/window/sounds.hpp b/src/imgui/window/sounds.hpp index 6f61b7e..f5ab6f1 100644 --- a/src/imgui/window/sounds.hpp +++ b/src/imgui/window/sounds.hpp @@ -1,10 +1,10 @@ #pragma once -#include "clipboard.h" -#include "dialog.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "clipboard.hpp" +#include "dialog.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/spritesheet_editor.cpp b/src/imgui/window/spritesheet_editor.cpp index 0c062d6..0801b25 100644 --- a/src/imgui/window/spritesheet_editor.cpp +++ b/src/imgui/window/spritesheet_editor.cpp @@ -1,15 +1,15 @@ -#include "spritesheet_editor.h" +#include "spritesheet_editor.hpp" #include #include #include -#include "imgui_.h" +#include "imgui_.hpp" #include "imgui_internal.h" -#include "math_.h" -#include "strings.h" -#include "tool.h" -#include "types.h" +#include "math_.hpp" +#include "strings.hpp" +#include "tool.hpp" +#include "types.hpp" using namespace anm2ed::types; using namespace anm2ed::resource; diff --git a/src/imgui/window/spritesheet_editor.hpp b/src/imgui/window/spritesheet_editor.hpp index e1a1da5..857cccc 100644 --- a/src/imgui/window/spritesheet_editor.hpp +++ b/src/imgui/window/spritesheet_editor.hpp @@ -1,9 +1,9 @@ #pragma once -#include "canvas.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "canvas.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/spritesheets.cpp b/src/imgui/window/spritesheets.cpp index f8b62f0..fef8bfd 100644 --- a/src/imgui/window/spritesheets.cpp +++ b/src/imgui/window/spritesheets.cpp @@ -1,4 +1,4 @@ -#include "spritesheets.h" +#include "spritesheets.hpp" #include #include @@ -8,12 +8,12 @@ #include #include -#include "document.h" -#include "log.h" -#include "path_.h" -#include "strings.h" -#include "toast.h" -#include "working_directory.h" +#include "document.hpp" +#include "log.hpp" +#include "path_.hpp" +#include "strings.hpp" +#include "toast.hpp" +#include "working_directory.hpp" using namespace anm2ed::types; using namespace anm2ed::resource; diff --git a/src/imgui/window/spritesheets.hpp b/src/imgui/window/spritesheets.hpp index 595448a..878b53c 100644 --- a/src/imgui/window/spritesheets.hpp +++ b/src/imgui/window/spritesheets.hpp @@ -1,10 +1,10 @@ #pragma once -#include "clipboard.h" -#include "dialog.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" +#include "clipboard.hpp" +#include "dialog.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/timeline.cpp b/src/imgui/window/timeline.cpp index 2c206c7..76288ab 100644 --- a/src/imgui/window/timeline.cpp +++ b/src/imgui/window/timeline.cpp @@ -1,4 +1,4 @@ -#include "timeline.h" +#include "timeline.hpp" #include #include @@ -6,10 +6,10 @@ #include -#include "log.h" -#include "toast.h" +#include "log.hpp" +#include "toast.hpp" -#include "vector_.h" +#include "vector_.hpp" using namespace anm2ed::resource; using namespace anm2ed::types; diff --git a/src/imgui/window/timeline.hpp b/src/imgui/window/timeline.hpp index bf6c670..d75910c 100644 --- a/src/imgui/window/timeline.hpp +++ b/src/imgui/window/timeline.hpp @@ -2,11 +2,11 @@ #include -#include "clipboard.h" -#include "manager.h" -#include "resources.h" -#include "settings.h" -#include "strings.h" +#include "clipboard.hpp" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" +#include "strings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/tools.cpp b/src/imgui/window/tools.cpp index b2773fa..3432da0 100644 --- a/src/imgui/window/tools.cpp +++ b/src/imgui/window/tools.cpp @@ -1,11 +1,11 @@ -#include "tools.h" +#include "tools.hpp" #include -#include "strings.h" -#include "tool.h" -#include "types.h" +#include "strings.hpp" +#include "tool.hpp" +#include "types.hpp" using namespace anm2ed::resource; using namespace anm2ed::types; diff --git a/src/imgui/window/tools.hpp b/src/imgui/window/tools.hpp index 6f74f72..e6e8831 100644 --- a/src/imgui/window/tools.hpp +++ b/src/imgui/window/tools.hpp @@ -1,9 +1,9 @@ #pragma once -#include "manager.h" -#include "resources.h" -#include "settings.h" -#include "strings.h" +#include "manager.hpp" +#include "resources.hpp" +#include "settings.hpp" +#include "strings.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/window/welcome.cpp b/src/imgui/window/welcome.cpp index 2d546fa..59b9524 100644 --- a/src/imgui/window/welcome.cpp +++ b/src/imgui/window/welcome.cpp @@ -1,9 +1,9 @@ -#include "welcome.h" +#include "welcome.hpp" #include -#include "path_.h" -#include "strings.h" +#include "path_.hpp" +#include "strings.hpp" using namespace anm2ed::util; using namespace anm2ed::resource; diff --git a/src/imgui/window/welcome.hpp b/src/imgui/window/welcome.hpp index d0d8f9f..3a43f20 100644 --- a/src/imgui/window/welcome.hpp +++ b/src/imgui/window/welcome.hpp @@ -1,9 +1,9 @@ #pragma once -#include "documents.h" -#include "manager.h" -#include "strings.h" -#include "taskbar.h" +#include "documents.hpp" +#include "manager.hpp" +#include "strings.hpp" +#include "taskbar.hpp" namespace anm2ed::imgui { diff --git a/src/imgui/wizard/about.cpp b/src/imgui/wizard/about.cpp index 0d53840..301b6c4 100644 --- a/src/imgui/wizard/about.cpp +++ b/src/imgui/wizard/about.cpp @@ -1,10 +1,10 @@ -#include "about.h" +#include "about.hpp" #include #include #include -#include "strings.h" +#include "strings.hpp" using namespace anm2ed::resource; diff --git a/src/imgui/wizard/about.hpp b/src/imgui/wizard/about.hpp index d1dcbcc..6722dd7 100644 --- a/src/imgui/wizard/about.hpp +++ b/src/imgui/wizard/about.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../../resources.h" +#include "../../resources.hpp" namespace anm2ed::imgui::wizard { diff --git a/src/imgui/wizard/change_all_frame_properties.cpp b/src/imgui/wizard/change_all_frame_properties.cpp index 4ce3e51..f346a20 100644 --- a/src/imgui/wizard/change_all_frame_properties.cpp +++ b/src/imgui/wizard/change_all_frame_properties.cpp @@ -1,9 +1,9 @@ -#include "change_all_frame_properties.h" +#include "change_all_frame_properties.hpp" #include #include -#include "math_.h" +#include "math_.hpp" using namespace anm2ed::util::math; using namespace glm; diff --git a/src/imgui/wizard/change_all_frame_properties.hpp b/src/imgui/wizard/change_all_frame_properties.hpp index f5143ee..555472a 100644 --- a/src/imgui/wizard/change_all_frame_properties.hpp +++ b/src/imgui/wizard/change_all_frame_properties.hpp @@ -1,7 +1,7 @@ #pragma once -#include "document.h" -#include "settings.h" +#include "document.hpp" +#include "settings.hpp" namespace anm2ed::imgui::wizard { diff --git a/src/imgui/wizard/configure.cpp b/src/imgui/wizard/configure.cpp index 5c075d2..bf91bc4 100644 --- a/src/imgui/wizard/configure.cpp +++ b/src/imgui/wizard/configure.cpp @@ -1,6 +1,6 @@ -#include "configure.h" +#include "configure.hpp" -#include "imgui_.h" +#include "imgui_.hpp" using namespace anm2ed::types; diff --git a/src/imgui/wizard/configure.hpp b/src/imgui/wizard/configure.hpp index 98840a5..9a4c4e5 100644 --- a/src/imgui/wizard/configure.hpp +++ b/src/imgui/wizard/configure.hpp @@ -1,6 +1,6 @@ #pragma once -#include "manager.h" +#include "manager.hpp" namespace anm2ed::imgui::wizard { diff --git a/src/imgui/wizard/generate_animation_from_grid.cpp b/src/imgui/wizard/generate_animation_from_grid.cpp index 97083c6..3c9ba64 100644 --- a/src/imgui/wizard/generate_animation_from_grid.cpp +++ b/src/imgui/wizard/generate_animation_from_grid.cpp @@ -1,7 +1,7 @@ -#include "generate_animation_from_grid.h" +#include "generate_animation_from_grid.hpp" -#include "math_.h" -#include "types.h" +#include "math_.hpp" +#include "types.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/imgui/wizard/generate_animation_from_grid.hpp b/src/imgui/wizard/generate_animation_from_grid.hpp index ca398bf..88d0330 100644 --- a/src/imgui/wizard/generate_animation_from_grid.hpp +++ b/src/imgui/wizard/generate_animation_from_grid.hpp @@ -1,9 +1,9 @@ #pragma once -#include "canvas.h" -#include "document.h" -#include "resources.h" -#include "settings.h" +#include "canvas.hpp" +#include "document.hpp" +#include "resources.hpp" +#include "settings.hpp" namespace anm2ed::imgui::wizard { diff --git a/src/imgui/wizard/render_animation.cpp b/src/imgui/wizard/render_animation.cpp index a616b2a..1e976d9 100644 --- a/src/imgui/wizard/render_animation.cpp +++ b/src/imgui/wizard/render_animation.cpp @@ -1,13 +1,13 @@ -#include "render_animation.h" +#include "render_animation.hpp" #include #include -#include "imgui_.h" -#include "log.h" -#include "path_.h" -#include "process_.h" -#include "toast.h" +#include "imgui_.hpp" +#include "log.hpp" +#include "path_.hpp" +#include "process_.hpp" +#include "toast.hpp" using namespace anm2ed::resource; using namespace anm2ed::util; diff --git a/src/imgui/wizard/render_animation.hpp b/src/imgui/wizard/render_animation.hpp index 77f20da..d80e460 100644 --- a/src/imgui/wizard/render_animation.hpp +++ b/src/imgui/wizard/render_animation.hpp @@ -1,8 +1,8 @@ #pragma once -#include "dialog.h" -#include "manager.h" -#include "resources.h" +#include "dialog.hpp" +#include "manager.hpp" +#include "resources.hpp" namespace anm2ed::imgui::wizard { diff --git a/src/imgui_new/anm2_window.cpp b/src/imgui_new/anm2_window.cpp new file mode 100644 index 0000000..1b3bb66 --- /dev/null +++ b/src/imgui_new/anm2_window.cpp @@ -0,0 +1,16 @@ +#include "anm2_window.hpp" + +#include "imgui.h" + +using namespace anm2ed::resource::anm2_new; + +namespace anm2ed::imgui_new +{ + void Window::update(Anm2& anm2, Anm2::Type type, Settings& settings) + { + if (ImGui::Begin("TestWindow", &settings.windowIsEvents)) + { + } + ImGui::End(); + } +} \ No newline at end of file diff --git a/src/imgui_new/anm2_window.hpp b/src/imgui_new/anm2_window.hpp new file mode 100644 index 0000000..196a877 --- /dev/null +++ b/src/imgui_new/anm2_window.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "../anm2_new/anm2.hpp" +#include "../settings.hpp" + +namespace anm2ed::imgui_new +{ + class Window + { + void update(anm2ed::resource::anm2_new::Anm2&, anm2ed::resource::anm2_new::Anm2::Type type, Settings&); + }; +} \ No newline at end of file diff --git a/src/loader.cpp b/src/loader.cpp index 85123ee..51c64b4 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -1,4 +1,4 @@ -#include "loader.h" +#include "loader.hpp" #include #include @@ -9,18 +9,18 @@ #include -#include "log.h" -#include "sdl.h" +#include "log.hpp" +#include "sdl.hpp" -#include "imgui_.h" +#include "imgui_.hpp" -#include "snapshots.h" -#include "socket.h" +#include "snapshots.hpp" +#include "socket.hpp" -#include "util/math_.h" +#include "util/math_.hpp" #ifdef _WIN32 - #include "util/path_.h" + #include "util/path_.hpp" #include #include #include diff --git a/src/loader.hpp b/src/loader.hpp index 5caeaeb..8bf9d41 100644 --- a/src/loader.hpp +++ b/src/loader.hpp @@ -7,8 +7,8 @@ #include -#include "settings.h" -#include "socket.h" +#include "settings.hpp" +#include "socket.hpp" namespace anm2ed { diff --git a/src/log.cpp b/src/log.cpp index f5d105e..19374f4 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -1,9 +1,9 @@ -#include "log.h" +#include "log.hpp" #include -#include "sdl.h" -#include "time_.h" +#include "sdl.hpp" +#include "time_.hpp" using namespace anm2ed::util; diff --git a/src/main.cpp b/src/main.cpp index 4da1214..375faca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ -#include "loader.h" -#include "state.h" +#include "loader.hpp" +#include "state.hpp" #ifdef _WIN32 #define SDL_MAIN_HANDLED diff --git a/src/manager.cpp b/src/manager.cpp index b631d48..15c8f51 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1,16 +1,16 @@ -#include "manager.h" +#include "manager.hpp" #include #include #include -#include "log.h" -#include "path_.h" -#include "sdl.h" -#include "strings.h" -#include "toast.h" -#include "vector_.h" +#include "log.hpp" +#include "path_.hpp" +#include "sdl.hpp" +#include "strings.hpp" +#include "toast.hpp" +#include "vector_.hpp" using namespace anm2ed::types; using namespace anm2ed::util; diff --git a/src/manager.hpp b/src/manager.hpp index 2dad576..7514795 100644 --- a/src/manager.hpp +++ b/src/manager.hpp @@ -5,9 +5,9 @@ #include #include -#include "document.h" -#include "settings.h" -#include "strings.h" +#include "document.hpp" +#include "settings.hpp" +#include "strings.hpp" namespace anm2ed { diff --git a/src/playback.cpp b/src/playback.cpp index 55a80c8..1b6508e 100644 --- a/src/playback.cpp +++ b/src/playback.cpp @@ -1,4 +1,4 @@ -#include "playback.h" +#include "playback.hpp" #include #include diff --git a/src/render.cpp b/src/render.cpp index 9149458..74018f5 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -1,4 +1,4 @@ -#include "render.h" +#include "render.hpp" #include #include @@ -8,11 +8,11 @@ #include #include -#include "log.h" -#include "path_.h" -#include "process_.h" -#include "sdl.h" -#include "string_.h" +#include "log.hpp" +#include "path_.hpp" +#include "process_.hpp" +#include "sdl.hpp" +#include "string_.hpp" using namespace anm2ed::util; @@ -56,6 +56,8 @@ namespace anm2ed std::string audioInputArguments{}; std::string audioOutputArguments{"-an"}; std::string command{}; + auto temporaryDirectory = framePaths.front().parent_path(); + if (temporaryDirectory.empty()) temporaryDirectory = std::filesystem::temp_directory_path(); auto audio_remove = [&]() { @@ -69,8 +71,8 @@ namespace anm2ed if (type != render::GIF && !audioStream.stream.empty() && audioStream.spec.freq > 0 && audioStream.spec.channels > 0) { - auto tempFilenameUtf8 = std::format("{}.f32", pathString); - audioPath = std::filesystem::temp_directory_path() / path::from_utf8(tempFilenameUtf8); + auto tempFilenameUtf8 = std::format("anm2ed_audio_{}_{}.f32", std::hash{}(pathString), SDL_GetTicks()); + audioPath = temporaryDirectory / path::from_utf8(tempFilenameUtf8); std::ofstream audioFile(audioPath, std::ios::binary); @@ -103,7 +105,7 @@ namespace anm2ed } } - auto framesListPath = std::filesystem::temp_directory_path() / path::from_utf8(std::format( + auto framesListPath = temporaryDirectory / path::from_utf8(std::format( "anm2ed_frames_{}_{}.txt", std::hash{}(pathString), SDL_GetTicks())) ; std::ofstream framesListFile(framesListPath); if (!framesListFile) @@ -176,7 +178,15 @@ namespace anm2ed return false; } - process.close(); + auto ffmpegExitCode = process.close(); + if (ffmpegExitCode != 0) + { + logger.error(std::format("FFmpeg exited with code {} while exporting {}", ffmpegExitCode, pathString)); + std::error_code ec; + std::filesystem::remove(framesListPath, ec); + audio_remove(); + return false; + } std::error_code ec; std::filesystem::remove(framesListPath, ec); diff --git a/src/render.hpp b/src/render.hpp index 5b41883..95d1bd8 100644 --- a/src/render.hpp +++ b/src/render.hpp @@ -1,7 +1,7 @@ #pragma once -#include "audio_stream.h" -#include "texture.h" +#include "audio_stream.hpp" +#include "texture.hpp" namespace anm2ed::render { diff --git a/src/resource/audio.cpp b/src/resource/audio.cpp index 41e45bc..79c3699 100644 --- a/src/resource/audio.cpp +++ b/src/resource/audio.cpp @@ -1,9 +1,9 @@ -#include "audio.h" +#include "audio.hpp" #include #include -#include "file_.h" +#include "file_.hpp" using namespace anm2ed::util; diff --git a/src/resource/audio_stream.cpp b/src/resource/audio_stream.cpp index 885b1ce..2ae3dfc 100644 --- a/src/resource/audio_stream.cpp +++ b/src/resource/audio_stream.cpp @@ -1,4 +1,4 @@ -#include "audio_stream.h" +#include "audio_stream.hpp" #if defined(__clang__) || defined(__GNUC__) #pragma GCC diagnostic push diff --git a/src/resource/font.cpp b/src/resource/font.cpp index 371ee6b..4be013d 100644 --- a/src/resource/font.cpp +++ b/src/resource/font.cpp @@ -1,4 +1,4 @@ -#include "font.h" +#include "font.hpp" namespace anm2ed::resource { diff --git a/src/resource/shader.cpp b/src/resource/shader.cpp index ba1e234..db0631a 100644 --- a/src/resource/shader.cpp +++ b/src/resource/shader.cpp @@ -1,6 +1,6 @@ -#include "shader.h" +#include "shader.hpp" -#include "log.h" +#include "log.hpp" namespace anm2ed::resource { diff --git a/src/resource/strings.cpp b/src/resource/strings.cpp index 9e2557c..1bd224d 100644 --- a/src/resource/strings.cpp +++ b/src/resource/strings.cpp @@ -1,3 +1,3 @@ -#include "strings.h" +#include "strings.hpp" anm2ed::Localizer localize; diff --git a/src/resource/texture.cpp b/src/resource/texture.cpp index 381f8a9..122bef3 100644 --- a/src/resource/texture.cpp +++ b/src/resource/texture.cpp @@ -1,4 +1,4 @@ -#include "texture.h" +#include "texture.hpp" #include #include @@ -23,8 +23,8 @@ #pragma GCC diagnostic pop #endif -#include "file_.h" -#include "math_.h" +#include "file_.hpp" +#include "math_.hpp" using namespace anm2ed::resource::texture; using namespace anm2ed::util::math; diff --git a/src/resources.cpp b/src/resources.cpp index 6bf5168..58e5bfe 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -1,9 +1,9 @@ -#include "resources.h" +#include "resources.hpp" #include -#include "log.h" -#include "music.h" +#include "log.hpp" +#include "music.hpp" using namespace anm2ed::resource; diff --git a/src/resources.hpp b/src/resources.hpp index 7e7a0d8..8e9b20f 100644 --- a/src/resources.hpp +++ b/src/resources.hpp @@ -2,11 +2,11 @@ #include -#include "audio.h" -#include "font.h" -#include "icon.h" -#include "shader.h" -#include "texture.h" +#include "audio.hpp" +#include "font.hpp" +#include "icon.hpp" +#include "shader.hpp" +#include "texture.hpp" namespace anm2ed { diff --git a/src/settings.cpp b/src/settings.cpp index 643d119..be984d5 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,10 +1,10 @@ -#include "settings.h" +#include "settings.hpp" #include #include -#include "log.h" -#include "path_.h" +#include "log.hpp" +#include "path_.hpp" using namespace anm2ed::util; using namespace glm; diff --git a/src/settings.hpp b/src/settings.hpp index a14cc19..fdbc1d3 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -5,11 +5,11 @@ #include -#include "anm2/anm2_type.h" -#include "origin.h" -#include "render.h" -#include "strings.h" -#include "types.h" +#include "anm2/anm2_type.hpp" +#include "origin.hpp" +#include "render.hpp" +#include "strings.hpp" +#include "types.hpp" namespace anm2ed { diff --git a/src/snapshots.cpp b/src/snapshots.cpp index 08c304d..5ffdf6a 100644 --- a/src/snapshots.cpp +++ b/src/snapshots.cpp @@ -1,4 +1,4 @@ -#include "snapshots.h" +#include "snapshots.hpp" #include diff --git a/src/snapshots.hpp b/src/snapshots.hpp index 62a2230..a5fce63 100644 --- a/src/snapshots.hpp +++ b/src/snapshots.hpp @@ -3,9 +3,9 @@ #include #include -#include "anm2/anm2.h" -#include "playback.h" -#include "storage.h" +#include "anm2/anm2.hpp" +#include "playback.hpp" +#include "storage.hpp" namespace anm2ed::snapshots { diff --git a/src/socket.cpp b/src/socket.cpp index e4bc500..33025c3 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -1,4 +1,4 @@ -#include "socket.h" +#include "socket.hpp" #include diff --git a/src/state.cpp b/src/state.cpp index 5c1e12a..9864ea2 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -1,4 +1,4 @@ -#include "state.h" +#include "state.hpp" #include @@ -7,10 +7,10 @@ #include #include -#include "log.h" -#include "path_.h" -#include "strings.h" -#include "toast.h" +#include "log.hpp" +#include "path_.hpp" +#include "strings.hpp" +#include "toast.hpp" using namespace anm2ed::imgui; using namespace anm2ed::util; @@ -37,6 +37,30 @@ namespace anm2ed void State::update(SDL_Window*& window, Settings& settings) { + /* + ImGui_ImplSDL3_NewFrame(); + ImGui_ImplOpenGL3_NewFrame(); + ImGui::NewFrame(); + + SDL_GetWindowSize(window, &settings.windowSize.x, &settings.windowSize.y); + SDL_GetWindowPosition(window, &settings.windowPosition.x, &settings.windowPosition.y); + + SDL_Event event{}; + + while (SDL_PollEvent(&event)) + { + switch (event.type) + { + case SDL_EVENT_QUIT: + isQuit = true; + default: + break; + } + } + + dockspace.update(taskbar, documents, manager, settings, resources, dialog, clipboard); + */ + SDL_Event event{}; while (SDL_PollEvent(&event)) diff --git a/src/state.hpp b/src/state.hpp index d36270e..e911559 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -2,7 +2,7 @@ #include -#include "dockspace.h" +#include "dockspace.hpp" namespace anm2ed { diff --git a/src/storage.cpp b/src/storage.cpp index 8001965..98e1a81 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -1,4 +1,4 @@ -#include "storage.h" +#include "storage.hpp" #include diff --git a/src/storage.hpp b/src/storage.hpp index dd0dc04..f8382f7 100644 --- a/src/storage.hpp +++ b/src/storage.hpp @@ -1,6 +1,6 @@ #pragma once -#include "imgui_.h" +#include "imgui_.hpp" namespace anm2ed { diff --git a/src/tool.hpp b/src/tool.hpp index 478e128..74266c7 100644 --- a/src/tool.hpp +++ b/src/tool.hpp @@ -1,8 +1,8 @@ #pragma once -#include "icon.h" -#include "settings.h" -#include "strings.h" +#include "icon.hpp" +#include "settings.hpp" +#include "strings.hpp" namespace anm2ed::tool { diff --git a/src/types.hpp b/src/types.hpp index cd7c4d8..f85f154 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -4,7 +4,7 @@ #include #include -#include "strings.h" +#include "strings.hpp" namespace anm2ed::types::theme { diff --git a/src/util/file_.cpp b/src/util/file_.cpp index f67887b..f41ae11 100644 --- a/src/util/file_.cpp +++ b/src/util/file_.cpp @@ -1,4 +1,4 @@ -#include "file_.h" +#include "file_.hpp" namespace anm2ed::util { diff --git a/src/util/math_.cpp b/src/util/math_.cpp index f553fa9..fb0f158 100644 --- a/src/util/math_.cpp +++ b/src/util/math_.cpp @@ -1,4 +1,4 @@ -#include "math.h" +#include "math_.hpp" #include #include @@ -80,4 +80,4 @@ namespace anm2ed::util::math float random() { return (float)rand() / RAND_MAX; } float random_in_range(float min, float max) { return min + random() * (max - min); } void random_seed_set() { srand(std::time(nullptr)); } -} \ No newline at end of file +} diff --git a/src/util/path_.cpp b/src/util/path_.cpp index a98188a..b9baad2 100644 --- a/src/util/path_.cpp +++ b/src/util/path_.cpp @@ -1,4 +1,4 @@ -#include "path_.h" +#include "path_.hpp" #include #include diff --git a/src/util/process_.cpp b/src/util/process_.cpp index fa4cfe3..2a74ee8 100644 --- a/src/util/process_.cpp +++ b/src/util/process_.cpp @@ -1,4 +1,4 @@ -#include "process_.h" +#include "process_.hpp" #ifdef WIN32 #include diff --git a/src/util/sdl.cpp b/src/util/sdl.cpp index a4ff66a..4a229bf 100644 --- a/src/util/sdl.cpp +++ b/src/util/sdl.cpp @@ -1,8 +1,8 @@ -#include "sdl.h" +#include "sdl.hpp" #include -#include "path_.h" +#include "path_.hpp" namespace anm2ed::util::sdl { diff --git a/src/util/string_.cpp b/src/util/string_.cpp index ae1af0a..4bb3da2 100644 --- a/src/util/string_.cpp +++ b/src/util/string_.cpp @@ -1,4 +1,4 @@ -#include "string_.h" +#include "string_.hpp" #include diff --git a/src/util/time_.cpp b/src/util/time_.cpp index 96021c4..f16b9e4 100644 --- a/src/util/time_.cpp +++ b/src/util/time_.cpp @@ -1,4 +1,4 @@ -#include "time_.h" +#include "time_.hpp" #include diff --git a/src/util/working_directory.cpp b/src/util/working_directory.cpp index 42118cf..644940c 100644 --- a/src/util/working_directory.cpp +++ b/src/util/working_directory.cpp @@ -1,9 +1,9 @@ -#include "working_directory.h" +#include "working_directory.hpp" #include -#include "log.h" -#include "path_.h" +#include "log.hpp" +#include "path_.hpp" namespace anm2ed::util { diff --git a/src/util/xml_.cpp b/src/util/xml_.cpp index 787ce72..24d709e 100644 --- a/src/util/xml_.cpp +++ b/src/util/xml_.cpp @@ -1,7 +1,7 @@ -#include "xml_.h" +#include "xml_.hpp" -#include "math_.h" -#include "path_.h" +#include "math_.hpp" +#include "path_.hpp" using namespace anm2ed::util; using namespace tinyxml2;