Compare commits

...

17 Commits

Author SHA1 Message Date
fe8bdae9a8 The Update(TM), Part 1 2025-07-27 22:08:57 -04:00
Shweet
0439221e78 Merge pull request #2 from im-tem/master
win32 app icon + multikey shortcut fix
2025-07-01 11:00:49 -04:00
im-tem
e04a403f24 Merge branch 'master' into master 2025-07-01 17:49:23 +03:00
im-tem
daefc91a72 input: hacky way of handling multikey shortcuts 2025-07-01 17:45:04 +03:00
im-tem
34443ebf35 win32: handle app icon 2025-07-01 17:44:43 +03:00
35a6697bcc save input 2025-07-01 10:21:39 -04:00
30880c003d The Omega Refactor(TM) + Input Options 2025-06-30 21:29:59 -04:00
Shweet
6b5437a2fd Merge pull request #1 from im-tem/master
Yes.
2025-06-30 09:03:16 -04:00
im-tem
6c63f6e53d Update CMakeLists.txt 2025-06-30 15:23:14 +03:00
im-tem
e583dd6eee fix up PACKED.h 2025-06-30 15:18:04 +03:00
im-tem
9cf21d9084 Merge branch 'master' of https://github.com/im-tem/anm2ed 2025-06-30 15:15:50 +03:00
im-tem
f5065ae1c2 define OpenGL flag for SDL3 so that it works on all platform 2025-06-30 15:00:31 +03:00
im-tem
d317fe2fd8 fix for strncpy with std::filesystem::path on windows 2025-06-30 15:00:01 +03:00
im-tem
ca08c30b31 always have a PATH_MAX definition 2025-06-30 14:59:37 +03:00
im-tem
84c1eb4633 resolve resources.h vs RESOURCES.h conflict 2025-06-30 14:59:02 +03:00
im-tem
866772f320 win_build: msvc-specific build changes + find_package 2025-06-30 14:58:42 +03:00
im-tem
2c2fed8796 win_build: vcpkg set-up 2025-06-30 14:56:56 +03:00
48 changed files with 5066 additions and 4052 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
build/ build/
concept/ concept/
packed/ packed/
vcpkg_installed/

3
.gitmodules vendored
View File

@@ -8,6 +8,3 @@
[submodule "include/tinyxml2"] [submodule "include/tinyxml2"]
path = include/tinyxml2 path = include/tinyxml2
url = https://github.com/leethomason/tinyxml2 url = https://github.com/leethomason/tinyxml2
[submodule "include/inih"]
path = include/inih
url = https://github.com/benhoyt/inih

View File

@@ -1,5 +1,15 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.15)
project(anm2ed 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()
project(anm2ed CXX)
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
find_package(GLEW REQUIRED)
find_package(OpenGL REQUIRED)
# Gather project sources # Gather project sources
file(GLOB SOURCES file(GLOB SOURCES
@@ -10,17 +20,30 @@ file(GLOB SOURCES
"include/imgui/backends/imgui_impl_sdl3.cpp" "include/imgui/backends/imgui_impl_sdl3.cpp"
"include/imgui/backends/imgui_impl_opengl3.cpp" "include/imgui/backends/imgui_impl_opengl3.cpp"
"include/tinyxml2/tinyxml2.cpp" "include/tinyxml2/tinyxml2.cpp"
"include/inih/ini.c"
"${PROJECT_SOURCE_DIR}/src/*.cpp" "${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/*.h"
) )
add_executable(${PROJECT_NAME} ${SOURCES}) if (WIN32)
enable_language("RC")
set (WIN32_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/assets/win_icon.rc)
endif()
add_executable(${PROJECT_NAME} ${SOURCES} ${WIN32_RESOURCES})
target_include_directories(${PROJECT_NAME} PRIVATE include include/imgui include/tinyxml2 include/inih src) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
set(CMAKE_CXX_FLAGS "-g -O2 -std=c++23 -Wall -Wextra -pedantic -Wno-unused-variable -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-parentheses -Wno-missing-field-initializers -Wno-unused-function -Wno-class-memaccess -Wno-delete-incomplete") target_include_directories(${PROJECT_NAME} PRIVATE include include/imgui include/tinyxml2 src)
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "-g -O2 -std=c++23 -Wall -Wextra -pedantic -fmax-errors=1")
else()
set(CMAKE_CXX_FLAGS "/std:c++latest /EHsc") # /std:c++latest is required to make MSVC grant access to all the latest C++ stuff (C++23 is listed as preview even on dev previews of MSVC....)
endif()
if(NOT MSVC)
target_link_libraries(${PROJECT_NAME} PRIVATE m)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL GLEW::GLEW SDL3::SDL3)
target_link_libraries(${PROJECT_NAME} PRIVATE m GL GLEW SDL3)
message("System: ${CMAKE_SYSTEM_NAME}") message("System: ${CMAKE_SYSTEM_NAME}")
message("Project: ${PROJECT_NAME}") message("Project: ${PROJECT_NAME}")

BIN
assets/Icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

1
assets/Icon.rc Normal file
View File

@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "Icon.ico"

BIN
assets/atlas.kra Normal file

Binary file not shown.

BIN
assets/atlas.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/bleh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

256
assets/bleh.txt Normal file
View File

@@ -0,0 +1,256 @@
unsigned char atlas_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x68,
0x04, 0x03, 0x00, 0x00, 0x01, 0x8b, 0xe2, 0xd8, 0xf0, 0x00, 0x00, 0x00,
0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x12, 0x00, 0x00, 0x0b,
0x12, 0x01, 0xd2, 0xdd, 0x7e, 0xfc, 0x00, 0x00, 0x00, 0x0f, 0x50, 0x4c,
0x54, 0x45, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0xff, 0xff, 0xff, 0x60,
0x60, 0x60, 0xff, 0xff, 0xff, 0xb1, 0x03, 0xf0, 0x56, 0x00, 0x00, 0x00,
0x03, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x00, 0x00, 0xfa, 0x76, 0xc4, 0xde,
0x00, 0x00, 0x04, 0x90, 0x49, 0x44, 0x41, 0x54, 0x58, 0xc3, 0xdd, 0x97,
0x6b, 0x6e, 0x24, 0x39, 0x0e, 0x84, 0x3f, 0x2c, 0xe3, 0x40, 0x1a, 0x48,
0x07, 0x88, 0x86, 0xe2, 0xfe, 0x67, 0x9a, 0x1f, 0x7a, 0x54, 0x96, 0xdb,
0x9e, 0x71, 0xf7, 0x0c, 0xb0, 0x8b, 0x15, 0x0a, 0x56, 0xca, 0x4c, 0x8a,
0xef, 0x20, 0x13, 0xd6, 0x92, 0x4a, 0xd2, 0x7e, 0x24, 0x03, 0x25, 0x5c,
0x1a, 0xa0, 0x7b, 0x2a, 0x24, 0xe8, 0xad, 0x01, 0x8c, 0xc6, 0x87, 0x4d,
0xf7, 0x74, 0x56, 0xe8, 0x8c, 0x7b, 0x6a, 0xe0, 0xe7, 0xd5, 0x96, 0xd7,
0xb3, 0xf1, 0xc4, 0x86, 0x0e, 0x18, 0x72, 0x37, 0xbd, 0x9d, 0x30, 0x20,
0xfd, 0x20, 0x0a, 0x26, 0x48, 0xb2, 0xa8, 0xbe, 0xf4, 0x77, 0x0d, 0x28,
0x61, 0x4c, 0x59, 0x83, 0x68, 0x00, 0x46, 0x22, 0xa0, 0xa9, 0x60, 0x14,
0x81, 0x88, 0x2c, 0x60, 0x30, 0x0a, 0x0d, 0x2c, 0x1d, 0x43, 0x1b, 0x48,
0x8c, 0x2c, 0x53, 0x04, 0xdc, 0x43, 0x5e, 0x87, 0x24, 0x09, 0xef, 0xaf,
0x95, 0x1b, 0xed, 0xe9, 0xb1, 0xbb, 0xec, 0x84, 0x24, 0x45, 0x20, 0x4a,
0x26, 0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0x3d,
0xe1, 0x40, 0x66, 0x2f, 0x1a, 0x63, 0xab, 0xba, 0x25, 0x40, 0x65, 0xb9,
0x7e, 0xe1, 0xfe, 0x83, 0xe1, 0x17, 0x57, 0xdf, 0xab, 0x7d, 0xf1, 0xd1,
0xc5, 0xc7, 0x4b, 0xc7, 0xca, 0xde, 0xf9, 0xdb, 0x0c, 0xfc, 0xff, 0x31,
0xdc, 0x46, 0xf7, 0x4d, 0x06, 0x99, 0xf8, 0x3f, 0xf9, 0x3e, 0xc3, 0x6a,
0x01, 0x6f, 0x18, 0xf9, 0x15, 0x43, 0x7e, 0x5e, 0xfe, 0x77, 0x25, 0xfc,
0xa6, 0x0d, 0xbf, 0xec, 0xa5, 0xff, 0x4a, 0xa4, 0x6b, 0x31, 0xb4, 0x6f,
0x33, 0x9c, 0xb6, 0xfb, 0xed, 0x7a, 0x38, 0x1d, 0xe8, 0x17, 0x18, 0xa8,
0xe7, 0xf7, 0x6e, 0xfb, 0x9b, 0x92, 0xfe, 0x13, 0xdc, 0x2c, 0x81, 0x38,
0xc8, 0xfa, 0xf8, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82
};
unsigned int atlas_png_len = 1288;
unsigned char atlas_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x68,
0x08, 0x06, 0x00, 0x00, 0x00, 0x0e, 0xcb, 0xf5, 0x55, 0x00, 0x00, 0x00,
0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x12, 0x00, 0x00, 0x0b,
0x12, 0x01, 0xd2, 0xdd, 0x7e, 0xfc, 0x00, 0x00, 0x06, 0x52, 0x49, 0x44,
0x41, 0x54, 0x78, 0xda, 0xed, 0x5d, 0x8b, 0x4e, 0x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53, 0x33, 0x78, 0xf3, 0x76, 0x22, 0xd5, 0x5b, 0x46, 0x56, 0xcf, 0x8d,
0xb6, 0x47, 0x6a, 0x42, 0x99, 0x00, 0x44, 0x9f, 0x4f, 0x85, 0x78, 0x0f,
0x6b, 0x37, 0x2f, 0xc2, 0x59, 0xd1, 0xc0, 0xa8, 0x34, 0x65, 0x66, 0xd2,
0xb3, 0x35, 0xa1, 0x59, 0x10, 0xd7, 0xc2, 0x2c, 0x69, 0xe5, 0x58, 0x46,
0x48, 0x96, 0x0d, 0x80, 0xa7, 0xf6, 0x82, 0x2e, 0x3b, 0xc9, 0xdc, 0xe8,
0xc1, 0xd5, 0xcb, 0x42, 0x21, 0x93, 0xa7, 0x3c, 0xe1, 0x01, 0x2f, 0x23,
0xd2, 0x18, 0xdd, 0x1b, 0x30, 0x63, 0x8f, 0x01, 0xb7, 0x27, 0x82, 0x15,
0x80, 0x68, 0xb6, 0x8b, 0x30, 0x10, 0xd1, 0x80, 0x8c, 0x49, 0xef, 0x15,
0x00, 0x44, 0x98, 0xaf, 0xee, 0x8e, 0xf1, 0xee, 0x46, 0xf1, 0xdc, 0x4b,
0xd5, 0x70, 0x86, 0x0f, 0xf0, 0x26, 0x69, 0x52, 0x35, 0x77, 0xf4, 0xdd,
0x5d, 0xcc, 0x47, 0x6a, 0xe7, 0x11, 0x0d, 0xd0, 0x26, 0x43, 0x66, 0x85,
0x8e, 0xd1, 0xad, 0x47, 0x99, 0x5b, 0x96, 0xdc, 0xcc, 0xb7, 0x4c, 0x90,
0xb6, 0xf7, 0x09, 0x51, 0x5f, 0xd4, 0x84, 0x78, 0x19, 0xec, 0xda, 0x81,
0x98, 0x08, 0x80, 0x37, 0x87, 0x82, 0xf6, 0xb9, 0x69, 0xd5, 0x4a, 0x24,
0x9a, 0x88, 0xda, 0xc8, 0x55, 0xa9, 0x7d, 0x14, 0x00, 0x14, 0x20, 0x17,
0xf3, 0x11, 0x67, 0x19, 0xdd, 0x25, 0x99, 0x15, 0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5, 0x49,
0xf9, 0x99, 0xf9, 0x40, 0x69, 0x40, 0x99, 0xa0, 0x35, 0x1a, 0x03, 0x66,
0xc2, 0xd3, 0xb3, 0xe1, 0x4b, 0x6b, 0x00, 0x00, 0xc2, 0xf4, 0x83, 0x00,
0x2f, 0x59, 0x0b, 0xea, 0xd7, 0xc0, 0x22, 0x07, 0x48, 0x1d, 0xb2, 0x3a,
0xba, 0x4c, 0xd1, 0xb8, 0x83, 0x2f, 0x00, 0x92, 0x80, 0xa8, 0xa5, 0x89,
0x15, 0x05, 0x15, 0x15, 0x00, 0x05, 0x40, 0x51, 0x01, 0x70, 0x15, 0xf2,
0x1e, 0x5a, 0x4d, 0x8f, 0xa1, 0x79, 0x95, 0xa4, 0x6c, 0xe9, 0x7f, 0xbc,
0x88, 0xfe, 0x3f, 0xdf, 0x02, 0xe0, 0x60, 0x10, 0xac, 0x4d, 0xd3, 0x91,
0x3e, 0xaf, 0x0c, 0xc0, 0x1f, 0x1f, 0xd0, 0xfe, 0x89, 0x99, 0x44, 0x47,
0x6d, 0xdd, 0xbc, 0xb4, 0x13, 0x96, 0x40, 0x28, 0xe6, 0x1f, 0x18, 0x05,
0x51, 0x10, 0x8a, 0xf9, 0xf3, 0x48, 0xac, 0x05, 0xfd, 0x30, 0xfc, 0xd1,
0x7d, 0x7e, 0x69, 0x5a, 0xb5, 0x71, 0xfa, 0x1f, 0xcc, 0xd3, 0x69, 0xcc,
0x40, 0x9f, 0x7b, 0x52, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82
};
unsigned int atlas_png_len = 1696;

View File

@@ -1,69 +0,0 @@
[Settings]
panX=-521.000000
panY=258.000000
# Dear ImGui
[Window][Window]
Pos=0,32
Size=1918,1030
Collapsed=0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Animations]
Pos=1197,40
Size=485,342
Collapsed=0
DockId=0x00000005,0
[Window][Events]
Pos=1197,384
Size=485,345
Collapsed=0
DockId=0x00000006,0
[Window][Spritesheets]
Pos=1684,40
Size=226,689
Collapsed=0
DockId=0x00000002,0
[Window][Spritesheet Editor]
Pos=60,60
Size=32,35
Collapsed=0
[Window][Timeline]
Pos=8,731
Size=1902,323
Collapsed=0
DockId=0x0000000A,0
[Window][Frame Properties]
Pos=890,40
Size=305,689
Collapsed=0
DockId=0x00000008,0
[Window][Animation Preview]
Pos=8,40
Size=880,689
Collapsed=0
DockId=0x00000007,0
[Docking][Data]
DockSpace ID=0xFB691B2E Window=0xFA2EAA04 Pos=8,40 Size=1902,1014 Split=Y Selected=0x024430EF
DockNode ID=0x00000009 Parent=0xFB691B2E SizeRef=1902,689 Split=X
DockNode ID=0x00000001 Parent=0x00000009 SizeRef=1674,1014 Split=X Selected=0x024430EF
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=1187,1014 Split=X Selected=0x024430EF
DockNode ID=0x00000007 Parent=0x00000003 SizeRef=880,1014 CentralNode=1 Selected=0x024430EF
DockNode ID=0x00000008 Parent=0x00000003 SizeRef=305,1014 Selected=0x754E368F
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=485,1014 Split=Y Selected=0x8A65D963
DockNode ID=0x00000005 Parent=0x00000004 SizeRef=485,504 Selected=0xC1986EE2
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=485,508 Selected=0x8A65D963
DockNode ID=0x00000002 Parent=0x00000009 SizeRef=226,1014 Selected=0x4EFD0020
DockNode ID=0x0000000A Parent=0xFB691B2E SizeRef=1902,323 Selected=0x4F89F0DC

View File

@@ -2,29 +2,30 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL.h>
#include <GL/glew.h> #include <GL/glew.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <glm/glm/glm.hpp> #include <glm/glm/glm.hpp>
#include <glm/glm/gtc/type_ptr.hpp> #include <glm/glm/gtc/type_ptr.hpp>
#include <glm/glm/gtc/matrix_transform.hpp> #include <glm/glm/gtc/matrix_transform.hpp>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <tinyxml2.h> #include <tinyxml2.h>
#include <algorithm> #include <algorithm>
#include <filesystem> #include <chrono>
#include <cstring>
#include <cmath>
#include <filesystem>
#include <format>
#include <functional>
#include <fstream>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <ranges> #include <print>
#include <vector> #include <optional>
#include <ranges>
#include "STRINGS.h" #include <string>
#include <vector>
#include <unordered_set>
typedef uint8_t u8; typedef uint8_t u8;
typedef uint16_t u16; typedef uint16_t u16;
@@ -42,18 +43,22 @@ typedef double f64;
#define PI (GLM_PI) #define PI (GLM_PI)
#define TAU (PI * 2) #define TAU (PI * 2)
using namespace glm; // fuck you using namespace glm;
#define MIN(x, min) (x < min ? min : x) #define MIN(x, min) (x < min ? min : x)
#define MAX(x, max) (x > max ? max : x) #define MAX(x, max) (x > max ? max : x)
#define CLAMP(x, min, max) (MIN(MAX(x, max), min)) #define CLAMP(x, min, max) (MIN(MAX(x, max), min))
#define ROUND_NEAREST_FLOAT(value, multiple) (roundf((value) / (multiple)) * (multiple))
#define COLOR_FLOAT_TO_INT(x) (static_cast<int>((x) * 255.0f)) #define COLOR_FLOAT_TO_INT(x) (static_cast<int>((x) * 255.0f))
#define COLOR_INT_TO_FLOAT(x) ((x) / 255.0f) #define COLOR_INT_TO_FLOAT(x) ((x) / 255.0f)
#define PERCENT_TO_UNIT(x) (x / 100.0f)
#define TICK_DELAY 33.3f #define TICK_DELAY 33.3f
#define TICK_CATCH_UP_MAX (33.3f * 5)
#define SECOND 1000.0f #define SECOND 1000.0f
#define TICK_RATE (SECOND / TICK_DELAY) #define TICK_RATE (SECOND / TICK_DELAY)
#define ID_NONE -1
#define INDEX_NONE -1
#define LENGTH_NONE -1
#define UV_VERTICES(uvMin, uvMax) \ #define UV_VERTICES(uvMin, uvMax) \
{ \ { \
@@ -78,12 +83,8 @@ static const f32 GL_UV_VERTICES[] =
1, 1, 1.0f, 1.0f, 1, 1, 1.0f, 1.0f,
0, 1, 0.0f, 1.0f 0, 1, 0.0f, 1.0f
}; };
#define IMVEC2_VEC2(value) ImVec2(value.x, value.y)
#define VEC2_IMVEC2(value) glm::vec2(value.x, value.y)
#define IMVEC4_VEC4(value) ImVec4(value.r, value.g, value.b, value.a)
static const GLuint GL_TEXTURE_INDICES[] = {0, 1, 2, 2, 3, 0}; static const GLuint GL_TEXTURE_INDICES[] = {0, 1, 2, 2, 3, 0};
static const vec4 COLOR_RED = {1.0f, 0.0f, 0.0f, 1.0f}; static const vec4 COLOR_RED = {1.0f, 0.0f, 0.0f, 1.0f};
static const vec4 COLOR_GREEN = {0.0f, 1.0f, 0.0f, 1.0f}; static const vec4 COLOR_GREEN = {0.0f, 1.0f, 0.0f, 1.0f};
static const vec4 COLOR_BLUE = {0.0f, 0.0f, 1.0f, 1.0f}; static const vec4 COLOR_BLUE = {0.0f, 0.0f, 1.0f, 1.0f};
@@ -91,19 +92,85 @@ static const vec4 COLOR_OPAQUE = {1.0f, 1.0f, 1.0f, 1.0f};
static const vec4 COLOR_TRANSPARENT = {0.0f, 0.0f, 0.0f, 1.0f}; static const vec4 COLOR_TRANSPARENT = {0.0f, 0.0f, 0.0f, 1.0f};
static const vec3 COLOR_OFFSET_NONE = {0.0f, 0.0f, 0.0f}; static const vec3 COLOR_OFFSET_NONE = {0.0f, 0.0f, 0.0f};
static inline const char* enum_to_string(const char* arr[], s32 count, s32 index) { return (index >= 0 && index < count) ? arr[index] : "undefined"; } static inline void log_error(const std::string& string)
static inline s32 string_to_enum(const char* str, const char* const* arr, s32 n) { for (s32 i=0; i<n; ++i) if (!strcmp(str, arr[i])) return i; return -1; } {
static inline bool string_to_bool(const char* str) { if (strcmp(str, "true") == 0) return true; return false; } std::println("[ERROR] {}", string);
}
template<typename T>
static inline s32 map_next_id_get(const std::map<s32, T>& map) { static inline void log_info(const std::string& string)
s32 id = 0; for (const auto& [key, _] : map) if (key != id) break; else ++id; return id; {
std::println("[INFO] {}", string);
}
static inline bool string_to_bool(const std::string& string)
{
if (string == "1") return true;
std::string lower = string;
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
return lower == "true";
}
static inline void working_directory_from_file_set(const std::string& path)
{
std::filesystem::path filePath = path;
std::filesystem::path parentPath = filePath.parent_path();
std::filesystem::current_path(parentPath);
};
static inline const char* enum_to_string(const char* array[], s32 count, s32 index)
{
return (index >= 0 && index < count) ? array[index] : "";
};
static inline s32 string_to_enum(const std::string& string, const char* const* array, s32 n)
{
for (s32 i = 0; i < n; i++)
if (string == array[i])
return i;
return -1;
};
template<typename T>
static inline s32 map_next_id_get(const std::map<s32, T>& map)
{
s32 id = 0;
for (const auto& [key, _] : map)
if (key != id)
break;
else
++id;
return id;
}
template<typename T>
static inline s32 vector_next_id_get(const std::vector<T>& vec)
{
std::unordered_set<s32> usedIDs;
for (const auto& item : vec)
usedIDs.insert(item.id);
for (s32 i = 0; ; ++i)
if (!usedIDs.contains(i))
return i;
}
template<typename T>
void vector_swap_by_id(std::vector<T>& vec, s32 idA, s32 idB)
{
if (idA == idB)
return;
auto itA = std::find_if(vec.begin(), vec.end(), [=](const T& item) { return item.id == idA; });
auto itB = std::find_if(vec.begin(), vec.end(), [=](const T& item) { return item.id == idB; });
if (itA != vec.end() && itB != vec.end())
std::swap(*itA, *itB);
} }
/* Swaps elements in a map */
/* If neither key exists, do nothing */
/* If one key exists, change its ID */
/* If both keys exist, swap */
template<typename Map, typename Key> template<typename Map, typename Key>
static inline void map_swap(Map& map, const Key& key1, const Key& key2) static inline void map_swap(Map& map, const Key& key1, const Key& key2)
{ {
@@ -130,12 +197,36 @@ static inline void map_swap(Map& map, const Key& key1, const Key& key2)
} }
}; };
#define DEFINE_ENUM_TO_STRING_FN(fn_name, arr, count) \ template <typename T>
static inline const char* fn_name(s32 index) { \ static inline void map_insert_shift(std::map<int, T>& map, s32 index, const T& value)
return enum_to_string(arr, count, index); \ {
const s32 insertIndex = index + 1;
std::vector<std::pair<int, T>> toShift;
for (auto it = map.rbegin(); it != map.rend(); ++it)
{
if (it->first < insertIndex)
break;
toShift.emplace_back(it->first + 1, std::move(it->second));
} }
#define DEFINE_STRING_TO_ENUM_FN(fn_name, enum_type, str_array, count) \ for (const auto& [newKey, _] : toShift)
static inline enum_type fn_name(const char* str) { \ map.erase(newKey - 1);
return (enum_type)string_to_enum(str, str_array, count); \
} for (auto& [newKey, val] : toShift)
map[newKey] = std::move(val);
map[insertIndex] = value;
}
#define DEFINE_ENUM_TO_STRING_FUNCTION(function, array, count) \
static inline std::string function(s32 index) \
{ \
return enum_to_string(array, count, index); \
};
#define DEFINE_STRING_TO_ENUM_FUNCTION(function, enumType, stringArray, count) \
static inline enumType function(const std::string& string) \
{ \
return static_cast<enumType>(string_to_enum(string, stringArray, count)); \
};

