2022-11-18 01:48:53 +01:00
|
|
|
#pragma once
|
|
|
|
|
2022-11-20 00:02:14 +01:00
|
|
|
#include <SFML/System/Time.hpp>
|
2022-11-18 01:48:53 +01:00
|
|
|
#include <filesystem>
|
|
|
|
|
|
|
|
#include <toml++/toml.h>
|
|
|
|
|
2022-11-19 01:43:37 +01:00
|
|
|
#include "colors.hpp"
|
2022-11-19 03:29:49 +01:00
|
|
|
#include "sizes.hpp"
|
2022-11-18 01:48:53 +01:00
|
|
|
#include "marker.hpp"
|
2022-11-19 03:29:49 +01:00
|
|
|
#include "widgets/lane_order.hpp"
|
2022-11-18 01:48:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace config {
|
|
|
|
using node_view = toml::node_view<const toml::node>;
|
|
|
|
|
|
|
|
toml::array dump_color(const sf::Color& color);
|
|
|
|
std::optional<sf::Color> parse_color(const node_view& node);
|
|
|
|
void load_color(const node_view& node, sf::Color& color);
|
|
|
|
|
|
|
|
struct Marker {
|
|
|
|
std::optional<std::filesystem::path> folder;
|
|
|
|
std::optional<Judgement> ending_state;
|
|
|
|
|
|
|
|
void load_from_v1_0_0_table(const toml::table& tbl);
|
|
|
|
void dump_as_v1_0_0(toml::table& tbl);
|
|
|
|
};
|
|
|
|
|
2022-11-19 03:29:49 +01:00
|
|
|
linear_view::Colors load_linear_view_colors_from_v1_0_0_table(const toml::table& linear_view);
|
|
|
|
void dump_linear_view_colors_as_v1_0_0(const linear_view::Colors& colors, toml::table& linear_view);
|
|
|
|
|
|
|
|
linear_view::Sizes load_linear_view_sizes_from_v1_0_0_table(const toml::table& linear_view);
|
|
|
|
void dump_linear_view_sizes_as_v1_0_0(const linear_view::Sizes& sizes, toml::table& linear_view);
|
|
|
|
|
|
|
|
linear_view::LaneOrder load_linear_view_lane_order_from_v1_0_0_table(const toml::table& linear_view);
|
|
|
|
void dump_linear_view_lane_order_as_v1_0_0(const linear_view::LaneOrder& lane_order, toml::table& linear_view);
|
2022-11-18 01:48:53 +01:00
|
|
|
|
|
|
|
struct LinearView {
|
2022-11-19 03:29:49 +01:00
|
|
|
linear_view::Colors colors;
|
|
|
|
linear_view::Sizes sizes;
|
|
|
|
linear_view::LaneOrder lane_order;
|
2022-11-20 00:02:14 +01:00
|
|
|
int zoom = 0;
|
2022-11-21 01:24:15 +01:00
|
|
|
bool color_notes = false;
|
2022-11-20 00:02:14 +01:00
|
|
|
|
|
|
|
void load_from_v1_0_0_table(const toml::table& tbl);
|
|
|
|
void dump_as_v1_0_0(toml::table& tbl);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Editor {
|
|
|
|
sf::Time collision_zone = sf::seconds(1);
|
2022-11-18 01:48:53 +01:00
|
|
|
|
|
|
|
void load_from_v1_0_0_table(const toml::table& tbl);
|
|
|
|
void dump_as_v1_0_0(toml::table& tbl);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* RAII-style class that holds settings we wish to save on disk and saves
|
|
|
|
them upon being destroyed */
|
|
|
|
class Config {
|
|
|
|
public:
|
|
|
|
Config(const std::filesystem::path& settings);
|
|
|
|
~Config();
|
|
|
|
|
|
|
|
const std::string version = "1.0.0";
|
|
|
|
|
|
|
|
Marker marker;
|
|
|
|
LinearView linear_view;
|
2022-11-20 00:02:14 +01:00
|
|
|
Editor editor;
|
2022-11-18 01:48:53 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void load_from_v1_0_0_table(const toml::table& tbl);
|
|
|
|
toml::table dump_as_v1_0_0();
|
|
|
|
|
|
|
|
std::filesystem::path config_path;
|
|
|
|
};
|
|
|
|
}
|