The Update(TM), Part 1

This commit is contained in:
2025-07-27 22:08:57 -04:00
parent 0439221e78
commit fe8bdae9a8
45 changed files with 4450 additions and 3564 deletions

View File

@@ -6,6 +6,7 @@ endif()
project(anm2ed CXX)
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
find_package(GLEW REQUIRED)
find_package(OpenGL REQUIRED)
@@ -29,6 +30,8 @@ if (WIN32)
endif()
add_executable(${PROJECT_NAME} ${SOURCES} ${WIN32_RESOURCES})
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
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")
@@ -41,6 +44,7 @@ if(NOT MSVC)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL GLEW::GLEW SDL3::SDL3)
message("System: ${CMAKE_SYSTEM_NAME}")
message("Project: ${PROJECT_NAME}")
message("Build: ${CMAKE_BUILD_TYPE}")

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, 0x2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xfb, 0xbc, 0x2f, 0x80, 0xde, 0x7b,
0xef, 0x1d, 0x91, 0xcc, 0x6c, 0x8d, 0xbd, 0x5d, 0xbd, 0x20, 0x69, 0xa7,
0xfb, 0xc9, 0x8a, 0x06, 0x45, 0x21, 0xab, 0x4f, 0xf3, 0x48, 0x83, 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, 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0xff, 0x55, 0x57, 0x01, 0x50, 0x51, 0xd0,
0x7a, 0x67, 0xea, 0x6d, 0x37, 0xb2, 0x09, 0xdc, 0x69, 0xe2, 0x4a, 0x03,
0x2a, 0x11, 0x2b, 0x13, 0xf4, 0xf2, 0x91, 0x0c, 0xe4, 0x84, 0xb5, 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;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

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

View File

@@ -13,17 +13,19 @@
#include <algorithm>
#include <chrono>
#include <cstring>
#include <cmath>
#include <filesystem>
#include <format>
#include <format>
#include <functional>
#include <fstream>
#include <iostream>
#include <iostream>
#include <map>
#include <print>
#include <optional>
#include <ranges>
#include <string>
#include <vector>
#include "STRINGS.h"
#include <unordered_set>
typedef uint8_t u8;
typedef uint16_t u16;
@@ -46,57 +48,17 @@ using namespace glm;
#define MIN(x, min) (x < min ? min : x)
#define MAX(x, max) (x > max ? max : x)
#define CLAMP(x, min, max) (MIN(MAX(x, max), min))
// Converts a string to a bool
static inline bool string_to_bool(const std::string& string)
{
return string == "true" || string == "1";
};
// Given a file path, sets the working directory to it
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);
};
// Converts an enum to a string value
static inline const char* enum_to_string(const char* array[], s32 count, s32 index)
{
return (index >= 0 && index < count) ? array[index] : "";
};
// Converts a string to an enum value
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;
};
// Macro to define enum to string functions
#define DEFINE_ENUM_TO_STRING_FUNCTION(function, array, count) \
static inline std::string function(s32 index) \
{ \
return enum_to_string(array, count, index); \
};
// Macro to define string to enum functions
#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)); \
};
#define ROUND_NEAREST_FLOAT(value, multiple) (roundf((value) / (multiple)) * (multiple))
#define COLOR_FLOAT_TO_INT(x) (static_cast<int>((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_CATCH_UP_MAX (33.3f * 5)
#define SECOND 1000.0f
#define TICK_RATE (SECOND / TICK_DELAY)
#define ID_NONE -1
#define INDEX_NONE -1
#define LENGTH_NONE -1
#define UV_VERTICES(uvMin, uvMax) \
{ \
@@ -122,11 +84,7 @@ static const f32 GL_UV_VERTICES[] =
0, 1, 0.0f, 1.0f
};
#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 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_BLUE = {0.0f, 0.0f, 1.0f, 1.0f};
@@ -134,15 +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 vec3 COLOR_OFFSET_NONE = {0.0f, 0.0f, 0.0f};
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;
static inline void log_error(const std::string& string)
{
std::println("[ERROR] {}", string);
}
static inline void log_info(const std::string& string)
{
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>
static inline void map_swap(Map& map, const Key& key1, const Key& key2)
{
@@ -167,4 +195,38 @@ static inline void map_swap(Map& map, const Key& key1, const Key& key2)
map[key1] = std::move(it2->second);
map.erase(it2);
}
};
};
template <typename T>
static inline void map_insert_shift(std::map<int, T>& map, s32 index, const T& value)
{
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));
}
for (const auto& [newKey, _] : toShift)
map.erase(newKey - 1);
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,130 +1,197 @@
// Includes packed resources (i.e., textures, shaders)
#pragma once
#include "COMMON.h"
const u32 TEXTURE_ATLAS_LENGTH = 916;
const u32 TEXTURE_ATLAS_LENGTH = 1696;
const u8 TEXTURE_ATLAS[] =
{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x68,
0x02, 0x03, 0x00, 0x00, 0x00, 0x73, 0xa5, 0x1d, 0xc6, 0x00, 0x00, 0x00,
0x09, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x60,
0x60, 0x60, 0x13, 0x5e, 0x42, 0xae, 0x00, 0x00, 0x00, 0x01, 0x74, 0x52,
0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00, 0x03, 0x39, 0x49,
0x44, 0x41, 0x54, 0x48, 0xc7, 0xcd, 0x95, 0xcf, 0x6b, 0x14, 0x31, 0x14,
0xc7, 0xbf, 0x19, 0x26, 0xb2, 0xb3, 0xa7, 0x11, 0x26, 0xcb, 0xea, 0x69,
0x90, 0x46, 0xb4, 0x7f, 0x45, 0x0a, 0xf5, 0xe0, 0x2d, 0x42, 0xde, 0x30,
0x9d, 0xd3, 0x28, 0x56, 0xa4, 0x7f, 0x45, 0x0e, 0x0a, 0xf5, 0xe6, 0x61,
0x47, 0xaa, 0xa7, 0x22, 0xac, 0xb4, 0xf3, 0x57, 0x9a, 0x97, 0x34, 0x16,
0x71, 0x57, 0x29, 0x82, 0xf8, 0x20, 0xbb, 0x2f, 0xf3, 0x79, 0xf9, 0xbe,
0x1f, 0x19, 0x76, 0xf1, 0x7b, 0x13, 0x06, 0xa8, 0x46, 0xc8, 0xbc, 0xd7,
0x3d, 0x92, 0x29, 0x07, 0x48, 0x0b, 0xf9, 0x0d, 0x2d, 0xd8, 0x88, 0xf8,
0x73, 0x22, 0x41, 0x64, 0x18, 0x2c, 0x15, 0xea, 0x28, 0x60, 0xa5, 0x89,
0x58, 0x11, 0xb9, 0x28, 0xa5, 0x5e, 0x59, 0x96, 0x91, 0xf3, 0xd6, 0x02,
0x85, 0x41, 0x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x3a, 0x0d, 0x8e, 0x0b, 0x52, 0x2f, 0x9c,
0x7a, 0x56, 0x38, 0xe5, 0xa4, 0xc5, 0x02, 0x6d, 0xab, 0x86, 0x00, 0x84,
0x85, 0x36, 0xd4, 0x6b, 0x12, 0xbd, 0x0a, 0x28, 0x82, 0xe6, 0xe1, 0x6b,
0xc4, 0x72, 0x1d, 0x59, 0x49, 0xca, 0xfe, 0x00, 0x50, 0x1b, 0x40, 0x03,
0xc2, 0x71, 0x83, 0xca, 0x30, 0x88, 0x39, 0xa0, 0x03, 0x58, 0x03, 0x48,
0x27, 0x10, 0xc1, 0xcf, 0x46, 0x4e, 0x11, 0x10, 0x93, 0xef, 0xb5, 0x39,
0x98, 0x07, 0xe0, 0xff, 0x00, 0x6e, 0xef, 0x6f, 0x22, 0xea, 0xee, 0x0e,
0xf0, 0xbf, 0x03, 0xe5, 0xf6, 0x00, 0xa2, 0xdd, 0x40, 0x1c, 0x1d, 0x99,
0x9d, 0x40, 0x0a, 0x63, 0xef, 0x02, 0x14, 0x45, 0x73, 0x7b, 0xc1, 0x5f,
0xe7, 0xc8, 0xe5, 0xde, 0xad, 0x41, 0x28, 0xf7, 0x3f, 0x5e, 0xd4, 0xbf,
0x00, 0xc0, 0x1f, 0x81, 0x26, 0xea, 0x77, 0x02, 0xfe, 0xff, 0xde, 0x09,
0x0a, 0x22, 0xef, 0x77, 0x01, 0x4c, 0x1d, 0x76, 0x03, 0xdd, 0xef, 0x01,
0xd5, 0xb8, 0x07, 0x14, 0x7e, 0x27, 0xf8, 0x0e, 0xc6, 0xe6, 0x29, 0x49,
0x20, 0x43, 0x4e, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
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,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, 0x09, 0xdc, 0x69, 0xe2, 0x4a, 0x03,
0x2a, 0x11, 0x2b, 0x13, 0xf4, 0xf2, 0x91, 0x0c, 0xe4, 0x84, 0xb5, 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
};
enum TextureType
{
TEXTURE_NONE,
TEXTURE_RECORD,
TEXTURE_ROOT,
TEXTURE_LAYER,
TEXTURE_NULL,
TEXTURE_TRIGGERS,
TEXTURE_VISIBLE,
TEXTURE_INVISIBLE,
TEXTURE_ERROR,
TEXTURE_SHOW_RECT,
TEXTURE_HIDE_RECT,
TEXTURE_PAN,
TEXTURE_MOVE,
TEXTURE_UP,
TEXTURE_DOWN,
TEXTURE_RECT,
TEXTURE_RECT_HIDE,
TEXTURE_ROTATE,
TEXTURE_SCALE,
TEXTURE_CROP,
TEXTURE_UNDO,
TEXTURE_REDO,
TEXTURE_DRAW,
TEXTURE_ERASE,
TEXTURE_SCALE,
TEXTURE_COLOR,
TEXTURE_PAN,
TEXTURE_CROP,
TEXTURE_COLOR_PICKER,
TEXTURE_ANIMATION,
TEXTURE_SPRITESHEET,
TEXTURE_EVENT,
TEXTURE_ROTATE,
TEXTURE_REDO,
TEXTURE_TRIGGER,
TEXTURE_PIVOT,
TEXTURE_SQUARE,
TEXTURE_CIRCLE,
TEXTURE_UNINTERPOLATED,
TEXTURE_INTERPOLATED,
TEXTURE_PICKER,
TEXTURE_FRAME,
TEXTURE_FRAME_ALT,
TEXTURE_FRAME,
TEXTURE_TARGET,
TEXTURE_COUNT
};
const vec2 ATLAS_SIZE = {96, 104};
const vec2 TEXTURE_SIZE = {16, 16};
const vec2 TEXTURE_SIZE_SMALL = {8, 8};
const vec2 TEXTURE_SIZE_BIG = {32, 32};
const vec2 TEXTURE_SIZE = {16, 16};
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]}
const vec2 ATLAS_UVS[TEXTURE_COUNT][2] =
@@ -159,7 +226,7 @@ const vec2 ATLAS_UVS[TEXTURE_COUNT][2] =
{ ATLAS_UV( 0, 64), ATLAS_UV( 16,104) }, /* 16 x 40 */
{ ATLAS_UV( 16, 64), ATLAS_UV( 32,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 */
};
const vec2 ATLAS_SIZES[TEXTURE_COUNT] =
@@ -287,4 +354,4 @@ const ShaderData SHADER_DATA[SHADER_COUNT] =
{SHADER_VERTEX, SHADER_FRAGMENT},
{SHADER_VERTEX, SHADER_TEXTURE_FRAGMENT},
{SHADER_VERTEX, SHADER_LINE_DOTTED_FRAGMENT}
};
};