View File

@@ -1,133 +1,200 @@
// Includes packed resources (i.e., textures, shaders)
#pragma once #pragma once
#include "COMMON.h" #include "COMMON.h"
static const unsigned int TEXTURE_ATLAS_LENGTH = 916; const u32 TEXTURE_ATLAS_LENGTH = 1696;
static const unsigned char TEXTURE_ATLAS[] = const u8 TEXTURE_ATLAS[] =
{ {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x68, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x68,
0x02, 0x03, 0x00, 0x00, 0x00, 0x73, 0xa5, 0x1d, 0xc6, 0x00, 0x00, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, 0x0e, 0xcb, 0xf5, 0x55, 0x00, 0x00, 0x00,
0x09, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x60, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x12, 0x00, 0x00, 0x0b,
0x60, 0x60, 0x13, 0x5e, 0x42, 0xae, 0x00, 0x00, 0x00, 0x01, 0x74, 0x52, 0x12, 0x01, 0xd2, 0xdd, 0x7e, 0xfc, 0x00, 0x00, 0x06, 0x52, 0x49, 0x44,
0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00, 0x03, 0x39, 0x49, 0x41, 0x54, 0x78, 0xda, 0xed, 0x5d, 0x8b, 0x4e, 0xeb, 0x30, 0x0c, 0x65,
0x44, 0x41, 0x54, 0x48, 0xc7, 0xcd, 0x95, 0xcf, 0x6b, 0x14, 0x31, 0x14, 0xd5, 0x3e, 0x14, 0xbe, 0x0c, 0xfe, 0x74, 0x97, 0x4a, 0x04, 0x05, 0x5f,
0xc7, 0xbf, 0x19, 0x26, 0xb2, 0xb3, 0xa7, 0x11, 0x26, 0xcb, 0xea, 0x69, 0x3f, 0x8e, 0x1d, 0xa7, 0xe9, 0x56, 0x5b, 0x42, 0x6c, 0xb4, 0x69, 0x52,
0x90, 0x46, 0xb4, 0x7f, 0x45, 0x0a, 0xf5, 0xe0, 0x2d, 0x42, 0xde, 0x30, 0x1f, 0xbf, 0xf3, 0xe0, 0xed, 0xad, 0xe8, 0x9c, 0xf4, 0x20, 0xf4, 0xcc,
0x9d, 0xd3, 0x28, 0x56, 0xa4, 0x7f, 0x45, 0x0e, 0x0a, 0xf5, 0xe6, 0x61, 0xef, 0x10, 0x69, 0xfb, 0xfe, 0xfe, 0xfe, 0xfb, 0xee, 0xfb, 0xe7, 0x99,
0x47, 0xaa, 0xa7, 0x22, 0xac, 0xb4, 0xf3, 0x57, 0x9a, 0x97, 0x34, 0x16, 0x7d, 0xa9, 0x8c, 0x7f, 0x46, 0x20, 0x32, 0xc6, 0xee, 0x6d, 0xdb, 0x83,
0x71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 0x93, 0xa7, 0x3c, 0xe1, 0x01, 0x2f, 0x23,
0x0a, 0x22, 0xef, 0x77, 0x01, 0x4c, 0x1d, 0x76, 0x03, 0xdd, 0xef, 0x01, 0xd2, 0x18, 0xdd, 0x1b, 0x30, 0x63, 0x8f, 0x01, 0xb7, 0x27, 0x82, 0x15,
0xd5, 0xb8, 0x07, 0x14, 0x7e, 0x27, 0xf8, 0x0e, 0xc6, 0xe6, 0x29, 0x49, 0x80, 0x68, 0xb6, 0x8b, 0x30, 0x10, 0xd1, 0x80, 0x8c, 0x49, 0xef, 0x15,
0x20, 0x43, 0x4e, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0x00, 0x44, 0x98, 0xaf, 0xee, 0x8e, 0xf1, 0xee, 0x46, 0xf1, 0xdc, 0x4b,
0xd5, 0x70, 0x86, 0x0f, 0xf0, 0x26, 0x69, 0x52, 0x35, 0x77, 0xf4, 0xdd,
0x5d, 0xcc, 0x47, 0x6a, 0xe7, 0x11, 0x0d, 0xd0, 0x26, 0x43, 0x66, 0x85,
0x8e, 0xd1, 0xad, 0x47, 0x99, 0x5b, 0x96, 0xdc, 0xcc, 0xb7, 0x4c, 0x90,
0xb6, 0xf7, 0x09, 0x51, 0x5f, 0xd4, 0x84, 0x78, 0x19, 0xec, 0xda, 0x81,
0x98, 0x08, 0x80, 0x37, 0x87, 0x82, 0xf6, 0xb9, 0x69, 0xd5, 0x4a, 0x24,
0x9a, 0x88, 0xda, 0xc8, 0x55, 0xa9, 0x7d, 0x14, 0x00, 0x14, 0x20, 0x17,
0xf3, 0x11, 0x67, 0x19, 0xdd, 0x25, 0x99, 0x15, 0x57, 0x67, 0x56, 0x17,
0x47, 0x7c, 0x80, 0xc7, 0x3f, 0xa0, 0xcc, 0xbf, 0x69, 0x8c, 0x90, 0x36,
0x9c, 0x69, 0x9b, 0xf9, 0xd0, 0x89, 0x87, 0x3e, 0xfb, 0xb5, 0x32, 0xe1,
0xc8, 0x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0xd7, 0xc0, 0x22, 0x07, 0x48, 0x1d, 0xb2, 0x3a,
0xba, 0x4c, 0xd1, 0xb8, 0x83, 0x2f, 0x00, 0x92, 0x80, 0xa8, 0xa5, 0x89,
0x15, 0x05, 0x15, 0x15, 0x00, 0x05, 0x40, 0x51, 0x01, 0x70, 0x15, 0xf2,
0x1e, 0x5a, 0x4d, 0x8f, 0xa1, 0x79, 0x95, 0xa4, 0x6c, 0xe9, 0x7f, 0xbc,
0x88, 0xfe, 0x3f, 0xdf, 0x02, 0xe0, 0x60, 0x10, 0xac, 0x4d, 0xd3, 0x91,
0x3e, 0xaf, 0x0c, 0xc0, 0x1f, 0x1f, 0xd0, 0xfe, 0x89, 0x99, 0x44, 0x47,
0x6d, 0xdd, 0xbc, 0xb4, 0x13, 0x96, 0x40, 0x28, 0xe6, 0x1f, 0x18, 0x05,
0x51, 0x10, 0x8a, 0xf9, 0xf3, 0x48, 0xac, 0x05, 0xfd, 0x30, 0xfc, 0xd1,
0x7d, 0x7e, 0x69, 0x5a, 0xb5, 0x71, 0xfa, 0x1f, 0xcc, 0xd3, 0x69, 0xcc,
0x40, 0x9f, 0x7b, 0x52, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82 0xae, 0x42, 0x60, 0x82
}; };
#define TEXTURE_COUNT (TEXTURE_TARGET + 1)
enum TextureType enum TextureType
{ {
TEXTURE_NONE,
TEXTURE_RECORD,
TEXTURE_ROOT, TEXTURE_ROOT,
TEXTURE_LAYER, TEXTURE_LAYER,
TEXTURE_NULL, TEXTURE_NULL,
TEXTURE_TRIGGERS, TEXTURE_TRIGGERS,
TEXTURE_VISIBLE, TEXTURE_VISIBLE,
TEXTURE_INVISIBLE, TEXTURE_INVISIBLE,
TEXTURE_ERROR, TEXTURE_SHOW_RECT,
TEXTURE_HIDE_RECT,
TEXTURE_PAN,
TEXTURE_MOVE, TEXTURE_MOVE,
TEXTURE_UP, TEXTURE_ROTATE,
TEXTURE_DOWN, TEXTURE_SCALE,
TEXTURE_RECT, TEXTURE_CROP,
TEXTURE_RECT_HIDE, TEXTURE_UNDO,
TEXTURE_REDO,
TEXTURE_DRAW, TEXTURE_DRAW,
TEXTURE_ERASE, TEXTURE_ERASE,
TEXTURE_SCALE, TEXTURE_COLOR_PICKER,
TEXTURE_COLOR,
TEXTURE_PAN,
TEXTURE_CROP,
TEXTURE_ANIMATION, TEXTURE_ANIMATION,
TEXTURE_SPRITESHEET, TEXTURE_SPRITESHEET,
TEXTURE_EVENT, TEXTURE_EVENT,
TEXTURE_ROTATE,
TEXTURE_REDO,
TEXTURE_TRIGGER, TEXTURE_TRIGGER,
TEXTURE_PIVOT, TEXTURE_PIVOT,
TEXTURE_SQUARE, TEXTURE_UNINTERPOLATED,
TEXTURE_CIRCLE, TEXTURE_INTERPOLATED,
TEXTURE_PICKER, TEXTURE_PICKER,
TEXTURE_FRAME,
TEXTURE_FRAME_ALT, TEXTURE_FRAME_ALT,
TEXTURE_TARGET TEXTURE_FRAME,
TEXTURE_TARGET,
TEXTURE_COUNT
}; };
static const vec2 ATLAS_SIZE = {96, 104}; const vec2 ATLAS_SIZE = {96, 104};
static const vec2 TEXTURE_SIZE = {16, 16}; const vec2 TEXTURE_SIZE_SMALL = {8, 8};
static const vec2 TEXTURE_SIZE_SMALL = {8, 8}; const vec2 TEXTURE_SIZE = {16, 16};
static const vec2 TEXTURE_SIZE_BIG = {32, 32}; const vec2 TEXTURE_SIZE_OBLONG = {16, 40};
static const vec2 TEXTURE_SIZE_OBLONG = {16, 40}; const vec2 TEXTURE_SIZE_BIG = {40, 40};
#define ATLAS_UV(x,y){(f32)x / ATLAS_SIZE[0], (f32) y / ATLAS_SIZE[1]} #define ATLAS_UV(x,y){(f32)x / ATLAS_SIZE[0], (f32) y / ATLAS_SIZE[1]}
static const vec2 ATLAS_UVS[TEXTURE_COUNT][2] = const vec2 ATLAS_UVS[TEXTURE_COUNT][2] =
{ {
{ ATLAS_UV( 0, 0), ATLAS_UV( 16, 16) }, /* 16 x 16 v */ { ATLAS_UV( 0, 0), ATLAS_UV( 16, 16) }, /* 16 x 16 v */
{ ATLAS_UV( 16, 0), ATLAS_UV( 32, 16) }, { ATLAS_UV( 16, 0), ATLAS_UV( 32, 16) },
@@ -159,10 +226,10 @@ static const vec2 ATLAS_UVS[TEXTURE_COUNT][2] =
{ ATLAS_UV( 0, 64), ATLAS_UV( 16,104) }, /* 16 x 40 */ { ATLAS_UV( 0, 64), ATLAS_UV( 16,104) }, /* 16 x 40 */
{ ATLAS_UV( 16, 64), ATLAS_UV( 32,104) }, { ATLAS_UV( 16, 64), ATLAS_UV( 32,104) },
{ ATLAS_UV( 32, 64), ATLAS_UV( 48,104) }, { ATLAS_UV( 32, 64), ATLAS_UV( 48,104) },
{ ATLAS_UV( 48, 64), ATLAS_UV( 80, 96) } /* 32 x 32 */ { ATLAS_UV( 48, 64), ATLAS_UV( 88,104) } /* 40 x 40 */
}; };
static const vec2 ATLAS_SIZES[TEXTURE_COUNT] = const vec2 ATLAS_SIZES[TEXTURE_COUNT] =
{ {
TEXTURE_SIZE, TEXTURE_SIZE,
TEXTURE_SIZE, TEXTURE_SIZE,
@@ -197,91 +264,94 @@ static const vec2 ATLAS_SIZES[TEXTURE_COUNT] =
TEXTURE_SIZE_BIG TEXTURE_SIZE_BIG
}; };
#define IMVEC2_ATLAS_UV_GET(type) IMVEC2_VEC2(ATLAS_UVS[type][0]), IMVEC2_VEC2(ATLAS_UVS[type][1])
#define ATLAS_UV_VERTICES(type) UV_VERTICES(ATLAS_UVS[type][0], ATLAS_UVS[type][1]) #define ATLAS_UV_VERTICES(type) UV_VERTICES(ATLAS_UVS[type][0], ATLAS_UVS[type][1])
/* Shaders */ /* Shaders */
struct ShaderData struct ShaderData
{ {
const char* vertex; std::string vertex;
const char* fragment; std::string fragment;
}; };
#define SHADER_COUNT (SHADER_LINE_DOTTED + 1)
enum ShaderType enum ShaderType
{ {
SHADER_LINE, SHADER_LINE,
SHADER_TEXTURE, SHADER_TEXTURE,
SHADER_LINE_DOTTED SHADER_LINE_DOTTED,
SHADER_COUNT
}; };
static const char SHADER_VERTEX[] = const std::string SHADER_VERTEX = R"(
"#version 330 core\n" \ #version 330 core
"layout (location = 0) in vec2 i_position;\n" \ layout (location = 0) in vec2 i_position;
"layout (location = 1) in vec2 i_uv;\n" \ layout (location = 1) in vec2 i_uv;
"\n" \
"out vec2 i_uv_out;\n" \
"\n" \
"uniform mat4 u_transform;\n" \
"\n" \
"void main()\n" \
"{\n" \
" i_uv_out = i_uv;\n" \
" gl_Position = u_transform * vec4(i_position, 0.0, 1.0);\n" \
"}\n";
static const char SHADER_TEXTURE_FRAGMENT[] = out vec2 i_uv_out;
"#version 330 core\n" \
"in vec2 i_uv_out;\n" \
"uniform sampler2D u_texture;\n" \
"uniform vec4 u_tint;\n" \
"uniform vec3 u_color_offset;\n" \
"out vec4 o_fragColor;\n" \
"void main()\n" \
"{\n" \
" vec4 texColor = texture(u_texture, i_uv_out);\n" \
" texColor *= u_tint;\n" \
" texColor.rgb += u_color_offset;\n" \
" o_fragColor = texColor;\n" \
"}\n";
static const char SHADER_FRAGMENT[] = uniform mat4 u_transform;
"#version 330 core\n" \
"out vec4 o_fragColor;\n" \
"uniform vec4 u_color;\n" \
"\n" \
"void main()\n" \
"{\n" \
" o_fragColor = u_color;\n" \
"}\n";
static const char SHADER_LINE_DOTTED_FRAGMENT[] = void main()
"#version 330 core\n" \ {
"uniform vec4 u_color;\n" \ i_uv_out = i_uv;
"out vec4 o_fragColor;\n" \ gl_Position = u_transform * vec4(i_position, 0.0, 1.0);
"void main()\n" \ }
"{\n" \ )";
" float patternX = mod(gl_FragCoord.x, 10.0);\n" \
" float patternY = mod(gl_FragCoord.y, 10.0);\n" \
" if (patternX < 5.0 || patternY < 5.0)\n" \
" {\n" \
" o_fragColor = u_color;\n" \
" }\n" \
" else\n" \
" {\n" \
" discard;\n" \
" }\n" \
"}\n";
static const char SHADER_UNIFORM_COLOR[] = "u_color"; const std::string SHADER_FRAGMENT = R"(
static const char SHADER_UNIFORM_TRANSFORM[] = "u_transform"; #version 330 core
static const char SHADER_UNIFORM_TINT[] = "u_tint"; out vec4 o_fragColor;
static const char SHADER_UNIFORM_COLOR_OFFSET[] = "u_color_offset"; uniform vec4 u_color;
static const char SHADER_UNIFORM_TEXTURE[] = "u_texture";
static const ShaderData SHADER_DATA[SHADER_COUNT] = void main()
{
o_fragColor = u_color;
}
)";
const std::string SHADER_TEXTURE_FRAGMENT = R"(
#version 330 core
in vec2 i_uv_out;
uniform sampler2D u_texture;
uniform vec4 u_tint;
uniform vec3 u_color_offset;
out vec4 o_fragColor;
void main()
{
vec4 texColor = texture(u_texture, i_uv_out);
texColor *= u_tint;
texColor.rgb += u_color_offset;
o_fragColor = texColor;
}
)";
const std::string SHADER_LINE_DOTTED_FRAGMENT = R"(
#version 330 core
uniform vec4 u_color;
out vec4 o_fragColor;
void main()
{
float patternX = mod(gl_FragCoord.x, 10.0);
float patternY = mod(gl_FragCoord.y, 10.0);
if (patternX < 5.0 || patternY < 5.0)
{
o_fragColor = u_color;
}
else
{
discard;
}
}
)";
#define SHADER_UNIFORM_COLOR "u_color"
#define SHADER_UNIFORM_TRANSFORM "u_transform"
#define SHADER_UNIFORM_TINT "u_tint"
#define SHADER_UNIFORM_COLOR_OFFSET "u_color_offset"
#define SHADER_UNIFORM_TEXTURE "u_texture"
const ShaderData SHADER_DATA[SHADER_COUNT] =
{ {
{SHADER_VERTEX, SHADER_FRAGMENT}, {SHADER_VERTEX, SHADER_FRAGMENT},
{SHADER_VERTEX, SHADER_TEXTURE_FRAGMENT}, {SHADER_VERTEX, SHADER_TEXTURE_FRAGMENT},
{SHADER_VERTEX, SHADER_LINE_DOTTED_FRAGMENT} {SHADER_VERTEX, SHADER_LINE_DOTTED_FRAGMENT}
}; };

View File

