.........................................................
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
#include "anm2_type.h"
|
||||
#include "types.h"
|
||||
|
||||
#if defined(TRANSPARENT)
|
||||
#undef TRANSPARENT
|
||||
#endif
|
||||
|
||||
namespace anm2ed::anm2
|
||||
{
|
||||
constexpr auto FRAME_DURATION_MIN = 1;
|
||||
@@ -53,4 +57,4 @@ namespace anm2ed::anm2
|
||||
};
|
||||
|
||||
#undef MEMBERS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ using namespace tinyxml2;
|
||||
|
||||
namespace anm2ed::anm2
|
||||
{
|
||||
Sound::Sound(const Sound& other) : path(other.path) { audio = path.empty() ? Audio() : Audio(path.c_str()); }
|
||||
Sound::Sound(const Sound& other) : path(other.path) { audio = path.empty() ? Audio() : Audio(path); }
|
||||
|
||||
Sound& Sound::operator=(const Sound& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
path = other.path;
|
||||
audio = path.empty() ? Audio() : Audio(path.c_str());
|
||||
audio = path.empty() ? Audio() : Audio(path);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace anm2ed::anm2
|
||||
filesystem::WorkingDirectory workingDirectory(directory);
|
||||
this->path = !path.empty() ? std::filesystem::relative(path) : this->path;
|
||||
this->path = filesystem::path_lower_case_backslash_handle(this->path);
|
||||
audio = Audio(this->path.c_str());
|
||||
audio = Audio(this->path);
|
||||
}
|
||||
|
||||
Sound::Sound(const std::filesystem::path& directory, const std::filesystem::path& path)
|
||||
@@ -40,14 +40,15 @@ namespace anm2ed::anm2
|
||||
element->QueryIntAttribute("Id", &id);
|
||||
xml::query_path_attribute(element, "Path", &path);
|
||||
path = filesystem::path_lower_case_backslash_handle(path);
|
||||
audio = Audio(path.c_str());
|
||||
audio = Audio(path);
|
||||
}
|
||||
|
||||
XMLElement* Sound::to_element(XMLDocument& document, int id)
|
||||
{
|
||||
auto element = document.NewElement("Sound");
|
||||
element->SetAttribute("Id", id);
|
||||
element->SetAttribute("Path", path.c_str());
|
||||
auto pathString = path.generic_string();
|
||||
element->SetAttribute("Path", pathString.c_str());
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace anm2ed::anm2
|
||||
return xml::document_to_string(document);
|
||||
}
|
||||
|
||||
void Sound::reload(const std::string& directory) { *this = Sound(directory, this->path); }
|
||||
void Sound::reload(const std::filesystem::path& directory) { *this = Sound(directory, this->path); }
|
||||
|
||||
bool Sound::is_valid() { return audio.is_valid(); }
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace anm2ed::anm2
|
||||
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, int);
|
||||
std::string to_string(int);
|
||||
void serialize(tinyxml2::XMLDocument&, tinyxml2::XMLElement*, int);
|
||||
void reload(const std::string&);
|
||||
void reload(const std::filesystem::path&);
|
||||
bool is_valid();
|
||||
void play();
|
||||
};
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace anm2ed::anm2
|
||||
{
|
||||
auto element = document.NewElement("Spritesheet");
|
||||
element->SetAttribute("Id", id);
|
||||
element->SetAttribute("Path", path.c_str());
|
||||
auto pathString = path.generic_string();
|
||||
element->SetAttribute("Path", pathString.c_str());
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -57,11 +58,11 @@ namespace anm2ed::anm2
|
||||
bool Spritesheet::save(const std::string& directory, const std::string& path)
|
||||
{
|
||||
filesystem::WorkingDirectory workingDirectory(directory);
|
||||
this->path = !path.empty() ? std::filesystem::relative(path).string() : this->path.string();
|
||||
this->path = !path.empty() ? std::filesystem::relative(path) : this->path;
|
||||
return texture.write_png(this->path);
|
||||
}
|
||||
|
||||
void Spritesheet::reload(const std::string& directory) { *this = Spritesheet(directory, this->path); }
|
||||
void Spritesheet::reload(const std::filesystem::path& directory) { *this = Spritesheet(directory, this->path); }
|
||||
|
||||
bool Spritesheet::is_valid() { return texture.is_valid(); }
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace anm2ed::anm2
|
||||
std::string to_string(int id);
|
||||
bool save(const std::string&, const std::string& = {});
|
||||
void serialize(tinyxml2::XMLDocument&, tinyxml2::XMLElement*, int);
|
||||
void reload(const std::string&);
|
||||
void reload(const std::filesystem::path&);
|
||||
bool is_valid();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user