Change clipboard system entirely, refactored anm2 serializing/deserializing, quick shell script for atlas update

This commit is contained in:
2025-09-11 17:18:27 -04:00
parent b0e52bd444
commit 6deaaea374
11 changed files with 842 additions and 798 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

66
assets/atlas_data_write.sh Executable file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env bash
set -euo pipefail
INPUT="atlas.png"
OUTPUT="../src/PACKED.h"
TMP="atlas.bytes"
# Ensure deps
command -v optipng >/dev/null 2>&1 || { echo "error: optipng not found in PATH" >&2; exit 1; }
command -v xxd >/dev/null 2>&1 || { echo "error: xxd not found in PATH" >&2; exit 1; }
# 1) Optimize PNG in place
optipng -o7 "$INPUT" >/dev/null
# 2) Extract ONLY the bytes from xxd -i (between '= {' and '};')
# Using awk avoids the earlier '{' vs '= {' mismatch bug.
xxd -i "$INPUT" \
| awk '
/= *\{/ {inside=1; next}
inside && /};/ {inside=0; exit}
inside {print}
' > "$TMP"
# Sanity check: make sure we got something
if ! [ -s "$TMP" ]; then
echo "error: failed to extract bytes from xxd output" >&2
exit 1
fi
# 3) Replace ONLY the bytes inside TEXTURE_ATLAS[] initializer
# - Find the exact declaration line for TEXTURE_ATLAS
# - Print that line
# - On the following line with just '{', print it, then insert bytes,
# then skip everything until the matching '};' and print that once.
awk -v tmpfile="$TMP" '
BEGIN { state=0 } # 0=normal, 1=after decl waiting for {, 2=skipping old bytes until };
# Match the TEXTURE_ATLAS declaration line precisely
$0 ~ /^[[:space:]]*const[[:space:]]+u8[[:space:]]+TEXTURE_ATLAS\[\][[:space:]]*=/ {
print; state=1; next
}
# After the decl, the next line with a lone "{" starts the initializer
state==1 && $0 ~ /^[[:space:]]*{[[:space:]]*$/ {
print # print the opening brace line
while ((getline line < tmpfile) > 0) print line # insert fresh bytes
close(tmpfile)
state=2 # now skip old initializer content until we hit the closing "};"
next
}
# While skipping, suppress lines until the closing "};", which we reprint once
state==2 {
if ($0 ~ /^[[:space:]]*};[[:space:]]*$/) {
print # print the closing brace+semicolon
state=0
}
next
}
# Default: pass through unchanged
{ print }
' "$OUTPUT" > "$OUTPUT.tmp" && mv "$OUTPUT.tmp" "$OUTPUT"
rm -f "$TMP"
echo "Updated $OUTPUT with optimized bytes from $INPUT."

View File