@@ -1,304 +0,0 @@
#pragma once
#define STRING_UNDEFINED "undefined"
#define STRING_EMPTY ""
#define STRING_WINDOW_TITLE "Anm2Ed"
#define STRING_WINDOW_TITLE_EDITING "Anm2Ed (%s)"
#define STRING_ANM2_CREATED_ON_FORMAT "%d-%B-%Y %I:%M:%S %p"
#define STRING_ERROR_SDL_INIT "[ERROR] Could not initialize SDL (%s)\n"
#define STRING_ERROR_GL_CONTEXT_INIT "[ERROR] Could not initialize OpenGL context (%s)\n"
#define STRING_ERROR_FILE_READ "[ERROR] Could not read from file: %s\n"
#define STRING_ERROR_SHADER_INIT "[ERROR] Could not initialize shader: %i\n%s"
#define STRING_ERROR_TEXTURE_INIT "[ERROR] Could not initialize texture: %s\n"
#define STRING_ERROR_ANM2_READ "[ERROR] Could not read anm2 from file %s: %s\n"
#define STRING_ERROR_ANM2_WRITE "[ERROR] Could not write anm2 to file %s: %s\n"
#define STRING_ERROR_SETTINGS_INIT "[ERROR] Could not load settings file (%s). Should be created on program exit.\n"
#define STRING_INFO_INIT "[INFO] Initializing\n"
#define STRING_INFO_QUIT "[INFO] Exited\n"
#define STRING_INFO_SDL_INIT "[INFO] Initialized SDL\n"
#define STRING_INFO_SDL_QUIT "[INFO] Quit SDL\n"
#define STRING_INFO_GLEW_INIT "[INFO] Initialized GLEW\n"
#define STRING_INFO_GL_CONTEXT_INIT "[INFO] Initialized OpenGL context\n"
#define STRING_INFO_FILE_READ "[INFO] Read from file: %s\n"
#define STRING_INFO_SHADER_INIT "[INFO] Initialized shader: %i\n"
#define STRING_INFO_TEXTURE_INIT "[INFO] Initialized texture: %s\n"
#define STRING_INFO_ANM2_WRITE "[INFO] Wrote anm2 to file: %s\n"
#define STRING_INFO_ANM2_READ "[INFO] Read anm2 from file: %s\n"
#define STRING_INFO_OPENGL "[INFO] OpenGL %s\n"
#define STRING_INFO_IMGUI_INIT "[INFO] Initialized Dear Imgui\n"
#define STRING_INFO_IMGUI_FREE "[INFO] Freed Dear Imgui\n"
#define STRING_DIALOG_ANM2_READ "Select .anm2 file to read..."
#define STRING_DIALOG_ANM2_WRITE "Select .anm2 file to write to..."
#define STRING_DIALOG_ANM2_FILTER "Anm2 Files (*.anm2)"
#define STRING_DIALOG_ANM2_FILTER_WILDCARD "*.anm2"
#define STRING_DIALOG_ALL_FILTER "All Files (*.*)"
#define STRING_DIALOG_ALL_FILTER_WILDCARD "*"
#define STRING_ANM2_CREATED_BY_DEFAULT "Unknown"
#define STRING_ANM2_NEW_ANIMATION "New Animation"
#define STRING_ANM2_NEW_LAYER "New Layer"
#define STRING_ANM2_NEW_NULL "New Null"
#define STRING_ANM2_NEW_EVENT "New Event"
#define STRING_ANM2_ROOT "Root"
#define STRING_PREVIEW_FRAMES_DIRECTORY "frames/"
#define STRING_PREVIEW_FRAMES_FORMAT "%s/%03d.png"
#define STRING_IMGUI_WINDOW "Window"
#define STRING_IMGUI_DOCKSPACE "Dockspace"
#define STRING_IMGUI_TASKBAR "Taskbar"
#define STRING_IMGUI_TASKBAR_PLAYBACK "Playback"
#define STRING_IMGUI_TASKBAR_FILE "File"
#define STRING_IMGUI_TASKBAR_WIZARD "Wizard"
#define STRING_IMGUI_FILE_MENU "File Menu"
#define STRING_IMGUI_FILE_NEW "New"
#define STRING_IMGUI_FILE_OPEN "Open"
#define STRING_IMGUI_FILE_SAVE "Save"
#define STRING_IMGUI_FILE_SAVE_AS "Save As"
#define STRING_IMGUI_PLAYBACK_MENU "Playback Menu"
#define STRING_IMGUI_PLAYBACK_LOOP "Loop"
#define STRING_IMGUI_WIZARD_MENU "Wizard Menu"
#define STRING_IMGUI_WIZARD_EXPORT_FRAMES_TO_PNG "Export Frames to PNG"
#define STRING_IMGUI_RECORDING "Recording..."
#define STRING_IMGUI_ANIMATIONS "Animations"
#define STRING_IMGUI_ANIMATIONS_ANIMATION_LABEL "##Animation"
#define STRING_IMGUI_ANIMATIONS_ADD "Add"
#define STRING_IMGUI_ANIMATIONS_REMOVE "Remove"
#define STRING_IMGUI_ANIMATIONS_DUPLICATE "Duplicate"
#define STRING_IMGUI_ANIMATIONS_SET_AS_DEFAULT "Set as Default"
#define STRING_IMGUI_ANIMATIONS_DEFAULT_ANIMATION_FORMAT "(*) %s "
#define STRING_IMGUI_ANIMATIONS_DRAG_DROP "Animation Drag/Drop"
#define STRING_IMGUI_EVENTS "Events"
#define STRING_IMGUI_EVENTS_EVENT_LABEL "##Event"
#define STRING_IMGUI_EVENTS_ADD "Add"
#define STRING_IMGUI_EVENTS_REMOVE "Remove"
#define STRING_IMGUI_EVENT_FORMAT "#%i %s"
#define STRING_IMGUI_EVENTS_DRAG_DROP "Event Drag/Drop"
#define STRING_IMGUI_SPRITESHEETS "Spritesheets"
#define STRING_IMGUI_SPRITESHEETS_ADD "Add"
#define STRING_IMGUI_SPRITESHEETS_REMOVE "Remove"
#define STRING_IMGUI_SPRITESHEETS_RELOAD "Reload"
#define STRING_IMGUI_SPRITESHEETS_REPLACE "Replace"
#define STRING_IMGUI_SPRITESHEET_FORMAT "#%i %s"
#define STRING_IMGUI_SPRITESHEETS_DRAG_DROP "Spritesheet Drag/Drop"
#define STRING_IMGUI_FRAME_PROPERTIES "Frame Properties"
#define STRING_IMGUI_FRAME_PROPERTIES_CROP_POSITION "Crop Position"
#define STRING_IMGUI_FRAME_PROPERTIES_CROP_SIZE "Crop Size"
#define STRING_IMGUI_FRAME_PROPERTIES_POSITION "Position"
#define STRING_IMGUI_FRAME_PROPERTIES_PIVOT "Pivot"
#define STRING_IMGUI_FRAME_PROPERTIES_SCALE "Scale"
#define STRING_IMGUI_FRAME_PROPERTIES_ROTATION "Rotation"
#define STRING_IMGUI_FRAME_PROPERTIES_VISIBLE "Visible"
#define STRING_IMGUI_FRAME_PROPERTIES_INTERPOLATED "Interpolated"
#define STRING_IMGUI_FRAME_PROPERTIES_DURATION "Duration"
#define STRING_IMGUI_FRAME_PROPERTIES_TINT "Tint"
#define STRING_IMGUI_FRAME_PROPERTIES_COLOR_OFFSET "Color Offset"
#define STRING_IMGUI_FRAME_PROPERTIES_EVENT "Event"
#define STRING_IMGUI_FRAME_PROPERTIES_AT_FRAME "At Frame"
#define STRING_IMGUI_FRAME_PROPERTIES_FLIP_X "Flip X"
#define STRING_IMGUI_FRAME_PROPERTIES_FLIP_Y "Flip Y"
#define STRING_IMGUI_FRAME_PROPERTIES_ROOT "-- Root --"
#define STRING_IMGUI_FRAME_PROPERTIES_LAYER "-- Layer -- "
#define STRING_IMGUI_FRAME_PROPERTIES_NULL "-- Null --"
#define STRING_IMGUI_FRAME_PROPERTIES_TRIGGER "-- Trigger --"
#define STRING_IMGUI_ANIMATION_PREVIEW "Animation Preview"
#define STRING_IMGUI_ANIMATION_PREVIEW_LABEL "##Animation Preview"
#define STRING_IMGUI_ANIMATION_PREVIEW_SETTINGS "##Animation Preview Settings"
#define STRING_IMGUI_ANIMATION_PREVIEW_GRID_SETTINGS "##Grid Settings"
#define STRING_IMGUI_ANIMATION_PREVIEW_GRID "Grid"
#define STRING_IMGUI_ANIMATION_PREVIEW_GRID_SIZE "Size"
#define STRING_IMGUI_ANIMATION_PREVIEW_GRID_OFFSET "Offset"
#define STRING_IMGUI_ANIMATION_PREVIEW_GRID_COLOR "Color"
#define STRING_IMGUI_ANIMATION_PREVIEW_VIEW_SETTINGS "##View Settings"
#define STRING_IMGUI_ANIMATION_PREVIEW_ZOOM "Zoom"
#define STRING_IMGUI_ANIMATION_PREVIEW_BACKGROUND_SETTINGS "##Background Settings"
#define STRING_IMGUI_ANIMATION_PREVIEW_BACKGROUND_COLOR "Background Color"
#define STRING_IMGUI_ANIMATION_PREVIEW_HELPER_SETTINGS "##Helper Settings"
#define STRING_IMGUI_ANIMATION_PREVIEW_CENTER_VIEW "Center View"
#define STRING_IMGUI_ANIMATION_PREVIEW_AXIS "Axes"
#define STRING_IMGUI_ANIMATION_PREVIEW_AXIS_COLOR "Color"
#define STRING_IMGUI_ANIMATION_PREVIEW_ROOT_TRANSFORM "Root Transform"
#define STRING_IMGUI_ANIMATION_PREVIEW_SHOW_PIVOT "Show Pivot"
#define STRING_IMGUI_ANIMATION_PREVIEW_POSITION "##Position"
#define STRING_IMGUI_ANIMATION_PREVIEW_POSITION_FORMAT "Position: {%5.0f, %5.0f}"
#define STRING_IMGUI_SPRITESHEET_EDITOR "Spritesheet Editor"
#define STRING_IMGUI_SPRITESHEET_EDITOR_LABEL "##Animation Preview"
#define STRING_IMGUI_SPRITESHEET_EDITOR_SETTINGS "##Animation Preview Settings"
#define STRING_IMGUI_SPRITESHEET_EDITOR_GRID_SETTINGS "##Grid Settings"
#define STRING_IMGUI_SPRITESHEET_EDITOR_GRID "Grid"
#define STRING_IMGUI_SPRITESHEET_EDITOR_GRID_SNAP "Snap"
#define STRING_IMGUI_SPRITESHEET_EDITOR_GRID_SIZE "Size"
#define STRING_IMGUI_SPRITESHEET_EDITOR_GRID_OFFSET "Offset"
#define STRING_IMGUI_SPRITESHEET_EDITOR_GRID_COLOR "Color"
#define STRING_IMGUI_SPRITESHEET_EDITOR_VIEW_SETTINGS "##View Settings"
#define STRING_IMGUI_SPRITESHEET_EDITOR_ZOOM "Zoom"
#define STRING_IMGUI_SPRITESHEET_EDITOR_BACKGROUND_SETTINGS "##Background Settings"
#define STRING_IMGUI_SPRITESHEET_EDITOR_BACKGROUND_COLOR "Background Color"
#define STRING_IMGUI_SPRITESHEET_EDITOR_CENTER_VIEW "Center View"
#define STRING_IMGUI_SPRITESHEET_EDITOR_BORDER "Border"
#define STRING_IMGUI_SPRITESHEET_EDITOR_POSITION "##Position"
#define STRING_IMGUI_SPRITESHEET_EDITOR_POSITION_FORMAT "Position: {%5.0f, %5.0f}"
#define STRING_IMGUI_TIMELINE "Timeline"
#define STRING_IMGUI_TIMELINE_HEADER "##Header"
#define STRING_IMGUI_TIMELINE_ELEMENT_UP "##Up"
#define STRING_IMGUI_TIMELINE_ELEMENT_DOWN "##Down"
#define STRING_IMGUI_TIMELINE_ELEMENT_FRAMES "Element Frames"
#define STRING_IMGUI_TIMELINE_ROOT "Root"
#define STRING_IMGUI_TIMELINE_ELEMENT_FORMAT "#%i %s"
#define STRING_IMGUI_TIMELINE_SPRITESHEET_FORMAT "#%i"
#define STRING_IMGUI_TIMELINE_SPRITESHEET_UNKNOWN "#?"
#define STRING_IMGUI_TIMELINE_ELEMENT_SPRITESHEET_ID_LABEL "##Timeline Element Spritesheet ID"
#define STRING_IMGUI_TIMELINE_ELEMENT_NAME_LABEL "##Timeline Element Name"
#define STRING_IMGUI_TIMELINE_TRIGGERS "Triggers"
#define STRING_IMGUI_TIMELINE_ANIMATION_LABEL "##Timeline Animation"
#define STRING_IMGUI_TIMELINE_ELEMENT_SHIFT_ARROWS_LABEL "##Timeline Shift Arrows"
#define STRING_IMGUI_TIMELINE_ANIMATIONS "Animations"
#define STRING_IMGUI_TIMELINE_PLAY "|> Play"
#define STRING_IMGUI_TIMELINE_PAUSE "|| Pause"
#define STRING_IMGUI_TIMELINE_FRAME_ADD "Add Frame"
#define STRING_IMGUI_TIMELINE_FRAMES "Frames"
#define STRING_IMGUI_TIMELINE_FRAME_LABEL "##Frame"
#define STRING_IMGUI_TIMELINE_TRIGGER_LABEL "##Trigger"
#define STRING_IMGUI_TIMELINE_FRAME_REMOVE "Remove Frame"
#define STRING_IMGUI_TIMELINE_FIT_ANIMATION_LENGTH "Fit Animation Length"
#define STRING_IMGUI_TIMELINE_ANIMATION LENGTH "Animation Length:"
#define STRING_IMGUI_TIMELINE_VISIBLE "##Visible"
#define STRING_IMGUI_TIMELINE_LAYER "Layer"
#define STRING_IMGUI_TIMELINE_NULL "Null"
#define STRING_IMGUI_TIMELINE_RECT "Rect"
#define STRING_IMGUI_TIMELINE_FRAME_INDICES "Frame Indices"
#define STRING_IMGUI_TIMELINE_ANIMATION_LENGTH "Animation Length"
#define STRING_IMGUI_TIMELINE_ELEMENT_TIMELINE "Element Timeline"
#define STRING_IMGUI_TIMELINE_ELEMENTS "Elements"
#define STRING_IMGUI_TIMELINE_ELEMENT_LIST "Element List"
#define STRING_IMGUI_TIMELINE_ELEMENT_ADD "Add Element"
#define STRING_IMGUI_TIMELINE_ELEMENT_ADD_MENU "Element Add Menu"
#define STRING_IMGUI_TIMELINE_ELEMENT_ADD_MENU_LAYER "Add Layer..."
#define STRING_IMGUI_TIMELINE_ELEMENT_ADD_MENU_NULL "Add Null..."
#define STRING_IMGUI_TIMELINE_ELEMENT_REMOVE "Remove Element"
#define STRING_IMGUI_TIMELINE_LOOP "Loop"
#define STRING_IMGUI_TIMELINE_FPS "FPS"
#define STRING_IMGUI_TIMELINE_CREATED_BY "Author"
#define STRING_IMGUI_TIMELINE_CREATED_ON "Created on: %s"
#define STRING_IMGUI_TIMELINE_VERSION "Version: %i"
#define STRING_IMGUI_TIMELINE_VIEWER "Viewer"
#define STRING_IMGUI_TIMELINE_CHILD "Timeline"
#define STRING_IMGUI_TIMELINE_MAIN "Main"
#define STRING_IMGUI_TIMELINE_FRAME_DRAG_DROP "Frame Drag/Drop"
#define STRING_IMGUI_TIMELINE_ITEM_DRAG_DROP "Item Drag/Drop"
#define STRING_IMGUI_TOOLS "Tools"
#define STRING_IMGUI_TOOLS_PAN "##Pan"
#define STRING_IMGUI_TOOLS_MOVE "##Move"
#define STRING_IMGUI_TOOLS_ROTATE "##Rotate"
#define STRING_IMGUI_TOOLS_SCALE "##Scale"
#define STRING_IMGUI_TOOLS_CROP "##Crop"
#define STRING_IMGUI_TOOLTIP_ANIMATIONS_ADD "Add a new animation."
#define STRING_IMGUI_TOOLTIP_ANIMATIONS_DUPLICATE "Duplicates the selected animation."
#define STRING_IMGUI_TOOLTIP_ANIMATIONS_REMOVE "Removes the selected animation."
#define STRING_IMGUI_TOOLTIP_ANIMATIONS_SELECT "Select the animation to edit.\nYou can also click the name to edit it."
#define STRING_IMGUI_TOOLTIP_ANIMATIONS_SET_AS_DEFAULT "Sets the selected animation as the default.\nThe default animation is marked with \"(*)\"."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_AXIS "Toggles the display of the X/Y axes on the animation preview."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_AXIS_COLOR "Changes the color of the X/Y axes on the animation preview."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_BACKGROUND_COLOR "Changes the background color of the animation preview."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_CENTER_VIEW "Centers the animation preview's pan."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_GRID "Toggles grid visibility on the animation preview."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_GRID_COLOR "Changes the animation preview grid color."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_GRID_OFFSET "Changes the animation preview grid's offset, in pixels."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_GRID_SIZE "Changes the animation preview grid's size, in pixels."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_ZOOM "Changes the animation preview zoom level."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_ROOT_TRANSFORM "Toggle the properties of the Root element of an animation being able to change the properties (such as position or scale) of all of the animation's elements.\nNOTE: Scale/rotation currently not implemented. Matrix math is hard."
#define STRING_IMGUI_TOOLTIP_ANIMATION_PREVIEW_SHOW_PIVOT "Toggle the pivots of layer animation elements being visible on the animation preview."
#define STRING_IMGUI_TOOLTIP_EVENTS_ADD "Add a new event."
#define STRING_IMGUI_TOOLTIP_EVENTS_REMOVE "Removes the selected event."
#define STRING_IMGUI_TOOLTIP_EVENTS_SELECT "Set the event for the trigger, or rename it."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_AT_FRAME "Sets the frame in which the trigger will activate."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_COLOR_OFFSET "Change the color offset of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_CROP_POSITION "Change the X/Y position of the crop of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_CROP_SIZE "Change the crop width/height of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_DURATION "Change the duration of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_EVENT "Sets the event the trigger will use."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_INTERPOLATED "Toggles the interpolation of the frame.\nBetween keyframes, will transform the values in the in-betweens to be smooth."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_PIVOT "Change the X/Y pivot of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_POSITION "Change the X/Y position of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_ROTATION "Change the rotation of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_SCALE "Change the X/Y scale of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_TINT "Change the tint of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_VISIBLE "Toggles the visibility of the frame."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_FLIP_X "Change the sign of the X scale, to cheat flipping the layer horizontally.\n(Anm2 doesn't support flipping directly)."
#define STRING_IMGUI_TOOLTIP_FRAME_PROPERTIES_FLIP_Y "Change the sign of the Y scale, to cheat flipping the layer vertically.\n(Anm2 doesn't support flipping directly)."
#define STRING_IMGUI_TOOLTIP_SPRITESHEETS_ADD "Opens the file dialog to load in a new spritesheet."
#define STRING_IMGUI_TOOLTIP_SPRITESHEETS_RELOAD "Reloads the selected spritesheet."
#define STRING_IMGUI_TOOLTIP_SPRITESHEETS_REMOVE "Removes the selected spritesheet."
#define STRING_IMGUI_TOOLTIP_SPRITESHEETS_REPLACE "Replaces the selected spritesheet; opens up the file dialog."
#define STRING_IMGUI_TOOLTIP_SPRITESHEETS_SELECT "Select the spritesheet element."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ANIMATION_LENGTH "Changes the current animation's length."
#define STRING_IMGUI_TOOLTIP_TIMELINE_CREATED_BY "Change the author of the animation."
#define STRING_IMGUI_TOOLTIP_TIMELINE_CREATED_ON_NOW "Set the date of creation to the current system time."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_ADD "Add a layer or null timeline element."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_LAYER "This is a Layer element.\nThese are the main graphical animation elements.\nClick to select or rename."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_NAME "Click to rename the element."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_NULL "This is a Null element.\nThese are invisible elements where a game engine may have access to them for additional effects.\nClick to select or rename."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_RECT "Toggle visibility for a rectangle around the null."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_REMOVE "Remove a timeline element."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_ROOT "This is the Root element.\nClick to select."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_SHIFT_DOWN "Shift this timeline element below.\nElements with lower indices will display further in front."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_SHIFT_UP "Shift this timeline element above.\nElements with higher indices will display further behind."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_SPRITESHEET "Click to change the spritesheet the layer is using."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_TRIGGERS "This is the animation's Triggers.\nTriggers are special activations; each is bound to an Event.\nClick to select."
#define STRING_IMGUI_TOOLTIP_TIMELINE_ELEMENT_VISIBLE "Toggle visibility for this element."
#define STRING_IMGUI_TOOLTIP_TIMELINE_FPS "Change the FPS of the animation."
#define STRING_IMGUI_TOOLTIP_TIMELINE_FIT_ANIMATION_LENGTH "Sets the animation length to the latest frame."
#define STRING_IMGUI_TOOLTIP_TIMELINE_FRAME_ADD "Add a frame to the current selected element."
#define STRING_IMGUI_TOOLTIP_TIMELINE_FRAME_REMOVE "Removes the selected frame from the current selected element."
#define STRING_IMGUI_TOOLTIP_TIMELINE_LOOP "Toggles the animation looping."
#define STRING_IMGUI_TOOLTIP_TIMELINE_PAUSE "Pauses the animation."
#define STRING_IMGUI_TOOLTIP_TIMELINE_PLAY "Plays the animation."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_AXIS "Toggles the display of the X/Y axes on the spritesheet editor."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_AXIS_COLOR "Changes the color of the X/Y axes on the spritesheet editor."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_BACKGROUND_COLOR "Changes the background color of the spritesheet editor."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_CENTER_VIEW "Centers the spritesheet editor's pan."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_GRID "Toggles grid visibility on the spritesheet editor."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_GRID_SNAP "When using the crop tool, will snap points to the grid."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_GRID_COLOR "Changes the spritesheet editor grid color."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_GRID_OFFSET "Changes the spritesheet editor grid's offset, in pixels."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_GRID_SIZE "Changes the spritesheet editor grid's size, in pixels."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_ZOOM "Changes the spritesheet editor zoom level."
#define STRING_IMGUI_TOOLTIP_SPRITESHEET_EDITOR_BORDER "Toggles a border appearing around the confines of the spritesheet."
#define STRING_IMGUI_TOOLTIP_TOOLS_PAN "Use the pan tool.\nWill shift the view as the cursor is dragged."
#define STRING_IMGUI_TOOLTIP_TOOLS_MOVE "Use the move tool.\nWill move selected elements as the cursor is dragged.\n(Animation Preview only.)"
#define STRING_IMGUI_TOOLTIP_TOOLS_ROTATE "Use the rotate tool.\nWill rotate selected elements as the cursor is dragged.\n(Animation Preview only.)"
#define STRING_IMGUI_TOOLTIP_TOOLS_SCALE "Use the scale tool.\nWill scale the selected elements as the cursor is dragged.\n(Animation Preview only.)"
#define STRING_IMGUI_TOOLTIP_TOOLS_CROP "Use the crop tool.\nWill set the crop of the selected elements as the cursor is dragged.\n(Spritesheet Editor only.)"
#define STRING_IMGUI_TOOLTIP_FILE_NEW "Load a blank .anm2 file to edit."
#define STRING_IMGUI_TOOLTIP_FILE_OPEN "Open an existing .anm2 file to edit."
#define STRING_IMGUI_TOOLTIP_FILE_SAVE "Save the current .anm2 file."
#define STRING_IMGUI_TOOLTIP_FILE_SAVE_AS "Save the current .anm2 file to a location."
#define STRING_IMGUI_TOOLTIP_PLAYBACK_IS_LOOP "Toggles the animation playback looping when the time reaches the end."
#define STRING_IMGUI_TOOLTIP_WIZARD_EXPORT_FRAMES_TO_PNG "Records the current animation and exports the frames as .pngs.\nLook in the working directory of the program for them."
#define STRING_IMGUI_TOOLTIP_FILE_MENU "Opens the file menu, for reading/writing anm2 files."
#define STRING_IMGUI_TOOLTIP_PLAYBACK_MENU "Opens the playback menu, for managing playback settings."
#define STRING_IMGUI_TOOLTIP_WIZARD_MENU "Opens the wizard menu, for handy functions involving the anm2."
#define STRING_OPENGL_VERSION "#version 330"
#define PATH_SETTINGS "settings.ini"

File diff suppressed because it is too large Load Diff

View File

