2022-03-02 23:59:19 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-18 01:25:29 +01:00
|
|
|
#include <cmath>
|
2023-07-10 01:13:14 +02:00
|
|
|
#include <cstddef>
|
2019-01-18 01:25:29 +01:00
|
|
|
#include <filesystem>
|
|
|
|
#include <functional>
|
2021-12-31 14:59:39 +01:00
|
|
|
#include <iomanip>
|
|
|
|
#include <iostream>
|
|
|
|
#include <map>
|
2023-07-11 21:03:37 +02:00
|
|
|
#include <memory>
|
2022-12-27 18:34:19 +01:00
|
|
|
#include <optional>
|
2021-12-31 14:59:39 +01:00
|
|
|
#include <sstream>
|
2022-11-18 01:48:53 +01:00
|
|
|
#include <unordered_map>
|
2023-07-11 21:03:37 +02:00
|
|
|
#include <variant>
|
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <SFML/Graphics/Sprite.hpp>
|
|
|
|
|
2023-07-10 01:13:14 +02:00
|
|
|
#include "sprite_sheet.hpp"
|
2023-03-11 12:13:37 +01:00
|
|
|
#include "utf8_sfml_redefinitions.hpp"
|
2017-08-17 19:10:53 +02:00
|
|
|
|
2022-04-09 00:54:06 +02:00
|
|
|
enum class Judgement {
|
|
|
|
Perfect,
|
|
|
|
Great,
|
|
|
|
Good,
|
2022-11-18 01:48:53 +01:00
|
|
|
Poor,
|
2022-04-09 00:54:06 +02:00
|
|
|
Miss
|
2017-08-17 19:10:53 +02:00
|
|
|
};
|
|
|
|
|
2022-11-18 01:48:53 +01:00
|
|
|
const static std::unordered_map<Judgement, std::string> judgement_to_name = {
|
2022-04-09 00:54:06 +02:00
|
|
|
{Judgement::Perfect, "PERFECT"},
|
|
|
|
{Judgement::Great, "GREAT"},
|
|
|
|
{Judgement::Good, "GOOD"},
|
2022-11-18 01:48:53 +01:00
|
|
|
{Judgement::Poor, "POOR"},
|
2022-04-09 00:54:06 +02:00
|
|
|
{Judgement::Miss, "MISS"}
|
|
|
|
};
|
|
|
|
|
2022-11-18 01:48:53 +01:00
|
|
|
const static std::unordered_map<std::string, Judgement> name_to_judgement = {
|
|
|
|
{"PERFECT", Judgement::Perfect},
|
|
|
|
{"GREAT", Judgement::Great},
|
|
|
|
{"GOOD", Judgement::Good},
|
|
|
|
{"POOR", Judgement::Poor},
|
|
|
|
{"MISS", Judgement::Miss}
|
|
|
|
};
|
|
|
|
|
2019-03-27 20:37:30 +01:00
|
|
|
/*
|
2021-12-31 14:59:39 +01:00
|
|
|
* Holds the textures associated with a given marker folder from the assets
|
|
|
|
* folder
|
2019-03-27 20:37:30 +01:00
|
|
|
*/
|
2023-07-11 21:03:37 +02:00
|
|
|
class Marker {
|
|
|
|
public:
|
|
|
|
virtual std::optional<sf::Sprite> at(Judgement state, sf::Time offset) const = 0;
|
|
|
|
virtual sf::Sprite judgement_preview(Judgement state) const = 0;
|
|
|
|
virtual sf::Sprite approach_preview() const = 0;
|
|
|
|
virtual const std::filesystem::path& get_folder() const = 0;
|
|
|
|
|
|
|
|
virtual ~Marker() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OldMarker : public Marker {
|
2017-08-17 19:10:53 +02:00
|
|
|
public:
|
2023-07-10 01:13:14 +02:00
|
|
|
explicit OldMarker(const std::filesystem::path& folder);
|
2022-11-18 01:48:53 +01:00
|
|
|
|
2023-07-11 21:03:37 +02:00
|
|
|
std::optional<sf::Sprite> at(Judgement state, sf::Time offset) const override;
|
|
|
|
sf::Sprite judgement_preview(Judgement state) const override;
|
|
|
|
sf::Sprite approach_preview() const;
|
|
|
|
|
|
|
|
const std::filesystem::path& get_folder() const override;
|
2017-08-17 19:10:53 +02:00
|
|
|
private:
|
2022-04-09 00:54:06 +02:00
|
|
|
unsigned int fps = 30;
|
|
|
|
|
2023-07-11 21:03:37 +02:00
|
|
|
using texture_type = feis::Texture;
|
|
|
|
using texture_vector_type = std::vector<texture_type>;
|
|
|
|
|
2023-01-09 16:17:46 +01:00
|
|
|
texture_vector_type approach;
|
|
|
|
texture_vector_type perfect;
|
|
|
|
texture_vector_type great;
|
|
|
|
texture_vector_type good;
|
|
|
|
texture_vector_type poor;
|
|
|
|
texture_vector_type miss;
|
|
|
|
|
2023-07-10 01:13:14 +02:00
|
|
|
const texture_vector_type& texture_vector_of(Judgement state) const;
|
2023-07-11 21:03:37 +02:00
|
|
|
|
2022-11-18 01:48:53 +01:00
|
|
|
std::filesystem::path folder;
|
2017-08-17 19:10:53 +02:00
|
|
|
};
|
|
|
|
|
2023-07-11 21:03:37 +02:00
|
|
|
class JujubeMarker : public Marker {
|
2023-07-10 01:13:14 +02:00
|
|
|
public:
|
2023-07-11 21:03:37 +02:00
|
|
|
explicit JujubeMarker(
|
|
|
|
const std::size_t fps,
|
|
|
|
const SpriteSheet& approach,
|
|
|
|
const SpriteSheet& perfect,
|
|
|
|
const SpriteSheet& great,
|
|
|
|
const SpriteSheet& good,
|
|
|
|
const SpriteSheet& poor,
|
|
|
|
const SpriteSheet& miss,
|
|
|
|
const std::filesystem::path& folder
|
|
|
|
);
|
|
|
|
static JujubeMarker load_from_folder(const std::filesystem::path& folder);
|
|
|
|
|
|
|
|
std::optional<sf::Sprite> at(Judgement state, sf::Time offset) const override;
|
|
|
|
sf::Sprite judgement_preview(Judgement state) const override;
|
|
|
|
sf::Sprite approach_preview() const;
|
|
|
|
|
|
|
|
const std::filesystem::path& get_folder() const override;
|
2023-07-10 01:13:14 +02:00
|
|
|
private:
|
|
|
|
std::size_t fps;
|
|
|
|
|
|
|
|
SpriteSheet approach;
|
|
|
|
SpriteSheet perfect;
|
|
|
|
SpriteSheet great;
|
|
|
|
SpriteSheet good;
|
|
|
|
SpriteSheet poor;
|
|
|
|
SpriteSheet miss;
|
2023-07-11 21:03:37 +02:00
|
|
|
|
|
|
|
const SpriteSheet& sprite_sheet_of(Judgement state) const;
|
|
|
|
|
|
|
|
std::filesystem::path folder;
|
2023-07-10 01:13:14 +02:00
|
|
|
};
|
|
|
|
|
2023-07-11 21:03:37 +02:00
|
|
|
std::shared_ptr<Marker> load_marker_from(const std::filesystem::path& folder);
|
|
|
|
std::shared_ptr<Marker> first_available_marker_in(const std::filesystem::path& assets_folder);
|