Use settings values for Video settings

* Convert window mode, vsync mode into enums, screenshot type into a struct.
* Add missing doc for screenshot type.
macos_ci_fix
elsid 1 year ago
parent 8380da2e1d
commit dcd81d026f
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -96,32 +96,29 @@ bool Launcher::GraphicsPage::loadSettings()
// Visuals // Visuals
int vsync = Settings::Manager::getInt("vsync mode", "Video"); const int vsync = Settings::video().mVsyncMode;
if (vsync < 0 || vsync > 2)
vsync = 0;
vSyncComboBox->setCurrentIndex(vsync); vSyncComboBox->setCurrentIndex(vsync);
size_t windowMode = static_cast<size_t>(Settings::Manager::getInt("window mode", "Video")); const Settings::WindowMode windowMode = Settings::video().mWindowMode;
if (windowMode > static_cast<size_t>(Settings::WindowMode::Windowed))
windowMode = 0;
windowModeComboBox->setCurrentIndex(windowMode);
slotFullScreenChanged(windowMode);
if (Settings::Manager::getBool("window border", "Video")) windowModeComboBox->setCurrentIndex(static_cast<int>(windowMode));
handleWindowModeChange(windowMode);
if (Settings::video().mWindowBorder)
windowBorderCheckBox->setCheckState(Qt::Checked); windowBorderCheckBox->setCheckState(Qt::Checked);
// aaValue is the actual value (0, 1, 2, 4, 8, 16) // aaValue is the actual value (0, 1, 2, 4, 8, 16)
int aaValue = Settings::Manager::getInt("antialiasing", "Video"); const int aaValue = Settings::video().mAntialiasing;
// aaIndex is the index into the allowed values in the pull down. // aaIndex is the index into the allowed values in the pull down.
int aaIndex = antiAliasingComboBox->findText(QString::number(aaValue)); const int aaIndex = antiAliasingComboBox->findText(QString::number(aaValue));
if (aaIndex != -1) if (aaIndex != -1)
antiAliasingComboBox->setCurrentIndex(aaIndex); antiAliasingComboBox->setCurrentIndex(aaIndex);
int width = Settings::Manager::getInt("resolution x", "Video"); const int width = Settings::video().mResolutionX;
int height = Settings::Manager::getInt("resolution y", "Video"); const int height = Settings::video().mResolutionY;
QString resolution = QString::number(width) + QString(" x ") + QString::number(height); QString resolution = QString::number(width) + QString(" x ") + QString::number(height);
screenComboBox->setCurrentIndex(Settings::Manager::getInt("screen", "Video")); screenComboBox->setCurrentIndex(Settings::video().mScreen);
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith); int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
@ -137,7 +134,7 @@ bool Launcher::GraphicsPage::loadSettings()
customHeightSpinBox->setValue(height); customHeightSpinBox->setValue(height);
} }
float fpsLimit = Settings::Manager::getFloat("framerate limit", "Video"); const float fpsLimit = Settings::video().mFramerateLimit;
if (fpsLimit != 0) if (fpsLimit != 0)
{ {
framerateLimitCheckBox->setCheckState(Qt::Checked); framerateLimitCheckBox->setCheckState(Qt::Checked);
@ -198,23 +195,10 @@ void Launcher::GraphicsPage::saveSettings()
{ {
// Visuals // Visuals
// Ensure we only set the new settings if they changed. This is to avoid cluttering the Settings::video().mVsyncMode.set(static_cast<SDLUtil::VSyncMode>(vSyncComboBox->currentIndex()));
// user settings file (which by definition should only contain settings the user has touched) Settings::video().mWindowMode.set(static_cast<Settings::WindowMode>(windowModeComboBox->currentIndex()));
int cVSync = vSyncComboBox->currentIndex(); Settings::video().mWindowBorder.set(windowBorderCheckBox->checkState() == Qt::Checked);
if (cVSync != Settings::Manager::getInt("vsync mode", "Video")) Settings::video().mAntialiasing.set(antiAliasingComboBox->currentText().toInt());
Settings::Manager::setInt("vsync mode", "Video", cVSync);
int cWindowMode = windowModeComboBox->currentIndex();
if (cWindowMode != Settings::Manager::getInt("window mode", "Video"))
Settings::Manager::setInt("window mode", "Video", cWindowMode);
bool cWindowBorder = windowBorderCheckBox->checkState();
if (cWindowBorder != Settings::Manager::getBool("window border", "Video"))
Settings::Manager::setBool("window border", "Video", cWindowBorder);
int cAAValue = antiAliasingComboBox->currentText().toInt();
if (cAAValue != Settings::Manager::getInt("antialiasing", "Video"))
Settings::Manager::setInt("antialiasing", "Video", cAAValue);
int cWidth = 0; int cWidth = 0;
int cHeight = 0; int cHeight = 0;
@ -234,25 +218,17 @@ void Launcher::GraphicsPage::saveSettings()
cHeight = customHeightSpinBox->value(); cHeight = customHeightSpinBox->value();
} }
if (cWidth != Settings::Manager::getInt("resolution x", "Video")) Settings::video().mResolutionX.set(cWidth);
Settings::Manager::setInt("resolution x", "Video", cWidth); Settings::video().mResolutionY.set(cHeight);
Settings::video().mScreen.set(screenComboBox->currentIndex());
if (cHeight != Settings::Manager::getInt("resolution y", "Video"))
Settings::Manager::setInt("resolution y", "Video", cHeight);
int cScreen = screenComboBox->currentIndex();
if (cScreen != Settings::Manager::getInt("screen", "Video"))
Settings::Manager::setInt("screen", "Video", cScreen);
if (framerateLimitCheckBox->checkState() != Qt::Unchecked) if (framerateLimitCheckBox->checkState() != Qt::Unchecked)
{ {
float cFpsLimit = framerateLimitSpinBox->value(); Settings::video().mFramerateLimit.set(framerateLimitSpinBox->value());
if (cFpsLimit != Settings::Manager::getFloat("framerate limit", "Video"))
Settings::Manager::setFloat("framerate limit", "Video", cFpsLimit);
} }
else if (Settings::Manager::getFloat("framerate limit", "Video") != 0) else if (Settings::video().mFramerateLimit != 0)
{ {
Settings::Manager::setFloat("framerate limit", "Video", 0); Settings::video().mFramerateLimit.set(0);
} }
// Lighting // Lighting
@ -392,8 +368,12 @@ void Launcher::GraphicsPage::screenChanged(int screen)
void Launcher::GraphicsPage::slotFullScreenChanged(int mode) void Launcher::GraphicsPage::slotFullScreenChanged(int mode)
{ {
if (mode == static_cast<int>(Settings::WindowMode::Fullscreen) handleWindowModeChange(static_cast<Settings::WindowMode>(mode));
|| mode == static_cast<int>(Settings::WindowMode::WindowedFullscreen)) }
void Launcher::GraphicsPage::handleWindowModeChange(Settings::WindowMode mode)
{
if (mode == Settings::WindowMode::Fullscreen || mode == Settings::WindowMode::WindowedFullscreen)
{ {
standardRadioButton->toggle(); standardRadioButton->toggle();
customRadioButton->setEnabled(false); customRadioButton->setEnabled(false);

@ -3,7 +3,7 @@
#include "ui_graphicspage.h" #include "ui_graphicspage.h"
#include <components/settings/settings.hpp> #include <components/settings/windowmode.hpp>
namespace Files namespace Files
{ {
@ -40,6 +40,7 @@ namespace Launcher
static QRect getMaximumResolution(); static QRect getMaximumResolution();
bool setupSDL(); bool setupSDL();
void handleWindowModeChange(Settings::WindowMode state);
}; };
} }
#endif #endif

@ -1,13 +1,5 @@
#include "maindialog.hpp" #include "maindialog.hpp"
#include <components/debug/debuglog.hpp>
#include <components/files/configurationmanager.hpp>
#include <components/files/conversion.hpp>
#include <components/files/qtconversion.hpp>
#include <components/misc/helpviewer.hpp>
#include <components/misc/utf8qtextstream.hpp>
#include <components/version/version.hpp>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
@ -15,10 +7,15 @@
#include <QTime> #include <QTime>
#include <components/debug/debugging.hpp> #include <components/debug/debugging.hpp>
#include <components/debug/debuglog.hpp>
#include <components/files/configurationmanager.hpp>
#include <components/files/conversion.hpp> #include <components/files/conversion.hpp>
#include <components/files/qtconfigpath.hpp> #include <components/files/qtconfigpath.hpp>
#include <components/files/qtconversion.hpp> #include <components/files/qtconversion.hpp>
#include <components/misc/helpviewer.hpp>
#include <components/misc/utf8qtextstream.hpp> #include <components/misc/utf8qtextstream.hpp>
#include <components/settings/settings.hpp>
#include <components/version/version.hpp>
#include "datafilespage.hpp" #include "datafilespage.hpp"
#include "graphicspage.hpp" #include "graphicspage.hpp"

@ -452,14 +452,13 @@ void OMW::Engine::setSkipMenu(bool skipMenu, bool newGame)
void OMW::Engine::createWindow() void OMW::Engine::createWindow()
{ {
int screen = Settings::Manager::getInt("screen", "Video"); const int screen = Settings::video().mScreen;
int width = Settings::Manager::getInt("resolution x", "Video"); const int width = Settings::video().mResolutionX;
int height = Settings::Manager::getInt("resolution y", "Video"); const int height = Settings::video().mResolutionY;
Settings::WindowMode windowMode const Settings::WindowMode windowMode = Settings::video().mWindowMode;
= static_cast<Settings::WindowMode>(Settings::Manager::getInt("window mode", "Video")); const bool windowBorder = Settings::video().mWindowBorder;
bool windowBorder = Settings::Manager::getBool("window border", "Video"); const SDLUtil::VSyncMode vsync = Settings::video().mVsyncMode;
int vsync = Settings::Manager::getInt("vsync mode", "Video"); unsigned antialiasing = static_cast<unsigned>(Settings::video().mAntialiasing);
unsigned int antialiasing = std::max(0, Settings::Manager::getInt("antialiasing", "Video"));
int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(screen), pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(screen); int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(screen), pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(screen);
@ -482,8 +481,7 @@ void OMW::Engine::createWindow()
if (!windowBorder) if (!windowBorder)
flags |= SDL_WINDOW_BORDERLESS; flags |= SDL_WINDOW_BORDERLESS;
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, Settings::video().mMinimizeOnFocusLoss ? "1" : "0");
Settings::Manager::getBool("minimize on focus loss", "Video") ? "1" : "0");
checkSDLError(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8));
checkSDLError(SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8));
@ -513,7 +511,7 @@ void OMW::Engine::createWindow()
Log(Debug::Warning) << "Warning: " << antialiasing << "x antialiasing not supported, trying " Log(Debug::Warning) << "Warning: " << antialiasing << "x antialiasing not supported, trying "
<< antialiasing / 2; << antialiasing / 2;
antialiasing /= 2; antialiasing /= 2;
Settings::Manager::setInt("antialiasing", "Video", antialiasing); Settings::video().mAntialiasing.set(antialiasing);
checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing));
continue; continue;
} }
@ -560,7 +558,7 @@ void OMW::Engine::createWindow()
SDL_DestroyWindow(mWindow); SDL_DestroyWindow(mWindow);
mWindow = nullptr; mWindow = nullptr;
antialiasing /= 2; antialiasing /= 2;
Settings::Manager::setInt("antialiasing", "Video", antialiasing); Settings::video().mAntialiasing.set(antialiasing);
checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing));
continue; continue;
} }
@ -866,7 +864,7 @@ void OMW::Engine::go()
// Do not try to outsmart the OS thread scheduler (see bug #4785). // Do not try to outsmart the OS thread scheduler (see bug #4785).
mViewer->setUseConfigureAffinity(false); mViewer->setUseConfigureAffinity(false);
mEnvironment.setFrameRateLimit(Settings::Manager::getFloat("framerate limit", "Video")); mEnvironment.setFrameRateLimit(Settings::video().mFramerateLimit);
prepareEngine(); prepareEngine();