@@ -6,15 +6,18 @@
#define ANM2_SCALE_CONVERT(x) ((f32)x / 100.0f) #define ANM2_SCALE_CONVERT(x) ((f32)x / 100.0f)
#define ANM2_TINT_CONVERT(x) ((f32)x / 255.0f) #define ANM2_TINT_CONVERT(x) ((f32)x / 255.0f)
#define ANM2_STRING_MAX 0xFF
#define ANM2_STRING_FORMATTED_MAX 0xFFF
#define ANM2_PATH_FORMATTED_MAX PATH_MAX + 0xFF
#define ANM2_BUFFER_MAX 0xFFFFF
#define ANM2_FPS_MIN 0 #define ANM2_FPS_MIN 0
#define ANM2_FPS_MAX 120 #define ANM2_FPS_MAX 120
#define ANM2_FRAME_NUM_MIN 1 #define ANM2_FRAME_NUM_MIN 1
#define ANM2_FRAME_NUM_MAX 1000000 #define ANM2_FRAME_NUM_MAX 1000000
#define ANM2_FRAME_DELAY_MIN 1 #define ANM2_FRAME_DELAY_MIN 1
#define ANM2_STRING_MAX 0xFF
#define ANM2_READ_ERROR "Failed to read anm2 from file: {}"
#define ANM2_READ_INFO "Read anm2 from file: {}"
#define ANM2_WRITE_ERROR "Failed to write anm2 to file: {}"
#define ANM2_WRITE_INFO "Wrote anm2 to file: {}"
#define STRING_ANM2_CREATED_ON_FORMAT "%d-%B-%Y %I:%M:%S %p"
/* Elements */ /* Elements */
#define ANM2_ELEMENT_LIST \ #define ANM2_ELEMENT_LIST \
@@ -53,7 +56,8 @@ static const char* ANM2_ELEMENT_STRINGS[] = {
#undef X #undef X
}; };
DEFINE_STRING_TO_ENUM_FN(anm2_element_from_string, Anm2Element, ANM2_ELEMENT_STRINGS, ANM2_ELEMENT_COUNT) DEFINE_STRING_TO_ENUM_FUNCTION(ANM2_ELEMENT_STRING_TO_ENUM, Anm2Element, ANM2_ELEMENT_STRINGS, ANM2_ELEMENT_COUNT)
DEFINE_ENUM_TO_STRING_FUNCTION(ANM2_ELEMENT_ENUM_TO_STRING, ANM2_ELEMENT_STRINGS, ANM2_ELEMENT_COUNT)
#define ANM2_ATTRIBUTE_LIST \ #define ANM2_ATTRIBUTE_LIST \
X(CREATED_BY, "CreatedBy") \ X(CREATED_BY, "CreatedBy") \
@@ -107,38 +111,39 @@ static const char* ANM2_ATTRIBUTE_STRINGS[] = {
#undef X #undef X
}; };
DEFINE_STRING_TO_ENUM_FN(anm2_attribute_from_string, Anm2Attribute, ANM2_ATTRIBUTE_STRINGS, ANM2_ATTRIBUTE_COUNT) DEFINE_STRING_TO_ENUM_FUNCTION(ANM2_ATTRIBUTE_STRING_TO_ENUM, Anm2Attribute, ANM2_ATTRIBUTE_STRINGS, ANM2_ATTRIBUTE_COUNT)
DEFINE_ENUM_TO_STRING_FUNCTION(ANM2_ATTRIBUTE_ENUM_TO_STRING, ANM2_ATTRIBUTE_STRINGS, ANM2_ATTRIBUTE_COUNT)
#define ANM2_COUNT (ANM2_TRIGGER + 1)
enum Anm2Type enum Anm2Type
{ {
ANM2_NONE, ANM2_NONE,
ANM2_ROOT, ANM2_ROOT,
ANM2_LAYER, ANM2_LAYER,
ANM2_NULL, ANM2_NULL,
ANM2_TRIGGERS ANM2_TRIGGERS,
ANM2_COUNT
}; };
struct Anm2Spritesheet struct Anm2Spritesheet
{ {
char path[PATH_MAX] = STRING_EMPTY; std::string path{};
}; };
struct Anm2Layer struct Anm2Layer
{ {
std::string name = "New Layer";
s32 spritesheetID = -1; s32 spritesheetID = -1;
char name[ANM2_STRING_MAX] = STRING_ANM2_NEW_LAYER;
}; };
struct Anm2Null struct Anm2Null
{ {
char name[ANM2_STRING_MAX] = STRING_ANM2_NEW_NULL; std::string name = "New Null";
bool isShowRect = false; bool isShowRect = false;
}; };
struct Anm2Event struct Anm2Event
{ {
char name[ANM2_STRING_MAX] = STRING_ANM2_NEW_EVENT; std::string name = "New Event";
}; };
struct Anm2Frame struct Anm2Frame
@@ -147,8 +152,8 @@ struct Anm2Frame
bool isVisible = true; bool isVisible = true;
f32 rotation = 1.0f; f32 rotation = 1.0f;
s32 delay = ANM2_FRAME_DELAY_MIN; s32 delay = ANM2_FRAME_DELAY_MIN;
s32 atFrame = -1; s32 atFrame = INDEX_NONE;
s32 eventID = -1; s32 eventID = ID_NONE;
vec2 crop = {0.0f, 0.0f}; vec2 crop = {0.0f, 0.0f};
vec2 pivot = {0.0f, 0.0f}; vec2 pivot = {0.0f, 0.0f};
vec2 position = {0.0f, 0.0f}; vec2 position = {0.0f, 0.0f};
@@ -167,7 +172,7 @@ struct Anm2Item
struct Anm2Animation struct Anm2Animation
{ {
s32 frameNum = ANM2_FRAME_NUM_MIN; s32 frameNum = ANM2_FRAME_NUM_MIN;
char name[ANM2_STRING_MAX] = STRING_ANM2_NEW_ANIMATION; std::string name = "New Animation";
bool isLoop = true; bool isLoop = true;
Anm2Item rootAnimation; Anm2Item rootAnimation;
std::map<s32, Anm2Item> layerAnimations; std::map<s32, Anm2Item> layerAnimations;
@@ -177,46 +182,66 @@ struct Anm2Animation
struct Anm2 struct Anm2
{ {
char path[PATH_MAX] = STRING_EMPTY; std::string path{};
s32 fps = 30; std::string defaultAnimation{};
s32 version = 0; std::string createdBy = "robot";
char createdBy[ANM2_STRING_MAX] = STRING_ANM2_CREATED_BY_DEFAULT; std::string createdOn{};
char createdOn[ANM2_STRING_MAX] = STRING_EMPTY;
char defaultAnimation[ANM2_STRING_MAX] = STRING_EMPTY;
std::map<s32, Anm2Spritesheet> spritesheets; std::map<s32, Anm2Spritesheet> spritesheets;
std::map<s32, Anm2Layer> layers; std::map<s32, Anm2Layer> layers;
std::map<s32, Anm2Null> nulls; std::map<s32, Anm2Null> nulls;
std::map<s32, Anm2Event> events; std::map<s32, Anm2Event> events;
std::map<s32, Anm2Animation> animations; std::map<s32, Anm2Animation> animations;
std::map<s32, s32> layerMap; // id, index
s32 fps = 30;
s32 version = 0;
}; };
struct Anm2Reference struct Anm2Reference
{ {
s32 animationID = ID_NONE;
Anm2Type itemType = ANM2_NONE; Anm2Type itemType = ANM2_NONE;
s32 animationID = -1; s32 itemID = ID_NONE;
s32 itemID = -1; s32 frameIndex = INDEX_NONE;
s32 frameIndex = -1;
auto operator<=>(const Anm2Reference&) const = default; auto operator<=>(const Anm2Reference&) const = default;
}; };
struct Anm2AnimationWithID
{
s32 id;
Anm2Animation animation;
};
struct Anm2EventWithID
{
s32 id;
Anm2Event event;
};
struct Anm2FrameWithReference
{
Anm2Reference reference;
Anm2Frame frame;
};
void anm2_layer_add(Anm2* self); void anm2_layer_add(Anm2* self);
void anm2_layer_remove(Anm2* self, s32 id); void anm2_layer_remove(Anm2* self, s32 id);
void anm2_null_add(Anm2* self); void anm2_null_add(Anm2* self);
void anm2_null_remove(Anm2* self, s32 id); void anm2_null_remove(Anm2* self, s32 id);
bool anm2_serialize(Anm2* self, const char* path); bool anm2_serialize(Anm2* self, const std::string& path);
bool anm2_deserialize(Anm2* self, Resources* resources, const char* path); bool anm2_deserialize(Anm2* self, Resources* resources, const std::string& path);
void anm2_new(Anm2* self); void anm2_new(Anm2* self);
void anm2_created_on_set(Anm2* self); void anm2_created_on_set(Anm2* self);
s32 anm2_animation_add(Anm2* self); s32 anm2_animation_add(Anm2* self);
void anm2_animation_remove(Anm2* self, s32 id); void anm2_animation_remove(Anm2* self, s32 id);
void anm2_spritesheet_texture_load(Anm2* self, Resources* resources, const char* path, s32 id); void anm2_spritesheet_texture_load(Anm2* self, Resources* resources, const std::string& path, s32 id);
Anm2Animation* anm2_animation_from_reference(Anm2* self, Anm2Reference* reference); Anm2Animation* anm2_animation_from_reference(Anm2* self, Anm2Reference* reference);
Anm2Item* anm2_item_from_reference(Anm2* self, Anm2Reference* reference); Anm2Item* anm2_item_from_reference(Anm2* self, Anm2Reference* reference);
Anm2Frame* anm2_frame_from_reference(Anm2* self, Anm2Reference* reference); Anm2Frame* anm2_frame_from_reference(Anm2* self, Anm2Reference* reference);
s32 anm2_frame_index_from_time(Anm2* self, Anm2Reference reference, f32 time);
Anm2Frame* anm2_frame_add(Anm2* self, Anm2Reference* reference, s32 time); Anm2Frame* anm2_frame_add(Anm2* self, Anm2Reference* reference, s32 time);
void anm2_frame_from_time(Anm2* self, Anm2Frame* frame, Anm2Reference reference, f32 time); void anm2_frame_from_time(Anm2* self, Anm2Frame* frame, Anm2Reference reference, f32 time);
void anm2_reference_clear(Anm2Reference* self); void anm2_reference_clear(Anm2Reference* self);
void anm2_reference_item_clear(Anm2Reference* self); void anm2_reference_item_clear(Anm2Reference* self);
void anm2_reference_frame_clear(Anm2Reference* self); void anm2_reference_frame_clear(Anm2Reference* self);
s32 anm2_animation_length_get(Anm2* self, s32 animationID); s32 anm2_animation_length_get(Anm2Animation* self);
void anm2_animation_length_set(Anm2Animation* self);

50
src/canvas.cpp Normal file
View File

@@ -0,0 +1,50 @@
// Common rendering area
#include "canvas.h"
void canvas_init(Canvas* self, vec2 size)
{
self->size = size;
glGenFramebuffers(1, &self->fbo);
glBindFramebuffer(GL_FRAMEBUFFER, self->fbo);
glGenTextures(1, &self->texture);
glBindTexture(GL_TEXTURE_2D, self->texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (s32)self->size.x, (s32)self->size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->texture, 0);
glGenRenderbuffers(1, &self->rbo);
glBindRenderbuffer(GL_RENDERBUFFER, self->rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (s32)self->size.x, (s32)self->size.y);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, self->rbo);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Texture
glGenVertexArrays(1, &self->textureVAO);
glGenBuffers(1, &self->textureVBO);
glGenBuffers(1, &self->textureEBO);
glBindVertexArray(self->textureVAO);
glBindBuffer(GL_ARRAY_BUFFER, self->textureVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(f32) * 4 * 4, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self->textureEBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_TEXTURE_INDICES), GL_TEXTURE_INDICES, GL_STATIC_DRAW);
// Position attribute
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)0);
// UV attribute
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)(2 * sizeof(f32)));
glBindVertexArray(0);
}

33
src/canvas.h Normal file
View File

@@ -0,0 +1,33 @@
#pragma once
#include "texture.h"
#include "shader.h"
#define CANVAS_ZOOM_MIN 1
#define CANVAS_ZOOM_MAX 1000
#define CANVAS_ZOOM_STEP 25
#define CANVAS_LINE_LENGTH 100000.0f
#define CANVAS_GRID_RANGE 100
#define CANVAS_GRID_MIN 1
#define CANVAS_GRID_MAX 100
const f32 CANVAS_AXIS_VERTICES[] =
{
-CANVAS_LINE_LENGTH, 0.0f,
CANVAS_LINE_LENGTH, 0.0f,
0.0f, -CANVAS_LINE_LENGTH,
0.0f, CANVAS_LINE_LENGTH
};
struct Canvas
{
GLuint fbo;
GLuint rbo;
GLuint texture;
GLuint textureEBO;
GLuint textureVAO;
GLuint textureVBO;
vec2 size;
};
void canvas_init(Canvas* self, vec2 size);

140
src/clipboard.cpp Normal file
View File

@@ -0,0 +1,140 @@
#include "clipboard.h"
static void _clipboard_item_remove(ClipboardItem* self, Anm2* anm2)
{
switch (self->type)
{
case CLIPBOARD_FRAME:
{
Anm2FrameWithReference frameWithReference = std::get<Anm2FrameWithReference>(self->data);
Anm2Animation* animation = anm2_animation_from_reference(anm2, &frameWithReference.reference);
if (!animation) break;
std::vector<Anm2Frame>* frames = nullptr;
switch (frameWithReference.reference.itemType)
{
case ANM2_ROOT:
frames = &animation->rootAnimation.frames;
break;
case ANM2_LAYER:
frames = &animation->layerAnimations[frameWithReference.reference.itemID].frames;
break;
case ANM2_NULL:
frames = &animation->nullAnimations[frameWithReference.reference.itemID].frames;
break;
case ANM2_TRIGGERS:
frames = &animation->triggers.frames;
break;
default:
break;
}
if (frames)
frames->erase(frames->begin() + frameWithReference.reference.frameIndex);
break;
}
case CLIPBOARD_ANIMATION:
{
Anm2AnimationWithID animationWithID = std::get<Anm2AnimationWithID>(self->data);
for (auto & [id, animation] : anm2->animations)
{
if (id == animationWithID.id)
anm2->animations.erase(animationWithID.id);
}
break;
}
case CLIPBOARD_EVENT:
{
Anm2EventWithID eventWithID = std::get<Anm2EventWithID>(self->data);
for (auto & [id, event] : anm2->events)
{
if (id == eventWithID.id)
anm2->events.erase(eventWithID.id);
}
break;
}
default:
break;
}
}
static void _clipboard_item_paste(ClipboardItem* self, ClipboardLocation* location, Anm2* anm2)
{
switch (self->type)
{
case CLIPBOARD_FRAME:
{
Anm2FrameWithReference* frameWithReference = std::get_if<Anm2FrameWithReference>(&self->data);
Anm2Reference* reference = std::get_if<Anm2Reference>(location);
if (!frameWithReference || !reference) break;
if (frameWithReference->reference.itemType != reference->itemType) break;
Anm2Animation* animation = anm2_animation_from_reference(anm2, reference);
Anm2Item* anm2Item = anm2_item_from_reference(anm2, reference);
if (!animation || !anm2Item) break;
s32 insertIndex = (reference->itemType == ANM2_TRIGGERS) ?
reference->frameIndex : MAX(reference->frameIndex, (s32)anm2Item->frames.size());
anm2Item->frames.insert(anm2Item->frames.begin() + insertIndex, frameWithReference->frame);
anm2_animation_length_set(animation);
break;
}
case CLIPBOARD_ANIMATION:
{
s32 index = 0;
if (std::holds_alternative<s32>(*location))
index = std::get<s32>(*location);
index = CLAMP(index, 0, (s32)anm2->animations.size());
map_insert_shift(anm2->animations, index, std::get<Anm2AnimationWithID>(self->data).animation);
break;
}
case CLIPBOARD_EVENT:
{
s32 index = 0;
if (std::holds_alternative<s32>(*location))
index = std::get<s32>(*location);
index = CLAMP(index, 0, (s32)anm2->events.size());
map_insert_shift(anm2->events, index, std::get<Anm2EventWithID>(self->data).event);
break;
}
default:
break;
}
}
void clipboard_copy(Clipboard* self)
{
self->item = self->hoveredItem;
}
void clipboard_cut(Clipboard* self)
{
self->item = self->hoveredItem;
_clipboard_item_remove(&self->item, self->anm2);
}
void clipboard_paste(Clipboard* self)
{
_clipboard_item_paste(&self->item, &self->location, self->anm2);
}
void clipboard_init(Clipboard* self, Anm2* anm2)
{
self->anm2 = anm2;
}

44
src/clipboard.h Normal file
View File

@@ -0,0 +1,44 @@
#pragma once
#include "anm2.h"
enum ClipboardItemType
{
CLIPBOARD_NONE,
CLIPBOARD_FRAME,
CLIPBOARD_ANIMATION,
CLIPBOARD_EVENT
};
struct ClipboardItem
{
std::variant<std::monostate, Anm2FrameWithReference, Anm2AnimationWithID, Anm2EventWithID> data = std::monostate();
ClipboardItemType type = CLIPBOARD_NONE;
ClipboardItem() = default;
ClipboardItem(const Anm2FrameWithReference& frame)
: data(frame), type(CLIPBOARD_FRAME) {}
ClipboardItem(const Anm2AnimationWithID& anim)
: data(anim), type(CLIPBOARD_ANIMATION) {}
ClipboardItem(const Anm2EventWithID& event)
: data(event), type(CLIPBOARD_EVENT) {}
};
using ClipboardLocation = std::variant<std::monostate, Anm2Reference, s32>;
struct Clipboard
{
Anm2* anm2 = nullptr;
ClipboardItem item;
ClipboardItem hoveredItem;
ClipboardLocation location;
};
void clipboard_copy(Clipboard* self);
void clipboard_cut(Clipboard* self);
void clipboard_paste(Clipboard* self);
void clipboard_init(Clipboard* self, Anm2* anm2);

View File

@@ -1,9 +1,10 @@
// File dialog; saving/writing to files
#include "dialog.h" #include "dialog.h"
static void _dialog_callback(void* userdata, const char* const* filelist, s32 filter); static void _dialog_callback(void* userdata, const char* const* filelist, s32 filter);
static void static void _dialog_callback(void* userdata, const char* const* filelist, s32 filter)
_dialog_callback(void* userdata, const char* const* filelist, s32 filter)
{ {
Dialog* self; Dialog* self;
@@ -11,15 +12,14 @@ _dialog_callback(void* userdata, const char* const* filelist, s32 filter)
if (filelist && filelist[0] && strlen(filelist[0]) > 0) if (filelist && filelist[0] && strlen(filelist[0]) > 0)
{ {
strncpy(self->path, filelist[0], PATH_MAX - 1); self->path = filelist[0];
self->isSelected = true; self->isSelected = true;
} }
else else
self->isSelected = false; self->isSelected = false;
} }
void void dialog_init(Dialog* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, SDL_Window* window)
dialog_init(Dialog* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, SDL_Window* window)
{ {
self->anm2 = anm2; self->anm2 = anm2;
self->reference = reference; self->reference = reference;
@@ -27,40 +27,31 @@ dialog_init(Dialog* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
self->window = window; self->window = window;
} }
/* Opens file dialog for user to pick anm2 files */ void dialog_anm2_open(Dialog* self)
void
dialog_anm2_open(Dialog* self)
{ {
SDL_ShowOpenFileDialog(_dialog_callback, self, NULL, DIALOG_FILE_FILTER_ANM2, 1, NULL, false); SDL_ShowOpenFileDialog(_dialog_callback, self, nullptr, DIALOG_FILE_FILTER_ANM2, 1, nullptr, false);
self->type = DIALOG_ANM2_OPEN; self->type = DIALOG_ANM2_OPEN;
} }
/* Opens file dialog for user to save new anm2 files */ void dialog_anm2_save(Dialog* self)
void
dialog_anm2_save(Dialog* self)
{ {
SDL_ShowSaveFileDialog(_dialog_callback, self, NULL, DIALOG_FILE_FILTER_ANM2, 1, NULL); SDL_ShowSaveFileDialog(_dialog_callback, self, nullptr, DIALOG_FILE_FILTER_ANM2, 1, nullptr);
self->type = DIALOG_ANM2_SAVE; self->type = DIALOG_ANM2_SAVE;
} }
/* Opens file dialog for user to pick png files for spritesheets */ void dialog_png_open(Dialog* self)
void
dialog_png_open(Dialog* self)
{ {
SDL_ShowOpenFileDialog(_dialog_callback, self, NULL, DIALOG_FILE_FILTER_PNG, 1, NULL, false); SDL_ShowOpenFileDialog(_dialog_callback, self, nullptr, DIALOG_FILE_FILTER_PNG, 1, nullptr, false);
self->type = DIALOG_PNG_OPEN; self->type = DIALOG_PNG_OPEN;
} }
/* Opens file dialog for user to pick png file to replace selected one */ void dialog_png_replace(Dialog* self)
void
dialog_png_replace(Dialog* self)
{ {
SDL_ShowOpenFileDialog(_dialog_callback, self, NULL, DIALOG_FILE_FILTER_PNG, 1, NULL, false); SDL_ShowOpenFileDialog(_dialog_callback, self, nullptr, DIALOG_FILE_FILTER_PNG, 1, nullptr, false);
self->type = DIALOG_PNG_REPLACE; self->type = DIALOG_PNG_REPLACE;
} }
void void dialog_tick(Dialog* self)
dialog_tick(Dialog* self)
{ {
if (self->isSelected) if (self->isSelected)
{ {
@@ -82,19 +73,19 @@ dialog_tick(Dialog* self)
case DIALOG_PNG_OPEN: case DIALOG_PNG_OPEN:
id = map_next_id_get(self->resources->textures); id = map_next_id_get(self->resources->textures);
self->anm2->spritesheets[id] = Anm2Spritesheet{}; self->anm2->spritesheets[id] = Anm2Spritesheet{};
strncpy(self->anm2->spritesheets[id].path, self->path, PATH_MAX); self->path = self->anm2->spritesheets[id].path;
anm2_spritesheet_texture_load(self->anm2, self->resources, self->path, id); resources_texture_init(self->resources, self->path, id);
break; break;
case DIALOG_PNG_REPLACE: case DIALOG_PNG_REPLACE:
strncpy(self->anm2->spritesheets[self->replaceID].path, self->path, PATH_MAX); self->anm2->spritesheets[self->replaceID].path = self->path;
anm2_spritesheet_texture_load(self->anm2, self->resources, self->path, self->replaceID); resources_texture_init(self->resources, self->path, self->replaceID);
self->replaceID = -1; self->replaceID = -1;
break; break;
default: default:
break; break;
} }
memset(self->path, '\0', PATH_MAX); self->path.clear();
self->isSelected = false; self->isSelected = false;
} }
} }

View File

@@ -4,12 +4,12 @@
#include "resources.h" #include "resources.h"
#include "window.h" #include "window.h"
static const SDL_DialogFileFilter DIALOG_FILE_FILTER_ANM2[] = const SDL_DialogFileFilter DIALOG_FILE_FILTER_ANM2[] =
{ {
{"Anm2", "anm2;xml"} {"Anm2", "anm2;xml"}
}; };
static const SDL_DialogFileFilter DIALOG_FILE_FILTER_PNG[] = const SDL_DialogFileFilter DIALOG_FILE_FILTER_PNG[] =
{ {
{"png", "png"} {"png", "png"}
}; };
@@ -20,18 +20,19 @@ enum DialogType
DIALOG_ANM2_OPEN, DIALOG_ANM2_OPEN,
DIALOG_ANM2_SAVE, DIALOG_ANM2_SAVE,
DIALOG_PNG_OPEN, DIALOG_PNG_OPEN,
DIALOG_PNG_REPLACE DIALOG_PNG_REPLACE,
DIALOG_FRAME_DIRECTORY_OPEN,
}; };
struct Dialog struct Dialog
{ {
Anm2* anm2 = NULL; Anm2* anm2 = nullptr;
Anm2Reference* reference = NULL; Anm2Reference* reference = nullptr;
Resources* resources = NULL; Resources* resources = nullptr;
SDL_Window* window = NULL; SDL_Window* window = nullptr;
s32 replaceID = -1; std::string path{};
enum DialogType type = DIALOG_NONE; s32 replaceID = ID_NONE;
char path[PATH_MAX] = ""; DialogType type = DIALOG_NONE;
bool isSelected = false; bool isSelected = false;
}; };
@@ -40,4 +41,5 @@ void dialog_anm2_open(Dialog* self);
void dialog_png_open(Dialog* self); void dialog_png_open(Dialog* self);
void dialog_png_replace(Dialog* self); void dialog_png_replace(Dialog* self);
void dialog_anm2_save(Dialog* self); void dialog_anm2_save(Dialog* self);
void dialog_frame_directory_open(Dialog* self);
void dialog_tick(Dialog* self); void dialog_tick(Dialog* self);

View File

