From df5fa7a39e1a6054bc61565b53767ca5a330bf47 Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 21 Nov 2022 20:40:10 +0100 Subject: [PATCH] SaveTool: remove the FPS cap implementation. I should port the code from my raycaster engine to here. --- src/SaveTool/SaveTool.cpp | 9 ++------- src/SaveTool/SaveTool.h | 4 +--- src/SaveTool/SaveTool_Initialisation.cpp | 8 ++------ src/SaveTool/SaveTool_drawMainMenu.cpp | 21 ++------------------- 4 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 80f31ae..b121988 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -136,10 +136,6 @@ SaveTool::SaveTool(const Arguments& arguments): case Framelimit::HalfVsync: setSwapInterval(2); break; - case Framelimit::FpsCap: - setSwapInterval(0); - setMinimalLoopPeriod(1000/_fpsCap); - break; } curl_global_init(CURL_GLOBAL_DEFAULT); @@ -184,9 +180,8 @@ SaveTool::~SaveTool() { case Framelimit::HalfVsync: _conf.setValue("frame_limit"_s, "half_vsync"_s); break; - case Framelimit::FpsCap: - _conf.setValue("frame_limit"_s, _fpsCap); - break; + default: + _conf.setValue("frame_limit"_s, "vsync"_s); } _conf.save(); diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index 4196c8e..0ddb586 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -262,10 +262,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener enum class Framelimit: UnsignedByte { Vsync, - HalfVsync, - FpsCap + HalfVsync } _framelimit{Framelimit::Vsync}; - UnsignedInt _fpsCap{60}; bool _skipDisclaimer{false}; bool _checkUpdatesOnStartup{true}; diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/SaveTool/SaveTool_Initialisation.cpp index 94465a1..38c0571 100644 --- a/src/SaveTool/SaveTool_Initialisation.cpp +++ b/src/SaveTool/SaveTool_Initialisation.cpp @@ -73,15 +73,11 @@ void SaveTool::initialiseConfiguration() { if(_conf.hasValue("frame_limit"_s)) { std::string frame_limit = _conf.value("frame_limit"_s); - if(frame_limit == "vsync"_s) { - _framelimit = Framelimit::Vsync; - } - else if(frame_limit == "half_vsync"_s) { + if(frame_limit == "half_vsync"_s) { _framelimit = Framelimit::HalfVsync; } else { - _framelimit = Framelimit::FpsCap; - _fpsCap = std::stoul(frame_limit); + _framelimit = Framelimit::Vsync; } } else { diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/SaveTool/SaveTool_drawMainMenu.cpp index 0ec6a1a..8708f6d 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/SaveTool/SaveTool_drawMainMenu.cpp @@ -58,11 +58,10 @@ void SaveTool::drawMainMenu() { drawAlignedText("Frame limiter:"); ImGui::SameLine(); - static const char* framelimit_labels[3] = { static auto selection = static_cast(_framelimit); + static const char* framelimit_labels[2] = { "V-sync", - "Half V-sync", - "FPS cap, no V-sync" + "Half V-sync" }; ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth()); @@ -77,26 +76,10 @@ void SaveTool::drawMainMenu() { _framelimit = Framelimit::HalfVsync; setSwapInterval(2); } - if(ImGui::Selectable(framelimit_labels[2], _framelimit == Framelimit::FpsCap)) { - selection = 2; - _framelimit = Framelimit::FpsCap; - setSwapInterval(0); - setMinimalLoopPeriod(1000 / _fpsCap); - } ImGui::EndCombo(); } - if(_framelimit == Framelimit::FpsCap) { - static constexpr UnsignedInt min_fps = 15; - static constexpr UnsignedInt max_fps = 150; - - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth()); - if(ImGui::SliderScalar("##FpsSlider", ImGuiDataType_U32, &_fpsCap, &min_fps, &max_fps, "%u FPS", ImGuiSliderFlags_AlwaysClamp)) { - setMinimalLoopPeriod(1000 / _fpsCap); - } - } - ImGui::Checkbox("Cheat mode", &_cheatMode); ImGui::SameLine(); ImGui::AlignTextToFramePadding();