From 5d6dda7ecdb88812730e5468481921a3cbf84102 Mon Sep 17 00:00:00 2001 From: Stepland <16676308+Stepland@users.noreply.github.com> Date: Thu, 6 Feb 2020 00:35:29 +0100 Subject: [PATCH] Song Cover loading encore --- src/Data/SongList.cpp | 10 +++++++++- src/Data/SongList.hpp | 2 ++ src/Resources/Autoloader.cpp | 7 +++++++ src/Resources/Autoloader.hpp | 7 ++++--- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Data/SongList.cpp b/src/Data/SongList.cpp index cb64350..202d97d 100644 --- a/src/Data/SongList.cpp +++ b/src/Data/SongList.cpp @@ -11,6 +11,14 @@ namespace fs = std::filesystem; namespace Data { + std::optional 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; } -} \ No newline at end of file +} diff --git a/src/Data/SongList.hpp b/src/Data/SongList.hpp index 3e5c3d9..1acd4e1 100644 --- a/src/Data/SongList.hpp +++ b/src/Data/SongList.hpp @@ -28,6 +28,8 @@ namespace Data { // to allow for decimal levels (introduced in jubeat ... festo ?) std::unordered_map chart_levels; + std::optional full_cover_path() const; + static bool sort_by_title(const Data::Song& a, const Data::Song& b) { return a.title < b.title; } diff --git a/src/Resources/Autoloader.cpp b/src/Resources/Autoloader.cpp index 1b36ad6..dd8dc25 100644 --- a/src/Resources/Autoloader.cpp +++ b/src/Resources/Autoloader.cpp @@ -1,5 +1,8 @@ #include "Autoloader.hpp" +#include +#include + 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 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(); +} diff --git a/src/Resources/Autoloader.hpp b/src/Resources/Autoloader.hpp index 5a96734..5966fde 100644 --- a/src/Resources/Autoloader.hpp +++ b/src/Resources/Autoloader.hpp @@ -26,8 +26,9 @@ namespace Textures { public: Autoloader() = default; std::shared_ptr get(const fs::path& t_path); - private: void load(const fs::path& t_path); - mutable std::unordered_map> m_mapping; - }; + bool has(const fs::path& t_path); + private: + std::unordered_map> m_mapping; + }; } \ No newline at end of file