@@ -1,16 +1,15 @@
// Handles the rendering of the spritesheet editor
#include "editor.h" #include "editor.h"
static s32 _editor_grid_set(Editor* self); static s32 _editor_grid_set(Editor* self)
static s32
_editor_grid_set(Editor* self)
{ {
std::vector<f32> vertices; std::vector<f32> vertices;
s32 verticalLineCount = (s32)(EDITOR_SIZE.x / MIN(self->settings->editorGridSizeX, EDITOR_GRID_MIN)); s32 verticalLineCount = (s32)(EDITOR_SIZE.x / MIN(self->settings->editorGridSizeX, EDITOR_GRID_MIN));
s32 horizontalLineCount = (s32)(EDITOR_SIZE.y / MIN(self->settings->editorGridSizeY, EDITOR_GRID_MIN)); s32 horizontalLineCount = (s32)(EDITOR_SIZE.y / MIN(self->settings->editorGridSizeY, EDITOR_GRID_MIN));
/* Vertical */ // Vertical
for (s32 i = 0; i <= verticalLineCount; i++) for (s32 i = 0; i <= verticalLineCount; i++)
{ {
s32 x = i * self->settings->editorGridSizeX - self->settings->editorGridOffsetX; s32 x = i * self->settings->editorGridSizeX - self->settings->editorGridOffsetX;
@@ -22,7 +21,7 @@ _editor_grid_set(Editor* self)
vertices.push_back(1.0f); vertices.push_back(1.0f);
} }
/* Horizontal */ // Horizontal
for (s32 i = 0; i <= horizontalLineCount; i++) for (s32 i = 0; i <= horizontalLineCount; i++)
{ {
s32 y = i * self->settings->editorGridSizeY - self->settings->editorGridOffsetY; s32 y = i * self->settings->editorGridSizeY - self->settings->editorGridOffsetY;
@@ -44,22 +43,21 @@ _editor_grid_set(Editor* self)
return (s32)vertices.size(); return (s32)vertices.size();
} }
void void editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, Settings* settings)
editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, Settings* settings)
{ {
self->anm2 = anm2; self->anm2 = anm2;
self->reference = reference; self->reference = reference;
self->resources = resources; self->resources = resources;
self->settings = settings; self->settings = settings;
/* Framebuffer + texture */ // Framebuffer + texture
glGenFramebuffers(1, &self->fbo); glGenFramebuffers(1, &self->fbo);
glBindFramebuffer(GL_FRAMEBUFFER, self->fbo); glBindFramebuffer(GL_FRAMEBUFFER, self->fbo);
glGenTextures(1, &self->texture); glGenTextures(1, &self->texture);
glBindTexture(GL_TEXTURE_2D, self->texture); glBindTexture(GL_TEXTURE_2D, self->texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (s32)EDITOR_SIZE.x, (s32)EDITOR_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (s32)EDITOR_SIZE.x, (s32)EDITOR_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -72,11 +70,11 @@ editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
/* Grid */ // Grid
glGenVertexArrays(1, &self->gridVAO); glGenVertexArrays(1, &self->gridVAO);
glGenBuffers(1, &self->gridVBO); glGenBuffers(1, &self->gridVBO);
/* Border */ // Border
glGenVertexArrays(1, &self->borderVAO); glGenVertexArrays(1, &self->borderVAO);
glGenBuffers(1, &self->borderVBO); glGenBuffers(1, &self->borderVBO);
@@ -88,7 +86,7 @@ editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(f32), (void*)0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(f32), (void*)0);
/* Viewing texture */ // Texture
glGenVertexArrays(1, &self->textureVAO); glGenVertexArrays(1, &self->textureVAO);
glGenBuffers(1, &self->textureVBO); glGenBuffers(1, &self->textureVBO);
glGenBuffers(1, &self->textureEBO); glGenBuffers(1, &self->textureEBO);
@@ -96,16 +94,16 @@ editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
glBindVertexArray(self->textureVAO); glBindVertexArray(self->textureVAO);
glBindBuffer(GL_ARRAY_BUFFER, self->textureVBO); glBindBuffer(GL_ARRAY_BUFFER, self->textureVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(f32) * 4 * 4, NULL, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(f32) * 4 * 4, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self->textureEBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self->textureEBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_TEXTURE_INDICES), GL_TEXTURE_INDICES, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_TEXTURE_INDICES), GL_TEXTURE_INDICES, GL_STATIC_DRAW);
/* Position */ // Position attribute
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)0);
/* UV */ // UV position attribute
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)(2 * sizeof(f32))); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)(2 * sizeof(f32)));
@@ -114,18 +112,17 @@ editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
_editor_grid_set(self); _editor_grid_set(self);
} }
void void editor_draw(Editor* self)
editor_draw(Editor* self)
{ {
GLuint shaderLine = self->resources->shaders[SHADER_LINE]; GLuint shaderLine = self->resources->shaders[SHADER_LINE];
GLuint shaderLineDotted = self->resources->shaders[SHADER_LINE_DOTTED]; GLuint shaderLineDotted = self->resources->shaders[SHADER_LINE_DOTTED];
GLuint shaderTexture = self->resources->shaders[SHADER_TEXTURE]; GLuint shaderTexture = self->resources->shaders[SHADER_TEXTURE];
f32 zoomFactor = self->settings->editorZoom / 100.0f;
/* Convert pan to pixels */ f32 zoomFactor = PERCENT_TO_UNIT(self->settings->editorZoom);
// Get normalized panning
glm::vec2 ndcPan = glm::vec2(-self->settings->editorPanX / (EDITOR_SIZE.x / 2.0f), -self->settings->editorPanY / (EDITOR_SIZE.y / 2.0f)); glm::vec2 ndcPan = glm::vec2(-self->settings->editorPanX / (EDITOR_SIZE.x / 2.0f), -self->settings->editorPanY / (EDITOR_SIZE.y / 2.0f));
/* Transformation matrix */
glm::mat4 editorTransform = glm::translate(glm::mat4(1.0f), glm::vec3(ndcPan, 0.0f)); glm::mat4 editorTransform = glm::translate(glm::mat4(1.0f), glm::vec3(ndcPan, 0.0f));
editorTransform = glm::scale(editorTransform, glm::vec3(zoomFactor, zoomFactor, 1.0f)); editorTransform = glm::scale(editorTransform, glm::vec3(zoomFactor, zoomFactor, 1.0f));
@@ -142,12 +139,10 @@ editor_draw(Editor* self)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
s32 spritesheetID = self->reference->itemType == ANM2_LAYER ? // Drawing the selected spritesheet
self->anm2->layers[self->reference->itemID].spritesheetID : -1; if (self->spritesheetID > -1)
if (spritesheetID > -1)
{ {
Texture* texture = &self->resources->textures[spritesheetID]; Texture* texture = &self->resources->textures[self->spritesheetID];
glm::mat4 spritesheetTransform = editorTransform; glm::mat4 spritesheetTransform = editorTransform;
glm::vec2 ndcScale = glm::vec2(texture->size.x, texture->size.y) / (EDITOR_SIZE * 0.5f); glm::vec2 ndcScale = glm::vec2(texture->size.x, texture->size.y) / (EDITOR_SIZE * 0.5f);
@@ -176,6 +171,7 @@ editor_draw(Editor* self)
glBindVertexArray(0); glBindVertexArray(0);
glUseProgram(0); glUseProgram(0);
// Border around the spritesheet
if (self->settings->editorIsBorder) if (self->settings->editorIsBorder)
{ {
glUseProgram(shaderLineDotted); glUseProgram(shaderLineDotted);
@@ -193,10 +189,10 @@ editor_draw(Editor* self)
Anm2Frame* frame = (Anm2Frame*)anm2_frame_from_reference(self->anm2, self->reference); Anm2Frame* frame = (Anm2Frame*)anm2_frame_from_reference(self->anm2, self->reference);
/* Draw the layer frame's crop and pivot */ // Drawing the frame's crop and pivot
if (frame) if (frame)
{ {
/* Rect */ // Crop
glm::mat4 rectTransform = editorTransform; glm::mat4 rectTransform = editorTransform;
glm::vec2 rectNDCPos = frame->crop / (EDITOR_SIZE / 2.0f); glm::vec2 rectNDCPos = frame->crop / (EDITOR_SIZE / 2.0f);
@@ -217,7 +213,7 @@ editor_draw(Editor* self)
glBindVertexArray(0); glBindVertexArray(0);
glUseProgram(0); glUseProgram(0);
/* Pivot */ // Pivot
glm::mat4 pivotTransform = editorTransform; glm::mat4 pivotTransform = editorTransform;
glm::vec2 pivotNDCPos = ((frame->crop + frame->pivot) - (EDITOR_PIVOT_SIZE / 2.0f)) / (EDITOR_SIZE / 2.0f); glm::vec2 pivotNDCPos = ((frame->crop + frame->pivot) - (EDITOR_PIVOT_SIZE / 2.0f)) / (EDITOR_SIZE / 2.0f);
glm::vec2 pivotNDCScale = EDITOR_PIVOT_SIZE / (EDITOR_SIZE / 2.0f); glm::vec2 pivotNDCScale = EDITOR_PIVOT_SIZE / (EDITOR_SIZE / 2.0f);
@@ -252,6 +248,7 @@ editor_draw(Editor* self)
} }
} }
// Grid
if (self->settings->editorIsGrid) if (self->settings->editorIsGrid)
{ {
static ivec2 previousGridSize = {-1, -1}; static ivec2 previousGridSize = {-1, -1};
@@ -292,14 +289,12 @@ editor_draw(Editor* self)
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }
void void editor_tick(Editor* self)
editor_tick(Editor* self)
{ {
self->settings->editorZoom = CLAMP(self->settings->editorZoom, EDITOR_ZOOM_MIN, EDITOR_ZOOM_MAX); self->settings->editorZoom = CLAMP(self->settings->editorZoom, EDITOR_ZOOM_MIN, EDITOR_ZOOM_MAX);
} }
void void editor_free(Editor* self)
editor_free(Editor* self)
{ {
glDeleteTextures(1, &self->texture); glDeleteTextures(1, &self->texture);
glDeleteFramebuffers(1, &self->fbo); glDeleteFramebuffers(1, &self->fbo);

View File

@@ -3,6 +3,7 @@
#include "anm2.h" #include "anm2.h"
#include "resources.h" #include "resources.h"
#include "settings.h" #include "settings.h"
#include "canvas.h"
#define EDITOR_ZOOM_MIN 1 #define EDITOR_ZOOM_MIN 1
#define EDITOR_ZOOM_MAX 1000 #define EDITOR_ZOOM_MAX 1000
@@ -12,18 +13,18 @@
#define EDITOR_GRID_OFFSET_MIN 0 #define EDITOR_GRID_OFFSET_MIN 0
#define EDITOR_GRID_OFFSET_MAX 100 #define EDITOR_GRID_OFFSET_MAX 100
static const vec2 EDITOR_SIZE = {5000, 5000}; const vec2 EDITOR_SIZE = {2000, 2000};
static const vec2 EDITOR_PIVOT_SIZE = {4, 4}; const vec2 EDITOR_PIVOT_SIZE = {4, 4};
static const vec4 EDITOR_TEXTURE_TINT = COLOR_OPAQUE; const vec4 EDITOR_TEXTURE_TINT = COLOR_OPAQUE;
static const vec4 EDITOR_BORDER_TINT = COLOR_OPAQUE; const vec4 EDITOR_BORDER_TINT = COLOR_OPAQUE;
static const vec4 EDITOR_FRAME_TINT = COLOR_RED; const vec4 EDITOR_FRAME_TINT = COLOR_RED;
struct Editor struct Editor
{ {
Anm2* anm2 = NULL; Anm2* anm2 = nullptr;
Anm2Reference* reference = NULL; Anm2Reference* reference = nullptr;
Resources* resources = NULL; Resources* resources = nullptr;
Settings* settings = NULL; Settings* settings = nullptr;
GLuint fbo; GLuint fbo;
GLuint rbo; GLuint rbo;
GLuint gridVAO; GLuint gridVAO;
@@ -34,6 +35,7 @@ struct Editor
GLuint textureVBO; GLuint textureVBO;
GLuint borderVAO; GLuint borderVAO;
GLuint borderVBO; GLuint borderVBO;
s32 spritesheetID = -1;
}; };
void editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, Settings* settings); void editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, Settings* settings);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,85 +0,0 @@
#include "input.h"
static void _mouse_tick(Mouse* self);
static void
_mouse_tick(Mouse* self)
{
s32 state;
memcpy(&self->previous, &self->current, sizeof(bool) * MOUSE_COUNT);
memset(&self->current, '\0', sizeof(bool) * MOUSE_COUNT);
state = SDL_GetMouseState(NULL, NULL);
if (state & SDL_BUTTON_LMASK != 0)
{
self->current[MOUSE_LEFT] = true;
}
if (state & SDL_BUTTON_RMASK != 0)
{
self->current[MOUSE_RIGHT] = true;
}
SDL_GetMouseState(&self->position.x, &self->position.y);
self->delta = self->position - self->oldPosition;
self->oldPosition = self->position;
}
static void
_keyboard_tick(Keyboard* self)
{
const bool* state;
memcpy(&self->previous, &self->current, sizeof(self->previous));
memset(&self->current, '\0', sizeof(self->current));
state = SDL_GetKeyboardState(NULL);
memcpy(&self->current, state, KEY_COUNT);
}
bool
mouse_press(Mouse* self, MouseType type)
{
return (self->current[type] && !self->previous[type]);
}
bool
mouse_held(Mouse* self, MouseType type)
{
return (self->current[type] && self->previous[type]);
}
bool
mouse_release(Mouse* self, MouseType type)
{
return (!self->current[type] && self->previous[type]);
}
bool
key_press(Keyboard* self, KeyType type)
{
return (self->current[type] && !self->previous[type]);
}
bool
key_held(Keyboard* self, KeyType type)
{
return (self->current[type] && self->previous[type]);
}
bool
key_release(Keyboard* self, KeyType type)
{
return (!self->current[type] && self->previous[type]);
}
void
input_tick(Input* self)
{
_mouse_tick(&self->mouse);
_keyboard_tick(&self->keyboard);
}

View File

@@ -1,301 +0,0 @@
#pragma once
#include "COMMON.h"
#define MOUSE_COUNT (MOUSE_RIGHT + 1)
enum MouseType
{
MOUSE_LEFT,
MOUSE_RIGHT
};
#define KEY_COUNT (255)
enum KeyType
{
KEY_UNKNOWN = 0,
KEY_UNKNOWN_TWO = 1,
KEY_UNKNOWN_THREE = 2,
KEY_UNKNOWN_FOUR = 3,
KEY_A = 4,
KEY_B = 5,
KEY_C = 6,
KEY_D = 7,
KEY_E = 8,
KEY_F = 9,
KEY_G = 10,
KEY_H = 11,
KEY_I = 12,
KEY_J = 13,
KEY_K = 14,
KEY_L = 15,
KEY_M = 16,
KEY_N = 17,
KEY_O = 18,
KEY_P = 19,
KEY_Q = 20,
KEY_R = 21,
KEY_S = 22,
KEY_T = 23,
KEY_U = 24,
KEY_V = 25,
KEY_W = 26,
KEY_X = 27,
KEY_Y = 28,
KEY_Z = 29,
KEY_1 = 30,
KEY_2 = 31,
KEY_3 = 32,
KEY_4 = 33,
KEY_5 = 34,
KEY_6 = 35,
KEY_7 = 36,
KEY_8 = 37,
KEY_9 = 38,
KEY_0 = 39,
KEY_RETURN = 40,
KEY_ESCAPE = 41,
KEY_BACKSPACE = 42,
KEY_TAB = 43,
KEY_SPACE = 44,
KEY_MINUS = 45,
KEY_EQUALS = 46,
KEY_LEFTBRACKET = 47,
KEY_RIGHTBRACKET = 48,
KEY_BACKSLASH = 49,
KEY_NONUSHASH = 50,
KEY_SEMICOLON = 51,
KEY_APOSTROPHE = 52,
KEY_GRAVE = 53,
KEY_COMMA = 54,
KEY_PERIOD = 55,
KEY_SLASH = 56,
KEY_CAPSLOCK = 57,
KEY_F1 = 58,
KEY_F2 = 59,
KEY_F3 = 60,
KEY_F4 = 61,
KEY_F5 = 62,
KEY_F6 = 63,
KEY_F7 = 64,
KEY_F8 = 65,
KEY_F9 = 66,
KEY_F10 = 67,
KEY_F11 = 68,
KEY_F12 = 69,
KEY_PRINTSCREEN = 70,
KEY_SCROLLLOCK = 71,
KEY_PAUSE = 72,
KEY_INSERT = 73,
KEY_HOME = 74,
KEY_PAGEUP = 75,
KEY_DELETE = 76,
KEY_END = 77,
KEY_PAGEDOWN = 78,
KEY_RIGHT = 79,
KEY_LEFT = 80,
KEY_DOWN = 81,
KEY_UP = 82,
KEY_NUMLOCKCLEAR = 83,
KEY_KP_DIVIDE = 84,
KEY_KP_MULTIPLY = 85,
KEY_KP_MINUS = 86,
KEY_KP_PLUS = 87,
KEY_KP_ENTER = 88,
KEY_KP_1 = 89,
KEY_KP_2 = 90,
KEY_KP_3 = 91,
KEY_KP_4 = 92,
KEY_KP_5 = 93,
KEY_KP_6 = 94,
KEY_KP_7 = 95,
KEY_KP_8 = 96,
KEY_KP_9 = 97,
KEY_KP_0 = 98,
KEY_KP_PERIOD = 99,
KEY_NONUSBACKSLASH = 100,
KEY_APPLICATION = 101,
KEY_POWER = 102,
KEY_KP_EQUALS = 103,
KEY_F13 = 104,
KEY_F14 = 105,
KEY_F15 = 106,
KEY_F16 = 107,
KEY_F17 = 108,
KEY_F18 = 109,
KEY_F19 = 110,
KEY_F20 = 111,
KEY_F21 = 112,
KEY_F22 = 113,
KEY_F23 = 114,
KEY_F24 = 115,
KEY_EXECUTE = 116,
KEY_HELP = 117,
KEY_MENU = 118,
KEY_SELECT = 119,
KEY_STOP = 120,
KEY_AGAIN = 121,
KEY_UNDO = 122,
KEY_CUT = 123,
KEY_COPY = 124,
KEY_PASTE = 125,
KEY_FIND = 126,
KEY_MUTE = 127,
KEY_VOLUMEUP = 128,
KEY_VOLUMEDOWN = 129,
KEY_LOCKINGCAPSLOCK = 130,
KEY_LOCKINGNUMLOCK = 131,
KEY_LOCKINGSCROLLLOCK = 132,
KEY_KP_COMMA = 133,
KEY_KP_EQUALSAS400 = 134,
KEY_INTERNATIONAL1 = 135,
KEY_INTERNATIONAL2 = 136,
KEY_INTERNATIONAL3 = 137,
KEY_INTERNATIONAL4 = 138,
KEY_INTERNATIONAL5 = 139,
KEY_INTERNATIONAL6 = 140,
KEY_INTERNATIONAL7 = 141,
KEY_INTERNATIONAL8 = 142,
KEY_INTERNATIONAL9 = 143,
KEY_LANG1 = 144,
KEY_LANG2 = 145,
KEY_LANG3 = 146,
KEY_LANG4 = 147,
KEY_LANG5 = 148,
KEY_LANG6 = 149,
KEY_LANG7 = 150,
KEY_LANG8 = 151,
KEY_LANG9 = 152,
KEY_ALTERASE = 153,
KEY_SYSREQ = 154,
KEY_CANCEL = 155,
KEY_CLEAR = 156,
KEY_PRIOR = 157,
KEY_RETURN2 = 158,
KEY_SEPARATOR = 159,
KEY_OUT = 160,
KEY_OPER = 161,
KEY_CLEARAGAIN = 162,
KEY_CRSEL = 163,
KEY_EXSEL = 164,
KEY_KP_00 = 176,
KEY_KP_000 = 177,
KEY_THOUSANDSSEPARATOR = 178,
KEY_DECIMALSEPARATOR = 179,
KEY_CURRENCYUNIT = 180,
KEY_CURRENCYSUBUNIT = 181,
KEY_KP_LEFTPAREN = 182,
KEY_KP_RIGHTPAREN = 183,
KEY_KP_LEFTBRACE = 184,
KEY_KP_RIGHTBRACE = 185,
KEY_KP_TAB = 186,
KEY_KP_BACKSPACE = 187,
KEY_KP_A = 188,
KEY_KP_B = 189,
KEY_KP_C = 190,
KEY_KP_D = 191,
KEY_KP_E = 192,
KEY_KP_F = 193,
KEY_KP_XOR = 194,
KEY_KP_POWER = 195,
KEY_KP_PERCENT = 196,
KEY_KP_LESS = 197,
KEY_KP_GREATER = 198,
KEY_KP_AMPERSAND = 199,
KEY_KP_DBLAMPERSAND = 200,
KEY_KP_VERTICALBAR = 201,
KEY_KP_DBLVERTICALBAR = 202,
KEY_KP_COLON = 203,
KEY_KP_HASH = 204,
KEY_KP_SPACE = 205,
KEY_KP_AT = 206,
KEY_KP_EXCLAM = 207,
KEY_KP_MEMSTORE = 208,
KEY_KP_MEMRECALL = 209,
KEY_KP_MEMCLEAR = 210,
KEY_KP_MEMADD = 211,
KEY_KP_MEMSUBTRACT = 212,
KEY_KP_MEMMULTIPLY = 213,
KEY_KP_MEMDIVIDE = 214,
KEY_KP_PLUSMINUS = 215,
KEY_KP_CLEAR = 216,
KEY_KP_CLEARENTRY = 217,
KEY_KP_BINARY = 218,
KEY_KP_OCTAL = 219,
KEY_KP_DECIMAL = 220,
KEY_KP_HEXADECIMAL = 221,
KEY_LCTRL = 224,
KEY_LSHIFT = 225,
KEY_LALT = 226,
KEY_LGUI = 227,
KEY_RCTRL = 228,
KEY_RSHIFT = 229,
KEY_RALT = 230,
KEY_RGUI = 231
};
#define INPUT_COUNT (INPUT_REDO + 1)
enum InputType
{
INPUT_PAN,
INPUT_MOVE,
INPUT_SCALE,
INPUT_CROP,
INPUT_LEFT,
INPUT_RIGHT,
INPUT_UP,
INPUT_DOWN,
INPUT_ROTATE_LEFT,
INPUT_ROTATE_RIGHT,
INPUT_ZOOM_IN,
INPUT_ZOOM_OUT,
INPUT_UNDO,
INPUT_REDO
};
static const KeyType INPUT_KEYS[INPUT_COUNT]
{
KEY_SPACE,
KEY_T,
KEY_S,
KEY_C,
KEY_LEFT,
KEY_RIGHT,
KEY_UP,
KEY_DOWN,
KEY_Q,
KEY_W,
KEY_1,
KEY_2,
KEY_Z,
KEY_Y
};
struct Keyboard
{
bool current[KEY_COUNT];
bool previous[KEY_COUNT];
};
struct Mouse
{
bool current[MOUSE_COUNT];
bool previous[MOUSE_COUNT];
vec2 position = {-1, -1};
vec2 oldPosition = {-1, -1};
vec2 delta = {-1, -1};
s32 wheelDeltaY = 0;
};
struct Input
{
Mouse mouse;
Keyboard keyboard;
};
bool mouse_press(Mouse* self, MouseType type);
bool mouse_held(Mouse* self, MouseType type);
bool mouse_release(Mouse* self, MouseType type);
bool key_press(Keyboard* self, KeyType type);
bool key_held(Keyboard* self, KeyType type);
bool key_release(Keyboard* self, KeyType type);
void input_tick(Input* self);

View File

@@ -1,3 +1,5 @@
// Main function
#include "main.h" #include "main.h"
s32 s32
@@ -5,12 +7,8 @@ main(s32 argc, char* argv[])
{ {
State state; State state;
/* If anm2 given on command line, set state argument to that (will be loaded) */
if (argc > 0 && argv[1]) if (argc > 0 && argv[1])
{ state.argument = argv[1];
strncpy(state.argument, argv[1], PATH_MAX - 1);
state.isArgument = true;
}
init(&state); init(&state);

View File

@@ -1,14 +1,12 @@
// Handles the rendering of the animation preview
#include "preview.h" #include "preview.h"
static void _preview_axis_set(Preview* self); static void _preview_axis_set(Preview* self)
static s32 _preview_grid_set(Preview* self);
static void
_preview_axis_set(Preview* self)
{ {
glBindVertexArray(self->axisVAO); glBindVertexArray(self->axisVAO);
glBindBuffer(GL_ARRAY_BUFFER, self->axisVBO); glBindBuffer(GL_ARRAY_BUFFER, self->axisVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(PREVIEW_AXIS_VERTICES), PREVIEW_AXIS_VERTICES, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(CANVAS_AXIS_VERTICES), CANVAS_AXIS_VERTICES, GL_STATIC_DRAW);
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(f32), (void*)0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(f32), (void*)0);
@@ -16,16 +14,14 @@ _preview_axis_set(Preview* self)
glBindVertexArray(0); glBindVertexArray(0);
} }
/* Sets and returns the grid's vertices */ static s32 _preview_grid_set(Preview* self)
static s32
_preview_grid_set(Preview* self)
{ {
std::vector<f32> vertices; std::vector<f32> vertices;
s32 verticalLineCount = (s32)(PREVIEW_SIZE.x / MIN(self->settings->previewGridSizeX, PREVIEW_GRID_MIN)); s32 verticalLineCount = (s32)(PREVIEW_SIZE.x / MIN(self->settings->previewGridSizeX, PREVIEW_GRID_MIN));
s32 horizontalLineCount = (s32)(PREVIEW_SIZE.y / MIN(self->settings->previewGridSizeY, PREVIEW_GRID_MIN)); s32 horizontalLineCount = (s32)(PREVIEW_SIZE.y / MIN(self->settings->previewGridSizeY, PREVIEW_GRID_MIN));
/* Vertical */ // Vertical
for (s32 i = 0; i <= verticalLineCount; i++) for (s32 i = 0; i <= verticalLineCount; i++)
{ {
s32 x = i * self->settings->previewGridSizeX - self->settings->previewGridOffsetX; s32 x = i * self->settings->previewGridSizeX - self->settings->previewGridOffsetX;
@@ -37,7 +33,7 @@ _preview_grid_set(Preview* self)
vertices.push_back(1.0f); vertices.push_back(1.0f);
} }
/* Horizontal */ // Horizontal
for (s32 i = 0; i <= horizontalLineCount; i++) for (s32 i = 0; i <= horizontalLineCount; i++)
{ {
s32 y = i * self->settings->previewGridSizeY - self->settings->previewGridOffsetY; s32 y = i * self->settings->previewGridSizeY - self->settings->previewGridOffsetY;
@@ -59,23 +55,21 @@ _preview_grid_set(Preview* self)
return (s32)vertices.size(); return (s32)vertices.size();
} }
void void preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, Settings* settings)
preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Resources* resources, Settings* settings)
{ {
self->anm2 = anm2; self->anm2 = anm2;
self->reference = reference; self->reference = reference;
self->time = time;
self->resources = resources; self->resources = resources;
self->settings = settings; self->settings = settings;
/* Framebuffer + texture */ // Framebuffer + texture
glGenFramebuffers(1, &self->fbo); glGenFramebuffers(1, &self->fbo);
glBindFramebuffer(GL_FRAMEBUFFER, self->fbo); glBindFramebuffer(GL_FRAMEBUFFER, self->fbo);
glGenTextures(1, &self->texture); glGenTextures(1, &self->texture);
glBindTexture(GL_TEXTURE_2D, self->texture); glBindTexture(GL_TEXTURE_2D, self->texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (s32)PREVIEW_SIZE.x, (s32)PREVIEW_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (s32)PREVIEW_SIZE.x, (s32)PREVIEW_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -88,15 +82,15 @@ preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Res
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
/* Axis */ // Axis
glGenVertexArrays(1, &self->axisVAO); glGenVertexArrays(1, &self->axisVAO);
glGenBuffers(1, &self->axisVBO); glGenBuffers(1, &self->axisVBO);
/* Grid */ // Grid
glGenVertexArrays(1, &self->gridVAO); glGenVertexArrays(1, &self->gridVAO);
glGenBuffers(1, &self->gridVBO); glGenBuffers(1, &self->gridVBO);
/* Rect */ // Rect
glGenVertexArrays(1, &self->rectVAO); glGenVertexArrays(1, &self->rectVAO);
glGenBuffers(1, &self->rectVBO); glGenBuffers(1, &self->rectVBO);
@@ -108,7 +102,7 @@ preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Res
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(f32), (void*)0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(f32), (void*)0);
/* Texture */ // Texture
glGenVertexArrays(1, &self->textureVAO); glGenVertexArrays(1, &self->textureVAO);
glGenBuffers(1, &self->textureVBO); glGenBuffers(1, &self->textureVBO);
glGenBuffers(1, &self->textureEBO); glGenBuffers(1, &self->textureEBO);
@@ -116,16 +110,16 @@ preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Res
glBindVertexArray(self->textureVAO); glBindVertexArray(self->textureVAO);
glBindBuffer(GL_ARRAY_BUFFER, self->textureVBO); glBindBuffer(GL_ARRAY_BUFFER, self->textureVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(f32) * 4 * 4, NULL, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(f32) * 4 * 4, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self->textureEBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self->textureEBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_TEXTURE_INDICES), GL_TEXTURE_INDICES, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_TEXTURE_INDICES), GL_TEXTURE_INDICES, GL_STATIC_DRAW);
/* Position */ // Position attribute
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)0);
/* UV */ // UV attribute
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)(2 * sizeof(f32))); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(f32), (void*)(2 * sizeof(f32)));
@@ -135,35 +129,36 @@ preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Res
_preview_grid_set(self); _preview_grid_set(self);
} }
void void preview_tick(Preview* self)
preview_tick(Preview* self)
{ {
self->settings->previewZoom = CLAMP(self->settings->previewZoom, PREVIEW_ZOOM_MIN, PREVIEW_ZOOM_MAX); self->settings->previewZoom = CLAMP(self->settings->previewZoom, PREVIEW_ZOOM_MIN, PREVIEW_ZOOM_MAX);
Anm2Animation* animation = anm2_animation_from_reference(self->anm2, self->reference); Anm2Animation* animation = anm2_animation_from_reference(self->anm2, self->reference);
// If animation is valid, manage playback
if (animation) if (animation)
{ {
if (self->isPlaying) if (self->isPlaying)
{ {
*self->time += (f32)self->anm2->fps / TICK_RATE; self->time += (f32)self->anm2->fps / TICK_RATE;
if (*self->time >= (f32)animation->frameNum - 1) // If looping, return back to 0; if not, stop at length
if (self->time >= (f32)animation->frameNum - 1)
{ {
if (self->settings->playbackIsLoop && !self->isRecording) if (self->settings->playbackIsLoop && !self->isRecording)
*self->time = 0.0f; self->time = 0.0f;
else else
self->isPlaying = false; self->isPlaying = false;
} }
} }
// Make sure to clamp time within appropriate range
if (!self->isPlaying) if (!self->isPlaying)
*self->time = CLAMP(*self->time, 0.0f, (f32)animation->frameNum - 1); self->time = CLAMP(self->time, 0.0f, (f32)animation->frameNum - 1);
} }
} }
void void preview_draw(Preview* self)
preview_draw(Preview* self)
{ {
GLuint shaderLine = self->resources->shaders[SHADER_LINE]; GLuint shaderLine = self->resources->shaders[SHADER_LINE];
GLuint shaderTexture = self->resources->shaders[SHADER_TEXTURE]; GLuint shaderTexture = self->resources->shaders[SHADER_TEXTURE];
@@ -171,7 +166,7 @@ preview_draw(Preview* self)
static f32 recordFrameTimeNext = 0.0f; static f32 recordFrameTimeNext = 0.0f;
static s32 recordFrameIndex = 0; static s32 recordFrameIndex = 0;
f32 zoomFactor = self->settings->previewZoom / 100.0f; f32 zoomFactor = PERCENT_TO_UNIT(self->settings->previewZoom);
glm::vec2 ndcPan = glm::vec2(-self->settings->previewPanX / (PREVIEW_SIZE.x / 2.0f), -self->settings->previewPanY / (PREVIEW_SIZE.y / 2.0f)); glm::vec2 ndcPan = glm::vec2(-self->settings->previewPanX / (PREVIEW_SIZE.x / 2.0f), -self->settings->previewPanY / (PREVIEW_SIZE.y / 2.0f));
glm::mat4 previewTransform = glm::translate(glm::mat4(1.0f), glm::vec3(ndcPan, 0.0f)); glm::mat4 previewTransform = glm::translate(glm::mat4(1.0f), glm::vec3(ndcPan, 0.0f));
previewTransform = glm::scale(previewTransform, glm::vec3(zoomFactor, zoomFactor, 1.0f)); previewTransform = glm::scale(previewTransform, glm::vec3(zoomFactor, zoomFactor, 1.0f));
@@ -188,7 +183,7 @@ preview_draw(Preview* self)
); );
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
/* Grid */ // Grid
if (self->settings->previewIsGrid) if (self->settings->previewIsGrid)
{ {
static ivec2 previousGridSize = {-1, -1}; static ivec2 previousGridSize = {-1, -1};
@@ -220,7 +215,7 @@ preview_draw(Preview* self)
glUseProgram(0); glUseProgram(0);
} }
/* Axes */ // Axes
if (self->settings->previewIsAxis) if (self->settings->previewIsAxis)
{ {
glUseProgram(shaderLine); glUseProgram(shaderLine);
@@ -249,21 +244,24 @@ preview_draw(Preview* self)
} }
Anm2Animation* animation = anm2_animation_from_reference(self->anm2, self->reference); Anm2Animation* animation = anm2_animation_from_reference(self->anm2, self->reference);
s32& animationID = self->reference->animationID;
/* Animation */
// Animation
if (animation) if (animation)
{ {
Anm2Frame rootFrame; Anm2Frame rootFrame;
Anm2Frame frame; Anm2Frame frame;
anm2_frame_from_time(self->anm2, &rootFrame, Anm2Reference{ANM2_ROOT, self->reference->animationID, 0, 0}, *self->time); anm2_frame_from_time(self->anm2, &rootFrame, Anm2Reference{animationID, ANM2_ROOT, 0, 0}, self->time);
/* Layers */ // Layers
for (auto & [id, layerAnimation] : animation->layerAnimations) for (auto [i, id] : self->anm2->layerMap)
{ {
Anm2Item& layerAnimation = animation->layerAnimations[id];
if (!layerAnimation.isVisible || layerAnimation.frames.size() <= 0) if (!layerAnimation.isVisible || layerAnimation.frames.size() <= 0)
continue; continue;
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{ANM2_LAYER, self->reference->animationID, id, 0}, *self->time); anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_LAYER, id, 0}, self->time);
if (!frame.isVisible) if (!frame.isVisible)
continue; continue;
@@ -275,8 +273,12 @@ preview_draw(Preview* self)
glm::mat4 layerTransform = previewTransform; glm::mat4 layerTransform = previewTransform;
glm::vec2 position = self->settings->previewIsRootTransform ? (frame.position + rootFrame.position) : frame.position; glm::vec2 position = self->settings->previewIsRootTransform ?
glm::vec2 scale = frame.scale / 100.0f; (frame.position + rootFrame.position) : frame.position;
glm::vec2 scale = self->settings->previewIsRootTransform ?
PERCENT_TO_UNIT(frame.scale) * PERCENT_TO_UNIT(rootFrame.scale) : PERCENT_TO_UNIT(frame.scale);
glm::vec2 ndcPos = position / (PREVIEW_SIZE / 2.0f); glm::vec2 ndcPos = position / (PREVIEW_SIZE / 2.0f);
glm::vec2 ndcPivotOffset = (frame.pivot * scale) / (PREVIEW_SIZE / 2.0f); glm::vec2 ndcPivotOffset = (frame.pivot * scale) / (PREVIEW_SIZE / 2.0f);
glm::vec2 ndcScale = (frame.size * scale) / (PREVIEW_SIZE / 2.0f); glm::vec2 ndcScale = (frame.size * scale) / (PREVIEW_SIZE / 2.0f);
@@ -316,6 +318,7 @@ preview_draw(Preview* self)
glUseProgram(0); glUseProgram(0);
} }
// Root target
if (animation->rootAnimation.isVisible && rootFrame.isVisible) if (animation->rootAnimation.isVisible && rootFrame.isVisible)
{ {
glm::mat4 rootTransform = previewTransform; glm::mat4 rootTransform = previewTransform;
@@ -350,25 +353,29 @@ preview_draw(Preview* self)
glUseProgram(0); glUseProgram(0);
} }
/* Pivots */ // Layer pivots
if (self->settings->previewIsShowPivot) if (self->settings->previewIsShowPivot)
{ {
/* Layers (Reversed) */ // Layers (Reversed)
for (auto & [id, layerAnimation] : animation->layerAnimations) for (auto & [id, layerAnimation] : animation->layerAnimations)
{ {
if (!layerAnimation.isVisible || layerAnimation.frames.size() <= 0) if (!layerAnimation.isVisible || layerAnimation.frames.size() <= 0)
continue; continue;
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{ANM2_LAYER, self->reference->animationID, id, 0}, *self->time); anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_LAYER, id, 0}, self->time);
if (!frame.isVisible) if (!frame.isVisible)
continue; continue;
glm::mat4 pivotTransform = previewTransform; glm::mat4 pivotTransform = previewTransform;
glm::vec2 position = self->settings->previewIsRootTransform ? (frame.position + rootFrame.position) : frame.position; glm::vec2 position = self->settings->previewIsRootTransform
? (frame.position + rootFrame.position) : frame.position;
glm::vec2 ndcPos = position /(PREVIEW_SIZE / 2.0f); glm::vec2 scale = self->settings->previewIsRootTransform ?
PERCENT_TO_UNIT(frame.scale) * PERCENT_TO_UNIT(rootFrame.scale) : PERCENT_TO_UNIT(frame.scale);
glm::vec2 ndcPos = (position - (PREVIEW_PIVOT_SIZE / 2.0f)) / (PREVIEW_SIZE / 2.0f);
glm::vec2 ndcScale = PREVIEW_PIVOT_SIZE / (PREVIEW_SIZE / 2.0f); glm::vec2 ndcScale = PREVIEW_PIVOT_SIZE / (PREVIEW_SIZE / 2.0f);
pivotTransform = glm::translate(pivotTransform, glm::vec3(ndcPos, 0.0f)); pivotTransform = glm::translate(pivotTransform, glm::vec3(ndcPos, 0.0f));
@@ -400,13 +407,13 @@ preview_draw(Preview* self)
} }
} }
/* Nulls */ // Null target/rect
for (auto & [id, nullAnimation] : animation->nullAnimations) for (auto & [id, nullAnimation] : animation->nullAnimations)
{ {
if (!nullAnimation.isVisible || nullAnimation.frames.size() <= 0) if (!nullAnimation.isVisible || nullAnimation.frames.size() <= 0)
continue; continue;
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{ANM2_NULL, id, 0}, *self->time); anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_NULL, id, 0}, self->time);
if (!frame.isVisible) if (!frame.isVisible)
continue; continue;
@@ -415,7 +422,7 @@ preview_draw(Preview* self)
glm::mat4 nullTransform = previewTransform; glm::mat4 nullTransform = previewTransform;
TextureType textureType = null->isShowRect ? TEXTURE_SQUARE : TEXTURE_TARGET; TextureType textureType = null->isShowRect ? TEXTURE_UNINTERPOLATED : TEXTURE_TARGET;
glm::vec2 size = null->isShowRect ? PREVIEW_POINT_SIZE : PREVIEW_TARGET_SIZE; glm::vec2 size = null->isShowRect ? PREVIEW_POINT_SIZE : PREVIEW_TARGET_SIZE;
glm::vec2 pos = self->settings->previewIsRootTransform ? frame.position + (rootFrame.position) - (size / 2.0f) : frame.position - (size / 2.0f); glm::vec2 pos = self->settings->previewIsRootTransform ? frame.position + (rootFrame.position) - (size / 2.0f) : frame.position - (size / 2.0f);
@@ -449,6 +456,7 @@ preview_draw(Preview* self)
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0); glUseProgram(0);
// Null rect
if (null->isShowRect) if (null->isShowRect)
{ {
glm::mat4 rectTransform = previewTransform; glm::mat4 rectTransform = previewTransform;
@@ -476,6 +484,7 @@ preview_draw(Preview* self)
} }
} }
/*
if (self->isRecording && animation) if (self->isRecording && animation)
{ {
if (recordFrameIndex == 0) if (recordFrameIndex == 0)
@@ -496,18 +505,16 @@ preview_draw(Preview* self)
if (isRecordThisFrame) if (isRecordThisFrame)
{ {
size_t frameSize = (self->recordSize.x * self->recordSize.y * 4); size_t frameSize = (self->recordSize.x * self->recordSize.y * 4);
u8* frame = (u8*)malloc(frameSize); u8* frame = (u8*)calloc(frameSize, 1);
memset(frame, '\0',frameSize); std:: string path;
char path[PATH_MAX];
vec2 position = vec2 position =
{ {
self->settings->previewPanX - (PREVIEW_SIZE.x / 2.0f) + (self->recordSize.x / 2.0f), self->settings->previewPanX - (PREVIEW_SIZE.x / 2.0f) + (self->recordSize.x / 2.0f),
self->settings->previewPanY - (PREVIEW_SIZE.y / 2.0f) + (self->recordSize.y / 2.0f) self->settings->previewPanY - (PREVIEW_SIZE.y / 2.0f) + (self->recordSize.y / 2.0f)
}; };
memset(path, '\0', PATH_MAX); path = std::format(STRING_PREVIEW_FRAMES_FORMAT, STRING_PREVIEW_FRAMES_DIRECTORY, recordFrameIndex);
snprintf(path, PATH_MAX, STRING_PREVIEW_FRAMES_FORMAT, STRING_PREVIEW_FRAMES_DIRECTORY, recordFrameIndex);
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
glReadPixels glReadPixels
@@ -530,27 +537,27 @@ preview_draw(Preview* self)
} }
else else
{ {
if (*self->time >= (f32)animation->frameNum - 1) if (self->time >= (f32)animation->frameNum - 1)
{ {
self->isRecording = false; self->isRecording = false;
self->isPlaying = false; self->isPlaying = false;
recordFrameIndex = 0; recordFrameIndex = 0;
recordFrameTimeNext = 0; recordFrameTimeNext = 0;
*self->time = 0.0f; self->time = 0.0f;
} }
else if (*self->time >= recordFrameTimeNext) else if (self->time >= recordFrameTimeNext)
{ {
isRecordThisFrame = true; isRecordThisFrame = true;
recordFrameTimeNext = *self->time + (f32)self->anm2->fps / TICK_RATE; recordFrameTimeNext = self->time + (f32)self->anm2->fps / TICK_RATE;
} }
} }
} }
*/
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }
void void preview_free(Preview* self)
preview_free(Preview* self)
{ {
glDeleteTextures(1, &self->texture); glDeleteTextures(1, &self->texture);
glDeleteFramebuffers(1, &self->fbo); glDeleteFramebuffers(1, &self->fbo);

View File

@@ -2,11 +2,11 @@
#include "anm2.h" #include "anm2.h"
#include "resources.h" #include "resources.h"
#include "input.h"
#include "settings.h" #include "settings.h"
#include "canvas.h"
static const vec2 PREVIEW_SIZE = {5000, 5000}; const vec2 PREVIEW_SIZE = {2000, 2000};
static const vec2 PREVIEW_CENTER = {0, 0}; const vec2 PREVIEW_CENTER = {0, 0};
#define PREVIEW_ZOOM_MIN 1 #define PREVIEW_ZOOM_MIN 1
#define PREVIEW_ZOOM_MAX 1000 #define PREVIEW_ZOOM_MAX 1000
@@ -15,52 +15,40 @@ static const vec2 PREVIEW_CENTER = {0, 0};
#define PREVIEW_GRID_MAX 1000 #define PREVIEW_GRID_MAX 1000
#define PREVIEW_GRID_OFFSET_MIN 0 #define PREVIEW_GRID_OFFSET_MIN 0
#define PREVIEW_GRID_OFFSET_MAX 100 #define PREVIEW_GRID_OFFSET_MAX 100
#define PREVIEW_MOVE_STEP 1
#define PREVIEW_ROTATE_STEP 1
#define PREVIEW_SCALE_STEP 1
static const f32 PREVIEW_AXIS_VERTICES[] = const vec2 PREVIEW_NULL_RECT_SIZE = {100, 100};
{ const vec2 PREVIEW_POINT_SIZE = {2, 2};
-1.0f, 0.0f, const vec2 PREVIEW_PIVOT_SIZE = {4, 4};
1.0f, 0.0f, const vec4 PREVIEW_ROOT_TINT = COLOR_GREEN;
0.0f, -1.0f, const vec4 PREVIEW_NULL_TINT = COLOR_BLUE;
0.0f, 1.0f const vec4 PREVIEW_PIVOT_TINT = COLOR_RED;
}; const vec2 PREVIEW_TARGET_SIZE = {16, 16};
static const vec2 PREVIEW_NULL_RECT_SIZE = {100, 100};
static const vec2 PREVIEW_POINT_SIZE = {2, 2};
static const vec2 PREVIEW_PIVOT_SIZE = {4, 4};
static const vec4 PREVIEW_ROOT_TINT = COLOR_GREEN;
static const vec4 PREVIEW_NULL_TINT = COLOR_BLUE;
static const vec4 PREVIEW_PIVOT_TINT = COLOR_RED;
static const vec2 PREVIEW_TARGET_SIZE = {16, 16};
struct Preview struct Preview
{ {
Anm2* anm2 = NULL; Anm2* anm2 = nullptr;
Anm2Reference* reference = NULL; Anm2Reference* reference = nullptr;
f32* time = NULL; Resources* resources = nullptr;
Input* input = NULL; Settings* settings = nullptr;
Resources* resources = NULL; GLuint axisVAO = ID_NONE;
Settings* settings = NULL; GLuint axisVBO = ID_NONE;
GLuint axisVAO; GLuint fbo = ID_NONE;
GLuint axisVBO; GLuint gridVAO = ID_NONE;
GLuint fbo; GLuint gridVBO = ID_NONE;
GLuint gridVAO; GLuint rbo = ID_NONE;
GLuint gridVBO; GLuint texture = ID_NONE;
GLuint rbo; GLuint rectVAO = ID_NONE;
GLuint texture; GLuint rectVBO = ID_NONE;
GLuint rectVAO; GLuint textureEBO = ID_NONE;
GLuint rectVBO; GLuint textureVAO = ID_NONE;
GLuint textureEBO; GLuint textureVBO = ID_NONE;
GLuint textureVAO;
GLuint textureVBO;
bool isPlaying = false; bool isPlaying = false;
bool isRecording = false; bool isRecording = false;
vec2 recordSize = {0.0f, 0.0f}; vec2 recordSize{};
f32 time{};
}; };
void preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Resources* resources, Settings* settings); void preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, Settings* settings);
void preview_draw(Preview* self); void preview_draw(Preview* self);
void preview_tick(Preview* self); void preview_tick(Preview* self);
void preview_free(Preview* self); void preview_free(Preview* self);

