BPM & offset settings in the "Properties" Menu

This commit is contained in:
Stepland 2019-02-09 06:26:57 +01:00
parent 88fb92f8a4
commit 20d50b439f
4 changed files with 27 additions and 17 deletions

View File

@ -12,6 +12,13 @@ SET(GCC_COVERAGE_LINK_FLAGS "-mwindows")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS} -static-libgcc -static-libstdc++") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS} -static-libgcc -static-libstdc++")
set(imgui imgui/imgui.cpp
imgui/imgui_draw.cpp
imgui/imgui_widgets.cpp
imgui/imgui-SFML.cpp
imgui/imgui_stdlib.cpp
imgui/imgui_demo.cpp)
set(SOURCE_FILES set(SOURCE_FILES
main.cpp main.cpp
Widgets.cpp Widgets.cpp
@ -20,12 +27,7 @@ set(SOURCE_FILES
Note.cpp Note.cpp
Chart.cpp Chart.cpp
EditorState.cpp EditorState.cpp
imgui/imgui.cpp ${imgui}
imgui/imgui_draw.cpp
imgui/imgui_widgets.cpp
imgui/imgui-SFML.cpp
imgui/imgui_stdlib.cpp
imgui/imgui_demo.cpp
tinyfiledialogs.c Toolbox.cpp Toolbox.h) tinyfiledialogs.c Toolbox.cpp Toolbox.h)
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${FEIS_SOURCE_DIR}/cmake") #set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${FEIS_SOURCE_DIR}/cmake")
@ -38,7 +40,9 @@ find_package (OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR} imgui/) include_directories(${OPENGL_INCLUDE_DIR} imgui/)
add_executable(FEIS ${SOURCE_FILES}) add_executable(FEIS ${SOURCE_FILES})
target_link_libraries(FEIS stdc++fs ${OPENGL_LIBRARIES} sfml-system sfml-window sfml-graphics sfml-network sfml-audio WinMM) target_link_libraries(FEIS stdc++fs ${OPENGL_LIBRARIES} sfml-system sfml-window sfml-graphics sfml-network sfml-audio WinMM)
add_executable(ImGuiDemo ImGuiDemoMain.cpp ${imgui})
target_link_libraries(ImGuiDemo ${OPENGL_LIBRARIES} sfml-system sfml-window sfml-graphics sfml-network sfml-audio WinMM)

View File

@ -163,6 +163,12 @@ void EditorState::displayProperties() {
if (Toolbox::InputTextColored(jacket.has_value(),"Invalid Jacket Path","Jacket",&(fumen.jacketPath))) { if (Toolbox::InputTextColored(jacket.has_value(),"Invalid Jacket Path","Jacket",&(fumen.jacketPath))) {
reloadJacket(); reloadJacket();
} }
if(ImGui::InputFloat("BPM",&fumen.BPM,1.0f,10.0f)) {
if (fumen.BPM <= 0.0f) {
fumen.BPM = 0.0f;
}
}
ImGui::InputFloat("offset",&fumen.offset);
} }
ImGui::End(); ImGui::End();
} }
@ -254,6 +260,7 @@ void EditorState::displayTimeline() {
ImGui::SetCursorPos({0,0}); ImGui::SetCursorPos({0,0});
if(ImGui::VSliderFloat("",ImGui::GetContentRegionMax(),&slider_pos,0.f,1.f,"")) { if(ImGui::VSliderFloat("",ImGui::GetContentRegionMax(),&slider_pos,0.f,1.f,"")) {
setPlaybackAndMusicPosition(sf::seconds(scroll.backwards_transform(slider_pos))); setPlaybackAndMusicPosition(sf::seconds(scroll.backwards_transform(slider_pos)));
this->lastTimingTicked = -1;
} }
} }
} }

View File

@ -36,6 +36,7 @@ public:
void setPlaybackAndMusicPosition(sf::Time newPosition); void setPlaybackAndMusicPosition(sf::Time newPosition);
bool playing; bool playing;
int lastTimingTicked = -1;
float getBeats() {return getBeatsAt(playbackPosition.asSeconds());}; float getBeats() {return getBeatsAt(playbackPosition.asSeconds());};
float getBeatsAt(float seconds) {return ((seconds+fumen.offset)/60.f)* fumen.BPM;}; float getBeatsAt(float seconds) {return ((seconds+fumen.offset)/60.f)* fumen.BPM;};

View File

@ -9,7 +9,6 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
// TODO : BPM & offset settings dans le menu Porperties
// TODO : Highlight des notes qui s'entrechoquent // TODO : Highlight des notes qui s'entrechoquent
// TODO : Undo / Redo // TODO : Undo / Redo
// TODO : Debug Log // TODO : Debug Log
@ -40,7 +39,7 @@ int main(int argc, char** argv) {
sf::Sound noteTickSound(noteTick); sf::Sound noteTickSound(noteTick);
int noteTickVolume = 10; int noteTickVolume = 10;
bool playNoteTick = false; bool playNoteTick = false;
bool noteTicked = false; int lastTickTicked = -1;
std::string beatTickPath = "assets/sounds/sound beat tick.wav"; std::string beatTickPath = "assets/sounds/sound beat tick.wav";
sf::SoundBuffer beatTick; sf::SoundBuffer beatTick;
@ -215,16 +214,15 @@ int main(int argc, char** argv) {
if (playNoteTick) { if (playNoteTick) {
for (auto note : editorState->visibleNotes) { for (auto note : editorState->visibleNotes) {
float noteTiming = editorState->getSecondsAt(note.getTiming()); float noteTiming = editorState->getSecondsAt(note.getTiming());
if (noteTiming >= editorState->previousPos.asSeconds() and noteTiming <= editorState->playbackPosition.asSeconds()) { if (noteTiming >= editorState->previousPos.asSeconds()
if (not noteTicked) { and noteTiming <= editorState->playbackPosition.asSeconds()
noteTickSound.play(); and note.getTiming() > editorState->lastTimingTicked) {
noteTicked = true; noteTickSound.play();
} editorState->lastTimingTicked = note.getTiming();
} }
} }
if (noteTicked) { } else {
noteTicked = false; editorState->lastTimingTicked = -1;
}
} }
if (editorState->playbackPosition >= editorState->chartRuntime) { if (editorState->playbackPosition >= editorState->chartRuntime) {
editorState->playing = false; editorState->playing = false;