mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2024-11-13 18:50:54 +01:00
Don't reset position when reloading the music
This commit is contained in:
parent
797c6142b7
commit
c9a4937a92
@ -7,6 +7,7 @@
|
||||
|
||||
## 🍒 Small improvements 🍒
|
||||
- Frendlier error message when the UI font is not found in the assets folder
|
||||
- Playback position is kept instead of being reset to zero when you change charts or reload the audio file
|
||||
|
||||
## 🚧 Small Changes 🚧
|
||||
- Force using the asset folder next to the executable
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "editor_state.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
#include <imgui-SFML.h>
|
||||
@ -44,10 +45,11 @@ void EditorState::reloadMusic() {
|
||||
) {
|
||||
music.reset();
|
||||
}
|
||||
|
||||
playbackPosition = sf::seconds(-(fumen.offset));
|
||||
previousPos = playbackPosition;
|
||||
reloadPreviewEnd();
|
||||
|
||||
auto seconds_position = std::clamp(playbackPosition.asSeconds(), -(fumen.offset), previewEnd.asSeconds());
|
||||
playbackPosition = sf::seconds(seconds_position);
|
||||
previousPos = playbackPosition;
|
||||
}
|
||||
|
||||
void EditorState::reloadPreviewEnd() {
|
||||
@ -92,11 +94,13 @@ void EditorState::reloadAlbumCover() {
|
||||
void EditorState::setPlaybackAndMusicPosition(sf::Time newPosition) {
|
||||
reloadPreviewEnd();
|
||||
|
||||
if (newPosition.asSeconds() < -fumen.offset) {
|
||||
newPosition = sf::seconds(-fumen.offset);
|
||||
} else if (newPosition > previewEnd) {
|
||||
newPosition = previewEnd;
|
||||
}
|
||||
newPosition = sf::seconds(
|
||||
std::clamp(
|
||||
newPosition.asSeconds(),
|
||||
-fumen.offset,
|
||||
previewEnd.asSeconds()
|
||||
)
|
||||
);
|
||||
previousPos = sf::seconds(newPosition.asSeconds() - 1.f / 60.f);
|
||||
playbackPosition = newPosition;
|
||||
if (music) {
|
||||
|
Loading…
Reference in New Issue
Block a user