View File

@@ -1,31 +1,39 @@
#include "resources.h" #include "resources.h"
/* Loads in resources */ void resources_texture_init(Resources* resources, const std::string& path, s32 id)
void {
resources_init(Resources* self) Texture texture;
if (resources->textures.find(id) != resources->textures.end() && resources->textures[id].id != resources->textures[TEXTURE_NONE].id)
texture_free(&resources->textures[id]);
if (!texture_from_path_init(&texture, path))
texture.isInvalid = true;
resources->textures[id] = texture;
}
void resources_init(Resources* self)
{ {
texture_from_data_init(&self->atlas, (u8*)TEXTURE_ATLAS, TEXTURE_ATLAS_LENGTH); texture_from_data_init(&self->atlas, (u8*)TEXTURE_ATLAS, TEXTURE_ATLAS_LENGTH);
for (s32 i = 0; i < SHADER_COUNT; i++) for (s32 i = 0; i < SHADER_COUNT; i++)
shader_init(&self->shaders[i], SHADER_DATA[i].vertex, SHADER_DATA[i].fragment); shader_init(&self->shaders[i], SHADER_DATA[i].vertex, SHADER_DATA[i].fragment);
} }
/* Frees resources*/ void resources_free(Resources* self)
void
resources_free(Resources* self)
{ {
resources_textures_free(self); resources_textures_free(self);
for (s32 i = 0; i < SHADER_COUNT; i++) for (s32 i = 0; i < SHADER_COUNT; i++)
shader_free(&self->shaders[i]); shader_free(&self->shaders[i]);
texture_free(&self->atlas); texture_free(&self->atlas);
} }
/* Frees loaded textures */ void resources_textures_free(Resources* self)
void
resources_textures_free(Resources* self)
{ {
for (auto & [id, texture] : self->textures) for (auto & [id, texture] : self->textures)
texture_free(&self->textures[id]); texture_free(&self->textures[id]);
log_info(RESOURCES_TEXTURES_FREE_INFO);
} }

