From b4a3fd6d0fe17b963fd49736d2b9334d41e10889 Mon Sep 17 00:00:00 2001 From: milkdropper <59471060+milkdropper@users.noreply.github.com> Date: Sat, 18 Jan 2020 14:57:57 +0400 Subject: [PATCH] Menu and FPS changes (#303) * Set build target to 10 (generic) instead the specific build the original author used. * Move help menu down a line and indent to align with preset title and FPS. * More accurate FPS: - by resetting timers whenever F5 is pushed. - by performing math based on percise seconds that passed, rather than assuming it will trigger exactly 250 milliseconds. * Set idle preset name so it's displayed with F3. --- msvc/MilkdropPresetFactory.vcxproj | 2 +- msvc/MstressJuppyDancer.vcxproj | 2 +- msvc/NativePresetFactory.vcxproj | 2 +- msvc/Renderer.vcxproj | 2 +- msvc/RovastarDarkSecret.vcxproj | 2 +- msvc/RovastarDriftingChaos.vcxproj | 2 +- msvc/RovastarFractalSpiral.vcxproj | 2 +- msvc/RovastarFractopiaFrantic.vcxproj | 2 +- msvc/projectM-qt.vcxproj | 2 +- msvc/projectM.vcxproj | 2 +- msvc/projectMSDL.vcxproj | 2 +- src/libprojectM/KeyHandler.cpp | 23 ++++++++++++++--------- src/libprojectM/Renderer/Renderer.cpp | 9 ++++----- src/libprojectM/projectM.cpp | 1 + 14 files changed, 30 insertions(+), 25 deletions(-) diff --git a/msvc/MilkdropPresetFactory.vcxproj b/msvc/MilkdropPresetFactory.vcxproj index 2d5db4823..f5c22d4e2 100644 --- a/msvc/MilkdropPresetFactory.vcxproj +++ b/msvc/MilkdropPresetFactory.vcxproj @@ -12,7 +12,7 @@ {EF3369C9-E934-3F1E-996B-21518B57A809} - 10.0.17763.0 + 10.0 Win32Proj x64 MilkdropPresetFactory diff --git a/msvc/MstressJuppyDancer.vcxproj b/msvc/MstressJuppyDancer.vcxproj index 0f426012d..d68876844 100644 --- a/msvc/MstressJuppyDancer.vcxproj +++ b/msvc/MstressJuppyDancer.vcxproj @@ -12,7 +12,7 @@ {55A71B6A-5C7E-30D5-8210-302A8D2080DB} - 10.0.17763.0 + 10.0 Win32Proj x64 MstressJuppyDancer diff --git a/msvc/NativePresetFactory.vcxproj b/msvc/NativePresetFactory.vcxproj index b7f4ea29a..5854bfb79 100644 --- a/msvc/NativePresetFactory.vcxproj +++ b/msvc/NativePresetFactory.vcxproj @@ -12,7 +12,7 @@ {E2D4CEE6-B8CB-32AC-8977-52A48C8DA4E1} - 10.0.17763.0 + 10.0 Win32Proj x64 NativePresetFactory diff --git a/msvc/Renderer.vcxproj b/msvc/Renderer.vcxproj index 7b7f7409d..361285ba3 100644 --- a/msvc/Renderer.vcxproj +++ b/msvc/Renderer.vcxproj @@ -12,7 +12,7 @@ {07427FA1-1771-3A2D-9183-167A8345DEEB} - 10.0.17763.0 + 10.0 Win32Proj x64 Renderer diff --git a/msvc/RovastarDarkSecret.vcxproj b/msvc/RovastarDarkSecret.vcxproj index e69781ddf..ab37a21af 100644 --- a/msvc/RovastarDarkSecret.vcxproj +++ b/msvc/RovastarDarkSecret.vcxproj @@ -12,7 +12,7 @@ {7A203034-A4D7-3A2B-9138-CB125F9B35E6} - 10.0.17763.0 + 10.0 Win32Proj x64 RovastarDarkSecret diff --git a/msvc/RovastarDriftingChaos.vcxproj b/msvc/RovastarDriftingChaos.vcxproj index fd0ec57a6..de80d883a 100644 --- a/msvc/RovastarDriftingChaos.vcxproj +++ b/msvc/RovastarDriftingChaos.vcxproj @@ -12,7 +12,7 @@ {6E418BC8-5407-3A37-96BD-5201D47DE753} - 10.0.17763.0 + 10.0 Win32Proj x64 RovastarDriftingChaos diff --git a/msvc/RovastarFractalSpiral.vcxproj b/msvc/RovastarFractalSpiral.vcxproj index 353b26b59..60807d90c 100644 --- a/msvc/RovastarFractalSpiral.vcxproj +++ b/msvc/RovastarFractalSpiral.vcxproj @@ -12,7 +12,7 @@ {B7C4937F-A36D-3B6C-A8AC-CA99772AE5EC} - 10.0.17763.0 + 10.0 Win32Proj x64 RovastarFractalSpiral diff --git a/msvc/RovastarFractopiaFrantic.vcxproj b/msvc/RovastarFractopiaFrantic.vcxproj index 180936990..f8bf2dc77 100644 --- a/msvc/RovastarFractopiaFrantic.vcxproj +++ b/msvc/RovastarFractopiaFrantic.vcxproj @@ -12,7 +12,7 @@ {27DDCE71-E33B-3521-92B5-9918356D78A1} - 10.0.17763.0 + 10.0 Win32Proj x64 RovastarFractopiaFrantic diff --git a/msvc/projectM-qt.vcxproj b/msvc/projectM-qt.vcxproj index c36588d6d..603365f42 100644 --- a/msvc/projectM-qt.vcxproj +++ b/msvc/projectM-qt.vcxproj @@ -12,7 +12,7 @@ {9260C46C-6BC9-396F-9310-6BAAD56A7801} - 10.0.17763.0 + 10.0 Win32Proj x64 projectM-qt diff --git a/msvc/projectM.vcxproj b/msvc/projectM.vcxproj index 92e7590cd..66edbb09f 100644 --- a/msvc/projectM.vcxproj +++ b/msvc/projectM.vcxproj @@ -12,7 +12,7 @@ {DABC69A6-66C3-392C-8A62-EC989B0850A4} - 10.0.17763.0 + 10.0 Win32Proj x64 projectM diff --git a/msvc/projectMSDL.vcxproj b/msvc/projectMSDL.vcxproj index 55b4534df..4b38770bb 100644 --- a/msvc/projectMSDL.vcxproj +++ b/msvc/projectMSDL.vcxproj @@ -12,7 +12,7 @@ {013DE011-EC24-3643-A8EE-F2609E7E4741} - 10.0.17763.0 + 10.0 Win32Proj x64 projectMSDL diff --git a/src/libprojectM/KeyHandler.cpp b/src/libprojectM/KeyHandler.cpp index d4b56b425..3d2f4454c 100755 --- a/src/libprojectM/KeyHandler.cpp +++ b/src/libprojectM/KeyHandler.cpp @@ -123,7 +123,6 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode case PROJECTM_K_h: renderer->showhelp = !renderer->showhelp; renderer->showstats= false; - renderer->showfps=false; case PROJECTM_K_F1: renderer->showhelp = !renderer->showhelp; renderer->showstats=false; @@ -135,10 +134,15 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode case PROJECTM_K_F5: renderer->showfps = !renderer->showfps; - if (renderer->showfps) - { - renderer->showpreset = false; - } + // Initialize counters and reset frame count. + renderer->lastTime = duration_cast(system_clock::now().time_since_epoch()); + renderer->currentTime = duration_cast(system_clock::now().time_since_epoch()); + renderer->totalframes = 0; + // Hide preset name from screen and replace it with FPS counter. + if (renderer->showfps) + { + renderer->showpreset = false; + } break; case PROJECTM_K_F4: if (!renderer->showhelp) @@ -146,10 +150,11 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode break; case PROJECTM_K_F3: { renderer->showpreset = !renderer->showpreset; - if (renderer->showpreset) - { - renderer->showfps = false; - } + // Hide FPS from screen and replace it with preset name. + if (renderer->showpreset) + { + renderer->showfps = false; + } break; } case PROJECTM_K_F2: diff --git a/src/libprojectM/Renderer/Renderer.cpp b/src/libprojectM/Renderer/Renderer.cpp index d6255a782..90884e438 100644 --- a/src/libprojectM/Renderer/Renderer.cpp +++ b/src/libprojectM/Renderer/Renderer.cpp @@ -240,7 +240,7 @@ void Renderer::SetupPass1(const Pipeline& pipeline, const PipelineContext& pipel /* If FPS is displayed (by pressing F5 or by config): - check if 250 milliseconds has passed (1/4 of a second) - - multiply the total rendered frames (totalframes) by four to get the approximate frames per second count. + - multiply the total rendered frames (totalframes) by the fraction of a second that passed to get the approximate frames per second count. - reset the totalframes and timer (lastTime) so we don't trigger for another 250 milliseconds. */ if (this->showfps) @@ -250,7 +250,7 @@ void Renderer::SetupPass1(const Pipeline& pipeline, const PipelineContext& pipel double diff = ms.count(); if (diff >= 250) { - this->realfps = totalframes * 4; + this->realfps = totalframes * (1000 / diff); setFPS(realfps); totalframes = 0; this->lastTime = duration_cast(system_clock::now().time_since_epoch()); @@ -572,8 +572,7 @@ void Renderer::draw_help() { #ifdef USE_TEXT_MENU // TODO: match winamp/milkdrop bindings - drawText("Help""\n" - "-------------------------------""\n" + drawText("\n" "F1: This help menu""\n" "F3: Show preset name""\n" "F5: Show FPS""\n" @@ -583,7 +582,7 @@ void Renderer::draw_help() "P: Previous preset""\n" "UP: Increase Beat Sensitivity""\n" "DOWN: Decrease Beat Sensitivity""\n" - "CTRL-F: Fullscreen", 1, 20, 2.5); + "CTRL-F: Fullscreen", 30, 20, 2.5); #endif /** USE_TEXT_MENU */ } diff --git a/src/libprojectM/projectM.cpp b/src/libprojectM/projectM.cpp index 40b3616e5..7c66890aa 100755 --- a/src/libprojectM/projectM.cpp +++ b/src/libprojectM/projectM.cpp @@ -656,6 +656,7 @@ int projectM::initPresetTools(int gx, int gy) // std::cerr << "[projectM] Allocating idle preset..." << std::endl; m_activePreset = m_presetLoader->loadPreset ("idle://Geiss & Sperl - Feedback (projectM idle HDR mix).milk"); + renderer->setPresetName("Geiss & Sperl - Feedback (projectM idle HDR mix)"); renderer->SetPipeline(m_activePreset->pipeline());