More LNMarker stuff
BIN
assets/markers/long/classic/background.png
Normal file
After Width: | Height: | Size: 124 KiB |
BIN
assets/markers/long/classic/highlight.png
Normal file
After Width: | Height: | Size: 105 KiB |
51
assets/markers/long/classic/long.json
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"name": "classic",
|
||||||
|
"fps": 30,
|
||||||
|
"size": 160,
|
||||||
|
"note": {
|
||||||
|
"background": {
|
||||||
|
"sprite_sheet": "background.png",
|
||||||
|
"count": 16,
|
||||||
|
"columns": 4,
|
||||||
|
"rows": 4
|
||||||
|
},
|
||||||
|
"outline": {
|
||||||
|
"sprite_sheet": "outline.png",
|
||||||
|
"count": 16,
|
||||||
|
"columns": 4,
|
||||||
|
"rows": 4
|
||||||
|
},
|
||||||
|
"highlight": {
|
||||||
|
"sprite_sheet": "highlight.png",
|
||||||
|
"count": 16,
|
||||||
|
"columns": 4,
|
||||||
|
"rows": 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tail": {
|
||||||
|
"sprite_sheet": "tail.png",
|
||||||
|
"count": 16,
|
||||||
|
"columns": 4,
|
||||||
|
"rows": 4
|
||||||
|
},
|
||||||
|
"tip": {
|
||||||
|
"appearance": {
|
||||||
|
"sprite_sheet": "tip_appearance.png",
|
||||||
|
"count": 16,
|
||||||
|
"columns": 4,
|
||||||
|
"rows": 4
|
||||||
|
},
|
||||||
|
"begin cycle": {
|
||||||
|
"sprite_sheet": "tip_begin_cycle.png",
|
||||||
|
"count": 8,
|
||||||
|
"columns": 3,
|
||||||
|
"rows": 3
|
||||||
|
},
|
||||||
|
"cycle": {
|
||||||
|
"sprite_sheet": "tip_cycle.png",
|
||||||
|
"count": 16,
|
||||||
|
"columns": 4,
|
||||||
|
"rows": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
assets/markers/long/classic/outline.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
assets/markers/long/classic/tail.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
assets/markers/long/classic/triangle_appearance.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
assets/markers/long/classic/triangle_begin_cycle.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
assets/markers/long/classic/triangle_cycle.png
Normal file
After Width: | Height: | Size: 87 KiB |
@ -37,10 +37,14 @@ sources = [
|
|||||||
'src/Input/Events.cpp',
|
'src/Input/Events.cpp',
|
||||||
'src/Resources/TextureCache.cpp',
|
'src/Resources/TextureCache.cpp',
|
||||||
'src/Resources/TextureCache.hpp',
|
'src/Resources/TextureCache.hpp',
|
||||||
|
'src/Resources/LNMarker.cpp',
|
||||||
|
'src/Resources/LNMarker.hpp',
|
||||||
'src/Resources/Marker.cpp',
|
'src/Resources/Marker.cpp',
|
||||||
'src/Resources/Marker.hpp',
|
'src/Resources/Marker.hpp',
|
||||||
'src/Resources/SharedResources.hpp',
|
'src/Resources/SharedResources.hpp',
|
||||||
'src/Resources/SharedResources.cpp',
|
'src/Resources/SharedResources.cpp',
|
||||||
|
'src/Resources/SpriteSheet.cpp',
|
||||||
|
'src/Resources/SpriteSheet.hpp',
|
||||||
# 'src/Resources/CoverAtlas.hpp',
|
# 'src/Resources/CoverAtlas.hpp',
|
||||||
# 'src/Resources/CoverAtlas.cpp',
|
# 'src/Resources/CoverAtlas.cpp',
|
||||||
'src/Screens/MusicSelect/Drawables/ControlPanels.hpp',
|
'src/Screens/MusicSelect/Drawables/ControlPanels.hpp',
|
||||||
|
@ -39,11 +39,15 @@ namespace Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void to_json(nlohmann::json& j, const Options& o) {
|
void to_json(nlohmann::json& j, const Options& o) {
|
||||||
j = nlohmann::json{{"marker", o.marker}};
|
j = nlohmann::json{
|
||||||
|
{"marker", o.marker},
|
||||||
|
{"ln_marker", o.ln_marker}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void from_json(const nlohmann::json& j, Options& o) {
|
void from_json(const nlohmann::json& j, Options& o) {
|
||||||
j.at("marker").get_to(o.marker);
|
j.at("marker").get_to(o.marker);
|
||||||
|
j.at("ln_marker").get_to(o.ln_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RAII style class which loads preferences from the dedicated file when constructed and saves them when destructed
|
// RAII style class which loads preferences from the dedicated file when constructed and saves them when destructed
|
||||||
@ -63,8 +67,8 @@ namespace Data {
|
|||||||
prefs_file >> j;
|
prefs_file >> j;
|
||||||
j.get_to(*this);
|
j.get_to(*this);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "Error while loading data/preferences.json : " << e.what() << std::endl;
|
std::cerr << "Error while loading data/preferences.json : " << e.what() << '\n';
|
||||||
std::cerr << "Using fallback preferences instead" << std::endl;
|
std::cerr << "Using fallback preferences instead" << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
key_mapping = Input::KeyMapping{key_mapping.m_button_to_key};
|
key_mapping = Input::KeyMapping{key_mapping.m_button_to_key};
|
||||||
@ -77,7 +81,7 @@ namespace Data {
|
|||||||
ghc::filesystem::create_directory(data_folder);
|
ghc::filesystem::create_directory(data_folder);
|
||||||
}
|
}
|
||||||
if (not ghc::filesystem::is_directory(data_folder)) {
|
if (not ghc::filesystem::is_directory(data_folder)) {
|
||||||
std::cerr << "Can't create data folder to save preferences, a file named 'data' exists" << std::endl;
|
std::cerr << "Can't create data folder to save preferences, a file named 'data' exists" << '\n';
|
||||||
}
|
}
|
||||||
std::ofstream preferences_file;
|
std::ofstream preferences_file;
|
||||||
preferences_file.open(data_folder/"preferences.json", std::ofstream::trunc | std::ofstream::out);
|
preferences_file.open(data_folder/"preferences.json", std::ofstream::trunc | std::ofstream::out);
|
||||||
|
@ -39,6 +39,7 @@ namespace Data {
|
|||||||
|
|
||||||
struct Options {
|
struct Options {
|
||||||
std::string marker;
|
std::string marker;
|
||||||
|
std::string ln_marker;
|
||||||
};
|
};
|
||||||
|
|
||||||
void to_json(nlohmann::json& j, const Options& o);
|
void to_json(nlohmann::json& j, const Options& o);
|
||||||
|
@ -55,7 +55,7 @@ namespace Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "Loaded Data::SongList, found " << songs.size() << " songs" << std::endl;
|
std::cout << "Loaded Data::SongList, found " << songs.size() << " songs" << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::shared_ptr<Song>> recursiveSongSearch(fs::path song_or_pack) {
|
std::list<std::shared_ptr<Song>> recursiveSongSearch(fs::path song_or_pack) {
|
||||||
|
@ -35,6 +35,9 @@ int main(int, char const **) {
|
|||||||
if (shared_resources.markers.find(preferences.options.marker) == shared_resources.markers.end()) {
|
if (shared_resources.markers.find(preferences.options.marker) == shared_resources.markers.end()) {
|
||||||
preferences.options.marker = shared_resources.markers.begin()->first;
|
preferences.options.marker = shared_resources.markers.begin()->first;
|
||||||
}
|
}
|
||||||
|
if (shared_resources.ln_markers.find(preferences.options.ln_marker) == shared_resources.ln_markers.end()) {
|
||||||
|
preferences.options.ln_marker = shared_resources.ln_markers.begin()->first;
|
||||||
|
}
|
||||||
MusicSelect::Screen music_select{song_list, music_select_resources};
|
MusicSelect::Screen music_select{song_list, music_select_resources};
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
@ -53,9 +56,9 @@ int main(int, char const **) {
|
|||||||
ImGui::SFML::Init(window);
|
ImGui::SFML::Init(window);
|
||||||
auto chart = music_select.select_chart(window);
|
auto chart = music_select.select_chart(window);
|
||||||
if (chart) {
|
if (chart) {
|
||||||
std::cout << "Selected Chart : " << chart->song.title << " [" << chart->difficulty << "]" << std::endl;
|
std::cout << "Selected Chart : " << chart->song.title << " [" << chart->difficulty << "]" << '\n';
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Exited MusicSelect::Screen without selecting a chart" << std::endl;
|
std::cout << "Exited MusicSelect::Screen without selecting a chart" << '\n';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "LNMarker.hpp"
|
#include "LNMarker.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace Resources {
|
namespace Resources {
|
||||||
LNMarker::LNMarker(const fs::path& t_folder) :
|
LNMarker::LNMarker(const fs::path& t_folder) :
|
||||||
@ -37,4 +38,28 @@ namespace Resources {
|
|||||||
j.at("tip").at("begin cycle").get_to(m.tip_begin_cycle);
|
j.at("tip").at("begin cycle").get_to(m.tip_begin_cycle);
|
||||||
j.at("tip").at("cycle").get_to(m.tip_cycle);
|
j.at("tip").at("cycle").get_to(m.tip_cycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LNMarkers::LNMarkers(const fs::path& jujube_path) {
|
||||||
|
load_from_folder(jujube_path/"markers"/"long");
|
||||||
|
load_from_folder(jujube_path/"assets"/"markers"/"long");
|
||||||
|
if (empty()) {
|
||||||
|
throw std::runtime_error("No long note markers found, jujube needs at least one to operate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void LNMarkers::load_from_folder(const fs::path& lnmarkers_folder) {
|
||||||
|
if (fs::exists(lnmarkers_folder)) {
|
||||||
|
for (auto& p : fs::directory_iterator(lnmarkers_folder)) {
|
||||||
|
if (p.is_directory()) {
|
||||||
|
try {
|
||||||
|
LNMarker m{p.path()};
|
||||||
|
emplace(m.name, m);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "Unable to load marker folder "
|
||||||
|
<< p.path().filename().string() << " : "
|
||||||
|
<< e.what() << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <ghc/filesystem.hpp>
|
#include <ghc/filesystem.hpp>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
@ -25,4 +28,11 @@ namespace Resources {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void from_json(const nlohmann::json& j, LNMarker& m);
|
void from_json(const nlohmann::json& j, LNMarker& m);
|
||||||
|
|
||||||
|
class LNMarkers : public std::map<std::string, LNMarker> {
|
||||||
|
public:
|
||||||
|
LNMarkers(const fs::path& jujube_path);
|
||||||
|
private:
|
||||||
|
void load_from_folder(const fs::path& lnmarkers_folder);
|
||||||
|
}
|
||||||
}
|
}
|
@ -111,26 +111,28 @@ namespace Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Markers load_markers(const fs::path& jujube_path) {
|
Markers::Markers(const fs::path& jujube_path) {
|
||||||
Markers res;
|
load_from_folder(jujube_path/"markers"/"tap");
|
||||||
auto markers_folder = jujube_path/"markers";
|
load_from_folder(jujube_path/"assets"/"markers"/"tap");
|
||||||
|
if (empty()) {
|
||||||
|
throw std::runtime_error("No tap note markers found in marker folder, jujube needs at least one to operate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Markers::load_from_folder(const fs::path& markers_folder) {
|
||||||
if (fs::exists(markers_folder)) {
|
if (fs::exists(markers_folder)) {
|
||||||
for (auto& p : fs::directory_iterator(markers_folder)) {
|
for (auto& p : fs::directory_iterator(markers_folder)) {
|
||||||
if (p.is_directory()) {
|
if (p.is_directory()) {
|
||||||
try {
|
try {
|
||||||
Marker m{p.path()};
|
Marker m{p.path()};
|
||||||
res.emplace(m.name, m);
|
emplace(m.name, m);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "Unable to load marker folder "
|
std::cerr << "Unable to load marker folder "
|
||||||
<< p.path().filename().string() << " : "
|
<< p.path().filename().string() << " : "
|
||||||
<< e.what() << std::endl;
|
<< e.what() << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.empty()) {
|
|
||||||
throw std::runtime_error("No markers found in marker folder, jujube needs at least one to operate");
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,10 @@ namespace Resources {
|
|||||||
|
|
||||||
void from_json(const nlohmann::json& j, Marker& m);
|
void from_json(const nlohmann::json& j, Marker& m);
|
||||||
|
|
||||||
using Markers = std::map<std::string, Marker>;
|
class Markers : public std::map<std::string, Marker> {
|
||||||
Markers load_markers(const ghc::filesystem::path& jujube_path);
|
public:
|
||||||
|
Markers(const fs::path& jujube_path);
|
||||||
|
private:
|
||||||
|
void load_from_folder(const fs::path& markers_folder);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,11 @@ namespace Resources {
|
|||||||
fallback_font(p.jujube_path),
|
fallback_font(p.jujube_path),
|
||||||
black_frame(p),
|
black_frame(p),
|
||||||
button_highlight(p),
|
button_highlight(p),
|
||||||
markers(Resources::load_markers(p.jujube_path))
|
markers(p.jujube_path),
|
||||||
|
ln_markers(p.jujube_path)
|
||||||
{
|
{
|
||||||
covers.reserve(256);
|
covers.reserve(256);
|
||||||
std::cout << "Loaded MusicSelect::SharedResources" << std::endl;
|
std::cout << "Loaded MusicSelect::SharedResources" << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Color SharedResources::get_chart_color(const std::string& chart) {
|
sf::Color SharedResources::get_chart_color(const std::string& chart) {
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "../Drawables/ButtonHighlight.hpp"
|
#include "../Drawables/ButtonHighlight.hpp"
|
||||||
#include "../Drawables/DensityGraph.hpp"
|
#include "../Drawables/DensityGraph.hpp"
|
||||||
#include "../Resources/Marker.hpp"
|
#include "../Resources/Marker.hpp"
|
||||||
|
#include "../Resources/LNMarker.hpp"
|
||||||
#include "../Resources/TextureCache.hpp"
|
#include "../Resources/TextureCache.hpp"
|
||||||
|
|
||||||
namespace Resources {
|
namespace Resources {
|
||||||
@ -57,6 +58,9 @@ namespace Resources {
|
|||||||
|
|
||||||
Resources::Markers markers;
|
Resources::Markers markers;
|
||||||
Resources::Marker& get_selected_marker();
|
Resources::Marker& get_selected_marker();
|
||||||
|
|
||||||
|
Resources::LNMarkers ln_markers;
|
||||||
|
Resources::LNMarker& get_selected_ln_marker();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Proxy for HoldsPreferences
|
// Proxy for HoldsPreferences
|
||||||
|
@ -23,7 +23,7 @@ MusicSelect::Screen::Screen(const Data::SongList& t_song_list, ScreenResources&
|
|||||||
start_button(t_resources)
|
start_button(t_resources)
|
||||||
{
|
{
|
||||||
panel_filter.setFillColor(sf::Color(0,0,0,200));
|
panel_filter.setFillColor(sf::Color(0,0,0,200));
|
||||||
std::cout << "loaded MusicSelect::Screen" << std::endl;
|
std::cout << "loaded MusicSelect::Screen" << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Data::SongDifficulty> MusicSelect::Screen::select_chart(sf::RenderWindow& window) {
|
std::optional<Data::SongDifficulty> MusicSelect::Screen::select_chart(sf::RenderWindow& window) {
|
||||||
|
@ -71,7 +71,7 @@ namespace MusicSelect {
|
|||||||
left_button(t_resources),
|
left_button(t_resources),
|
||||||
right_button(t_resources)
|
right_button(t_resources)
|
||||||
{
|
{
|
||||||
std::cout << "Loaded MusicSelect::Ribbon" << std::endl;
|
std::cout << "Loaded MusicSelect::Ribbon" << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|