@@ -44,6 +44,7 @@ typedef double f64;
#define TAU (PI * 2)
using namespace glm;
using namespace tinyxml2;
#define PREFERENCES_DIRECTORY "anm2ed"
@@ -203,11 +204,6 @@ static inline bool path_is_valid(const std::filesystem::path& pathCheck)
return isValid;
}
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++)
@@ -326,12 +322,6 @@ static inline mat4 quad_model_parent_get(vec2 position = {}, vec2 pivot = {}, ve
return glm::translate(mat4(1.0f), vec3(position, 0.0f)) * local;
}
#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) \
{ \

View File

@@ -1,5 +1,3 @@
// Includes packed resources (i.e., textures, shaders)
#pragma once
#include "COMMON.h"
@@ -11,100 +9,110 @@ const u8 TEXTURE_ATLAS[] =
0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x5e, 0x74, 0xbf, 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, 0xff, 0xff, 0xff, 0x60, 0x60, 0x60, 0xff,
0xff, 0xff, 0x60, 0x60, 0x60, 0x15, 0x68, 0x14, 0xc2, 0x00, 0x00, 0x00,
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, 0x17, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x96,
0x0d, 0x6e, 0xe3, 0x3a, 0x0c, 0x84, 0x07, 0x18, 0x9e, 0xe0, 0xdd, 0xe0,
0xdd, 0x80, 0xc0, 0xf0, 0x00, 0x04, 0xc4, 0xfb, 0x9f, 0x69, 0x61, 0xc9,
0x82, 0xbc, 0x75, 0xda, 0xd8, 0x1b, 0xb4, 0x01, 0x16, 0x3b, 0x40, 0x2b,
0xd1, 0xd1, 0x17, 0xfe, 0x88, 0xb2, 0x82, 0x3f, 0x91, 0x84, 0x87, 0xa2,
0xa3, 0xab, 0x45, 0x5f, 0x75, 0x58, 0x2f, 0xf5, 0x21, 0x29, 0xe5, 0x61,
0xbd, 0xe4, 0x87, 0x2f, 0x54, 0x05, 0x60, 0xfd, 0x39, 0x20, 0x07, 0x3b,
0x39, 0x96, 0x34, 0x49, 0x60, 0x37, 0x17, 0x50, 0x14, 0xc0, 0xdd, 0x95,
0xd4, 0xa7, 0x6b, 0x85, 0x44, 0x75, 0xf9, 0x0a, 0x89, 0x0a, 0xd3, 0x00,
0x28, 0xe1, 0xb0, 0xc0, 0x1c, 0x38, 0xda, 0xf4, 0x1d, 0x90, 0x34, 0x2c,
0x39, 0x9d, 0x3d, 0x7a, 0x5b, 0x0b, 0x56, 0x48, 0x27, 0x80, 0x02, 0x9d,
0xe8, 0x72, 0xfa, 0x58, 0x60, 0xd5, 0xa4, 0xa8, 0xfc, 0x1d, 0x88, 0x6e,
0xc9, 0x8f, 0x40, 0xa0, 0x65, 0x07, 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0x54, 0x58, 0xc3, 0xed, 0x58,
0x5b, 0x92, 0xdc, 0x36, 0x0c, 0xec, 0x0a, 0x70, 0x80, 0x1c, 0x21, 0x95,
0x13, 0xa0, 0x0c, 0x1e, 0x00, 0x65, 0xf4, 0xfd, 0xcf, 0xe4, 0x0f, 0x10,
0x14, 0xe7, 0xb1, 0x3b, 0xd2, 0x3a, 0xbb, 0x76, 0xb9, 0xc2, 0x8f, 0x91,
0x38, 0x62, 0x0b, 0x00, 0xd9, 0x68, 0x50, 0x04, 0x3e, 0xd0, 0xc8, 0xe7,
0xff, 0x6b, 0xd4, 0x75, 0x24, 0x00, 0x70, 0x1b, 0x4f, 0x02, 0x20, 0x4d,
0x49, 0xdb, 0xc6, 0x93, 0xb1, 0xbd, 0x90, 0x9e, 0x80, 0x00, 0x50, 0x02,
0x0c, 0x68, 0x21, 0x03, 0x00, 0x06, 0x49, 0xe8, 0xea, 0x16, 0xc0, 0x95,
0x80, 0x4e, 0x53, 0x64, 0xdd, 0xae, 0x11, 0xa4, 0x92, 0x8d, 0x98, 0x2e,
0x29, 0x53, 0x58, 0x00, 0xed, 0x17, 0xd6, 0x00, 0x89, 0x72, 0xa8, 0xfb,
0x15, 0x4b, 0xbd, 0xa2, 0x7a, 0x0c, 0x0d, 0x35, 0xac, 0xb1, 0x81, 0x46,
0x04, 0x9e, 0x01, 0x94, 0xd0, 0xd0, 0x8a, 0x34, 0x34, 0x6a, 0x80, 0xf8,
0x20, 0xd3, 0xed, 0x16, 0x90, 0x80, 0x06, 0x18, 0x3b, 0x20, 0x31, 0x0c,
0x80, 0xb8, 0x8f, 0x74, 0x37, 0x40, 0x6a, 0xee, 0x38, 0x8c, 0x0c, 0x40,
0x43, 0x89, 0x0d, 0x20, 0x9c, 0x33, 0x2e, 0xee, 0xee, 0x06, 0x60, 0x84,
0x66, 0xc5, 0x3a, 0xa3, 0x67, 0x00, 0x35, 0x4b, 0x00, 0x02, 0x0d, 0x30,
0x77, 0x37, 0x33, 0x21, 0x01, 0xd2, 0x8e, 0x85, 0xab, 0x55, 0x3b, 0x00,
0x83, 0x09, 0x00, 0x22, 0x22, 0x2e, 0x02, 0x65, 0x00, 0xca, 0x38, 0x00,
0xbd, 0x70, 0x3d, 0x4b, 0x3a, 0xd7, 0x17, 0x66, 0x66, 0xf6, 0x04, 0x30,
0xa9, 0x21, 0x35, 0xef, 0x76, 0x90, 0x46, 0x44, 0x00, 0x08, 0xad, 0x7e,
0xf8, 0x9a, 0x7c, 0x30, 0x7c, 0x51, 0x6b, 0x9a, 0xcb, 0x9d, 0x45, 0xb9,
0x21, 0xf7, 0xd1, 0x6f, 0x9a, 0xdf, 0x3f, 0xef, 0xbc, 0x18, 0x2c, 0x0a,
0x38, 0x49, 0xfa, 0xc1, 0x29, 0x99, 0x73, 0x82, 0xbb, 0xe9, 0x45, 0x02,
0xc0, 0x00, 0x06, 0x01, 0xe6, 0x62, 0xad, 0x0c, 0xba, 0x33, 0xed, 0x30,
0x45, 0x77, 0x27, 0x81, 0x22, 0x28, 0x40, 0xab, 0x3c, 0x69, 0x40, 0x3d,
0xb7, 0x65, 0x4a, 0xe8, 0x3e, 0x48, 0x6b, 0x80, 0x54, 0x9e, 0x58, 0x21,
0xbe, 0x03, 0xf5, 0x1c, 0x80, 0xa6, 0xfb, 0x08, 0x68, 0xba, 0x33, 0x47,
0x34, 0xa0, 0xf3, 0xa4, 0x69, 0xbe, 0x9e, 0x4b, 0x8e, 0x91, 0x39, 0x4c,
0xd3, 0x07, 0x7d, 0x04, 0x02, 0x1a, 0x05, 0x50, 0x42, 0x63, 0xd2, 0xfc,
0xdb, 0x7a, 0x4e, 0x53, 0x8d, 0x10, 0x8e, 0x70, 0xa6, 0x6b, 0x16, 0x40,
0x56, 0x9e, 0x14, 0xcd, 0xbf, 0xfd, 0xab, 0xe9, 0x4c, 0x1f, 0x01, 0x09,
0x35, 0x09, 0x35, 0x4d, 0x25, 0xd0, 0x2e, 0x1d, 0x79, 0x02, 0x73, 0x77,
0xfc, 0xf5, 0x8f, 0xc6, 0xa0, 0x43, 0x03, 0x50, 0x90, 0x08, 0x08, 0x99,
0xee, 0x33, 0x68, 0x12, 0x42, 0x06, 0x9c, 0xa6, 0x92, 0x62, 0xd5, 0x4f,
0x73, 0x02, 0x90, 0x04, 0x86, 0x01, 0xa4, 0xbb, 0xd7, 0xb4, 0xea, 0xc8,
0x00, 0x09, 0x71, 0x1a, 0x68, 0x36, 0xfb, 0x26, 0x4e, 0xab, 0xa5, 0x4d,
0x00, 0x4a, 0xf7, 0xb9, 0x70, 0xa9, 0x31, 0x30, 0x08, 0x67, 0x3a, 0x28,
0x5b, 0x3f, 0xfc, 0x19, 0x35, 0x4c, 0x4d, 0xa2, 0xa8, 0x01, 0x53, 0x7c,
0xff, 0x5b, 0x4d, 0x42, 0x40, 0x92, 0x37, 0xfc, 0xdb, 0xc8, 0x45, 0x56,
0xdf, 0x7d, 0xcf, 0x98, 0xa3, 0xff, 0x51, 0xbe, 0xf7, 0xf5, 0x74, 0x7d,
0x98, 0xd7, 0xe9, 0x9a, 0x06, 0x35, 0x78, 0x5c, 0x01, 0x00, 0xa5, 0x84,
0x2d, 0xa1, 0x9b, 0x76, 0xa3, 0x65, 0x67, 0x5d, 0xa7, 0xb8, 0xd9, 0xa3,
0x6b, 0x33, 0x61, 0xb4, 0xde, 0xb0, 0x14, 0x11, 0x00, 0xd4, 0xdc, 0xf6,
0xd9, 0x99, 0xa2, 0xcb, 0x52, 0xbb, 0x12, 0xc5, 0x0e, 0x2b, 0x00, 0x20,
0x29, 0x00, 0x62, 0x98, 0xa4, 0x62, 0xb1, 0x74, 0x0a, 0x97, 0x02, 0x18,
0x65, 0x69, 0x79, 0x30, 0x68, 0x80, 0x46, 0x02, 0x43, 0x43, 0x03, 0x23,
0xa1, 0xa1, 0x95, 0x7e, 0xa1, 0xd3, 0xc2, 0xe6, 0x52, 0x32, 0x03, 0x60,
0x84, 0x86, 0xce, 0x44, 0x24, 0xa9, 0xb5, 0x46, 0x55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, 0x1e, 0x3d,
0x78, 0xe1, 0xd3, 0xe7, 0x03, 0x78, 0xea, 0xaf, 0x5f, 0x03, 0x38, 0x5c,
0xff, 0x2c, 0xc0, 0xef, 0x13, 0xf4, 0x6f, 0x48, 0x8d, 0xcf, 0xcf, 0x87,
0x2f, 0xc8, 0xe9, 0xcb, 0x32, 0x73, 0x5d, 0xc8, 0x2e, 0x4b, 0xe5, 0x75,
0x31, 0xbe, 0x2c, 0xf7, 0xd7, 0x0b, 0xca, 0xe5, 0x92, 0x75, 0xbd, 0x28,
0xe2, 0xb1, 0xec, 0xfe, 0x00, 0x02, 0x11, 0xe6, 0x1b, 0x65, 0x7c, 0x86,
0x80, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
0x82
};
const u32 TEXTURE_ATLAS_LENGTH = (u32)std::size(TEXTURE_ATLAS);
@@ -122,8 +130,8 @@ enum AtlasType
ATLAS_INVISIBLE,
ATLAS_SHOW_RECT,
ATLAS_HIDE_RECT,
ATLAS_PLACEHOLDER,
ATLAS_PLACEHOLDER2,
ATLAS_SHOW_UNUSED,
ATLAS_HIDE_UNUSED,
ATLAS_PAN,
ATLAS_MOVE,
ATLAS_ROTATE,

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,8 @@
#define ANM2_EMPTY_ERROR "No path given for anm2"
#define ANM2_READ_ERROR "Failed to read anm2 from file: {}"
#define ANM2_PARSE_ERROR "Failed to parse anm2: {} ({})"
#define ANM2_FRAME_PARSE_ERROR "Failed to parse frame: {} ({})"
#define ANM2_ANIMATION_PARSE_ERROR "Failed to parse frame: {} ({})"
#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: {}"
@@ -63,7 +65,6 @@ const inline char* ANM2_ELEMENT_STRINGS[] =
};
DEFINE_STRING_TO_ENUM_FUNCTION(ANM2_ELEMENT_STRING_TO_ENUM, Anm2Element, ANM2_ELEMENT_STRINGS, ANM2_ELEMENT_COUNT)
DEFINE_ENUM_TO_STRING_FUNCTION(ANM2_ELEMENT_ENUM_TO_STRING, ANM2_ELEMENT_STRINGS, ANM2_ELEMENT_COUNT)
#define ANM2_ATTRIBUTE_LIST \
X(CREATED_BY, "CreatedBy") \
@@ -120,7 +121,6 @@ static const char* ANM2_ATTRIBUTE_STRINGS[] =
};
DEFINE_STRING_TO_ENUM_FUNCTION(ANM2_ATTRIBUTE_STRING_TO_ENUM, Anm2Attribute, ANM2_ATTRIBUTE_STRINGS, ANM2_ATTRIBUTE_COUNT)
DEFINE_ENUM_TO_STRING_FUNCTION(ANM2_ATTRIBUTE_ENUM_TO_STRING, ANM2_ATTRIBUTE_STRINGS, ANM2_ATTRIBUTE_COUNT)
enum Anm2Type
{
@@ -199,6 +199,7 @@ struct Anm2Animation
s32 frameNum = ANM2_FRAME_NUM_MIN;
std::string name = "New Animation";
bool isLoop = true;
bool isShowUnused = true;
Anm2Item rootAnimation;
std::map<s32, Anm2Item> layerAnimations;
std::map<s32, Anm2Item> nullAnimations;
@@ -227,27 +228,10 @@ struct Anm2Reference
Anm2Type itemType = ANM2_NONE;
s32 itemID = ID_NONE;
s32 frameIndex = INDEX_NONE;
f32 time = VALUE_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;
};
enum Anm2MergeType
{
ANM2_MERGE_APPEND_FRAMES,
@@ -278,14 +262,14 @@ bool anm2_deserialize(Anm2* self, const std::string& path, bool isTextures = tru
void anm2_new(Anm2* self);
void anm2_free(Anm2* self);
void anm2_created_on_set(Anm2* self);
s32 anm2_animation_add(Anm2* self);
s32 anm2_animation_add(Anm2* self, bool isAddRootFrame = true, Anm2Animation* animation = nullptr, s32 id = ID_NONE);
void anm2_animation_remove(Anm2* self, s32 id);
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, Anm2Frame* frame, Anm2Reference* reference, s32 time = 0.0f);
void anm2_frame_erase(Anm2* self, Anm2Reference* reference);
Anm2Frame* anm2_frame_add(Anm2* self, Anm2Frame* frame, Anm2Reference* reference);
void anm2_frame_remove(Anm2* self, Anm2Reference* reference);
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);
@@ -300,3 +284,7 @@ void anm2_generate_from_grid(Anm2* self, Anm2Reference* reference, vec2 startPos
void anm2_spritesheet_texture_pixels_upload(Anm2* self);
void anm2_spritesheet_texture_pixels_download(Anm2* self);
vec4 anm2_animation_rect_get(Anm2* anm2, Anm2Reference* reference, bool isRootTransform);
void anm2_frame_serialize(Anm2Frame* frame, Anm2Type type, XMLDocument* document, XMLElement* addElement, std::string* string);
void anm2_animation_serialize(Anm2* self, Anm2Animation* animation, XMLDocument* document, XMLElement* addElement, std::string* string);
bool anm2_frame_deserialize_from_xml(Anm2* self, Anm2Frame* frame, const std::string& xml);
bool anm2_animation_deserialize_from_xml(Anm2* self, Anm2Animation* frame, const std::string& xml);

View File

@@ -1,94 +1,101 @@
#include "clipboard.h"
static void _clipboard_item_remove(ClipboardItem* self, Anm2* anm2)
{
switch (self->type)
{
case CLIPBOARD_FRAME:
{
Anm2FrameWithReference* frameWithReference = std::get_if<Anm2FrameWithReference>(&self->data);
if (!frameWithReference) break;
anm2_frame_erase(anm2, &frameWithReference->reference);
break;
}
case CLIPBOARD_ANIMATION:
{
Anm2AnimationWithID* animationWithID = std::get_if<Anm2AnimationWithID>(&self->data);
if (!animationWithID) break;
for (auto & [id, animation] : anm2->animations)
{
if (id == animationWithID->id)
{
anm2->animations.erase(animationWithID->id);
break;
}
}
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;
anm2_frame_add(anm2, &frameWithReference->frame, reference, reference->frameIndex);
break;
}
case CLIPBOARD_ANIMATION:
{
Anm2AnimationWithID* animationWithID = std::get_if<Anm2AnimationWithID>(&self->data);
if (!animationWithID) break;
s32 index = 0;
if (std::holds_alternative<s32>(*location))
index = std::get<s32>(*location);
else
break;
index = std::clamp(index, 0, (s32)anm2->animations.size());
map_insert_shift(anm2->animations, index, animationWithID->animation);
break;
}
default:
break;
}
}
void clipboard_copy(Clipboard* self)
{
self->item = self->hoveredItem;
std::string clipboardText{};
auto clipboard_text_set = [&]()
{
if (!SDL_SetClipboardText(clipboardText.c_str()))
log_warning(std::format(CLIPBOARD_TEXT_SET_WARNING, SDL_GetError()));
};
switch (self->type)
{
case CLIPBOARD_FRAME:
{
Anm2Reference* reference = std::get_if<Anm2Reference>(&self->location);
if (!reference) break;
Anm2Frame* frame = anm2_frame_from_reference(self->anm2, reference);
if (!frame) break;
anm2_frame_serialize(frame, reference->itemType, nullptr, nullptr, &clipboardText);
clipboard_text_set();
break;
}
case CLIPBOARD_ANIMATION:
{
s32* id = std::get_if<s32>(&self->location);
if (!id) break;
Anm2Animation* animation = map_find(self->anm2->animations, *id);
if (!animation) break;
anm2_animation_serialize(self->anm2, animation, nullptr, nullptr, &clipboardText);
clipboard_text_set();
break;
}
break;
default:
break;
}
}
void clipboard_cut(Clipboard* self)
{
self->item = self->hoveredItem;
_clipboard_item_remove(&self->item, self->anm2);
clipboard_copy(self);
switch (self->type)
{
case CLIPBOARD_FRAME:
{
Anm2Reference* reference = std::get_if<Anm2Reference>(&self->location);
if (!reference) break;
anm2_frame_remove(self->anm2, reference);
break;
}
case CLIPBOARD_ANIMATION:
{
s32* id = std::get_if<s32>(&self->location);
if (!id) break;
anm2_animation_remove(self->anm2, *id);
break;
}
default:
break;
}
}
void clipboard_paste(Clipboard* self)
{
_clipboard_item_paste(&self->item, &self->location, self->anm2);
auto clipboard_string = [&]()
{
char* clipboardText = SDL_GetClipboardText();
std::string clipboardString = std::string(clipboardText);
SDL_free(clipboardText);
return clipboardString;
};
switch (self->type)
{
case CLIPBOARD_FRAME:
{
Anm2Reference* reference = std::get_if<Anm2Reference>(&self->location);
if (!reference) break;
Anm2Frame frame;
if (anm2_frame_deserialize_from_xml(self->anm2, &frame, clipboard_string()))
anm2_frame_add(self->anm2, &frame, reference);
break;
}
case CLIPBOARD_ANIMATION:
{
s32* id = std::get_if<s32>(&self->location);
if (!id) break;
Anm2Animation animation;
if (anm2_animation_deserialize_from_xml(self->anm2, &animation, clipboard_string()))
anm2_animation_add(self->anm2, false, &animation, *id);
break;
}
default:
break;
}
}
void clipboard_init(Clipboard* self, Anm2* anm2)
@@ -96,3 +103,7 @@ void clipboard_init(Clipboard* self, Anm2* anm2)
self->anm2 = anm2;
}
bool clipboard_is_value(void)
{
return SDL_HasClipboardText();
}

