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
This commit is contained in:
Alayan 2024-05-19 14:58:58 +02:00
parent fcd8cea5cd
commit deff598b6d
No known key found for this signature in database
7 changed files with 228 additions and 9 deletions

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="1%" width="96%" height="98%" layout="vertical-row" >
<spacer height="1%" width="10" />
<header id="title" width="100%" height="fit" text_align="center" word_wrap="true" text="Recommend Video Settings" />
<spacer height="5%" width="10" />
<label width="100%" I18N="Recommend video settings dialog" text="The recommended settings will be valid for the current resolution." word_wrap="true"/>
<spacer height="2%" width="10" />
<label width="100%" I18N="Recommend video settings dialog" text="What should the settings prioritize?"/>
<spacer height="2%" width="10" />
<div layout="horizontal-row" width="100%" height="5%">
<checkbox id="performance"/>
<spacer width="10" height="10"/>
<label text="Performance" I18N="Recommend video settings dialog"/>
</div>
<spacer height="2%" width="10" />
<div layout="horizontal-row" width="100%" height="5%">
<checkbox id="balance"/>
<spacer width="1%" height="1%"/>
<label text="Balance performance and graphics quality" I18N="Recommend video settings dialog"/>
</div>
<spacer height="2%" width="10" />
<div layout="horizontal-row" width="100%" height="5%">
<checkbox id="graphics"/>
<spacer width="1%" height="1%"/>
<label text="Graphics quality" I18N="Recommend video settings dialog"/>
</div>
<spacer height="2%" width="10" />
<div layout="horizontal-row" width="100%" height="5%">
<checkbox id="sparing"/>
<spacer width="1%" height="1%"/>
<label text="Sparing energy" I18N="Recommend video settings dialog"/>
</div>
<spacer height="2%" width="10" />
<label width="100%" I18N="Recommend video settings dialog" text="Do you like graphics effects creating blur?"/>
<spacer height="2%" width="10" />
<gauge id="blur_priority" min_value="0" max_value="1" wrap_around="true" width="30%" />
<spacer height="4%" width="10" />
<buttonbar id="buttons" height="20%" width="50%" align="center">
<icon-button id="cancel" width="128" height="128" icon="gui/icons/red_x.png"
I18N="Recommend video settings dialog" text="Cancel" align="center"/>
<icon-button id="start_test" width="128" height="128" icon="gui/icons/green_check.png"
I18N="Recommend video settings dialog" text="Start the test" align="center"/>
</buttonbar>
</div>
</stkgui>

View File

@ -100,14 +100,14 @@
<spacer width="5%" height="100%" />
<button id="benchmarkCurrent" text="Performance test of the current settings" I18N="In the video settings" align="center"/>
</div>
<!--
<spacer width="5" height="2%"/>
<div width="100%" height="fit" layout="horizontal-row" id="outer_box" >
<spacer width="5%" height="100%" />
<button id="benchmarkStandard" text="Standard Benchmark" I18N="In the video settings" align="center"/>
<button id="benchmarkRecommend" text="Recommend settings" I18N="In the video settings" align="center"/>
</div>
-->
</box>
</div>
</div>

View File

@ -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"

View File

@ -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);

View File

@ -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<CheckBoxWidget>("performance")->setState(false);
getWidget<CheckBoxWidget>("balance")->setState(true);
getWidget<CheckBoxWidget>("graphics")->setState(false);
getWidget<CheckBoxWidget>("sparing")->setState(false);
SpinnerWidget* blur_priority = getWidget<SpinnerWidget>("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<CheckBoxWidget>("performance")->setState(false);
getWidget<CheckBoxWidget>("balance")->setState(false);
getWidget<CheckBoxWidget>("graphics")->setState(false);
}
if (eventSource == "performance")
{
getWidget<CheckBoxWidget>("performance")->setState(true);
}
else if (eventSource == "balance")
{
getWidget<CheckBoxWidget>("balance")->setState(true);
}
else if (eventSource == "graphics")
{
getWidget<CheckBoxWidget>("graphics")->setState(true);
}
else if (eventSource == "buttons")
{
const std::string& selection = getWidget<RibbonWidget>("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

View File

@ -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

View File

@ -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 <ge_main.hpp>
@ -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
// --------------------------------------------------------------------------------------------