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_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
main.cpp
Widgets.cpp
@ -20,12 +27,7 @@ set(SOURCE_FILES
Note.cpp
Chart.cpp
EditorState.cpp
imgui/imgui.cpp
imgui/imgui_draw.cpp
imgui/imgui_widgets.cpp
imgui/imgui-SFML.cpp
imgui/imgui_stdlib.cpp
imgui/imgui_demo.cpp
${imgui}
tinyfiledialogs.c Toolbox.cpp Toolbox.h)
#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/)
add_executable(FEIS ${SOURCE_FILES})
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))) {
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();
}
@ -254,6 +260,7 @@ void EditorState::displayTimeline() {
ImGui::SetCursorPos({0,0});
if(ImGui::VSliderFloat("",ImGui::GetContentRegionMax(),&slider_pos,0.f,1.f,"")) {
setPlaybackAndMusicPosition(sf::seconds(scroll.backwards_transform(slider_pos)));
this->lastTimingTicked = -1;
}
}
}

View File

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

View File

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