This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "resources.h"
|
||||
#include "resources.hpp"
|
||||
|
||||
#include "util/preferences.hpp"
|
||||
|
||||
using namespace game::resource;
|
||||
using namespace game::anm2;
|
||||
using namespace game::util;
|
||||
|
||||
namespace game
|
||||
{
|
||||
@@ -10,19 +12,30 @@ namespace game
|
||||
for (int i = 0; i < shader::COUNT; i++)
|
||||
shaders[i] = Shader(shader::INFO[i].vertex, shader::INFO[i].fragment);
|
||||
|
||||
for (int i = 0; i < audio::COUNT; i++)
|
||||
audio[i] = Audio(audio::PATHS[i]);
|
||||
|
||||
for (int i = 0; i < texture::COUNT; i++)
|
||||
textures[i] = Texture(texture::PATHS[i]);
|
||||
|
||||
for (int i = 0; i < anm2::COUNT; i++)
|
||||
anm2s[i] = Anm2(anm2::PATHS[i]);
|
||||
for (auto& entry : std::filesystem::recursive_directory_iterator("resources/characters"))
|
||||
if (entry.is_regular_file() && entry.path().extension() == ".zip") characterPreviews.emplace_back(entry.path());
|
||||
characters.resize(characterPreviews.size());
|
||||
}
|
||||
|
||||
void Resources::sound_play(audio::Type type) { audio[type].play(); }
|
||||
void Resources::volume_set(float vol) { Audio::volume_set(vol); }
|
||||
|
||||
void Resources::set_audio_gain(float vol) {
|
||||
Audio::set_gain(vol);
|
||||
resource::xml::Character& Resources::character_get(int index)
|
||||
{
|
||||
if (!characters.at(index).has_value())
|
||||
{
|
||||
characters[index].emplace(characterPreviews.at(index).path);
|
||||
characters[index]->save = characterPreviews.at(index).save;
|
||||
}
|
||||
return *characters[index];
|
||||
}
|
||||
}
|
||||
|
||||
resource::xml::CharacterPreview& Resources::character_preview_get(int index) { return characterPreviews.at(index); }
|
||||
|
||||
void Resources::character_save_set(int index, const resource::xml::Save& save)
|
||||
{
|
||||
characterPreviews.at(index).save = save;
|
||||
if (characters.at(index).has_value()) characters[index]->save = save;
|
||||
}
|
||||
|
||||
Resources::~Resources() { settings.serialize(preferences::path() / "settings.xml"); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user