From deff598b6d802687e8c2d2d146a17fc432b28d3f Mon Sep 17 00:00:00 2001
From: Alayan <25536748+Alayan-stk-2@users.noreply.github.com>
Date: Sun, 19 May 2024 14:58:58 +0200
Subject: [PATCH] Prepare the GUI to recommend video settings
- Add a new dialog that gives some information and asks for the user's preferences
- Ensure that one and only one of the 'Performance', 'Balanced' and 'Graphics quality' checkboxes is active
- Add a new button in video settings to access this dialog
---
.../dialogs/recommend_video_settings.stkgui | 65 +++++++++++
data/gui/screens/options/options_video.stkgui | 6 +-
.../dialogs/custom_video_settings.cpp | 1 -
.../dialogs/custom_video_settings.hpp | 2 +-
.../dialogs/recommend_video_settings.cpp | 110 ++++++++++++++++++
.../dialogs/recommend_video_settings.hpp | 45 +++++++
.../options/options_screen_video.cpp | 8 +-
7 files changed, 228 insertions(+), 9 deletions(-)
create mode 100644 data/gui/dialogs/recommend_video_settings.stkgui
create mode 100644 src/states_screens/dialogs/recommend_video_settings.cpp
create mode 100644 src/states_screens/dialogs/recommend_video_settings.hpp
diff --git a/data/gui/dialogs/recommend_video_settings.stkgui b/data/gui/dialogs/recommend_video_settings.stkgui
new file mode 100644
index 000000000..4f3d18563
--- /dev/null
+++ b/data/gui/dialogs/recommend_video_settings.stkgui
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/gui/screens/options/options_video.stkgui b/data/gui/screens/options/options_video.stkgui
index f450bfade..fc90d0e2d 100644
--- a/data/gui/screens/options/options_video.stkgui
+++ b/data/gui/screens/options/options_video.stkgui
@@ -100,14 +100,14 @@
-
+
diff --git a/src/states_screens/dialogs/custom_video_settings.cpp b/src/states_screens/dialogs/custom_video_settings.cpp
index a38d28848..9aad0d9ba 100644
--- a/src/states_screens/dialogs/custom_video_settings.cpp
+++ b/src/states_screens/dialogs/custom_video_settings.cpp
@@ -23,7 +23,6 @@
#include "guiengine/widgets/spinner_widget.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/state_manager.hpp"
-#include "utils/translation.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "utils/string_utils.hpp"
diff --git a/src/states_screens/dialogs/custom_video_settings.hpp b/src/states_screens/dialogs/custom_video_settings.hpp
index 573255708..fadfd3879 100644
--- a/src/states_screens/dialogs/custom_video_settings.hpp
+++ b/src/states_screens/dialogs/custom_video_settings.hpp
@@ -36,7 +36,7 @@ public:
virtual void beforeAddingWidgets();
- /** Updates the activation state of the advaced pipeline checkboxes. */
+ /** Updates the activation state of the advanced pipeline checkboxes. */
void updateActivation();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
diff --git a/src/states_screens/dialogs/recommend_video_settings.cpp b/src/states_screens/dialogs/recommend_video_settings.cpp
new file mode 100644
index 000000000..183f43360
--- /dev/null
+++ b/src/states_screens/dialogs/recommend_video_settings.cpp
@@ -0,0 +1,110 @@
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2009-2015 Marianne Gagnon, 2024 Alayan
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "states_screens/dialogs/recommend_video_settings.hpp"
+
+#include "config/user_config.hpp"
+#include "guiengine/widgets/check_box_widget.hpp"
+#include "guiengine/widgets/list_widget.hpp"
+#include "guiengine/widgets/ribbon_widget.hpp"
+#include "guiengine/widgets/spinner_widget.hpp"
+#include "states_screens/options/options_screen_video.hpp"
+#include "states_screens/state_manager.hpp"
+#include "utils/string_utils.hpp"
+#include "utils/translation.hpp"
+
+using namespace GUIEngine;
+using namespace irr;
+using namespace irr::core;
+using namespace irr::gui;
+
+// -----------------------------------------------------------------------------
+
+RecommendVideoSettingsDialog::RecommendVideoSettingsDialog(const float w, const float h) :
+ ModalDialog(w, h)
+{
+ loadFromFile("recommend_video_settings.stkgui");
+}
+
+// -----------------------------------------------------------------------------
+
+RecommendVideoSettingsDialog::~RecommendVideoSettingsDialog()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void RecommendVideoSettingsDialog::beforeAddingWidgets()
+{
+#ifndef SERVER_ONLY
+ getWidget("performance")->setState(false);
+ getWidget("balance")->setState(true);
+ getWidget("graphics")->setState(false);
+ getWidget("sparing")->setState(false);
+
+ SpinnerWidget* blur_priority = getWidget("blur_priority");
+ blur_priority->addLabel(_("No"));
+ blur_priority->addLabel(_("Yes"));
+ blur_priority->setValue(0);
+#endif
+}
+
+// -----------------------------------------------------------------------------
+
+GUIEngine::EventPropagation RecommendVideoSettingsDialog::processEvent(const std::string& eventSource)
+{
+#ifndef SERVER_ONLY
+
+ // Make sure that one and only one of the performance-to-graphics checkboxes is always selected.
+ if (eventSource == "performance" || eventSource == "balance" || eventSource == "graphics")
+ {
+ getWidget("performance")->setState(false);
+ getWidget("balance")->setState(false);
+ getWidget("graphics")->setState(false);
+ }
+
+ if (eventSource == "performance")
+ {
+ getWidget("performance")->setState(true);
+ }
+ else if (eventSource == "balance")
+ {
+ getWidget("balance")->setState(true);
+ }
+ else if (eventSource == "graphics")
+ {
+ getWidget("graphics")->setState(true);
+ }
+
+ else if (eventSource == "buttons")
+ {
+ const std::string& selection = getWidget("buttons")->
+ getSelectionIDString(PLAYER_ID_GAME_MASTER);
+
+ if (selection == "start_test")
+ {
+ // TODO
+ }
+ else if (selection == "cancel")
+ {
+ ModalDialog::dismiss();
+ return GUIEngine::EVENT_BLOCK;
+ }
+ }
+#endif
+ return GUIEngine::EVENT_LET;
+} // processEvent
\ No newline at end of file
diff --git a/src/states_screens/dialogs/recommend_video_settings.hpp b/src/states_screens/dialogs/recommend_video_settings.hpp
new file mode 100644
index 000000000..03e3f2b37
--- /dev/null
+++ b/src/states_screens/dialogs/recommend_video_settings.hpp
@@ -0,0 +1,45 @@
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2009-2015 Marianne Gagnon, 2024 Alayan
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef HEADER_RECOMMEND_VIDEO_SETTINGS_HPP
+#define HEADER_RECOMMEND_VIDEO_SETTINGS_HPP
+
+#include "guiengine/modaldialog.hpp"
+#include "guiengine/screen.hpp"
+
+/**
+ * \brief Dialog that asks the player some questions before starting a benchmark to
+ * recommend video settings
+ * \ingroup states_screens
+ */
+class RecommendVideoSettingsDialog : public GUIEngine::ModalDialog
+{
+public:
+ /**
+ * Creates a modal dialog with given percentage of screen width and height
+ */
+ RecommendVideoSettingsDialog(const float percentWidth, const float percentHeight);
+ ~RecommendVideoSettingsDialog();
+
+ virtual void beforeAddingWidgets();
+
+ GUIEngine::EventPropagation processEvent(const std::string& eventSource);
+
+};
+
+#endif
diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp
index 63631bcd7..2f22cccca 100644
--- a/src/states_screens/options/options_screen_video.cpp
+++ b/src/states_screens/options/options_screen_video.cpp
@@ -24,6 +24,7 @@
#include "race/race_manager.hpp"
#include "replay/replay_play.hpp"
#include "states_screens/dialogs/custom_video_settings.hpp"
+#include "states_screens/dialogs/recommend_video_settings.hpp"
#ifndef SERVER_ONLY
#include
@@ -692,11 +693,10 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
}
#endif
} // benchmarkCurrent
- // TODO - Add a standard benchmark testing multiple presets
- /*else if (name == "benchmarkStandard")
+ else if (name == "benchmarkRecommend")
{
- // DO NOTHING FOR NOW
- }*/
+ new RecommendVideoSettingsDialog(0.8f, 0.9f);
+ } // benchmarkRecommend
} // eventCallback
// --------------------------------------------------------------------------------------------