impr: Default to monitor synchronized FPS limit
This commit is contained in:
parent
1367e9cebe
commit
52925c99e8
@ -427,7 +427,7 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static float s_targetFPS = 60.0F;
|
static float s_targetFPS = 14.0F;
|
||||||
|
|
||||||
float getTargetFPS() {
|
float getTargetFPS() {
|
||||||
return s_targetFPS;
|
return s_targetFPS;
|
||||||
|
@ -265,7 +265,10 @@ namespace hex {
|
|||||||
|
|
||||||
// Limit frame rate
|
// Limit frame rate
|
||||||
const auto targetFps = ImHexApi::System::getTargetFPS();
|
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);
|
auto leftoverFrameTime = i64((this->m_lastFrameTime + 1 / targetFps - glfwGetTime()) * 1000);
|
||||||
if (leftoverFrameTime > 0)
|
if (leftoverFrameTime > 0)
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(leftoverFrameTime));
|
std::this_thread::sleep_for(std::chrono::milliseconds(leftoverFrameTime));
|
||||||
|
@ -435,6 +435,7 @@
|
|||||||
"hex.builtin.setting.interface.color": "Color theme",
|
"hex.builtin.setting.interface.color": "Color theme",
|
||||||
"hex.builtin.setting.interface.fps": "FPS Limit",
|
"hex.builtin.setting.interface.fps": "FPS Limit",
|
||||||
"hex.builtin.setting.interface.fps.unlocked": "Unlocked",
|
"hex.builtin.setting.interface.fps.unlocked": "Unlocked",
|
||||||
|
"hex.builtin.setting.interface.fps.native": "Native",
|
||||||
"hex.builtin.setting.interface.language": "Language",
|
"hex.builtin.setting.interface.language": "Language",
|
||||||
"hex.builtin.setting.interface.multi_windows": "Enable Multi Window support",
|
"hex.builtin.setting.interface.multi_windows": "Enable Multi Window support",
|
||||||
"hex.builtin.setting.interface.pattern_tree_style": "Pattern Tree Style",
|
"hex.builtin.setting.interface.pattern_tree_style": "Pattern Tree Style",
|
||||||
|
@ -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) {
|
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);
|
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;
|
setting = fps;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
ImHexApi::System::setTargetFPS(targetFps);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user