yeah these too

This commit is contained in:
2025-12-13 01:21:57 -05:00
parent 3be9f0746f
commit c77701fe72
41 changed files with 1391 additions and 872 deletions

View File

@@ -19,7 +19,7 @@ namespace anm2ed::anm2
{
Anm2::Anm2() { info.createdOn = time::get("%m/%d/%Y %I:%M:%S %p"); }
Anm2::Anm2(const std::string& path, std::string* errorString)
Anm2::Anm2(const std::filesystem::path& path, std::string* errorString)
{
XMLDocument document;
@@ -51,7 +51,7 @@ namespace anm2ed::anm2
return element;
}
bool Anm2::serialize(const std::string& path, std::string* errorString)
bool Anm2::serialize(const std::filesystem::path& path, std::string* errorString)
{
XMLDocument document;
document.InsertFirstChild(to_element(document));
@@ -326,7 +326,8 @@ namespace anm2ed::anm2
animations.items.push_back(std::move(processed));
}
if (animations.defaultAnimation.empty() && !source.animations.defaultAnimation.empty()) {
if (animations.defaultAnimation.empty() && !source.animations.defaultAnimation.empty())
{
animations.defaultAnimation = source.animations.defaultAnimation;
}
}

View File

@@ -33,16 +33,17 @@ namespace anm2ed::anm2
Anm2();
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&);
bool serialize(const std::string&, std::string* = nullptr);
bool serialize(const std::filesystem::path&, std::string* = nullptr);
std::string to_string();
Anm2(const std::string&, std::string* = nullptr);
Anm2(const std::filesystem::path&, std::string* = nullptr);
uint64_t hash();
Spritesheet* spritesheet_get(int);
bool spritesheet_add(const std::string&, const std::string&, int&);
bool spritesheet_add(const std::filesystem::path&, const std::filesystem::path&, int&);
std::vector<std::string> spritesheet_labels_get();
std::set<int> spritesheets_unused();
bool spritesheets_deserialize(const std::string&, const std::string&, types::merge::Type type, std::string*);
bool spritesheets_deserialize(const std::string&, const std::filesystem::path&, types::merge::Type type,
std::string*);
void layer_add(int&);
std::set<int> layers_unused();
@@ -59,10 +60,10 @@ namespace anm2ed::anm2
std::set<int> events_unused();
bool events_deserialize(const std::string&, types::merge::Type, std::string*);
bool sound_add(const std::string& directory, const std::string& path, int& id);
bool sound_add(const std::filesystem::path& directory, const std::filesystem::path& path, int& id);
std::vector<std::string> sound_labels_get();
std::set<int> sounds_unused();
bool sounds_deserialize(const std::string&, const std::string&, types::merge::Type, std::string*);
bool sounds_deserialize(const std::string&, const std::filesystem::path&, types::merge::Type, std::string*);
Animation* animation_get(int);
std::vector<std::string> animation_labels_get();
@@ -75,7 +76,6 @@ namespace anm2ed::anm2
Reference null_animation_add(Reference = {}, std::string = {}, types::destination::Type = types::destination::ALL);
Frame* frame_get(int, Type, int, int = -1);
void merge(const Anm2& source, const std::filesystem::path& destinationDirectory = {},
const std::filesystem::path& sourceDirectory = {});
void merge(const Anm2&, const std::filesystem::path&, const std::filesystem::path&);
};
}

View File

