1
0
mirror of synced 2025-02-08 22:59:41 +01:00

Chart List

This commit is contained in:
Stepland 2020-02-16 17:39:55 +01:00
parent d6f204b191
commit 426e2ede47
5 changed files with 58 additions and 4 deletions

View File

@ -20,6 +20,7 @@
- Title
- Artist
- Chart
- Chart List
- Song Panel click
- difficulty cycle
- Handling Resolution changes
@ -30,7 +31,6 @@
### Music Select Screen
- Top Screen Part Handling
- Chart List
- Density graph
- Sound
- Fullscreen handling

View File

@ -75,6 +75,8 @@ namespace MusicSelect {
} else {
selected_chart = m_song.chart_levels.cbegin()->first;
}
m_resources.selected_panel->last_click.restart();
m_resources.selected_panel->is_first_click = false;
} else {
// Look for the first chart with dif greater or equal to the last select one
// or else select the first chart

View File

@ -15,9 +15,11 @@ namespace MusicSelect {
class SelectablePanel;
struct TimedSelectedPanel {
TimedSelectedPanel(SelectablePanel& s) : panel(s), selected_since() {};
TimedSelectedPanel(SelectablePanel& s) : panel(s), first_click(), last_click() {};
SelectablePanel& panel;
sf::Clock selected_since;
sf::Clock first_click;
sf::Clock last_click;
bool is_first_click = true;
};
struct SharedResources {

View File

@ -5,6 +5,7 @@
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include "../../Toolkit/EasingFunctions.hpp"
#include "../../Toolkit/NormalizedOrigin.hpp"
#include "Panel.hpp"
@ -44,7 +45,7 @@ namespace MusicSelect {
cover.setScale(get_size()/bounds.width, get_size()/bounds.height);
auto alpha = static_cast<std::uint8_t>(
m_seconds_to_alpha.clampedTransform(
selected_panel->selected_since.getElapsedTime().asSeconds()
selected_panel->first_click.getElapsedTime().asSeconds()
)
);
cover.setColor(sf::Color(255, 255, 255, alpha));
@ -62,6 +63,7 @@ namespace MusicSelect {
target.draw(m_big_cover, states);
draw_song_title(target, states);
draw_big_level(target, states);
draw_chart_list(target, states);
}
void SongInfo::draw_song_title(sf::RenderTarget& target, sf::RenderStates states) const {
@ -118,6 +120,7 @@ namespace MusicSelect {
target.draw(song_artist_label, states);
}
}
void SongInfo::draw_big_level(sf::RenderTarget& target, sf::RenderStates states) const {
auto selected_panel = m_resources.selected_panel;
if (not selected_panel.has_value()) {
@ -166,4 +169,49 @@ namespace MusicSelect {
chart_label.setFillColor(m_resources.get_chart_color(selected_chart->chart));
target.draw(chart_label, states);
}
void MusicSelect::SongInfo::draw_chart_list(sf::RenderTarget& target, sf::RenderStates states) const {
auto selected_panel = m_resources.selected_panel;
if (not selected_panel.has_value()) {
return;
}
auto selected_chart = selected_panel->panel.get_selected_chart();
if (not selected_chart.has_value()) {
return;
}
auto dif_badge_radius = 8.f/768.f*get_screen_width();
auto dif_badge_x = 30.f/768.f*get_screen_width();
auto dif_badge_y = 40.f/768.f*get_screen_width();
auto dif_badge_step = 3.f*dif_badge_radius;
std::size_t dif_index = 0;
for (auto &&[chart_name, level] : selected_chart->song.chart_levels) {
sf::CircleShape dif_badge{dif_badge_radius};
Toolkit::set_origin_normalized(dif_badge, 0.5f, 0.5f);
dif_badge.setFillColor(m_resources.get_chart_color(chart_name));
dif_badge.setPosition(dif_badge_x+dif_index*dif_badge_step, dif_badge_y);
target.draw(dif_badge, states);
if (chart_name == selected_chart->chart) {
sf::CircleShape select_triangle(dif_badge_radius, 3);
Toolkit::set_origin_normalized(select_triangle, 0.5f, 0.5f);
select_triangle.rotate(180.f);
select_triangle.setFillColor(sf::Color::White);
if (selected_panel->is_first_click) {
select_triangle.setPosition(
dif_badge_x+dif_index*dif_badge_step,
dif_badge_y-dif_badge_step
);
} else {
auto previous_index = (dif_index + selected_chart->song.chart_levels.size() - 1) % selected_chart->song.chart_levels.size();
auto animation_factor = m_seconds_to_badge_anim.clampedTransform(selected_panel->last_click.getElapsedTime().asSeconds());
animation_factor = Toolkit::EaseExponential(-7.f).transform(animation_factor);
select_triangle.setPosition(
dif_badge_x+(animation_factor*dif_index+(1-animation_factor)*previous_index)*dif_badge_step,
dif_badge_y-dif_badge_step
);
}
target.draw(select_triangle);
}
dif_index++;
}
}
}

View File

@ -27,6 +27,8 @@ namespace MusicSelect {
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
void draw_song_title(sf::RenderTarget& target, sf::RenderStates states) const;
void draw_big_level(sf::RenderTarget& target, sf::RenderStates states) const;
void draw_chart_list(sf::RenderTarget& target, sf::RenderStates states) const;
mutable BigCover m_big_cover;
const Toolkit::AffineTransform<float> m_seconds_to_badge_anim{0.f, 0.15f, 0.f, 1.f};
};
}