.................
This commit is contained in:
@@ -29,6 +29,11 @@ namespace anm2ed::anm2
|
|||||||
audio = Audio(this->path.c_str());
|
audio = Audio(this->path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sound::Sound(const std::filesystem::path& directory, const std::filesystem::path& path)
|
||||||
|
: Sound(directory.string(), path.string())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Sound::Sound(XMLElement* element, int& id)
|
Sound::Sound(XMLElement* element, int& id)
|
||||||
{
|
{
|
||||||
if (!element) return;
|
if (!element) return;
|
||||||
@@ -63,4 +68,4 @@ namespace anm2ed::anm2
|
|||||||
bool Sound::is_valid() { return audio.is_valid(); }
|
bool Sound::is_valid() { return audio.is_valid(); }
|
||||||
|
|
||||||
void Sound::play() { audio.play(); }
|
void Sound::play() { audio.play(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace anm2ed::anm2
|
|||||||
Sound& operator=(const Sound&);
|
Sound& operator=(const Sound&);
|
||||||
Sound(tinyxml2::XMLElement*, int&);
|
Sound(tinyxml2::XMLElement*, int&);
|
||||||
Sound(const std::string&, const std::string&);
|
Sound(const std::string&, const std::string&);
|
||||||
|
Sound(const std::filesystem::path&, const std::filesystem::path&);
|
||||||
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, int);
|
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, int);
|
||||||
std::string to_string(int);
|
std::string to_string(int);
|
||||||
void serialize(tinyxml2::XMLDocument&, tinyxml2::XMLElement*, int);
|
void serialize(tinyxml2::XMLDocument&, tinyxml2::XMLElement*, int);
|
||||||
@@ -30,4 +31,4 @@ namespace anm2ed::anm2
|
|||||||
bool is_valid();
|
bool is_valid();
|
||||||
void play();
|
void play();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ namespace anm2ed::anm2
|
|||||||
texture = Texture(this->path);
|
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)
|
XMLElement* Spritesheet::to_element(XMLDocument& document, int id)
|
||||||
{
|
{
|
||||||
auto element = document.NewElement("Spritesheet");
|
auto element = document.NewElement("Spritesheet");
|
||||||
@@ -60,4 +65,4 @@ namespace anm2ed::anm2
|
|||||||
|
|
||||||
bool Spritesheet::is_valid() { return texture.is_valid(); }
|
bool Spritesheet::is_valid() { return texture.is_valid(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace anm2ed::anm2
|
|||||||
Spritesheet() = default;
|
Spritesheet() = default;
|
||||||
Spritesheet(tinyxml2::XMLElement*, int&);
|
Spritesheet(tinyxml2::XMLElement*, int&);
|
||||||
Spritesheet(const std::string&, const std::string& = {});
|
Spritesheet(const std::string&, const std::string& = {});
|
||||||
|
Spritesheet(const std::filesystem::path&, const std::filesystem::path& = {});
|
||||||
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, int);
|
tinyxml2::XMLElement* to_element(tinyxml2::XMLDocument&, int);
|
||||||
std::string to_string(int id);
|
std::string to_string(int id);
|
||||||
bool save(const std::string&, const std::string& = {});
|
bool save(const std::string&, const std::string& = {});
|
||||||
@@ -27,4 +28,4 @@ namespace anm2ed::anm2
|
|||||||
void reload(const std::string&);
|
void reload(const std::string&);
|
||||||
bool is_valid();
|
bool is_valid();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ namespace anm2ed::resource
|
|||||||
if (path && *path) internal = MIX_LoadAudio(mixer_get(), path, true);
|
if (path && *path) internal = MIX_LoadAudio(mixer_get(), path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Audio::Audio(const std::string& path) : Audio(path.c_str()) {}
|
||||||
|
|
||||||
|
Audio::Audio(const std::filesystem::path& path) : Audio(path.string()) {}
|
||||||
|
|
||||||
Audio::Audio(const unsigned char* data, size_t size)
|
Audio::Audio(const unsigned char* data, size_t size)
|
||||||
{
|
{
|
||||||
SDL_IOStream* io = SDL_IOFromConstMem(data, size);
|
SDL_IOStream* io = SDL_IOFromConstMem(data, size);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL3_mixer/SDL_mixer.h>
|
#include <SDL3_mixer/SDL_mixer.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace anm2ed::resource
|
namespace anm2ed::resource
|
||||||
@@ -15,6 +17,8 @@ namespace anm2ed::resource
|
|||||||
public:
|
public:
|
||||||
Audio(const char*);
|
Audio(const char*);
|
||||||
Audio(const unsigned char*, size_t);
|
Audio(const unsigned char*, size_t);
|
||||||
|
Audio(const std::string&);
|
||||||
|
Audio(const std::filesystem::path&);
|
||||||
~Audio();
|
~Audio();
|
||||||
Audio() = default;
|
Audio() = default;
|
||||||
Audio(Audio&&) noexcept;
|
Audio(Audio&&) noexcept;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <lunasvg.h>
|
#include <lunasvg.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -123,11 +124,15 @@ namespace anm2ed::resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Texture::Texture(const std::filesystem::path& pngPath) : Texture(pngPath.string()) {}
|
||||||
|
|
||||||
bool Texture::write_png(const std::string& path)
|
bool Texture::write_png(const std::string& path)
|
||||||
{
|
{
|
||||||
return stbi_write_png(path.c_str(), size.x, size.y, CHANNELS, this->pixels.data(), size.x * CHANNELS);
|
return stbi_write_png(path.c_str(), size.x, size.y, CHANNELS, this->pixels.data(), size.x * CHANNELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Texture::write_png(const std::filesystem::path& path) { return write_png(path.string()); }
|
||||||
|
|
||||||
void Texture::pixel_set(ivec2 position, vec4 color)
|
void Texture::pixel_set(ivec2 position, vec4 color)
|
||||||
{
|
{
|
||||||
if (position.x < 0 || position.y < 0 || position.x >= size.x || position.y >= size.y) return;
|
if (position.x < 0 || position.y < 0 || position.x >= size.x || position.y >= size.y) return;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -36,7 +37,9 @@ namespace anm2ed::resource
|
|||||||
Texture(const uint8_t*, glm::ivec2);
|
Texture(const uint8_t*, glm::ivec2);
|
||||||
Texture(const char*, size_t, glm::ivec2);
|
Texture(const char*, size_t, glm::ivec2);
|
||||||
Texture(const std::string&);
|
Texture(const std::string&);
|
||||||
|
Texture(const std::filesystem::path&);
|
||||||
bool write_png(const std::string&);
|
bool write_png(const std::string&);
|
||||||
|
bool write_png(const std::filesystem::path&);
|
||||||
void pixel_set(glm::ivec2, glm::vec4);
|
void pixel_set(glm::ivec2, glm::vec4);
|
||||||
void pixel_line(glm::ivec2, glm::ivec2, glm::vec4);
|
void pixel_line(glm::ivec2, glm::ivec2, glm::vec4);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user