From c377f594a5ae2c7db104b82a1c9baeebd6d78575 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Sat, 8 Jul 2017 18:01:58 +0200 Subject: [PATCH] Add optional real fullscreen mode support --- client/CMT.cpp | 19 ++-- config/schemas/settings.json | 8 +- launcher/settingsView/csettingsview_moc.cpp | 8 ++ launcher/settingsView/csettingsview_moc.h | 2 + launcher/settingsView/csettingsview_moc.ui | 101 +++++++++++--------- 5 files changed, 83 insertions(+), 55 deletions(-) diff --git a/client/CMT.cpp b/client/CMT.cpp index dd57e4168..e29ef464d 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -1071,13 +1071,18 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn cleanupRenderer(); + bool realFullscreen = settings["video"]["realFullscreen"].Bool(); + #ifdef VCMI_ANDROID mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex),SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), 0, 0, SDL_WINDOW_FULLSCREEN); #else + if(fullscreen) { - //in full-screen mode always use desktop resolution - mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex),SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), 0, 0, SDL_WINDOW_FULLSCREEN_DESKTOP); + if(realFullscreen) + mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), w, h, SDL_WINDOW_FULLSCREEN); + else //in windowed full-screen mode use desktop resolution + mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex),SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), 0, 0, SDL_WINDOW_FULLSCREEN_DESKTOP); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); } else @@ -1104,13 +1109,15 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn SDL_GetRendererInfo(mainRenderer,&info); logGlobal->infoStream() << "Created renderer " << info.name; - SDL_RenderSetLogicalSize(mainRenderer, w, h); + if(!(fullscreen && realFullscreen)) + { + SDL_RenderSetLogicalSize(mainRenderer, w, h); #ifndef VCMI_ANDROID - // on android this stretches the game to fit the screen, not preserving aspect and apparently this also breaks coordinates scaling in mouse events - SDL_RenderSetViewport(mainRenderer, nullptr); + // on android this stretches the game to fit the screen, not preserving aspect and apparently this also breaks coordinates scaling in mouse events + SDL_RenderSetViewport(mainRenderer, nullptr); #endif - + } #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) diff --git a/config/schemas/settings.json b/config/schemas/settings.json index 995d67eca..2227dcf5b 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -53,7 +53,7 @@ "type" : "object", "additionalProperties" : false, "default": {}, - "required" : [ "screenRes", "bitsPerPixel", "fullscreen", "spellbookAnimation","driver", "showIntro", "displayIndex" ], + "required" : [ "screenRes", "bitsPerPixel", "fullscreen", "realFullscreen", "spellbookAnimation","driver", "showIntro", "displayIndex" ], "properties" : { "screenRes" : { "type" : "object", @@ -69,7 +69,11 @@ "type" : "number", "default" : 32 }, - "fullscreen" : { + "fullscreen": { + "type": "boolean", + "default": false + }, + "realFullscreen" : { "type" : "boolean", "default" : false }, diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index 8d12ee54a..828ebedc1 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -44,6 +44,7 @@ void CSettingsView::loadSettings() ui->comboBoxResolution->setCurrentIndex(resIndex); ui->comboBoxFullScreen->setCurrentIndex(settings["video"]["fullscreen"].Bool()); ui->comboBoxShowIntro->setCurrentIndex(settings["video"]["showIntro"].Bool()); + ui->checkBoxFullScreen->setChecked(settings["video"]["realFullscreen"].Bool()); int friendlyAIIndex = ui->comboBoxFriendlyAI->findText(QString::fromUtf8(settings["server"]["friendlyAI"].String().c_str())); int neutralAIIndex = ui->comboBoxNeutralAI->findText(QString::fromUtf8(settings["server"]["neutralAI"].String().c_str())); @@ -89,6 +90,7 @@ CSettingsView::~CSettingsView() delete ui; } + void CSettingsView::on_comboBoxResolution_currentIndexChanged(const QString &arg1) { QStringList list = arg1.split("x"); @@ -104,6 +106,12 @@ void CSettingsView::on_comboBoxFullScreen_currentIndexChanged(int index) node->Bool() = index; } +void CSettingsView::on_checkBoxFullScreen_stateChanged(int state) +{ + Settings node = settings.write["video"]["realFullscreen"]; + node->Bool() = state; +} + void CSettingsView::on_comboBoxAutoCheck_currentIndexChanged(int index) { Settings node = settings.write["launcher"]["autoCheckRepositories"]; diff --git a/launcher/settingsView/csettingsview_moc.h b/launcher/settingsView/csettingsview_moc.h index e26f5364a..08655651e 100644 --- a/launcher/settingsView/csettingsview_moc.h +++ b/launcher/settingsView/csettingsview_moc.h @@ -16,6 +16,8 @@ public: void setDisplayList(const QStringList& displayList); private slots: + void on_checkBoxFullScreen_stateChanged(int state); + void on_comboBoxResolution_currentIndexChanged(const QString &arg1); void on_comboBoxFullScreen_currentIndexChanged(int index); diff --git a/launcher/settingsView/csettingsview_moc.ui b/launcher/settingsView/csettingsview_moc.ui index 5a1c10cff..195618cad 100644 --- a/launcher/settingsView/csettingsview_moc.ui +++ b/launcher/settingsView/csettingsview_moc.ui @@ -7,7 +7,7 @@ 0 0 738 - 459 + 471 @@ -26,6 +26,30 @@ 0 + + + + Log files directory + + + + + + + 1 + + + + Off + + + + + On + + + + @@ -66,7 +90,7 @@ - + @@ -87,7 +111,7 @@ - + @@ -100,7 +124,7 @@ - + Check repositories on startup @@ -121,7 +145,7 @@ - + @@ -153,7 +177,7 @@ - + @@ -181,31 +205,7 @@ - - - - Log files directory - - - - - - - 1 - - - - Off - - - - - On - - - - - + @@ -225,7 +225,7 @@ - + 1024 @@ -238,7 +238,7 @@ - + QPlainTextEdit::NoWrap @@ -255,7 +255,7 @@ - + @@ -268,14 +268,14 @@ - + Player AI - + false @@ -302,7 +302,7 @@ - + Qt::Vertical @@ -374,7 +374,7 @@ - + @@ -404,7 +404,7 @@ - + @@ -417,7 +417,7 @@ - + Network port @@ -486,7 +486,7 @@ - + Qt::Vertical @@ -502,7 +502,7 @@ - + false @@ -522,7 +522,7 @@ - + @@ -551,7 +551,7 @@ - + @@ -566,7 +566,7 @@ - + Qt::Horizontal @@ -582,20 +582,27 @@ - + Heroes III character set - + Neutral AI + + + + Real fullscreen mode + + +