1
0
mirror of synced 2025-02-08 22:59:41 +01:00

Song Cover loading encore

This commit is contained in:
Stepland 2020-02-06 00:35:29 +01:00
parent df3dda88f3
commit 5d6dda7ecd
4 changed files with 22 additions and 4 deletions

View File

@ -11,6 +11,14 @@ namespace fs = std::filesystem;
namespace Data {
std::optional<fs::path> Song::full_cover_path() const {
if (cover) {
return folder/cover.value();
} else {
return {};
}
}
SongList::SongList::SongList() {
// Loading all song metadata
@ -125,4 +133,4 @@ namespace Data {
return res;
}
}
}

View File

@ -28,6 +28,8 @@ namespace Data {
// to allow for decimal levels (introduced in jubeat ... festo ?)
std::unordered_map<std::string, unsigned int> chart_levels;
std::optional<fs::path> full_cover_path() const;
static bool sort_by_title(const Data::Song& a, const Data::Song& b) {
return a.title < b.title;
}

View File

@ -1,5 +1,8 @@
#include "Autoloader.hpp"
#include <chrono>
#include <thread>
void Textures::Autoloader::load(const fs::path& t_path) {
if (m_mapping.find(t_path) != m_mapping.end()) {
return;
@ -18,3 +21,7 @@ std::shared_ptr<sf::Texture> Textures::Autoloader::get(const fs::path& t_path) {
}
return m_mapping.at(t_path);
}
bool Textures::Autoloader::has(const fs::path& t_path) {
return m_mapping.find(t_path) != m_mapping.end();
}

View File

@ -26,8 +26,9 @@ namespace Textures {
public:
Autoloader() = default;
std::shared_ptr<sf::Texture> get(const fs::path& t_path);
private:
void load(const fs::path& t_path);
mutable std::unordered_map<fs::path, std::shared_ptr<sf::Texture>> m_mapping;
};
bool has(const fs::path& t_path);
private:
std::unordered_map<fs::path, std::shared_ptr<sf::Texture>> m_mapping;
};
}