View File

@@ -1,297 +0,0 @@
#pragma once
#define STRING_WINDOW_TITLE "Anm2Ed"
#define STRING_ANM2_CREATED_ON_FORMAT "%d-%B-%Y %I:%M:%S %p"
#define STRING_ERROR_SDL_INIT "[ERROR] Could not initialize SDL: "
#define STRING_ERROR_GL_CONTEXT_INIT "[ERROR] Could not initialize OpenGL context: "
#define STRING_ERROR_FILE_READ "[ERROR] Could not read from file: "
#define STRING_ERROR_SHADER_INIT "[ERROR] Could not initialize shader: "
#define STRING_ERROR_TEXTURE_INIT "[ERROR] Could not initialize texture: "
#define STRING_ERROR_ANM2_READ "[ERROR] Could not read anm2 from file: "
#define STRING_ERROR_ANM2_WRITE "[ERROR] Could not write anm2 to file: "
#define STRING_ERROR_SETTINGS_INIT "[ERROR] Could not load settings file: "
#define STRING_INFO_INIT "[INFO] Initializing"
#define STRING_INFO_QUIT "[INFO] Exited"
#define STRING_INFO_SDL_INIT "[INFO] Initialized SDL"
#define STRING_INFO_SDL_QUIT "[INFO] Quit SDL"
#define STRING_INFO_GLEW_INIT "[INFO] Initialized GLEW"
#define STRING_INFO_GL_CONTEXT_INIT "[INFO] Initialized OpenGL context"
#define STRING_INFO_FILE_READ "[INFO] Read from file: "
#define STRING_INFO_TEXTURE_INIT "[INFO] Initialized texture: "
#define STRING_INFO_ANM2_WRITE "[INFO] Wrote anm2 to file: "
#define STRING_INFO_ANM2_READ "[INFO] Read anm2 from file: "
#define STRING_INFO_OPENGL "OpenGL"
#define STRING_INFO_IMGUI_INIT "[INFO] Initialized Dear Imgui"
#define STRING_INFO_IMGUI_FREE "[INFO] Freed Dear Imgui"
#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 "{}/{:03}.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 "(*) {}"
#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 "#{} {}"
#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 "#{} {}"
#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_POSITION_FORMAT "Position: {{{:5}, {:5}}}"
#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_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_ITEM_FORMAT "#{} {}"
#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_SPRITESHEET_ID_FORMAT "#{}"
#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"

View File