@@ -9,7 +9,7 @@ using namespace tinyxml2;
namespace anm2ed::anm2
{
bool Anm2::sound_add(const std::string& directory, const std::string& path, int& id)
bool Anm2::sound_add(const std::filesystem::path& directory, const std::filesystem::path& path, int& id)
{
id = map::next_id_get(content.sounds);
content.sounds[id] = Sound(directory, path);
@@ -19,9 +19,12 @@ namespace anm2ed::anm2
std::vector<std::string> Anm2::sound_labels_get()
{
std::vector<std::string> labels{};
labels.emplace_back("None");
labels.emplace_back(localize.get(BASIC_NONE));
for (auto& [id, sound] : content.sounds)
labels.emplace_back(sound.path.string());
{
auto pathCStr = sound.path.c_str();
labels.emplace_back(std::vformat(localize.get(FORMAT_SOUND), std::make_format_args(id, pathCStr)));
}
return labels;
}
@@ -39,7 +42,7 @@ namespace anm2ed::anm2
return unused;
}
bool Anm2::sounds_deserialize(const std::string& string, const std::string& directory, merge::Type type,
bool Anm2::sounds_deserialize(const std::string& string, const std::filesystem::path& directory, merge::Type type,
std::string* errorString)
{
XMLDocument document{};

View File

@@ -13,7 +13,7 @@ namespace anm2ed::anm2
{
Spritesheet* Anm2::spritesheet_get(int id) { return map::find(content.spritesheets, id); }
bool Anm2::spritesheet_add(const std::string& directory, const std::string& path, int& id)
bool Anm2::spritesheet_add(const std::filesystem::path& directory, const std::filesystem::path& path, int& id)
{
Spritesheet spritesheet(directory, path);
if (!spritesheet.is_valid()) return false;
@@ -41,14 +41,14 @@ namespace anm2ed::anm2
labels.emplace_back(localize.get(BASIC_NONE));
for (auto& [id, spritesheet] : content.spritesheets)
{
auto string = spritesheet.path.string();
labels.emplace_back(std::vformat(localize.get(FORMAT_SPRITESHEET), std::make_format_args(id, string)));
auto pathCStr = spritesheet.path.c_str();
labels.emplace_back(std::vformat(localize.get(FORMAT_SPRITESHEET), std::make_format_args(id, pathCStr)));
}
return labels;
}
bool Anm2::spritesheets_deserialize(const std::string& string, const std::string& directory, merge::Type type,
std::string* errorString)
bool Anm2::spritesheets_deserialize(const std::string& string, const std::filesystem::path& directory,
merge::Type type, std::string* errorString)
{
XMLDocument document{};

View File

@@ -9,14 +9,14 @@ using namespace tinyxml2;
namespace anm2ed::anm2
{
Sound::Sound(const Sound& other) : path(other.path) { audio = path.empty() ? Audio() : Audio(path); }
Sound::Sound(const Sound& other) : path(other.path), audio(other.audio) {}
Sound& Sound::operator=(const Sound& other)
{
if (this != &other)
{
path = other.path;
audio = path.empty() ? Audio() : Audio(path);
audio = other.audio;
}
return *this;
}
@@ -33,7 +33,7 @@ namespace anm2ed::anm2
}
}
Sound::Sound(const std::string& directory, const std::string& path)
Sound::Sound(const std::filesystem::path& directory, const std::filesystem::path& path)
{
filesystem::WorkingDirectory workingDirectory(directory);
this->path = !path.empty() ? make_relative_or_keep(path) : this->path;
@@ -41,11 +41,6 @@ namespace anm2ed::anm2
audio = Audio(this->path);
}
Sound::Sound(const std::filesystem::path& directory, const std::filesystem::path& path)
: Sound(directory.string(), path.string())
{
}
Sound::Sound(XMLElement* element, int& id)
{
if (!element) return;

View File

@@ -20,7 +20,6 @@ namespace anm2ed::anm2
Sound(const Sound&);
Sound& operator=(const Sound&);
Sound(tinyxml2::XMLElement*, int&);
Sound(const std::string&, const std::string&);
Sound(const std::filesystem::path&, const std::filesystem::path&);
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, int);
std::string to_string(int);

View File

@@ -33,7 +33,7 @@ namespace anm2ed::anm2
}
}
Spritesheet::Spritesheet(const std::string& directory, const std::string& path)
Spritesheet::Spritesheet(const std::filesystem::path& directory, const std::filesystem::path& path)
{
filesystem::WorkingDirectory workingDirectory(directory);
this->path = !path.empty() ? make_relative_or_keep(path) : this->path;
@@ -41,11 +41,6 @@ namespace anm2ed::anm2
texture = Texture(this->path);
}
Spritesheet::Spritesheet(const std::filesystem::path& directory, const std::filesystem::path& path)
: Spritesheet(directory.string(), path.string())
{
}
XMLElement* Spritesheet::to_element(XMLDocument& document, int id)
{
auto element = document.NewElement("Spritesheet");
@@ -67,7 +62,7 @@ namespace anm2ed::anm2
return xml::document_to_string(document);
}
bool Spritesheet::save(const std::string& directory, const std::string& path)
bool Spritesheet::save(const std::filesystem::path& directory, const std::filesystem::path& path)
{
filesystem::WorkingDirectory workingDirectory(directory);
this->path = !path.empty() ? make_relative_or_keep(path) : this->path;

View File

@@ -16,11 +16,10 @@ namespace anm2ed::anm2
Spritesheet() = default;
Spritesheet(tinyxml2::XMLElement*, int&);
Spritesheet(const std::string&, const std::string& = {});
Spritesheet(const std::filesystem::path&, const std::filesystem::path& = {});
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, int);
std::string to_string(int id);
bool save(const std::string&, const std::string& = {});
bool save(const std::filesystem::path&, const std::filesystem::path& = {});
void serialize(tinyxml2::XMLDocument&, tinyxml2::XMLElement*, int);
void reload(const std::filesystem::path&);
bool is_valid();