1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

add borderless windows, deprecate fullscreen mode

This commit is contained in:
cody glassman 2022-05-03 22:50:31 -07:00
parent 45161d91c9
commit 05901a2480
13 changed files with 163 additions and 89 deletions

View File

@ -157,6 +157,7 @@
Feature #6600: Support NiSortAdjustNode
Feature #6684: Support NiFltAnimationNode
Feature #6699: Ignored flag
Feature #6700: Support borderless fullscreen
Feature #6706: Save the size of the Options window
Feature #6721: [OpenMW-CS] Add option to open records in new window
Task #6201: Remove the "Note: No relevant classes found. No output generated" warnings

View File

@ -42,7 +42,7 @@ Launcher::GraphicsPage::GraphicsPage(QWidget *parent)
customWidthSpinBox->setMaximum(res.width());
customHeightSpinBox->setMaximum(res.height());
connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int)));
connect(windowModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotFullScreenChanged(int)));
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
connect(screenComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(screenChanged(int)));
connect(framerateLimitCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotFramerateLimitToggled(bool)));
@ -94,8 +94,10 @@ bool Launcher::GraphicsPage::loadSettings()
if (Settings::Manager::getBool("vsync", "Video"))
vSyncCheckBox->setCheckState(Qt::Checked);
if (Settings::Manager::getBool("fullscreen", "Video"))
fullScreenCheckBox->setCheckState(Qt::Checked);
size_t windowMode = static_cast<size_t>(Settings::Manager::getInt("window mode", "Video"));
if (windowMode > static_cast<size_t>(Settings::WindowMode::Windowed))
windowMode = 0;
windowModeComboBox->setCurrentIndex(windowMode);
if (Settings::Manager::getBool("window border", "Video"))
windowBorderCheckBox->setCheckState(Qt::Checked);
@ -183,9 +185,9 @@ void Launcher::GraphicsPage::saveSettings()
if (cVSync != Settings::Manager::getBool("vsync", "Video"))
Settings::Manager::setBool("vsync", "Video", cVSync);
bool cFullScreen = fullScreenCheckBox->checkState();
if (cFullScreen != Settings::Manager::getBool("fullscreen", "Video"))
Settings::Manager::setBool("fullscreen", "Video", cFullScreen);
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"))
@ -355,9 +357,9 @@ void Launcher::GraphicsPage::screenChanged(int screen)
}
}
void Launcher::GraphicsPage::slotFullScreenChanged(int state)
void Launcher::GraphicsPage::slotFullScreenChanged(int mode)
{
if (state == Qt::Checked) {
if (mode == static_cast<int>(Settings::WindowMode::Fullscreen) || mode == static_cast<int>(Settings::WindowMode::BorderlessFullscreen)) {
standardRadioButton->toggle();
customRadioButton->setEnabled(false);
customWidthSpinBox->setEnabled(false);

View File

@ -554,7 +554,7 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
int screen = settings.getInt("screen", "Video");
int width = settings.getInt("resolution x", "Video");
int height = settings.getInt("resolution y", "Video");
bool fullscreen = settings.getBool("fullscreen", "Video");
Settings::WindowMode windowMode = static_cast<Settings::WindowMode>(Settings::Manager::getInt("window mode", "Video"));
bool windowBorder = settings.getBool("window border", "Video");
bool vsync = settings.getBool("vsync", "Video");
unsigned int antialiasing = std::max(0, settings.getInt("antialiasing", "Video"));
@ -562,15 +562,17 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(screen),
pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(screen);
if(fullscreen)
if(windowMode == Settings::WindowMode::Fullscreen || windowMode == Settings::WindowMode::BorderlessFullscreen)
{
pos_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen);
pos_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen);
}
Uint32 flags = SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE;
if(fullscreen)
if(windowMode == Settings::WindowMode::Fullscreen)
flags |= SDL_WINDOW_FULLSCREEN;
else if (windowMode == Settings::WindowMode::BorderlessFullscreen)
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
// Allows for Windows snapping features to properly work in borderless window
SDL_SetHint("SDL_BORDERLESS_WINDOWED_STYLE", "1");

View File

@ -224,7 +224,7 @@ namespace MWGui
getWidget(mSettingsTab, "SettingsTab");
getWidget(mOkButton, "OkButton");
getWidget(mResolutionList, "ResolutionList");
getWidget(mFullscreenButton, "FullscreenButton");
getWidget(mWindowModeList, "WindowModeList");
getWidget(mWindowBorderButton, "WindowBorderButton");
getWidget(mTextureFilteringButton, "TextureFilteringButton");
getWidget(mAnisotropyBox, "AnisotropyBox");
@ -274,6 +274,8 @@ namespace MWGui
mLightsResetButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onLightsResetButtonClicked);
mMaxLights->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onMaxLightsChanged);
mWindowModeList->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onWindowModeChanged);
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
@ -325,7 +327,8 @@ namespace MWGui
updateMaxLightsComboBox(mMaxLights);
mWindowBorderButton->setEnabled(!Settings::Manager::getBool("fullscreen", "Video"));
Settings::WindowMode windowMode = static_cast<Settings::WindowMode>(Settings::Manager::getInt("window mode", "Video"));
mWindowBorderButton->setEnabled(windowMode != Settings::WindowMode::Fullscreen && windowMode != Settings::WindowMode::BorderlessFullscreen);
mKeyboardSwitch->setStateSelected(true);
mControllerSwitch->setStateSelected(false);
@ -433,6 +436,15 @@ namespace MWGui
apply();
}
void SettingsWindow::onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos)
{
if (pos == MyGUI::ITEM_NONE)
return;
Settings::Manager::setInt("window mode", "Video", static_cast<int>(_sender->getIndexSelected()));
apply();
}
void SettingsWindow::onMaxLightsChanged(MyGUI::ComboBox* _sender, size_t pos)
{
int count = 8 * (pos + 1);
@ -485,49 +497,6 @@ namespace MWGui
newState = true;
}
if (_sender == mFullscreenButton)
{
// check if this resolution is supported in fullscreen
if (mResolutionList->getIndexSelected() != MyGUI::ITEM_NONE)
{
std::string resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected());
int resX, resY;
parseResolution (resX, resY, resStr);
Settings::Manager::setInt("resolution x", "Video", resX);
Settings::Manager::setInt("resolution y", "Video", resY);
}
bool supported = false;
int fallbackX = 0, fallbackY = 0;
for (unsigned int i=0; i<mResolutionList->getItemCount(); ++i)
{
std::string resStr = mResolutionList->getItemNameAt(i);
int resX, resY;
parseResolution (resX, resY, resStr);
if (i == 0)
{
fallbackX = resX;
fallbackY = resY;
}
if (resX == Settings::Manager::getInt("resolution x", "Video")
&& resY == Settings::Manager::getInt("resolution y", "Video"))
supported = true;
}
if (!supported && mResolutionList->getItemCount())
{
if (fallbackX != 0 && fallbackY != 0)
{
Settings::Manager::setInt("resolution x", "Video", fallbackX);
Settings::Manager::setInt("resolution y", "Video", fallbackY);
}
}
mWindowBorderButton->setEnabled(!newState);
}
if (getSettingType(_sender) == checkButtonType)
{
Settings::Manager::setBool(getSettingName(_sender), getSettingCategory(_sender), newState);
@ -691,6 +660,59 @@ namespace MWGui
mLightingMethodButton->setIndexSelected(mLightingMethodButton->findItemIndexWith(lightingMethodStr));
}
void SettingsWindow::updateWindowModeSettings()
{
size_t index = static_cast<size_t>(Settings::Manager::getInt("window mode", "Video"));
if (index > static_cast<size_t>(Settings::WindowMode::Windowed))
index = MyGUI::ITEM_NONE;
mWindowModeList->setIndexSelected(index);
if (index != static_cast<size_t>(Settings::WindowMode::Windowed) && index != MyGUI::ITEM_NONE)
{
// check if this resolution is supported in fullscreen
if (mResolutionList->getIndexSelected() != MyGUI::ITEM_NONE)
{
std::string resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected());
int resX, resY;
parseResolution (resX, resY, resStr);
Settings::Manager::setInt("resolution x", "Video", resX);
Settings::Manager::setInt("resolution y", "Video", resY);
}
bool supported = false;
int fallbackX = 0, fallbackY = 0;
for (unsigned int i=0; i<mResolutionList->getItemCount(); ++i)
{
std::string resStr = mResolutionList->getItemNameAt(i);
int resX, resY;
parseResolution (resX, resY, resStr);
if (i == 0)
{
fallbackX = resX;
fallbackY = resY;
}
if (resX == Settings::Manager::getInt("resolution x", "Video")
&& resY == Settings::Manager::getInt("resolution y", "Video"))
supported = true;
}
if (!supported && mResolutionList->getItemCount())
{
if (fallbackX != 0 && fallbackY != 0)
{
Settings::Manager::setInt("resolution x", "Video", fallbackX);
Settings::Manager::setInt("resolution y", "Video", fallbackY);
}
}
mWindowBorderButton->setEnabled(false);
}
}
void SettingsWindow::layoutControlsBox()
{
const int h = 18;
@ -866,6 +888,7 @@ namespace MWGui
highlightCurrentResolution();
updateControlsBox();
updateLightSettings();
updateWindowModeSettings();
resetScrollbars();
renderScriptSettings();
resizeScriptSettings();

View File

@ -18,6 +18,8 @@ namespace MWGui
void updateLightSettings();
void updateWindowModeSettings();
void onResChange(int, int) override { center(); }
protected:
@ -26,7 +28,7 @@ namespace MWGui
// graphics
MyGUI::ListBox* mResolutionList;
MyGUI::Button* mFullscreenButton;
MyGUI::ComboBox* mWindowModeList;
MyGUI::Button* mWindowBorderButton;
MyGUI::ComboBox* mTextureFilteringButton;
MyGUI::Widget* mAnisotropyBox;
@ -72,6 +74,8 @@ namespace MWGui
void onLightsResetButtonClicked(MyGUI::Widget* _sender);
void onMaxLightsChanged(MyGUI::ComboBox* _sender, size_t pos);
void onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos);
void onRebindAction(MyGUI::Widget* _sender);
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);
void onResetDefaultBindings(MyGUI::Widget* _sender);
@ -94,7 +98,7 @@ namespace MWGui
void renderScriptSettings();
void computeMinimumWindowSize();
private:
void resetScrollbars();
};