@@ -1,12 +1,10 @@
// Anm2 file format; serializing/deserializing
#include "anm2.h"
using namespace tinyxml2;
static void _anm2_created_on_set(Anm2* self);
// Sets the anm2's date to the system's current date
static void
_anm2_created_on_set(Anm2* self)
static void _anm2_created_on_set(Anm2* self)
{
auto now = std::chrono::system_clock::now();
std::time_t time = std::chrono::system_clock::to_time_t(now);
@@ -17,9 +15,7 @@ _anm2_created_on_set(Anm2* self)
self->createdOn = timeString.str();
}
// Serializes the anm2 struct into XML and exports it to the given path
bool
anm2_serialize(Anm2* self, const std::string& path)
bool anm2_serialize(Anm2* self, const std::string& path)
{
XMLDocument document;
XMLError error;
@@ -33,17 +29,11 @@ anm2_serialize(Anm2* self, const std::string& path)
XMLElement* eventsElement;
XMLElement* animationsElement;
if (!self || path.empty())
return false;
if (!self || path.empty()) return false;
// Update creation date on first version
if (self->version == 0)
_anm2_created_on_set(self);
if (self->version == 0) _anm2_created_on_set(self);
// Set anm2 path to argument
self->path = path;
// Update version
self->version++;
// AnimatedActor
@@ -137,7 +127,7 @@ anm2_serialize(Anm2* self, const std::string& path)
animationsElement = document.NewElement(ANM2_ELEMENT_STRINGS[ANM2_ELEMENT_ANIMATIONS]);
animationsElement->SetAttribute(ANM2_ATTRIBUTE_STRINGS[ANM2_ATTRIBUTE_DEFAULT_ANIMATION], self->defaultAnimation.c_str()); // DefaultAnimation
for (const auto & [id, animation] : self->animations)
for (auto& [id, animation] : self->animations)
{
XMLElement* animationElement;
XMLElement* rootAnimationElement;
@@ -155,7 +145,7 @@ anm2_serialize(Anm2* self, const std::string& path)
// RootAnimation
rootAnimationElement = document.NewElement(ANM2_ELEMENT_STRINGS[ANM2_ELEMENT_ROOT_ANIMATION]);
for (const auto & frame : animation.rootAnimation.frames)
for (auto& frame : animation.rootAnimation.frames)
{
XMLElement* frameElement;
@@ -188,8 +178,10 @@ anm2_serialize(Anm2* self, const std::string& path)
// LayerAnimations
layerAnimationsElement = document.NewElement(ANM2_ELEMENT_STRINGS[ANM2_ELEMENT_LAYER_ANIMATIONS]);
for (const auto & [layerID, layerAnimation] : animation.layerAnimations)
for (auto& [layerIndex, layerID] : self->layerMap)
{
Anm2Item& layerAnimation = animation.layerAnimations[layerID];
XMLElement* layerAnimationElement;
// LayerAnimation
@@ -304,30 +296,28 @@ anm2_serialize(Anm2* self, const std::string& path)
if (error != XML_SUCCESS)
{
std::cout << STRING_ERROR_ANM2_WRITE << path << std::endl;
log_error(std::format(ANM2_WRITE_ERROR, path));
return false;
}
std::cout << STRING_INFO_ANM2_WRITE << path << std::endl;
log_info(std::format(ANM2_WRITE_INFO, path));
return true;
}
// Loads the .anm2 file and deserializes it into the struct equivalent
bool
anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
bool anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
{
XMLDocument xmlDocument;
XMLError xmlError;
const XMLElement* xmlElement;
const XMLElement* xmlRoot;
Anm2Animation* animation = NULL;
Anm2Layer* layer = NULL;
Anm2Null* null = NULL;
Anm2Item* item = NULL;
Anm2Event* event = NULL;
Anm2Frame* frame = NULL;
Anm2Spritesheet* spritesheet = NULL;
Anm2Animation* animation = nullptr;
Anm2Layer* layer = nullptr;
Anm2Null* null = nullptr;
Anm2Item* item = nullptr;
Anm2Event* event = nullptr;
Anm2Frame* frame = nullptr;
Anm2Spritesheet* spritesheet = nullptr;
Anm2Element anm2Element = ANM2_ELEMENT_ANIMATED_ACTOR;
Anm2Attribute anm2Attribute = ANM2_ATTRIBUTE_ID;
Anm2Item addItem;
@@ -335,9 +325,11 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
Anm2Null addNull;
Anm2Event addEvent;
Anm2Spritesheet addSpritesheet;
s32 layerMapIndex = 0;
bool isLayerMapSet = false;
bool isFirstAnimationDone = false;
if (!self || path.empty())
return false;
if (!self || path.empty()) return false;
*self = Anm2{};
@@ -345,13 +337,10 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
if (xmlError != XML_SUCCESS)
{
std::cout << STRING_ERROR_ANM2_READ << path << xmlDocument.ErrorStr() << std::endl;
log_error(std::format(ANM2_READ_ERROR, xmlDocument.ErrorStr()));
return false;
}
// Free the loaded textures used by resources so new ones for the anm2 can be loaded
resources_textures_free(resources);
// Save old working directory and then use anm2's path as directory
// (used for loading textures from anm2 correctly which are relative)
std::filesystem::path workingPath = std::filesystem::current_path();
@@ -365,8 +354,8 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
// Iterate through elements
while (xmlElement)
{
const XMLAttribute* xmlAttribute = NULL;
const XMLElement* xmlChild = NULL;
const XMLAttribute* xmlAttribute = nullptr;
const XMLElement* xmlChild = nullptr;
s32 id = 0;
anm2Element = ANM2_ELEMENT_STRING_TO_ENUM(xmlElement->Name());
@@ -389,6 +378,11 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
id = map_next_id_get(self->animations);
self->animations[id] = Anm2Animation{};
animation = &self->animations[id];
if (isFirstAnimationDone)
isLayerMapSet = true;
isFirstAnimationDone = true;
break;
case ANM2_ELEMENT_ROOT_ANIMATION: // RootAnimation
item = &animation->rootAnimation;
@@ -455,6 +449,13 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
break;
case ANM2_ATTRIBUTE_LAYER_ID: // LayerId
id = atoi(xmlAttribute->Value());
if (!isLayerMapSet)
{
self->layerMap[layerMapIndex] = id;
layerMapIndex++;
}
animation->layerAnimations[id] = addItem;
item = &animation->layerAnimations[id];
break;
@@ -588,9 +589,7 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
xmlAttribute = xmlAttribute->Next();
}
// Load this anm2's spritesheet textures
if (anm2Element == ANM2_ELEMENT_SPRITESHEET)
resources_texture_init(resources, spritesheet->path , id);
if (anm2Element == ANM2_ELEMENT_SPRITESHEET) resources_texture_init(resources, spritesheet->path , id);
xmlChild = xmlElement->FirstChildElement();
@@ -600,7 +599,6 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
continue;
}
// Iterate through siblings
while (xmlElement)
{
const XMLElement* xmlNext;
@@ -613,12 +611,11 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
break;
}
// If no siblings, return to parent. If no parent, end parsing
xmlElement = xmlElement->Parent() ? xmlElement->Parent()->ToElement() : NULL;
xmlElement = xmlElement->Parent() ? xmlElement->Parent()->ToElement() : nullptr;
}
}
std::cout << STRING_INFO_ANM2_READ << path << std::endl;
log_info(std::format(ANM2_READ_INFO, path));
// Return to old working directory
std::filesystem::current_path(workingPath);
@@ -626,9 +623,7 @@ anm2_deserialize(Anm2* self, Resources* resources, const std::string& path)
return true;
}
// Adds a layer to the anm2
void
anm2_layer_add(Anm2* self)
void anm2_layer_add(Anm2* self)
{
s32 id = map_next_id_get(self->layers);
@@ -638,9 +633,7 @@ anm2_layer_add(Anm2* self)
animation.layerAnimations[id] = Anm2Item{};
}
// Removes a layer from the anm2
void
anm2_layer_remove(Anm2* self, s32 id)
void anm2_layer_remove(Anm2* self, s32 id)
{
// Make sure the layer exists
auto it = self->layers.find(id);
@@ -653,9 +646,7 @@ anm2_layer_remove(Anm2* self, s32 id)
animation.layerAnimations.erase(id);
}
// Adds a null to the anm2
void
anm2_null_add(Anm2* self)
void anm2_null_add(Anm2* self)
{
s32 id = map_next_id_get(self->nulls);
@@ -665,9 +656,7 @@ anm2_null_add(Anm2* self)
animation.nullAnimations[id] = Anm2Item{};
}
// Removes the specified null from the anm2
void
anm2_null_remove(Anm2* self, s32 id)
void anm2_null_remove(Anm2* self, s32 id)
{
// Make sure the null exists
auto it = self->nulls.find(id);
@@ -680,26 +669,16 @@ anm2_null_remove(Anm2* self, s32 id)
animation.nullAnimations.erase(id);
}
// Adds an animation to the anm2
s32
anm2_animation_add(Anm2* self)
s32 anm2_animation_add(Anm2* self)
{
s32 id = map_next_id_get(self->animations);
Anm2Animation animation;
// Match layers
for (auto & [layerID, layer] : self->layers)
{
animation.layerAnimations[layerID] = Anm2Item{};
}
for (auto& [layerID, layer] : self->layers)
animation.layerAnimations[layerID] = Anm2Item{};
for (auto & [nullID, null] : self->nulls)
animation.nullAnimations[nullID] = Anm2Item{};
// Match nulls
for (auto & [nullID, null] : self->nulls)
{
animation.nullAnimations[nullID] = Anm2Item{};
}
// Add a root frame
animation.rootAnimation.frames.push_back(Anm2Frame{});
self->animations[id] = animation;
@@ -707,38 +686,29 @@ anm2_animation_add(Anm2* self)
return id;
}
// Removes an animation by id from the anm2
void
anm2_animation_remove(Anm2* self, s32 id)
void anm2_animation_remove(Anm2* self, s32 id)
{
self->animations.erase(id);
}
// Sets the anm2 to default
void
anm2_new(Anm2* self)
void anm2_new(Anm2* self)
{
*self = Anm2{};
_anm2_created_on_set(self);
}
Anm2Animation*
anm2_animation_from_reference(Anm2* self, Anm2Reference* reference)
Anm2Animation* anm2_animation_from_reference(Anm2* self, Anm2Reference* reference)
{
auto it = self->animations.find(reference->animationID);
if (it == self->animations.end())
return NULL;
if (it == self->animations.end()) return nullptr;
return &it->second;
}
// Returns the item from a anm2 reference.
Anm2Item*
anm2_item_from_reference(Anm2* self, Anm2Reference* reference)
Anm2Item* anm2_item_from_reference(Anm2* self, Anm2Reference* reference)
{
Anm2Animation* animation = anm2_animation_from_reference(self, reference);
if (!animation)
return NULL;
if (!animation) return nullptr;
switch (reference->itemType)
{
@@ -748,78 +718,108 @@ anm2_item_from_reference(Anm2* self, Anm2Reference* reference)
{
auto it = animation->layerAnimations.find(reference->itemID);
if (it == animation->layerAnimations.end())
return NULL;
return nullptr;
return &it->second;
}
case ANM2_NULL:
{
auto it = animation->nullAnimations.find(reference->itemID);
if (it == animation->nullAnimations.end())
return NULL;
return nullptr;
return &it->second;
}
case ANM2_TRIGGERS:
return &animation->triggers;
default:
return NULL;
return nullptr;
}
}
// Gets the frame from the reference's properties
Anm2Frame*
anm2_frame_from_reference(Anm2* self, Anm2Reference* reference)
Anm2Frame* anm2_frame_from_reference(Anm2* self, Anm2Reference* reference)
{
Anm2Item* item = anm2_item_from_reference(self, reference);
if (!item)
return NULL;
if (reference->frameIndex < 0 || reference->frameIndex >= (s32)item->frames.size())
return NULL;
if (!item) return nullptr;
if (reference->frameIndex < 0 || reference->frameIndex >= (s32)item->frames.size()) return nullptr;
return &item->frames[reference->frameIndex];
}
// Creates or fetches a frame from a given time.
void
anm2_frame_from_time(Anm2* self, Anm2Frame* frame, Anm2Reference reference, f32 time)
s32 anm2_frame_index_from_time(Anm2* self, Anm2Reference reference, f32 time)
{
Anm2Animation* animation = anm2_animation_from_reference(self, &reference);
if (!animation)
return;
if (time < 0 || time > animation->frameNum)
return;
if (!animation) return INDEX_NONE;
if (time < 0 || time > animation->frameNum) return INDEX_NONE;
Anm2Item* item = anm2_item_from_reference(self, &reference);
if (!item)
return;
if (!item) return INDEX_NONE;
Anm2Frame* nextFrame = NULL;
s32 delayCurrent = 0;
s32 delayNext = 0;
for (s32 i = 0; i < (s32)item->frames.size(); i++)
for (auto [i, frame] : std::views::enumerate(item->frames))
{
*frame = item->frames[i];
delayNext += frame->delay;
delayNext += frame.delay;
// Use the last parsed frame as the given frame.
if (time >= delayCurrent && time < delayNext)
{
if (i + 1 < (s32)item->frames.size())
nextFrame = &item->frames[i + 1];
else
nextFrame = NULL;
break;
}
return i;
delayCurrent += frame->delay;
delayCurrent += frame.delay;
}
// Interpolate, but only if there's a frame following.
return INDEX_NONE;
}
void anm2_frame_from_time(Anm2* self, Anm2Frame* frame, Anm2Reference reference, f32 time)
{
Anm2Animation* animation = anm2_animation_from_reference(self, &reference);
if (!animation) return;
if (time < 0 || time > animation->frameNum) return;
Anm2Item* item = anm2_item_from_reference(self, &reference);
if (!item) return;
Anm2Frame* nextFrame = nullptr;
s32 delayCurrent = 0;
s32 delayNext = 0;
for (auto [i, iFrame] : std::views::enumerate(item->frames))
{
if (reference.itemType == ANM2_TRIGGERS)
{
if ((s32)time == iFrame.atFrame)
{
*frame = iFrame;
break;
}
}
else
{
*frame = iFrame;
delayNext += frame->delay;
if (time >= delayCurrent && time < delayNext)
{
if (i + 1 < (s32)item->frames.size())
nextFrame = &item->frames[i + 1];
else
nextFrame = nullptr;
break;
}
delayCurrent += frame->delay;
}
}
if (reference.itemType == ANM2_TRIGGERS)
return;
if (frame->isInterpolated && nextFrame)
{
f32 interpolationTime = (time - delayCurrent) / (delayNext - delayCurrent);
@@ -832,62 +832,54 @@ anm2_frame_from_time(Anm2* self, Anm2Frame* frame, Anm2Reference reference, f32
}
}
// Returns the animation's length, based on the present frames.
s32
anm2_animation_length_get(Anm2* self, s32 animationID)
s32 anm2_animation_length_get(Anm2Animation* self)
{
auto it = self->animations.find(animationID);
if (it == self->animations.end())
return -1;
s32 length = 0;
Anm2Animation* animation = &it->second;
s32 delayHighest = 0;
auto accumulate_max_delay = [&](const std::vector<Anm2Frame>& frames)
{
s32 delaySum = 0;
for (const auto& frame : frames)
{
delaySum += frame.delay;
length = std::max(length, delaySum);
}
};
// Go through all items and see which one has the latest frame; that's the length
// Root
for (auto & frame : animation->rootAnimation.frames)
delayHighest = std::max(delayHighest, frame.delay);
accumulate_max_delay(self->rootAnimation.frames);
// Layer
for (auto & [id, item] : animation->layerAnimations)
for (auto & frame : item.frames)
delayHighest = std::max(delayHighest, frame.delay);
for (const auto& [_, item] : self->layerAnimations)
accumulate_max_delay(item.frames);
// Null
for (auto & [id, item] : animation->nullAnimations)
for (auto & frame : item.frames)
delayHighest = std::max(delayHighest, frame.delay);
for (const auto& [_, item] : self->nullAnimations)
accumulate_max_delay(item.frames);
// Triggers
for (auto & trigger : animation->triggers.frames)
delayHighest = std::max(delayHighest, trigger.atFrame);
for (const auto& frame : self->triggers.frames)
length = std::max(length, frame.atFrame);
return delayHighest;
return length;
}
// Will try adding a frame to the anm2 given the specified reference
Anm2Frame*
anm2_frame_add(Anm2* self, Anm2Reference* reference, s32 time)
void anm2_animation_length_set(Anm2Animation* self)
{
self->frameNum = anm2_animation_length_get(self);
}
Anm2Frame* anm2_frame_add(Anm2* self, Anm2Reference* reference, s32 time)
{
Anm2Animation* animation = anm2_animation_from_reference(self, reference);
Anm2Item* item = anm2_item_from_reference(self, reference);
if (!animation || !item)
return NULL;
if (!animation || !item) return nullptr;
if (item)
{
Anm2Frame frame = Anm2Frame{};
s32 index = -1;
s32 index = INDEX_NONE;
if (reference->itemType == ANM2_TRIGGERS)
{
// Don't add redundant triggers
for (auto & frameCheck : item->frames)
{
if (frameCheck.atFrame == time)
return NULL;
}
for (auto & frameCheck : item->frames) if (frameCheck.atFrame == time) return nullptr;
frame.atFrame = time;
index = item->frames.size();
@@ -896,20 +888,15 @@ anm2_frame_add(Anm2* self, Anm2Reference* reference, s32 time)
{
s32 frameDelayCount = 0;
// Get the latest frame delay, to see where this frame might lie
for (auto & frameCheck : item->frames)
frameDelayCount += frameCheck.delay;
// If adding the smallest frame delay would be over the length, don't bother
if (frameDelayCount + ANM2_FRAME_DELAY_MIN > animation->frameNum)
return NULL;
if (frameDelayCount + ANM2_FRAME_DELAY_MIN > animation->frameNum) return nullptr;
// Will insert next to frame if frame exists
Anm2Frame* checkFrame = anm2_frame_from_reference(self, reference);
if (checkFrame)
{
// Will shrink frame delay to fit
if (frameDelayCount + checkFrame->delay > animation->frameNum)
frame.delay = animation->frameNum - frameDelayCount;
@@ -924,27 +911,22 @@ anm2_frame_add(Anm2* self, Anm2Reference* reference, s32 time)
return &item->frames[index];
}
return NULL;
return nullptr;
}
// Clears the anm2 reference, totally
void
anm2_reference_clear(Anm2Reference* self)
void anm2_reference_clear(Anm2Reference* self)
{
*self = Anm2Reference{};
}
// Clears the anm2 reference's item
void
anm2_reference_item_clear(Anm2Reference* self)
void anm2_reference_item_clear(Anm2Reference* self)
{
self->itemType = ANM2_NONE;
self->itemID = -1;
self->itemID = ID_NONE;
self->frameIndex = INDEX_NONE;
}
// Clears the anm2 reference's frame
void
anm2_reference_frame_clear(Anm2Reference* self)
void anm2_reference_frame_clear(Anm2Reference* self)
{
self->frameIndex = -1;
self->frameIndex = INDEX_NONE;
}

View File

@@ -13,6 +13,12 @@
#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 */
#define ANM2_ELEMENT_LIST \
X(ANIMATED_ACTOR, "AnimatedActor") \
@@ -120,24 +126,24 @@ enum Anm2Type
struct Anm2Spritesheet
{
std::string path;
std::string path{};
};
struct Anm2Layer
{
std::string name = STRING_ANM2_NEW_LAYER;
std::string name = "New Layer";
s32 spritesheetID = -1;
};
struct Anm2Null
{
std::string name = STRING_ANM2_NEW_NULL;
std::string name = "New Null";
bool isShowRect = false;
};
struct Anm2Event
{
std::string name = STRING_ANM2_NEW_EVENT;
std::string name = "New Event";
};
struct Anm2Frame
@@ -146,8 +152,8 @@ struct Anm2Frame
bool isVisible = true;
f32 rotation = 1.0f;
s32 delay = ANM2_FRAME_DELAY_MIN;
s32 atFrame = -1;
s32 eventID = -1;
s32 atFrame = INDEX_NONE;
s32 eventID = ID_NONE;
vec2 crop = {0.0f, 0.0f};
vec2 pivot = {0.0f, 0.0f};
vec2 position = {0.0f, 0.0f};
@@ -166,7 +172,7 @@ struct Anm2Item
struct Anm2Animation
{
s32 frameNum = ANM2_FRAME_NUM_MIN;
std::string name = STRING_ANM2_NEW_ANIMATION;
std::string name = "New Animation";
bool isLoop = true;
Anm2Item rootAnimation;
std::map<s32, Anm2Item> layerAnimations;
@@ -176,29 +182,47 @@ struct Anm2Animation
struct Anm2
{
std::string path;
std::string defaultAnimation;
std::string createdBy = STRING_ANM2_CREATED_BY_DEFAULT;
std::string createdOn;
std::string path{};
std::string defaultAnimation{};
std::string createdBy = "robot";
std::string createdOn{};
std::map<s32, Anm2Spritesheet> spritesheets;
std::map<s32, Anm2Layer> layers;
std::map<s32, Anm2Null> nulls;
std::map<s32, Anm2Event> events;
std::map<s32, Anm2Event> events;
std::map<s32, Anm2Animation> animations;
std::map<s32, s32> layerMap; // id, index
s32 fps = 30;
s32 version = 0;
};
struct Anm2Reference
{
s32 animationID = -1;
s32 animationID = ID_NONE;
Anm2Type itemType = ANM2_NONE;
s32 itemID = -1;
s32 frameIndex = -1;
s32 itemID = ID_NONE;
s32 frameIndex = INDEX_NONE;
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_remove(Anm2* self, s32 id);
void anm2_null_add(Anm2* self);
@@ -213,9 +237,11 @@ void anm2_spritesheet_texture_load(Anm2* self, Resources* resources, const std::
Anm2Animation* anm2_animation_from_reference(Anm2* self, Anm2Reference* reference);
Anm2Item* anm2_item_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);
void anm2_frame_from_time(Anm2* self, Anm2Frame* frame, Anm2Reference reference, f32 time);
void anm2_reference_clear(Anm2Reference* self);
void anm2_reference_item_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,10 +1,10 @@
// File dialog; saving/writing to files
#include "dialog.h"
static void _dialog_callback(void* userdata, const char* const* filelist, s32 filter);
// Callback that runs during the file dialog; will get the path and determine if one has been selected
static void
_dialog_callback(void* userdata, const char* const* filelist, s32 filter)
static void _dialog_callback(void* userdata, const char* const* filelist, s32 filter)
{
Dialog* self;
@@ -19,9 +19,7 @@ _dialog_callback(void* userdata, const char* const* filelist, s32 filter)
self->isSelected = false;
}
// Initializes dialog
void
dialog_init(Dialog* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, SDL_Window* window)
void dialog_init(Dialog* self, Anm2* anm2, Anm2Reference* reference, Resources* resources, SDL_Window* window)
{
self->anm2 = anm2;
self->reference = reference;
@@ -29,41 +27,31 @@ dialog_init(Dialog* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
self->window = window;
}
// Opens file dialog to open a new anm2
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;
}
// Opens file dialog to save anm2
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;
}
// Opens file dialog to open png
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;
}
// Opens file dialog to replace a given png
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;
}
// Ticks dialog
void
dialog_tick(Dialog* self)
void dialog_tick(Dialog* self)
{
if (self->isSelected)
{

View File

@@ -26,12 +26,12 @@ enum DialogType
struct Dialog
{
Anm2* anm2 = NULL;
Anm2Reference* reference = NULL;
Resources* resources = NULL;
SDL_Window* window = NULL;
std::string path;
s32 replaceID = -1;
Anm2* anm2 = nullptr;
Anm2Reference* reference = nullptr;
Resources* resources = nullptr;
SDL_Window* window = nullptr;
std::string path{};
s32 replaceID = ID_NONE;
DialogType type = DIALOG_NONE;
bool isSelected = false;
};

View File

@@ -1,17 +1,15 @@
// Handles the rendering of the spritesheet editor
#include "editor.h"
static s32 _editor_grid_set(Editor* self);
// Sets the editor's grid
static s32
_editor_grid_set(Editor* self)
static s32 _editor_grid_set(Editor* self)
{
std::vector<f32> vertices;
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));
/* Vertical */
// Vertical
for (s32 i = 0; i <= verticalLineCount; i++)
{
s32 x = i * self->settings->editorGridSizeX - self->settings->editorGridOffsetX;
@@ -23,7 +21,7 @@ _editor_grid_set(Editor* self)
vertices.push_back(1.0f);
}
/* Horizontal */
// Horizontal
for (s32 i = 0; i <= horizontalLineCount; i++)
{
s32 y = i * self->settings->editorGridSizeY - self->settings->editorGridOffsetY;
@@ -45,9 +43,7 @@ _editor_grid_set(Editor* self)
return (s32)vertices.size();
}
// Initializes editor
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)
{
self->anm2 = anm2;
self->reference = reference;
@@ -61,7 +57,7 @@ editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
glGenTextures(1, &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_MAG_FILTER, GL_LINEAR);
@@ -98,7 +94,7 @@ editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
glBindVertexArray(self->textureVAO);
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);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_TEXTURE_INDICES), GL_TEXTURE_INDICES, GL_STATIC_DRAW);
@@ -116,15 +112,14 @@ editor_init(Editor* self, Anm2* anm2, Anm2Reference* reference, Resources* resou
_editor_grid_set(self);
}
// Draws the editor
void
editor_draw(Editor* self)
void editor_draw(Editor* self)
{
GLuint shaderLine = self->resources->shaders[SHADER_LINE];
GLuint shaderLineDotted = self->resources->shaders[SHADER_LINE_DOTTED];
GLuint shaderTexture = self->resources->shaders[SHADER_TEXTURE];
f32 zoomFactor = PERCENT_TO_UNIT(self->settings->editorZoom);
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));
@@ -294,16 +289,12 @@ editor_draw(Editor* self)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Ticks editor
void
editor_tick(Editor* self)
void editor_tick(Editor* self)
{
self->settings->editorZoom = CLAMP(self->settings->editorZoom, EDITOR_ZOOM_MIN, EDITOR_ZOOM_MAX);
}
// Frees editor
void
editor_free(Editor* self)
void editor_free(Editor* self)
{
glDeleteTextures(1, &self->texture);
glDeleteFramebuffers(1, &self->fbo);

View File

@@ -3,6 +3,7 @@
#include "anm2.h"
#include "resources.h"
#include "settings.h"
#include "canvas.h"
#define EDITOR_ZOOM_MIN 1
#define EDITOR_ZOOM_MAX 1000
@@ -12,7 +13,7 @@
#define EDITOR_GRID_OFFSET_MIN 0
#define EDITOR_GRID_OFFSET_MAX 100
const vec2 EDITOR_SIZE = {5000, 5000};
const vec2 EDITOR_SIZE = {2000, 2000};
const vec2 EDITOR_PIVOT_SIZE = {4, 4};
const vec4 EDITOR_TEXTURE_TINT = COLOR_OPAQUE;
const vec4 EDITOR_BORDER_TINT = COLOR_OPAQUE;
@@ -20,10 +21,10 @@ const vec4 EDITOR_FRAME_TINT = COLOR_RED;
struct Editor
{
Anm2* anm2 = NULL;
Anm2Reference* reference = NULL;
Resources* resources = NULL;
Settings* settings = NULL;
Anm2* anm2 = nullptr;
Anm2Reference* reference = nullptr;
Resources* resources = nullptr;
Settings* settings = nullptr;
GLuint fbo;
GLuint rbo;
GLuint gridVAO;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,132 +0,0 @@
#include "input.h"
static void _mouse_tick(Mouse* self);
// Ticks mouse
static void
_mouse_tick(Mouse* self)
{
s32 state;
std::memcpy(&self->previous, &self->current, sizeof(self->current));
std::memset(&self->current, '\0', sizeof(self->current));
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;
}
// Ticks keyboard
static void
_keyboard_tick(Keyboard* self)
{
const bool* state;
std::memcpy(&self->previous, &self->current, sizeof(self->previous));
std::memset(&self->current, '\0', sizeof(self->current));
state = SDL_GetKeyboardState(NULL);
std::memcpy(&self->current, state, KEY_COUNT);
}
// Checks to see if the given mouse button has been pressed
bool
mouse_press(Mouse* self, MouseType type)
{
return (self->current[type] && !self->previous[type]);
}
// Checks to see if the given mouse button is held
bool
mouse_held(Mouse* self, MouseType type)
{
return (self->current[type] && self->previous[type]);
}
// Checks to see if the given mouse button is released
bool
mouse_release(Mouse* self, MouseType type)
{
return (!self->current[type] && self->previous[type]);
}
// Checks to see if the given key is pressed
bool
key_press(Keyboard* self, KeyType type)
{
return (self->current[type] && !self->previous[type]);
}
// Checks to see if the given key is held
bool
key_held(Keyboard* self, KeyType type)
{
return (self->current[type] && self->previous[type]);
}
// Checks to see if the given key is released
bool
key_release(Keyboard* self, KeyType type)
{
return (!self->current[type] && self->previous[type]);
}
// Checks to see if the given input is pressed
bool
input_press(Input* self, InputType type)
{
for (KeyType key : INPUT_KEYS[type])
if (!key_press(&self->keyboard, (key)))
return false;
return true;
}
// Checks to see if the given input is held
bool
input_held(Input* self, InputType type)
{
for (KeyType key : INPUT_KEYS[type])
if (!key_held(&self->keyboard, (key)))
return false;
return true;
}
// Checks to see if the given input is held
bool
input_release(Input* self, InputType type)
{
for (size_t i = 0; i < INPUT_KEYS[type].size(); i++) {
auto& key = INPUT_KEYS[type][i];
//below is some hackery to ensure that multikey shortcuts work...
//ideally would split this into a separate function or rename this?
if (i != INPUT_KEYS[type].size()) {
if (!key_held(&self->keyboard, key)) return false;
}
// last key in the shortcut chain, so in a mod1-mod2-...-key it won't be a mod key
// todo: introduce a list of modifer keys as a more reliable solution
else if (!key_release(&self->keyboard, (key))) return false;
};
return true;
}
// Ticks input
void
input_tick(Input* self)
{
_mouse_tick(&self->mouse);
_keyboard_tick(&self->keyboard);
}

View File

@@ -1,310 +0,0 @@
#pragma once
#include "COMMON.h"
enum MouseType
{
MOUSE_LEFT,
MOUSE_RIGHT,
MOUSE_COUNT
};
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,
KEY_COUNT = 255
};
enum InputType
{
INPUT_MOD,
INPUT_DELETE,
INPUT_PLAY,
INPUT_PAN,
INPUT_MOVE,
INPUT_ROTATE,
INPUT_SCALE,
INPUT_CROP,
INPUT_LEFT,
INPUT_RIGHT,
INPUT_UP,
INPUT_DOWN,
INPUT_ZOOM_IN,
INPUT_ZOOM_OUT,
INPUT_UNDO,
INPUT_REDO,
INPUT_SAVE,
INPUT_COUNT
};
const std::vector<KeyType> INPUT_KEYS[INPUT_COUNT] =
{
{ KEY_LSHIFT },
{ KEY_DELETE },
{ KEY_SPACE },
{ KEY_P },
{ KEY_M },
{ KEY_R },
{ KEY_S },
{ KEY_C },
{ KEY_LEFT },
{ KEY_RIGHT },
{ KEY_UP },
{ KEY_DOWN },
{ KEY_1 },
{ KEY_2 },
{ KEY_Z },
{ KEY_Y },
{ KEY_LCTRL , KEY_S}
};
struct Keyboard
{
bool current[KEY_COUNT] = { 0 };
bool previous[KEY_COUNT] = { 0 };
};
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);
bool input_press(Input* self, InputType type);
bool input_held(Input* self, InputType type);
bool input_release(Input* self, InputType type);
void input_tick(Input* self);

