mirror of
https://gitlab.com/square-game-liberation-front/F.E.I.S.git
synced 2024-11-15 03:27:41 +01:00
Small fixes avoiding segfaults
This commit is contained in:
parent
e6d4267385
commit
c363374d0b
@ -43,7 +43,7 @@ find_library (WinMM libwinmm.a)
|
||||
find_package (SFML 2.5.1 COMPONENTS system window graphics network audio REQUIRED)
|
||||
find_package (OpenGL REQUIRED)
|
||||
|
||||
include_directories(${OPENGL_INCLUDE_DIR} include/ include/imgui/)
|
||||
include_directories(${OPENGL_INCLUDE_DIR} ${SFML_INCLUDE_DIR} include/ include/imgui/)
|
||||
|
||||
add_executable(FEIS ${SOURCE_FILES})
|
||||
|
||||
|
@ -29,24 +29,22 @@ void EditorState::reloadFromFumen() {
|
||||
/*
|
||||
* Reloads music from what's indicated in the "music path" field of the fumen
|
||||
* Resets the music state in case anything fails
|
||||
* Updates playbackPosition and previewEnd
|
||||
* Updates playbackPosition and previewEnd as well
|
||||
*/
|
||||
void EditorState::reloadMusic() {
|
||||
|
||||
music.emplace();
|
||||
if (!music->openFromFile(
|
||||
(fumen.path.parent_path() / std::filesystem::path(fumen.musicPath)).string())
|
||||
) {
|
||||
|
||||
std::filesystem::path music_path = std::filesystem::path(fumen.path).parent_path() / fumen.musicPath;
|
||||
|
||||
if (
|
||||
fumen.musicPath.empty() or
|
||||
not std::filesystem::exists(music_path) or
|
||||
not music->openFromFile(music_path.string())
|
||||
) {
|
||||
music.reset();
|
||||
}
|
||||
reloadPlaybackPositionAndPreviewEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
* NEVER CALL THAT YOURSELF,
|
||||
* Let reloadMusic do it,
|
||||
* you can end up with some strange stuff if you call it before reloadMusic
|
||||
*/
|
||||
void EditorState::reloadPlaybackPositionAndPreviewEnd() {
|
||||
playbackPosition = sf::seconds(-(fumen.offset));
|
||||
previousPos = playbackPosition;
|
||||
if (music) {
|
||||
@ -69,10 +67,19 @@ void EditorState::reloadPlaybackPositionAndPreviewEnd() {
|
||||
* Resets the album cover state if anything fails
|
||||
*/
|
||||
void EditorState::reloadAlbumCover() {
|
||||
|
||||
albumCover.emplace();
|
||||
if (!albumCover->loadFromFile((fumen.path.parent_path() / std::filesystem::path(fumen.albumCoverPath)).string())) {
|
||||
|
||||
std::filesystem::path album_cover_path = std::filesystem::path(fumen.path).parent_path() / fumen.albumCoverPath;
|
||||
|
||||
if (
|
||||
fumen.albumCoverPath.empty() or
|
||||
not std::filesystem::exists(album_cover_path) or
|
||||
not albumCover->loadFromFile(album_cover_path.string())
|
||||
) {
|
||||
albumCover.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EditorState::setPlaybackAndMusicPosition(sf::Time newPosition) {
|
||||
@ -550,9 +557,13 @@ void EditorState::displayLinearView() {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize,0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,ImVec2(2,2));
|
||||
if (ImGui::Begin("Linear View", &showLinearView,ImGuiWindowFlags_NoScrollbar)) {
|
||||
linearView.update(chart->ref, playbackPosition, getTicks(), fumen.BPM, getResolution(), ImGui::GetContentRegionMax());
|
||||
ImGui::SetCursorPos({0,ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.f});
|
||||
ImGui::Image(linearView.view.getTexture(),ImVec2(0,1),ImVec2(1,0));
|
||||
if (chart) {
|
||||
linearView.update(chart->ref, playbackPosition, getTicks(), fumen.BPM, getResolution(), ImGui::GetContentRegionMax());
|
||||
ImGui::SetCursorPos({0,ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.f});
|
||||
ImGui::Image(linearView.view.getTexture(),ImVec2(0,1),ImVec2(1,0));
|
||||
} else {
|
||||
ImGui::TextDisabled("- no chart selected -");
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(2);
|
||||
|
Loading…
Reference in New Issue
Block a user