1
0
mirror of synced 2025-01-31 03:53:44 +01:00

impr: Default to monitor synchronized FPS limit

This commit is contained in:
WerWolv 2023-04-13 17:12:40 +02:00
parent 1367e9cebe
commit 52925c99e8
5 changed files with 16 additions and 5 deletions

View File

@ -427,7 +427,7 @@ namespace hex {
}
static float s_targetFPS = 60.0F;
static float s_targetFPS = 14.0F;
float getTargetFPS() {
return s_targetFPS;

View File

@ -265,7 +265,10 @@ namespace hex {
// Limit frame rate
const auto targetFps = ImHexApi::System::getTargetFPS();
if (targetFps <= 200) {
if (targetFps < 15) {
glfwSwapInterval(1);
} else if (targetFps <= 200) {
glfwSwapInterval(0);
auto leftoverFrameTime = i64((this->m_lastFrameTime + 1 / targetFps - glfwGetTime()) * 1000);
if (leftoverFrameTime > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(leftoverFrameTime));

View File

@ -435,6 +435,7 @@
"hex.builtin.setting.interface.color": "Color theme",
"hex.builtin.setting.interface.fps": "FPS Limit",
"hex.builtin.setting.interface.fps.unlocked": "Unlocked",
"hex.builtin.setting.interface.fps.native": "Native",
"hex.builtin.setting.interface.language": "Language",
"hex.builtin.setting.interface.multi_windows": "Enable Multi Window support",
"hex.builtin.setting.interface.pattern_tree_style": "Pattern Tree Style",

View File

@ -223,9 +223,16 @@ namespace hex::plugin::builtin {
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.fps", 60, [](auto name, nlohmann::json &setting) {
static int fps = static_cast<int>(setting);
auto format = fps > 200 ? "hex.builtin.setting.interface.fps.unlocked"_lang : "%d FPS";
auto format = [] -> std::string {
if (fps > 200)
return "hex.builtin.setting.interface.fps.unlocked"_lang;
else if (fps < 15)
return "hex.builtin.setting.interface.fps.native"_lang;
else
return "%d FPS";
}();
if (ImGui::SliderInt(name.data(), &fps, 15, 201, format, ImGuiSliderFlags_AlwaysClamp)) {
if (ImGui::SliderInt(name.data(), &fps, 14, 201, format.c_str(), ImGuiSliderFlags_AlwaysClamp)) {
setting = fps;
return true;
}

View File

@ -461,7 +461,7 @@ namespace hex::plugin::builtin {
}
{
auto targetFps = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.fps", 60);
auto targetFps = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.fps", 14);
ImHexApi::System::setTargetFPS(targetFps);
}