View File

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

View File

@@ -1,15 +1,12 @@
// Handles the rendering of the animation preview
#include "preview.h"
static void _preview_axis_set(Preview* self);
static s32 _preview_grid_set(Preview* self);
// Sets the preview's axis (lines across x/y)
static void
_preview_axis_set(Preview* self)
static void _preview_axis_set(Preview* self)
{
glBindVertexArray(self->axisVAO);
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);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(f32), (void*)0);
@@ -17,16 +14,14 @@ _preview_axis_set(Preview* self)
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;
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));
/* Vertical */
// Vertical
for (s32 i = 0; i <= verticalLineCount; i++)
{
s32 x = i * self->settings->previewGridSizeX - self->settings->previewGridOffsetX;
@@ -38,7 +33,7 @@ _preview_grid_set(Preview* self)
vertices.push_back(1.0f);
}
/* Horizontal */
// Horizontal
for (s32 i = 0; i <= horizontalLineCount; i++)
{
s32 y = i * self->settings->previewGridSizeY - self->settings->previewGridOffsetY;
@@ -60,13 +55,10 @@ _preview_grid_set(Preview* self)
return (s32)vertices.size();
}
// Initializes preview
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)
{
self->anm2 = anm2;
self->reference = reference;
self->time = time;
self->resources = resources;
self->settings = settings;
@@ -77,7 +69,7 @@ preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Res
glGenTextures(1, &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_MAG_FILTER, GL_LINEAR);
@@ -118,7 +110,7 @@ preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Res
glBindVertexArray(self->textureVAO);
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);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_TEXTURE_INDICES), GL_TEXTURE_INDICES, GL_STATIC_DRAW);
@@ -137,9 +129,7 @@ preview_init(Preview* self, Anm2* anm2, Anm2Reference* reference, f32* time, Res
_preview_grid_set(self);
}
// Ticks preview
void
preview_tick(Preview* self)
void preview_tick(Preview* self)
{
self->settings->previewZoom = CLAMP(self->settings->previewZoom, PREVIEW_ZOOM_MIN, PREVIEW_ZOOM_MAX);
@@ -150,13 +140,13 @@ preview_tick(Preview* self)
{
if (self->isPlaying)
{
*self->time += (f32)self->anm2->fps / TICK_RATE;
self->time += (f32)self->anm2->fps / TICK_RATE;
// If looping, return back to 0; if not, stop at length
if (*self->time >= (f32)animation->frameNum - 1)
if (self->time >= (f32)animation->frameNum - 1)
{
if (self->settings->playbackIsLoop && !self->isRecording)
*self->time = 0.0f;
self->time = 0.0f;
else
self->isPlaying = false;
}
@@ -164,13 +154,11 @@ preview_tick(Preview* self)
// Make sure to clamp time within appropriate range
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);
}
}
// Draws preview
void
preview_draw(Preview* self)
void preview_draw(Preview* self)
{
GLuint shaderLine = self->resources->shaders[SHADER_LINE];
GLuint shaderTexture = self->resources->shaders[SHADER_TEXTURE];
@@ -263,15 +251,17 @@ preview_draw(Preview* self)
{
Anm2Frame rootFrame;
Anm2Frame frame;
anm2_frame_from_time(self->anm2, &rootFrame, Anm2Reference{animationID, ANM2_ROOT, 0, 0}, *self->time);
anm2_frame_from_time(self->anm2, &rootFrame, Anm2Reference{animationID, ANM2_ROOT, 0, 0}, self->time);
// 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)
continue;
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_LAYER, id, 0}, *self->time);
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_LAYER, id, 0}, self->time);
if (!frame.isVisible)
continue;
@@ -372,7 +362,7 @@ preview_draw(Preview* self)
if (!layerAnimation.isVisible || layerAnimation.frames.size() <= 0)
continue;
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_LAYER, id, 0}, *self->time);
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_LAYER, id, 0}, self->time);
if (!frame.isVisible)
continue;
@@ -423,7 +413,7 @@ preview_draw(Preview* self)
if (!nullAnimation.isVisible || nullAnimation.frames.size() <= 0)
continue;
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_NULL, id, 0}, *self->time);
anm2_frame_from_time(self->anm2, &frame, Anm2Reference{animationID, ANM2_NULL, id, 0}, self->time);
if (!frame.isVisible)
continue;
@@ -432,7 +422,7 @@ preview_draw(Preview* self)
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 pos = self->settings->previewIsRootTransform ? frame.position + (rootFrame.position) - (size / 2.0f) : frame.position - (size / 2.0f);
@@ -494,12 +484,11 @@ preview_draw(Preview* self)
}
}
// Manage recording
/*
if (self->isRecording && animation)
{
if (recordFrameIndex == 0)
{
// Create frames directory, if it exists
if
(
std::filesystem::exists(STRING_PREVIEW_FRAMES_DIRECTORY) &&
@@ -548,27 +537,27 @@ preview_draw(Preview* self)
}
else
{
if (*self->time >= (f32)animation->frameNum - 1)
if (self->time >= (f32)animation->frameNum - 1)
{
self->isRecording = false;
self->isPlaying = false;
recordFrameIndex = 0;
recordFrameTimeNext = 0;
*self->time = 0.0f;
self->time = 0.0f;
}
else if (*self->time >= recordFrameTimeNext)
else if (self->time >= recordFrameTimeNext)
{
isRecordThisFrame = true;
recordFrameTimeNext = *self->time + (f32)self->anm2->fps / TICK_RATE;
recordFrameTimeNext = self->time + (f32)self->anm2->fps / TICK_RATE;
}
}
}
*/
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void
preview_free(Preview* self)
void preview_free(Preview* self)
{
glDeleteTextures(1, &self->texture);
glDeleteFramebuffers(1, &self->fbo);

View File

@@ -2,13 +2,12 @@
#include "anm2.h"
#include "resources.h"
#include "input.h"
#include "settings.h"
#include "canvas.h"
const vec2 PREVIEW_SIZE = {5000, 5000};
const vec2 PREVIEW_SIZE = {2000, 2000};
const vec2 PREVIEW_CENTER = {0, 0};
#define PREVIEW_ZOOM_MIN 1
#define PREVIEW_ZOOM_MAX 1000
#define PREVIEW_ZOOM_STEP 25
@@ -16,20 +15,6 @@ const vec2 PREVIEW_CENTER = {0, 0};
#define PREVIEW_GRID_MAX 1000
#define PREVIEW_GRID_OFFSET_MIN 0
#define PREVIEW_GRID_OFFSET_MAX 100
#define PREVIEW_MOVE_STEP 1
#define PREVIEW_MOVE_STEP_MOD 10
#define PREVIEW_ROTATE_STEP 1
#define PREVIEW_ROTATE_STEP_MOD 10
#define PREVIEW_SCALE_STEP 1
#define PREVIEW_SCALE_STEP_MOD 10
const f32 PREVIEW_AXIS_VERTICES[] =
{
-1.0f, 0.0f,
1.0f, 0.0f,
0.0f, -1.0f,
0.0f, 1.0f
};
const vec2 PREVIEW_NULL_RECT_SIZE = {100, 100};
const vec2 PREVIEW_POINT_SIZE = {2, 2};
@@ -41,30 +26,29 @@ const vec2 PREVIEW_TARGET_SIZE = {16, 16};
struct Preview
{
Anm2* anm2 = NULL;
Anm2Reference* reference = NULL;
f32* time = NULL;
Input* input = NULL;
Resources* resources = NULL;
Settings* settings = NULL;
GLuint axisVAO;
GLuint axisVBO;
GLuint fbo;
GLuint gridVAO;
GLuint gridVBO;
GLuint rbo;
GLuint texture;
GLuint rectVAO;
GLuint rectVBO;
GLuint textureEBO;
GLuint textureVAO;
GLuint textureVBO;
Anm2* anm2 = nullptr;
Anm2Reference* reference = nullptr;
Resources* resources = nullptr;
Settings* settings = nullptr;
GLuint axisVAO = ID_NONE;
GLuint axisVBO = ID_NONE;
GLuint fbo = ID_NONE;
GLuint gridVAO = ID_NONE;
GLuint gridVBO = ID_NONE;
GLuint rbo = ID_NONE;
GLuint texture = ID_NONE;
GLuint rectVAO = ID_NONE;
GLuint rectVBO = ID_NONE;
GLuint textureEBO = ID_NONE;
GLuint textureVAO = ID_NONE;
GLuint textureVBO = ID_NONE;
bool isPlaying = 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_tick(Preview* self);
void preview_free(Preview* self);

View File

@@ -1,48 +1,39 @@
#include "resources.h"
// Loads a texture, given a path and an id for it to be assigned to
void
resources_texture_init(Resources* resources, const std::string& path, s32 id)
void resources_texture_init(Resources* resources, const std::string& path, s32 id)
{
Texture texture;
if (resources->textures.find(id) != resources->textures.end() && resources->textures[id].id != resources->textures[TEXTURE_ERROR].id)
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))
resources->textures[id] = texture;
else
texture.isInvalid = true;
if (!texture_from_path_init(&texture, path))
texture.isInvalid = true;
resources->textures[id] = texture;
resources->textures[id] = texture;
}
// Loads in resources
void
resources_init(Resources* self)
void resources_init(Resources* self)
{
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);
}
// Frees resources
void
resources_free(Resources* self)
void resources_free(Resources* 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]);
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]);
log_info(RESOURCES_TEXTURES_FREE_INFO);
}

