WE ARE OFFICIALY DONE WITH MUSIC SELECT FOR 0.1.0
This commit is contained in:
parent
62a042184c
commit
e8780c9721
@ -39,6 +39,7 @@
|
|||||||
- Options
|
- Options
|
||||||
- Left / Right
|
- Left / Right
|
||||||
- Back
|
- Back
|
||||||
|
- Start Button Action
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
- Handling Resolution changes
|
- Handling Resolution changes
|
||||||
|
@ -50,6 +50,18 @@ namespace Data {
|
|||||||
virtual ~Song() = default;
|
virtual ~Song() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SongDifficulty {
|
||||||
|
const Data::Song& song;
|
||||||
|
const std::string& difficulty;
|
||||||
|
|
||||||
|
bool operator==(const SongDifficulty &other) const {
|
||||||
|
return (
|
||||||
|
song.folder == other.song.folder and
|
||||||
|
difficulty == other.difficulty
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct MemonSong : public Song {
|
struct MemonSong : public Song {
|
||||||
explicit MemonSong(const fs::path& memon_path);
|
explicit MemonSong(const fs::path& memon_path);
|
||||||
std::optional<Chart> get_chart(const std::string& difficulty) const;
|
std::optional<Chart> get_chart(const std::string& difficulty) const;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include <cereal/archives/json.hpp>
|
#include <cereal/archives/json.hpp>
|
||||||
@ -39,7 +38,8 @@ int main(int, char const **) {
|
|||||||
preferences.screen.fullscreen ? sf::Style::Fullscreen : sf::Style::Default,
|
preferences.screen.fullscreen ? sf::Style::Fullscreen : sf::Style::Default,
|
||||||
settings
|
settings
|
||||||
};
|
};
|
||||||
music_select.select_chart(window);
|
auto chart = music_select.select_chart(window);
|
||||||
|
std::cout << "Selected Chart : " << chart.song.title << " [" << chart.difficulty << "]" << std::endl;
|
||||||
/*
|
/*
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace MusicSelect {
|
|||||||
target.draw(m_vertex_array, states);
|
target.draw(m_vertex_array, states);
|
||||||
}
|
}
|
||||||
|
|
||||||
DensityGraph compute_density_graph_from_struct(const SongDifficulty& sd) {
|
DensityGraph compute_density_graph_from_struct(const Data::SongDifficulty& sd) {
|
||||||
return compute_density_graph_from_song_difficulty(sd.song, sd.difficulty);
|
return compute_density_graph_from_song_difficulty(sd.song, sd.difficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,29 +20,17 @@ namespace MusicSelect {
|
|||||||
sf::VertexArray m_vertex_array;
|
sf::VertexArray m_vertex_array;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SongDifficulty {
|
DensityGraph compute_density_graph_from_struct(const Data::SongDifficulty& sd);
|
||||||
const Data::Song& song;
|
|
||||||
const std::string& difficulty;
|
|
||||||
|
|
||||||
bool operator==(const SongDifficulty &other) const {
|
|
||||||
return (
|
|
||||||
song.folder == other.song.folder and
|
|
||||||
difficulty == other.difficulty
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DensityGraph compute_density_graph_from_struct(const SongDifficulty& sd);
|
|
||||||
DensityGraph compute_density_graph_from_song_difficulty(const Data::Song& song, const std::string& difficulty);
|
DensityGraph compute_density_graph_from_song_difficulty(const Data::Song& song, const std::string& difficulty);
|
||||||
DensityGraph compute_density_graph_from_chart(const Data::Chart& chart, long start, long end);
|
DensityGraph compute_density_graph_from_chart(const Data::Chart& chart, long start, long end);
|
||||||
|
|
||||||
using DensityGraphCache = Toolkit::Cache<SongDifficulty, DensityGraph, &compute_density_graph_from_struct>;
|
using DensityGraphCache = Toolkit::Cache<Data::SongDifficulty, DensityGraph, &compute_density_graph_from_struct>;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <>
|
template <>
|
||||||
struct hash<MusicSelect::SongDifficulty> {
|
struct hash<Data::SongDifficulty> {
|
||||||
std::size_t operator()(const MusicSelect::SongDifficulty& sd) const {
|
std::size_t operator()(const Data::SongDifficulty& sd) const {
|
||||||
auto song_hash = std::hash<std::string>()(sd.song.folder.string());
|
auto song_hash = std::hash<std::string>()(sd.song.folder.string());
|
||||||
song_hash ^= std::hash<std::string>()(sd.difficulty) + 0x9e3779b9 + (song_hash<<6) + (song_hash>>2);
|
song_hash ^= std::hash<std::string>()(sd.difficulty) + 0x9e3779b9 + (song_hash<<6) + (song_hash>>2);
|
||||||
return song_hash;
|
return song_hash;
|
||||||
|
@ -27,10 +27,9 @@ MusicSelect::Screen::Screen(const Data::SongList& t_song_list, SharedResources&
|
|||||||
std::cout << "loaded MusicSelect::Screen" << std::endl;
|
std::cout << "loaded MusicSelect::Screen" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MusicSelect::Screen::select_chart(sf::RenderWindow& window) {
|
Data::SongDifficulty MusicSelect::Screen::select_chart(sf::RenderWindow& window) {
|
||||||
window.setFramerateLimit(60);
|
window.setFramerateLimit(60);
|
||||||
ImGui::SFML::Init(window);
|
ImGui::SFML::Init(window);
|
||||||
bool chart_selected = false;
|
|
||||||
sf::Clock imguiClock;
|
sf::Clock imguiClock;
|
||||||
ribbon.setPosition(get_ribbon_x(), get_ribbon_y());
|
ribbon.setPosition(get_ribbon_x(), get_ribbon_y());
|
||||||
resources.button_highlight.setPosition(get_ribbon_x(), get_ribbon_y());
|
resources.button_highlight.setPosition(get_ribbon_x(), get_ribbon_y());
|
||||||
@ -95,6 +94,8 @@ void MusicSelect::Screen::select_chart(sf::RenderWindow& window) {
|
|||||||
resources.music_preview.update();
|
resources.music_preview.update();
|
||||||
}
|
}
|
||||||
ImGui::SFML::Shutdown();
|
ImGui::SFML::Shutdown();
|
||||||
|
assert((resources.selected_panel.has_value()));
|
||||||
|
return *resources.selected_panel->obj.get_selected_difficulty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MusicSelect::Screen::draw_debug() {
|
void MusicSelect::Screen::draw_debug() {
|
||||||
@ -217,6 +218,11 @@ void MusicSelect::Screen::press_button(const Data::Button& button) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Data::Button::B16: // Start Button
|
||||||
|
if (resources.selected_panel) {
|
||||||
|
chart_selected = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace MusicSelect {
|
|||||||
const Data::SongList& t_song_list,
|
const Data::SongList& t_song_list,
|
||||||
SharedResources& t_resources
|
SharedResources& t_resources
|
||||||
);
|
);
|
||||||
void select_chart(sf::RenderWindow& window);
|
Data::SongDifficulty select_chart(sf::RenderWindow& window);
|
||||||
void draw_debug() override;
|
void draw_debug() override;
|
||||||
private:
|
private:
|
||||||
const Data::SongList song_list;
|
const Data::SongList song_list;
|
||||||
@ -40,6 +40,7 @@ namespace MusicSelect {
|
|||||||
MainOptionPage main_option_page;
|
MainOptionPage main_option_page;
|
||||||
OptionsButton options_button;
|
OptionsButton options_button;
|
||||||
StartButton start_button;
|
StartButton start_button;
|
||||||
|
bool chart_selected = false;
|
||||||
|
|
||||||
Drawables::BlackFrame black_frame;
|
Drawables::BlackFrame black_frame;
|
||||||
sf::RectangleShape panel_filter;
|
sf::RectangleShape panel_filter;
|
||||||
|
@ -97,9 +97,9 @@ namespace MusicSelect {
|
|||||||
selected_chart.reset();
|
selected_chart.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<SongDifficulty> SongPanel::get_selected_difficulty() const {
|
std::optional<Data::SongDifficulty> SongPanel::get_selected_difficulty() const {
|
||||||
if (selected_chart) {
|
if (selected_chart) {
|
||||||
return SongDifficulty{*m_song, *selected_chart};
|
return Data::SongDifficulty{*m_song, *selected_chart};
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ namespace MusicSelect {
|
|||||||
using Panel::Panel;
|
using Panel::Panel;
|
||||||
virtual ~SelectablePanel() = default;
|
virtual ~SelectablePanel() = default;
|
||||||
virtual void unselect() = 0;
|
virtual void unselect() = 0;
|
||||||
virtual std::optional<SongDifficulty> get_selected_difficulty() const = 0;
|
virtual std::optional<Data::SongDifficulty> get_selected_difficulty() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SongPanel final : public SelectablePanel {
|
class SongPanel final : public SelectablePanel {
|
||||||
@ -77,7 +77,7 @@ namespace MusicSelect {
|
|||||||
explicit SongPanel(SharedResources& t_resources, const std::shared_ptr<const Data::Song>& t_song) : SelectablePanel(t_resources), m_song(t_song) {};
|
explicit SongPanel(SharedResources& t_resources, const std::shared_ptr<const Data::Song>& t_song) : SelectablePanel(t_resources), m_song(t_song) {};
|
||||||
void click(Ribbon& ribbon, const Data::Button& button) override;
|
void click(Ribbon& ribbon, const Data::Button& button) override;
|
||||||
void unselect() override;
|
void unselect() override;
|
||||||
std::optional<SongDifficulty> get_selected_difficulty() const override;
|
std::optional<Data::SongDifficulty> get_selected_difficulty() const override;
|
||||||
private:
|
private:
|
||||||
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
||||||
std::shared_ptr<const Data::Song> m_song;
|
std::shared_ptr<const Data::Song> m_song;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user