View File

@ -1086,7 +1086,7 @@ namespace MWGui
else if (setting.first == "Video" && (
setting.second == "resolution x"
|| setting.second == "resolution y"
|| setting.second == "fullscreen"
|| setting.second == "window mode"
|| setting.second == "window border"))
changeRes = true;
@ -1101,7 +1101,7 @@ namespace MWGui
{
mVideoWrapper->setVideoMode(Settings::Manager::getInt("resolution x", "Video"),
Settings::Manager::getInt("resolution y", "Video"),
Settings::Manager::getBool("fullscreen", "Video"),
static_cast<Settings::WindowMode>(Settings::Manager::getInt("window mode", "Video")),
Settings::Manager::getBool("window border", "Video"));
}
}

View File

@ -1,6 +1,7 @@
#include "sdlvideowrapper.hpp"
#include <components/debug/debuglog.hpp>
#include <components/settings/settings.hpp>
#include <osgViewer/Viewer>
@ -68,21 +69,21 @@ namespace SDLUtil
Log(Debug::Warning) << "Couldn't set gamma: " << SDL_GetError();
}
void VideoWrapper::setVideoMode(int width, int height, bool fullscreen, bool windowBorder)
void VideoWrapper::setVideoMode(int width, int height, Settings::WindowMode windowMode, bool windowBorder)
{
SDL_SetWindowFullscreen(mWindow, 0);
if (SDL_GetWindowFlags(mWindow) & SDL_WINDOW_MAXIMIZED)
SDL_RestoreWindow(mWindow);
if (fullscreen)
if (windowMode == Settings::WindowMode::Fullscreen || windowMode == Settings::WindowMode::BorderlessFullscreen)
{
SDL_DisplayMode mode;
SDL_GetWindowDisplayMode(mWindow, &mode);
mode.w = width;
mode.h = height;
SDL_SetWindowDisplayMode(mWindow, &mode);
SDL_SetWindowFullscreen(mWindow, fullscreen);
SDL_SetWindowFullscreen(mWindow, windowMode == Settings::WindowMode::Fullscreen ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP);
}
else
{

View File

@ -12,6 +12,11 @@ namespace osgViewer
class Viewer;
}
namespace Settings
{
enum class WindowMode;
}
namespace SDLUtil
{
@ -25,7 +30,7 @@ namespace SDLUtil
void setGammaContrast(float gamma, float contrast);
void setVideoMode(int width, int height, bool fullscreen, bool windowBorder);
void setVideoMode(int width, int height, Settings::WindowMode windowMode, bool windowBorder);
void centerWindow();

View File

@ -16,6 +16,13 @@ namespace Files
namespace Settings
{
enum class WindowMode
{
Fullscreen = 0,
BorderlessFullscreen,
Windowed
};
///
/// \brief Settings management (can change during runtime)
///

View File

@ -31,17 +31,23 @@ The window resolution can be selected from a menu of common screen sizes
in the Video tab of the Video Panel of the Options menu, or in the Graphics tab of the OpenMW Launcher.
The vertical resolution can also be set to a custom value in the Graphics tab of the OpenMW Launcher.
fullscreen
----------
window mode
-----------
:Type: boolean
:Range: True/False
:Default: False
:Type: integer
:Range: 0, 1, 2
:Default: 2 (Windowed)
This setting determines whether the entire screen is used for the specified resolution.
This setting determines the window mode.
This setting can be toggled in game using the Fullscreen button in the Video tab of the Video panel in the Options menu.
It can also be toggled with the Full Screen check box in the Graphics tab of the OpenMW Launcher.
0: Fullscreen
1: Borderless Fullscreen
2: Windowed
This setting can be toggled in game using the dropdown list in the Video tab of the Video panel in the Options menu.
It can also be toggled with the window mode dropdown in the Graphics tab of the OpenMW Launcher.
screen
------

View File

@ -270,17 +270,17 @@
<Widget type="TabItem" skin="" position="0 28 352 268" align="Stretch">
<Property key="Caption" value=" Video "/>
<Widget type="ListBox" skin="MW_List" position="0 4 170 170" align="Left Top" name="ResolutionList"/>
<Widget type="HBox" skin="" position="182 4 300 24">
<Widget type="AutoSizedButton" skin="MW_Button" position="0 0 24 24" align="Left Top" name="FullscreenButton">
<UserString key="SettingCategory" value="Video"/>
<UserString key="SettingName" value="fullscreen"/>
<UserString key="SettingType" value="CheckButton"/>
</Widget>
<Widget type="AutoSizedTextBox" skin="SandText" position="28 4 70 16" align="Left Top">
<Property key="Caption" value="Fullscreen"/>
<Widget type="TextBox" skin="NormalText" position="182 4 170 18" align="Left Top">
<Property key="Caption" value="Window Mode:"/>
</Widget>
<Widget type="HBox" skin="" position="182 28 300 24">
<Widget type="ComboBox" skin="MW_ComboBox" position="0 0 200 24" align="Left Top" name="WindowModeList">
<Property key="AddItem" value="Fullscreen"/>
<Property key="AddItem" value="Borderless Fullscreen"/>
<Property key="AddItem" value="Windowed"/>
</Widget>
</Widget>
<Widget type="HBox" skin="" position="182 34 300 24">
<Widget type="HBox" skin="" position="182 64 300 24">
<Widget type="AutoSizedButton" skin="MW_Button" position="0 0 24 24" align="Left Top" name="VSyncButton">
<UserString key="SettingCategory" value="Video"/>
<UserString key="SettingName" value="vsync"/>
@ -290,7 +290,7 @@
<Property key="Caption" value="VSync"/>
</Widget>
</Widget>
<Widget type="HBox" skin="" position="182 64 300 24">
<Widget type="HBox" skin="" position="182 94 300 24">
<Widget type="AutoSizedButton" skin="MW_Button" position="0 0 24 24" align="Left Top" name="WindowBorderButton">
<UserString key="SettingCategory" value="Video"/>
<UserString key="SettingName" value="window border"/>
@ -301,7 +301,7 @@
</Widget>
</Widget>
<Widget type="TextBox" skin="SandText" position="182 94 300 32" align="Left Top">
<Widget type="TextBox" skin="SandText" position="182 124 300 32" align="Left Top">
<Property key="Caption" value="Hint: press F3 to show \nthe current frame rate."/>
</Widget>

View File

@ -611,8 +611,9 @@ hrtf =
resolution x = 800
resolution y = 600
# OpenMW takes complete control of the screen.
fullscreen = false
# Specify the window mode.
# 0 = Fullscreen, 1 = Borderless Fullscreen, 2 = Windowed
window mode = 0
# Determines which screen OpenMW is on. (>=0).
screen = 0

View File

@ -112,17 +112,39 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QCheckBox" name="windowBorderCheckBox">
<property name="text">
<string>Window Border</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="fullScreenCheckBox">
<item row="2" column="1">
<widget class="QComboBox" name="windowModeComboBox">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Fullscreen</string>
</property>
</item>
<item>
<property name="text">
<string>Borderless Fullscreen</string>
</property>
</item>
<item>
<property name="text">
<string>Windowed</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="windowModeLabel">
<property name="text">
<string>Full Screen</string>
<string>Window Mode:</string>
</property>
</widget>
</item>