2022-03-16 02:10:18 +01:00
|
|
|
#include "better_song.hpp"
|
2022-03-27 03:32:13 +02:00
|
|
|
|
2022-03-23 02:20:07 +01:00
|
|
|
#include <SFML/System/Time.hpp>
|
2022-03-16 02:10:18 +01:00
|
|
|
|
2022-03-31 03:50:15 +02:00
|
|
|
#include "better_hakus.hpp"
|
|
|
|
#include "json.hpp"
|
|
|
|
#include "src/better_hakus.hpp"
|
2022-03-27 03:32:13 +02:00
|
|
|
#include "std_optional_extras.hpp"
|
2022-03-31 03:50:15 +02:00
|
|
|
#include "variant_visitor.hpp"
|
2022-03-27 03:32:13 +02:00
|
|
|
|
2022-03-16 02:10:18 +01:00
|
|
|
namespace better {
|
2022-03-31 03:50:15 +02:00
|
|
|
std::string stringify_level(std::optional<Decimal> level) {
|
|
|
|
return stringify_or(level, "(no level defined)");
|
2022-03-16 02:10:18 +01:00
|
|
|
};
|
|
|
|
|
2022-04-01 01:41:47 +02:00
|
|
|
nlohmann::ordered_json Song::dump_for_memon_1_0_0() const {
|
2022-03-31 03:50:15 +02:00
|
|
|
nlohmann::ordered_json memon;
|
|
|
|
memon["version"] = "1.0.0";
|
2022-04-01 01:41:47 +02:00
|
|
|
auto json_metadata = metadata.dump_for_memon_1_0_0();
|
2022-03-31 03:50:15 +02:00
|
|
|
if (not json_metadata.empty()) {
|
|
|
|
memon["metadata"] = json_metadata;
|
|
|
|
}
|
2022-04-01 01:41:47 +02:00
|
|
|
nlohmann::json fallback_timing_object = R"(
|
|
|
|
{"offset": "0", "bpms": [{"beat": 0, "bpm": "120"}]}
|
|
|
|
)"_json;
|
|
|
|
auto song_timing = dump_memon_1_0_0_timing_object(timing, hakus, fallback_timing_object);
|
|
|
|
if (not song_timing.empty()) {
|
|
|
|
memon["timing"] = song_timing;
|
2022-03-31 03:50:15 +02:00
|
|
|
}
|
2022-04-01 01:41:47 +02:00
|
|
|
fallback_timing_object.update(song_timing);
|
2022-03-31 03:50:15 +02:00
|
|
|
auto json_charts = nlohmann::ordered_json::object();
|
|
|
|
for (const auto& [name, chart] : charts) {
|
2022-04-01 01:41:47 +02:00
|
|
|
json_charts[name] = chart.dump_for_memon_1_0_0(fallback_timing_object);
|
2022-03-31 03:50:15 +02:00
|
|
|
}
|
|
|
|
return memon;
|
2022-03-23 02:20:07 +01:00
|
|
|
}
|
2022-03-16 02:10:18 +01:00
|
|
|
}
|