View File

@@ -4,6 +4,8 @@
#include "texture.h" #include "texture.h"
#include "shader.h" #include "shader.h"
#define RESOURCES_TEXTURES_FREE_INFO "Freed texture resources"
struct Resources struct Resources
{ {
GLuint shaders[SHADER_COUNT]; GLuint shaders[SHADER_COUNT];
@@ -12,5 +14,6 @@ struct Resources
}; };
void resources_init(Resources* self); void resources_init(Resources* self);
void resources_texture_init(Resources* resources, const std::string& path, s32 id);
void resources_free(Resources* self); void resources_free(Resources* self);
void resources_textures_free(Resources* self); void resources_textures_free(Resources* self);

View File

@@ -1,31 +1,30 @@
#include "settings.h" #include "settings.h"
static void _settings_setting_load(Settings* self, char* line); static void _settings_setting_load(Settings* self, const std::string& line)
static void _settings_setting_write(Settings* self, SDL_IOStream* io, SettingsItem type);
/* Load a particular settings from a line */
static void
_settings_setting_load(Settings* self, char* line)
{ {
for (int i = 0; i < SETTINGS_COUNT; i++) for (s32 i = 0; i < SETTINGS_COUNT; i++)
{ {
if (strncmp(line, SETTINGS_ENTRIES[i].value, strlen(SETTINGS_ENTRIES[i].value)) == 0) const std::string& key = SETTINGS_ENTRIES[i].key;
size_t keyLength = key.length();
if (line.compare(0, keyLength, key) == 0)
{ {
char* value = line + strlen(SETTINGS_ENTRIES[i].value); const char* value = line.c_str() + keyLength;
void* target = (u8*)self + SETTINGS_ENTRIES[i].offset; void* target = (u8*)self + SETTINGS_ENTRIES[i].offset;
switch (SETTINGS_ENTRIES[i].type) switch (SETTINGS_ENTRIES[i].type)
{ {
case SETTINGS_TYPE_INT: case SETTINGS_TYPE_INT:
*(s32*)target = std::atoi(value);
break;
case SETTINGS_TYPE_BOOL: case SETTINGS_TYPE_BOOL:
*(s32*)target = atoi(value); *(s32*)target = string_to_bool(std::string(value));
break; break;
case SETTINGS_TYPE_FLOAT: case SETTINGS_TYPE_FLOAT:
*(f32*)target = atof(value); *(f32*)target = std::atof(value);
break; break;
case SETTINGS_TYPE_STRING: case SETTINGS_TYPE_STRING:
strncpy((char*)target, value, SETTINGS_BUFFER_ITEM - 1); *(std::string*)target = std::string(value);
((char*)target)[SETTINGS_BUFFER_ITEM - 1] = '\0';
break; break;
default: default:
break; break;
@@ -35,126 +34,86 @@ _settings_setting_load(Settings* self, char* line)
} }
} }
/* Writes a particular setting to the current IO */ static void _settings_setting_write(Settings* self, std::ostream& out, SettingsEntry entry)
static void
_settings_setting_write(Settings* self, SDL_IOStream* io, SettingsItem type)
{ {
char valueBuffer[SETTINGS_BUFFER_ITEM];
SettingsEntry entry = SETTINGS_ENTRIES[type];
u8* selfPointer = (u8*)self; u8* selfPointer = (u8*)self;
std::string value;
memset(valueBuffer, '\0', sizeof(valueBuffer));
switch (entry.type) switch (entry.type)
{ {
case SETTINGS_TYPE_INT: case SETTINGS_TYPE_INT:
snprintf(valueBuffer, SETTINGS_BUFFER_ITEM, entry.format, *(s32*)(selfPointer + entry.offset)); value = std::format("{}", *(s32*)(selfPointer + entry.offset));
break; break;
case SETTINGS_TYPE_BOOL: case SETTINGS_TYPE_BOOL:
snprintf(valueBuffer, SETTINGS_BUFFER_ITEM, entry.format, *(bool*)(selfPointer + entry.offset)); value = std::format("{}", *(bool*)(selfPointer + entry.offset));
break; break;
case SETTINGS_TYPE_FLOAT: case SETTINGS_TYPE_FLOAT:
snprintf(valueBuffer, SETTINGS_BUFFER_ITEM, entry.format, *(f32*)(selfPointer + entry.offset)); value = std::format("{:.3f}", *(f32*)(selfPointer + entry.offset));
break; break;
case SETTINGS_TYPE_STRING: case SETTINGS_TYPE_STRING:
snprintf(valueBuffer, SETTINGS_BUFFER_ITEM, entry.value, entry.format, *(char*)(selfPointer + entry.offset)); value = *(std::string*)(selfPointer + entry.offset);
break; break;
default: default:
break; break;
} }
SDL_WriteIO(io, valueBuffer, strlen(valueBuffer)); out << entry.key << value << "\n";
SDL_WriteIO(io, "\n", strlen("\n"));
} }
/* Saves the program's settings to the PATH_SETTINGS file */ void settings_save(Settings* self)
void
settings_save(Settings* self)
{ {
char buffer[SETTINGS_BUFFER]; std::ifstream input(SETTINGS_PATH);
std::string oldContents;
/* Get the original settings.ini buffer (as previously saved by imgui before this is called) */ if (!input)
memset(buffer, '\0', SETTINGS_BUFFER);
SDL_IOStream* io = SDL_IOFromFile(PATH_SETTINGS, "r");
if (!io)
{
printf(STRING_ERROR_SETTINGS_INIT, PATH_SETTINGS);
return;
}
SDL_ReadIO(io, buffer, SETTINGS_BUFFER);
SDL_CloseIO(io);
io = SDL_IOFromFile(PATH_SETTINGS, "w");
if (!io)
{ {
printf(STRING_ERROR_SETTINGS_INIT, PATH_SETTINGS); log_error(std::format(SETTINGS_INIT_ERROR, SETTINGS_PATH));
return; return;
} }
/* [Settings] */ oldContents.assign((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
SDL_WriteIO(io, SETTINGS_SECTION, strlen(SETTINGS_SECTION)); input.close();
SDL_WriteIO(io, "\n", strlen("\n"));
std::ofstream output(SETTINGS_PATH);
if (!output)
{
log_error(std::format(SETTINGS_INIT_ERROR, SETTINGS_PATH));
return;
}
output << SETTINGS_SECTION << "\n";
/* Write down all elements */
for (s32 i = 0; i < SETTINGS_COUNT; i++) for (s32 i = 0; i < SETTINGS_COUNT; i++)
_settings_setting_write(self, io, (SettingsItem)i); _settings_setting_write(self, output, SETTINGS_ENTRIES[i]);
SDL_WriteIO(io, "\n", strlen("\n")); output << "\n" << SETTINGS_SECTION_IMGUI << "\n";
output << oldContents;
/* specify that the other settings are imgui */ output.close();
SDL_WriteIO(io, SETTINGS_SECTION_IMGUI, strlen(SETTINGS_SECTION_IMGUI));
SDL_WriteIO(io, "\n", strlen("\n"));
/* Then write original contents */
SDL_WriteIO(io, buffer, strlen(buffer));
SDL_CloseIO(io);
} }
/* Loads the settings from the PATH_SETTINGS file */ void settings_init(Settings* self)
void
settings_load(Settings* self)
{ {
char buffer[SETTINGS_BUFFER]; std::ifstream file(SETTINGS_PATH);
char* line = NULL;
if (!file)
memset(buffer, '\0', SETTINGS_BUFFER);
SDL_IOStream* io = SDL_IOFromFile(PATH_SETTINGS, "r");
if (!io)
{
printf(STRING_ERROR_SETTINGS_INIT, PATH_SETTINGS);
return;
}
size_t bytesRead = SDL_ReadIO(io, buffer, SETTINGS_BUFFER);
SDL_CloseIO(io);
buffer[bytesRead] = '\0';
line = strtok(buffer, "\n");
/* The settings will be the first section in the file */
/* Go through its elements, load them to settings, and go on with your day */
while (line != NULL)
{ {
if (strcmp(line, SETTINGS_SECTION) == 0) log_error(std::format(SETTINGS_INIT_ERROR, SETTINGS_PATH));
return;
}
std::string line;
bool inSettingsSection = false;
while (std::getline(file, line))
{
if (line == SETTINGS_SECTION)
{ {
line = strtok(NULL, "\n"); inSettingsSection = true;
continue; continue;
} }
_settings_setting_load(self, line);
/* get out here */ if (line == SETTINGS_SECTION_IMGUI) break;
if (strcmp(line, SETTINGS_SECTION_IMGUI) == 0) if (inSettingsSection) _settings_setting_load(self, line);
break;
line = strtok(NULL, "\n");
} }
} }

View File

@@ -6,6 +6,8 @@
#define SETTINGS_BUFFER_ITEM 0xFF #define SETTINGS_BUFFER_ITEM 0xFF
#define SETTINGS_SECTION "[Settings]" #define SETTINGS_SECTION "[Settings]"
#define SETTINGS_SECTION_IMGUI "# Dear ImGui" #define SETTINGS_SECTION_IMGUI "# Dear ImGui"
#define SETTINGS_INIT_ERROR "Failed to read settings file! ({})"
#define SETTINGS_PATH "settings.ini"
enum SettingsValueType enum SettingsValueType
{ {
@@ -17,61 +19,11 @@ enum SettingsValueType
struct SettingsEntry struct SettingsEntry
{ {
const char* value; std::string key;
const char* format;
SettingsValueType type; SettingsValueType type;
s32 offset; s32 offset;
}; };
#define SETTINGS_COUNT (SETTINGS_EDITOR_BACKGROUND_COLOR_A + 1)
enum SettingsItem
{
SETTINGS_WINDOW_W,
SETTINGS_WINDOW_H,
SETTINGS_PLAYBACK_IS_LOOP,
SETTINGS_PREVIEW_IS_AXIS,
SETTINGS_PREVIEW_IS_GRID,
SETTINGS_PREVIEW_IS_ROOT_TRANSFORM,
SETTINGS_PREVIEW_IS_SHOW_PIVOT,
SETTINGS_PREVIEW_PAN_X,
SETTINGS_PREVIEW_PAN_Y,
SETTINGS_PREVIEW_ZOOM,
SETTINGS_PREVIEW_GRID_SIZE_X,
SETTINGS_PREVIEW_GRID_SIZE_Y,
SETTINGS_PREVIEW_GRID_OFFSET_X,
SETTINGS_PREVIEW_GRID_OFFSET_Y,
SETTINGS_PREVIEW_GRID_COLOR_R,
SETTINGS_PREVIEW_GRID_COLOR_G,
SETTINGS_PREVIEW_GRID_COLOR_B,
SETTINGS_PREVIEW_GRID_COLOR_A,
SETTINGS_PREVIEW_AXIS_COLOR_R,
SETTINGS_PREVIEW_AXIS_COLOR_G,
SETTINGS_PREVIEW_AXIS_COLOR_B,
SETTINGS_PREVIEW_AXIS_COLOR_A,
SETTINGS_PREVIEW_BACKGROUND_COLOR_R,
SETTINGS_PREVIEW_BACKGROUND_COLOR_G,
SETTINGS_PREVIEW_BACKGROUND_COLOR_B,
SETTINGS_PREVIEW_BACKGROUND_COLOR_A,
SETTINGS_EDITOR_IS_GRID,
SETTINGS_EDITOR_IS_GRID_SNAP,
SETTINGS_EDITOR_IS_BORDER,
SETTINGS_EDITOR_PAN_X,
SETTINGS_EDITOR_PAN_Y,
SETTINGS_EDITOR_ZOOM,
SETTINGS_EDITOR_GRID_SIZE_X,
SETTINGS_EDITOR_GRID_SIZE_Y,
SETTINGS_EDITOR_GRID_OFFSET_X,
SETTINGS_EDITOR_GRID_OFFSET_Y,
SETTINGS_EDITOR_GRID_COLOR_R,
SETTINGS_EDITOR_GRID_COLOR_G,
SETTINGS_EDITOR_GRID_COLOR_B,
SETTINGS_EDITOR_GRID_COLOR_A,
SETTINGS_EDITOR_BACKGROUND_COLOR_R,
SETTINGS_EDITOR_BACKGROUND_COLOR_G,
SETTINGS_EDITOR_BACKGROUND_COLOR_B,
SETTINGS_EDITOR_BACKGROUND_COLOR_A,
};
struct Settings struct Settings
{ {
s32 windowW = 1920; s32 windowW = 1920;
@@ -118,55 +70,64 @@ struct Settings
f32 editorBackgroundColorG = 0.184f; f32 editorBackgroundColorG = 0.184f;
f32 editorBackgroundColorB = 0.286f; f32 editorBackgroundColorB = 0.286f;
f32 editorBackgroundColorA = 1.0f; f32 editorBackgroundColorA = 1.0f;
f32 toolColorR = 1.0f;
f32 toolColorG = 1.0f;
f32 toolColorB = 1.0f;
f32 toolColorA = 1.0f;
}; };
static const SettingsEntry SETTINGS_ENTRIES[SETTINGS_COUNT] = const SettingsEntry SETTINGS_ENTRIES[] =
{ {
{"windowW=", "windowW=%i", SETTINGS_TYPE_INT, offsetof(Settings, windowW)}, {"windowW=", SETTINGS_TYPE_INT, offsetof(Settings, windowW)},
{"windowH=", "windowH=%i", SETTINGS_TYPE_INT, offsetof(Settings, windowH)}, {"windowH=", SETTINGS_TYPE_INT, offsetof(Settings, windowH)},
{"playbackIsLoop=", "playbackIsLoop=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, playbackIsLoop)}, {"playbackIsLoop=", SETTINGS_TYPE_BOOL, offsetof(Settings, playbackIsLoop)},
{"previewIsAxis=", "previewIsAxis=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsAxis)}, {"previewIsAxis=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsAxis)},
{"previewIsGrid=", "previewIsGrid=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsGrid)}, {"previewIsGrid=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsGrid)},
{"previewIsRootTransform=", "previewIsRootTransform=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsRootTransform)}, {"previewIsRootTransform=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsRootTransform)},
{"previewIsShowPivot=", "previewIsShowPivot=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsShowPivot)}, {"previewIsShowPivot=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsShowPivot)},
{"previewPanX=", "previewPanX=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewPanX)}, {"previewPanX=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewPanX)},
{"previewPanY=", "previewPanY=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewPanY)}, {"previewPanY=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewPanY)},
{"previewZoom=", "previewZoom=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewZoom)}, {"previewZoom=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewZoom)},
{"previewGridSizeX=", "previewGridSizeX=%i", SETTINGS_TYPE_INT, offsetof(Settings, previewGridSizeX)}, {"previewGridSizeX=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridSizeX)},
{"previewGridSizeY=", "previewGridSizeY=%i", SETTINGS_TYPE_INT, offsetof(Settings, previewGridSizeY)}, {"previewGridSizeY=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridSizeY)},
{"previewGridOffsetX=", "previewGridOffsetX=%i", SETTINGS_TYPE_INT, offsetof(Settings, previewGridOffsetX)}, {"previewGridOffsetX=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridOffsetX)},
{"previewGridOffsetY=", "previewGridOffsetY=%i", SETTINGS_TYPE_INT, offsetof(Settings, previewGridOffsetY)}, {"previewGridOffsetY=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridOffsetY)},
{"previewGridColorR=", "previewGridColorR=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorR)}, {"previewGridColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorR)},
{"previewGridColorG=", "previewGridColorG=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorG)}, {"previewGridColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorG)},
{"previewGridColorB=", "previewGridColorB=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorB)}, {"previewGridColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorB)},
{"previewGridColorA=", "previewGridColorA=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorA)}, {"previewGridColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorA)},
{"previewAxisColorR=", "previewAxisColorR=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorR)}, {"previewAxisColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorR)},
{"previewAxisColorG=", "previewAxisColorG=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorG)}, {"previewAxisColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorG)},
{"previewAxisColorB=", "previewAxisColorB=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorB)}, {"previewAxisColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorB)},
{"previewAxisColorA=", "previewAxisColorA=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorA)}, {"previewAxisColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorA)},
{"previewBackgroundColorR=", "previewBackgroundColorR=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorR)}, {"previewBackgroundColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorR)},
{"previewBackgroundColorG=", "previewBackgroundColorG=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorG)}, {"previewBackgroundColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorG)},
{"previewBackgroundColorB=", "previewBackgroundColorB=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorB)}, {"previewBackgroundColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorB)},
{"previewBackgroundColorA=", "previewBackgroundColorA=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorA)}, {"previewBackgroundColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorA)},
{"editorIsGrid=", "editorIsGrid=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsGrid)}, {"editorIsGrid=", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsGrid)},
{"editorIsGridSnap=", "editorIsGridSnap=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsGridSnap)}, {"editorIsGridSnap=", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsGridSnap)},
{"editorIsBorder=", "editorIsBorder=%i", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsBorder)}, {"editorIsBorder=", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsBorder)},
{"editorPanX=", "editorPanX=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorPanX)}, {"editorPanX=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorPanX)},
{"editorPanY=", "editorPanY=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorPanY)}, {"editorPanY=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorPanY)},
{"editorZoom=", "editorZoom=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorZoom)}, {"editorZoom=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorZoom)},
{"editorGridSizeX=", "editorGridSizeX=%i", SETTINGS_TYPE_INT, offsetof(Settings, editorGridSizeX)}, {"editorGridSizeX=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridSizeX)},
{"editorGridSizeY=", "editorGridSizeY=%i", SETTINGS_TYPE_INT, offsetof(Settings, editorGridSizeY)}, {"editorGridSizeY=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridSizeY)},
{"editorGridOffsetX=", "editorGridOffsetX=%i", SETTINGS_TYPE_INT, offsetof(Settings, editorGridOffsetX)}, {"editorGridOffsetX=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridOffsetX)},
{"editorGridOffsetY=", "editorGridOffsetY=%i", SETTINGS_TYPE_INT, offsetof(Settings, editorGridOffsetY)}, {"editorGridOffsetY=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridOffsetY)},
{"editorGridColorR=", "editorGridColorR=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorR)}, {"editorGridColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorR)},
{"editorGridColorG=", "editorGridColorG=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorG)}, {"editorGridColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorG)},
{"editorGridColorB=", "editorGridColorB=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorB)}, {"editorGridColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorB)},
{"editorGridColorA=", "editorGridColorA=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorA)}, {"editorGridColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorA)},
{"editorBackgroundColorR=", "editorBackgroundColorR=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorR)}, {"editorBackgroundColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorR)},
{"editorBackgroundColorG=", "editorBackgroundColorG=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorG)}, {"editorBackgroundColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorG)},
{"editorBackgroundColorB=", "editorBackgroundColorB=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorB)}, {"editorBackgroundColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorB)},
{"editorBackgroundColorA=", "editorBackgroundColorA=%f", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorA)} {"editorBackgroundColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorA)},
{"toolColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorR)},
{"toolColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorG)},
{"toolColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorB)},
{"toolColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorA)}
}; };
constexpr s32 SETTINGS_COUNT = (s32)std::size(SETTINGS_ENTRIES);
void settings_save(Settings* self); void settings_save(Settings* self);
void settings_load(Settings* self); void settings_init(Settings* self);

View File

@@ -1,32 +1,29 @@
#include "shader.h" #include "shader.h"
static bool _shader_compile(GLuint* self, const char* text); static bool _shader_compile(GLuint* self, const std::string& text)
static bool
_shader_compile(GLuint* self, const char* text)
{ {
char compileLog[SHADER_BUFFER_MAX]; std::string compileLog;
s32 isCompile; s32 isCompile;
const GLchar* source = text; const GLchar* source = text.c_str();
glShaderSource(*self, 1, &source, NULL); glShaderSource(*self, 1, &source, nullptr);
glCompileShader(*self); glCompileShader(*self);
glGetShaderiv(*self, GL_COMPILE_STATUS, &isCompile); glGetShaderiv(*self, GL_COMPILE_STATUS, &isCompile);
if (!isCompile) if (!isCompile)
{ {
glGetShaderInfoLog(*self, SHADER_BUFFER_MAX, NULL, compileLog); glGetShaderInfoLog(*self, SHADER_INFO_LOG_MAX, nullptr, &compileLog[0]);
printf(STRING_ERROR_SHADER_INIT, *self, compileLog); log_error(std::format(SHADER_INIT_ERROR, *self, compileLog));
return false; return false;
} }
return true; return true;
} }
bool // Initializes a given shader with vertex/fragment
shader_init(GLuint* self, const char* vertex, const char* fragment) bool shader_init(GLuint* self, const std::string& vertex, const std::string& fragment)
{ {
GLuint vertexHandle; GLuint vertexHandle;
GLuint fragmentHandle; GLuint fragmentHandle;
@@ -34,11 +31,7 @@ shader_init(GLuint* self, const char* vertex, const char* fragment)
vertexHandle = glCreateShader(GL_VERTEX_SHADER); vertexHandle = glCreateShader(GL_VERTEX_SHADER);
fragmentHandle = glCreateShader(GL_FRAGMENT_SHADER); fragmentHandle = glCreateShader(GL_FRAGMENT_SHADER);
if if (!_shader_compile(&vertexHandle, vertex) || !_shader_compile(&fragmentHandle, fragment))
(
!_shader_compile(&vertexHandle, vertex) ||
!_shader_compile(&fragmentHandle, fragment)
)
return false; return false;
*self = glCreateProgram(); *self = glCreateProgram();
@@ -51,13 +44,10 @@ shader_init(GLuint* self, const char* vertex, const char* fragment)
glDeleteShader(vertexHandle); glDeleteShader(vertexHandle);
glDeleteShader(fragmentHandle); glDeleteShader(fragmentHandle);
printf(STRING_INFO_SHADER_INIT, *self);
return true; return true;
} }
void void shader_free(GLuint* self)
shader_free(GLuint* self)
{ {
glDeleteProgram(*self); glDeleteProgram(*self);
} }

View File

@@ -2,7 +2,8 @@
#include "COMMON.h" #include "COMMON.h"
#define SHADER_BUFFER_MAX 2048 #define SHADER_INFO_LOG_MAX 0xFF
#define SHADER_INIT_ERROR "Failed to initialize shader {}:\n{}"
bool shader_init(GLuint* self, const char* vertex, const char* fragment); bool shader_init(GLuint* self, const std::string& vertex, const std::string& fragment);
void shader_free(GLuint* self); void shader_free(GLuint* self);

View File

@@ -1,90 +1,62 @@
#include "snapshots.h" #include "snapshots.h"
void static void _snapshot_stack_push(SnapshotStack* stack, const Snapshot* snapshot)
snapshots_undo_stack_push(Snapshots* self, Snapshot* snapshot)
{ {
if (self->undoStack.top >= SNAPSHOT_STACK_MAX) if (stack->top >= SNAPSHOT_STACK_MAX)
{ {
memmove(&self->undoStack.snapshots[0], &self->undoStack.snapshots[1], sizeof(Snapshot) * (SNAPSHOT_STACK_MAX - 1)); for (s32 i = 0; i < SNAPSHOT_STACK_MAX - 1; i++)
self->undoStack.top = SNAPSHOT_STACK_MAX - 1; stack->snapshots[i] = stack->snapshots[i + 1];
stack->top = SNAPSHOT_STACK_MAX - 1;
} }
stack->snapshots[stack->top++] = *snapshot;
self->undoStack.snapshots[self->undoStack.top++] = *snapshot;
self->redoStack.top = 0;
} }
bool static bool _snapshot_stack_pop(SnapshotStack* stack, Snapshot* snapshot)
snapshots_undo_stack_pop(Snapshots* self, Snapshot* snapshot)
{ {
if (self->undoStack.top == 0) if (stack->top == 0) return false;
return false;
*snapshot = self->undoStack.snapshots[--self->undoStack.top];
*snapshot = stack->snapshots[--stack->top];
return true; return true;
} }
void static void _snapshot_set(Snapshots* self, const Snapshot& snapshot)
snapshots_redo_stack_push(Snapshots* self, Snapshot* snapshot)
{ {
if (self->redoStack.top >= SNAPSHOT_STACK_MAX) *self->anm2 = snapshot.anm2;
{ *self->reference = snapshot.reference;
memmove(&self->redoStack.snapshots[0], &self->redoStack.snapshots[1], sizeof(Snapshot) * (SNAPSHOT_STACK_MAX - 1)); self->preview->time = snapshot.time;
self->redoStack.top = SNAPSHOT_STACK_MAX - 1;
}
self->redoStack.snapshots[self->redoStack.top++] = *snapshot;
} }
bool void snapshots_init(Snapshots* self, Anm2* anm2, Anm2Reference* reference, Preview* preview)
snapshots_redo_stack_pop(Snapshots* self, Snapshot* snapshot)
{
if (self->redoStack.top == 0)
return false;
*snapshot = self->redoStack.snapshots[--self->redoStack.top];
return true;
}
void
snapshots_init(Snapshots* self, Anm2* anm2, Anm2Reference* reference, f32* time, Input* input)
{ {
self->anm2 = anm2; self->anm2 = anm2;
self->reference = reference; self->reference = reference;
self->time = time; self->preview = preview;
self->input = input;
} }
void void snapshots_undo_stack_push(Snapshots* self, const Snapshot* snapshot)
snapshots_tick(Snapshots* self)
{ {
/* Undo */ _snapshot_stack_push(&self->undoStack, snapshot);
if (key_press(&self->input->keyboard, INPUT_KEYS[INPUT_UNDO])) self->redoStack.top = 0;
{ }
Snapshot snapshot;
if (snapshots_undo_stack_pop(self, &snapshot))
{
Snapshot current = {*self->anm2, *self->reference, *self->time};
snapshots_redo_stack_push(self, &current);
*self->anm2 = snapshot.anm2; void snapshots_undo(Snapshots* self)
*self->reference = snapshot.reference; {
*self->time = snapshot.time; Snapshot snapshot;
} if (_snapshot_stack_pop(&self->undoStack, &snapshot))
{
Snapshot current = {*self->anm2, *self->reference, self->preview->time};
_snapshot_stack_push(&self->redoStack, &current);
_snapshot_set(self, snapshot);
} }
}
/* Redo */ void snapshots_redo(Snapshots* self)
if (key_press(&self->input->keyboard, INPUT_KEYS[INPUT_REDO])) {
Snapshot snapshot;
if (_snapshot_stack_pop(&self->redoStack, &snapshot))
{ {
Snapshot snapshot; Snapshot current = {*self->anm2, *self->reference, self->preview->time};
if (snapshots_redo_stack_pop(self, &snapshot)) _snapshot_stack_push(&self->undoStack, &current);
{ _snapshot_set(self, snapshot);
Snapshot current = {*self->anm2, *self->reference, *self->time};
snapshots_undo_stack_push(self, &current);
*self->anm2 = snapshot.anm2;
*self->reference = snapshot.reference;
*self->time = snapshot.time;
}
} }
} }

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include "anm2.h" #include "anm2.h"
#include "input.h" #include "preview.h"
#define SNAPSHOT_STACK_MAX 100 #define SNAPSHOT_STACK_MAX 100
@@ -9,7 +9,7 @@ struct Snapshot
{ {
Anm2 anm2; Anm2 anm2;
Anm2Reference reference; Anm2Reference reference;
f32 time; f32 time = 0.0f;
}; };
struct SnapshotStack struct SnapshotStack
@@ -20,15 +20,14 @@ struct SnapshotStack
struct Snapshots struct Snapshots
{ {
Anm2* anm2 = NULL; Anm2* anm2 = nullptr;
Anm2Reference* reference = NULL; Preview* preview = nullptr;
f32* time = NULL; Anm2Reference* reference = nullptr;
Input* input = NULL;
SnapshotStack undoStack; SnapshotStack undoStack;
SnapshotStack redoStack; SnapshotStack redoStack;
}; };
void snapshots_undo_stack_push(Snapshots* self, Snapshot* snapshot); void snapshots_undo_stack_push(Snapshots* self, const Snapshot* snapshot);
bool snapshots_undo_stack_pop(Snapshots* self, Snapshot* snapshot); void snapshots_init(Snapshots* self, Anm2* anm2, Anm2Reference* reference, Preview* preview);
void snapshots_init(Snapshots* self, Anm2* anm2, Anm2Reference* reference, f32* time, Input* input); void snapshots_undo(Snapshots* self);
void snapshots_tick(Snapshots* self); void snapshots_redo(Snapshots* self);

View File

@@ -1,169 +1,133 @@
#include "state.h" #include "state.h"
static void _tick(State* state); static void _tick(State* self)
static void _draw(State* state);
static void
_tick(State* state)
{ {
SDL_Event event; SDL_GetWindowSize(self->window, &self->settings.windowW, &self->settings.windowH);
SDL_MouseWheelEvent* mouseWheelEvent;
state->input.mouse.wheelDeltaY = 0; editor_tick(&self->editor);
preview_tick(&self->preview);
dialog_tick(&self->dialog);
imgui_tick(&self->imgui);
while(SDL_PollEvent(&event)) if (self->imgui.isQuit) self->isRunning = false;
{
ImGui_ImplSDL3_ProcessEvent(&event);
switch (event.type)
{
case SDL_EVENT_QUIT:
state->isRunning = false;
break;
case SDL_EVENT_MOUSE_WHEEL:
mouseWheelEvent = &event.wheel;
state->input.mouse.wheelDeltaY = mouseWheelEvent->y;
break;
default:
break;
}
}
SDL_GetWindowSize(state->window, &state->settings.windowW, &state->settings.windowH);
input_tick(&state->input);
editor_tick(&state->editor);
preview_tick(&state->preview);
tool_tick(&state->tool);
snapshots_tick(&state->snapshots);
dialog_tick(&state->dialog);
imgui_tick(&state->imgui);
} }
static void static void _draw(State* self)
_draw(State* state)
{ {
editor_draw(&state->editor); editor_draw(&self->editor);
preview_draw(&state->preview); preview_draw(&self->preview);
imgui_draw(&state->imgui); imgui_draw();
SDL_GL_SwapWindow(state->window); SDL_GL_SwapWindow(self->window);
} }
void void init(State* self)
init(State* state)
{ {
settings_load(&state->settings); settings_init(&self->settings);
printf(STRING_INFO_INIT); log_info(STATE_INIT_INFO);
if (!SDL_Init(SDL_INIT_VIDEO)) if (!SDL_Init(SDL_INIT_VIDEO))
{ {
printf(STRING_ERROR_SDL_INIT, SDL_GetError()); log_error(std::format(STATE_SDL_INIT_ERROR, SDL_GetError()));
quit(state); quit(self);
} }
printf(STRING_INFO_SDL_INIT); log_info(STATE_SDL_INIT_INFO);
SDL_CreateWindowAndRenderer SDL_CreateWindowAndRenderer
( (
STRING_WINDOW_TITLE, WINDOW_TITLE,
state->settings.windowW, self->settings.windowW,
state->settings.windowH, self->settings.windowH,
WINDOW_FLAGS, WINDOW_FLAGS,
&state->window, &self->window,
&state->renderer &self->renderer
); );
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
state->glContext = SDL_GL_CreateContext(state->window); glewInit();
printf(STRING_INFO_OPENGL, glGetString(GL_VERSION)); self->glContext = SDL_GL_CreateContext(self->window);
if (!state->glContext) if (!self->glContext)
{ {
printf(STRING_ERROR_GL_CONTEXT_INIT, SDL_GetError()); log_error(std::format(STATE_GL_CONTEXT_INIT_ERROR, SDL_GetError()));
quit(state); quit(self);
} }
glewInit(); log_info(std::format(STATE_GL_CONTEXT_INIT_INFO, (const char*)glGetString(GL_VERSION)));
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glLineWidth(LINE_WIDTH); glLineWidth(STATE_GL_LINE_WIDTH);
printf(STRING_INFO_GLEW_INIT); resources_init(&self->resources);
clipboard_init(&self->clipboard, &self->anm2);
resources_init(&state->resources); dialog_init(&self->dialog, &self->anm2, &self->reference, &self->resources, self->window);
dialog_init(&state->dialog, &state->anm2, &state->reference, &state->resources, state->window); snapshots_init(&self->snapshots, &self->anm2, &self->reference, &self->preview);
tool_init(&state->tool, &state->input); preview_init(&self->preview, &self->anm2, &self->reference, &self->resources, &self->settings);
snapshots_init(&state->snapshots, &state->anm2, &state->reference, &state->time, &state->input); editor_init(&self->editor, &self->anm2, &self->reference, &self->resources, &self->settings);
preview_init(&state->preview, &state->anm2, &state->reference, &state->time, &state->resources, &state->settings);
editor_init(&state->editor, &state->anm2, &state->reference, &state->resources, &state->settings);
imgui_init imgui_init
( (
&state->imgui, &self->imgui,
&state->dialog, &self->dialog,
&state->resources, &self->resources,
&state->input, &self->anm2,
&state->anm2, &self->reference,
&state->reference, &self->editor,
&state->time, &self->preview,
&state->editor, &self->settings,
&state->preview, &self->snapshots,
&state->settings, &self->clipboard,
&state->tool, self->window,
&state->snapshots, &self->glContext
state->window,
&state->glContext
); );
if (state->isArgument) if (self->is_argument())
{ {
anm2_deserialize(&state->anm2, &state->resources, state->argument); anm2_deserialize(&self->anm2, &self->resources, self->argument);
window_title_from_path_set(state->window, state->argument); window_title_from_path_set(self->window, self->argument);
} }
else else
anm2_new(&state->anm2); anm2_new(&self->anm2);
} }
void void loop(State* self)
loop(State* state)
{ {
state->tick = SDL_GetTicks(); self->tick = SDL_GetTicks();
while (state->tick > state->lastTick + TICK_DELAY) while (self->tick > self->lastTick + TICK_DELAY)
{ {
state->tick = SDL_GetTicks(); self->tick = SDL_GetTicks();
if (state->tick - state->lastTick < TICK_DELAY) if (self->tick - self->lastTick < TICK_DELAY)
SDL_Delay(TICK_DELAY - (state->tick - state->lastTick)); SDL_Delay(TICK_DELAY - (self->tick - self->lastTick));
_tick(state); _tick(self);
self->lastTick = self->tick;
state->lastTick = state->tick;
} }
_draw(state); _draw(self);
} }
void void quit(State* self)
quit(State* state)
{ {
imgui_free(&state->imgui); imgui_free();
settings_save(&state->settings); settings_save(&self->settings);
preview_free(&state->preview); preview_free(&self->preview);
editor_free(&state->editor); editor_free(&self->editor);
resources_free(&state->resources); resources_free(&self->resources);
SDL_GL_DestroyContext(state->glContext); SDL_GL_DestroyContext(self->glContext);
SDL_Quit(); SDL_Quit();
printf(STRING_INFO_QUIT); log_info(STATE_QUIT_INFO);
} }

View File

@@ -2,10 +2,13 @@
#include "imgui.h" #include "imgui.h"
#define WINDOW_WIDTH 1920 #define STATE_INIT_INFO "Initializing..."
#define WINDOW_HEIGHT 1080 #define STATE_SDL_INIT_ERROR "Failed to initialize SDL! {}"
#define WINDOW_FLAGS SDL_WINDOW_RESIZABLE #define STATE_SDL_INIT_INFO "Initialized SDL"
#define LINE_WIDTH 2.0f #define STATE_GL_CONTEXT_INIT_ERROR "Failed to initialize OpenGL context! {}"
#define STATE_GL_CONTEXT_INIT_INFO "Initialized OpenGL context (OpenGL {})"
#define STATE_QUIT_INFO "Exiting..."
#define STATE_GL_LINE_WIDTH 2.0f
struct State struct State
{ {
@@ -13,22 +16,21 @@ struct State
SDL_Renderer* renderer; SDL_Renderer* renderer;
SDL_GLContext glContext; SDL_GLContext glContext;
Imgui imgui; Imgui imgui;
Input input;
Dialog dialog; Dialog dialog;
Editor editor; Editor editor;
Preview preview; Preview preview;
Anm2 anm2; Anm2 anm2;
Anm2Reference reference; Anm2Reference reference;
f32 time;
Resources resources; Resources resources;
Settings settings; Settings settings;
Tool tool;
Snapshots snapshots; Snapshots snapshots;
bool isArgument = false; Clipboard clipboard;
bool isRunning = true; bool isRunning = true;
char argument[PATH_MAX] = STRING_EMPTY; std::string argument{};
u64 lastTick = 0; u64 lastTick = 0;
u64 tick = 0; u64 tick = 0;
bool is_argument() const { return !argument.empty(); }
}; };
void init(State* state); void init(State* state);

View File

@@ -5,73 +5,56 @@
#define STBI_NO_HDR #define STBI_NO_HDR
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h> #include <stb_image.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h> #include <stb_image_write.h>
void void texture_gl_set(Texture* self, void* data)
texture_gl_set(Texture* self, void* data)
{ {
glGenTextures(1, &self->id); glGenTextures(1, &self->id);
glBindTexture(GL_TEXTURE_2D, self->id); glBindTexture(GL_TEXTURE_2D, self->id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, self->size.x, self->size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, self->size.x, self->size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }
bool bool texture_from_path_init(Texture* self, const std::string& path)
texture_from_path_init(Texture* self, const char* path)
{ {
void* data; void* data = stbi_load(path.c_str(), &self->size.x, &self->size.y, &self->channels, TEXTURE_CHANNELS);
data = stbi_load(path, &self->size.x, &self->size.y, &self->channels, 4);
if (!data) if (!data)
{ {
printf(STRING_ERROR_TEXTURE_INIT, path); log_error(std::format(TEXTURE_INIT_ERROR, path));
return false; return false;
} }
printf(STRING_INFO_TEXTURE_INIT, path); log_info(std::format(TEXTURE_INIT_INFO, path));
texture_gl_set(self, data); texture_gl_set(self, data);
return true; return true;
} }
bool bool texture_from_data_init(Texture* self, const u8* data, u32 length)
texture_from_data_init(Texture* self, const u8* data, u32 length)
{ {
void* textureData; void* textureData = stbi_load_from_memory(data, length, &self->size.x, &self->size.y, &self->channels, TEXTURE_CHANNELS);
textureData = stbi_load_from_memory(data, length, &self->size.x, &self->size.y, &self->channels, 4); if (!textureData) return false;
if (!textureData)
return false;
texture_gl_set(self, textureData); texture_gl_set(self, textureData);
return true; return true;
} }
/* Writes a *.png to the path from the data/size */ bool texture_from_data_write(const std::string& path, const u8* data, s32 width, s32 height)
/* Returns true on success */
bool
texture_from_data_write(const char* path, const u8* data, s32 width, s32 height)
{ {
return (bool)stbi_write_png(path, width, height, 4, data, width * 4); return (bool)stbi_write_png(path.c_str(), width, height, TEXTURE_CHANNELS, data, width * TEXTURE_CHANNELS);
} }
void void texture_free(Texture* self)
texture_free(Texture* self)
{ {
glDeleteTextures(1, &self->id); glDeleteTextures(1, &self->id);
memset(self, '\0', sizeof(Texture)); *self = Texture{};
} }

View File

@@ -2,6 +2,10 @@
#include "COMMON.h" #include "COMMON.h"
#define TEXTURE_CHANNELS 4
#define TEXTURE_INIT_INFO "Initialized texture from file: {}"
#define TEXTURE_INIT_ERROR "Failed to initialize texture from file: {}"
struct Texture struct Texture
{ {
GLuint id = 0; GLuint id = 0;
@@ -11,7 +15,7 @@ struct Texture
}; };
void texture_gl_set(Texture* self, void* data); void texture_gl_set(Texture* self, void* data);
bool texture_from_path_init(Texture* self, const char* path); bool texture_from_path_init(Texture* self, const std::string& path);
bool texture_from_data_init(Texture* self, const u8* data, u32 length); bool texture_from_data_init(Texture* self, const u8* data, u32 length);
void texture_free(Texture* self); void texture_free(Texture* self);
bool texture_from_data_write(const char* path, const u8* data, s32 width, s32 height); bool texture_from_data_write(const std::string& path, const u8* data, s32 width, s32 height);

View File

@@ -1,33 +0,0 @@
#include "tool.h"
void
tool_init(Tool* self, Input* input)
{
self->input = input;
}
void
tool_tick(Tool* self)
{
if (!self->isEnabled) return;
/* Input handling */
if (key_press(&self->input->keyboard, INPUT_KEYS[INPUT_PAN]))
self->type = TOOL_PAN;
if (key_press(&self->input->keyboard, INPUT_KEYS[INPUT_MOVE]))
self->type = TOOL_MOVE;
if (key_press(&self->input->keyboard, INPUT_KEYS[INPUT_SCALE]))
self->type = TOOL_SCALE;
if (key_press(&self->input->keyboard, INPUT_KEYS[INPUT_CROP]))
self->type = TOOL_CROP;
if
(
key_press(&self->input->keyboard, INPUT_KEYS[INPUT_ROTATE_LEFT]) ||
key_press(&self->input->keyboard, INPUT_KEYS[INPUT_ROTATE_RIGHT])
)
self->type = TOOL_ROTATE;
}

View File

@@ -1,23 +0,0 @@
#pragma once
#include "input.h"
#define TOOL_COUNT (TOOL_CROP + 1)
enum ToolType
{
TOOL_PAN,
TOOL_MOVE,
TOOL_ROTATE,
TOOL_SCALE,
TOOL_CROP
};
struct Tool
{
Input* input = NULL;
ToolType type = TOOL_PAN;
bool isEnabled = false;
};
void tool_init(Tool* self, Input* input);
void tool_tick(Tool* self);

View File

@@ -1,15 +1,9 @@
#include "window.h" #include "window.h"
/* Sets the window title from the given anm2 */ void window_title_from_path_set(SDL_Window* self, const std::string& path)
void
window_title_from_path_set(SDL_Window* self, const char* path)
{ {
if (!strcmp(path, STRING_EMPTY) == 0) if (!path.empty())
{ SDL_SetWindowTitle(self, std::format(WINDOW_TITLE_FORMAT, path).c_str());
char windowTitle[WINDOW_TITLE_MAX];
snprintf(windowTitle, WINDOW_TITLE_MAX, STRING_WINDOW_TITLE_EDITING, path);
SDL_SetWindowTitle(self, windowTitle);
}
else else
SDL_SetWindowTitle(self, STRING_WINDOW_TITLE); SDL_SetWindowTitle(self, WINDOW_TITLE);
} }

View File

@@ -2,6 +2,10 @@
#include "COMMON.h" #include "COMMON.h"
#define WINDOW_TITLE_MAX 0xFF + PATH_MAX #define WINDOW_TITLE "Anm2Ed"
#define WINDOW_TITLE_FORMAT "Anm2Ed ({})"
#define WINDOW_WIDTH 1920
#define WINDOW_HEIGHT 1080
#define WINDOW_FLAGS SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL
void window_title_from_path_set(SDL_Window* self, const char* path); void window_title_from_path_set(SDL_Window* self, const std::string& path);

14
vcpkg-configuration.json Normal file
View File

@@ -0,0 +1,14 @@
{
"default-registry": {
"kind": "git",
"baseline": "4f8fe05871555c1798dbcb1957d0d595e94f7b57",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}

6
vcpkg.json Normal file
View File

@@ -0,0 +1,6 @@
{
"dependencies": [
"sdl3",
"glew"
]
}