Skip to content

Commit

Permalink
UI: Disable render dup frames where it can't work.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Mar 22, 2020
1 parent 0d2acb6 commit 3b05e83
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 3 additions & 0 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ void GameSettingsScreen::CreateViews() {
});
#endif
CheckBox *frameDuplication = graphicsSettings->Add(new CheckBox(&g_Config.bRenderDuplicateFrames, gr->T("Render duplicate frames to 60hz")));
frameDuplication->SetEnabledFunc([] {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE || (g_Config.bSoftwareRendering && g_Config.iFrameSkip != 0);
});
frameDuplication->OnClick.Add([=](EventParams &e) {
settingInfo_->Show(gr->T("RenderDuplicateFrames Tip", "Can make framerate smoother in games that run at lower framerates"), e.v);
return UI::EVENT_CONTINUE;
Expand Down
30 changes: 25 additions & 5 deletions ext/native/ui/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,34 @@ class View {
return GetFocusedView() == this;
}

void SetEnabled(bool enabled) { enabled_ = enabled; enabledMeansDisabled_ = false; }
void SetEnabled(bool enabled) {
enabledFunc_ = nullptr;
enabledPtr_ = nullptr;
enabled_ = enabled;
enabledMeansDisabled_ = false;
}
bool IsEnabled() const {
if (enabledFunc_)
return enabledFunc_() != enabledMeansDisabled_;
if (enabledPtr_)
return *enabledPtr_ != enabledMeansDisabled_;
else
return enabled_ != enabledMeansDisabled_;
return enabled_ != enabledMeansDisabled_;
}
void SetEnabledFunc(std::function<bool()> func) {
enabledFunc_ = func;
enabledPtr_ = nullptr;
enabledMeansDisabled_ = false;
}
void SetEnabledPtr(bool *enabled) {
enabledFunc_ = nullptr;
enabledPtr_ = enabled;
enabledMeansDisabled_ = false;
}
void SetDisabledPtr(bool *disabled) {
enabledFunc_ = nullptr;
enabledPtr_ = disabled;
enabledMeansDisabled_ = true;
}
void SetEnabledPtr(bool *enabled) { enabledPtr_ = enabled; enabledMeansDisabled_ = false; }
void SetDisabledPtr(bool *disabled) { enabledPtr_ = disabled; enabledMeansDisabled_ = true; }

virtual void SetVisibility(Visibility visibility) { visibility_ = visibility; }
Visibility GetVisibility() const { return visibility_; }
Expand Down Expand Up @@ -445,6 +464,7 @@ class View {
std::vector<Tween *> tweens_;

private:
std::function<bool()> enabledFunc_;
bool *enabledPtr_;
bool enabled_;
bool enabledMeansDisabled_;
Expand Down

0 comments on commit 3b05e83

Please sign in to comment.