Song Info
This commit is contained in:
parent
d0368f6fbc
commit
71ac2eeda5
@ -46,11 +46,13 @@
|
|||||||
- Sort out the wierdness when hitting early
|
- Sort out the wierdness when hitting early
|
||||||
- Score
|
- Score
|
||||||
- compute
|
- compute
|
||||||
|
- display
|
||||||
- Combo
|
- Combo
|
||||||
- compute
|
- compute
|
||||||
- display
|
- display
|
||||||
- Shutter
|
- Shutter
|
||||||
- compute
|
- compute
|
||||||
|
- Song Info
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
- Handling Resolution changes
|
- Handling Resolution changes
|
||||||
|
3
TODO.md
3
TODO.md
@ -7,11 +7,10 @@
|
|||||||
- Fullscreen handling
|
- Fullscreen handling
|
||||||
|
|
||||||
## Gameplay Screen
|
## Gameplay Screen
|
||||||
- Score
|
|
||||||
- display
|
|
||||||
- Shutter
|
- Shutter
|
||||||
- display
|
- display
|
||||||
- Density Graph
|
- Density Graph
|
||||||
|
- Long Notes
|
||||||
|
|
||||||
## Results Screen
|
## Results Screen
|
||||||
|
|
||||||
|
@ -82,7 +82,8 @@ sources = [
|
|||||||
'src/Toolkit/GHCFilesystemPathHash.hpp',
|
'src/Toolkit/GHCFilesystemPathHash.hpp',
|
||||||
'src/Toolkit/HSL.hpp',
|
'src/Toolkit/HSL.hpp',
|
||||||
'src/Toolkit/HSL.cpp',
|
'src/Toolkit/HSL.cpp',
|
||||||
'src/Toolkit/NormalizedOrigin.hpp',
|
'src/Toolkit/SFMLHelpers.hpp',
|
||||||
|
'src/Toolkit/SFMLHelpers.cpp',
|
||||||
'src/Toolkit/QuickRNG.hpp',
|
'src/Toolkit/QuickRNG.hpp',
|
||||||
'src/Toolkit/QuickRNG.cpp',
|
'src/Toolkit/QuickRNG.cpp',
|
||||||
'src/Main.cpp',
|
'src/Main.cpp',
|
||||||
|
@ -74,6 +74,8 @@ namespace Data {
|
|||||||
float get_big_level_x() const {return preferences.layout.big_level_x*get_screen_width();};
|
float get_big_level_x() const {return preferences.layout.big_level_x*get_screen_width();};
|
||||||
float get_big_level_y() const {return preferences.layout.big_level_y*get_screen_width();};
|
float get_big_level_y() const {return preferences.layout.big_level_y*get_screen_width();};
|
||||||
float get_upper_part_height() const {return preferences.layout.upper_part_height*get_screen_width();};
|
float get_upper_part_height() const {return preferences.layout.upper_part_height*get_screen_width();};
|
||||||
|
// Scales a length in pixels from the original jubeat resolution of 768x1360 to the current screen resolution
|
||||||
|
float scale(float length) const {return (length*get_screen_width())/768.f;};
|
||||||
Preferences& preferences;
|
Preferences& preferences;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "../Data/Chart.hpp"
|
#include "../Data/Chart.hpp"
|
||||||
#include "../Data/Song.hpp"
|
#include "../Data/Song.hpp"
|
||||||
#include "../Toolkit/Cache.hpp"
|
#include "../Toolkit/Cache.hpp"
|
||||||
#include "../Toolkit/NormalizedOrigin.hpp"
|
#include "../Toolkit/SFMLHelpers.hpp"
|
||||||
|
|
||||||
namespace Drawables {
|
namespace Drawables {
|
||||||
class DensityGraph : public sf::Drawable, public sf::Transformable {
|
class DensityGraph : public sf::Drawable, public sf::Transformable {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include "../../Input/Buttons.hpp"
|
#include "../../Input/Buttons.hpp"
|
||||||
#include "../../Toolkit/NormalizedOrigin.hpp"
|
#include "../../Toolkit/SFMLHelpers.hpp"
|
||||||
#include "PreciseMusic.hpp"
|
#include "PreciseMusic.hpp"
|
||||||
#include "Silence.hpp"
|
#include "Silence.hpp"
|
||||||
|
|
||||||
@ -58,6 +58,9 @@ namespace Gameplay {
|
|||||||
case sf::Event::Resized:
|
case sf::Event::Resized:
|
||||||
// update the view to the new size of the window
|
// update the view to the new size of the window
|
||||||
window.setView(sf::View({0, 0, static_cast<float>(event.size.width), static_cast<float>(event.size.height)}));
|
window.setView(sf::View({0, 0, static_cast<float>(event.size.width), static_cast<float>(event.size.height)}));
|
||||||
|
shared.preferences.screen.height = event.size.height;
|
||||||
|
shared.preferences.screen.width = event.size.width;
|
||||||
|
shared.button_highlight.setPosition(get_ribbon_x(), get_ribbon_y());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -80,6 +83,24 @@ namespace Gameplay {
|
|||||||
auto music_time = music->getPlayingOffset();
|
auto music_time = music->getPlayingOffset();
|
||||||
update_note_index(music_time);
|
update_note_index(music_time);
|
||||||
window.clear(sf::Color(7, 23, 53));
|
window.clear(sf::Color(7, 23, 53));
|
||||||
|
|
||||||
|
// Draw song info
|
||||||
|
// Cover is 40x40 @ (384,20)
|
||||||
|
if (song_selection.song.cover) {
|
||||||
|
auto cover = shared.covers.get(*song_selection.song.full_cover_path());
|
||||||
|
if (cover) {
|
||||||
|
sf::Sprite cover_sprite{*cover->texture};
|
||||||
|
auto cover_size = 40.f/768.f*get_screen_width();
|
||||||
|
Toolkit::set_size_from_local_bounds(cover_sprite, cover_size, cover_size);
|
||||||
|
cover_sprite.setPosition(
|
||||||
|
384.f/768.f*get_screen_width(),
|
||||||
|
20.f/768.f*get_screen_width()
|
||||||
|
);
|
||||||
|
window.draw(cover_sprite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Draw Combo
|
// Draw Combo
|
||||||
auto current_combo = combo.load();
|
auto current_combo = combo.load();
|
||||||
if (current_combo >= 4) {
|
if (current_combo >= 4) {
|
||||||
@ -95,6 +116,8 @@ namespace Gameplay {
|
|||||||
);
|
);
|
||||||
window.draw(combo_text);
|
window.draw(combo_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw score
|
||||||
auto current_score = score.get_score();
|
auto current_score = score.get_score();
|
||||||
sf::Text score_text;
|
sf::Text score_text;
|
||||||
score_text.setFont(shared.fallback_font.black);
|
score_text.setFont(shared.fallback_font.black);
|
||||||
@ -108,6 +131,69 @@ namespace Gameplay {
|
|||||||
);
|
);
|
||||||
window.draw(score_text);
|
window.draw(score_text);
|
||||||
|
|
||||||
|
// Draw song info
|
||||||
|
auto song_title = song_selection.song.title;
|
||||||
|
if (not song_title.empty()) {
|
||||||
|
sf::Text song_title_label{
|
||||||
|
sf::String::fromUtf8(song_title.begin(), song_title.end()),
|
||||||
|
shared.fallback_font.medium,
|
||||||
|
static_cast<unsigned int>(scale(20.f))
|
||||||
|
};
|
||||||
|
Toolkit::set_local_origin_normalized(song_title_label, 0.f, 1.f);
|
||||||
|
song_title_label.setFillColor(sf::Color::White);
|
||||||
|
song_title_label.setPosition(scale(440.f), scale(40.f));
|
||||||
|
window.draw(song_title_label);
|
||||||
|
}
|
||||||
|
auto song_artist = song_selection.song.artist;
|
||||||
|
if (not song_artist.empty()) {
|
||||||
|
sf::Text song_artist_label{
|
||||||
|
sf::String::fromUtf8(song_artist.begin(), song_artist.end()),
|
||||||
|
shared.fallback_font.medium,
|
||||||
|
static_cast<unsigned int>(scale(12.f))
|
||||||
|
};
|
||||||
|
song_artist_label.setStyle(sf::Text::Italic);
|
||||||
|
song_artist_label.setFillColor(sf::Color::White);
|
||||||
|
song_artist_label.setPosition(scale(440.f), scale(45.f));
|
||||||
|
window.draw(song_artist_label);
|
||||||
|
}
|
||||||
|
sf::Text level_label{
|
||||||
|
"LEVEL:",
|
||||||
|
shared.fallback_font.medium,
|
||||||
|
static_cast<unsigned int>(scale(10.f))
|
||||||
|
};
|
||||||
|
Toolkit::set_origin_normalized(level_label, 1.f, 1.f);
|
||||||
|
level_label.setPosition(scale(322.f), scale(35.f));
|
||||||
|
level_label.setFillColor(sf::Color::White);
|
||||||
|
window.draw(level_label);
|
||||||
|
|
||||||
|
sf::Text level_number_label{
|
||||||
|
std::to_string(chart.level),
|
||||||
|
shared.fallback_font.black,
|
||||||
|
static_cast<unsigned int>(scale(35.f))
|
||||||
|
};
|
||||||
|
Toolkit::set_origin_normalized(level_number_label, 0.5f, 0.f);
|
||||||
|
level_number_label.setPosition(scale(351.f), scale(24.f));
|
||||||
|
level_number_label.setFillColor(sf::Color::White);
|
||||||
|
window.draw(level_number_label);
|
||||||
|
|
||||||
|
std::string full_difficulty = song_selection.difficulty;
|
||||||
|
if (full_difficulty == "BSC") {
|
||||||
|
full_difficulty = "BASIC";
|
||||||
|
} else if (full_difficulty == "ADV") {
|
||||||
|
full_difficulty = "ADVANCED";
|
||||||
|
} else if (full_difficulty == "EXT") {
|
||||||
|
full_difficulty = "EXTREME";
|
||||||
|
}
|
||||||
|
|
||||||
|
sf::Text chart_label{
|
||||||
|
sf::String::fromUtf8(full_difficulty.begin(), full_difficulty.end()),
|
||||||
|
shared.fallback_font.medium,
|
||||||
|
static_cast<unsigned int>(scale(16.f))
|
||||||
|
};
|
||||||
|
Toolkit::set_local_origin_normalized(chart_label, 1.f, 1.f);
|
||||||
|
chart_label.setPosition(scale(322.f), scale(55.f));
|
||||||
|
chart_label.setFillColor(shared.get_chart_color(song_selection.difficulty));
|
||||||
|
window.draw(chart_label);
|
||||||
|
|
||||||
// Draw Notes
|
// Draw Notes
|
||||||
for (auto i = note_index.load(); i < notes.size(); ++i) {
|
for (auto i = note_index.load(); i < notes.size(); ++i) {
|
||||||
@ -125,8 +211,7 @@ namespace Gameplay {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (sprite) {
|
if (sprite) {
|
||||||
auto rect = sprite->getLocalBounds();
|
Toolkit::set_size_from_local_bounds(*sprite, get_panel_size(), get_panel_size());
|
||||||
sprite->setScale(get_panel_size()/rect.width, get_panel_size()/rect.height);
|
|
||||||
auto pos = Input::button_to_coords(note.position);
|
auto pos = Input::button_to_coords(note.position);
|
||||||
sprite->setPosition(
|
sprite->setPosition(
|
||||||
get_ribbon_x()+get_panel_step()*pos.x,
|
get_ribbon_x()+get_panel_step()*pos.x,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "ControlPanels.hpp"
|
#include "ControlPanels.hpp"
|
||||||
|
|
||||||
#include "../../../Toolkit/NormalizedOrigin.hpp"
|
#include "../../../Toolkit/SFMLHelpers.hpp"
|
||||||
|
|
||||||
namespace MusicSelect {
|
namespace MusicSelect {
|
||||||
void LeftButton::draw(sf::RenderTarget& target, sf::RenderStates states) const {
|
void LeftButton::draw(sf::RenderTarget& target, sf::RenderStates states) const {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "../../Input/Buttons.hpp"
|
#include "../../Input/Buttons.hpp"
|
||||||
#include "../../Input/KeyMapping.hpp"
|
#include "../../Input/KeyMapping.hpp"
|
||||||
#include "../../Toolkit/NormalizedOrigin.hpp"
|
#include "../../Toolkit/SFMLHelpers.hpp"
|
||||||
#include "Panels/Panel.hpp"
|
#include "Panels/Panel.hpp"
|
||||||
#include "PanelLayout.hpp"
|
#include "PanelLayout.hpp"
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include "../../../Toolkit/HSL.hpp"
|
#include "../../../Toolkit/HSL.hpp"
|
||||||
#include "../../../Toolkit/NormalizedOrigin.hpp"
|
#include "../../../Toolkit/SFMLHelpers.hpp"
|
||||||
|
|
||||||
namespace MusicSelect {
|
namespace MusicSelect {
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include "../../../Toolkit/HSL.hpp"
|
#include "../../../Toolkit/HSL.hpp"
|
||||||
#include "../../../Toolkit/NormalizedOrigin.hpp"
|
#include "../../../Toolkit/SFMLHelpers.hpp"
|
||||||
#include "../Ribbon.hpp"
|
#include "../Ribbon.hpp"
|
||||||
#include "../Resources.hpp"
|
#include "../Resources.hpp"
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <SFML/Graphics/Sprite.hpp>
|
#include <SFML/Graphics/Sprite.hpp>
|
||||||
|
|
||||||
#include "../../Toolkit/EasingFunctions.hpp"
|
#include "../../Toolkit/EasingFunctions.hpp"
|
||||||
#include "../../Toolkit/NormalizedOrigin.hpp"
|
#include "../../Toolkit/SFMLHelpers.hpp"
|
||||||
|
|
||||||
#include "Panels/Panel.hpp"
|
#include "Panels/Panel.hpp"
|
||||||
|
|
||||||
@ -112,7 +112,6 @@ namespace MusicSelect {
|
|||||||
song_artist_label.setScale(m_big_cover.get_size() / song_artist_bounds.width, 1.0f);
|
song_artist_label.setScale(m_big_cover.get_size() / song_artist_bounds.width, 1.0f);
|
||||||
}
|
}
|
||||||
song_artist_label.setFillColor(sf::Color::White);
|
song_artist_label.setFillColor(sf::Color::White);
|
||||||
song_artist_label.setFillColor(sf::Color::White);
|
|
||||||
song_artist_label.setPosition(
|
song_artist_label.setPosition(
|
||||||
get_big_cover_x() - m_big_cover.get_size()/2.f,
|
get_big_cover_x() - m_big_cover.get_size()/2.f,
|
||||||
get_big_cover_y() + m_big_cover.get_size() + 0.04f*get_screen_width()
|
get_big_cover_y() + m_big_cover.get_size() + 0.04f*get_screen_width()
|
||||||
|
8
src/Toolkit/SFMLHelpers.cpp
Normal file
8
src/Toolkit/SFMLHelpers.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "SFMLHelpers.hpp"
|
||||||
|
|
||||||
|
namespace Toolkit {
|
||||||
|
void set_size_from_local_bounds(sf::Sprite& s, float x, float y) {
|
||||||
|
auto const bounds = s.getLocalBounds();
|
||||||
|
s.setScale(x/bounds.width,y/bounds.height);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics/Sprite.hpp>
|
||||||
|
|
||||||
namespace Toolkit {
|
namespace Toolkit {
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -20,4 +20,6 @@ namespace Toolkit {
|
|||||||
auto bounds = s.getGlobalBounds();
|
auto bounds = s.getGlobalBounds();
|
||||||
s.setOrigin(x*bounds.width, y*bounds.height);
|
s.setOrigin(x*bounds.width, y*bounds.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_size_from_local_bounds(sf::Sprite& s, float x, float y);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user