WIP why is cereal so fucking hard to use
This commit is contained in:
parent
1310886609
commit
88c655fe38
@ -38,6 +38,8 @@ sources = [
|
||||
'src/Drawables/BlackFrame.cpp',
|
||||
'src/Resources/TextureCache.cpp',
|
||||
'src/Resources/TextureCache.hpp',
|
||||
'src/Resources/Marker.cpp',
|
||||
'src/Resources/Marker.hpp',
|
||||
# 'src/Resources/CoverAtlas.hpp',
|
||||
# 'src/Resources/CoverAtlas.cpp',
|
||||
# 'src/Screens/Gameplay.hpp',
|
||||
@ -49,8 +51,12 @@ sources = [
|
||||
'src/Screens/MusicSelect/MusicPreview.cpp',
|
||||
'src/Screens/MusicSelect/MusicSelect.hpp',
|
||||
'src/Screens/MusicSelect/MusicSelect.cpp',
|
||||
'src/Screens/MusicSelect/OptionMenu.hpp',
|
||||
# 'src/Screens/MusicSelect/OptionMenu.cpp',
|
||||
'src/Screens/MusicSelect/Panel.hpp',
|
||||
'src/Screens/MusicSelect/Panel.cpp',
|
||||
'src/Screens/MusicSelect/PanelLayout.hpp',
|
||||
'src/Screens/MusicSelect/PanelLayout.cpp',
|
||||
'src/Screens/MusicSelect/Ribbon.hpp',
|
||||
'src/Screens/MusicSelect/Ribbon.cpp',
|
||||
'src/Screens/MusicSelect/SharedResources.hpp',
|
||||
@ -63,6 +69,8 @@ sources = [
|
||||
'src/Toolkit/Debuggable.hpp',
|
||||
'src/Toolkit/EasingFunctions.hpp',
|
||||
'src/Toolkit/EasingFunctions.cpp',
|
||||
'src/Toolkit/ExtraCerealTypes/GHCFilesystemPath.hpp',
|
||||
'src/Toolkit/GHCFilesystemPathHash.hpp',
|
||||
'src/Toolkit/HSL.hpp',
|
||||
'src/Toolkit/HSL.cpp',
|
||||
'src/Toolkit/NormalizedOrigin.hpp',
|
||||
|
@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <ghc/filesystem.hpp>
|
||||
#include <fstream>
|
||||
|
||||
#include <cereal/archives/json.hpp>
|
||||
#include <cereal/types/string.hpp>
|
||||
#include <cereal/types/unordered_map.hpp>
|
||||
#include <ghc/filesystem.hpp>
|
||||
#include <SFML/System.hpp>
|
||||
|
||||
#include "Buttons.hpp"
|
||||
@ -60,8 +61,8 @@ namespace Data {
|
||||
template<class Archive>
|
||||
void serialize(Archive & archive) {
|
||||
archive(
|
||||
CEREAL_NVP(marker),
|
||||
);
|
||||
CEREAL_NVP(marker)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,10 +9,6 @@
|
||||
|
||||
#include <cereal/archives/json.hpp>
|
||||
|
||||
#include "../Toolkit/GHCFilesystemPathHash.hpp"
|
||||
|
||||
namespace fs = ghc::filesystem;
|
||||
|
||||
namespace Resources {
|
||||
|
||||
Marker::Marker(const fs::path& marker_folder) :
|
||||
@ -92,7 +88,7 @@ namespace Resources {
|
||||
ss << " lasts " << metadata.count/static_cast<float>(m_metadata.fps)*1000.f << "ms";
|
||||
ss << " (" << metadata.count << "f @ " << m_metadata.fps << "fps)";
|
||||
ss << " which is more than the maximum of " << 16.f/30.f*1000.f << "ms";
|
||||
ss << ' (16f @ 30fps)';
|
||||
ss << " (16f @ 30fps)";
|
||||
throw std::invalid_argument(ss.str());
|
||||
}
|
||||
}
|
||||
@ -117,6 +113,8 @@ namespace Resources {
|
||||
case MarkerAnimation::PERFECT:
|
||||
return m_perfect;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("wtf ?");
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +138,8 @@ namespace Resources {
|
||||
case MarkerAnimation::PERFECT:
|
||||
return m_metadata.perfect;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("wtf ?");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,17 @@
|
||||
#include <ghc/filesystem.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
#include "../Toolkit/ExtraCerealTypes/GHCFilesystemPath.hpp"
|
||||
namespace fs = ghc::filesystem;
|
||||
|
||||
template <class Archive>
|
||||
std::string save_minimal(const Archive &, ghc::filesystem::path& p) {
|
||||
return p.string();
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void load_minimal(const Archive &, ghc::filesystem::path& p, const std::string& value) {
|
||||
p = fs::path{value};
|
||||
}
|
||||
|
||||
namespace Resources {
|
||||
enum class MarkerAnimation {
|
||||
@ -26,11 +36,11 @@ namespace Resources {
|
||||
std::size_t rows; // how many vertically
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & archive) const {
|
||||
void serialize(Archive& archive) {
|
||||
archive(
|
||||
CEREAL_NVP(sprite_sheet),
|
||||
CEREAL_NVP(count),
|
||||
CEREAL_NVP(column),
|
||||
CEREAL_NVP(columns),
|
||||
CEREAL_NVP(rows)
|
||||
);
|
||||
}
|
||||
@ -49,7 +59,7 @@ namespace Resources {
|
||||
MarkerAnimationMetadata perfect;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & archive) const {
|
||||
void serialize(Archive & archive) {
|
||||
archive(
|
||||
CEREAL_NVP(name),
|
||||
CEREAL_NVP(size),
|
||||
@ -65,7 +75,7 @@ namespace Resources {
|
||||
};
|
||||
|
||||
struct Marker {
|
||||
explicit Marker(const ghc::filesystem::path& marker_folder);
|
||||
Marker(const fs::path& marker_folder);
|
||||
std::optional<sf::Sprite> get_sprite(const MarkerAnimation& state, const float& seconds);
|
||||
std::optional<sf::Sprite> get_sprite(const MarkerAnimation& state, const std::size_t frame);
|
||||
void load_and_check(sf::Texture& spritesheet, const MarkerAnimationMetadata& metadata);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "../../Drawables/BlackFrame.hpp"
|
||||
#include "../../Resources/Marker.hpp"
|
||||
#include "../../Toolkit/AffineTransform.hpp"
|
||||
#include "SongListRibbon.hpp"
|
||||
#include "Ribbon.hpp"
|
||||
#include "SongInfo.hpp"
|
||||
#include "SharedResources.hpp"
|
||||
#include "ButtonHighlight.hpp"
|
||||
@ -39,7 +39,7 @@ namespace MusicSelect {
|
||||
Resources::Markers markers;
|
||||
|
||||
// State
|
||||
SongListRibbon ribbon;
|
||||
Ribbon ribbon;
|
||||
SongInfo song_info;
|
||||
std::optional<std::reference_wrapper<SongPanel>> selected_panel;
|
||||
ButtonHighlight button_highlight;
|
||||
|
@ -18,5 +18,5 @@ namespace MusicSelect {
|
||||
void click(const Data::Button& button);
|
||||
private:
|
||||
void draw(sf::RenderTarget& target, sf::RenderStates states);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace MusicSelect {
|
||||
return (m_position + (Data::button_to_index(button) % 4)) % m_layout.size();
|
||||
}
|
||||
|
||||
jbcoe::polymorphic_value<Panel>& Ribbon::get_panel_under_button(const Data::Button& button) const {
|
||||
jbcoe::polymorphic_value<Panel>& Ribbon::get_panel_under_button(const Data::Button& button) {
|
||||
auto button_index = Data::button_to_index(button);
|
||||
return (
|
||||
m_layout
|
||||
@ -116,7 +116,7 @@ namespace MusicSelect {
|
||||
if (std::any_of(
|
||||
column.begin(),
|
||||
column.end(),
|
||||
[](std::shared_ptr<Panel> panel) -> bool {
|
||||
[](jbcoe::polymorphic_value<Panel> panel) -> bool {
|
||||
return (std::dynamic_pointer_cast<CategoryPanel>(panel).get() != nullptr);
|
||||
}
|
||||
)) {
|
||||
|
@ -40,7 +40,7 @@ namespace MusicSelect {
|
||||
class Ribbon : public sf::Drawable, public sf::Transformable, public HoldsSharedResources, public Toolkit::Debuggable {
|
||||
public:
|
||||
Ribbon(PanelLayout layout, SharedResources& t_resources);
|
||||
jbcoe::polymorphic_value<Panel>& get_panel_under_button(const Data::Button& button) const;
|
||||
jbcoe::polymorphic_value<Panel>& get_panel_under_button(const Data::Button& button);
|
||||
void click_on(const Data::Button& button);
|
||||
void move_right();
|
||||
void move_left();
|
||||
|
@ -2,17 +2,16 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/types/string.hpp>
|
||||
#include <cereal/details/traits.hpp>
|
||||
#include <ghc/filesystem.hpp>
|
||||
|
||||
|
||||
template <class Archive>
|
||||
std::string save_minimal(const Archive &, const ghc::filesystem::path & p) {
|
||||
std::string save_minimal(const Archive &, ghc::filesystem::path& p) {
|
||||
return p.string();
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void load_minimal(const Archive &, ghc::filesystem::path& p, const std::string& value) {
|
||||
p = ghc::filesystem::path{value};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user