Add more options for frame rate

This commit is contained in:
Benau 2022-11-10 11:17:23 +08:00
parent 4e8744f047
commit b4fff82dc1
4 changed files with 36 additions and 18 deletions

View File

@ -75,7 +75,7 @@
<spinner id="vsync" width="100%" align="center" />
</div>
<div layout="vertical-row" proportion="1" height="100%">
<label id="vsync_label" height="100%" I18N="In the video settings" text="Vertical Sync" align="left"/>
<label id="vsync_label" height="100%" I18N="In the video options, maximum frame per second" text="Maximum FPS" align="left"/>
</div>
</div>

View File

@ -530,6 +530,8 @@ begin:
UserConfigParams::m_vulkan_fullscreen_desktop) ||
UserConfigParams::m_non_ge_fullscreen_desktop;
#endif
if (UserConfigParams::m_swap_interval > 1)
UserConfigParams::m_swap_interval = 1;
// Try 32 and, upon failure, 24 then 16 bit per pixels
for (int bits=32; bits>15; bits -=8)

View File

@ -311,6 +311,8 @@ void getConfigForDevice(const char* dev)
}
}
}
// TODO remove when vulkan is used as it uses less power than gles3
UserConfigParams::m_max_fps = 30;
}
#endif

View File

@ -51,6 +51,7 @@
#include <functional>
#include <iostream>
#include <iterator>
#include <sstream>
using namespace GUIEngine;
@ -252,31 +253,30 @@ void OptionsScreenVideo::init()
assert( vsync != NULL );
vsync->clearLabels();
#ifdef IOS_STK
//I18N: In the video options, maximum frame per second
getWidget("vsync_label")->setText(_("Maximum FPS"));
vsync->addLabel("30");
vsync->addLabel("60");
vsync->addLabel("120");
vsync->setValue(UserConfigParams::m_swap_interval);
#else
vsync->addLabel(_("Disabled"));
//I18N: In the video options, full vertical sync (usually 60fps)
vsync->addLabel(_("Full"));
//I18N: In the video options
vsync->addLabel(_("Vertical Sync"));
std::set<int> fps = { 30, 60, 120, 180, 250, 500, 1000 };
fps.insert(UserConfigParams::m_max_fps);
for (auto& i : fps)
vsync->addLabel(core::stringw(i));
if (UserConfigParams::m_swap_interval > 1)
UserConfigParams::m_swap_interval = 1;
vsync->setValue(UserConfigParams::m_swap_interval);
if (UserConfigParams::m_swap_interval == 1)
vsync->setValue(0);
else
{
auto it = fps.find(UserConfigParams::m_max_fps);
assert(it != fps.end());
vsync->setValue(1 + std::distance(fps.begin(), it));
}
//I18N: in graphical options. The \n is a newline character, place it where appropriate, two can be used if required.
core::stringw vsync_tooltip = _("Vsync forces the graphics card to supply a new frame\nonly when the monitor is ready to display it.");
//I18N: in graphical options.
vsync_tooltip = vsync_tooltip + L"\n" + _("Full: one frame per monitor refresh");
//I18N: in graphical options.
vsync_tooltip = vsync_tooltip + L"\n" + _("Vsync will not work if your drivers don't support it.");
vsync->setTooltip(vsync_tooltip);
#endif
// Setup Render Resolution (scale_rtts) spinner
GUIEngine::SpinnerWidget* scale_rtts = getWidget<GUIEngine::SpinnerWidget>("scale_rtts");
@ -865,7 +865,21 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
{
GUIEngine::SpinnerWidget* vsync = getWidget<GUIEngine::SpinnerWidget>("vsync");
assert( vsync != NULL );
UserConfigParams::m_swap_interval = vsync->getValue();
int swap = vsync->getValue();
if (swap == 0)
{
UserConfigParams::m_swap_interval = 1;
UserConfigParams::m_max_fps.revertToDefaults();
}
else
{
UserConfigParams::m_swap_interval = 0;
std::string fps = StringUtils::wideToUtf8(vsync->getStringValue());
UserConfigParams::m_max_fps.revertToDefaults();
int max_fps = UserConfigParams::m_max_fps;
StringUtils::fromString(fps, max_fps);
UserConfigParams::m_max_fps = max_fps;
}
#if !defined(SERVER_ONLY) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
update_swap_interval(UserConfigParams::m_swap_interval);
#endif