staging some future refactoring, .h -> hpp, fix for rendering w/ audio
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "snapshots.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace anm2ed
|
||||
{
|
||||
|
||||
class Document
|
||||
{
|
||||
public:
|
||||
enum ChangeType
|
||||
{
|
||||
INFO,
|
||||
LAYERS,
|
||||
NULLS,
|
||||
SPRITESHEETS,
|
||||
TEXTURES,
|
||||
EVENTS,
|
||||
ANIMATIONS,
|
||||
ITEMS,
|
||||
FRAMES,
|
||||
SOUNDS,
|
||||
ALL,
|
||||
COUNT
|
||||
};
|
||||
|
||||
std::filesystem::path path{};
|
||||
|
||||
Snapshots snapshots{};
|
||||
Snapshot& current = snapshots.current;
|
||||
|
||||
Playback& playback = current.playback;
|
||||
Storage& animation = current.animation;
|
||||
Storage& event = current.event;
|
||||
Storage& frames = current.frames;
|
||||
Storage& items = current.items;
|
||||
Storage& layer = current.layer;
|
||||
Storage& merge = current.merge;
|
||||
Storage& null = current.null;
|
||||
Storage& region = current.region;
|
||||
Storage& sound = current.sound;
|
||||
Storage& spritesheet = current.spritesheet;
|
||||
anm2::Anm2& anm2 = current.anm2;
|
||||
anm2::Reference& reference = current.reference;
|
||||
float& frameTime = current.frameTime;
|
||||
std::string& message = current.message;
|
||||
std::map<int, Storage> regionBySpritesheet{};
|
||||
|
||||
float previewZoom{200};
|
||||
glm::vec2 previewPan{};
|
||||
glm::vec2 editorPan{};
|
||||
float editorZoom{200};
|
||||
int overlayIndex{-1};
|
||||
|
||||
uint64_t hash{};
|
||||
uint64_t saveHash{};
|
||||
uint64_t autosaveHash{};
|
||||
double lastAutosaveTime{};
|
||||
bool isValid{true};
|
||||
bool isOpen{true};
|
||||
bool isForceDirty{false};
|
||||
std::unordered_map<int, uint64_t> spritesheetHashes{};
|
||||
std::unordered_map<int, uint64_t> spritesheetSaveHashes{};
|
||||
bool isAnimationPreviewSet{false};
|
||||
bool isSpritesheetEditorSet{false};
|
||||
|
||||
Document(anm2::Anm2& anm2, const std::filesystem::path&);
|
||||
Document(const std::filesystem::path&, bool = false, std::string* = nullptr);
|
||||
Document(const Document&) = delete;
|
||||
Document& operator=(const Document&) = delete;
|
||||
Document(Document&&) noexcept;
|
||||
Document& operator=(Document&&) noexcept;
|
||||
bool save(const std::filesystem::path& = {}, std::string* = nullptr, anm2::Compatibility = anm2::ANM2ED);
|
||||
void hash_set();
|
||||
void clean();
|
||||
void change(ChangeType);
|
||||
bool is_dirty() const;
|
||||
bool is_autosave_dirty() const;
|
||||
std::filesystem::path directory_get() const;
|
||||
std::filesystem::path filename_get() const;
|
||||
bool is_valid() const;
|
||||
void spritesheet_hash_update(int);
|
||||
void spritesheet_hash_set_saved(int);
|
||||
bool spritesheet_is_dirty(int);
|
||||
bool spritesheet_any_dirty();
|
||||
void spritesheet_hashes_reset();
|
||||
void spritesheet_hashes_sync();
|
||||
|
||||
anm2::Frame* frame_get();
|
||||
anm2::Item* item_get();
|
||||
anm2::Spritesheet* spritesheet_get();
|
||||
anm2::Animation* animation_get();
|
||||
|
||||
void spritesheet_add(const std::filesystem::path&);
|
||||
void sound_add(const std::filesystem::path&);
|
||||
|
||||
bool autosave(std::string* = nullptr, anm2::Compatibility = anm2::ANM2ED);
|
||||
std::filesystem::path autosave_path_get();
|
||||
std::filesystem::path path_from_autosave_get(std::filesystem::path&);
|
||||
|
||||
void snapshot(const std::string& message);
|
||||
void undo();
|
||||
void redo();
|
||||
bool is_able_to_undo();
|
||||
bool is_able_to_redo();
|
||||
};
|
||||
|
||||
#define DOCUMENT_EDIT(document, message, changeType, body) \
|
||||
{ \
|
||||
document.snapshot(message); \
|
||||
body; \
|
||||
document.change(changeType); \
|
||||
}
|
||||
|
||||
#define DOCUMENT_EDIT_PTR(document, message, changeType, body) \
|
||||
{ \
|
||||
document->snapshot(message); \
|
||||
body; \
|
||||
document->change(changeType); \
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user