@ -354,7 +354,7 @@ namespace MWGui
+= MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings); += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
// fill resolution list // fill resolution list
int screen = Settings::Manager::getInt("screen", "Video"); const int screen = Settings::video().mScreen;
int numDisplayModes = SDL_GetNumDisplayModes(screen); int numDisplayModes = SDL_GetNumDisplayModes(screen);
std::vector<std::pair<int, int>> resolutions; std::vector<std::pair<int, int>> resolutions;
for (int i = 0; i < numDisplayModes; i++) for (int i = 0; i < numDisplayModes; i++)
@ -396,8 +396,7 @@ namespace MWGui
updateMaxLightsComboBox(mMaxLights); updateMaxLightsComboBox(mMaxLights);
Settings::WindowMode windowMode const Settings::WindowMode windowMode = Settings::video().mWindowMode;
= static_cast<Settings::WindowMode>(Settings::Manager::getInt("window mode", "Video"));
mWindowBorderButton->setEnabled( mWindowBorderButton->setEnabled(
windowMode != Settings::WindowMode::Fullscreen && windowMode != Settings::WindowMode::WindowedFullscreen); windowMode != Settings::WindowMode::Fullscreen && windowMode != Settings::WindowMode::WindowedFullscreen);
@ -491,8 +490,8 @@ namespace MWGui
int resX, resY; int resX, resY;
parseResolution(resX, resY, resStr); parseResolution(resX, resY, resStr);
Settings::Manager::setInt("resolution x", "Video", resX); Settings::video().mResolutionX.set(resX);
Settings::Manager::setInt("resolution y", "Video", resY); Settings::video().mResolutionY.set(resY);
apply(); apply();
} }
@ -506,8 +505,8 @@ namespace MWGui
{ {
mResolutionList->setIndexSelected(MyGUI::ITEM_NONE); mResolutionList->setIndexSelected(MyGUI::ITEM_NONE);
int currentX = Settings::Manager::getInt("resolution x", "Video"); const int currentX = Settings::video().mResolutionX;
int currentY = Settings::Manager::getInt("resolution y", "Video"); const int currentY = Settings::video().mResolutionY;
for (size_t i = 0; i < mResolutionList->getItemCount(); ++i) for (size_t i = 0; i < mResolutionList->getItemCount(); ++i)
{ {
@ -591,23 +590,22 @@ namespace MWGui
"#{OMWEngine:ChangeRequiresRestart}", { "#{Interface:OK}" }, true); "#{OMWEngine:ChangeRequiresRestart}", { "#{Interface:OK}" }, true);
} }
void SettingsWindow::onVSyncModeChanged(MyGUI::ComboBox* _sender, size_t pos) void SettingsWindow::onVSyncModeChanged(MyGUI::ComboBox* sender, size_t pos)
{ {
if (pos == MyGUI::ITEM_NONE) if (pos == MyGUI::ITEM_NONE)
return; return;
int index = static_cast<int>(_sender->getIndexSelected()); Settings::video().mVsyncMode.set(static_cast<SDLUtil::VSyncMode>(sender->getIndexSelected()));
Settings::Manager::setInt("vsync mode", "Video", index);
apply(); apply();
} }
void SettingsWindow::onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos) void SettingsWindow::onWindowModeChanged(MyGUI::ComboBox* sender, size_t pos)
{ {
if (pos == MyGUI::ITEM_NONE) if (pos == MyGUI::ITEM_NONE)
return; return;
int index = static_cast<int>(_sender->getIndexSelected()); const Settings::WindowMode windowMode = static_cast<Settings::WindowMode>(sender->getIndexSelected());
if (index == static_cast<size_t>(Settings::WindowMode::WindowedFullscreen)) if (windowMode == Settings::WindowMode::WindowedFullscreen)
{ {
mResolutionList->setEnabled(false); mResolutionList->setEnabled(false);
mWindowModeHint->setVisible(true); mWindowModeHint->setVisible(true);
@ -618,12 +616,12 @@ namespace MWGui
mWindowModeHint->setVisible(false); mWindowModeHint->setVisible(false);
} }
if (index == static_cast<size_t>(Settings::WindowMode::Windowed)) if (windowMode == Settings::WindowMode::Windowed)
mWindowBorderButton->setEnabled(true); mWindowBorderButton->setEnabled(true);
else else
mWindowBorderButton->setEnabled(false); mWindowBorderButton->setEnabled(false);
Settings::Manager::setInt("window mode", "Video", index); Settings::video().mWindowMode.set(windowMode);
apply(); apply();
} }
@ -849,14 +847,12 @@ namespace MWGui
void SettingsWindow::updateWindowModeSettings() void SettingsWindow::updateWindowModeSettings()
{ {
size_t index = static_cast<size_t>(Settings::Manager::getInt("window mode", "Video")); const Settings::WindowMode windowMode = Settings::video().mWindowMode;
const std::size_t windowModeIndex = static_cast<std::size_t>(windowMode);
if (index > static_cast<size_t>(Settings::WindowMode::Windowed)) mWindowModeList->setIndexSelected(windowModeIndex);
index = MyGUI::ITEM_NONE;
mWindowModeList->setIndexSelected(index); if (windowMode != Settings::WindowMode::Windowed && windowModeIndex != MyGUI::ITEM_NONE)
if (index != static_cast<size_t>(Settings::WindowMode::Windowed) && index != MyGUI::ITEM_NONE)
{ {
// check if this resolution is supported in fullscreen // check if this resolution is supported in fullscreen
if (mResolutionList->getIndexSelected() != MyGUI::ITEM_NONE) if (mResolutionList->getIndexSelected() != MyGUI::ITEM_NONE)
@ -864,8 +860,8 @@ namespace MWGui
const std::string& resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected()); const std::string& resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected());
int resX, resY; int resX, resY;
parseResolution(resX, resY, resStr); parseResolution(resX, resY, resStr);
Settings::Manager::setInt("resolution x", "Video", resX); Settings::video().mResolutionX.set(resX);
Settings::Manager::setInt("resolution y", "Video", resY); Settings::video().mResolutionY.set(resY);
} }
bool supported = false; bool supported = false;
@ -882,8 +878,7 @@ namespace MWGui
fallbackY = resY; fallbackY = resY;
} }
if (resX == Settings::Manager::getInt("resolution x", "Video") if (resX == Settings::video().mResolutionX && resY == Settings::video().mResolutionY)
&& resY == Settings::Manager::getInt("resolution y", "Video"))
supported = true; supported = true;
} }
@ -891,26 +886,21 @@ namespace MWGui
{ {
if (fallbackX != 0 && fallbackY != 0) if (fallbackX != 0 && fallbackY != 0)
{ {
Settings::Manager::setInt("resolution x", "Video", fallbackX); Settings::video().mResolutionX.set(fallbackX);
Settings::Manager::setInt("resolution y", "Video", fallbackY); Settings::video().mResolutionY.set(fallbackY);
} }
} }
mWindowBorderButton->setEnabled(false); mWindowBorderButton->setEnabled(false);
} }
if (index == static_cast<size_t>(Settings::WindowMode::WindowedFullscreen)) if (windowMode == Settings::WindowMode::WindowedFullscreen)
mResolutionList->setEnabled(false); mResolutionList->setEnabled(false);
} }
void SettingsWindow::updateVSyncModeSettings() void SettingsWindow::updateVSyncModeSettings()
{ {
int index = static_cast<size_t>(Settings::Manager::getInt("vsync mode", "Video")); mVSyncModeList->setIndexSelected(static_cast<size_t>(Settings::video().mVsyncMode));
if (index < 0 || index > 2)
index = 0;
mVSyncModeList->setIndexSelected(index);
} }
void SettingsWindow::layoutControlsBox() void SettingsWindow::layoutControlsBox()

