Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9aba726e85 | ||
|
|
ae7dafaef6 | ||
|
|
9e193a3d5c | ||
|
|
e963bc50d3 | ||
|
|
068d189e6a | ||
|
|
71b0ef683b | ||
|
|
48a6a386e3 | ||
|
|
becd6430ed | ||
|
|
f35f9cb4b8 | ||
|
|
c5a2bddfa1 | ||
|
|
7bacfe0cd6 | ||
|
|
c891e1a873 | ||
|
|
67b2296fc0 | ||
|
|
7a0ef5dd9f | ||
|
|
b29e208a20 | ||
|
|
c467c39baa | ||
|
|
f78d35b12b | ||
|
|
f6325a794b | ||
|
|
69cb240a8d | ||
|
|
48661b4c2c | ||
|
|
13bbd8f9c5 | ||
|
|
05de859879 | ||
|
|
bbfdafb006 | ||
|
|
f39ea8cdfc | ||
|
|
045acb181f | ||
|
|
0fd0bc4cf2 | ||
|
|
4b17e9b328 | ||
|
|
91cc11aa3b | ||
|
|
69b6acb9e8 | ||
|
|
d2c50b5548 | ||
|
|
ada48aefdd | ||
|
|
228a15b5b3 | ||
|
|
1fc6b064ae | ||
|
|
f9dcfb8d79 | ||
|
|
a5ffa916d8 | ||
|
|
f7c90945a7 | ||
|
|
14e9668bab | ||
|
|
a9177b13d0 | ||
|
|
8d3ebf2329 | ||
|
|
99e06b72ea | ||
|
|
15e94192bd | ||
|
|
250adcb6e9 | ||
|
|
544ab3cac9 | ||
|
|
c44c7fe8df | ||
|
|
0f5a224e7a | ||
|
|
7e3c5cfeb5 | ||
|
|
03bbb93ba6 | ||
|
|
c38a3a9890 | ||
|
|
20209e655e | ||
|
|
2f1e75da37 | ||
|
|
d2c0e32ff5 | ||
|
|
6f2fc8c196 | ||
|
|
7e81ea4259 | ||
|
|
7afdf709c3 | ||
|
|
40f6b554b5 | ||
|
|
666f65bf3a | ||
|
|
7fb2c607c2 | ||
|
|
a515267e26 | ||
|
|
4e35f9d450 | ||
|
|
9072ac5745 | ||
|
|
8ef089d306 | ||
|
|
065dd522f3 | ||
|
|
c9d68781d0 | ||
|
|
201a7c7cfc | ||
|
|
b69b0eaa1b | ||
|
|
d77b2bae71 | ||
|
|
a6f9b425e8 | ||
|
|
4141c53681 | ||
|
|
5f01e8065d | ||
|
|
bec89bf48f | ||
|
|
0857e62419 | ||
|
|
d4b88289ac | ||
|
|
4a13c345ef | ||
|
|
38ce53f870 | ||
|
|
0e705e43fa | ||
|
|
8807096170 | ||
|
|
76c2186c81 | ||
|
|
280adaa189 | ||
|
|
5d274e547a | ||
|
|
54f62529e0 | ||
|
|
a917d8ae97 | ||
|
|
b31a28ebe9 | ||
|
|
4375844c84 | ||
|
|
0adb0f89bc | ||
|
|
6b6cd671f7 | ||
|
|
af60cdc11c | ||
|
|
e8372ca149 | ||
|
|
d1a6d89d14 | ||
|
|
6edf5f0e5b | ||
|
|
1381824fb7 | ||
|
|
2ce8795b4a | ||
|
|
ef5796d667 | ||
|
|
a440af3c95 | ||
|
|
f3fb7d5101 | ||
|
|
94d0bbf206 | ||
|
|
f4fd255a02 | ||
|
|
abb9f965d6 | ||
|
|
2dbbfa5e86 | ||
|
|
356d74ebb6 | ||
|
|
4d949827c8 | ||
|
|
4856d9ba27 | ||
|
|
d53d176125 | ||
|
|
dd898c2a0c | ||
|
|
9ff05e389d | ||
|
|
c09e8ca64e | ||
|
|
ce3b544392 | ||
|
|
ded95f436a | ||
|
|
97be81b5c1 | ||
|
|
8fb28ef30a | ||
|
|
251d04848a | ||
|
|
24af98a68e | ||
|
|
993957decf | ||
|
|
d8ab5ff018 | ||
|
|
e713c15030 | ||
|
|
3653295c8f | ||
|
|
5f40a789fe | ||
|
|
99a3744a31 | ||
|
|
2c4bee6330 | ||
|
|
70abe366a0 | ||
|
|
e6a374f571 | ||
|
|
640bf0abeb | ||
|
|
210232eb83 | ||
|
|
c4b21fd90c | ||
|
|
4b6e186f57 | ||
|
|
69e78ff77a | ||
|
|
146e5d4ff1 | ||
|
|
c04a685f18 | ||
|
|
901c11691b | ||
|
|
ab276f6f08 | ||
|
|
36869918e5 | ||
|
|
4c569cb1e5 | ||
|
|
4d16f21541 | ||
|
|
39ccfb723a | ||
|
|
595658581f | ||
|
|
c6c8e3598b | ||
|
|
dc32483c45 | ||
|
|
6f7a457f8f | ||
|
|
d08f59d7ba | ||
|
|
e50d76c784 | ||
|
|
0b6f67d9bd | ||
|
|
2d0f70b1e5 | ||
|
|
9f43a210c5 | ||
|
|
65a3546c3b | ||
|
|
700b613c62 | ||
|
|
20bfbace7a | ||
|
|
26ab394fe4 | ||
|
|
5311c2835f | ||
|
|
8953101245 | ||
|
|
8e37b5df3b | ||
|
|
ec72a30ce0 | ||
|
|
a4638a422d | ||
|
|
30ea363c39 | ||
|
|
d926fc6677 | ||
|
|
3f31cedeed | ||
|
|
a9f48bc3a0 | ||
|
|
41ed347925 | ||
|
|
9e9dd8bd8a | ||
|
|
b7c24fad99 | ||
|
|
5e27111b21 | ||
|
|
46690d6975 | ||
|
|
a4b34cc0be | ||
|
|
e32e781b46 | ||
|
|
ff76932555 | ||
|
|
98f87c9d46 | ||
|
|
c7abe29106 | ||
|
|
d3996a218e | ||
|
|
6786bff07c | ||
|
|
c28ea8eb6f | ||
|
|
c5a9ab8119 | ||
|
|
2b662d24d6 | ||
|
|
5792dd25a2 | ||
|
|
555caf9f4f | ||
|
|
80ef3f8597 | ||
|
|
f00396bdfe | ||
|
|
b5528bc118 | ||
|
|
6d206045c7 | ||
|
|
d079295803 |
No files matched your search
@@ -1,11 +1,32 @@
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 120
|
||||
PointerAlignment: Left
|
||||
ReferenceAlignment: Left
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
CommentPragmas: '^'
|
||||
BreakBeforeBraces: Allman
|
||||
NamespaceIndentation: All
|
||||
FixNamespaceComments: false
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: true
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
RemoveBracesLLVM: true
|
||||
InsertBraces: false
|
||||
SortIncludes: Never
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
AccessModifierOffset: -4
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: BeforeHash
|
||||
NamespaceIndentation: None
|
||||
PointerAlignment: Left
|
||||
@@ -9,4 +9,6 @@ cmake-build-debug/
|
||||
.vs/
|
||||
.idea/
|
||||
.codex
|
||||
AGENTS.md
|
||||
compile_commands.json
|
||||
AGENTS.md
|
||||
CLAUDE.md
|
||||
@@ -1,19 +1,22 @@
|
||||
[submodule "external/glm"]
|
||||
path = external/glm
|
||||
url = https://github.com/g-truc/glm
|
||||
[submodule "external/imgui"]
|
||||
path = external/imgui
|
||||
url = https://github.com/ocornut/imgui
|
||||
branch = docking
|
||||
[submodule "external/tinyxml2"]
|
||||
path = external/tinyxml2
|
||||
url = https://github.com/leethomason/tinyxml2
|
||||
[submodule "external/SDL"]
|
||||
path = external/SDL
|
||||
url = https://github.com/libsdl-org/SDL.git
|
||||
[submodule "external/lunasvg"]
|
||||
path = external/lunasvg
|
||||
url = https://github.com/sammycage/lunasvg
|
||||
[submodule "external/SDL_mixer"]
|
||||
path = external/SDL_mixer
|
||||
url = https://github.com/libsdl-org/SDL_mixer
|
||||
[submodule "external/simdjson"]
|
||||
path = external/simdjson
|
||||
url = https://github.com/simdjson/simdjson
|
||||
[submodule "external/pugixml"]
|
||||
path = external/pugixml
|
||||
url = https://github.com/zeux/pugixml
|
||||
[submodule "external/doctest"]
|
||||
path = external/doctest
|
||||
url = https://github.com/doctest/doctest
|
||||
[submodule "external/stb"]
|
||||
path = external/stb
|
||||
url = https://github.com/nothings/stb
|
||||
@@ -1,28 +0,0 @@
|
||||
You are a senior level professional software developer, etc.
|
||||
|
||||
Use X Macros liberally and lookup tables (maps, etc.) for querying data, etc. Avoid functions for this purpose (i.e., don't map enums to strings with a function). Define X Macros in .cpp files if possible, headers if not.
|
||||
|
||||
Try to use structs/defines for data in general.
|
||||
|
||||
Prefer enums instead of bools for functions in cases where it makes sense (i.e., instead of true/false, have descriptive enums).
|
||||
|
||||
If user asks for "how to", or "why", that's an indicator to generate no code and simply answer their prompt.
|
||||
|
||||
Avoid hardcoding specific solutions and always see if there's ways to optimize/crunch down existing code to support whatever solution user is asking for. Your goal is the least lines/files for the same functionality, while maintaing most clarity/simplicy. Do not use comments.
|
||||
|
||||
Avoid use of anonymous namespaces. For namepsaces, try to have them match files; don't create superfluous namespaces within documents.
|
||||
|
||||
If an if statement has a single line inside, omit the braces.
|
||||
|
||||
Functions should use snake case and should typically be written like "[noun]_[verb]". Try and use a limited amount of verbs to describe functionality; "save", "load", etc.
|
||||
|
||||
For functions that check if true/false, write them like a question, starting with "is", i.e., "is_[noun]_[verb]".
|
||||
|
||||
|
||||
ImGui hidden labels, etc. that aren't user-facing should be typically like "##Name Here".
|
||||
|
||||
If a change is ordered that would impede past API, make it happen regardless without consideration of backwards compatibility.
|
||||
|
||||
With bools, ALWAYS name them "is[VariableName]", even if the variable would be gramatically incorrect.
|
||||
|
||||
When compiling/building, use as many threads as possible.
|
||||
@@ -1,235 +1,118 @@
|
||||
cmake_minimum_required(VERSION 3.27)
|
||||
project(anm2ed LANGUAGES C CXX)
|
||||
|
||||
if(WIN32 AND DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE
|
||||
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE STRING "Vcpkg toolchain file")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
if(CMAKE_EXPORT_COMPILE_COMMANDS AND NOT WIN32)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/compile_commands.json
|
||||
${CMAKE_SOURCE_DIR}/compile_commands.json)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug>:ProgramDatabase>")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||
|
||||
macro(anm2ed_set_cache_bool name value)
|
||||
set(${name} ${value} CACHE BOOL "" FORCE)
|
||||
endmacro()
|
||||
|
||||
anm2ed_set_cache_bool(SDL_STATIC ON)
|
||||
anm2ed_set_cache_bool(SDL_SHARED OFF)
|
||||
if(NOT WIN32)
|
||||
anm2ed_set_cache_bool(SDL_ALSA ON)
|
||||
anm2ed_set_cache_bool(SDL_ALSA_SHARED ON)
|
||||
anm2ed_set_cache_bool(SDL_JACK ON)
|
||||
anm2ed_set_cache_bool(SDL_JACK_SHARED ON)
|
||||
anm2ed_set_cache_bool(SDL_PIPEWIRE ON)
|
||||
anm2ed_set_cache_bool(SDL_PIPEWIRE_SHARED ON)
|
||||
anm2ed_set_cache_bool(SDL_SNDIO ON)
|
||||
anm2ed_set_cache_bool(SDL_SNDIO_SHARED ON)
|
||||
endif()
|
||||
anm2ed_set_cache_bool(SDL_HAPTIC OFF)
|
||||
anm2ed_set_cache_bool(SDL_JOYSTICK OFF)
|
||||
anm2ed_set_cache_bool(SDL_SENSOR OFF)
|
||||
anm2ed_set_cache_bool(SDL_HIDAPI OFF)
|
||||
anm2ed_set_cache_bool(SDL_CAMERA OFF)
|
||||
anm2ed_set_cache_bool(SDL_TRAY OFF)
|
||||
anm2ed_set_cache_bool(SDL_VULKAN OFF)
|
||||
add_subdirectory(external/SDL EXCLUDE_FROM_ALL)
|
||||
|
||||
anm2ed_set_cache_bool(SDLMIXER_DEPS_SHARED OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_AIFF OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_AU OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_FLAC_LIBFLAC OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_FLAC_DRFLAC OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_GME OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_MOD_XMP OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_MP3_DRMP3 OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_MP3_MPG123 OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_MIDI_FLUIDSYNTH OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_MIDI_TIMIDITY OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_OPUS ON)
|
||||
anm2ed_set_cache_bool(SDLMIXER_VOC OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_VORBIS_STB ON)
|
||||
anm2ed_set_cache_bool(SDLMIXER_VORBIS_VORBISFILE OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_VORBIS_TREMOR OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_WAVE ON)
|
||||
anm2ed_set_cache_bool(SDLMIXER_WAVPACK OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_TEST OFF)
|
||||
anm2ed_set_cache_bool(SDLMIXER_INSTALL OFF)
|
||||
add_subdirectory(external/SDL_mixer EXCLUDE_FROM_ALL)
|
||||
|
||||
add_subdirectory(external/lunasvg)
|
||||
|
||||
set(GLAD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/include/glad/glad.cpp)
|
||||
|
||||
set(IMGUI_SRC
|
||||
external/imgui/imgui.cpp
|
||||
external/imgui/imgui_draw.cpp
|
||||
external/imgui/imgui_widgets.cpp
|
||||
external/imgui/imgui_tables.cpp
|
||||
external/imgui/backends/imgui_impl_sdl3.cpp
|
||||
external/imgui/backends/imgui_impl_opengl3.cpp)
|
||||
|
||||
set(TINYXML2_SRC external/tinyxml2/tinyxml2.cpp)
|
||||
|
||||
file(GLOB PROJECT_SRC CONFIGURE_DEPENDS
|
||||
src/anm2/*.cpp
|
||||
src/anm2/*.hpp
|
||||
src/resource/*.cpp
|
||||
src/resource/*.hpp
|
||||
src/imgui/*.cpp
|
||||
src/imgui/*.hpp
|
||||
src/imgui/window/*.cpp
|
||||
src/imgui/window/*.hpp
|
||||
src/imgui/popup/*.cpp
|
||||
src/imgui/popup/*.hpp
|
||||
src/imgui/wizard/*.cpp
|
||||
src/imgui/wizard/*.hpp
|
||||
src/util/imgui/*.cpp
|
||||
src/util/imgui/*.hpp
|
||||
src/util/*.cpp
|
||||
src/util/*.hpp
|
||||
src/window/*.cpp
|
||||
src/window/*.hpp
|
||||
src/*.cpp
|
||||
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)
|
||||
|
||||
target_include_directories(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE include
|
||||
include/glad
|
||||
external
|
||||
external/imgui
|
||||
external/glm
|
||||
external/tinyxml2
|
||||
external/lunasvg
|
||||
external/SDL
|
||||
external/SDL_mixer
|
||||
external/SDL_mixer/include
|
||||
src
|
||||
src/imgui
|
||||
src/resource
|
||||
src/util)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
# Two builds: Release (the default) and Debug. Set before the libraries are added, so they're optimized too.
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE DEBUG)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
# Keep Release as a GUI app (no console window).
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
if(MSVC)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE /SUBSYSTEM:WINDOWS)
|
||||
else()
|
||||
target_link_options(${PROJECT_NAME} PRIVATE -mwindows)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -O0 -pg)
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -O3)
|
||||
endif()
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE m)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
enable_language(RC)
|
||||
target_sources(${PROJECT_NAME} PRIVATE anm2ed.rc)
|
||||
# Linux release builds: -O2, unused code and data dropped, and the symbols stripped.
|
||||
# Link-time optimization is left off: it made the binary bigger and every relink take seconds longer.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_compile_options("$<$<CONFIG:Release>:-O2;-ffunction-sections;-fdata-sections>")
|
||||
add_link_options("$<$<CONFIG:Release>:-Wl,--gc-sections;-s>")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /EHsc)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE /STACK:0xffffff)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /Zi)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE /DEBUG)
|
||||
endif()
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>" /EHsc)
|
||||
endif()
|
||||
|
||||
# SDL: static, with only video (OpenGL), audio, events, clipboard and file dialogs.
|
||||
# Its audio plays WAV and, through stb_vorbis, Ogg Vorbis.
|
||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
foreach(OPTION TEST_LIBRARY EXAMPLES RENDER GPU VULKAN OPENGLES CAMERA HAPTIC JOYSTICK HIDAPI SENSOR POWER TRAY
|
||||
OFFSCREEN KMSDRM DUMMYVIDEO DISKAUDIO DUMMYAUDIO OSS JACK SNDIO LIBURING)
|
||||
set(SDL_${OPTION} OFF CACHE BOOL "" FORCE)
|
||||
endforeach()
|
||||
add_subdirectory(external/SDL EXCLUDE_FROM_ALL)
|
||||
|
||||
set(LUNASVG_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(external/lunasvg EXCLUDE_FROM_ALL)
|
||||
|
||||
# simdjson: its single-file build, without exceptions, with only the AVX2 parser and the portable one.
|
||||
add_library(simdjson STATIC external/simdjson/singleheader/simdjson.cpp)
|
||||
target_compile_definitions(simdjson PUBLIC SIMDJSON_EXCEPTIONS=0 SIMDJSON_IMPLEMENTATION_ICELAKE=0
|
||||
SIMDJSON_IMPLEMENTATION_WESTMERE=0)
|
||||
|
||||
# Everything under resources/ is compiled in, through one generated C file (see embed.cmake).
|
||||
file(GLOB_RECURSE RESOURCES CONFIGURE_DEPENDS resources/*)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/embed/embed.c ${CMAKE_BINARY_DIR}/embed/embed.h
|
||||
COMMAND ${CMAKE_COMMAND} -DRESOURCES=${CMAKE_SOURCE_DIR}/resources -DOUTPUT=${CMAKE_BINARY_DIR}/embed
|
||||
-P ${CMAKE_SOURCE_DIR}/embed.cmake
|
||||
DEPENDS ${RESOURCES} ${CMAKE_SOURCE_DIR}/embed.cmake)
|
||||
|
||||
# The core: the model, edits, undo and file formats, with no window or OpenGL. The tests link it alone.
|
||||
file(GLOB CORE_SOURCES CONFIGURE_DEPENDS src/edit/*.cpp src/model/*.cpp)
|
||||
foreach(FILE log image audio_data asset_store file path math_util timestamp working_directory pack ui/multiselect
|
||||
snapshots playback selection)
|
||||
list(APPEND CORE_SOURCES src/${FILE}.cpp)
|
||||
endforeach()
|
||||
add_library(anm2ed_core STATIC ${CORE_SOURCES} external/pugixml/src/pugixml.cpp external/imgui/imgui.cpp
|
||||
external/imgui/imgui_draw.cpp external/imgui/imgui_widgets.cpp external/imgui/imgui_tables.cpp
|
||||
${CMAKE_BINARY_DIR}/embed/embed.c)
|
||||
target_include_directories(anm2ed_core PUBLIC external external/imgui external/stb src
|
||||
${CMAKE_BINARY_DIR}/embed)
|
||||
target_link_libraries(anm2ed_core PUBLIC lunasvg simdjson SDL3::Headers)
|
||||
target_compile_definitions(anm2ed_core PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
$<$<CONFIG:Debug>:IMGUI_DEBUG_PARANOID> $<$<BOOL:${WIN32}>:NOMINMAX>)
|
||||
|
||||
# The editor: the core with its window, OpenGL and interface. The render tests link it too.
|
||||
file(GLOB_RECURSE APP_SOURCES CONFIGURE_DEPENDS src/*.cpp)
|
||||
list(REMOVE_ITEM APP_SOURCES ${CORE_SOURCES} ${CMAKE_SOURCE_DIR}/src/main.cpp)
|
||||
set_source_files_properties(external/stb/stb_vorbis.c PROPERTIES COMPILE_OPTIONS -w)
|
||||
add_library(anm2ed_app STATIC ${APP_SOURCES} external/stb/stb_vorbis.c external/imgui/backends/imgui_impl_sdl3.cpp
|
||||
external/imgui/backends/imgui_impl_opengl3.cpp)
|
||||
if(WIN32)
|
||||
set(OPENGL_LIB opengl32)
|
||||
set(PLATFORM_LIBS
|
||||
ws2_32
|
||||
bcrypt
|
||||
imm32
|
||||
version
|
||||
winmm
|
||||
shell32
|
||||
ole32
|
||||
advapi32
|
||||
gdi32
|
||||
user32
|
||||
setupapi
|
||||
legacy_stdio_definitions)
|
||||
if(TARGET SDL3::SDL3main)
|
||||
set(SDL_MAIN_TARGET SDL3::SDL3main)
|
||||
else()
|
||||
set(SDL_MAIN_TARGET)
|
||||
endif()
|
||||
set(PLATFORM_LIBRARIES opengl32 ws2_32 bcrypt imm32 version winmm shell32 ole32 advapi32 gdi32 user32 setupapi
|
||||
$<$<BOOL:${MSVC}>:legacy_stdio_definitions>)
|
||||
else()
|
||||
set(OPENGL_LIB GL)
|
||||
set(PLATFORM_LIBS)
|
||||
set(SDL_MAIN_TARGET)
|
||||
set(PLATFORM_LIBRARIES GL)
|
||||
endif()
|
||||
target_link_libraries(anm2ed_app PUBLIC anm2ed_core SDL3::SDL3-static ${PLATFORM_LIBRARIES})
|
||||
|
||||
add_executable(anm2ed src/main.cpp $<$<BOOL:${WIN32}>:anm2ed.rc>)
|
||||
target_link_libraries(anm2ed PRIVATE anm2ed_app)
|
||||
set_target_properties(anm2ed PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
if(MSVC)
|
||||
target_link_options(anm2ed PRIVATE /STACK:0xffffff $<$<CONFIG:Release>:/SUBSYSTEM:WINDOWS>)
|
||||
elseif(WIN32)
|
||||
target_link_options(anm2ed PRIVATE $<$<CONFIG:Release>:-mwindows>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${OPENGL_LIB} SDL3-static ${SDL_MAIN_TARGET}
|
||||
SDL3_mixer::SDL3_mixer lunasvg ${PLATFORM_LIBS})
|
||||
|
||||
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "Project: ${PROJECT_NAME}")
|
||||
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
|
||||
|
||||
get_target_property(PROJECT_COMPILE_OPTIONS ${PROJECT_NAME} COMPILE_OPTIONS)
|
||||
if(NOT PROJECT_COMPILE_OPTIONS)
|
||||
set(PROJECT_COMPILE_OPTIONS "<none>")
|
||||
if(NOT MSVC)
|
||||
foreach(TARGET anm2ed_core anm2ed_app anm2ed)
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wpedantic -Wno-missing-field-initializers)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPER)
|
||||
set(EFFECTIVE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
if(BUILD_TYPE_UPPER)
|
||||
set(CONFIG_FLAGS_VAR "CMAKE_CXX_FLAGS_${BUILD_TYPE_UPPER}")
|
||||
if(DEFINED ${CONFIG_FLAGS_VAR})
|
||||
string(APPEND EFFECTIVE_CXX_FLAGS " ${${CONFIG_FLAGS_VAR}}")
|
||||
endif()
|
||||
endif()
|
||||
string(STRIP "${EFFECTIVE_CXX_FLAGS}" EFFECTIVE_CXX_FLAGS)
|
||||
if(EFFECTIVE_CXX_FLAGS STREQUAL "")
|
||||
set(EFFECTIVE_CXX_FLAGS "<none>")
|
||||
endif()
|
||||
option(ANM2ED_TESTS "Build the tests" ON)
|
||||
if(ANM2ED_TESTS)
|
||||
enable_testing()
|
||||
set(TEST_DIRECTORY ${CMAKE_SOURCE_DIR}/tests)
|
||||
|
||||
message(STATUS "Compiler Flags: ${EFFECTIVE_CXX_FLAGS}")
|
||||
message(STATUS "Target Compile Options: ${PROJECT_COMPILE_OPTIONS}")
|
||||
message(STATUS "Build: ${CMAKE_BUILD_TYPE}")
|
||||
file(GLOB TEST_SOURCES CONFIGURE_DEPENDS tests/*.cpp)
|
||||
add_executable(anm2ed_tests ${TEST_SOURCES})
|
||||
target_link_libraries(anm2ed_tests PRIVATE anm2ed_core)
|
||||
target_include_directories(anm2ed_tests PRIVATE external/doctest/doctest)
|
||||
target_compile_definitions(anm2ed_tests PRIVATE ANM2ED_TEST_DIR="${TEST_DIRECTORY}")
|
||||
add_test(NAME anm2ed_tests COMMAND anm2ed_tests WORKING_DIRECTORY ${TEST_DIRECTORY})
|
||||
|
||||
# Drawing needs OpenGL (skipped without a display). Renders land in build/renders for a look.
|
||||
file(GLOB RENDER_TEST_SOURCES CONFIGURE_DEPENDS tests/render/*.cpp)
|
||||
add_executable(anm2ed_render_tests tests/main.cpp ${RENDER_TEST_SOURCES})
|
||||
target_link_libraries(anm2ed_render_tests PRIVATE anm2ed_app)
|
||||
target_include_directories(anm2ed_render_tests PRIVATE external/doctest/doctest tests)
|
||||
target_compile_definitions(anm2ed_render_tests PRIVATE ANM2ED_TEST_DIR="${TEST_DIRECTORY}"
|
||||
ANM2ED_RENDER_DIR="${CMAKE_BINARY_DIR}/renders")
|
||||
add_test(NAME anm2ed_render_tests COMMAND anm2ed_render_tests WORKING_DIRECTORY ${TEST_DIRECTORY})
|
||||
add_test(NAME anm2ed_cli_info COMMAND anm2ed info ${TEST_DIRECTORY}/render/spin.anm2)
|
||||
endif()
|
||||
@@ -2,27 +2,24 @@
|
||||
|
||||

|
||||
|
||||
A reimplementation of *The Binding of Isaac: Rebirth*'s proprietary animation editor. Manipulates the XML-based ".anm2" format, used for in-game tweened animations.
|
||||
Anm2Ed is a modern editor for *The Binding of Isaac: Rebirth*'s XML-based `.anm2` animation format. It is built as an extended, more comfortable replacement for the original proprietary animation editor, with a dockable Dear ImGui interface and tools aimed at both quick edits and larger animation workflows.
|
||||
|
||||
### Clarification
|
||||
This application was developed with the assistance of a large language model.
|
||||
|
||||
## Features
|
||||
- Extended version of the original proprietary Nicalis animation editor
|
||||
- Smooth [Dear ImGui](https://github.com/ocornut/imgui) interface; docking, dragging and dropping, etc. You might be familiar with it from [Repentogon](https://repentogon.com/).
|
||||
- Greatly polished in many areas, to assist with all your animating needs
|
||||
- New features
|
||||
- Additional hotkeys/shortcuts (rebindable!)
|
||||
- Additional wizard options
|
||||
- Broadened sound support
|
||||
- Can output .webm, .mp4 or *.png sequence (wih FFmpeg)
|
||||
- Cutting, copying and pasting
|
||||
- Onionskinning
|
||||
- Spritesheet "regions"; pre-set areas to be reused
|
||||
- Robust snapshot (undo/redo) system
|
||||
- Selecting multiple frames at a time
|
||||
- Settings that will preserve on exit (stored in %APPDATA% on Windows or ~/.local/share on Linux)
|
||||
- Texture packing
|
||||
- Full `.anm2` editing: spritesheets (PNG or SVG), regions, layers, nulls, events, sounds, shaders, animations, frames and triggers (several events each).
|
||||
- Animation layers: a layer can play another animation, from the same file or a linked library (`.anm2`), with per-keyframe loop/once/hold, start frame and restart. The timeline shows the child's tracks under the layer; double-click to edit the child in place, with a breadcrumb back out.
|
||||
- Dockable [Dear ImGui](https://github.com/ocornut/imgui) interface (windows can be detached into their own) with persistent layout, drag and drop, context menus and rebindable shortcuts.
|
||||
- Timeline: multi-select, cut/copy/paste (whole frames or single properties), duplicate, split, bake, drag to move/resize, and start/end markers to loop a range.
|
||||
- Groups for animations, layers and nulls, with group transforms baked for the game on save.
|
||||
- Frame properties for crop, size, position, pivot, scale, skew, rotation, depth, tint, color offset (with alpha), blur (Flash's blur filter), region, shader, visibility, interpolation (including easing) and flips; batch changes across selections.
|
||||
- Spritesheet editor with pan, move, crop, draw, erase and color picker tools; regions; packing, merging, trimming; spritesheets and libraries reload when their files change on disk.
|
||||
- Animation preview with grid, axes, pivots, borders, onionskin (with pivot paths), and another document's animation as an overlay.
|
||||
- Wizards: generate animations from a grid, generate regions, change all frame properties, merge animations and files.
|
||||
- Render to video, GIF, spritesheet or PNG sequence (FFmpeg), with trigger sounds.
|
||||
- Saves write the game's format with the editor's own copy embedded (`SourceDocument`), so nothing is lost; animation layers are flattened for the game, and anything else the game doesn't support is warned about first. Documents can instead be saved as the editor's own, human-readable JSON ([format](docs/json_format.md)), which opens like any `.anm2`.
|
||||
- Undo/redo, autosave (spritesheet edits included) with crash restore, and overwrite warnings.
|
||||
|
||||
### Supported Languages
|
||||
- English
|
||||
@@ -31,28 +28,40 @@ This application was developed with the assistance of a large language model.
|
||||
- 中文 (Chinese)
|
||||
- 한국어 (Korean)
|
||||
|
||||
**If you want to help localize for your language, feel free to get in touch to contribute!**
|
||||
**If you want to help localize for your language, feel free to get in touch to contribute.**
|
||||
|
||||
### Note: Rendering Animations
|
||||
You will need FFmpeg installed to output GIF/video! Get it from [here](https://ffmpeg.org/download.html), and point to the downloaded ffmpeg executable within the program!
|
||||
### Rendering Animations
|
||||
FFmpeg is required for video/GIF-style export. Download it from [ffmpeg.org](https://ffmpeg.org/download.html), then point Anm2Ed to the `ffmpeg` executable in the render window.
|
||||
|
||||
## Build
|
||||
|
||||
After cloning and enter the repository's directory, make sure to initialize the submodules:
|
||||
After cloning and entering the repository directory, initialize the submodules:
|
||||
|
||||
```git submodule update --init --recursive```
|
||||
```sh
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
### Windows
|
||||
Visual Studio is recommended for build.
|
||||
Visual Studio is recommended.
|
||||
|
||||
### Linux
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```sh
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build -j
|
||||
```
|
||||
|
||||
## Happy animating!
|
||||

|
||||
### Tests
|
||||
```sh
|
||||
ctest --test-dir build
|
||||
```
|
||||
Render tests draw with OpenGL (skipped without a display) and leave their images in `build/renders`.
|
||||
|
||||
## Command Line
|
||||
`anm2ed <command>` looks at a file without opening the editor, drawing with the editor's renderer:
|
||||
```sh
|
||||
anm2ed info file.anm2 # animations, items, spritesheets, Isaac issues
|
||||
anm2ed frame file.anm2 --out frame.png --time 4 # one frame
|
||||
anm2ed render file.anm2 --out sheet.png --scale 3 # every frame in a grid (--type pngs|gif|webm|mp4|ogv)
|
||||
```
|
||||
Common options: `--animation NAME|INDEX`, `--scale`, `--fps`, `--start`/`--end`, `--background RRGGBB`, `--ffmpeg PATH` (defaults to the editor's FFmpeg setting). `anm2ed render` alone lists them all.
|
||||
@@ -1 +0,0 @@
|
||||
/home/anon/sda/Personal/Repos/anm2ed/out/build/linux-release/compile_commands.json
|
||||
@@ -0,0 +1,200 @@
|
||||
# Anm2Ed JSON format
|
||||
|
||||
The JSON format is the editor's own document, saved alone when **Save as JSON** is on (Configure → Serialization). It holds everything the editor knows about a document; the game can't read it. This page lists its shape and how the editor plays it, so that a converter or a game's loader can match the editor exactly.
|
||||
|
||||
A regular save is different: it writes the game's `.anm2` XML, with the editor's copy embedded as `<SourceDocument>`. See [XML saves](#xml-saves).
|
||||
|
||||
## Recognizing one
|
||||
```json
|
||||
{
|
||||
"info": {"createdBy": "…", "createdOn": "2026-01-01T12:00:00", "fps": 30, "version": 2},
|
||||
…
|
||||
}
|
||||
```
|
||||
- **A file is JSON** when its first character, after whitespace, is `{`. There is no format version.
|
||||
- **Defaults are left out.** Any key missing from an object has its default (listed below).
|
||||
- **Ids are indices.** An item is referred to by its position in its array, starting at 0.
|
||||
- **Unknown keys, wrong types, unknown values and out-of-range indices** are reported by where they are (e.g. `animations.Idle.layers[0].frames[2].pos: expected an array of 2 numbers`); the document still opens, with the default in their place.
|
||||
- **`createdOn`** is ISO 8601 local time.
|
||||
- **`info.isaacIgnored`** is `true` when the document was last saved with Ignore and Save; see [XML saves](#xml-saves).
|
||||
|
||||
## Content
|
||||
```json
|
||||
"sheets": [
|
||||
{"path": "parts.png"},
|
||||
{
|
||||
"path": "body.svg",
|
||||
"regions": [
|
||||
{"name": "head", "crop": [48, 0], "size": [32, 32], "pivot": [16, 16], "origin": "center"}
|
||||
]
|
||||
}
|
||||
],
|
||||
"shaders": [
|
||||
{"name": "glow", "vertex": "glow.vs", "fragment": "glow.fs", "uniforms": [{"name": "strength", "value": "0.5"}]}
|
||||
],
|
||||
"libraries": [
|
||||
"shared/shadows.anm2"
|
||||
],
|
||||
"layers": [
|
||||
{"name": "torso", "sheet": 1},
|
||||
{"name": "hx", "animation": "Head"},
|
||||
{"name": "shadow", "library": 0, "animation": "SmallShadow"}
|
||||
],
|
||||
"nulls": [
|
||||
{"name": "hitbox", "showRect": true}
|
||||
],
|
||||
"events": [
|
||||
"shoot",
|
||||
"done"
|
||||
],
|
||||
"sounds": [
|
||||
"sounds/step.ogg"
|
||||
]
|
||||
```
|
||||
|
||||
| Item | Key | Default | Meaning |
|
||||
|---|---|---|---|
|
||||
| Sheet | `path` | | The image, relative to the document. |
|
||||
| Region | `name` | `""` | |
|
||||
| | `crop`, `size`, `pivot` | `[0, 0]` | The rectangle in the spritesheet, and its pivot. |
|
||||
| | `origin` | custom | `topLeft` or `center` sets the pivot from the size. |
|
||||
| Shader | `name`, `vertex`, `fragment` | `""` | A custom shader and its source files. |
|
||||
| | `uniforms` | none | `{ name, binding, value, components: [ { index, binding, value } ] }` |
|
||||
| Layer | `name` | `""` | The name code should use for the layer (or its instance). |
|
||||
| | `sheet` | `0` | Its spritesheet; `-1` for one that is missing. |
|
||||
| | `animation` | none | Makes it an animation layer, playing this animation. |
|
||||
| | `library` | none | Where `animation` comes from; none means this file. |
|
||||
| Null | `name` | `""` | |
|
||||
| | `showRect` | `false` | |
|
||||
| Event, sound, library | | | A name, or a path relative to the document. |
|
||||
|
||||
**SVG spritesheets**
|
||||
- A spritesheet whose path ends in `.svg` is an SVG.
|
||||
- One SVG unit is one pixel. Crops, sizes and pivots are in SVG units.
|
||||
- The editor draws an SVG at whatever resolution it is shown at.
|
||||
|
||||
**Libraries**
|
||||
- A library is another `.anm2` (XML or JSON) whose animations layers can play.
|
||||
- A path is relative to the file that names it, so a library's own libraries are relative to that library.
|
||||
|
||||
**Layers**
|
||||
- A layer either shows its spritesheet, or plays an animation when `animation` is set.
|
||||
- **No self-nesting:** an animation never plays inside itself, even through other animations. That draw is skipped.
|
||||
|
||||
## Animations
|
||||
Animations are an object keyed by their name; names are unique (a repeated one is saved as `"Name 2"`, `"Name 3"`…). A key whose object has an `animations` object is a group of animations; a group may share a name with an animation inside it.
|
||||
```json
|
||||
"default": "Walk",
|
||||
"animations": {
|
||||
"Walk": {
|
||||
"length": 24, "markers": [4, 19],
|
||||
"root": […frames…],
|
||||
"layers": [
|
||||
{"layer": 0, "frames": […frames…]},
|
||||
{"group": "arms", "root": […frames…], "layers": [{"layer": 3, "frames": […]}]}
|
||||
],
|
||||
"nulls": [{"null": 0, "frames": […]}],
|
||||
"triggers": [
|
||||
{"at": 12, "events": [0], "sounds": [0]},
|
||||
{"at": 23, "events": [0, 1]}
|
||||
]
|
||||
},
|
||||
"Combat": {"expanded": false, "animations": {"Attack": {…}}}
|
||||
}
|
||||
```
|
||||
|
||||
| Key | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `length` | `1` | Frames in the animation. |
|
||||
| `loop` | `true` | |
|
||||
| `markers` | `[-1, -1]` | Start and end frames editor playback stays between, inclusive; `-1` for none. Editor-only. |
|
||||
| `root`, `triggers` | none | Frame arrays. |
|
||||
| `layers`, `nulls` | none | Tracks and groups, in order. |
|
||||
| Track `layer` / `null` | | The item the track animates. |
|
||||
| Track `visible` | `true` | |
|
||||
| Group `group` | | The group's name; always present. |
|
||||
| Group `expanded`, `visible` | `true` | Timeline state. |
|
||||
| Group `root` | one default frame | A transform applied to its tracks after the animation's root. |
|
||||
| Trigger `at` | | The frame it fires on. |
|
||||
| Trigger `events` | none | Every event fires on `at`. |
|
||||
| Trigger `sounds` | none | The editor picks one at random. |
|
||||
|
||||
**Layer order**
|
||||
- Layers draw in `layers` order: the first one is drawn first, so it ends up at the bottom.
|
||||
- `depth` on a layer frame moves it among the layers for that frame. The sort key is (position in the list + depth, depth).
|
||||
|
||||
## Frames
|
||||
Keys on a frame of a layer, null or root track:
|
||||
|
||||
| Key | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `pos` | `[0, 0]` | Position in pixels; y points down. |
|
||||
| `region` | none | Layer frames: a region of the layer's spritesheet. The frame takes its crop, size and pivot, and has none of its own. |
|
||||
| `crop`, `size` | `[0, 0]` | Layer frames without a region: the spritesheet rectangle. |
|
||||
| `pivot` | `[0, 0]` | Layer frames without a region: the pivot in the frame's pixels. |
|
||||
| `scale` | `[100, 100]` | Percent. A negative value flips. |
|
||||
| `rotation` | `0` | Degrees, clockwise on screen. |
|
||||
| `skew` | `[0, 0]` | Percent: `x' = x + skew.x/100·y`, `y' = y + skew.y/100·x`. |
|
||||
| `tint` | `[255, 255, 255, 255]` | RGBA, multiplied. |
|
||||
| `offset` | `[0, 0, 0, 0]` | RGBA, added after the tint. Alpha may be negative; the result is clamped to 0–1. |
|
||||
| `blur` | `0` | Layer frames: Flash's low-quality BlurFilter, a box this many canvas pixels wide, averaged over the frame's crop. |
|
||||
| `depth` | `0` | Layer frames; see Layer order. |
|
||||
| `shader` | none | A custom shader from `shaders`. |
|
||||
| `delay` | `1` | Duration in frames. |
|
||||
| `visible` | `true` | Hidden frames draw nothing. |
|
||||
| `ease` | none | `lerp`, `in` (t²), `out` (1−(1−t)²) or `inOut`. It blends position, scale, skew, rotation, tint, color offset and blur toward the next frame. |
|
||||
|
||||
**A layer frame's transform.** A point `p` of the spritesheet crop, in pixels, lands at:
|
||||
```
|
||||
world = Root · GroupRoot · ( pos + Flip · Rotate · Skew · |scale| · (p − pivot) )
|
||||
```
|
||||
- `Flip` holds the signs of the scale. When exactly one axis is flipped, the rotation turns the other way.
|
||||
- A root's transform is `pos + Flip · Rotate · Skew · |scale| · p`. A root has no pivot.
|
||||
|
||||
### Animation layer frames
|
||||
On a layer that plays an animation, a frame places the child, and its `child` object plays it. The object is left out when all its keys are defaults:
|
||||
```json
|
||||
{"pos": [8, 0], "child": {"name": "Spin", "mode": "once", "start": 3}}
|
||||
```
|
||||
|
||||
| Key | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `name` | the layer's | The animation this keyframe plays, from the same file or library. |
|
||||
| `mode` | `loop` | `loop`, `once` (stops on its last frame) or `hold` (stays on the start frame). |
|
||||
| `start` | `0` | The child's frame when its clock starts. |
|
||||
| `random` | `false` | Start on a random frame instead. |
|
||||
| `restart` | `false` | Restarts the child's clock at this keyframe. |
|
||||
|
||||
**Placement.** The child's whole drawing goes through the frame's transform, with the frame's pivot as the child's origin:
|
||||
```
|
||||
world = Root · GroupRoot · ( pos + Flip · Rotate · Skew · |scale| · (q − pivot) )
|
||||
```
|
||||
- `q` is a point in the child's space, after the child's own root and groups.
|
||||
- **Colour:** the frame's tint multiplies the child's colour, and its offset adds to it.
|
||||
- **Unused keys:** crop, size, region and shader are not used.
|
||||
|
||||
**Timing.** The child's time when the parent is at time `t`:
|
||||
1. **Clock start.** The child's clock starts at the first keyframe. It restarts at any keyframe with `restart`, or whose `name` differs from the previous keyframe's. Each start begins at that keyframe's `start`.
|
||||
2. **Child time.** Take the start keyframe that most recently began (call its frame `S` and its `start` `C`). The child time is `C + (t − S)`.
|
||||
3. **Mode.** The keyframe playing at `t` decides the mode:
|
||||
- `loop` wraps the time over the child's `length`.
|
||||
- `once` stops at `length − 1`.
|
||||
- `hold` uses that keyframe's own `start`.
|
||||
4. **Random start.** A random start is `(layerIndex·73856093 xor keyframeIndex·19349663) mod length`, using unsigned 32-bit arithmetic.
|
||||
|
||||
**Child triggers.** A child fires its trigger on each frame it reaches. That is the frames where its whole-number time, or its animation, differs from the previous parent frame's, and always on parent frame 0. A held child fires once.
|
||||
|
||||
## XML saves
|
||||
A regular save writes the game's `.anm2` XML, keeping only what the game reads, followed by the editor's full copy as `<SourceDocument>` (the same data as the JSON, in XML):
|
||||
- **Default colors** (tints of 255, color offsets of 0) are left out of both copies, since readers assume them.
|
||||
- **Animation layers** are flattened into plain layers, one per layer the child draws, named `layer/childLayer`. Their frames are baked one per frame and skew is dropped. A library's spritesheets are added with paths relative to the document.
|
||||
- **Children's trigger events** join the animation's triggers, matched by name.
|
||||
- **Triggers** keep one event each: the first.
|
||||
- **Depth** is stood in for by copies of the layer, named for the depth (`body (depth +1)`), placed where the editor draws it, and each showing only the frames at its depth. Groups in such an animation have their roots baked into their tracks.
|
||||
- **Alpha offsets** join the alpha tint (clamped), which matches on opaque pixels.
|
||||
- **Skew, blur and shaders** are baked: each layer frame using one is drawn alone at 1x into `<name>.baked.png` beside the save (identical images once), and stands on a copy of its layer (`body (baked)`, on that spritesheet) right after it, one frame per step, while the layer hides those frames. A shaded frame's tint and color offset go into its image; others keep theirs. A skewed root (or group root) goes into its layers' images, and becomes plain; nulls take its transform without the skew. Children of animation layers are flattened first, without their skew. Baking needs OpenGL (`convert` makes a context); without it, these are dropped. Autosaves don't bake.
|
||||
- These are what **Convert and Save** does; **Ignore and Save**, in the save's Isaac compatibility warning, leaves them out. The document remembers which (`info.isaacIgnored`) for saves that don't ask (the warning turned off, or `convert`).
|
||||
- **Dropped attributes:** markers, extra events, trigger sounds and libraries.
|
||||
- **SVG spritesheets** are offered for conversion to PNGs before saving.
|
||||
|
||||
Older editor files saved without a game copy (the former extended format) still open, and are written as above when saved again.
|
||||
@@ -0,0 +1,25 @@
|
||||
# Writes every file under RESOURCES into one C source as a byte array, with a header naming each as an Embed.
|
||||
# resources/icon/folder_open.svg becomes ICON_FOLDER_OPEN_SVG.
|
||||
# Each array ends in a zero not counted in its size, so text can be read as a C string.
|
||||
# Run as a script: cmake -DRESOURCES=<directory> -DOUTPUT=<directory> -P embed.cmake
|
||||
file(GLOB_RECURSE FILES RELATIVE ${RESOURCES} ${RESOURCES}/*)
|
||||
list(FILTER FILES EXCLUDE REGEX "LICENSE")
|
||||
list(SORT FILES)
|
||||
|
||||
set(HEADER "#pragma once\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\nstruct Embed\n{\n const unsigned char* data;\n unsigned int size;\n};\n\n")
|
||||
set(SOURCE "#include \"embed.h\"\n\n")
|
||||
foreach(FILE ${FILES})
|
||||
string(MAKE_C_IDENTIFIER ${FILE} NAME)
|
||||
string(TOUPPER ${NAME} NAME)
|
||||
file(READ ${RESOURCES}/${FILE} BYTES HEX)
|
||||
string(REGEX REPLACE "(..)" "0x\\1," BYTES "${BYTES}")
|
||||
string(APPEND HEADER "extern const struct Embed ${NAME};\n")
|
||||
string(APPEND SOURCE "static const unsigned char ${NAME}_DATA[] = {${BYTES}0};\n")
|
||||
string(APPEND SOURCE "const struct Embed ${NAME} = {${NAME}_DATA, sizeof(${NAME}_DATA) - 1};\n")
|
||||
endforeach()
|
||||
string(APPEND HEADER "\n#ifdef __cplusplus\n}\n#endif\n")
|
||||
|
||||
# The header is only replaced when it changes, so editing a resource doesn't rebuild what includes it.
|
||||
file(WRITE ${OUTPUT}/embed.h.new "${HEADER}")
|
||||
file(COPY_FILE ${OUTPUT}/embed.h.new ${OUTPUT}/embed.h ONLY_IF_DIFFERENT)
|
||||
file(WRITE ${OUTPUT}/embed.c "${SOURCE}")
|
||||
@@ -1,311 +0,0 @@
|
||||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
# define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
# define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
/*
|
||||
* To support platform where unsigned long cannot be used interchangeably with
|
||||
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
|
||||
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
|
||||
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
|
||||
* unsigned long long or similar (this results in different C++ name mangling).
|
||||
* To avoid changes for existing platforms, we restrict usage of intptr_t to
|
||||
* platforms where the size of a pointer is larger than the size of long.
|
||||
*/
|
||||
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
|
||||
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
|
||||
#define KHRONOS_USE_INTPTR_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef KHRONOS_USE_INTPTR_T
|
||||
typedef intptr_t khronos_intptr_t;
|
||||
typedef uintptr_t khronos_uintptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
||||
@@ -1,147 +0,0 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// DEAR IMGUI COMPILE-TIME OPTIONS
|
||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
|
||||
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
|
||||
//-----------------------------------------------------------------------------
|
||||
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
||||
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||
// Call IMGUI_CHECKVERSION() from your .cpp file to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
// - If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
// - Compiling with NDEBUG will usually strip out assert() to nothing, which is NOT recommended because we use asserts to notify of programmer mistakes.
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
|
||||
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// - Windows DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
//#define IMGUI_API __declspec(dllexport) // MSVC Windows: DLL export
|
||||
//#define IMGUI_API __declspec(dllimport) // MSVC Windows: DLL import
|
||||
//#define IMGUI_API __attribute__((visibility("default"))) // GCC/Clang: override visibility when set is hidden
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows/tools.
|
||||
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
|
||||
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
|
||||
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty.
|
||||
|
||||
//---- Don't implement some functions to reduce linkage requirements.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
||||
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS // Don't implement default platform_io.Platform_OpenInShellFn() handler (Win32: ShellExecute(), require shell32.lib/.a, Mac/Linux: use system("")).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
//#define IMGUI_DISABLE_DEFAULT_FONT // Disable default embedded font (ProggyClean.ttf), remove ~9.5 KB from output binary. AddFontDefault() will assert.
|
||||
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||
|
||||
//---- Enable Test Engine / Automation features.
|
||||
//#define IMGUI_ENABLE_TEST_ENGINE // Enable imgui_test_engine hooks. Generally set automatically by include "imgui_te_config.h", see Test Engine for details.
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||
// May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included.
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
//#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h"
|
||||
|
||||
//---- Pack vertex colors as BGRA8 instead of RGBA8 (to avoid converting from one to another). Need dedicated backend support.
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Use legacy CRC32-adler tables (used before 1.91.6), in order to preserve old .ini data that you cannot afford to invalidate.
|
||||
//#define IMGUI_USE_LEGACY_CRC32_ADLER
|
||||
|
||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
|
||||
//#define IMGUI_USE_WCHAR32
|
||||
|
||||
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
||||
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
|
||||
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
||||
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
||||
//#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if IMGUI_USE_STB_SPRINTF is defined.
|
||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION // only disabled if IMGUI_USE_STB_SPRINTF is defined.
|
||||
|
||||
//---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
|
||||
// Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h.
|
||||
//#define IMGUI_USE_STB_SPRINTF
|
||||
|
||||
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
|
||||
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
|
||||
// Note that imgui_freetype.cpp may be used _without_ this define, if you manually call ImFontAtlas::SetFontLoader(). The define is simply a convenience.
|
||||
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
||||
//#define IMGUI_ENABLE_FREETYPE
|
||||
|
||||
//---- Use FreeType + plutosvg or lunasvg to render OpenType SVG fonts (SVGinOT)
|
||||
// Only works in combination with IMGUI_ENABLE_FREETYPE.
|
||||
// - plutosvg is currently easier to install, as e.g. it is part of vcpkg. It will support more fonts and may load them faster. See misc/freetype/README for instructions.
|
||||
// - Both require headers to be available in the include path + program to be linked with the library code (not provided).
|
||||
// - (note: lunasvg implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement)
|
||||
//#define IMGUI_ENABLE_FREETYPE_PLUTOSVG
|
||||
//#define IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||
|
||||
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
||||
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
|
||||
//#define IMGUI_ENABLE_STB_TRUETYPE
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
/*
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \
|
||||
operator MyVec2() const { return MyVec2(x,y); }
|
||||
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
//---- ...Or use Dear ImGui's own very basic math operators.
|
||||
//#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
|
||||
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
|
||||
//struct ImDrawList;
|
||||
//struct ImDrawCmd;
|
||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||
//#define ImDrawCallback MyImDrawCallback
|
||||
|
||||
//---- Debug Tools: Macro to break in Debugger (we provide a default implementation of this in the codebase)
|
||||
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||
//#define IM_DEBUG_BREAK __debugbreak()
|
||||
|
||||
//---- Debug Tools: Enable highlight ID conflicts _before_ hovering items. When io.ConfigDebugHighlightIdConflicts is set.
|
||||
// (THIS WILL SLOW DOWN DEAR IMGUI. Only use occasionally and disable after use)
|
||||
//#define IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS
|
||||
|
||||
//---- Debug Tools: Enable slower asserts
|
||||
//#define IMGUI_DEBUG_PARANOID
|
||||
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files)
|
||||
/*
|
||||
namespace ImGui
|
||||
{
|
||||
void MyFunction(const char* name, MyMatrix44* mtx);
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,94 @@
|
||||
Copyright 2018 The Noto Project Authors (github.com/noto-fonts/noto-fonts)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License,
|
||||
Version 1.1.
|
||||
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font
|
||||
creation efforts of academic and linguistic communities, and to
|
||||
provide a free and open framework in which fonts may be shared and
|
||||
improved in partnership with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply to
|
||||
any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software
|
||||
components as distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to,
|
||||
deleting, or substituting -- in part or in whole -- any of the
|
||||
components of the Original Version, by changing formats or by porting
|
||||
the Font Software to a new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed,
|
||||
modify, redistribute, and sell modified and unmodified copies of the
|
||||
Font Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components, in
|
||||
Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the
|
||||
corresponding Copyright Holder. This restriction only applies to the
|
||||
primary font name as presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created using
|
||||
the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
<AnimatedActor>
|
||||
<Info CreatedBy="robot" CreatedOn="05/21/2026 09:25:40 PM" Fps="30" Version="0"/>
|
||||
<Content>
|
||||
<Spritesheets>
|
||||
<Spritesheet Id="0" Path="ash.png">
|
||||
<Region Id="0" Name="1" XCrop="1" YCrop="51" Width="52" Height="28" XPivot="25" YPivot="28"/>
|
||||
<Region Id="1" Name="2" XCrop="1" YCrop="1" Width="48" Height="48" XPivot="24" YPivot="48"/>
|
||||
</Spritesheet>
|
||||
</Spritesheets>
|
||||
<Layers>
|
||||
<Layer Id="0" Name="Main" SpritesheetId="0"/>
|
||||
</Layers>
|
||||
<Nulls/>
|
||||
<Events/>
|
||||
</Content>
|
||||
<Animations DefaultAnimation="Main">
|
||||
<Animation Name="Main" FrameNum="9" Loop="true">
|
||||
<RootAnimation>
|
||||
<Frame XPosition="0" YPosition="0" Delay="9" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
|
||||
</RootAnimation>
|
||||
<LayerAnimations>
|
||||
<LayerAnimation LayerId="0" Visible="true">
|
||||
<Frame RegionId="1" XPivot="24" YPivot="48" XCrop="1" YCrop="1" Width="48" Height="48" XPosition="1" YPosition="-4" Delay="3" Visible="true" XScale="95" YScale="105" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="0" XPivot="25" YPivot="28" XCrop="1" YCrop="51" Width="52" Height="28" XPosition="1" YPosition="-4" Delay="5" Visible="true" XScale="105" YScale="95" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="24" YPivot="48" XCrop="1" YCrop="1" Width="48" Height="48" XPosition="1" YPosition="-4" Delay="1" Visible="true" XScale="90" YScale="110" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
</LayerAnimations>
|
||||
<NullAnimations/>
|
||||
<Triggers/>
|
||||
</Animation>
|
||||
</Animations>
|
||||
</AnimatedActor>
|
||||
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,36 @@
|
||||
|
||||
<AnimatedActor>
|
||||
<Info CreatedBy="robot" CreatedOn="05/21/2026 11:54:09 PM" Fps="30" Version="0"/>
|
||||
<Content>
|
||||
<Spritesheets>
|
||||
<Spritesheet Id="0" Path="isaac.png">
|
||||
<Region Id="0" Name="1" XCrop="1" YCrop="36" Width="28" Height="34" XPivot="14" YPivot="34"/>
|
||||
<Region Id="1" Name="2" XCrop="1" YCrop="1" Width="30" Height="33" XPivot="15" YPivot="33"/>
|
||||
<Region Id="2" Name="3" XCrop="31" YCrop="36" Width="28" Height="34" XPivot="15" YPivot="34"/>
|
||||
</Spritesheet>
|
||||
</Spritesheets>
|
||||
<Layers>
|
||||
<Layer Id="0" Name="Main" SpritesheetId="0"/>
|
||||
</Layers>
|
||||
<Nulls/>
|
||||
<Events/>
|
||||
</Content>
|
||||
<Animations DefaultAnimation="Main">
|
||||
<Animation Name="Main" FrameNum="14" Loop="true">
|
||||
<RootAnimation>
|
||||
<Frame XPosition="0" YPosition="0" Delay="14" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
|
||||
</RootAnimation>
|
||||
<LayerAnimations>
|
||||
<LayerAnimation LayerId="0" Visible="true">
|
||||
<Frame RegionId="0" XPivot="14" YPivot="34" XCrop="1" YCrop="36" Width="28" Height="34" XPosition="2" YPosition="0" Delay="5" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="15" YPivot="33" XCrop="1" YCrop="1" Width="30" Height="33" XPosition="2" YPosition="0" Delay="2" Visible="true" XScale="110" YScale="90" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="2" XPivot="15" YPivot="34" XCrop="31" YCrop="36" Width="28" Height="34" XPosition="2" YPosition="0" Delay="5" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="15" YPivot="33" XCrop="1" YCrop="1" Width="30" Height="33" XPosition="2" YPosition="0" Delay="2" Visible="true" XScale="110" YScale="90" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
</LayerAnimations>
|
||||
<NullAnimations/>
|
||||
<Triggers/>
|
||||
</Animation>
|
||||
</Animations>
|
||||
</AnimatedActor>
|
||||
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,49 @@
|
||||
|
||||
<AnimatedActor>
|
||||
<Info CreatedBy="robot" CreatedOn="05/21/2026 11:07:19 PM" Fps="30" Version="0"/>
|
||||
<Content>
|
||||
<Spritesheets>
|
||||
<Spritesheet Id="0" Path="meatboy.png">
|
||||
<Region Id="0" Name="Head" XCrop="1" YCrop="1" Width="41" Height="33" Origin="Center"/>
|
||||
<Region Id="1" Name="Arms" XCrop="1" YCrop="36" Width="24" Height="12" Origin="Center"/>
|
||||
<Region Id="2" Name="Legs" XCrop="27" YCrop="36" Width="31" Height="9" Origin="Center"/>
|
||||
</Spritesheet>
|
||||
</Spritesheets>
|
||||
<Layers>
|
||||
<Layer Id="0" Name="Head" SpritesheetId="0"/>
|
||||
<Layer Id="1" Name="Arms" SpritesheetId="0"/>
|
||||
<Layer Id="2" Name="Legs" SpritesheetId="0"/>
|
||||
</Layers>
|
||||
<Nulls/>
|
||||
<Events/>
|
||||
</Content>
|
||||
<Animations DefaultAnimation="Main">
|
||||
<Animation Name="Main" FrameNum="14" Loop="true">
|
||||
<RootAnimation>
|
||||
<Frame XPosition="0" YPosition="0" Delay="14" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
|
||||
</RootAnimation>
|
||||
<LayerAnimations>
|
||||
<LayerAnimation LayerId="2" Visible="true">
|
||||
<Frame RegionId="2" XPivot="15" YPivot="4" XCrop="27" YCrop="36" Width="31" Height="9" XPosition="1" YPosition="-5" Delay="7" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="-1" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="2" XPivot="15" YPivot="4" XCrop="27" YCrop="36" Width="31" Height="9" XPosition="1" YPosition="-5" Delay="6" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="1" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="2" XPivot="15" YPivot="4" XCrop="27" YCrop="36" Width="31" Height="9" XPosition="1" YPosition="-5" Delay="1" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
<LayerAnimation LayerId="0" Visible="true">
|
||||
<Frame RegionId="0" XPivot="20" YPivot="16" XCrop="1" YCrop="1" Width="41" Height="33" XPosition="2" YPosition="-23" Delay="7" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="0" XPivot="20" YPivot="16" XCrop="1" YCrop="1" Width="41" Height="33" XPosition="0" YPosition="-23" Delay="6" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="0" XPivot="20" YPivot="16" XCrop="1" YCrop="1" Width="41" Height="33" XPosition="2" YPosition="-23" Delay="1" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
<LayerAnimation LayerId="1" Visible="true">
|
||||
<Frame RegionId="1" XPivot="12" YPivot="6" XCrop="1" YCrop="36" Width="24" Height="12" XPosition="-12" YPosition="-14" Delay="3" Visible="true" XScale="95" YScale="95" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="8" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="12" YPivot="6" XCrop="1" YCrop="36" Width="24" Height="12" XPosition="0" YPosition="-16" Delay="4" Visible="true" XScale="125" YScale="125" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="12" YPivot="6" XCrop="1" YCrop="36" Width="24" Height="12" XPosition="12" YPosition="-14" Delay="3" Visible="true" XScale="95" YScale="95" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="-8" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="12" YPivot="6" XCrop="1" YCrop="36" Width="24" Height="12" XPosition="0" YPosition="-16" Delay="3" Visible="true" XScale="125" YScale="125" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="12" YPivot="6" XCrop="1" YCrop="36" Width="24" Height="12" XPosition="-12" YPosition="-14" Delay="1" Visible="true" XScale="95" YScale="95" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="8" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
</LayerAnimations>
|
||||
<NullAnimations/>
|
||||
<Triggers/>
|
||||
</Animation>
|
||||
</Animations>
|
||||
</AnimatedActor>
|
||||
|
||||
|
After Width: | Height: | Size: 655 B |
@@ -0,0 +1,48 @@
|
||||
|
||||
<AnimatedActor>
|
||||
<Info CreatedBy="robot" CreatedOn="05/21/2026 10:34:48 PM" Fps="30" Version="0"/>
|
||||
<Content>
|
||||
<Spritesheets>
|
||||
<Spritesheet Id="0" Path="stacy.png">
|
||||
<Region Id="0" Name="Head" XCrop="1" YCrop="1" Width="32" Height="32" Origin="Center"/>
|
||||
<Region Id="1" Name="HeadAlt" XCrop="1" YCrop="35" Width="32" Height="32" Origin="Center"/>
|
||||
<Region Id="2" Name="Body" XCrop="35" YCrop="1" Width="30" Height="18" Origin="Center"/>
|
||||
<Region Id="3" Name="Tail" XCrop="35" YCrop="21" Width="13" Height="12" Origin="Center"/>
|
||||
</Spritesheet>
|
||||
</Spritesheets>
|
||||
<Layers>
|
||||
<Layer Id="0" Name="Head" SpritesheetId="0"/>
|
||||
<Layer Id="1" Name="Body" SpritesheetId="0"/>
|
||||
<Layer Id="2" Name="Tail" SpritesheetId="0"/>
|
||||
</Layers>
|
||||
<Nulls/>
|
||||
<Events/>
|
||||
</Content>
|
||||
<Animations DefaultAnimation="Main">
|
||||
<Animation Name="Main" FrameNum="9" Loop="true">
|
||||
<RootAnimation>
|
||||
<Frame XPosition="0" YPosition="0" Delay="9" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
|
||||
</RootAnimation>
|
||||
<LayerAnimations>
|
||||
<LayerAnimation LayerId="2" Visible="true">
|
||||
<Frame RegionId="3" XPivot="6" YPivot="6" XCrop="35" YCrop="21" Width="13" Height="12" XPosition="-12" YPosition="-10" Delay="4" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="3" XPivot="6" YPivot="6" XCrop="35" YCrop="21" Width="13" Height="12" XPosition="-12" YPosition="-11" Delay="4" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="4" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="3" XPivot="6" YPivot="6" XCrop="35" YCrop="21" Width="13" Height="12" XPosition="-12" YPosition="-10" Delay="1" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
<LayerAnimation LayerId="1" Visible="true">
|
||||
<Frame RegionId="2" XPivot="15" YPivot="9" XCrop="35" YCrop="1" Width="30" Height="18" XPosition="0" YPosition="-7" Delay="4" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="2" XPivot="15" YPivot="9" XCrop="35" YCrop="1" Width="30" Height="18" XPosition="0" YPosition="-8" Delay="4" Visible="true" XScale="95" YScale="105" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="2" XPivot="15" YPivot="9" XCrop="35" YCrop="1" Width="30" Height="18" XPosition="0" YPosition="-7" Delay="1" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
<LayerAnimation LayerId="0" Visible="true">
|
||||
<Frame RegionId="0" XPivot="16" YPivot="16" XCrop="1" YCrop="1" Width="32" Height="32" XPosition="-1" YPosition="-24" Delay="4" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="1" XPivot="16" YPivot="16" XCrop="1" YCrop="35" Width="32" Height="32" XPosition="-1" YPosition="-26" Delay="4" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
<Frame RegionId="0" XPivot="16" YPivot="16" XCrop="1" YCrop="1" Width="32" Height="32" XPosition="-1" YPosition="-24" Delay="1" Visible="true" XScale="100" YScale="100" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="EaseInOut"/>
|
||||
</LayerAnimation>
|
||||
</LayerAnimations>
|
||||
<NullAnimations/>
|
||||
<Triggers/>
|
||||
</Animation>
|
||||
</Animations>
|
||||
</AnimatedActor>
|
||||
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M5.99807 7L8.30747 3H11.9981L9.68867 7H5.99807ZM11.9981 7L14.3075 3H17.9981L15.6887 7H11.9981ZM17.9981 7L20.3075 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H5.99807L4 6.46076V19H20V7H17.9981Z"/></svg>
|
||||
|
After Width: | Height: | Size: 393 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"/></svg>
|
||||
|
After Width: | Height: | Size: 300 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M15.5355 2.80744C17.0976 1.24534 19.6303 1.24534 21.1924 2.80744C22.7545 4.36953 22.7545 6.90219 21.1924 8.46429L18.3638 11.2929L18.7175 11.6466C19.108 12.0371 19.108 12.6703 18.7175 13.0608C18.327 13.4513 17.6938 13.4513 17.3033 13.0608L16.9498 12.7073L10.7351 18.922C10.1767 19.4804 9.46547 19.861 8.6911 20.0159L6.93694 20.3667C6.54976 20.4442 6.19416 20.6345 5.91496 20.9137L4.92894 21.8997C4.53841 22.2902 3.90525 22.2902 3.51472 21.8997L2.10051 20.4855C1.70999 20.095 1.70999 19.4618 2.10051 19.0713L3.08653 18.0852C3.36574 17.806 3.55605 17.4504 3.63348 17.0633L3.98431 15.3091C4.13919 14.5347 4.51981 13.8235 5.07821 13.2651L11.2929 7.05045L10.9393 6.69686C10.5488 6.30634 10.5488 5.67317 10.9393 5.28265C11.3299 4.89212 11.963 4.89212 12.3535 5.28265L12.7069 5.63604L15.5355 2.80744ZM12.7071 8.46466L6.49242 14.6794C6.21322 14.9586 6.02291 15.3142 5.94548 15.7013L5.59464 17.4555C5.43977 18.2299 5.05915 18.9411 4.50075 19.4995C5.05915 18.9411 5.77035 18.5604 6.54471 18.4056L8.29887 18.0547C8.68605 17.9773 9.04165 17.787 9.32085 17.5078L15.5355 11.2931L12.7071 8.46466Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M15 17V19H6C5.44772 19 5 18.5523 5 18V7H2V5H5V2H7V17H15ZM17 22V7H9V5H18C18.5523 5 19 5.44772 19 6V17H22V19H19V22H17Z"/></svg>
|
||||
|
After Width: | Height: | Size: 207 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M12.8995 6.85453L17.1421 11.0972L7.24264 20.9967H3V16.754L12.8995 6.85453ZM14.3137 5.44032L16.435 3.319C16.8256 2.92848 17.4587 2.92848 17.8492 3.319L20.6777 6.14743C21.0682 6.53795 21.0682 7.17112 20.6777 7.56164L18.5563 9.68296L14.3137 5.44032Z"/></svg>
|
||||
|
After Width: | Height: | Size: 337 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M9 8L16 12L9 16V8Z" stroke="#FFF" stroke-width="2" stroke-linejoin="round"/> </svg>
|
||||
|
After Width: | Height: | Size: 166 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M6.5 8L11.5 12L6.5 16V8Z" stroke="#FFF" stroke-width="2" stroke-linejoin="round"/> <path d="M17.5 8L12.5 12L17.5 16V8Z" stroke="#FFF" stroke-width="2" stroke-linejoin="round"/> </svg>
|
||||
|
After Width: | Height: | Size: 266 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M15 8L8 12L15 16V8Z" stroke="#FFF" stroke-width="2" stroke-linejoin="round"/> </svg>
|
||||
|
After Width: | Height: | Size: 167 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M13.9999 18.9966H20.9999V20.9966H11.9999L8.00229 20.9991L1.51457 14.5113C1.12405 14.1208 1.12405 13.4877 1.51457 13.0971L12.1212 2.49053C12.5117 2.1 13.1449 2.1 13.5354 2.49053L21.3136 10.2687C21.7041 10.6592 21.7041 11.2924 21.3136 11.6829L13.9999 18.9966ZM15.6567 14.5113L19.1922 10.9758L12.8283 4.61185L9.29275 8.14738L15.6567 14.5113Z"/></svg>
|
||||
|
After Width: | Height: | Size: 429 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M13 10H20L11 23V14H4L13 1V10Z"/></svg>
|
||||
|
After Width: | Height: | Size: 120 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M21 9V20.9925C21 21.5511 20.5552 22 20.0066 22H3.9934C3.44495 22 3 21.556 3 21.0082V2.9918C3 2.45531 3.44694 2 3.99826 2H14V8C14 8.55228 14.4477 9 15 9H21ZM21 7H16V2.00318L21 7Z"/></svg>
|
||||
|
After Width: | Height: | Size: 268 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M3 3C2.44772 3 2 3.44772 2 4V7H9.58579L12 4.58579L10.4142 3H3ZM14.4142 5L10.4142 9H2V20C2 20.5523 2.44772 21 3 21H21C21.5523 21 22 20.5523 22 20V6C22 5.44772 21.5523 5 21 5H14.4142Z"/></svg>
|
||||
|
After Width: | Height: | Size: 272 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M3 21C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H10.4142L12.4142 5H20C20.5523 5 21 5.44772 21 6V9H4V18.996L6 11H22.5L20.1894 20.2425C20.0781 20.6877 19.6781 21 19.2192 21H3Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 279 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M20.0833 15.1999L21.2854 15.9212C21.5221 16.0633 21.5989 16.3704 21.4569 16.6072C21.4146 16.6776 21.3557 16.7365 21.2854 16.7787L12.5144 22.0412C12.1977 22.2313 11.8021 22.2313 11.4854 22.0412L2.71451 16.7787C2.47772 16.6366 2.40093 16.3295 2.54301 16.0927C2.58523 16.0223 2.64413 15.9634 2.71451 15.9212L3.9166 15.1999L11.9999 20.0499L20.0833 15.1999ZM20.0833 10.4999L21.2854 11.2212C21.5221 11.3633 21.5989 11.6704 21.4569 11.9072C21.4146 11.9776 21.3557 12.0365 21.2854 12.0787L11.9999 17.6499L2.71451 12.0787C2.47772 11.9366 2.40093 11.6295 2.54301 11.3927C2.58523 11.3223 2.64413 11.2634 2.71451 11.2212L3.9166 10.4999L11.9999 15.3499L20.0833 10.4999ZM12.5144 1.30864L21.2854 6.5712C21.5221 6.71327 21.5989 7.0204 21.4569 7.25719C21.4146 7.32757 21.3557 7.38647 21.2854 7.42869L11.9999 12.9999L2.71451 7.42869C2.47772 7.28662 2.40093 6.97949 2.54301 6.7427C2.58523 6.67232 2.64413 6.61343 2.71451 6.5712L11.4854 1.30864C11.8021 1.11864 12.1977 1.11864 12.5144 1.30864ZM11.9999 3.33233L5.88723 6.99995L11.9999 10.6676L18.1126 6.99995L11.9999 3.33233Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="4" y="4" width="16" height="16" rx="0.5" stroke="#FFF" stroke-width="2" stroke-linejoin="round"/> <circle cx="12" cy="12" r="1" fill="#FFF" stroke="none"/> <path d="M2 2L22 22" stroke="#FFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> </svg>
|
||||
|
After Width: | Height: | Size: 346 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M21 4V6H20L15 13.5V22H9V13.5L4 6H3V4H21ZM6.4037 6L11 12.8944V20H13V12.8944L17.5963 6H6.4037Z"/></svg>
|
||||
|
After Width: | Height: | Size: 183 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"> <circle cx="12" cy="12" r="2.5"/> </svg>
|
||||
|
After Width: | Height: | Size: 114 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M4.52047 5.93457L1.39366 2.80777L2.80788 1.39355L22.6069 21.1925L21.1927 22.6068L17.8827 19.2968C16.1814 20.3755 14.1638 21.0002 12.0003 21.0002C6.60812 21.0002 2.12215 17.1204 1.18164 12.0002C1.61832 9.62282 2.81932 7.5129 4.52047 5.93457ZM14.7577 16.1718L13.2937 14.7078C12.902 14.8952 12.4634 15.0002 12.0003 15.0002C10.3434 15.0002 9.00026 13.657 9.00026 12.0002C9.00026 11.537 9.10522 11.0984 9.29263 10.7067L7.82866 9.24277C7.30514 10.0332 7.00026 10.9811 7.00026 12.0002C7.00026 14.7616 9.23884 17.0002 12.0003 17.0002C13.0193 17.0002 13.9672 16.6953 14.7577 16.1718ZM7.97446 3.76015C9.22127 3.26959 10.5793 3.00016 12.0003 3.00016C17.3924 3.00016 21.8784 6.87992 22.8189 12.0002C22.5067 13.6998 21.8038 15.2628 20.8068 16.5925L16.947 12.7327C16.9821 12.4936 17.0003 12.249 17.0003 12.0002C17.0003 9.23873 14.7617 7.00016 12.0003 7.00016C11.7514 7.00016 11.5068 7.01833 11.2677 7.05343L7.97446 3.76015Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1000 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M20.0833 10.4999L21.2854 11.2212C21.5221 11.3633 21.5989 11.6704 21.4569 11.9072C21.4146 11.9776 21.3557 12.0365 21.2854 12.0787L11.9999 17.6499L2.71451 12.0787C2.47772 11.9366 2.40093 11.6295 2.54301 11.3927C2.58523 11.3223 2.64413 11.2634 2.71451 11.2212L3.9166 10.4999L11.9999 15.3499L20.0833 10.4999ZM20.0833 15.1999L21.2854 15.9212C21.5221 16.0633 21.5989 16.3704 21.4569 16.6072C21.4146 16.6776 21.3557 16.7365 21.2854 16.7787L12.5144 22.0412C12.1977 22.2313 11.8021 22.2313 11.4854 22.0412L2.71451 16.7787C2.47772 16.6366 2.40093 16.3295 2.54301 16.0927C2.58523 16.0223 2.64413 15.9634 2.71451 15.9212L3.9166 15.1999L11.9999 20.0499L20.0833 15.1999ZM12.5144 1.30864L21.2854 6.5712C21.5221 6.71327 21.5989 7.0204 21.4569 7.25719C21.4146 7.32757 21.3557 7.38647 21.2854 7.42869L11.9999 12.9999L2.71451 7.42869C2.47772 7.28662 2.40093 6.97949 2.54301 6.7427C2.58523 6.67232 2.64413 6.61343 2.71451 6.5712L11.4854 1.30864C11.8021 1.11864 12.1977 1.11864 12.5144 1.30864Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M18 11V8L22 12L18 16V13H13V18H16L12 22L8 18H11V13H6V16L2 12L6 8V11H11V6H8L12 2L16 6H13V11H18Z"/></svg>
|
||||
|
After Width: | Height: | Size: 184 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M10.5859 12L2.79297 4.20706L4.20718 2.79285L12.0001 10.5857L19.793 2.79285L21.2072 4.20706L13.4143 12L21.2072 19.7928L19.793 21.2071L12.0001 13.4142L4.20718 21.2071L2.79297 19.7928L10.5859 12Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 289 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M6 5C5.44772 5 5 5.44772 5 6C5 6.55228 5.44772 7 6 7C6.55228 7 7 6.55228 7 6C7 5.44772 6.55228 5 6 5ZM3 6C3 4.34315 4.34315 3 6 3C7.65685 3 9 4.34315 9 6C9 7.30622 8.16519 8.41746 7 8.82929V9C7 10.1046 7.89543 11 9 11H15C16.1046 11 17 10.1046 17 9V8.82929C15.8348 8.41746 15 7.30622 15 6C15 4.34315 16.3431 3 18 3C19.6569 3 21 4.34315 21 6C21 7.30622 20.1652 8.41746 19 8.82929V9C19 11.2091 17.2091 13 15 13H13V15.1707C14.1652 15.5825 15 16.6938 15 18C15 19.6569 13.6569 21 12 21C10.3431 21 9 19.6569 9 18C9 16.6938 9.83481 15.5825 11 15.1707V13H9C6.79086 13 5 11.2091 5 9V8.82929C3.83481 8.41746 3 7.30622 3 6ZM18 5C17.4477 5 17 5.44772 17 6C17 6.55228 17.4477 7 18 7C18.5523 7 19 6.55228 19 6C19 5.44772 18.5523 5 18 5ZM12 17C11.4477 17 11 17.4477 11 18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18C13 17.4477 12.5523 17 12 17Z"/></svg>
|
||||
|
After Width: | Height: | Size: 931 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M11 3C11.5523 3 12 3.44772 12 4V6H17C17.5523 6 18 6.44772 18 7V12H20C20.5523 12 21 12.4477 21 13V20C21 20.5523 20.5523 21 20 21H13C12.4477 21 12 20.5523 12 20V18H7C6.44772 18 6 17.5523 6 17V12H4C3.44772 12 3 11.5523 3 11V4C3 3.44772 3.44772 3 4 3H11ZM16 8H8V16H16V8Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 363 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M12 22L8 18H16L12 22ZM12 2L16 6H8L12 2ZM12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14ZM2 12L6 8V16L2 12ZM22 12L18 16V8L22 12Z"/></svg>
|
||||
|
After Width: | Height: | Size: 288 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z"/></svg>
|
||||
|
After Width: | Height: | Size: 132 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 48" fill="#FFF" xmlns="http://www.w3.org/2000/svg"> <path d="M4 0H20V38L12 48L4 38V0Z"/> </svg>
|
||||
|
After Width: | Height: | Size: 117 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M4.99989 13.9999L4.99976 5.00003L6.99976 5L6.99986 11.9999L14.5859 12V6.58581L21.0001 13L14.5859 19.4142L14.5859 14L4.99989 13.9999Z"/></svg>
|
||||
|
After Width: | Height: | Size: 223 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M15.382 4H22V6H16.618L9 21.2361L5.38197 14H2V12H6.61803L9 16.7639L15.382 4Z"/></svg>
|
||||
|
After Width: | Height: | Size: 166 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M16 7H11C7.68629 7 5 9.68629 5 13C5 16.3137 7.68629 19 11 19H20V21H11C6.58172 21 3 17.4183 3 13C3 8.58172 6.58172 5 11 5H16V1L22 6L16 11V7Z"/></svg>
|
||||
|
After Width: | Height: | Size: 230 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M21 3H13.5L16.5429 6.04289L13.2929 9.29289L14.7071 10.7071L17.9571 7.45711L21 10.5V3ZM3 21H10.5L7.45711 17.9571L10.7071 14.7071L9.29289 13.2929L6.04289 16.5429L3 13.5V21Z"/></svg>
|
||||
|
After Width: | Height: | Size: 261 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M14 4.4375C15.3462 4.4375 16.4375 3.34619 16.4375 2H17.5625C17.5625 3.34619 18.6538 4.4375 20 4.4375V5.5625C18.6538 5.5625 17.5625 6.65381 17.5625 8H16.4375C16.4375 6.65381 15.3462 5.5625 14 5.5625V4.4375ZM1 11C4.31371 11 7 8.31371 7 5H9C9 8.31371 11.6863 11 15 11V13C11.6863 13 9 15.6863 9 19H7C7 15.6863 4.31371 13 1 13V11ZM4.87601 12C6.18717 12.7276 7.27243 13.8128 8 15.124C8.72757 13.8128 9.81283 12.7276 11.124 12C9.81283 11.2724 8.72757 10.1872 8 8.87601C7.27243 10.1872 6.18717 11.2724 4.87601 12ZM17.25 14C17.25 15.7949 15.7949 17.25 14 17.25V18.75C15.7949 18.75 17.25 20.2051 17.25 22H18.75C18.75 20.2051 20.2051 18.75 22 18.75V17.25C20.2051 17.25 18.75 15.7949 18.75 14H17.25Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 784 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M20.0833 10.4999L21.2854 11.2212C21.5221 11.3633 21.5989 11.6704 21.4569 11.9072C21.4146 11.9776 21.3557 12.0365 21.2854 12.0787L11.9999 17.6499L2.71451 12.0787C2.47772 11.9366 2.40093 11.6295 2.54301 11.3927C2.58523 11.3223 2.64413 11.2634 2.71451 11.2212L3.9166 10.4999L11.9999 15.3499L20.0833 10.4999ZM20.0833 15.1999L21.2854 15.9212C21.5221 16.0633 21.5989 16.3704 21.4569 16.6072C21.4146 16.6776 21.3557 16.7365 21.2854 16.7787L12.5144 22.0412C12.1977 22.2313 11.8021 22.2313 11.4854 22.0412L2.71451 16.7787C2.47772 16.6366 2.40093 16.3295 2.54301 16.0927C2.58523 16.0223 2.64413 15.9634 2.71451 15.9212L3.9166 15.1999L11.9999 20.0499L20.0833 15.1999ZM12.5144 1.30864L21.2854 6.5712C21.5221 6.71327 21.5989 7.0204 21.4569 7.25719C21.4146 7.32757 21.3557 7.38647 21.2854 7.42869L11.9999 12.9999L2.71451 7.42869C2.47772 7.28662 2.40093 6.97949 2.54301 6.7427C2.58523 6.67232 2.64413 6.61343 2.71451 6.5712L11.4854 1.30864C11.8021 1.11864 12.1977 1.11864 12.5144 1.30864Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="4" y="4" width="16" height="16" rx="0.5" stroke="#FFF" stroke-width="2" stroke-linejoin="round"/> <circle cx="12" cy="12" r="1" fill="#FFF" stroke="none"/> </svg>
|
||||
|
After Width: | Height: | Size: 245 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M6.92893 0.514648L21.0711 14.6568L19.6569 16.071L15.834 12.2486L15 13.4999V21.9999H9V13.4999L4 5.99993H3V3.99993L7.585 3.99965L5.51472 1.92886L6.92893 0.514648ZM9.585 5.99965L6.4037 5.99993L11 12.8944V19.9999H13V12.8944L14.392 10.8066L9.585 5.99965ZM21 3.99993V5.99993H20L18.085 8.87193L16.643 7.42893L17.5963 5.99993H15.213L13.213 3.99993H21Z"/></svg>
|
||||
|
After Width: | Height: | Size: 434 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="#FFF" stroke-width="2" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><path d="M8 5H20L16 19H4Z"/></svg>
|
||||
|
After Width: | Height: | Size: 162 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M6.60282 10.0001L10 7.22056V16.7796L6.60282 14.0001H3V10.0001H6.60282ZM2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 854 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C17.5222 2 22 5.97778 22 10.8889C22 13.9556 19.5111 16.4444 16.4444 16.4444H14.4778C13.5556 16.4444 12.8111 17.1889 12.8111 18.1111C12.8111 18.5333 12.9778 18.9222 13.2333 19.2111C13.5 19.5111 13.6667 19.9 13.6667 20.3333C13.6667 21.2556 12.9 22 12 22C6.47778 22 2 17.5222 2 12C2 6.47778 6.47778 2 12 2ZM10.8111 18.1111C10.8111 16.0843 12.451 14.4444 14.4778 14.4444H16.4444C18.4065 14.4444 20 12.851 20 10.8889C20 7.1392 16.4677 4 12 4C7.58235 4 4 7.58235 4 12C4 16.19 7.2226 19.6285 11.324 19.9718C10.9948 19.4168 10.8111 18.7761 10.8111 18.1111ZM7.5 12C6.67157 12 6 11.3284 6 10.5C6 9.67157 6.67157 9 7.5 9C8.32843 9 9 9.67157 9 10.5C9 11.3284 8.32843 12 7.5 12ZM16.5 12C15.6716 12 15 11.3284 15 10.5C15 9.67157 15.6716 9 16.5 9C17.3284 9 18 9.67157 18 10.5C18 11.3284 17.3284 12 16.5 12ZM12 9C11.1716 9 10.5 8.32843 10.5 7.5C10.5 6.67157 11.1716 6 12 6C12.8284 6 13.5 6.67157 13.5 7.5C13.5 8.32843 12.8284 9 12 9Z"/></svg>
|
||||
|
After Width: | Height: | Size: 1013 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="#FFF" stroke-width="0.75" xmlns="http://www.w3.org/2000/svg"> <circle cx="12" cy="12" r="2.8"/> <line x1="12" y1="5" x2="12" y2="19"/> <line x1="5" y1="12" x2="19" y2="12"/> </svg>
|
||||
|
After Width: | Height: | Size: 226 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="#FFF" stroke-width="0.75" xmlns="http://www.w3.org/2000/svg"> <circle cx="12" cy="12" r="2.8"/> <circle cx="12" cy="12" r="0.3" fill="#FFF" stroke="none"/> </svg>
|
||||
|
After Width: | Height: | Size: 208 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"> <path d="M11 5h2v10h-2V5Zm0 14h2v2h-2v-2Z"/> </svg>
|
||||
|
After Width: | Height: | Size: 125 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M3 3H12.382C12.7607 3 13.107 3.214 13.2764 3.55279L14 5H20C20.5523 5 21 5.44772 21 6V17C21 17.5523 20.5523 18 20 18H13.618C13.2393 18 12.893 17.786 12.7236 17.4472L12 16H5V22H3V3Z"/></svg>
|
||||
|
After Width: | Height: | Size: 270 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFF"><path d="M11 3C11.5523 3 12 3.44772 12 4V6H17C17.5523 6 18 6.44772 18 7V12H20C20.5523 12 21 12.4477 21 13V20C21 20.5523 20.5523 21 20 21H13C12.4477 21 12 20.5523 12 20V18H7C6.44772 18 6 17.5523 6 17V12H4C3.44772 12 3 11.5523 3 11V4C3 3.44772 3.44772 3 4 3H11ZM16 8H12V11C12 11.5523 11.5523 12 11 12H8V16H12V13C12 12.4477 12.4477 12 13 12H16V8Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 431 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M19.0001 13.9999L19.0002 5.00003L17.0002 5L17.0001 11.9999L9.41406 12V6.58581L2.99986 13L9.41406 19.4142L9.41406 14L19.0001 13.9999Z"/></svg>
|
||||
|
After Width: | Height: | Size: 223 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"> <rect x="9.5" y="9.5" width="5" height="5"/> </svg>
|
||||
|
After Width: | Height: | Size: 125 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="#FFF" xmlns="http://www.w3.org/2000/svg"><path d="M1.18164 12C2.12215 6.87976 6.60812 3 12.0003 3C17.3924 3 21.8784 6.87976 22.8189 12C21.8784 17.1202 17.3924 21 12.0003 21C6.60812 21 2.12215 17.1202 1.18164 12ZM12.0003 17C14.7617 17 17.0003 14.7614 17.0003 12C17.0003 9.23858 14.7617 7 12.0003 7C9.23884 7 7.00026 9.23858 7.00026 12C7.00026 14.7614 9.23884 17 12.0003 17ZM12.0003 15C10.3434 15 9.00026 13.6569 9.00026 12C9.00026 10.3431 10.3434 9 12.0003 9C13.6571 9 15.0003 10.3431 15.0003 12C15.0003 13.6569 13.6571 15 12.0003 15Z"/></svg>
|
||||
|
After Width: | Height: | Size: 574 B |
@@ -1,352 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <tinyxml2/tinyxml2.h>
|
||||
|
||||
#include "icon.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
#define ANM2_ELEMENT_TYPES \
|
||||
X(UNKNOWN, "") \
|
||||
X(ANIMATED_ACTOR, "AnimatedActor") \
|
||||
X(INFO, "Info") \
|
||||
X(CONTENT, "Content") \
|
||||
X(SPRITESHEETS, "Spritesheets") \
|
||||
X(SPRITESHEET, "Spritesheet") \
|
||||
X(REGION, "Region") \
|
||||
X(LAYERS, "Layers") \
|
||||
X(LAYER_ELEMENT, "Layer") \
|
||||
X(NULLS, "Nulls") \
|
||||
X(NULL_ELEMENT, "Null") \
|
||||
X(EVENTS, "Events") \
|
||||
X(EVENT_ELEMENT, "Event") \
|
||||
X(SOUNDS, "Sounds") \
|
||||
X(SOUND_ELEMENT, "Sound") \
|
||||
X(ANIMATIONS, "Animations") \
|
||||
X(ANIMATION, "Animation") \
|
||||
X(ROOT_ANIMATION, "RootAnimation") \
|
||||
X(LAYER_ANIMATIONS, "LayerAnimations") \
|
||||
X(LAYER_ANIMATION, "LayerAnimation") \
|
||||
X(NULL_ANIMATIONS, "NullAnimations") \
|
||||
X(NULL_ANIMATION, "NullAnimation") \
|
||||
X(GROUP, "Group") \
|
||||
X(TRIGGERS, "Triggers") \
|
||||
X(FRAME, "Frame") \
|
||||
X(TRIGGER, "Trigger")
|
||||
|
||||
namespace anm2ed
|
||||
{
|
||||
enum class ElementType
|
||||
{
|
||||
#define X(symbol, tag) symbol,
|
||||
ANM2_ELEMENT_TYPES
|
||||
#undef X
|
||||
COUNT
|
||||
};
|
||||
|
||||
enum class Interpolation
|
||||
{
|
||||
NONE,
|
||||
LINEAR,
|
||||
EASE_IN,
|
||||
EASE_OUT,
|
||||
EASE_IN_OUT,
|
||||
COUNT
|
||||
};
|
||||
|
||||
enum class Origin
|
||||
{
|
||||
CUSTOM,
|
||||
TOP_LEFT,
|
||||
CENTER,
|
||||
COUNT
|
||||
};
|
||||
|
||||
enum class ItemType
|
||||
{
|
||||
NONE,
|
||||
ROOT,
|
||||
LAYER,
|
||||
NULL_,
|
||||
TRIGGER,
|
||||
COUNT
|
||||
};
|
||||
|
||||
inline constexpr int NONE = (int)ItemType::NONE;
|
||||
inline constexpr int ROOT = (int)ItemType::ROOT;
|
||||
inline constexpr int LAYER = (int)ItemType::LAYER;
|
||||
inline constexpr int NULL_ = (int)ItemType::NULL_;
|
||||
inline constexpr int TRIGGER = (int)ItemType::TRIGGER;
|
||||
|
||||
inline constexpr int FRAME_DURATION_MIN = 1;
|
||||
inline constexpr int FRAME_DURATION_MAX = 1000000;
|
||||
inline constexpr int FRAME_NUM_MIN = 1;
|
||||
inline constexpr int FRAME_NUM_MAX = FRAME_DURATION_MAX;
|
||||
inline constexpr int FPS_MIN = 1;
|
||||
inline constexpr int FPS_MAX = 120;
|
||||
|
||||
enum class SpritesheetMergeOrigin
|
||||
{
|
||||
APPEND_RIGHT,
|
||||
APPEND_BOTTOM,
|
||||
COUNT
|
||||
};
|
||||
|
||||
inline constexpr int APPEND_RIGHT = (int)SpritesheetMergeOrigin::APPEND_RIGHT;
|
||||
inline constexpr int APPEND_BOTTOM = (int)SpritesheetMergeOrigin::APPEND_BOTTOM;
|
||||
|
||||
inline const glm::vec4 ROOT_COLOR = glm::vec4(0.140f, 0.310f, 0.560f, 1.000f);
|
||||
inline const glm::vec4 ROOT_COLOR_ACTIVE = glm::vec4(0.240f, 0.520f, 0.880f, 1.000f);
|
||||
inline const glm::vec4 ROOT_COLOR_HOVERED = glm::vec4(0.320f, 0.640f, 1.000f, 1.000f);
|
||||
|
||||
inline const glm::vec4 LAYER_COLOR = glm::vec4(0.640f, 0.320f, 0.110f, 1.000f);
|
||||
inline const glm::vec4 LAYER_COLOR_ACTIVE = glm::vec4(0.840f, 0.450f, 0.170f, 1.000f);
|
||||
inline const glm::vec4 LAYER_COLOR_HOVERED = glm::vec4(0.960f, 0.560f, 0.240f, 1.000f);
|
||||
|
||||
inline const glm::vec4 NULL_COLOR = glm::vec4(0.140f, 0.430f, 0.200f, 1.000f);
|
||||
inline const glm::vec4 NULL_COLOR_ACTIVE = glm::vec4(0.250f, 0.650f, 0.350f, 1.000f);
|
||||
inline const glm::vec4 NULL_COLOR_HOVERED = glm::vec4(0.350f, 0.800f, 0.480f, 1.000f);
|
||||
|
||||
inline const glm::vec4 TRIGGER_COLOR = glm::vec4(0.620f, 0.150f, 0.260f, 1.000f);
|
||||
inline const glm::vec4 TRIGGER_COLOR_ACTIVE = glm::vec4(0.820f, 0.250f, 0.380f, 1.000f);
|
||||
inline const glm::vec4 TRIGGER_COLOR_HOVERED = glm::vec4(0.950f, 0.330f, 0.490f, 1.000f);
|
||||
|
||||
#define ANM2_ITEM_TYPES \
|
||||
X(NONE, STRING_UNDEFINED, "", resource::icon::NONE, glm::vec4(), glm::vec4(), glm::vec4()) \
|
||||
X(ROOT, BASIC_ROOT, "RootAnimation", resource::icon::ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED) \
|
||||
X(LAYER, BASIC_LAYER_ANIMATION, "LayerAnimation", resource::icon::LAYER, LAYER_COLOR, LAYER_COLOR_ACTIVE, \
|
||||
LAYER_COLOR_HOVERED) \
|
||||
X(NULL_, BASIC_NULL_ANIMATION, "NullAnimation", resource::icon::NULL_, NULL_COLOR, NULL_COLOR_ACTIVE, \
|
||||
NULL_COLOR_HOVERED) \
|
||||
X(TRIGGER, BASIC_TRIGGERS, "Triggers", resource::icon::TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, \
|
||||
TRIGGER_COLOR_HOVERED)
|
||||
|
||||
constexpr StringType TYPE_STRINGS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) string,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr const char* TYPE_ITEM_STRINGS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) itemString,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr resource::icon::Type TYPE_ICONS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) icon,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) color,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR_ACTIVE[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) colorActive,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR_HOVERED[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered) colorHovered,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
enum class ChangeType
|
||||
{
|
||||
ADJUST,
|
||||
ADD,
|
||||
SUBTRACT,
|
||||
MULTIPLY,
|
||||
DIVIDE
|
||||
};
|
||||
|
||||
enum Flag
|
||||
{
|
||||
SERIALIZE_GROUPS = 1 << 0,
|
||||
SERIALIZE_REGIONS = 1 << 1,
|
||||
SERIALIZE_SOUNDS = 1 << 2,
|
||||
SERIALIZE_REDUNDANT_FRAME_REGION_VALUES = 1 << 3,
|
||||
SERIALIZE_BAKE_SPECIAL_INTERPOLATED_FRAMES = 1 << 4
|
||||
};
|
||||
|
||||
using Flags = int;
|
||||
|
||||
constexpr bool has_flag(Flags flags, Flag flag) { return (flags & flag) != 0; }
|
||||
constexpr Flags SERIALIZE_EDITOR_DEFAULT =
|
||||
SERIALIZE_GROUPS | SERIALIZE_REGIONS | SERIALIZE_SOUNDS | SERIALIZE_REDUNDANT_FRAME_REGION_VALUES;
|
||||
constexpr Flags SERIALIZE_DEFAULT = SERIALIZE_EDITOR_DEFAULT | SERIALIZE_BAKE_SPECIAL_INTERPOLATED_FRAMES;
|
||||
|
||||
struct Options
|
||||
{
|
||||
Flags flags{SERIALIZE_DEFAULT};
|
||||
};
|
||||
|
||||
struct FrameChange
|
||||
{
|
||||
std::optional<bool> isVisible{};
|
||||
std::optional<Interpolation> interpolation{};
|
||||
std::optional<float> rotation{};
|
||||
std::optional<int> duration{};
|
||||
std::optional<int> regionId{};
|
||||
std::optional<float> pivotX{};
|
||||
std::optional<float> pivotY{};
|
||||
std::optional<float> cropX{};
|
||||
std::optional<float> cropY{};
|
||||
std::optional<float> positionX{};
|
||||
std::optional<float> positionY{};
|
||||
std::optional<float> sizeX{};
|
||||
std::optional<float> sizeY{};
|
||||
std::optional<float> scaleX{};
|
||||
std::optional<float> scaleY{};
|
||||
std::optional<float> colorOffsetR{};
|
||||
std::optional<float> colorOffsetG{};
|
||||
std::optional<float> colorOffsetB{};
|
||||
std::optional<float> tintR{};
|
||||
std::optional<float> tintG{};
|
||||
std::optional<float> tintB{};
|
||||
std::optional<float> tintA{};
|
||||
std::optional<bool> isFlipX{};
|
||||
std::optional<bool> isFlipY{};
|
||||
};
|
||||
|
||||
struct Element
|
||||
{
|
||||
ElementType type{ElementType::UNKNOWN};
|
||||
std::string tag{};
|
||||
std::vector<Element> children{};
|
||||
std::string name{};
|
||||
std::string createdBy{"robot"};
|
||||
std::string createdOn{};
|
||||
std::filesystem::path path{};
|
||||
std::string defaultAnimation{};
|
||||
int id{-1};
|
||||
int layerId{-1};
|
||||
int nullId{-1};
|
||||
int spritesheetId{};
|
||||
int fps{30};
|
||||
int version{};
|
||||
int frameNum{1};
|
||||
int duration{1};
|
||||
int atFrame{-1};
|
||||
int eventId{-1};
|
||||
int regionId{-1};
|
||||
int soundId{-1};
|
||||
int groupId{-1};
|
||||
bool isLoop{true};
|
||||
bool isVisible{true};
|
||||
bool isShowRect{};
|
||||
bool isExpanded{true};
|
||||
Interpolation interpolation{Interpolation::NONE};
|
||||
Origin origin{Origin::CUSTOM};
|
||||
float rotation{};
|
||||
std::vector<int> soundIds{};
|
||||
glm::vec2 pivot{};
|
||||
glm::vec2 crop{};
|
||||
glm::vec2 position{};
|
||||
glm::vec2 size{};
|
||||
glm::vec2 scale{100.0f, 100.0f};
|
||||
glm::vec3 colorOffset{};
|
||||
glm::vec4 tint{types::color::WHITE};
|
||||
};
|
||||
|
||||
struct Reference
|
||||
{
|
||||
int animationIndex{-1};
|
||||
int itemType{(int)ItemType::NONE};
|
||||
int itemID{-1};
|
||||
int frameIndex{-1};
|
||||
|
||||
auto operator<=>(const Reference&) const = default;
|
||||
};
|
||||
|
||||
Element element_make(ElementType);
|
||||
Element element_read(const tinyxml2::XMLElement*);
|
||||
std::string element_to_string(const Element&, Flags = SERIALIZE_EDITOR_DEFAULT);
|
||||
std::string element_to_string(const Element&, ElementType, Flags = SERIALIZE_EDITOR_DEFAULT);
|
||||
tinyxml2::XMLElement* element_to_xml(tinyxml2::XMLDocument&, const Element&, Flags = SERIALIZE_EDITOR_DEFAULT);
|
||||
tinyxml2::XMLElement* element_to_xml(tinyxml2::XMLDocument&, const Element&, ElementType,
|
||||
Flags = SERIALIZE_EDITOR_DEFAULT);
|
||||
Element* element_child_first_get(Element&, ElementType);
|
||||
const Element* element_child_first_get(const Element&, ElementType);
|
||||
Element* element_child_id_get(Element&, ElementType, int);
|
||||
const Element* element_child_id_get(const Element&, ElementType, int);
|
||||
int element_child_next_id_get(const Element&, ElementType);
|
||||
int element_child_max_id_get(const Element&, ElementType);
|
||||
bool element_child_id_erase(Element&, ElementType, int);
|
||||
Element* element_first_get(Element&, ElementType);
|
||||
const Element* element_first_get(const Element&, ElementType);
|
||||
Element* animation_item_get(Element&, ItemType, int = -1);
|
||||
const Element* animation_item_get(const Element&, ItemType, int = -1);
|
||||
ElementType item_type_to_track_type_get(ItemType);
|
||||
Element* track_frame_get(Element&, int);
|
||||
const Element* track_frame_get(const Element&, int);
|
||||
Element frame_generate(const Element&, float);
|
||||
int frame_index_from_at_frame_get(const Element&, int);
|
||||
int frame_index_from_time_get(const Element&, float);
|
||||
float frame_time_from_index_get(const Element&, int);
|
||||
void frame_bake(Element&, int, int, bool, bool);
|
||||
void frames_generate_from_grid(Element&, glm::ivec2, glm::ivec2, glm::vec2, int, int, int);
|
||||
bool frames_deserialize(Element&, const std::string&, int, std::set<int>&, std::string* = nullptr);
|
||||
void frames_sort_by_at_frame(Element&);
|
||||
void frames_change(Element&, FrameChange, ItemType, ChangeType, const std::set<int>&);
|
||||
int track_length_get(const Element&);
|
||||
int animation_length_get(const Element&);
|
||||
|
||||
class Anm2
|
||||
{
|
||||
public:
|
||||
bool isValid{true};
|
||||
Element root{};
|
||||
|
||||
Anm2();
|
||||
Anm2(const std::filesystem::path&, std::string* = nullptr);
|
||||
|
||||
bool load(const std::filesystem::path&, std::string* = nullptr);
|
||||
bool load_string(std::string_view, std::string* = nullptr);
|
||||
bool save(const std::filesystem::path&, std::string* = nullptr, Options = {}) const;
|
||||
std::string to_string(Options = {}) const;
|
||||
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, Options = {}) const;
|
||||
std::uint64_t hash(Options = {}) const;
|
||||
bool is_special_interpolated_frames() const;
|
||||
void special_interpolated_frames_bake(int, bool, bool);
|
||||
void region_frames_sync(bool);
|
||||
Anm2 normalized_for_serialize() const;
|
||||
|
||||
Element* element_get(ElementType);
|
||||
const Element* element_get(ElementType) const;
|
||||
Element* element_get(ElementType, int);
|
||||
const Element* element_get(ElementType, int) const;
|
||||
Element* element_get(int, ItemType, int = -1);
|
||||
const Element* element_get(int, ItemType, int = -1) const;
|
||||
Element* element_get(int, ItemType, int, int);
|
||||
const Element* element_get(int, ItemType, int, int) const;
|
||||
std::set<int> element_unused(ElementType) const;
|
||||
std::set<int> element_unused(ElementType, const Element&) const;
|
||||
std::set<int> element_unused(ElementType, int) const;
|
||||
bool deserialize(ElementType, const std::string&, bool, std::string* = nullptr, const std::filesystem::path& = {});
|
||||
bool regions_deserialize(int, const std::string&, bool, std::string* = nullptr);
|
||||
Element frame_effective(int, const Element&) const;
|
||||
glm::vec4 animation_rect(const Element&, bool) const;
|
||||
int layer_animation_add(int, int = -1, int = -1, std::string = {}, int = 0,
|
||||
types::destination::Type = types::destination::ALL);
|
||||
int null_animation_add(int, int = -1, std::string = {}, bool = false,
|
||||
types::destination::Type = types::destination::ALL);
|
||||
bool animations_deserialize(const std::string&, int, std::set<int>&, std::string* = nullptr);
|
||||
int animations_merge(int, std::set<int>&, types::merge::Type = types::merge::APPEND, bool = true);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "asset_store.h"
|
||||
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <span>
|
||||
|
||||
constexpr std::uint64_t HASH_SEED = 14695981039346656037ull;
|
||||
constexpr std::uint64_t HASH_SPREAD = 0x9E3779B97F4A7C15ull;
|
||||
constexpr std::uint64_t HASH_MIX = 0x94D049BB133111EBull;
|
||||
constexpr int HASH_ROTATION = 27;
|
||||
|
||||
// Hashes eight bytes a step (the tail one at a time), each mixed by a multiply and a rotation. Hashes stay within a
|
||||
// session, so they only have to tell contents apart.
|
||||
static std::uint64_t bytes_hash(std::span<const std::uint8_t> bytes, std::uint64_t hash = HASH_SEED)
|
||||
{
|
||||
auto step = [&](std::uint64_t word) {
|
||||
hash = std::rotl(hash ^ (word * HASH_SPREAD), HASH_ROTATION) * HASH_MIX;
|
||||
};
|
||||
std::size_t i = 0;
|
||||
for (; i + sizeof(std::uint64_t) <= bytes.size(); i += sizeof(std::uint64_t))
|
||||
{
|
||||
std::uint64_t word = 0;
|
||||
std::memcpy(&word, bytes.data() + i, sizeof(word));
|
||||
step(word);
|
||||
}
|
||||
for (; i < bytes.size(); ++i)
|
||||
step(bytes[i]);
|
||||
step(bytes.size());
|
||||
return hash;
|
||||
}
|
||||
|
||||
template <class Value> static std::span<const std::uint8_t> value_bytes_get(const Value& value)
|
||||
{
|
||||
return {reinterpret_cast<const std::uint8_t*>(&value), sizeof(value)};
|
||||
}
|
||||
|
||||
// Content hash. 0 stays free to mean "no asset".
|
||||
static std::uint64_t hash_finish(std::uint64_t hash)
|
||||
{
|
||||
return hash ? hash : 1;
|
||||
}
|
||||
|
||||
std::uint64_t AssetStore::image_add(Image image)
|
||||
{
|
||||
auto hash = bytes_hash(value_bytes_get(image.size));
|
||||
hash = bytes_hash(value_bytes_get(image.isLinear), hash);
|
||||
hash = bytes_hash(image.pixels, hash);
|
||||
if (image.svg)
|
||||
hash = bytes_hash({(const std::uint8_t*)image.svg->data(), image.svg->size()}, hash);
|
||||
hash = hash_finish(hash);
|
||||
images.try_emplace(hash, std::move(image));
|
||||
return hash;
|
||||
}
|
||||
|
||||
std::uint64_t AssetStore::audio_add(AudioData data)
|
||||
{
|
||||
auto hash = hash_finish(bytes_hash(data.bytes));
|
||||
audio.try_emplace(hash, std::move(data));
|
||||
return hash;
|
||||
}
|
||||
|
||||
const Image* AssetStore::image_get(std::uint64_t hash) const
|
||||
{
|
||||
auto it = images.find(hash);
|
||||
return it == images.end() ? nullptr : &it->second;
|
||||
}
|
||||
|
||||
const AudioData* AssetStore::audio_get(std::uint64_t hash) const
|
||||
{
|
||||
auto it = audio.find(hash);
|
||||
return it == audio.end() ? nullptr : &it->second;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "audio_data.h"
|
||||
#include "image.h"
|
||||
|
||||
// Immutable images and sounds keyed by content hash. Undo history records keys, never pixels or bytes, and
|
||||
// entries live until the document closes so any step can be restored.
|
||||
class AssetStore
|
||||
{
|
||||
std::unordered_map<std::uint64_t, Image> images;
|
||||
std::unordered_map<std::uint64_t, AudioData> audio;
|
||||
|
||||
public:
|
||||
std::uint64_t image_add(Image);
|
||||
std::uint64_t audio_add(AudioData);
|
||||
const Image* image_get(std::uint64_t) const;
|
||||
const AudioData* audio_get(std::uint64_t) const;
|
||||
};
|
||||
@@ -0,0 +1,232 @@
|
||||
#include "audio.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include <stb_vorbis.c>
|
||||
|
||||
constexpr SDL_AudioSpec AUDIO_SPEC = {SDL_AUDIO_F32, AUDIO_CHANNELS, AUDIO_FREQUENCY};
|
||||
constexpr int FRAME_SIZE = AUDIO_CHANNELS * sizeof(float);
|
||||
|
||||
// One play of a sound. The audio thread feeds its stream from `position`, wrapping around when it loops.
|
||||
struct AudioVoice
|
||||
{
|
||||
struct AudioSound* sound = nullptr;
|
||||
SDL_AudioStream* stream = nullptr;
|
||||
std::atomic<std::size_t> position = 0;
|
||||
std::atomic<bool> isLoop = false;
|
||||
};
|
||||
|
||||
// A decoded sound, its voices (one per overlapping play, reused once finished) and the loudness they played.
|
||||
struct AudioSound
|
||||
{
|
||||
std::vector<float> samples;
|
||||
std::vector<std::unique_ptr<AudioVoice>> voices;
|
||||
std::atomic<float> squares[AUDIO_CHANNELS] = {};
|
||||
std::atomic<int> frameCount = 0;
|
||||
};
|
||||
|
||||
static std::unordered_map<std::uint64_t, AudioSound> sounds;
|
||||
|
||||
// Converts audio in `spec` to AUDIO_SPEC.
|
||||
static std::vector<float> samples_convert(const SDL_AudioSpec& spec, const void* data, int size)
|
||||
{
|
||||
Uint8* converted = nullptr;
|
||||
int convertedSize = 0;
|
||||
if (!SDL_ConvertAudioSamples(&spec, (const Uint8*)data, size, &AUDIO_SPEC, &converted, &convertedSize))
|
||||
return {};
|
||||
std::vector<float> samples(convertedSize / sizeof(float));
|
||||
std::memcpy(samples.data(), converted, samples.size() * sizeof(float));
|
||||
SDL_free(converted);
|
||||
return samples;
|
||||
}
|
||||
|
||||
static std::vector<float> samples_decode(const AudioData& data)
|
||||
{
|
||||
if (data.bytes.size() >= 4 && std::memcmp(data.bytes.data(), "OggS", 4) == 0)
|
||||
{
|
||||
int channels = 0;
|
||||
int frequency = 0;
|
||||
short* decoded = nullptr;
|
||||
auto frames =
|
||||
stb_vorbis_decode_memory(data.bytes.data(), (int)data.bytes.size(), &channels, &frequency, &decoded);
|
||||
if (frames <= 0)
|
||||
return {};
|
||||
auto samples =
|
||||
samples_convert({SDL_AUDIO_S16, channels, frequency}, decoded, frames * channels * sizeof(short));
|
||||
free(decoded);
|
||||
return samples;
|
||||
}
|
||||
|
||||
SDL_AudioSpec spec = {};
|
||||
Uint8* decoded = nullptr;
|
||||
Uint32 size = 0;
|
||||
if (!SDL_LoadWAV_IO(SDL_IOFromConstMem(data.bytes.data(), data.bytes.size()), true, &spec, &decoded, &size))
|
||||
return {};
|
||||
auto samples = samples_convert(spec, decoded, (int)size);
|
||||
SDL_free(decoded);
|
||||
return samples;
|
||||
}
|
||||
|
||||
static AudioSound* sound_get(const AudioData& data)
|
||||
{
|
||||
if (!data.is_valid())
|
||||
return nullptr;
|
||||
auto [it, isNew] = sounds.try_emplace(data.uid);
|
||||
if (isNew)
|
||||
it->second.samples = samples_decode(data);
|
||||
return it->second.samples.empty() ? nullptr : &it->second;
|
||||
}
|
||||
|
||||
// Opened on the first play. A failed open is tried again on the next, for a device that shows up later.
|
||||
static SDL_AudioDeviceID device_get()
|
||||
{
|
||||
static SDL_AudioDeviceID device = 0;
|
||||
if (!device && SDL_InitSubSystem(SDL_INIT_AUDIO))
|
||||
device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &AUDIO_SPEC);
|
||||
return device;
|
||||
}
|
||||
|
||||
// Runs on the audio thread: gives the stream what it asks for, and adds it to the sound's loudness.
|
||||
static void SDLCALL voice_feed(void* userdata, SDL_AudioStream* stream, int amount, int)
|
||||
{
|
||||
auto voice = (AudioVoice*)userdata;
|
||||
auto& samples = voice->sound->samples;
|
||||
auto frames = (std::size_t)amount / FRAME_SIZE;
|
||||
auto position = voice->position.load();
|
||||
float squares[AUDIO_CHANNELS] = {};
|
||||
std::size_t fed = 0;
|
||||
while (fed < frames)
|
||||
{
|
||||
if (position * AUDIO_CHANNELS >= samples.size())
|
||||
{
|
||||
if (!voice->isLoop)
|
||||
break;
|
||||
position = 0;
|
||||
}
|
||||
auto count = std::min(frames - fed, samples.size() / AUDIO_CHANNELS - position);
|
||||
auto start = samples.data() + position * AUDIO_CHANNELS;
|
||||
for (std::size_t i = 0; i < count * AUDIO_CHANNELS; ++i)
|
||||
squares[i % AUDIO_CHANNELS] += start[i] * start[i];
|
||||
SDL_PutAudioStreamData(stream, start, (int)(count * FRAME_SIZE));
|
||||
position += count;
|
||||
fed += count;
|
||||
}
|
||||
voice->position = position;
|
||||
for (int channel = 0; channel < AUDIO_CHANNELS; ++channel)
|
||||
voice->sound->squares[channel] += squares[channel];
|
||||
voice->sound->frameCount += (int)fed;
|
||||
}
|
||||
|
||||
static bool is_voice_playing(AudioVoice& voice)
|
||||
{
|
||||
return voice.isLoop || voice.position * AUDIO_CHANNELS < voice.sound->samples.size() ||
|
||||
SDL_GetAudioStreamQueued(voice.stream) > 0;
|
||||
}
|
||||
|
||||
// A sound can play over itself: while a voice is still playing it, another voice takes the new play.
|
||||
void audio_play(const AudioData& data, AudioPlayMode mode)
|
||||
{
|
||||
auto sound = sound_get(data);
|
||||
if (!sound || !device_get())
|
||||
return;
|
||||
|
||||
auto free = std::ranges::find_if(sound->voices, [](auto& voice) { return !is_voice_playing(*voice); });
|
||||
AudioVoice* voice = nullptr;
|
||||
if (free != sound->voices.end())
|
||||
voice = free->get();
|
||||
else
|
||||
{
|
||||
auto stream = SDL_CreateAudioStream(&AUDIO_SPEC, &AUDIO_SPEC);
|
||||
if (!stream)
|
||||
return;
|
||||
voice = sound->voices.emplace_back(std::make_unique<AudioVoice>()).get();
|
||||
voice->sound = sound;
|
||||
voice->stream = stream;
|
||||
SDL_SetAudioStreamGetCallback(voice->stream, voice_feed, voice);
|
||||
SDL_BindAudioStream(device_get(), voice->stream);
|
||||
}
|
||||
|
||||
SDL_LockAudioStream(voice->stream);
|
||||
SDL_ClearAudioStream(voice->stream);
|
||||
voice->position = 0;
|
||||
voice->isLoop = mode == AUDIO_LOOP;
|
||||
SDL_UnlockAudioStream(voice->stream);
|
||||
}
|
||||
|
||||
void audio_stop(const AudioData& data)
|
||||
{
|
||||
auto it = sounds.find(data.uid);
|
||||
if (it == sounds.end())
|
||||
return;
|
||||
for (auto& voice : it->second.voices)
|
||||
{
|
||||
SDL_LockAudioStream(voice->stream);
|
||||
voice->isLoop = false;
|
||||
voice->position = it->second.samples.size() / AUDIO_CHANNELS;
|
||||
SDL_ClearAudioStream(voice->stream);
|
||||
SDL_UnlockAudioStream(voice->stream);
|
||||
}
|
||||
}
|
||||
|
||||
void audio_prune(const std::set<std::uint64_t>& uids)
|
||||
{
|
||||
std::erase_if(sounds, [&](auto& entry) {
|
||||
auto& [uid, sound] = entry;
|
||||
if (uids.contains(uid) ||
|
||||
std::ranges::any_of(sound.voices, [](auto& voice) { return is_voice_playing(*voice); }))
|
||||
return false;
|
||||
for (auto& voice : sound.voices)
|
||||
SDL_DestroyAudioStream(voice->stream);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool is_audio_playing(const AudioData& data)
|
||||
{
|
||||
auto it = sounds.find(data.uid);
|
||||
return it != sounds.end() &&
|
||||
std::ranges::any_of(it->second.voices, [](auto& voice) { return is_voice_playing(*voice); });
|
||||
}
|
||||
|
||||
// The left/right loudness (RMS, 0-1) of what the sound played since the last call.
|
||||
Vec2 audio_levels_get(const AudioData& data)
|
||||
{
|
||||
auto it = sounds.find(data.uid);
|
||||
if (it == sounds.end())
|
||||
return {};
|
||||
auto& sound = it->second;
|
||||
auto count = (float)std::max(sound.frameCount.exchange(0), 1);
|
||||
return {std::sqrt(sound.squares[0].exchange(0.0f) / count), std::sqrt(sound.squares[1].exchange(0.0f) / count)};
|
||||
}
|
||||
|
||||
std::vector<float> audio_mix(const std::vector<std::vector<const AudioData*>>& frameSounds, int fps)
|
||||
{
|
||||
std::vector<float> mix;
|
||||
if (fps <= 0)
|
||||
return mix;
|
||||
auto framesPerStep = (double)AUDIO_FREQUENCY / fps;
|
||||
for (std::size_t step = 0; step < frameSounds.size(); ++step)
|
||||
{
|
||||
auto start = (std::size_t)std::floor(step * framesPerStep) * AUDIO_CHANNELS;
|
||||
mix.resize(std::max(mix.size(), (std::size_t)std::floor((step + 1) * framesPerStep) * AUDIO_CHANNELS));
|
||||
for (auto data : frameSounds[step])
|
||||
{
|
||||
auto sound = sound_get(*data);
|
||||
if (!sound)
|
||||
continue;
|
||||
mix.resize(std::max(mix.size(), start + sound->samples.size()));
|
||||
for (std::size_t i = 0; i < sound->samples.size(); ++i)
|
||||
mix[start + i] += sound->samples[i];
|
||||
}
|
||||
}
|
||||
for (auto& sample : mix)
|
||||
sample = std::clamp(sample, -1.0f, 1.0f);
|
||||
return mix;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "vec.h"
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "audio_data.h"
|
||||
|
||||
constexpr int AUDIO_CHANNELS = 2;
|
||||
constexpr int AUDIO_FREQUENCY = 48000;
|
||||
|
||||
enum AudioPlayMode
|
||||
{
|
||||
AUDIO_ONCE,
|
||||
AUDIO_LOOP
|
||||
};
|
||||
|
||||
// Sounds (WAV or Ogg Vorbis) are decoded on their first play to AUDIO_FREQUENCY stereo floats, cached by uid.
|
||||
// Each play is a stream on one shared device, opened on the first play, which mixes them.
|
||||
void audio_play(const AudioData&, AudioPlayMode = AUDIO_ONCE);
|
||||
void audio_stop(const AudioData&);
|
||||
// Lets go of decoded sounds whose uids aren't in this set, once they stop playing.
|
||||
void audio_prune(const std::set<std::uint64_t>&);
|
||||
bool is_audio_playing(const AudioData&);
|
||||
Vec2 audio_levels_get(const AudioData&);
|
||||
|
||||
// Each frame's sounds started on that frame and mixed at `fps`, as interleaved stereo floats.
|
||||
std::vector<float> audio_mix(const std::vector<std::vector<const AudioData*>>&, int fps);
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "audio_data.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
|
||||
#include "uid.h"
|
||||
|
||||
AudioData::AudioData(const unsigned char* memory, size_t size)
|
||||
{
|
||||
if (!memory || size == 0)
|
||||
return;
|
||||
bytes.assign(memory, memory + size);
|
||||
uid = uid_next();
|
||||
}
|
||||
|
||||
AudioData::AudioData(const std::filesystem::path& path)
|
||||
{
|
||||
std::ifstream file(path, std::ios::binary);
|
||||
std::vector<unsigned char> data = {std::istreambuf_iterator<char>(file), {}};
|
||||
*this = AudioData(data.data(), data.size());
|
||||
}
|
||||
|
||||
bool AudioData::is_valid() const
|
||||
{
|
||||
return !bytes.empty();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
// Encoded audio file bytes. uid identifies the bytes so playback state can be cached by it.
|
||||
struct AudioData
|
||||
{
|
||||
std::vector<unsigned char> bytes;
|
||||
std::uint64_t uid = 0;
|
||||
|
||||
AudioData() = default;
|
||||
AudioData(const unsigned char*, size_t);
|
||||
AudioData(const std::filesystem::path&);
|
||||
|
||||
bool is_valid() const;
|
||||
};
|
||||
@@ -1,262 +1,404 @@
|
||||
#include "canvas.hpp"
|
||||
#include "canvas.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <glm/ext/matrix_clip_space.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include "vec.h"
|
||||
|
||||
#include "math.hpp"
|
||||
#include "math_util.h"
|
||||
#include "texture.h"
|
||||
|
||||
using namespace glm;
|
||||
using namespace anm2ed::resource;
|
||||
using namespace anm2ed::util;
|
||||
|
||||
namespace anm2ed
|
||||
static void canvas_blend_premultiplied_set()
|
||||
{
|
||||
Canvas::Canvas() = default;
|
||||
gl.Enable(GL_BLEND);
|
||||
gl.BlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
Canvas::Canvas(vec2 size)
|
||||
{
|
||||
static void canvas_blend_straight_set()
|
||||
{
|
||||
gl.BlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl.Enable(GL_BLEND);
|
||||
}
|
||||
|
||||
static void vertex_array_make(GLuint& vao, GLuint& vbo, const void* data, GLsizeiptr size, GLenum usage,
|
||||
std::initializer_list<int> attributeSizes)
|
||||
{
|
||||
gl.GenVertexArrays(1, &vao);
|
||||
gl.GenBuffers(1, &vbo);
|
||||
gl.BindVertexArray(vao);
|
||||
gl.BindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
gl.BufferData(GL_ARRAY_BUFFER, size, data, usage);
|
||||
|
||||
auto stride = 0;
|
||||
for (auto attributeSize : attributeSizes)
|
||||
stride += attributeSize;
|
||||
auto offset = 0;
|
||||
auto index = 0;
|
||||
for (auto attributeSize : attributeSizes)
|
||||
{
|
||||
gl.EnableVertexAttribArray(index);
|
||||
gl.VertexAttribPointer(index++, attributeSize, GL_FLOAT, GL_FALSE, stride * sizeof(float),
|
||||
(void*)(offset * sizeof(float)));
|
||||
offset += attributeSize;
|
||||
}
|
||||
}
|
||||
|
||||
Canvas::Canvas() = default;
|
||||
|
||||
Canvas::Canvas(Vec2 size)
|
||||
{
|
||||
Framebuffer::size_set(size);
|
||||
vertex_array_make(axisVAO, axisVBO, AXIS_VERTICES, sizeof(AXIS_VERTICES), GL_STATIC_DRAW, {2});
|
||||
vertex_array_make(gridVAO, gridVBO, GRID_VERTICES, sizeof(GRID_VERTICES), GL_STATIC_DRAW, {2, 2});
|
||||
vertex_array_make(rectVAO, rectVBO, RECT_VERTICES, sizeof(RECT_VERTICES), GL_STATIC_DRAW, {2});
|
||||
vertex_array_make(textureVAO, textureVBO, nullptr, sizeof(TEXTURE_VERTICES), GL_DYNAMIC_DRAW, {2, 2});
|
||||
gl.GenBuffers(1, &textureEBO);
|
||||
gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, textureEBO);
|
||||
gl.BufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(TEXTURE_INDICES), TEXTURE_INDICES, GL_DYNAMIC_DRAW);
|
||||
gl.BindVertexArray(0);
|
||||
}
|
||||
|
||||
// Axis
|
||||
glGenVertexArrays(1, &axisVAO);
|
||||
glGenBuffers(1, &axisVBO);
|
||||
Canvas::~Canvas()
|
||||
{
|
||||
if (!Framebuffer::is_valid())
|
||||
return;
|
||||
for (auto vao : {axisVAO, gridVAO, rectVAO, textureVAO})
|
||||
gl.DeleteVertexArrays(1, &vao);
|
||||
for (auto buffer : {axisVBO, gridVBO, rectVBO, textureVBO, textureEBO})
|
||||
gl.DeleteBuffers(1, &buffer);
|
||||
}
|
||||
|
||||
glBindVertexArray(axisVAO);
|
||||
Mat4 Canvas::transform_get(float zoom, Vec2 pan) const
|
||||
{
|
||||
auto zoomFactor = percent_to_unit(zoom);
|
||||
auto projection = mat4_ortho(0.0f, (float)size.x, 0.0f, (float)size.y, -1.0f, 1.0f);
|
||||
auto view = Mat4{1.0f};
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, axisVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(AXIS_VERTICES), AXIS_VERTICES, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
|
||||
|
||||
// Grid
|
||||
glGenVertexArrays(1, &gridVAO);
|
||||
glBindVertexArray(gridVAO);
|
||||
|
||||
glGenBuffers(1, &gridVBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(GRID_VERTICES), GRID_VERTICES, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)0);
|
||||
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)(sizeof(float) * 2));
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
// Rect
|
||||
glGenVertexArrays(1, &rectVAO);
|
||||
glGenBuffers(1, &rectVBO);
|
||||
|
||||
glBindVertexArray(rectVAO);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, rectVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(RECT_VERTICES), RECT_VERTICES, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0);
|
||||
|
||||
// Texture
|
||||
glGenVertexArrays(1, &textureVAO);
|
||||
glGenBuffers(1, &textureVBO);
|
||||
glGenBuffers(1, &textureEBO);
|
||||
|
||||
glBindVertexArray(textureVAO);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, textureVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * 4, nullptr, GL_DYNAMIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, textureEBO);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(TEXTURE_INDICES), TEXTURE_INDICES, GL_DYNAMIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
|
||||
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float)));
|
||||
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
Canvas::~Canvas()
|
||||
{
|
||||
if (!Framebuffer::is_valid()) return;
|
||||
|
||||
glDeleteVertexArrays(1, &axisVAO);
|
||||
glDeleteBuffers(1, &axisVBO);
|
||||
|
||||
glDeleteVertexArrays(1, &gridVAO);
|
||||
glDeleteBuffers(1, &gridVBO);
|
||||
|
||||
glDeleteVertexArrays(1, &rectVAO);
|
||||
glDeleteBuffers(1, &rectVBO);
|
||||
}
|
||||
|
||||
mat4 Canvas::transform_get(float zoom, vec2 pan) const
|
||||
{
|
||||
auto zoomFactor = math::percent_to_unit(zoom);
|
||||
auto projection = glm::ortho(0.0f, (float)size.x, 0.0f, (float)size.y, -1.0f, 1.0f);
|
||||
auto view = mat4{1.0f};
|
||||
|
||||
view = glm::translate(view, vec3((size * 0.5f) + pan, 0.0f));
|
||||
view = glm::scale(view, vec3(zoomFactor, zoomFactor, 1.0f));
|
||||
view = mat4_translate(view, Vec3((size * 0.5f) + pan, 0.0f));
|
||||
view = mat4_scale(view, Vec3(zoomFactor, zoomFactor, 1.0f));
|
||||
|
||||
return projection * view;
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::axes_render(Shader& shader, float zoom, vec2 pan, vec4 color) const
|
||||
{
|
||||
auto originNDC = transform_get(zoom, pan) * vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
void Canvas::axes_render(ShaderProgram& shader, float zoom, Vec2 pan, Vec4 color) const
|
||||
{
|
||||
canvas_blend_premultiplied_set();
|
||||
|
||||
auto originNDC = transform_get(zoom, pan) * Vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
originNDC /= originNDC.w;
|
||||
|
||||
glUseProgram(shader.id);
|
||||
gl.UseProgram(shader.id);
|
||||
|
||||
glUniform4fv(glGetUniformLocation(shader.id, shader::UNIFORM_COLOR), 1, value_ptr(color));
|
||||
glUniform2f(glGetUniformLocation(shader.id, shader::UNIFORM_ORIGIN_NDC), originNDC.x, originNDC.y);
|
||||
gl.Uniform4fv(gl.GetUniformLocation(shader.id, UNIFORM_COLOR), 1, values_get(color));
|
||||
gl.Uniform2f(gl.GetUniformLocation(shader.id, UNIFORM_ORIGIN_NDC), originNDC.x, originNDC.y);
|
||||
|
||||
glBindVertexArray(axisVAO);
|
||||
gl.BindVertexArray(axisVAO);
|
||||
|
||||
glUniform1i(glGetUniformLocation(shader.id, shader::UNIFORM_AXIS), 0);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
gl.Uniform1i(gl.GetUniformLocation(shader.id, UNIFORM_AXIS), 0);
|
||||
gl.DrawArrays(GL_LINES, 0, 2);
|
||||
|
||||
glUniform1i(glGetUniformLocation(shader.id, shader::UNIFORM_AXIS), 1);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
gl.Uniform1i(gl.GetUniformLocation(shader.id, UNIFORM_AXIS), 1);
|
||||
gl.DrawArrays(GL_LINES, 0, 2);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
gl.BindVertexArray(0);
|
||||
gl.UseProgram(0);
|
||||
canvas_blend_straight_set();
|
||||
}
|
||||
|
||||
void Canvas::grid_render(Shader& shader, float zoom, vec2 pan, ivec2 size, ivec2 offset, vec4 color) const
|
||||
{
|
||||
auto transform = glm::inverse(transform_get(zoom, pan));
|
||||
void Canvas::grid_render(ShaderProgram& shader, float zoom, Vec2 pan, IVec2 size, IVec2 offset, Vec4 color) const
|
||||
{
|
||||
canvas_blend_premultiplied_set();
|
||||
|
||||
glUseProgram(shader.id);
|
||||
auto transform = mat4_inverse(transform_get(zoom, pan));
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader.id, shader::UNIFORM_TRANSFORM), 1, GL_FALSE, value_ptr(transform));
|
||||
glUniform2f(glGetUniformLocation(shader.id, shader::UNIFORM_SIZE), (float)size.x, (float)size.y);
|
||||
glUniform2f(glGetUniformLocation(shader.id, shader::UNIFORM_OFFSET), (float)offset.x, (float)offset.y);
|
||||
glUniform4f(glGetUniformLocation(shader.id, shader::UNIFORM_COLOR), color.r, color.g, color.b, color.a);
|
||||
gl.UseProgram(shader.id);
|
||||
|
||||
glBindVertexArray(gridVAO);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
gl.UniformMatrix4fv(gl.GetUniformLocation(shader.id, UNIFORM_TRANSFORM), 1, GL_FALSE, values_get(transform));
|
||||
gl.Uniform2f(gl.GetUniformLocation(shader.id, UNIFORM_SIZE), (float)size.x, (float)size.y);
|
||||
gl.Uniform2f(gl.GetUniformLocation(shader.id, UNIFORM_OFFSET), (float)offset.x, (float)offset.y);
|
||||
gl.Uniform4f(gl.GetUniformLocation(shader.id, UNIFORM_COLOR), color.r, color.g, color.b, color.a);
|
||||
|
||||
glUseProgram(0);
|
||||
}
|
||||
gl.BindVertexArray(gridVAO);
|
||||
gl.DrawArrays(GL_TRIANGLES, 0, 3);
|
||||
gl.BindVertexArray(0);
|
||||
|
||||
void Canvas::texture_render(Shader& shader, GLuint& texture, mat4 transform, vec4 tint, vec3 colorOffset,
|
||||
float* vertices) const
|
||||
{
|
||||
glUseProgram(shader.id);
|
||||
gl.UseProgram(0);
|
||||
canvas_blend_straight_set();
|
||||
}
|
||||
|
||||
glUniform1i(glGetUniformLocation(shader.id, shader::UNIFORM_TEXTURE), 0);
|
||||
glUniform3fv(glGetUniformLocation(shader.id, shader::UNIFORM_COLOR_OFFSET), 1, value_ptr(colorOffset));
|
||||
glUniform4fv(glGetUniformLocation(shader.id, shader::UNIFORM_TINT), 1, value_ptr(tint));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader.id, shader::UNIFORM_TRANSFORM), 1, GL_FALSE, value_ptr(transform));
|
||||
static void texture_uniform_set(const ShaderUniform& uniform, Vec4 value)
|
||||
{
|
||||
if (uniform.valueType == UNIFORM_VALUE_INT || uniform.valueType == UNIFORM_VALUE_SAMPLER2D)
|
||||
return gl.Uniform1i(uniform.location, uniform.intValue);
|
||||
switch (UNIFORM_VALUE_TYPE_INFOS[uniform.valueType].componentCount)
|
||||
{
|
||||
case 2:
|
||||
return gl.Uniform2fv(uniform.location, 1, values_get(value));
|
||||
case 3:
|
||||
return gl.Uniform3fv(uniform.location, 1, values_get(value));
|
||||
case 4:
|
||||
return gl.Uniform4fv(uniform.location, 1, values_get(value));
|
||||
default:
|
||||
if (uniform.valueType == UNIFORM_VALUE_FLOAT)
|
||||
gl.Uniform1f(uniform.location, value.x);
|
||||
}
|
||||
}
|
||||
|
||||
glBindVertexArray(textureVAO);
|
||||
static Vec4 texture_uniform_components_get(const ShaderUniform& uniform, float playbackTime)
|
||||
{
|
||||
Vec4 result{};
|
||||
for (int i = 0; i < (int)uniform.components.size(); ++i)
|
||||
result[i] =
|
||||
uniform.components[i].binding == UNIFORM_BINDING_PLAYBACK_TIME ? playbackTime : uniform.components[i].value;
|
||||
return result;
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, textureVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(TEXTURE_VERTICES), vertices, GL_DYNAMIC_DRAW);
|
||||
static void texture_uniforms_set(ShaderProgram& shader, Mat4 transform, Vec4 tint, Vec4 colorOffset, Vec2 textureSize,
|
||||
float playbackTime)
|
||||
{
|
||||
if (shader.uniforms.empty())
|
||||
{
|
||||
gl.Uniform1i(gl.GetUniformLocation(shader.id, UNIFORM_TEXTURE), 0);
|
||||
gl.Uniform4fv(gl.GetUniformLocation(shader.id, UNIFORM_COLOR_OFFSET), 1, values_get(colorOffset));
|
||||
gl.Uniform4fv(gl.GetUniformLocation(shader.id, UNIFORM_TINT), 1, values_get(tint));
|
||||
gl.UniformMatrix4fv(gl.GetUniformLocation(shader.id, UNIFORM_TRANSFORM), 1, GL_FALSE, values_get(transform));
|
||||
return;
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
for (auto& uniform : shader.uniforms)
|
||||
{
|
||||
if (uniform.location == -1)
|
||||
continue;
|
||||
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
switch (uniform.binding)
|
||||
{
|
||||
case UNIFORM_BINDING_MAIN_TEXTURE:
|
||||
gl.Uniform1i(uniform.location, 0);
|
||||
break;
|
||||
case UNIFORM_BINDING_TRANSFORM:
|
||||
if (uniform.valueType == UNIFORM_VALUE_MAT4)
|
||||
gl.UniformMatrix4fv(uniform.location, 1, GL_FALSE, values_get(transform));
|
||||
break;
|
||||
case UNIFORM_BINDING_FRAME_TINT:
|
||||
texture_uniform_set(uniform, tint);
|
||||
break;
|
||||
case UNIFORM_BINDING_COLOR_OFFSET:
|
||||
texture_uniform_set(uniform, colorOffset);
|
||||
break;
|
||||
case UNIFORM_BINDING_TEXTURE_SIZE:
|
||||
texture_uniform_set(uniform, Vec4(textureSize, 0.0f, 0.0f));
|
||||
break;
|
||||
case UNIFORM_BINDING_PLAYBACK_TIME:
|
||||
texture_uniform_set(uniform, Vec4(playbackTime));
|
||||
break;
|
||||
case UNIFORM_BINDING_COMPONENTS:
|
||||
texture_uniform_set(uniform, texture_uniform_components_get(uniform, playbackTime));
|
||||
break;
|
||||
case UNIFORM_BINDING_MANUAL:
|
||||
texture_uniform_set(uniform, uniform.value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glUseProgram(0);
|
||||
void Canvas::texture_render(ShaderProgram& shader, GLuint texture, const TextureDraw& draw) const
|
||||
{
|
||||
auto& [transform, tint, colorOffset, vertices, textureSize, playbackTime, blur] = draw;
|
||||
canvas_blend_premultiplied_set();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
gl.UseProgram(shader.id);
|
||||
|
||||
void Canvas::rect_render(Shader& shader, const mat4& transform, const mat4& model, vec4 color, float dashLength,
|
||||
float dashGap, float dashOffset) const
|
||||
{
|
||||
glUseProgram(shader.id);
|
||||
texture_uniforms_set(shader, transform, tint, colorOffset, textureSize, playbackTime);
|
||||
// The editor's own texture shader blurs. A custom shader without these uniforms ignores them.
|
||||
gl.Uniform1f(gl.GetUniformLocation(shader.id, UNIFORM_BLUR), blur.radius);
|
||||
gl.Uniform4fv(gl.GetUniformLocation(shader.id, UNIFORM_REGION), 1, values_get(blur.region));
|
||||
gl.Uniform2fv(gl.GetUniformLocation(shader.id, UNIFORM_TEXEL), 1,
|
||||
values_get(textureSize.x > 0 && textureSize.y > 0 ? 1.0f / textureSize : Vec2()));
|
||||
gl.VertexAttrib4fv(2, values_get(tint));
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader.id, shader::UNIFORM_TRANSFORM), 1, GL_FALSE, value_ptr(transform));
|
||||
if (auto location = glGetUniformLocation(shader.id, shader::UNIFORM_MODEL); location != -1)
|
||||
glUniformMatrix4fv(location, 1, GL_FALSE, value_ptr(model));
|
||||
glUniform4fv(glGetUniformLocation(shader.id, shader::UNIFORM_COLOR), 1, value_ptr(color));
|
||||
gl.BindVertexArray(textureVAO);
|
||||
|
||||
auto origin = model * vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
auto edgeX = model * vec4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
auto edgeY = model * vec4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
gl.BindBuffer(GL_ARRAY_BUFFER, textureVBO);
|
||||
gl.BufferData(GL_ARRAY_BUFFER, sizeof(TEXTURE_VERTICES), vertices ? vertices : TEXTURE_VERTICES, GL_DYNAMIC_DRAW);
|
||||
|
||||
auto axisX = vec2(edgeX - origin);
|
||||
auto axisY = vec2(edgeY - origin);
|
||||
gl.ActiveTexture(GL_TEXTURE0);
|
||||
gl.BindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
if (auto location = glGetUniformLocation(shader.id, shader::UNIFORM_AXIS_X); location != -1)
|
||||
glUniform2fv(location, 1, value_ptr(axisX));
|
||||
if (auto location = glGetUniformLocation(shader.id, shader::UNIFORM_AXIS_Y); location != -1)
|
||||
glUniform2fv(location, 1, value_ptr(axisY));
|
||||
gl.DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
|
||||
if (auto location = glGetUniformLocation(shader.id, shader::UNIFORM_DASH_LENGTH); location != -1)
|
||||
glUniform1f(location, dashLength);
|
||||
if (auto location = glGetUniformLocation(shader.id, shader::UNIFORM_DASH_GAP); location != -1)
|
||||
glUniform1f(location, dashGap);
|
||||
if (auto location = glGetUniformLocation(shader.id, shader::UNIFORM_DASH_OFFSET); location != -1)
|
||||
glUniform1f(location, dashOffset);
|
||||
gl.BindVertexArray(0);
|
||||
gl.BindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
gl.BindTexture(GL_TEXTURE_2D, 0);
|
||||
gl.UseProgram(0);
|
||||
|
||||
glBindVertexArray(rectVAO);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, 4);
|
||||
canvas_blend_straight_set();
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
static void rect_begin(ShaderProgram& shader, const Mat4& transform, const Mat4& model, Vec4 color)
|
||||
{
|
||||
canvas_blend_premultiplied_set();
|
||||
gl.UseProgram(shader.id);
|
||||
gl.UniformMatrix4fv(gl.GetUniformLocation(shader.id, UNIFORM_TRANSFORM), 1, GL_FALSE, values_get(transform));
|
||||
if (auto location = gl.GetUniformLocation(shader.id, UNIFORM_MODEL); location != -1)
|
||||
gl.UniformMatrix4fv(location, 1, GL_FALSE, values_get(model));
|
||||
gl.Uniform4fv(gl.GetUniformLocation(shader.id, UNIFORM_COLOR), 1, values_get(color));
|
||||
}
|
||||
|
||||
void Canvas::rect_fill_render(Shader& shader, const mat4& transform, const mat4& model, vec4 color) const
|
||||
{
|
||||
glUseProgram(shader.id);
|
||||
static void rect_end(GLuint vao, GLenum mode, int count = 4)
|
||||
{
|
||||
gl.BindVertexArray(vao);
|
||||
gl.DrawArrays(mode, 0, count);
|
||||
gl.BindVertexArray(0);
|
||||
gl.UseProgram(0);
|
||||
canvas_blend_straight_set();
|
||||
}
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader.id, shader::UNIFORM_TRANSFORM), 1, GL_FALSE, value_ptr(transform));
|
||||
if (auto location = glGetUniformLocation(shader.id, shader::UNIFORM_MODEL); location != -1)
|
||||
glUniformMatrix4fv(location, 1, GL_FALSE, value_ptr(model));
|
||||
glUniform4fv(glGetUniformLocation(shader.id, shader::UNIFORM_COLOR), 1, value_ptr(color));
|
||||
void Canvas::dashed_render(ShaderProgram& shader, const Mat4& transform, const Mat4& model, Vec4 color, Dash dash,
|
||||
DashedShape shape) const
|
||||
{
|
||||
rect_begin(shader, transform, model, color);
|
||||
|
||||
glBindVertexArray(rectVAO);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
auto origin = model * Vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
for (auto [name, axis] : {std::pair{UNIFORM_AXIS_X, Vec4(1.0f, 0.0f, 0.0f, 1.0f)},
|
||||
std::pair{UNIFORM_AXIS_Y, Vec4(0.0f, 1.0f, 0.0f, 1.0f)}})
|
||||
if (auto location = gl.GetUniformLocation(shader.id, name); location != -1)
|
||||
gl.Uniform2fv(location, 1, values_get(Vec2(model * axis - origin)));
|
||||
for (auto [name, value] : {std::pair{UNIFORM_DASH_LENGTH, dash.length}, std::pair{UNIFORM_DASH_GAP, dash.gap},
|
||||
std::pair{UNIFORM_DASH_OFFSET, dash.offset}})
|
||||
if (auto location = gl.GetUniformLocation(shader.id, name); location != -1)
|
||||
gl.Uniform1f(location, value);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
if (shape == DASHED_RECT)
|
||||
rect_end(rectVAO, GL_LINE_LOOP, RECT_VERTEX_COUNT);
|
||||
else
|
||||
rect_end(rectVAO, GL_LINES, LINE_VERTEX_COUNT);
|
||||
}
|
||||
|
||||
void Canvas::zoom_set(float& zoom, vec2& pan, vec2 focus, float step) const
|
||||
{
|
||||
auto zoomFactor = math::percent_to_unit(zoom);
|
||||
float newZoom = glm::clamp(math::round_nearest_multiple(zoom + step, step), ZOOM_MIN, ZOOM_MAX);
|
||||
// A layer draw's crop of its spritesheet. A blurred one (Flash's BlurFilter: a box `blur` canvas pixels wide) grows by
|
||||
// the box's reach, in texels at the draw's scale, and averages its crop over it.
|
||||
void Canvas::layer_render(ShaderProgram& shader, GLuint texture, Vec2 textureSize, const Mat4& transform,
|
||||
const Draw& draw, Vec4 tint, Vec4 colorOffset) const
|
||||
{
|
||||
auto blurred = draw;
|
||||
auto& frame = blurred.frame;
|
||||
TextureBlur blur = {.region = Vec4(frame.crop, frame.crop + frame.size) / Vec4(textureSize, textureSize)};
|
||||
if (frame.blur > 0.0f && frame.size.x > 0.0f && frame.size.y > 0.0f)
|
||||
{
|
||||
auto matrix = draw.parent * draw_quad_model_get(draw);
|
||||
auto canvasArea = std::abs(matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1]);
|
||||
auto canvasPerTexel = std::sqrt(canvasArea / (frame.size.x * frame.size.y));
|
||||
blur.radius = canvasPerTexel > 0.0f ? std::round(frame.blur * 0.5f / canvasPerTexel) : 0.0f;
|
||||
frame.crop -= blur.radius;
|
||||
frame.size += blur.radius * 2.0f;
|
||||
frame.pivot += blur.radius;
|
||||
}
|
||||
auto vertices = uv_vertices_get(frame.crop / textureSize, (frame.crop + frame.size) / textureSize);
|
||||
texture_render(shader, texture,
|
||||
{.transform = transform * blurred.parent * draw_quad_model_get(blurred),
|
||||
.tint = tint,
|
||||
.colorOffset = colorOffset,
|
||||
.vertices = vertices.data(),
|
||||
.textureSize = textureSize,
|
||||
.time = draw.time,
|
||||
.blur = blur});
|
||||
}
|
||||
|
||||
// An animation's layers alone (no markers or helpers). Spritesheet images are looked up by draw, custom shaders by id.
|
||||
void Canvas::layers_render(ShaderProgram& shader, const Model& model, const Animation& animation,
|
||||
const DrawOptions& options, const Mat4& transform,
|
||||
const std::function<const Image*(const Draw&)>& image_get,
|
||||
const std::function<ShaderProgram*(int)>& shader_get) const
|
||||
{
|
||||
for (auto& draw : animation_draws_get(model, animation, options))
|
||||
{
|
||||
if (draw.type != DrawType::LAYER)
|
||||
continue;
|
||||
auto& frame = draw.frame;
|
||||
auto image = image_get(draw);
|
||||
if (!image || !image->is_valid() || frame.size == Vec2())
|
||||
continue;
|
||||
auto customShader = shader_get ? shader_get(frame.shaderId) : nullptr;
|
||||
layer_render(customShader ? *customShader : shader, texture_id_get(*image), image->unit_size_get(), transform,
|
||||
draw, frame.tint, frame.colorOffset);
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::rect_render(ShaderProgram& shader, const Mat4& transform, const Mat4& model, Vec4 color, Dash dash) const
|
||||
{
|
||||
dashed_render(shader, transform, model, color, dash, DASHED_RECT);
|
||||
}
|
||||
|
||||
// A line from start to end: the bottom edge of a rectangle laid along it.
|
||||
void Canvas::line_render(ShaderProgram& shader, const Mat4& transform, Vec2 start, Vec2 end, Vec4 color,
|
||||
Dash dash) const
|
||||
{
|
||||
auto direction = end - start;
|
||||
auto normal = vec_length(direction) > 0.0f ? vec_normalize(Vec2(-direction.y, direction.x)) : Vec2(0.0f, 1.0f);
|
||||
auto model = Mat4(Vec4(direction, 0.0f, 0.0f), Vec4(normal, 0.0f, 0.0f), Vec4(0.0f, 0.0f, 1.0f, 0.0f),
|
||||
Vec4(start, 0.0f, 1.0f));
|
||||
dashed_render(shader, transform, model, color, dash, DASHED_LINE);
|
||||
}
|
||||
|
||||
void Canvas::rect_fill_render(ShaderProgram& shader, const Mat4& transform, const Mat4& model, Vec4 color) const
|
||||
{
|
||||
rect_begin(shader, transform, model, color);
|
||||
rect_end(rectVAO, GL_TRIANGLE_FAN);
|
||||
}
|
||||
|
||||
float Canvas::zoom_level_get(float zoom, int levelDelta) const
|
||||
{
|
||||
if (levelDelta == 0)
|
||||
return zoom;
|
||||
if (zoom < ZOOM_LEVELS.front())
|
||||
return ZOOM_LEVELS.front();
|
||||
if (zoom > ZOOM_LEVELS.back())
|
||||
return ZOOM_LEVELS.back();
|
||||
|
||||
auto levelCount = (int)ZOOM_LEVELS.size();
|
||||
int levelIndex = 0;
|
||||
if (levelDelta > 0)
|
||||
{
|
||||
auto it = std::upper_bound(ZOOM_LEVELS.begin(), ZOOM_LEVELS.end(), zoom);
|
||||
levelIndex = (int)std::distance(ZOOM_LEVELS.begin(), it) + levelDelta - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = std::lower_bound(ZOOM_LEVELS.begin(), ZOOM_LEVELS.end(), zoom);
|
||||
levelIndex = (int)std::distance(ZOOM_LEVELS.begin(), it) + levelDelta;
|
||||
}
|
||||
|
||||
return ZOOM_LEVELS[std::clamp(levelIndex, 0, levelCount - 1)];
|
||||
}
|
||||
|
||||
void Canvas::zoom_level_adjust(float& zoom, Vec2& pan, Vec2 focus, int levelDelta) const
|
||||
{
|
||||
auto zoomFactor = percent_to_unit(zoom);
|
||||
float newZoom = zoom_level_get(zoom, levelDelta);
|
||||
if (newZoom != zoom)
|
||||
{
|
||||
float newZoomFactor = math::percent_to_unit(newZoom);
|
||||
pan += focus * (zoomFactor - newZoomFactor);
|
||||
zoom = newZoom;
|
||||
float newZoomFactor = percent_to_unit(newZoom);
|
||||
pan += focus * (zoomFactor - newZoomFactor);
|
||||
zoom = newZoom;
|
||||
}
|
||||
}
|
||||
|
||||
Vec2 Canvas::position_translate(float& zoom, Vec2& pan, Vec2 position) const
|
||||
{
|
||||
auto zoomFactor = percent_to_unit(zoom);
|
||||
return (position - pan - (size * 0.5f)) / zoomFactor;
|
||||
}
|
||||
|
||||
void Canvas::set_to_rect(float& zoom, Vec2& pan, Vec4 rect) const
|
||||
{
|
||||
if (rect != Vec4(-1.0f) && (rect.z > 0 && rect.w > 0))
|
||||
{
|
||||
float scaleX = size.x / rect.z;
|
||||
float scaleY = size.y / rect.w;
|
||||
float fitScale = std::min(scaleX, scaleY);
|
||||
|
||||
zoom = unit_to_percent(fitScale);
|
||||
|
||||
Vec2 rectCenter = {rect.x + rect.z * 0.5f, rect.y + rect.w * 0.5f};
|
||||
pan = -rectCenter * fitScale;
|
||||
}
|
||||
}
|
||||
|
||||
vec2 Canvas::position_translate(float& zoom, vec2& pan, vec2 position) const
|
||||
{
|
||||
auto zoomFactor = math::percent_to_unit(zoom);
|
||||
return (position - pan - (size * 0.5f)) / zoomFactor;
|
||||
}
|
||||
|
||||
void Canvas::set_to_rect(float& zoom, vec2& pan, vec4 rect) const
|
||||
{
|
||||
if (rect != vec4(-1.0f) && (rect.z > 0 && rect.w > 0))
|
||||
{
|
||||
f32 scaleX = size.x / rect.z;
|
||||
f32 scaleY = size.y / rect.w;
|
||||
f32 fitScale = std::min(scaleX, scaleY);
|
||||
|
||||
zoom = math::unit_to_percent(fitScale);
|
||||
|
||||
vec2 rectCenter = {rect.x + rect.z * 0.5f, rect.y + rect.w * 0.5f};
|
||||
pan = -rectCenter * fitScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
|
||||
#include "gl.h"
|
||||
#include "vec.h"
|
||||
|
||||
#include "framebuffer.h"
|
||||
#include "image.h"
|
||||
#include "model/draw.h"
|
||||
#include "shader.h"
|
||||
|
||||
#include "types.h"
|
||||
|
||||
// A box blur `radius` texels wide each way over the texture's `region` (UV min, max). Outside it is clear.
|
||||
struct TextureBlur
|
||||
{
|
||||
float radius = 0;
|
||||
Vec4 region{};
|
||||
};
|
||||
|
||||
constexpr float DASH_LENGTH = 4.0f;
|
||||
constexpr float DASH_GAP = 1.0f;
|
||||
constexpr float DASH_OFFSET = 1.0f;
|
||||
|
||||
// A dashed outline's pattern, in canvas pixels.
|
||||
struct Dash
|
||||
{
|
||||
float length = DASH_LENGTH;
|
||||
float gap = DASH_GAP;
|
||||
float offset = DASH_OFFSET;
|
||||
};
|
||||
|
||||
enum DashedShape
|
||||
{
|
||||
DASHED_RECT,
|
||||
DASHED_LINE
|
||||
};
|
||||
|
||||
// How a texture is drawn: placed by `transform`, colored, over `vertices` (the whole texture when null), with what a
|
||||
// layer's shader reads (its texture size and playback time) and its blur.
|
||||
struct TextureDraw
|
||||
{
|
||||
Mat4 transform = Mat4(1.0f);
|
||||
Vec4 tint = Vec4(1.0f);
|
||||
Vec4 colorOffset{};
|
||||
const float* vertices = nullptr;
|
||||
Vec2 textureSize{};
|
||||
float time = 0;
|
||||
TextureBlur blur = {};
|
||||
};
|
||||
|
||||
class Canvas : public Framebuffer
|
||||
{
|
||||
public:
|
||||
static constexpr float TEXTURE_VERTICES[] = {0, 0, 0.0f, 0.0f, 1, 0, 1.0f, 0.0f,
|
||||
1, 1, 1.0f, 1.0f, 0, 1, 0.0f, 1.0f};
|
||||
static constexpr auto PIVOT_SIZE = Vec2(8, 8);
|
||||
static constexpr auto ZOOM_MIN = 1.0f;
|
||||
static constexpr auto ZOOM_MAX = 2000.0f;
|
||||
static constexpr auto STEP = 1.0f;
|
||||
static constexpr auto STEP_FAST = 5.0f;
|
||||
static constexpr auto ZOOM_LEVEL_STEP = 1;
|
||||
static constexpr std::array ZOOM_LEVELS = {1.0f, 2.0f, 5.0f, 10.0f, 15.0f, 25.0f, 33.0f,
|
||||
50.0f, 66.0f, 75.0f, 100.0f, 125.0f, 150.0f, 200.0f,
|
||||
300.0f, 400.0f, 600.0f, 800.0f, 1200.0f, 2000.0f};
|
||||
static constexpr auto GRID_SIZE_MIN = 1;
|
||||
static constexpr auto GRID_SIZE_MAX = 10000;
|
||||
static constexpr auto GRID_OFFSET_MIN = 0;
|
||||
static constexpr auto GRID_OFFSET_MAX = 10000;
|
||||
static constexpr auto CHECKER_SIZE = 32.0f;
|
||||
static constexpr float AXIS_VERTICES[] = {-1.0f, 0.0f, 1.0f, 0.0f};
|
||||
static constexpr float GRID_VERTICES[] = {-1.f, -1.f, 0.f, 0.f, 3.f, -1.f, 2.f, 0.f, -1.f, 3.f, 0.f, 2.f};
|
||||
static constexpr float RECT_VERTICES[] = {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f};
|
||||
static constexpr int RECT_VERTEX_COUNT = 4;
|
||||
static constexpr int LINE_VERTEX_COUNT = 2;
|
||||
static constexpr GLuint TEXTURE_INDICES[] = {0, 1, 2, 2, 3, 0};
|
||||
static constexpr Dash BORDER_DASH = {.length = 1.0f, .gap = 0.5f, .offset = 0.0f};
|
||||
static constexpr auto PIVOT_COLOR = COLOR_PINK;
|
||||
|
||||
GLuint axisVAO = 0;
|
||||
GLuint axisVBO = 0;
|
||||
GLuint rectVAO = 0;
|
||||
GLuint rectVBO = 0;
|
||||
GLuint gridVAO = 0;
|
||||
GLuint gridVBO = 0;
|
||||
GLuint textureVAO = 0;
|
||||
GLuint textureVBO = 0;
|
||||
GLuint textureEBO = 0;
|
||||
|
||||
Canvas();
|
||||
Canvas(Vec2);
|
||||
~Canvas();
|
||||
Mat4 transform_get(float = 100.0f, Vec2 = {}) const;
|
||||
void axes_render(ShaderProgram&, float, Vec2, Vec4 = Vec4(1.0f)) const;
|
||||
void grid_render(ShaderProgram&, float, Vec2, IVec2 = IVec2(32, 32), IVec2 = {}, Vec4 = Vec4(1.0f)) const;
|
||||
void texture_render(ShaderProgram&, GLuint, const TextureDraw&) const;
|
||||
void layer_render(ShaderProgram&, GLuint, Vec2, const Mat4&, const Draw&, Vec4, Vec4) const;
|
||||
void rect_fill_render(ShaderProgram&, const Mat4&, const Mat4&, Vec4 = Vec4(1.0f)) const;
|
||||
void layers_render(ShaderProgram&, const Model&, const Animation&, const DrawOptions&, const Mat4&,
|
||||
const std::function<const Image*(const Draw&)>&,
|
||||
const std::function<ShaderProgram*(int)>& = {}) const;
|
||||
void dashed_render(ShaderProgram&, const Mat4&, const Mat4&, Vec4, Dash, DashedShape) const;
|
||||
void rect_render(ShaderProgram&, const Mat4&, const Mat4&, Vec4 = Vec4(1.0f), Dash = {}) const;
|
||||
void line_render(ShaderProgram&, const Mat4&, Vec2, Vec2, Vec4 = Vec4(1.0f), Dash = {}) const;
|
||||
float zoom_level_get(float, int) const;
|
||||
void zoom_level_adjust(float&, Vec2&, Vec2, int) const;
|
||||
Vec2 position_translate(float&, Vec2&, Vec2) const;
|
||||
void set_to_rect(float& zoom, Vec2& pan, Vec4 rect) const;
|
||||
};
|
||||
@@ -1,68 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "framebuffer.hpp"
|
||||
#include "shader.hpp"
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
namespace anm2ed
|
||||
{
|
||||
class Canvas : public Framebuffer
|
||||
{
|
||||
public:
|
||||
static constexpr float TEXTURE_VERTICES[] = {0, 0, 0.0f, 0.0f, 1, 0, 1.0f, 0.0f,
|
||||
1, 1, 1.0f, 1.0f, 0, 1, 0.0f, 1.0f};
|
||||
static constexpr auto PIVOT_SIZE = glm::vec2(8, 8);
|
||||
static constexpr auto ZOOM_MIN = 1.0f;
|
||||
static constexpr auto ZOOM_MAX = 2000.0f;
|
||||
static constexpr auto DASH_LENGTH = 4.0f;
|
||||
static constexpr auto DASH_GAP = 1.0f;
|
||||
static constexpr auto DASH_OFFSET = 1.0f;
|
||||
static constexpr auto STEP = 1.0f;
|
||||
static constexpr auto STEP_FAST = 5.0f;
|
||||
static constexpr auto ZOOM_STEP_FAST_MULTIPLIER = 5.0f;
|
||||
static constexpr auto GRID_SIZE_MIN = 1;
|
||||
static constexpr auto GRID_SIZE_MAX = 10000;
|
||||
static constexpr auto GRID_OFFSET_MIN = 0;
|
||||
static constexpr auto GRID_OFFSET_MAX = 10000;
|
||||
static constexpr auto CHECKER_SIZE = 32.0f;
|
||||
static constexpr float AXIS_VERTICES[] = {-1.0f, 0.0f, 1.0f, 0.0f};
|
||||
static constexpr float GRID_VERTICES[] = {-1.f, -1.f, 0.f, 0.f, 3.f, -1.f, 2.f, 0.f, -1.f, 3.f, 0.f, 2.f};
|
||||
static constexpr float RECT_VERTICES[] = {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f};
|
||||
static constexpr GLuint TEXTURE_INDICES[] = {0, 1, 2, 2, 3, 0};
|
||||
static constexpr auto BORDER_DASH_LENGTH = 1.0f;
|
||||
static constexpr auto BORDER_DASH_GAP = 0.5f;
|
||||
static constexpr auto BORDER_DASH_OFFSET = 0.0f;
|
||||
static constexpr auto PIVOT_COLOR = types::color::PINK;
|
||||
|
||||
GLuint axisVAO{};
|
||||
GLuint axisVBO{};
|
||||
GLuint rectVAO{};
|
||||
GLuint rectVBO{};
|
||||
GLuint gridVAO{};
|
||||
GLuint gridVBO{};
|
||||
GLuint textureVAO{};
|
||||
GLuint textureVBO{};
|
||||
GLuint textureEBO{};
|
||||
|
||||
Canvas();
|
||||
Canvas(glm::vec2);
|
||||
~Canvas();
|
||||
glm::mat4 transform_get(float = 100.0f, glm::vec2 = {}) const;
|
||||
void axes_render(resource::Shader&, float, glm::vec2, glm::vec4 = glm::vec4(1.0f)) const;
|
||||
void grid_render(resource::Shader&, float, glm::vec2, glm::ivec2 = glm::ivec2(32, 32), glm::ivec2 = {},
|
||||
glm::vec4 = glm::vec4(1.0f)) const;
|
||||
void texture_render(resource::Shader&, GLuint&, glm::mat4 = {1.0f}, glm::vec4 = glm::vec4(1.0f), glm::vec3 = {},
|
||||
float* = (float*)TEXTURE_VERTICES) const;
|
||||
void rect_fill_render(resource::Shader&, const glm::mat4&, const glm::mat4&,
|
||||
glm::vec4 = glm::vec4(1.0f)) const;
|
||||
void rect_render(resource::Shader&, const glm::mat4&, const glm::mat4&, glm::vec4 = glm::vec4(1.0f),
|
||||
float dashLength = DASH_LENGTH, float dashGap = DASH_GAP, float dashOffset = DASH_OFFSET) const;
|
||||
void zoom_set(float&, glm::vec2&, glm::vec2, float) const;
|
||||
glm::vec2 position_translate(float&, glm::vec2&, glm::vec2) const;
|
||||
void set_to_rect(float& zoom, glm::vec2& pan, glm::vec4 rect) const;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
#include "cli.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <charconv>
|
||||
#include <cstdio>
|
||||
#include <format>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <print>
|
||||
#include <string>
|
||||
|
||||
#include "canvas.h"
|
||||
#include "document.h"
|
||||
#include "image.h"
|
||||
#include "model/xml.h"
|
||||
#include "path.h"
|
||||
#include "render.h"
|
||||
#include "sdl.h"
|
||||
#include "settings.h"
|
||||
#include "working_directory.h"
|
||||
|
||||
constexpr const char* USAGE = R"(usage: anm2ed <command> <file.anm2> [options]
|
||||
|
||||
commands:
|
||||
info animations, items, spritesheets and Isaac compatibility, as text
|
||||
frame one frame as a PNG (--out, --time)
|
||||
convert the document as --format, to --out (default: the file itself)
|
||||
render the animation as --type:
|
||||
sheet all frames in a grid PNG (default; --rows, --columns)
|
||||
pngs one PNG per frame in the --out folder (--format, default "{}.png")
|
||||
gif, webm, mp4, ogv through FFmpeg (--ffmpeg, default: the editor's setting)
|
||||
|
||||
options:
|
||||
--format json|xml the document format for "convert" (default xml: the game's, with the editor's copy)
|
||||
--animation NAME|INDEX which animation (default: the default animation)
|
||||
--out PATH where to write
|
||||
--time T frame time for "frame" (default 0)
|
||||
--start N, --end N frame range for "render" (default: the whole animation)
|
||||
--fps N frames per second to sample (default: the animation's)
|
||||
--scale S output scale (default 1)
|
||||
--background RRGGBB background color, or "transparent" (default)
|
||||
--no-root-transform draw without the root's transform
|
||||
)";
|
||||
|
||||
constexpr float SCALE_DEFAULT = 1.0f;
|
||||
constexpr int HEX_BASE = 16;
|
||||
constexpr int HEX_RGB_LENGTH = 6;
|
||||
constexpr float CHANNEL_MAX = 255.0f;
|
||||
|
||||
struct Arguments
|
||||
{
|
||||
std::string command;
|
||||
std::filesystem::path file;
|
||||
std::map<std::string, std::string> options;
|
||||
|
||||
std::optional<std::string> get(const std::string& name) const
|
||||
{
|
||||
auto it = options.find(name);
|
||||
return it == options.end() ? std::nullopt : std::optional(it->second);
|
||||
}
|
||||
|
||||
template <class T> T number_get(const std::string& name, T value) const
|
||||
{
|
||||
if (auto text = get(name))
|
||||
std::from_chars(text->data(), text->data() + text->size(), value);
|
||||
return value;
|
||||
}
|
||||
|
||||
bool is(const std::string& name) const
|
||||
{
|
||||
return options.contains(name);
|
||||
}
|
||||
};
|
||||
|
||||
// PNG sequences go into a folder. Everything else is a file.
|
||||
static bool type_is_folder(const Arguments& arguments)
|
||||
{
|
||||
return arguments.command == "render" && arguments.get("type").value_or("") == "pngs";
|
||||
}
|
||||
|
||||
static std::optional<Arguments> arguments_get(int argc, const char** argv)
|
||||
{
|
||||
if (argc < 3)
|
||||
return {};
|
||||
// Absolute, so a bare file name still has a folder for the paths in it.
|
||||
Arguments arguments = {.command = argv[1], .file = std::filesystem::absolute(path_from_utf8(argv[2]))};
|
||||
for (int i = 3; i < argc; ++i)
|
||||
{
|
||||
std::string name = argv[i];
|
||||
if (!name.starts_with("--"))
|
||||
return {};
|
||||
name.erase(0, 2);
|
||||
auto isFlag = i + 1 >= argc || std::string_view(argv[i + 1]).starts_with("--");
|
||||
arguments.options[name] = isFlag ? std::string{} : std::string(argv[++i]);
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
// RRGGBB (opaque) or "transparent".
|
||||
static Vec4 background_get(const Arguments& arguments)
|
||||
{
|
||||
auto text = arguments.get("background").value_or("transparent");
|
||||
if (text.starts_with('#'))
|
||||
text.erase(0, 1);
|
||||
unsigned value = 0;
|
||||
if (text.size() != HEX_RGB_LENGTH ||
|
||||
std::from_chars(text.data(), text.data() + text.size(), value, HEX_BASE).ec != std::errc{})
|
||||
return {};
|
||||
return {(float)((value >> 16) & 0xFF) / CHANNEL_MAX, (float)((value >> 8) & 0xFF) / CHANNEL_MAX,
|
||||
(float)(value & 0xFF) / CHANNEL_MAX, 1.0f};
|
||||
}
|
||||
|
||||
// --ffmpeg, or else the FFmpeg the editor's Render Animation uses (or "ffmpeg" on the PATH).
|
||||
static std::filesystem::path ffmpeg_path_get(const Arguments& arguments)
|
||||
{
|
||||
if (auto ffmpeg = arguments.get("ffmpeg"))
|
||||
return path_from_utf8(*ffmpeg);
|
||||
auto settingsPath = preferences_directory_get() / "settings.ini";
|
||||
auto settingsFfmpeg =
|
||||
is_path_exist(settingsPath) ? Settings(settingsPath).renderFFmpegPath : std::filesystem::path{};
|
||||
return settingsFfmpeg.empty() ? std::filesystem::path("ffmpeg") : settingsFfmpeg;
|
||||
}
|
||||
|
||||
// By index or name. The default animation otherwise.
|
||||
static std::pair<int, const Animation*> animation_get(const Model& model, const Arguments& arguments)
|
||||
{
|
||||
auto animations = model.animations_get();
|
||||
auto name = arguments.get("animation").value_or(model.animations.defaultAnimation);
|
||||
int index = -1;
|
||||
if (std::from_chars(name.data(), name.data() + name.size(), index).ec == std::errc{} && index >= 0 &&
|
||||
index < (int)animations.size())
|
||||
return animations[index];
|
||||
for (auto [i, animation] : animations)
|
||||
if (animation->name == name)
|
||||
return {i, animation};
|
||||
if (!arguments.is("animation") && !animations.empty())
|
||||
return animations.front();
|
||||
return {-1, nullptr};
|
||||
}
|
||||
|
||||
static int info_print(const Arguments& arguments)
|
||||
{
|
||||
Model model = {};
|
||||
std::string error;
|
||||
if (!model_load(model, arguments.file, &error))
|
||||
{
|
||||
std::println(stderr, "could not load {}: {}", path_to_utf8(arguments.file), error);
|
||||
return 1;
|
||||
}
|
||||
auto& content = model.content;
|
||||
std::println("file: {}", path_to_utf8(arguments.file));
|
||||
std::println("fps: {}, created by: {}", model.info.fps, model.info.createdBy);
|
||||
|
||||
std::println("animations (default: {}):", model.animations.defaultAnimation);
|
||||
for (auto [index, animation] : model.animations_get())
|
||||
{
|
||||
int layers{}, nulls{};
|
||||
items_each(animation->layers, [&](const Track&, auto*) { ++layers; });
|
||||
items_each(animation->nulls, [&](const Track&, auto*) { ++nulls; });
|
||||
std::println(" [{}] {}: {} frames{}, {} layer tracks, {} null tracks, {} triggers", index, animation->name,
|
||||
animation->frameNum, animation->isLoop ? ", loops" : "", layers, nulls,
|
||||
animation->triggers.frames.size());
|
||||
}
|
||||
|
||||
WorkingDirectory workingDirectory(arguments.file.parent_path());
|
||||
std::println("spritesheets:");
|
||||
for (auto& spritesheet : content.spritesheets)
|
||||
{
|
||||
auto image = Image(path_case_insensitive_find(spritesheet.path));
|
||||
auto status = image.is_valid() ? std::format("{}x{}", image.size.x, image.size.y) : std::string("missing");
|
||||
std::println(" #{} {} ({}), {} regions", spritesheet.id, path_to_utf8(spritesheet.path), status,
|
||||
spritesheet.regions.size());
|
||||
}
|
||||
for (auto& library : content.libraries)
|
||||
std::println("library #{} {}", library.id, path_to_utf8(library.path));
|
||||
for (auto& layer : content.layers)
|
||||
if (layer.is_animation())
|
||||
std::println("layer #{} {} (animation {}, library #{})", layer.id, layer.name, layer.animation,
|
||||
layer.libraryId);
|
||||
else
|
||||
std::println("layer #{} {} (spritesheet #{})", layer.id, layer.name, layer.spritesheetId);
|
||||
for (auto& null : content.nulls)
|
||||
std::println("null #{} {}", null.id, null.name);
|
||||
for (auto& event : content.events)
|
||||
std::println("event #{} {}", event.id, event.name);
|
||||
for (auto& sound : content.sounds)
|
||||
std::println("sound #{} {}", sound.id, path_to_utf8(sound.path));
|
||||
|
||||
auto issues = isaac_issues_get(model);
|
||||
std::println("isaac issues: {} eased frames, {} group transforms, {} skewed frames, {} shader frames, {} depth "
|
||||
"frames, {} alpha offset frames, {} blurred frames, {} extra trigger events, {} trigger sounds, "
|
||||
"{} animation layers, {} vector spritesheets",
|
||||
issues.easedFrames, issues.groupTransforms, issues.skewFrames, issues.shaderFrames, issues.depthFrames,
|
||||
issues.alphaOffsetFrames, issues.blurFrames, issues.extraEvents, issues.triggerSounds,
|
||||
issues.animationLayers, issues.vectorSpritesheets);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int draw_run(const Arguments& arguments)
|
||||
{
|
||||
auto out = arguments.get("out");
|
||||
if (!out)
|
||||
{
|
||||
std::println(stderr, "--out is required");
|
||||
return 2;
|
||||
}
|
||||
|
||||
HeadlessGL gl = {};
|
||||
if (!gl.is_valid())
|
||||
{
|
||||
std::println(stderr, "could not create an OpenGL 3.3 context");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string error;
|
||||
Document document(arguments.file, DOCUMENT_OPEN, &error);
|
||||
if (!document.is_valid())
|
||||
{
|
||||
std::println(stderr, "could not load {}: {}", path_to_utf8(arguments.file), error);
|
||||
return 1;
|
||||
}
|
||||
auto [index, animation] = animation_get(document.model, arguments);
|
||||
if (!animation)
|
||||
{
|
||||
std::println(stderr, "no such animation: {}", arguments.get("animation").value_or(""));
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto& textureInfo = SHADERS[SHADER_TEXTURE];
|
||||
ShaderProgram shader(textureInfo.vertex, textureInfo.fragment);
|
||||
Canvas canvas(Vec2(1.0f));
|
||||
auto isRootTransform = !arguments.is("no-root-transform");
|
||||
FrameRender render{.canvas = canvas,
|
||||
.shader = shader,
|
||||
.document = document,
|
||||
.animation = *animation,
|
||||
.bounds = animation_bounds_get(document, *animation, isRootTransform),
|
||||
.background = background_get(arguments),
|
||||
.scale = arguments.number_get("scale", SCALE_DEFAULT),
|
||||
.isRootTransform = isRootTransform};
|
||||
auto outPath = path_from_utf8(*out);
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(type_is_folder(arguments) ? outPath : outPath.parent_path(), ec);
|
||||
|
||||
if (arguments.command == "frame")
|
||||
{
|
||||
auto pixels = animation_frame_render(render, arguments.number_get("time", 0.0f));
|
||||
pixels_unpremultiply(pixels);
|
||||
if (!Image::write_pixels_png(outPath, IVec2(canvas.size), pixels.data()))
|
||||
{
|
||||
std::println(stderr, "could not write {}", *out);
|
||||
return 1;
|
||||
}
|
||||
std::println("{}: \"{}\" at time {}, {}x{}", *out, animation->name, arguments.number_get("time", 0.0f),
|
||||
(int)canvas.size.x, (int)canvas.size.y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto typeName = arguments.get("type").value_or("sheet");
|
||||
auto type = typeName == "sheet" ? RENDER_SPRITESHEET : RENDER_PNGS;
|
||||
for (int i = 0; i < RENDER_COUNT; ++i)
|
||||
if (RENDER_EXTENSIONS[i] == "." + typeName)
|
||||
type = (RenderType)i;
|
||||
if (typeName != "sheet" && typeName != "pngs" && type == RENDER_PNGS)
|
||||
{
|
||||
std::println(stderr, "unknown --type: {}", typeName);
|
||||
return 2;
|
||||
}
|
||||
|
||||
auto fps = std::max(document.model.info.fps, 1);
|
||||
RecorderOptions options{.type = type,
|
||||
.path = outPath,
|
||||
.format = path_from_utf8(arguments.get("format").value_or("{}.png")),
|
||||
.ffmpegPath = ffmpeg_path_get(arguments),
|
||||
.start = arguments.number_get("start", 0),
|
||||
.end = arguments.number_get("end", animation->frameNum - 1),
|
||||
.animationFps = fps,
|
||||
.fps = arguments.number_get("fps", fps),
|
||||
.rows = arguments.number_get("rows", 0),
|
||||
.columns = arguments.number_get("columns", 0)};
|
||||
auto count = frame_count_get(options.start, options.end, options.animationFps, options.fps);
|
||||
if (!animation_record(options, render))
|
||||
{
|
||||
std::println(stderr, "could not write {} (FFmpeg: {})", *out, path_to_utf8(options.ffmpegPath));
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::print("{}: \"{}\", {} frames ({} to {} at {} fps), each {}x{}", *out, animation->name, count, options.start,
|
||||
options.end, options.fps, (int)canvas.size.x, (int)canvas.size.y);
|
||||
if (type == RENDER_SPRITESHEET)
|
||||
{
|
||||
auto layout = spritesheet_layout_get(options.rows, options.columns, count);
|
||||
std::print(", {} rows x {} columns, left to right", layout.rows, layout.columns);
|
||||
}
|
||||
std::println("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Saved as the editor saves it: XML (the game's copy, with the editor's embedded) or the editor's JSON.
|
||||
static int convert_run(const Arguments& arguments)
|
||||
{
|
||||
auto format = arguments.get("format").value_or("xml");
|
||||
if (format != "xml" && format != "json")
|
||||
{
|
||||
std::println(stderr, "--format must be json or xml");
|
||||
return 2;
|
||||
}
|
||||
// The game's copy bakes what it can't draw with OpenGL (and the document's shaders compile only with it).
|
||||
std::optional<HeadlessGL> gl;
|
||||
if (format == "xml")
|
||||
gl.emplace();
|
||||
std::string error;
|
||||
Document document(arguments.file, DOCUMENT_OPEN, &error);
|
||||
auto fileUtf8 = path_to_utf8(arguments.file);
|
||||
if (!document.is_valid())
|
||||
{
|
||||
std::println(stderr, "could not load {}: {}", fileUtf8, error);
|
||||
return 1;
|
||||
}
|
||||
if (!error.empty())
|
||||
std::println(stderr, "{}:\n{}", fileUtf8, error);
|
||||
auto out = std::filesystem::absolute(arguments.get("out").transform(path_from_utf8).value_or(arguments.file));
|
||||
Options options = {};
|
||||
options.isJson = format == "json";
|
||||
if (document.save(out, &error, options))
|
||||
return 0;
|
||||
std::println(stderr, "could not write {}: {}", path_to_utf8(out), error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
constexpr std::string_view COMMANDS[] = {"info", "frame", "render", "convert"};
|
||||
|
||||
bool is_cli(int argc, const char** argv)
|
||||
{
|
||||
return argc >= 2 && std::ranges::contains(COMMANDS, std::string_view(argv[1])) && !is_path_exist(argv[1]);
|
||||
}
|
||||
|
||||
int cli_run(int argc, const char** argv)
|
||||
{
|
||||
auto arguments = arguments_get(argc, argv);
|
||||
if (!arguments)
|
||||
{
|
||||
std::print(stderr, "{}", USAGE);
|
||||
return 2;
|
||||
}
|
||||
if (arguments->command == "info")
|
||||
return info_print(*arguments);
|
||||
if (arguments->command == "convert")
|
||||
return convert_run(*arguments);
|
||||
return draw_run(*arguments);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// The command-line mode: "anm2ed <info|frame|render> <file.anm2> [options]" looks at a file without the editor, as
|
||||
// text or drawn (by the editor's OpenGL renderer, in a hidden window) to a PNG frame, a contact sheet, PNGs, a GIF or
|
||||
// a video.
|
||||
bool is_cli(int, const char**);
|
||||
int cli_run(int, const char**);
|
||||
@@ -1,22 +1,28 @@
|
||||
#include "clipboard.hpp"
|
||||
#include "clipboard.h"
|
||||
|
||||
#include <SDL3/SDL_clipboard.h>
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
|
||||
namespace anm2ed
|
||||
Clipboard::Clipboard()
|
||||
{
|
||||
Clipboard::Clipboard() { set(""); }
|
||||
set("");
|
||||
}
|
||||
|
||||
std::string Clipboard::get()
|
||||
{
|
||||
std::string Clipboard::get()
|
||||
{
|
||||
auto text = SDL_GetClipboardText();
|
||||
auto string = std::string(text);
|
||||
SDL_free(text);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
bool Clipboard::is_empty() { return get().empty(); }
|
||||
|
||||
void Clipboard::set(const std::string& string) { SDL_SetClipboardText(string.data()); }
|
||||
}
|
||||
|
||||
bool Clipboard::is_empty()
|
||||
{
|
||||
return !SDL_HasClipboardText();
|
||||
}
|
||||
|
||||
void Clipboard::set(const std::string& string)
|
||||
{
|
||||
SDL_SetClipboardText(string.c_str());
|
||||
}
|
||||