impr: Added more generic way to unlock frame rate when needed

This commit is contained in:
WerWolv
2025-07-27 16:25:10 +02:00
parent c7b2f26bd5
commit f42ae97f14
6 changed files with 28 additions and 2 deletions
@@ -454,6 +454,9 @@ EXPORT_MODULE namespace hex {
void cleanup();
bool frameRateUnlockRequested();
void resetFrameRateUnlockRequested();
}
/**
@@ -720,6 +723,10 @@ EXPORT_MODULE namespace hex {
*/
void addMigrationRoutine(SemanticVersion migrationVersion, std::function<void()> function);
/**
* @brief Unlocks the frame rate temporarily, allowing animations to run smoothly
*/
void unlockFrameRate();
}
/**
+11
View File
@@ -597,6 +597,14 @@ namespace hex {
object->reset();
}
static bool s_frameRateUnlockRequested = false;
bool frameRateUnlockRequested() {
return s_frameRateUnlockRequested;
}
void resetFrameRateUnlockRequested() {
s_frameRateUnlockRequested = false;
}
}
@@ -967,6 +975,9 @@ namespace hex {
impl::s_windowResizable = resizable;
}
void unlockFrameRate() {
impl::s_frameRateUnlockRequested = true;
}
}
+4 -2
View File
@@ -355,8 +355,10 @@ namespace hex {
if (ImGui::GetPlatformIO().Viewports.size() > 1)
unlockFrameRate();
// Unlock frame rate if there's any task running that shows a loading animation
if (TaskManager::getRunningTaskCount() > 0 || TaskManager::getRunningBlockingTaskCount() > 0) {
// Unlock frame rate if the frame rate was requested to be unlocked
if (ImHexApi::System::impl::frameRateUnlockRequested()) {
ImHexApi::System::impl::resetFrameRateUnlockRequested();
glfwPostEmptyEvent();
unlockFrameRate();
}
@@ -15,6 +15,8 @@ namespace hex::plugin::builtin {
m_onFinish(std::move(onFinish)){ }
void drawContent() override {
ImHexApi::System::unlockFrameRate();
ImGui::TextUnformatted("hex.builtin.popup.waiting_for_tasks.desc"_lang);
ImGui::Separator();
@@ -283,6 +283,8 @@ namespace hex::plugin::builtin {
if (frontTask == nullptr)
return;
ImHexApi::System::unlockFrameRate();
const auto progress = frontTask->getMaxValue() == 0 ? -1 : float(frontTask->getValue()) / float(frontTask->getMaxValue());
ImHexApi::System::setTaskBarProgress(ImHexApi::System::TaskProgressState::Progress, ImHexApi::System::TaskProgressType::Normal, u32(progress * 100));
@@ -186,6 +186,8 @@ namespace hex::plugin::builtin {
if (over)
return;
ImHexApi::System::unlockFrameRate();
const auto drawTile = [&](u32 x, u32 y) {
drawList->AddRectFilled(
{