@ -294,8 +294,7 @@ namespace MWGui
+= MyGUI::newDelegate(this, &WindowManager::onClipboardRequested); += MyGUI::newDelegate(this, &WindowManager::onClipboardRequested);
mVideoWrapper = std::make_unique<SDLUtil::VideoWrapper>(window, viewer); mVideoWrapper = std::make_unique<SDLUtil::VideoWrapper>(window, viewer);
mVideoWrapper->setGammaContrast( mVideoWrapper->setGammaContrast(Settings::video().mGamma, Settings::video().mContrast);
Settings::Manager::getFloat("gamma", "Video"), Settings::Manager::getFloat("contrast", "Video"));
if (useShaders) if (useShaders)
mGuiPlatform->getRenderManagerPtr()->enableShaders(mResourceSystem->getSceneManager()->getShaderManager()); mGuiPlatform->getRenderManagerPtr()->enableShaders(mResourceSystem->getSceneManager()->getShaderManager());
@ -1157,25 +1156,22 @@ namespace MWGui
changeRes = true; changeRes = true;
else if (setting.first == "Video" && setting.second == "vsync mode") else if (setting.first == "Video" && setting.second == "vsync mode")
mVideoWrapper->setSyncToVBlank(Settings::Manager::getInt("vsync mode", "Video")); mVideoWrapper->setSyncToVBlank(Settings::video().mVsyncMode);
else if (setting.first == "Video" && (setting.second == "gamma" || setting.second == "contrast")) else if (setting.first == "Video" && (setting.second == "gamma" || setting.second == "contrast"))
mVideoWrapper->setGammaContrast( mVideoWrapper->setGammaContrast(Settings::video().mGamma, Settings::video().mContrast);
Settings::Manager::getFloat("gamma", "Video"), Settings::Manager::getFloat("contrast", "Video"));
} }
if (changeRes) if (changeRes)
{ {
mVideoWrapper->setVideoMode(Settings::Manager::getInt("resolution x", "Video"), mVideoWrapper->setVideoMode(Settings::video().mResolutionX, Settings::video().mResolutionY,
Settings::Manager::getInt("resolution y", "Video"), Settings::video().mWindowMode, Settings::video().mWindowBorder);
static_cast<Settings::WindowMode>(Settings::Manager::getInt("window mode", "Video")),
Settings::Manager::getBool("window border", "Video"));
} }
} }
void WindowManager::windowResized(int x, int y) void WindowManager::windowResized(int x, int y)
{ {
Settings::Manager::setInt("resolution x", "Video", x); Settings::video().mResolutionX.set(x);
Settings::Manager::setInt("resolution y", "Video", y); Settings::video().mResolutionY.set(y);
// We only want to process changes to window-size related settings. // We only want to process changes to window-size related settings.
Settings::CategorySettingVector filter = { { "Video", "resolution x" }, { "Video", "resolution y" } }; Settings::CategorySettingVector filter = { { "Video", "resolution x" }, { "Video", "resolution y" } };

@ -4,7 +4,7 @@
#include <SDL_keyboard.h> #include <SDL_keyboard.h>
#include <components/settings/settings.hpp> #include <components/settings/values.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
@ -170,10 +170,9 @@ namespace MWInput
void ActionManager::screenshot() void ActionManager::screenshot()
{ {
const std::string& settingStr = Settings::Manager::getString("screenshot type", "Video"); const Settings::ScreenshotSettings& settings = Settings::video().mScreenshotType;
bool regularScreenshot = settingStr.empty() || settingStr == "regular";
if (regularScreenshot) if (settings.mType == Settings::ScreenshotType::Regular)
{ {
mScreenCaptureHandler->setFramesToCapture(1); mScreenCaptureHandler->setFramesToCapture(1);
mScreenCaptureHandler->captureNextFrame(*mViewer); mScreenCaptureHandler->captureNextFrame(*mViewer);

@ -42,8 +42,7 @@ namespace MWInput
float angle = 0; float angle = 0;
SDL_DisplayOrientation currentOrientation SDL_DisplayOrientation currentOrientation = SDL_GetDisplayOrientation(Settings::video().mScreen);
= SDL_GetDisplayOrientation(Settings::Manager::getInt("screen", "Video"));
switch (currentOrientation) switch (currentOrientation)
{ {
case SDL_ORIENTATION_UNKNOWN: case SDL_ORIENTATION_UNKNOWN:

@ -94,8 +94,8 @@ namespace MWLua
api["getViewTransform"] = [camera]() { return LuaUtil::TransformM{ camera->getViewMatrix() }; }; api["getViewTransform"] = [camera]() { return LuaUtil::TransformM{ camera->getViewMatrix() }; };
api["viewportToWorldVector"] = [camera, renderingManager](osg::Vec2f pos) -> osg::Vec3f { api["viewportToWorldVector"] = [camera, renderingManager](osg::Vec2f pos) -> osg::Vec3f {
double width = Settings::Manager::getInt("resolution x", "Video"); const double width = Settings::video().mResolutionX;
double height = Settings::Manager::getInt("resolution y", "Video"); const double height = Settings::video().mResolutionY;
double aspect = (height == 0.0) ? 1.0 : width / height; double aspect = (height == 0.0) ? 1.0 : width / height;
double fovTan = std::tan(osg::DegreesToRadians(renderingManager->getFieldOfView()) / 2); double fovTan = std::tan(osg::DegreesToRadians(renderingManager->getFieldOfView()) / 2);
osg::Matrixf invertedViewMatrix; osg::Matrixf invertedViewMatrix;
@ -106,8 +106,8 @@ namespace MWLua
}; };
api["worldToViewportVector"] = [camera](osg::Vec3f pos) { api["worldToViewportVector"] = [camera](osg::Vec3f pos) {
double width = Settings::Manager::getInt("resolution x", "Video"); const double width = Settings::video().mResolutionX;
double height = Settings::Manager::getInt("resolution y", "Video"); const double height = Settings::video().mResolutionY;
osg::Matrix windowMatrix osg::Matrix windowMatrix
= osg::Matrix::translate(1.0, 1.0, 1.0) * osg::Matrix::scale(0.5 * width, 0.5 * height, 0.5); = osg::Matrix::translate(1.0, 1.0, 1.0) * osg::Matrix::scale(0.5 * width, 0.5 * height, 0.5);

@ -239,10 +239,7 @@ namespace MWLua
return luaManager->uiResourceManager()->registerTexture(data); return luaManager->uiResourceManager()->registerTexture(data);
}; };
api["screenSize"] = []() { api["screenSize"] = []() { return osg::Vec2f(Settings::video().mResolutionX, Settings::video().mResolutionY); };
return osg::Vec2f(
Settings::Manager::getInt("resolution x", "Video"), Settings::Manager::getInt("resolution y", "Video"));
};
api["_getAllUiModes"] = [](sol::this_state lua) { api["_getAllUiModes"] = [](sol::this_state lua) {
sol::table res(lua, sol::create); sol::table res(lua, sol::create);

@ -154,7 +154,7 @@ namespace MWRender
public: public:
CharacterPreviewRTTNode(uint32_t sizeX, uint32_t sizeY) CharacterPreviewRTTNode(uint32_t sizeX, uint32_t sizeY)
: RTTNode(sizeX, sizeY, Settings::Manager::getInt("antialiasing", "Video"), false, 0, : RTTNode(sizeX, sizeY, Settings::video().mAntialiasing, false, 0,
StereoAwareness::Unaware_MultiViewShaders, shouldAddMSAAIntermediateTarget()) StereoAwareness::Unaware_MultiViewShaders, shouldAddMSAAIntermediateTarget())
, mAspectRatio(static_cast<float>(sizeX) / static_cast<float>(sizeY)) , mAspectRatio(static_cast<float>(sizeX) / static_cast<float>(sizeY))
{ {

@ -112,7 +112,7 @@ namespace MWRender
: osg::Group() : osg::Group()
, mEnableLiveReload(false) , mEnableLiveReload(false)
, mRootNode(rootNode) , mRootNode(rootNode)
, mSamples(Settings::Manager::getInt("antialiasing", "Video")) , mSamples(Settings::video().mAntialiasing)
, mDirty(false) , mDirty(false)
, mDirtyFrameId(0) , mDirtyFrameId(0)
, mRendering(rendering) , mRendering(rendering)

@ -1230,8 +1230,8 @@ namespace MWRender
if (mViewDistance < mNearClip) if (mViewDistance < mNearClip)
throw std::runtime_error("Viewing distance is less than near clip"); throw std::runtime_error("Viewing distance is less than near clip");
double width = Settings::Manager::getInt("resolution x", "Video"); const double width = Settings::video().mResolutionX;
double height = Settings::Manager::getInt("resolution y", "Video"); const double height = Settings::video().mResolutionY;
double aspect = (height == 0.0) ? 1.0 : width / height; double aspect = (height == 0.0) ? 1.0 : width / height;
float fov = mFieldOfView; float fov = mFieldOfView;

@ -8,6 +8,7 @@
#include <osg/Texture2D> #include <osg/Texture2D>
#include <osg/TextureCubeMap> #include <osg/TextureCubeMap>
#include <components/loadinglistener/loadinglistener.hpp>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
#include <components/misc/strings/conversion.hpp> #include <components/misc/strings/conversion.hpp>
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
@ -20,7 +21,6 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwgui/loadingscreen.hpp"
#include "postprocessor.hpp" #include "postprocessor.hpp"
#include "util.hpp" #include "util.hpp"
@ -29,7 +29,7 @@
namespace MWRender namespace MWRender
{ {
enum Screenshot360Type enum class Screenshot360Type
{ {
Spherical, Spherical,
Cylindrical, Cylindrical,
@ -161,59 +161,46 @@ namespace MWRender
bool ScreenshotManager::screenshot360(osg::Image* image) bool ScreenshotManager::screenshot360(osg::Image* image)
{ {
int screenshotW = mViewer->getCamera()->getViewport()->width(); const Settings::ScreenshotSettings& settings = Settings::video().mScreenshotType;
int screenshotH = mViewer->getCamera()->getViewport()->height();
Screenshot360Type screenshotMapping = Spherical;
const std::string& settingStr = Settings::Manager::getString("screenshot type", "Video"); Screenshot360Type screenshotMapping = Screenshot360Type::Spherical;
std::vector<std::string_view> settingArgs;
Misc::StringUtils::split(settingStr, settingArgs);
if (settingArgs.size() > 0)
{
std::string_view typeStrings[4] = { "spherical", "cylindrical", "planet", "cubemap" };
bool found = false;
for (int i = 0; i < 4; ++i) switch (settings.mType)
{ {
if (settingArgs[0] == typeStrings[i]) case Settings::ScreenshotType::Regular:
{ Log(Debug::Warning) << "Wrong screenshot 360 type: regular.";
screenshotMapping = static_cast<Screenshot360Type>(i);
found = true;
break;
}
}
if (!found)
{
Log(Debug::Warning) << "Wrong screenshot type: " << settingArgs[0] << ".";
return false; return false;
} case Settings::ScreenshotType::Cylindrical:
screenshotMapping = Screenshot360Type::Cylindrical;
break;
case Settings::ScreenshotType::Spherical:
screenshotMapping = Screenshot360Type::Spherical;
break;
case Settings::ScreenshotType::Planet:
screenshotMapping = Screenshot360Type::Planet;
break;
case Settings::ScreenshotType::Cubemap:
screenshotMapping = Screenshot360Type::RawCubemap;
break;
} }
// planet mapping needs higher resolution int screenshotW = mViewer->getCamera()->getViewport()->width();
int cubeSize = screenshotMapping == Planet ? screenshotW : screenshotW / 2;
if (settingArgs.size() > 1) if (settings.mWidth.has_value())
{ screenshotW = *settings.mWidth;
screenshotW = std::min(10000, Misc::StringUtils::toNumeric<int>(settingArgs[1], 0));
}
if (settingArgs.size() > 2) int screenshotH = mViewer->getCamera()->getViewport()->height();
{
screenshotH = std::min(10000, Misc::StringUtils::toNumeric<int>(settingArgs[2], 0));
}
if (settingArgs.size() > 3) if (settings.mHeight.has_value())
{ screenshotH = *settings.mHeight;
cubeSize = std::min(5000, Misc::StringUtils::toNumeric<int>(settingArgs[3], 0));
}
bool rawCubemap = screenshotMapping == RawCubemap; // planet mapping needs higher resolution
const int cubeSize = screenshotMapping == Screenshot360Type::Planet ? screenshotW : screenshotW / 2;
const bool rawCubemap = screenshotMapping == Screenshot360Type::RawCubemap;
if (rawCubemap) if (rawCubemap)
screenshotW = cubeSize * 6; // the image will consist of 6 cube sides in a row screenshotW = cubeSize * 6; // the image will consist of 6 cube sides in a row
else if (screenshotMapping == Planet) else if (screenshotMapping == Screenshot360Type::Planet)
screenshotH = screenshotW; // use square resolution for planet mapping screenshotH = screenshotW; // use square resolution for planet mapping
std::vector<osg::ref_ptr<osg::Image>> images; std::vector<osg::ref_ptr<osg::Image>> images;
@ -276,7 +263,7 @@ namespace MWRender
stateset->setAttributeAndModes(shaderMgr.getProgram("360"), osg::StateAttribute::ON); stateset->setAttributeAndModes(shaderMgr.getProgram("360"), osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("cubeMap", 0)); stateset->addUniform(new osg::Uniform("cubeMap", 0));
stateset->addUniform(new osg::Uniform("mapping", screenshotMapping)); stateset->addUniform(new osg::Uniform("mapping", static_cast<int>(screenshotMapping)));
stateset->setTextureAttributeAndModes(0, cubeTexture, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(0, cubeTexture, osg::StateAttribute::ON);
screenshotCamera->addChild(quad); screenshotCamera->addChild(quad);

@ -70,7 +70,7 @@ namespace MWRender
bool shouldAddMSAAIntermediateTarget() bool shouldAddMSAAIntermediateTarget()
{ {
return Settings::shaders().mAntialiasAlphaTest && Settings::Manager::getInt("antialiasing", "Video") > 1; return Settings::shaders().mAntialiasAlphaTest && Settings::video().mAntialiasing > 1;
} }
} }

@ -87,6 +87,8 @@ add_component_dir (settings
settingvalue settingvalue
shadermanager shadermanager
values values
screenshotsettings
windowmode
) )
add_component_dir (bsa add_component_dir (bsa
@ -336,7 +338,15 @@ add_component_dir (fontloader
) )
add_component_dir (sdlutil add_component_dir (sdlutil
gl4es_init sdlgraphicswindow imagetosurface sdlinputwrapper sdlvideowrapper events sdlcursormanager sdlmappings events
gl4es_init
imagetosurface
sdlcursormanager
sdlgraphicswindow
sdlinputwrapper
sdlmappings
sdlvideowrapper
vsyncmode
) )
add_component_dir (version add_component_dir (version

@ -14,22 +14,16 @@ namespace SDLUtil
close(true); close(true);
} }
GraphicsWindowSDL2::GraphicsWindowSDL2(osg::GraphicsContext::Traits* traits, int vsync) GraphicsWindowSDL2::GraphicsWindowSDL2(osg::GraphicsContext::Traits* traits, VSyncMode vsyncMode)
: mWindow(nullptr) : mWindow(nullptr)
, mContext(nullptr) , mContext(nullptr)
, mValid(false) , mValid(false)
, mRealized(false) , mRealized(false)
, mOwnsWindow(false) , mOwnsWindow(false)
, mVSyncMode(vsyncMode)
{ {
_traits = traits; _traits = traits;
if (vsync == 2)
mVSyncMode = VSyncMode::Adaptive;
else if (vsync == 1)
mVSyncMode = VSyncMode::Enabled;
else
mVSyncMode = VSyncMode::Disabled;
init(); init();
if (GraphicsWindowSDL2::valid()) if (GraphicsWindowSDL2::valid())
{ {

@ -5,14 +5,10 @@
#include <osgViewer/GraphicsWindow> #include <osgViewer/GraphicsWindow>
#include "vsyncmode.hpp"
namespace SDLUtil namespace SDLUtil
{ {
enum VSyncMode
{
Disabled = 0,
Enabled = 1,
Adaptive = 2
};
class GraphicsWindowSDL2 : public osgViewer::GraphicsWindow class GraphicsWindowSDL2 : public osgViewer::GraphicsWindow
{ {
@ -29,7 +25,7 @@ namespace SDLUtil
virtual ~GraphicsWindowSDL2(); virtual ~GraphicsWindowSDL2();
public: public:
GraphicsWindowSDL2(osg::GraphicsContext::Traits* traits, int vsync); GraphicsWindowSDL2(osg::GraphicsContext::Traits* traits, VSyncMode vsyncMode);
bool isSameKindAs(const Object* object) const override bool isSameKindAs(const Object* object) const override
{ {

@ -1,7 +1,7 @@
#include "sdlinputwrapper.hpp" #include "sdlinputwrapper.hpp"
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/settings/settings.hpp> #include <components/settings/values.hpp>
#include <osgViewer/Viewer> #include <osgViewer/Viewer>
@ -187,8 +187,10 @@ namespace SDLUtil
{ {
case SDL_DISPLAYEVENT_ORIENTATION: case SDL_DISPLAYEVENT_ORIENTATION:
if (mSensorListener if (mSensorListener
&& evt.display.display == (unsigned int)Settings::Manager::getInt("screen", "Video")) && evt.display.display == static_cast<Uint32>(Settings::video().mScreen))
{
mSensorListener->displayOrientationChanged(); mSensorListener->displayOrientationChanged();
}
break; break;
default: default:
break; break;

@ -30,14 +30,8 @@ namespace SDLUtil
SDL_SetWindowGammaRamp(mWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]); SDL_SetWindowGammaRamp(mWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
} }
void VideoWrapper::setSyncToVBlank(int mode) void VideoWrapper::setSyncToVBlank(VSyncMode vsyncMode)
{ {
VSyncMode vsyncMode = VSyncMode::Disabled;
if (mode == 1)
vsyncMode = VSyncMode::Enabled;
else if (mode == 2)
vsyncMode = VSyncMode::Adaptive;
osgViewer::Viewer::Windows windows; osgViewer::Viewer::Windows windows;
mViewer->getWindows(windows); mViewer->getWindows(windows);
mViewer->stopThreading(); mViewer->stopThreading();
@ -47,7 +41,7 @@ namespace SDLUtil
if (GraphicsWindowSDL2* sdl2win = dynamic_cast<GraphicsWindowSDL2*>(win)) if (GraphicsWindowSDL2* sdl2win = dynamic_cast<GraphicsWindowSDL2*>(win))
sdl2win->setSyncToVBlank(vsyncMode); sdl2win->setSyncToVBlank(vsyncMode);
else else
win->setSyncToVBlank(static_cast<bool>(mode)); win->setSyncToVBlank(vsyncMode != VSyncMode::Disabled);
} }
mViewer->startThreading(); mViewer->startThreading();
} }

@ -5,6 +5,8 @@
#include <SDL_types.h> #include <SDL_types.h>
#include "vsyncmode.hpp"
struct SDL_Window; struct SDL_Window;
namespace osgViewer namespace osgViewer
@ -26,7 +28,7 @@ namespace SDLUtil
VideoWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> viewer); VideoWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> viewer);
~VideoWrapper(); ~VideoWrapper();
void setSyncToVBlank(int mode); void setSyncToVBlank(VSyncMode vsyncMode);
void setGammaContrast(float gamma, float contrast); void setGammaContrast(float gamma, float contrast);

@ -0,0 +1,14 @@
#ifndef OPENMW_COMPONENTS_SDLUTIL_VSYNCMODE_H
#define OPENMW_COMPONENTS_SDLUTIL_VSYNCMODE_H
namespace SDLUtil
{
enum VSyncMode
{
Disabled = 0,
Enabled = 1,
Adaptive = 2
};
}
#endif

@ -1,8 +1,12 @@
#ifndef OPENMW_COMPONENTS_SETTINGS_CATEGORIES_VIDEO_H #ifndef OPENMW_COMPONENTS_SETTINGS_CATEGORIES_VIDEO_H
#define OPENMW_COMPONENTS_SETTINGS_CATEGORIES_VIDEO_H #define OPENMW_COMPONENTS_SETTINGS_CATEGORIES_VIDEO_H
#include "components/settings/sanitizerimpl.hpp" #include <components/settings/sanitizerimpl.hpp>
#include "components/settings/settingvalue.hpp" #include <components/settings/screenshotsettings.hpp>
#include <components/settings/settingvalue.hpp>
#include <components/settings/windowmode.hpp>
#include <components/sdlutil/vsyncmode.hpp>
#include <osg/Math> #include <osg/Math>
#include <osg/Vec2f> #include <osg/Vec2f>
@ -20,16 +24,16 @@ namespace Settings
SettingValue<int> mResolutionX{ mIndex, "Video", "resolution x", makeMaxSanitizerInt(1) }; SettingValue<int> mResolutionX{ mIndex, "Video", "resolution x", makeMaxSanitizerInt(1) };
SettingValue<int> mResolutionY{ mIndex, "Video", "resolution y", makeMaxSanitizerInt(1) }; SettingValue<int> mResolutionY{ mIndex, "Video", "resolution y", makeMaxSanitizerInt(1) };
SettingValue<int> mWindowMode{ mIndex, "Video", "window mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; SettingValue<WindowMode> mWindowMode{ mIndex, "Video", "window mode" };
SettingValue<int> mScreen{ mIndex, "Video", "screen", makeMaxSanitizerInt(0) }; SettingValue<int> mScreen{ mIndex, "Video", "screen", makeMaxSanitizerInt(0) };
SettingValue<bool> mMinimizeOnFocusLoss{ mIndex, "Video", "minimize on focus loss" }; SettingValue<bool> mMinimizeOnFocusLoss{ mIndex, "Video", "minimize on focus loss" };
SettingValue<bool> mWindowBorder{ mIndex, "Video", "window border" }; SettingValue<bool> mWindowBorder{ mIndex, "Video", "window border" };
SettingValue<int> mAntialiasing{ mIndex, "Video", "antialiasing", makeMaxSanitizerInt(0) }; SettingValue<int> mAntialiasing{ mIndex, "Video", "antialiasing", makeMaxSanitizerInt(0) };
SettingValue<int> mVsyncMode{ mIndex, "Video", "vsync mode", makeEnumSanitizerInt({ 0, 1, 2 }) }; SettingValue<SDLUtil::VSyncMode> mVsyncMode{ mIndex, "Video", "vsync mode" };
SettingValue<float> mFramerateLimit{ mIndex, "Video", "framerate limit", makeMaxSanitizerFloat(0) }; SettingValue<float> mFramerateLimit{ mIndex, "Video", "framerate limit", makeMaxSanitizerFloat(0) };
SettingValue<float> mContrast{ mIndex, "Video", "contrast", makeMaxStrictSanitizerFloat(0) }; SettingValue<float> mContrast{ mIndex, "Video", "contrast", makeMaxStrictSanitizerFloat(0) };
SettingValue<float> mGamma{ mIndex, "Video", "gamma", makeMaxStrictSanitizerFloat(0) }; SettingValue<float> mGamma{ mIndex, "Video", "gamma", makeMaxStrictSanitizerFloat(0) };
SettingValue<std::string> mScreenshotType{ mIndex, "Video", "screenshot type" }; SettingValue<ScreenshotSettings> mScreenshotType{ mIndex, "Video", "screenshot type" };
}; };
} }

@ -0,0 +1,29 @@
#ifndef OPENMW_COMPONENTS_SETTINGS_SCREENSHOTSETTINGS_H
#define OPENMW_COMPONENTS_SETTINGS_SCREENSHOTSETTINGS_H
#include <optional>
#include <ostream>
namespace Settings
{
enum class ScreenshotType
{
Regular,
Cylindrical,
Spherical,
Planet,
Cubemap,
};
struct ScreenshotSettings
{
ScreenshotType mType;
std::optional<int> mWidth;
std::optional<int> mHeight;
std::optional<int> mCubeSize;
auto operator<=>(const ScreenshotSettings& value) const = default;
};
}
#endif

@ -119,6 +119,23 @@ namespace Settings
Log(Debug::Warning) << "Invalid HRTF mode value: " << static_cast<int>(value) << ", fallback to auto (-1)"; Log(Debug::Warning) << "Invalid HRTF mode value: " << static_cast<int>(value) << ", fallback to auto (-1)";
return -1; return -1;
} }
ScreenshotType parseScreenshotType(std::string_view value)
{
if (value == "regular")
return ScreenshotType::Regular;
if (value == "spherical")
return ScreenshotType::Spherical;
if (value == "cylindrical")
return ScreenshotType::Cylindrical;
if (value == "planet")
return ScreenshotType::Planet;
if (value == "cubemap")
return ScreenshotType::Cubemap;
Log(Debug::Warning) << "Invalid screenshot type: " << value << ", fallback to regular";
return ScreenshotType::Regular;
}
} }
CategorySettingValueMap Manager::mDefaultSettings = CategorySettingValueMap(); CategorySettingValueMap Manager::mDefaultSettings = CategorySettingValueMap();
@ -501,6 +518,16 @@ namespace Settings
setInt(setting, category, toInt(value)); setInt(setting, category, toInt(value));
} }
void Manager::set(std::string_view setting, std::string_view category, WindowMode value)
{
setInt(setting, category, static_cast<int>(value));
}
void Manager::set(std::string_view setting, std::string_view category, SDLUtil::VSyncMode value)
{
setInt(setting, category, static_cast<int>(value));
}
void Manager::recordInit(std::string_view setting, std::string_view category) void Manager::recordInit(std::string_view setting, std::string_view category)
{ {
sInitialized.emplace(category, setting); sInitialized.emplace(category, setting);
@ -547,4 +574,28 @@ namespace Settings
Log(Debug::Warning) << "Unknown lighting method '" << value << "', returning fallback '" << fallback << "'"; Log(Debug::Warning) << "Unknown lighting method '" << value << "', returning fallback '" << fallback << "'";
return SceneUtil::LightingMethod::PerObjectUniform; return SceneUtil::LightingMethod::PerObjectUniform;
} }
ScreenshotSettings parseScreenshotSettings(std::string_view value)
{
std::vector<std::string_view> settingArgs;
Misc::StringUtils::split(value, settingArgs);
ScreenshotSettings result;
if (settingArgs.size() > 0)
result.mType = parseScreenshotType(settingArgs[0]);
else
result.mType = ScreenshotType::Regular;
if (settingArgs.size() > 1)
result.mWidth = std::min(10000, Misc::StringUtils::toNumeric<int>(settingArgs[1], 0));
if (settingArgs.size() > 2)
result.mHeight = std::min(10000, Misc::StringUtils::toNumeric<int>(settingArgs[2], 0));
if (settingArgs.size() > 3)
result.mCubeSize = std::min(5000, Misc::StringUtils::toNumeric<int>(settingArgs[3], 0));
return result;
}
} }

@ -5,9 +5,12 @@
#include "gyroscopeaxis.hpp" #include "gyroscopeaxis.hpp"
#include "hrtfmode.hpp" #include "hrtfmode.hpp"
#include "navmeshrendermode.hpp" #include "navmeshrendermode.hpp"
#include "screenshotsettings.hpp"
#include "windowmode.hpp"
#include <components/detournavigator/collisionshapetype.hpp> #include <components/detournavigator/collisionshapetype.hpp>
#include <components/sceneutil/lightingmethod.hpp> #include <components/sceneutil/lightingmethod.hpp>
#include <components/sdlutil/vsyncmode.hpp>
#include <filesystem> #include <filesystem>
#include <set> #include <set>
@ -27,13 +30,6 @@ namespace Files
namespace Settings namespace Settings
{ {
enum class WindowMode
{
Fullscreen = 0,
WindowedFullscreen,
Windowed
};
/// ///
/// \brief Settings management (can change during runtime) /// \brief Settings management (can change during runtime)
/// ///
@ -114,6 +110,8 @@ namespace Settings
static void set(std::string_view setting, std::string_view category, const MyGUI::Colour& value); static void set(std::string_view setting, std::string_view category, const MyGUI::Colour& value);
static void set(std::string_view setting, std::string_view category, SceneUtil::LightingMethod value); static void set(std::string_view setting, std::string_view category, SceneUtil::LightingMethod value);
static void set(std::string_view setting, std::string_view category, HrtfMode value); static void set(std::string_view setting, std::string_view category, HrtfMode value);
static void set(std::string_view setting, std::string_view category, WindowMode value);
static void set(std::string_view setting, std::string_view category, SDLUtil::VSyncMode value);
private: private:
static std::set<std::pair<std::string_view, std::string_view>> sInitialized; static std::set<std::pair<std::string_view, std::string_view>> sInitialized;
@ -239,6 +237,32 @@ namespace Settings
return HrtfMode::Enable; return HrtfMode::Enable;
return HrtfMode::Disable; return HrtfMode::Disable;
} }
template <>
inline WindowMode Manager::getImpl<WindowMode>(std::string_view setting, std::string_view category)
{
const int value = getInt(setting, category);
if (value < 0 || 2 < value)
return WindowMode::Fullscreen;
return static_cast<WindowMode>(value);
}
template <>
inline SDLUtil::VSyncMode Manager::getImpl<SDLUtil::VSyncMode>(std::string_view setting, std::string_view category)
{
const int value = getInt(setting, category);
if (value < 0 || 2 < value)
return SDLUtil::VSyncMode::Disabled;
return static_cast<SDLUtil::VSyncMode>(value);
}
ScreenshotSettings parseScreenshotSettings(std::string_view value);
template <>
inline ScreenshotSettings Manager::getImpl<ScreenshotSettings>(std::string_view setting, std::string_view category)
{
return parseScreenshotSettings(getString(setting, category));
}
} }
#endif // COMPONENTS_SETTINGS_H #endif // COMPONENTS_SETTINGS_H

@ -42,6 +42,9 @@ namespace Settings
NavMeshRenderMode, NavMeshRenderMode,
LightingMethod, LightingMethod,
HrtfMode, HrtfMode,
WindowMode,
VSyncMode,
ScreenshotSettings,
}; };
template <class T> template <class T>
@ -161,6 +164,24 @@ namespace Settings
return SettingValueType::HrtfMode; return SettingValueType::HrtfMode;
} }
template <>
inline constexpr SettingValueType getSettingValueType<WindowMode>()
{
return SettingValueType::WindowMode;
}
template <>
inline constexpr SettingValueType getSettingValueType<SDLUtil::VSyncMode>()
{
return SettingValueType::VSyncMode;
}
template <>
inline constexpr SettingValueType getSettingValueType<ScreenshotSettings>()
{
return SettingValueType::ScreenshotSettings;
}
inline constexpr std::string_view getSettingValueTypeName(SettingValueType type) inline constexpr std::string_view getSettingValueTypeName(SettingValueType type)
{ {
switch (type) switch (type)
@ -203,6 +224,12 @@ namespace Settings
return "lighting method"; return "lighting method";
case SettingValueType::HrtfMode: case SettingValueType::HrtfMode:
return "hrtf mode"; return "hrtf mode";
case SettingValueType::WindowMode:
return "window mode";
case SettingValueType::VSyncMode:
return "vsync mode";
case SettingValueType::ScreenshotSettings:
return "screenshot settings";
} }
return "unsupported"; return "unsupported";
} }
@ -361,6 +388,17 @@ namespace Settings
} }
return stream; return stream;
} }
else if constexpr (std::is_same_v<T, ScreenshotSettings>)
{
stream << "ScreenshotSettings{ .mType = " << static_cast<int>(value.mValue.mType);
if (value.mValue.mWidth.has_value())
stream << ", .mWidth = " << *value.mValue.mWidth;
if (value.mValue.mHeight.has_value())
stream << ", .mHeight = " << *value.mValue.mHeight;
if (value.mValue.mCubeSize.has_value())
stream << ", .mCubeSize = " << *value.mValue.mCubeSize;
return stream << " }";
}
else else
return stream << value.mValue; return stream << value.mValue;
} }