View File

@@ -2,21 +2,13 @@
#include "anm2.h"
enum ClipboardItemType
#define CLIPBOARD_TEXT_SET_WARNING "Unable to set clipboard text! ({})"
enum ClipboardType
{
CLIPBOARD_NONE,
CLIPBOARD_FRAME,
CLIPBOARD_ANIMATION,
};
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& animation) : data(animation), type(CLIPBOARD_ANIMATION) {}
CLIPBOARD_ANIMATION
};
using ClipboardLocation = std::variant<std::monostate, Anm2Reference, s32>;
@@ -24,11 +16,11 @@ using ClipboardLocation = std::variant<std::monostate, Anm2Reference, s32>;
struct Clipboard
{
Anm2* anm2 = nullptr;
ClipboardItem item;
ClipboardItem hoveredItem;
ClipboardType type;
ClipboardLocation location;
};
bool clipboard_is_value(void);
void clipboard_copy(Clipboard* self);
void clipboard_cut(Clipboard* self);
void clipboard_paste(Clipboard* self);

View File

@@ -94,14 +94,13 @@ static bool _imgui_is_input_default(void)
return ImGui::IsItemHovered() && (ImGui::IsKeyPressed(IMGUI_INPUT_DEFAULT) || ImGui::IsMouseClicked(IMGUI_MOUSE_DEFAULT));
}
static std::string_view imgui_window_get(void)
static bool _imgui_is_focus_window(const std::string& focus)
{
ImGuiWindow* navWindow = ImGui::GetCurrentContext()->NavWindow;
if (!navWindow) return {};
ImGuiContext* ctx = ImGui::GetCurrentContext();
if (!ctx || !ctx->NavWindow) return false;
std::string_view name(navWindow->Name);
size_t slash = name.find('/');
return (slash == std::string_view::npos) ? name : name.substr(0, slash);
std::string_view name(ctx->NavWindow->Name);
return name.find(focus) != std::string_view::npos;
}
static void _imgui_atlas(const AtlasType& self, Imgui* imgui)
@@ -217,7 +216,7 @@ static void _imgui_item_post(const ImguiItem& self, Imgui* imgui, ImguiItemType
if
(
imgui->isContextualActionsEnabled && _imgui_chord_pressed(self.chord_get()) &&
self.is_focus_window() && (imgui_window_get() == self.focusWindow)
(self.is_focus_window() && _imgui_is_focus_window(self.focusWindow))
)
if (!self.isDisabled) isActivated = true;
@@ -616,7 +615,7 @@ static void _imgui_context_menu(Imgui* self)
{
_imgui_selectable(IMGUI_CUT, self);
_imgui_selectable(IMGUI_COPY, self);
_imgui_selectable(IMGUI_PASTE.copy({self->clipboard->item.type == CLIPBOARD_NONE}), self);
_imgui_selectable(IMGUI_PASTE.copy({!clipboard_is_value()}), self);
imgui_end_popup(self);
}
@@ -983,10 +982,10 @@ static void _imgui_timeline(Imgui* self)
if (_imgui_is_window_hovered())
{
hoverReference = reference;
if (reference.itemType == ANM2_TRIGGERS)
hoverReference.frameIndex = frameTime;
else
hoverReference.frameIndex = anm2_frame_index_from_time(self->anm2, reference, frameTime);
hoverReference.time = frameTime;
hoverReference.frameIndex = anm2_frame_index_from_time(self->anm2, reference, frameTime);
self->clipboard->location = hoverReference;
self->clipboard->type = CLIPBOARD_FRAME;
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{
@@ -1230,14 +1229,14 @@ static void _imgui_timeline(Imgui* self)
if (_imgui_button(IMGUI_ADD_FRAME.copy({!item}), self))
{
Anm2Reference frameReference = *self->reference;
frameReference.frameIndex = item->frames.empty() ? 0 : std::clamp(frameReference.frameIndex, 0, static_cast<s32>(item->frames.size() - 1));
frameReference.frameIndex = item->frames.empty() ? 0 : std::clamp(frameReference.frameIndex, 0, (s32)(item->frames.size() - 1));
Anm2Frame* addFrame = anm2_frame_from_reference(self->anm2, &frameReference);
anm2_frame_add(self->anm2, addFrame, &frameReference);
}
if(_imgui_button(IMGUI_REMOVE_FRAME.copy({!frame}), self))
{
anm2_frame_erase(self->anm2, self->reference);
anm2_frame_remove(self->anm2, self->reference);
anm2_reference_frame_clear(self->reference);
}
@@ -1851,6 +1850,12 @@ static void _imgui_animations(Imgui* self)
anm2_reference_item_clear(self->reference);
}
if (ImGui::IsItemHovered())
{
self->clipboard->type = CLIPBOARD_ANIMATION;
self->clipboard->location = (s32)id;
}
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
{
if (ImGui::IsDragDropActive()) ImGui::SetNextItemWidth(_imgui_item_size_get(animationItem, IMGUI_SELECTABLE).x);
@@ -1895,11 +1900,7 @@ static void _imgui_animations(Imgui* self)
}
if (_imgui_button(IMGUI_ANIMATION_DUPLICATE.copy({!animation}), self))
{
s32 id = map_next_id_get(self->anm2->animations);
self->anm2->animations.insert({id, *animation});
self->reference->animationID = id;
}
self->reference->animationID = anm2_animation_add(self->anm2, false, animation, self->reference->animationID);
_imgui_button(IMGUI_ANIMATION_MERGE.copy({!animation}), self);
@@ -2844,10 +2845,9 @@ void imgui_update(Imgui* self)
{
for (const auto& item : imgui_item_registry())
{
if (item->is_chord() && _imgui_chord_pressed(item->chord_get()))
if (item->is_chord() && _imgui_chord_pressed(item->chord_get()) && !item->is_focus_window())
{
if (item->is_undoable()) imgui_snapshot(self, item->snapshotAction);
if (item->is_focus_window()) continue;
if (item->is_function()) item->function(self);
}
}

View File

@@ -66,7 +66,7 @@
#define IMGUI_ACTION_FRAME_SWAP "Frame Swap"
#define IMGUI_ACTION_ANIMATION_SWAP "Animation Swap"
#define IMGUI_ACTION_TRIGGER_MOVE "Trigger AtFrame"
#define IMGUI_ACTION_TRIGGER_MOVE "Trigger At Frame"
#define IMGUI_ACTION_FRAME_DELAY "Frame Delay"
#define IMGUI_ACTION_MOVE_PLAYHEAD "Move Playhead"
#define IMGUI_ACTION_DRAW "Draw"
@@ -1268,7 +1268,6 @@ IMGUI_ITEM(IMGUI_ANIMATIONS_CHILD, self.label = "## Animations Child", self.flag
IMGUI_ITEM(IMGUI_ANIMATION,
self.label = "## Animation Item",
self.snapshotAction = "Select Animation",
self.dragDrop = "## Animation Drag Drop",
self.atlas = ATLAS_ANIMATION,
self.idOffset = 2000
@@ -1965,7 +1964,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_ITEM_SELECTABLE,
IMGUI_ITEM(IMGUI_TIMELINE_ITEM_ROOT_SELECTABLE,
self.label = "Root",
self.tooltip = "The root item of an animation.\nChanging its properties will transform the rest of the animation.",
self.snapshotAction = "Root Item Select",
self.atlas = ATLAS_ROOT,
self.size = IMGUI_TIMELINE_ITEM_SELECTABLE_SIZE
);
@@ -1973,7 +1971,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_ITEM_ROOT_SELECTABLE,
IMGUI_ITEM(IMGUI_TIMELINE_ITEM_LAYER_SELECTABLE,
self.label = "## Layer Selectable",
self.tooltip = "A layer item.\nA graphical item within the animation.",
self.snapshotAction = "Layer Item Select",
self.dragDrop = "## Layer Drag Drop",
self.atlas = ATLAS_LAYER,
self.size = IMGUI_TIMELINE_ITEM_SELECTABLE_SIZE
@@ -1982,7 +1979,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_ITEM_LAYER_SELECTABLE,
IMGUI_ITEM(IMGUI_TIMELINE_ITEM_NULL_SELECTABLE,
self.label = "## Null Selectable",
self.tooltip = "A null item.\nAn invisible item within the animation that is accessible via a game engine.",
self.snapshotAction = "Null Item Select",
self.dragDrop = "## Null Drag Drop",
self.atlas = ATLAS_NULL,
self.size = IMGUI_TIMELINE_ITEM_SELECTABLE_SIZE
@@ -1991,7 +1987,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_ITEM_NULL_SELECTABLE,
IMGUI_ITEM(IMGUI_TIMELINE_ITEM_TRIGGERS_SELECTABLE,
self.label = "Triggers",
self.tooltip = "The animation's triggers.\nWill fire based on an event.",
self.snapshotAction = "Triggers Item Select",
self.atlas = ATLAS_TRIGGERS,
self.size = IMGUI_TIMELINE_ITEM_SELECTABLE_SIZE
);
@@ -2056,7 +2051,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_FRAME, self.label = "## Frame");
static const vec4 IMGUI_FRAME_BORDER_COLOR = {1.0f, 1.0f, 1.0f, 0.25f};
IMGUI_ITEM(IMGUI_TIMELINE_ROOT_FRAME,
self.label = "## Root Frame",
self.snapshotAction = "Root Frame Select",
self.color = {{0.14f, 0.27f, 0.39f, 1.0f}, {0.28f, 0.54f, 0.78f, 1.0f}, {0.36f, 0.70f, 0.95f, 1.0f}, IMGUI_FRAME_BORDER_COLOR},
self.size = IMGUI_TIMELINE_FRAME_SIZE,
self.atlasOffset = IMGUI_TIMELINE_FRAME_ATLAS_OFFSET,
@@ -2065,7 +2059,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_ROOT_FRAME,
IMGUI_ITEM(IMGUI_TIMELINE_LAYER_FRAME,
self.label = "## Layer Frame",
self.snapshotAction = "Layer Frame Select",
self.dragDrop = "## Layer Frame Drag Drop",
self.color = {{0.45f, 0.18f, 0.07f, 1.0f}, {0.78f, 0.32f, 0.12f, 1.0f}, {0.95f, 0.40f, 0.15f, 1.0f}, IMGUI_FRAME_BORDER_COLOR},
self.size = IMGUI_TIMELINE_FRAME_SIZE,
@@ -2075,7 +2068,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_LAYER_FRAME,
IMGUI_ITEM(IMGUI_TIMELINE_NULL_FRAME,
self.label = "## Null Frame",
self.snapshotAction = "Null Frame Select",
self.dragDrop = "## Null Frame Drag Drop",
self.color = {{0.17f, 0.33f, 0.17f, 1.0f}, {0.34f, 0.68f, 0.34f, 1.0f}, {0.44f, 0.88f, 0.44f, 1.0f}, IMGUI_FRAME_BORDER_COLOR},
self.size = IMGUI_TIMELINE_FRAME_SIZE,
@@ -2085,7 +2077,6 @@ IMGUI_ITEM(IMGUI_TIMELINE_NULL_FRAME,
IMGUI_ITEM(IMGUI_TIMELINE_TRIGGERS_FRAME,
self.label = "## Triggers Frame",
self.snapshotAction = "Trigger Select",
self.color = {{0.36f, 0.14f, 0.24f, 1.0f}, {0.72f, 0.28f, 0.48f, 1.0f}, {0.92f, 0.36f, 0.60f, 1.0f}, IMGUI_FRAME_BORDER_COLOR},
self.size = IMGUI_TIMELINE_FRAME_SIZE,
self.atlasOffset = IMGUI_TIMELINE_FRAME_ATLAS_OFFSET,

View File

@@ -24,4 +24,3 @@ bool texture_from_rgba_write(const std::string& path, const u8* data, ivec2 size
bool texture_pixel_set(Texture* self, ivec2 position, vec4 color);
void texture_free(Texture* self);
std::vector<u8> texture_download(const Texture* self);
Texture texture_copy(Texture* self);