Overlays, Shaders, Group Roots, Serialization Changes. Legalize Nuclear Bombs

This commit is contained in:
shweet committed 2026-07-09 19:49:33 -04:00
1 parent 555caf9f4f
commit 5792dd25a2
40 files changed
+6099 -747

No files matched your search

+80 -5
View File
@@ -4,6 +4,7 @@
#include <map>
#include <optional>
#include <set>
#include <vector>
#include "anm2/anm2.hpp"
#include "audio.hpp"
@@ -19,6 +20,34 @@ namespace anm2ed::snapshots
namespace anm2ed
{
enum class SnapshotStepDirection
{
UNDO,
REDO
};
template <typename T> struct SnapshotStepValue
{
T undo{};
T redo{};
};
struct SnapshotElementStep
{
std::vector<int> path{};
Element undo{};
Element redo{};
};
struct SnapshotAnm2Step
{
std::optional<SnapshotStepValue<bool>> isValid{};
std::vector<SnapshotElementStep> elements{};
bool is_empty() const;
void apply(Anm2&, SnapshotStepDirection) const;
};
class Snapshot
{
public:
@@ -30,18 +59,58 @@ namespace anm2ed
Storage layer{};
Storage merge{};
Storage null{};
Storage overlay{};
Storage region{};
Storage sound{};
Storage spritesheet{};
std::map<int, resource::Texture> textures{};
std::map<int, resource::Texture> overlayTextures{};
std::map<int, resource::Audio> sounds{};
Anm2 anm2{};
Reference reference{};
std::set<Reference> groupReferences{};
float frameTime{};
std::string message = snapshots::ACTION;
};
Snapshot stack_copy_get() const;
using SnapshotTextureMap = std::map<int, resource::Texture>;
using SnapshotOverlayTextureMap = std::map<int, resource::Texture>;
using SnapshotSoundMap = std::map<int, resource::Audio>;
#define SNAPSHOT_STEP_STATE_FIELDS \
X(Playback, playback) \
X(Storage, animation) \
X(Storage, event) \
X(Storage, frames) \
X(Storage, items) \
X(Storage, layer) \
X(Storage, merge) \
X(Storage, null) \
X(Storage, overlay) \
X(Storage, region) \
X(Storage, sound) \
X(Storage, spritesheet) \
X(Reference, reference) \
X(std::set<Reference>, groupReferences) \
X(float, frameTime)
#define SNAPSHOT_STEP_RESOURCE_FIELDS \
X(SnapshotTextureMap, textures) \
X(SnapshotOverlayTextureMap, overlayTextures) \
X(SnapshotSoundMap, sounds)
struct SnapshotStep
{
std::string message = snapshots::ACTION;
SnapshotAnm2Step anm2{};
#define X(type, name) std::optional<SnapshotStepValue<type>> name{};
SNAPSHOT_STEP_STATE_FIELDS
SNAPSHOT_STEP_RESOURCE_FIELDS
#undef X
bool is_empty() const;
void apply(Snapshot&, SnapshotStepDirection) const;
};
class SnapshotStack
@@ -50,8 +119,8 @@ namespace anm2ed
SnapshotStack() = default;
bool is_empty();
void push(const Snapshot&);
std::optional<Snapshot> pop();
void push(SnapshotStep);
std::optional<SnapshotStep> pop();
void clear();
void trim_to_limit();
@@ -60,7 +129,7 @@ namespace anm2ed
private:
static int maxSize;
std::deque<Snapshot> stack;
std::deque<SnapshotStep> stack;
};
class Snapshots
@@ -69,9 +138,15 @@ namespace anm2ed
SnapshotStack undoStack{};
SnapshotStack redoStack{};
Snapshot current{};
std::optional<SnapshotStep> pendingStep{};
Snapshot* get();
void push(const Snapshot&);
void anm2_push(const Snapshot&, const std::string&);
void frames_push(const Snapshot&, const std::string&, const std::set<Reference>&);
void regions_push(const Snapshot&, const std::string&, int, const std::set<int>&);
void textures_push(const Snapshot&, const std::string&);
void anm2_textures_push(const Snapshot&, const std::string&);
void commit(const Snapshot&);
bool undo();
bool redo();
void reset();