@ -0,0 +1,14 @@
#ifndef OPENMW_COMPONENTS_SETTINGS_WINDOWMODE_H
#define OPENMW_COMPONENTS_SETTINGS_WINDOWMODE_H
namespace Settings
{
enum class WindowMode
{
Fullscreen = 0,
WindowedFullscreen = 1,
Windowed = 2,
};
}
#endif

@ -273,7 +273,7 @@ namespace Stereo
void Manager::updateStereoFramebuffer() void Manager::updateStereoFramebuffer()
{ {
// VR-TODO: in VR, still need to have this framebuffer attached before the postprocessor is created // VR-TODO: in VR, still need to have this framebuffer attached before the postprocessor is created
// auto samples = Settings::Manager::getInt("antialiasing", "Video"); // auto samples = /*do not use Settings here*/;
// auto eyeRes = eyeResolution(); // auto eyeRes = eyeResolution();
// if (mMultiviewFramebuffer) // if (mMultiviewFramebuffer)

@ -194,3 +194,12 @@ Gamma is an exponent that makes colors brighter if greater than 1.0 and darker i
This setting can be changed in the Detail tab of the Video panel of the Options menu. This setting can be changed in the Detail tab of the Video panel of the Options menu.
It has been reported to not work on some Linux systems, It has been reported to not work on some Linux systems,
and therefore the in-game setting in the Options menu has been disabled on Linux systems. and therefore the in-game setting in the Options menu has been disabled on Linux systems.
screenshot type
---------------
:Type: screenshot settings
:Default: regular
Type of screenshot to take (regular, cylindrical, spherical, planet or cubemap), optionally followed by
screenshot width, height and cubemap resolution in pixels (e.g. spherical 1600 1000 1200).

@ -640,7 +640,7 @@ contrast = 1.0
# Video gamma setting. (>0.0). No effect in Linux. # Video gamma setting. (>0.0). No effect in Linux.
gamma = 1.0 gamma = 1.0
# Type of screenshot to take (regular, cylindrical, spherical or planet), optionally followed by # Type of screenshot to take (regular, cylindrical, spherical, planet or cubemap), optionally followed by
# screenshot width, height and cubemap resolution in pixels. (e.g. spherical 1600 1000 1200) # screenshot width, height and cubemap resolution in pixels. (e.g. spherical 1600 1000 1200)
screenshot type = regular screenshot type = regular

Loading…
Cancel
Save