From 0424f71cb25fd272c987b8ff8ae32c760fcec497 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sat, 8 Feb 2025 20:02:31 +0100 Subject: [PATCH 1/2] portrait mode for android --- android/AndroidManifest.xml | 2 +- .../java/eu/vcmi/vcmi/VcmiSDLActivity.java | 2 + client/eventsSDL/InputHandler.cpp | 8 + client/renderSDL/ScreenHandler.cpp | 6 +- config/schemas/settings.json | 7 +- launcher/settingsView/csettingsview_moc.cpp | 10 + launcher/settingsView/csettingsview_moc.h | 1 + launcher/settingsView/csettingsview_moc.ui | 187 ++++++++++-------- 8 files changed, 138 insertions(+), 85 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index f9dbc17c6..c71d8864d 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -81,7 +81,7 @@ android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:label="@string/app_name" android:launchMode="singleTop" - android:screenOrientation="sensorLandscape" /> + android:screenOrientation="fullSensor" /> buttonHandleBackRightMouseButton->hide(); ui->labelHandleBackRightMouseButton->hide(); + ui->buttonAllowPortrait->hide(); + ui->labelAllowPortrait->hide(); #endif fillValidScalingRange(); @@ -206,6 +208,7 @@ void CSettingsView::loadSettings() void CSettingsView::loadToggleButtonSettings() { setCheckbuttonState(ui->buttonShowIntro, settings["video"]["showIntro"].Bool()); + setCheckbuttonState(ui->buttonAllowPortrait, settings["video"]["allowPortrait"].Bool()); setCheckbuttonState(ui->buttonAutoCheck, settings["launcher"]["autoCheckRepositories"].Bool()); setCheckbuttonState(ui->buttonRepositoryDefault, settings["launcher"]["defaultRepositoryEnabled"].Bool()); @@ -472,6 +475,13 @@ void CSettingsView::on_buttonShowIntro_toggled(bool value) updateCheckbuttonText(ui->buttonShowIntro); } +void CSettingsView::on_buttonAllowPortrait_toggled(bool value) +{ + Settings node = settings.write["video"]["allowPortrait"]; + node->Bool() = value; + updateCheckbuttonText(ui->buttonAllowPortrait); +} + void CSettingsView::on_buttonAutoSave_toggled(bool value) { Settings node = settings.write["general"]["saveFrequency"]; diff --git a/launcher/settingsView/csettingsview_moc.h b/launcher/settingsView/csettingsview_moc.h index f19d11d16..a8cebead3 100644 --- a/launcher/settingsView/csettingsview_moc.h +++ b/launcher/settingsView/csettingsview_moc.h @@ -47,6 +47,7 @@ private slots: void on_comboBoxEnemyAI_currentTextChanged(const QString & arg1); void on_spinBoxNetworkPort_valueChanged(int arg1); void on_buttonShowIntro_toggled(bool value); + void on_buttonAllowPortrait_toggled(bool value); void on_buttonAutoCheck_toggled(bool value); void on_comboBoxDisplayIndex_currentIndexChanged(int index); void on_buttonAutoSave_toggled(bool value); diff --git a/launcher/settingsView/csettingsview_moc.ui b/launcher/settingsView/csettingsview_moc.ui index 04736eeff..590ed4515 100644 --- a/launcher/settingsView/csettingsview_moc.ui +++ b/launcher/settingsView/csettingsview_moc.ui @@ -53,7 +53,7 @@ - + @@ -69,14 +69,14 @@ - + Mods Validation - + @@ -105,7 +105,7 @@ - + 500 @@ -133,7 +133,7 @@ - + Reset @@ -147,7 +147,7 @@ - + 500 @@ -172,7 +172,7 @@ - + true @@ -223,7 +223,7 @@ - + 100 @@ -239,7 +239,7 @@ - + true @@ -261,34 +261,34 @@ - + Sound Volume - + Haptic Feedback - + Touch Tap Tolerance - + - + 1024 @@ -301,7 +301,7 @@ - + true @@ -326,7 +326,7 @@ - + @@ -341,7 +341,7 @@ - + 10 @@ -372,14 +372,14 @@ - + Software Cursor - + VCAI @@ -396,7 +396,7 @@ - + @@ -406,7 +406,7 @@ - + VCAI @@ -430,7 +430,7 @@ - + @@ -445,14 +445,14 @@ - + Default repository - + @@ -471,21 +471,21 @@ - + Relative Pointer Speed - + Downscaling Filter - + true @@ -527,7 +527,30 @@ - + + + + Allow portrait mode + + + + + + + + 0 + 0 + + + + + + + true + + + + @@ -549,7 +572,7 @@ - + 100 @@ -565,7 +588,7 @@ - + @@ -584,28 +607,28 @@ - + Refresh now - + Adventure Map Allies - + Neutral AI in battles - + 10 @@ -636,21 +659,21 @@ - + - + Display index - + Use Relative Pointer Mode @@ -660,14 +683,14 @@ - + Autocombat AI in battles - + true @@ -692,7 +715,7 @@ - + @@ -714,7 +737,7 @@ - + @@ -730,7 +753,7 @@ - + @@ -745,7 +768,7 @@ - + Additional repository @@ -768,7 +791,7 @@ - + Adventure Map Enemies @@ -782,21 +805,21 @@ - + Use scalable fonts - + Renderer - + @@ -827,10 +850,10 @@ - + - + @@ -853,28 +876,28 @@ - + Online Lobby address - + Online Lobby port - + Controller Click Tolerance - + BattleAI @@ -891,7 +914,7 @@ - + @@ -910,24 +933,24 @@ - + Ignore SSL errors - + - + Show Tutorial again - + Sticks Acceleration @@ -949,7 +972,7 @@ - + false @@ -983,21 +1006,21 @@ - + Mouse Click Tolerance - + Handle back as right mouse button - + @@ -1013,7 +1036,7 @@ - + Enemy AI in battles @@ -1027,7 +1050,7 @@ - + 0 @@ -1062,14 +1085,14 @@ - + Music Volume - + false @@ -1089,14 +1112,14 @@ - + - + Cursor Scaling @@ -1119,7 +1142,7 @@ - + @@ -1141,7 +1164,7 @@ - + @@ -1156,7 +1179,7 @@ - + @@ -1171,7 +1194,7 @@ - + 100 @@ -1243,21 +1266,21 @@ Fullscreen Exclusive Mode - the game will cover the entirety of your screen and - + Long Touch Duration - + Check on startup - + 0 @@ -1301,7 +1324,7 @@ Fullscreen Exclusive Mode - the game will cover the entirety of your screen and - + 100 @@ -1320,7 +1343,7 @@ Fullscreen Exclusive Mode - the game will cover the entirety of your screen and - + Font Scaling (experimental) @@ -1343,7 +1366,7 @@ Fullscreen Exclusive Mode - the game will cover the entirety of your screen and - + 0 @@ -1378,7 +1401,7 @@ Fullscreen Exclusive Mode - the game will cover the entirety of your screen and - + @@ -1416,14 +1439,14 @@ Fullscreen Exclusive Mode - the game will cover the entirety of your screen and - + Sticks Sensitivity - + Upscaling Filter @@ -1447,7 +1470,7 @@ Fullscreen Exclusive Mode - the game will cover the entirety of your screen and - + true From de06de06b5be0729c9e0668b962ef5df5cbbad5f Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sat, 8 Feb 2025 20:53:32 +0100 Subject: [PATCH 2/2] refactor backgrounds (allow resolution change) --- client/mainmenu/CHighScoreScreen.cpp | 15 ++++++++++++--- client/mainmenu/CHighScoreScreen.h | 4 ++-- client/windows/GUIClasses.cpp | 14 +++++++------- client/windows/GUIClasses.h | 2 ++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/client/mainmenu/CHighScoreScreen.cpp b/client/mainmenu/CHighScoreScreen.cpp index 87a024754..bad22e7e7 100644 --- a/client/mainmenu/CHighScoreScreen.cpp +++ b/client/mainmenu/CHighScoreScreen.cpp @@ -45,8 +45,6 @@ CHighScoreScreen::CHighScoreScreen(HighScorePage highscorepage, int highlighted) OBJECT_CONSTRUCTION; pos = center(Rect(0, 0, 800, 600)); - backgroundAroundMenu = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y)); - addHighScores(); addButtons(); } @@ -174,6 +172,12 @@ void CHighScoreScreen::buttonExitClick() CMM->playMusic(); } +void CHighScoreScreen::showAll(Canvas & to) +{ + to.fillTexture(GH.renderHandler().loadImage(ImagePath::builtin("DiBoxBck"), EImageBlitMode::OPAQUE)); + CWindowObject::showAll(to); +} + CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc, const StatisticDataSet & statistic) : CWindowObject(BORDERED), won(won), calc(calc), stat(statistic) { @@ -182,7 +186,6 @@ CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc OBJECT_CONSTRUCTION; pos = center(Rect(0, 0, 800, 600)); - backgroundAroundMenu = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y)); background = std::make_shared(Rect(0, 0, pos.w, pos.h), Colors::BLACK); if(won) @@ -272,6 +275,12 @@ void CHighScoreInputScreen::show(Canvas & to) CWindowObject::showAll(to); } +void CHighScoreInputScreen::showAll(Canvas & to) +{ + to.fillTexture(GH.renderHandler().loadImage(ImagePath::builtin("DiBoxBck"), EImageBlitMode::OPAQUE)); + CWindowObject::showAll(to); +} + void CHighScoreInputScreen::clickPressed(const Point & cursorPosition) { if(statisticButton && statisticButton->pos.isInside(cursorPosition)) diff --git a/client/mainmenu/CHighScoreScreen.h b/client/mainmenu/CHighScoreScreen.h index a8d68011e..b86806d53 100644 --- a/client/mainmenu/CHighScoreScreen.h +++ b/client/mainmenu/CHighScoreScreen.h @@ -39,11 +39,11 @@ private: void buttonExitClick(); void showPopupWindow(const Point & cursorPosition) override; + void showAll(Canvas & to) override; HighScorePage highscorepage; std::shared_ptr background; - std::shared_ptr backgroundAroundMenu; std::vector> buttons; std::vector> texts; std::vector> images; @@ -77,7 +77,6 @@ class CHighScoreInputScreen : public CWindowObject, public IVideoHolder std::shared_ptr input; std::shared_ptr background; std::shared_ptr videoPlayer; - std::shared_ptr backgroundAroundMenu; std::shared_ptr statisticButton; @@ -95,4 +94,5 @@ public: void clickPressed(const Point & cursorPosition) override; void keyPressed(EShortcut key) override; void show(Canvas & to) override; + void showAll(Canvas & to) override; }; diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 7d8e5bd4a..52e283c74 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1685,15 +1685,12 @@ void CObjectListWindow::keyPressed(EShortcut key) } VideoWindow::VideoWindow(const VideoPath & video, const ImagePath & rim, bool showBackground, float scaleFactor, const std::function & closeCb) - : CWindowObject(BORDERED | SHADOW_DISABLED | NEEDS_ANIMATED_BACKGROUND), closeCb(closeCb) + : CWindowObject(BORDERED | SHADOW_DISABLED | NEEDS_ANIMATED_BACKGROUND), closeCb(closeCb), showBackground(showBackground) { OBJECT_CONSTRUCTION; addUsedEvents(LCLICK | KEYBOARD); - if(showBackground) - backgroundAroundWindow = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, GH.screenDimensions().x, GH.screenDimensions().y)); - if(!rim.empty()) { setBackground(rim); @@ -1707,9 +1704,13 @@ VideoWindow::VideoWindow(const VideoPath & video, const ImagePath & rim, bool sh pos = center(Rect(0, 0, videoPlayer->pos.w, videoPlayer->pos.h)); blackBackground->addBox(Point(0, 0), Point(videoPlayer->pos.w, videoPlayer->pos.h), Colors::BLACK); } +} - if(backgroundAroundWindow) - backgroundAroundWindow->pos.moveTo(Point(0, 0)); +void VideoWindow::showAll(Canvas & to) +{ + if(showBackground) + to.fillTexture(GH.renderHandler().loadImage(ImagePath::builtin("DiBoxBck"), EImageBlitMode::OPAQUE)); + CWindowObject::showAll(to); } void VideoWindow::onVideoPlaybackFinished() @@ -1717,7 +1718,6 @@ void VideoWindow::onVideoPlaybackFinished() exit(false); } - void VideoWindow::exit(bool skipped) { close(); diff --git a/client/windows/GUIClasses.h b/client/windows/GUIClasses.h index 555c46cf7..b65a5b888 100644 --- a/client/windows/GUIClasses.h +++ b/client/windows/GUIClasses.h @@ -517,6 +517,7 @@ class VideoWindow : public CWindowObject, public IVideoHolder std::shared_ptr videoPlayer; std::shared_ptr backgroundAroundWindow; std::shared_ptr blackBackground; + bool showBackground; std::function closeCb; @@ -528,4 +529,5 @@ public: void clickPressed(const Point & cursorPosition) override; void keyPressed(EShortcut key) override; void notFocusedClick() override; + void showAll(Canvas & to) override; };