View File

@@ -4,6 +4,8 @@
#include "texture.h"
#include "shader.h"
#define RESOURCES_TEXTURES_FREE_INFO "Freed texture resources"
struct Resources
{
GLuint shaders[SHADER_COUNT];

View File

@@ -1,23 +1,17 @@
#include "settings.h"
static void _settings_setting_load(Settings* self, const std::string& line);
static void _settings_setting_write(Settings* self, std::ostream& out, SettingsEntry entry);
static void
_settings_setting_load(Settings* self, const std::string& line)
static void _settings_setting_load(Settings* self, const std::string& line)
{
for (s32 i = 0; i < SETTINGS_COUNT; i++)
{
const std::string& key = SETTINGS_ENTRIES[i].key;
size_t keyLength = key.length();
// Compare keys
if (line.compare(0, keyLength, key) == 0)
{
const char* value = line.c_str() + keyLength;
void* target = (u8*)self + SETTINGS_ENTRIES[i].offset;
// Based on type, assign value to offset of settings
switch (SETTINGS_ENTRIES[i].type)
{
case SETTINGS_TYPE_INT:
@@ -40,9 +34,7 @@ _settings_setting_load(Settings* self, const std::string& line)
}
}
// Writes a given setting to the stream
static void
_settings_setting_write(Settings* self, std::ostream& out, SettingsEntry entry)
static void _settings_setting_write(Settings* self, std::ostream& out, SettingsEntry entry)
{
u8* selfPointer = (u8*)self;
std::string value;
@@ -68,60 +60,51 @@ _settings_setting_write(Settings* self, std::ostream& out, SettingsEntry entry)
out << entry.key << value << "\n";
}
// Saves the current settings
// Note: this is just for this program's settings, additional imgui settings handled elsewhere
void
settings_save(Settings* self)
void settings_save(Settings* self)
{
std::ifstream input(PATH_SETTINGS);
std::ifstream input(SETTINGS_PATH);
std::string oldContents;
if (!input)
{
std::cout << STRING_ERROR_SETTINGS_INIT << PATH_SETTINGS << std::endl;
log_error(std::format(SETTINGS_INIT_ERROR, SETTINGS_PATH));
return;
}
// We're writing after the imgui stuff
oldContents.assign((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
input.close();
std::ofstream output(PATH_SETTINGS);
std::ofstream output(SETTINGS_PATH);
if (!output)
{
std::cout << STRING_ERROR_SETTINGS_INIT << PATH_SETTINGS << std::endl;
log_error(std::format(SETTINGS_INIT_ERROR, SETTINGS_PATH));
return;
}
// [Settings]
output << SETTINGS_SECTION << "\n";
// Write each setting
for (s32 i = 0; i < SETTINGS_COUNT; i++)
_settings_setting_write(self, output, SETTINGS_ENTRIES[i]);
// Write the the imgui section
output << "\n" << SETTINGS_SECTION_IMGUI << "\n";
output << oldContents;
output.close();
}
// Load settings
void
settings_load(Settings* self)
void settings_init(Settings* self)
{
std::ifstream file(PATH_SETTINGS);
std::ifstream file(SETTINGS_PATH);
if (!file)
{
std::cerr << STRING_ERROR_SETTINGS_INIT << PATH_SETTINGS << std::endl;
log_error(std::format(SETTINGS_INIT_ERROR, SETTINGS_PATH));
return;
}
std::string line;
bool inSettingsSection = false;
// Iterare through settings lines until the imgui section is reached, then end
while (std::getline(file, line))
{
if (line == SETTINGS_SECTION)
@@ -130,10 +113,7 @@ settings_load(Settings* self)
continue;
}
if (line == SETTINGS_SECTION_IMGUI)
break;
if (inSettingsSection)
_settings_setting_load(self, line);
if (line == SETTINGS_SECTION_IMGUI) break;
if (inSettingsSection) _settings_setting_load(self, line);
}
}

View File

@@ -6,6 +6,8 @@
#define SETTINGS_BUFFER_ITEM 0xFF
#define SETTINGS_SECTION "[Settings]"
#define SETTINGS_SECTION_IMGUI "# Dear ImGui"
#define SETTINGS_INIT_ERROR "Failed to read settings file! ({})"
#define SETTINGS_PATH "settings.ini"
enum SettingsValueType
{
@@ -22,7 +24,6 @@ struct SettingsEntry
s32 offset;
};
#define SETTINGS_COUNT 44
struct Settings
{
s32 windowW = 1920;
@@ -69,9 +70,13 @@ struct Settings
f32 editorBackgroundColorG = 0.184f;
f32 editorBackgroundColorB = 0.286f;
f32 editorBackgroundColorA = 1.0f;
f32 toolColorR = 1.0f;
f32 toolColorG = 1.0f;
f32 toolColorB = 1.0f;
f32 toolColorA = 1.0f;
};
const SettingsEntry SETTINGS_ENTRIES[SETTINGS_COUNT] =
const SettingsEntry SETTINGS_ENTRIES[] =
{
{"windowW=", SETTINGS_TYPE_INT, offsetof(Settings, windowW)},
{"windowH=", SETTINGS_TYPE_INT, offsetof(Settings, windowH)},
@@ -116,8 +121,13 @@ const SettingsEntry SETTINGS_ENTRIES[SETTINGS_COUNT] =
{"editorBackgroundColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorR)},
{"editorBackgroundColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorG)},
{"editorBackgroundColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorB)},
{"editorBackgroundColorA=", 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_load(Settings* self);
void settings_init(Settings* self);

View File

@@ -1,25 +1,21 @@
#include "shader.h"
static bool _shader_compile(GLuint* self, const std::string& text);
// Compiles the shader; returns true/false based on success
static bool
_shader_compile(GLuint* self, const std::string& text)
static bool _shader_compile(GLuint* self, const std::string& text)
{
std::string compileLog;
s32 isCompile;
const GLchar* source = text.c_str();
glShaderSource(*self, 1, &source, NULL);
glShaderSource(*self, 1, &source, nullptr);
glCompileShader(*self);
glGetShaderiv(*self, GL_COMPILE_STATUS, &isCompile);
if (!isCompile)
{
glGetShaderInfoLog(*self, SHADER_INFO_LOG_MAX, NULL, &compileLog[0]);
std::cout << STRING_ERROR_SHADER_INIT << *self << std::endl << compileLog << std::endl;
glGetShaderInfoLog(*self, SHADER_INFO_LOG_MAX, nullptr, &compileLog[0]);
log_error(std::format(SHADER_INIT_ERROR, *self, compileLog));
return false;
}
@@ -27,8 +23,7 @@ _shader_compile(GLuint* self, const std::string& text)
}
// Initializes a given shader with vertex/fragment
bool
shader_init(GLuint* self, const std::string& vertex, const std::string& fragment)
bool shader_init(GLuint* self, const std::string& vertex, const std::string& fragment)
{
GLuint vertexHandle;
GLuint fragmentHandle;
@@ -36,11 +31,7 @@ shader_init(GLuint* self, const std::string& vertex, const std::string& fragment
vertexHandle = glCreateShader(GL_VERTEX_SHADER);
fragmentHandle = glCreateShader(GL_FRAGMENT_SHADER);
if
(
!_shader_compile(&vertexHandle, vertex) ||
!_shader_compile(&fragmentHandle, fragment)
)
if (!_shader_compile(&vertexHandle, vertex) || !_shader_compile(&fragmentHandle, fragment))
return false;
*self = glCreateProgram();
@@ -56,9 +47,7 @@ shader_init(GLuint* self, const std::string& vertex, const std::string& fragment
return true;
}
// Frees a given shader
void
shader_free(GLuint* self)
void shader_free(GLuint* self)
{
glDeleteProgram(*self);
}

View File

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

View File

@@ -1,112 +1,62 @@
#include "snapshots.h"
// Pushes the undo stack
void
snapshots_undo_stack_push(Snapshots* self, Snapshot* snapshot)
static void _snapshot_stack_push(SnapshotStack* stack, const Snapshot* snapshot)
{
// If stack over the limit, shift it
if (self->undoStack.top >= SNAPSHOT_STACK_MAX)
if (stack->top >= SNAPSHOT_STACK_MAX)
{
for (s32 i = 0; i < SNAPSHOT_STACK_MAX - 1; i++)
self->undoStack.snapshots[i] = self->undoStack.snapshots[i + 1];
self->undoStack.top = SNAPSHOT_STACK_MAX - 1;
stack->snapshots[i] = stack->snapshots[i + 1];
stack->top = SNAPSHOT_STACK_MAX - 1;
}
self->undoStack.snapshots[self->undoStack.top++] = *snapshot;
self->redoStack.top = 0;
stack->snapshots[stack->top++] = *snapshot;
}
// Pops the undo stack
bool
snapshots_undo_stack_pop(Snapshots* self, Snapshot* snapshot)
static bool _snapshot_stack_pop(SnapshotStack* stack, Snapshot* snapshot)
{
if (self->undoStack.top == 0)
return false;
*snapshot = self->undoStack.snapshots[--self->undoStack.top];
if (stack->top == 0) return false;
*snapshot = stack->snapshots[--stack->top];
return true;
}
// Pushes the redo stack
void
snapshots_redo_stack_push(Snapshots* self, Snapshot* snapshot)
static void _snapshot_set(Snapshots* self, const Snapshot& snapshot)
{
if (self->redoStack.top >= SNAPSHOT_STACK_MAX)
{
for (s32 i = 0; i < SNAPSHOT_STACK_MAX - 1; i++)
self->redoStack.snapshots[i] = self->redoStack.snapshots[i + 1];
self->redoStack.top = SNAPSHOT_STACK_MAX - 1;
}
self->redoStack.snapshots[self->redoStack.top++] = *snapshot;
*self->anm2 = snapshot.anm2;
*self->reference = snapshot.reference;
self->preview->time = snapshot.time;
}
// Pops the redo stack
bool
snapshots_redo_stack_pop(Snapshots* self, Snapshot* snapshot)
{
if (self->redoStack.top == 0)
return false;
*snapshot = self->redoStack.snapshots[--self->redoStack.top];
return true;
}
// Initializes snapshots
void
snapshots_init(Snapshots* self, Anm2* anm2, Anm2Reference* reference, f32* time, Input* input)
void snapshots_init(Snapshots* self, Anm2* anm2, Anm2Reference* reference, Preview* preview)
{
self->anm2 = anm2;
self->reference = reference;
self->time = time;
self->input = input;
self->preview = preview;
}
// Ticks snapshots
void
snapshots_tick(Snapshots* self)
void snapshots_undo_stack_push(Snapshots* self, const Snapshot* snapshot)
{
/* Undo */
if (input_press(self->input, INPUT_UNDO))
self->isUndo = true;
// isUndo disconnected, if another part of the program wants to set it
if (self->isUndo)
_snapshot_stack_push(&self->undoStack, snapshot);
self->redoStack.top = 0;
}
void snapshots_undo(Snapshots* self)
{
Snapshot snapshot;
if (_snapshot_stack_pop(&self->undoStack, &snapshot))
{
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;
*self->reference = snapshot.reference;
*self->time = snapshot.time;
}
self->isUndo = false;
Snapshot current = {*self->anm2, *self->reference, self->preview->time};
_snapshot_stack_push(&self->redoStack, &current);
_snapshot_set(self, snapshot);
}
}
/* Redo */
if (input_press(self->input, INPUT_REDO))
self->isRedo = true;
// isRedo disconnected, if another part of the program wants to set it
if (self->isRedo)
void snapshots_redo(Snapshots* self)
{
Snapshot snapshot;
if (_snapshot_stack_pop(&self->redoStack, &snapshot))
{
Snapshot snapshot;
if (snapshots_redo_stack_pop(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;
}
self->isRedo = false;
Snapshot current = {*self->anm2, *self->reference, self->preview->time};
_snapshot_stack_push(&self->undoStack, &current);
_snapshot_set(self, snapshot);
}
}

View File

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

View File

@@ -1,182 +1,133 @@
#include "state.h"
static void _tick(State* state);
static void _draw(State* state);
static void
_tick(State* state)
static void _tick(State* self)
{
SDL_Event event;
SDL_MouseWheelEvent* mouseWheelEvent;
SDL_GetWindowSize(self->window, &self->settings.windowW, &self->settings.windowH);
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))
{
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);
if (input_release(&state->input, INPUT_SAVE))
{
// Open dialog if path empty, otherwise save in-place
if (state->anm2.path.empty())
dialog_anm2_save(&state->dialog);
else
anm2_serialize(&state->anm2, state->anm2.path);
}
if (input_release(&state->input, INPUT_PLAY))
{
state->preview.isPlaying = !state->preview.isPlaying;
state->preview.isRecording = false;
}
if (self->imgui.isQuit) self->isRunning = false;
}
static void
_draw(State* state)
static void _draw(State* self)
{
editor_draw(&state->editor);
preview_draw(&state->preview);
editor_draw(&self->editor);
preview_draw(&self->preview);
imgui_draw();
SDL_GL_SwapWindow(state->window);
SDL_GL_SwapWindow(self->window);
}
void
init(State* state)
void init(State* self)
{
settings_load(&state->settings);
settings_init(&self->settings);
std::cout << STRING_INFO_INIT << std::endl;
log_info(STATE_INIT_INFO);
if (!SDL_Init(SDL_INIT_VIDEO))
{
std::cout << STRING_ERROR_SDL_INIT << SDL_GetError() << std::endl;
quit(state);
log_error(std::format(STATE_SDL_INIT_ERROR, SDL_GetError()));
quit(self);
}
log_info(STATE_SDL_INIT_INFO);
SDL_CreateWindowAndRenderer
(
STRING_WINDOW_TITLE,
state->settings.windowW,
state->settings.windowH,
WINDOW_TITLE,
self->settings.windowW,
self->settings.windowH,
WINDOW_FLAGS,
&state->window,
&state->renderer
&self->window,
&self->renderer
);
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_MINOR_VERSION, 3);
state->glContext = SDL_GL_CreateContext(state->window);
glewInit();
if (!state->glContext)
self->glContext = SDL_GL_CreateContext(self->window);
if (!self->glContext)
{
std::cout << STRING_ERROR_GL_CONTEXT_INIT << SDL_GetError() << std::endl;
quit(state);
log_error(std::format(STATE_GL_CONTEXT_INIT_ERROR, SDL_GetError()));
quit(self);
}
std::cout << STRING_INFO_SDL_INIT << "(" << STRING_INFO_OPENGL << glGetString(GL_VERSION) << ")" << std::endl;
glewInit();
log_info(std::format(STATE_GL_CONTEXT_INIT_INFO, (const char*)glGetString(GL_VERSION)));
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glLineWidth(LINE_WIDTH);
glLineWidth(STATE_GL_LINE_WIDTH);
std::cout << STRING_INFO_GLEW_INIT << std::endl;
resources_init(&state->resources);
dialog_init(&state->dialog, &state->anm2, &state->reference, &state->resources, state->window);
tool_init(&state->tool, &state->input);
snapshots_init(&state->snapshots, &state->anm2, &state->reference, &state->time, &state->input);
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);
resources_init(&self->resources);
clipboard_init(&self->clipboard, &self->anm2);
dialog_init(&self->dialog, &self->anm2, &self->reference, &self->resources, self->window);
snapshots_init(&self->snapshots, &self->anm2, &self->reference, &self->preview);
preview_init(&self->preview, &self->anm2, &self->reference, &self->resources, &self->settings);
editor_init(&self->editor, &self->anm2, &self->reference, &self->resources, &self->settings);
imgui_init
(
&state->imgui,
&state->dialog,
&state->resources,
&state->input,
&state->anm2,
&state->reference,
&state->time,
&state->editor,
&state->preview,
&state->settings,
&state->tool,
&state->snapshots,
state->window,
&state->glContext
&self->imgui,
&self->dialog,
&self->resources,
&self->anm2,
&self->reference,
&self->editor,
&self->preview,
&self->settings,
&self->snapshots,
&self->clipboard,
self->window,
&self->glContext
);
if (state->isArgument)
if (self->is_argument())
{
anm2_deserialize(&state->anm2, &state->resources, state->argument);
window_title_from_path_set(state->window, state->argument);
anm2_deserialize(&self->anm2, &self->resources, self->argument);
window_title_from_path_set(self->window, self->argument);
}
else
anm2_new(&state->anm2);
anm2_new(&self->anm2);
}
void
loop(State* state)
void loop(State* self)
{
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)
SDL_Delay(TICK_DELAY - (state->tick - state->lastTick));
if (self->tick - self->lastTick < TICK_DELAY)
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
quit(State* state)
void quit(State* self)
{
imgui_free();
settings_save(&state->settings);
preview_free(&state->preview);
editor_free(&state->editor);
resources_free(&state->resources);
settings_save(&self->settings);
preview_free(&self->preview);
editor_free(&self->editor);
resources_free(&self->resources);
SDL_GL_DestroyContext(state->glContext);
SDL_GL_DestroyContext(self->glContext);
SDL_Quit();
std::cout << STRING_INFO_QUIT << std::endl;
}
log_info(STATE_QUIT_INFO);
}

View File

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

View File

@@ -5,75 +5,55 @@
#define STBI_NO_HDR
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
// Generates GL texture and sets parameters
void
texture_gl_set(Texture* self, void* data)
void texture_gl_set(Texture* self, void* data)
{
glGenTextures(1, &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);
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_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, 0);
}
// Initializes texture from path; returns true/false on success
bool
texture_from_path_init(Texture* self, const std::string& path)
bool texture_from_path_init(Texture* self, const std::string& path)
{
void* data;
data = stbi_load(path.c_str(), &self->size.x, &self->size.y, &self->channels, 4);
void* data = stbi_load(path.c_str(), &self->size.x, &self->size.y, &self->channels, TEXTURE_CHANNELS);
if (!data)
{
std::cout << STRING_ERROR_TEXTURE_INIT << path << std::endl;
log_error(std::format(TEXTURE_INIT_ERROR, path));
return false;
}
std::cout << STRING_INFO_TEXTURE_INIT << path << std::endl;
log_info(std::format(TEXTURE_INIT_INFO, path));
texture_gl_set(self, data);
return true;
}
// Initializes texture from data; returns true/false on success
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* 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);
return true;
}
// Writes an image to the path from the data/size
bool
texture_from_data_write(const std::string& path, const u8* data, s32 width, s32 height)
bool texture_from_data_write(const std::string& path, const u8* data, s32 width, s32 height)
{
return (bool)stbi_write_png(path.c_str(), width, height, 4, data, width * 4);
return (bool)stbi_write_png(path.c_str(), width, height, TEXTURE_CHANNELS, data, width * TEXTURE_CHANNELS);
}
// Frees texture
void
texture_free(Texture* self)
void texture_free(Texture* self)
{
glDeleteTextures(1, &self->id);
*self = Texture{};

View File

@@ -2,6 +2,10 @@
#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
{
GLuint id = 0;

View File

@@ -1,31 +0,0 @@
#include "tool.h"
// Initializes tools
void
tool_init(Tool* self, Input* input)
{
self->input = input;
}
// Ticks tools
void
tool_tick(Tool* self)
{
if (!self->isEnabled) return;
// Input handling for tools
if (input_release(self->input, INPUT_PAN))
self->type = TOOL_PAN;
if (input_release(self->input, INPUT_MOVE))
self->type = TOOL_MOVE;
if (input_release(self->input, INPUT_SCALE))
self->type = TOOL_SCALE;
if (input_release(self->input, INPUT_ROTATE))
self->type = TOOL_ROTATE;
if (input_release(self->input, INPUT_CROP))
self->type = TOOL_CROP;
}

View File

@@ -1,23 +0,0 @@
#pragma once
#include "input.h"
enum ToolType
{
TOOL_PAN,
TOOL_MOVE,
TOOL_ROTATE,
TOOL_SCALE,
TOOL_CROP,
TOOL_COUNT
};
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"
/* 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 std::string& path)
{
if (path.empty())
{
std::string windowTitle = path;
windowTitle = windowTitle + " (" + path + ")";
SDL_SetWindowTitle(self, windowTitle.c_str());
}
if (!path.empty())
SDL_SetWindowTitle(self, std::format(WINDOW_TITLE_FORMAT, path).c_str());
else
SDL_SetWindowTitle(self, STRING_WINDOW_TITLE);
SDL_SetWindowTitle(self, WINDOW_TITLE);
}

View File

@@ -2,4 +2,10 @@
#include "COMMON.h"
#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 std::string& path);