Add dialog to customize graphics settings in addition to slider

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10482 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-12-22 21:14:57 +00:00
parent f9f8052f09
commit febcc4411f
7 changed files with 226 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -16,21 +16,27 @@
<box proportion="1" width="100%" layout="vertical-row"> <box proportion="1" width="100%" layout="vertical-row">
<spacer height="20" width="10"/> <spacer height="15" width="10"/>
<!-- ************ GRAPHICAL EFFECTS SETTINGS ************ --> <!-- ************ GRAPHICAL EFFECTS SETTINGS ************ -->
<div width="75%" height="fit" layout="horizontal-row" > <div width="75%" height="fit" layout="horizontal-row" id="outer_box" >
<label I18N="In the graphics settings" text="Graphical Effects Level" align="center"/> <label I18N="In the graphics settings" text="Graphical Effects Level" align="center"/>
<spacer width="20" height="20"/> <spacer width="20" height="20"/>
<gauge id="gfx_level" min_value="1" max_value="7" width="300" />
<div layout="vertical-row" proportion="1" height="fit" id="inner_box">
<gauge id="gfx_level" min_value="1" max_value="7" width="300" align="center" />
<spacer height="5" width="10"/>
<button id="custom" text="Custom settings..." I18N="In the video settings" align="center"/>
</div>
</div> </div>
<spacer height="10" width="10"/> <spacer height="10" width="10"/>
<!-- ************ VSYNC ************ --> <!-- ************ VSYNC ************ -->
<div width="75%" height="fit" layout="horizontal-row" > <div width="75%" height="fit" layout="horizontal-row" >
<spacer width="40" height="2" />
<checkbox id="vsync"/> <checkbox id="vsync"/>
<spacer width="20" height="100%" /> <spacer width="20" height="2" />
<label height="100%" I18N="In the video settings" text="Vertical Sync (requires restart)"/> <label height="100%" I18N="In the video settings" text="Vertical Sync (requires restart)"/>
</div> </div>
@ -38,8 +44,9 @@
<!-- ************ FBO ************ --> <!-- ************ FBO ************ -->
<div width="75%" height="fit" layout="horizontal-row" > <div width="75%" height="fit" layout="horizontal-row" >
<spacer width="40" height="2" />
<checkbox id="fbos"/> <checkbox id="fbos"/>
<spacer width="20" height="100%" /> <spacer width="20" height="2" />
<label height="100%" I18N="In the video settings" text="Use Frame Buffer Objects (requires restart)"/> <label height="100%" I18N="In the video settings" text="Use Frame Buffer Objects (requires restart)"/>
</div> </div>
@ -49,7 +56,7 @@
<spacer height="10" width="10"/> <spacer height="10" width="10"/>
<label width="100%" I18N="In the graphics settings" text="Resolution"/> <label width="100%" I18N="In the graphics settings" text="Resolution"/>
<scrollable_ribbon id="resolutions" proportion="2" label_location="each" <scrollable_ribbon id="resolutions" proportion="1" label_location="each"
width="100%" square_items="false" width="100%" square_items="false"
align="center" child_width="128" child_height="128" max_height="150" /> align="center" child_width="128" child_height="128" max_height="150" />
@ -70,7 +77,7 @@
I18N="In the video settings menu" text="Apply new resolution" /> I18N="In the video settings menu" text="Apply new resolution" />
</div> </div>
<spacer height="4" width="4"/> <spacer height="15" width="4"/>
</box> </box>
</div> </div>

View File

@ -299,6 +299,7 @@
9576460812BAD1CF00DB80C7 /* tutorial_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9576460512BAD1CF00DB80C7 /* tutorial_manager.cpp */; }; 9576460812BAD1CF00DB80C7 /* tutorial_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9576460512BAD1CF00DB80C7 /* tutorial_manager.cpp */; };
957817DC142142C500AD07B2 /* referee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957817DA142142C500AD07B2 /* referee.cpp */; }; 957817DC142142C500AD07B2 /* referee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957817DA142142C500AD07B2 /* referee.cpp */; };
957899B813C8E05F007AA5A3 /* profiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957899B613C8E05F007AA5A3 /* profiler.cpp */; }; 957899B813C8E05F007AA5A3 /* profiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957899B613C8E05F007AA5A3 /* profiler.cpp */; };
957957A214A3CA3900E72497 /* custom_video_settings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957957A014A3CA3900E72497 /* custom_video_settings.cpp */; };
957A2D291405E21D00F45B22 /* hit_sfx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957A2D271405E21D00F45B22 /* hit_sfx.cpp */; }; 957A2D291405E21D00F45B22 /* hit_sfx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957A2D271405E21D00F45B22 /* hit_sfx.cpp */; };
957ED4801163FF18002AB42C /* ai_base_controller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957ED47E1163FF18002AB42C /* ai_base_controller.cpp */; }; 957ED4801163FF18002AB42C /* ai_base_controller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 957ED47E1163FF18002AB42C /* ai_base_controller.cpp */; };
958330CC10122B4A00C5137E /* engine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958330B210122B4A00C5137E /* engine.cpp */; }; 958330CC10122B4A00C5137E /* engine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958330B210122B4A00C5137E /* engine.cpp */; };
@ -1059,6 +1060,8 @@
957817DB142142C500AD07B2 /* referee.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = referee.hpp; path = ../../graphics/referee.hpp; sourceTree = SOURCE_ROOT; }; 957817DB142142C500AD07B2 /* referee.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = referee.hpp; path = ../../graphics/referee.hpp; sourceTree = SOURCE_ROOT; };
957899B613C8E05F007AA5A3 /* profiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = profiler.cpp; path = ../../utils/profiler.cpp; sourceTree = SOURCE_ROOT; }; 957899B613C8E05F007AA5A3 /* profiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = profiler.cpp; path = ../../utils/profiler.cpp; sourceTree = SOURCE_ROOT; };
957899B713C8E05F007AA5A3 /* profiler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = profiler.hpp; path = ../../utils/profiler.hpp; sourceTree = SOURCE_ROOT; }; 957899B713C8E05F007AA5A3 /* profiler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = profiler.hpp; path = ../../utils/profiler.hpp; sourceTree = SOURCE_ROOT; };
957957A014A3CA3900E72497 /* custom_video_settings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = custom_video_settings.cpp; path = ../../states_screens/dialogs/custom_video_settings.cpp; sourceTree = SOURCE_ROOT; };
957957A114A3CA3900E72497 /* custom_video_settings.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = custom_video_settings.hpp; path = ../../states_screens/dialogs/custom_video_settings.hpp; sourceTree = SOURCE_ROOT; };
957A2D261405E21D00F45B22 /* hit_effect.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = hit_effect.hpp; path = ../../graphics/hit_effect.hpp; sourceTree = SOURCE_ROOT; }; 957A2D261405E21D00F45B22 /* hit_effect.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = hit_effect.hpp; path = ../../graphics/hit_effect.hpp; sourceTree = SOURCE_ROOT; };
957A2D271405E21D00F45B22 /* hit_sfx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = hit_sfx.cpp; path = ../../graphics/hit_sfx.cpp; sourceTree = SOURCE_ROOT; }; 957A2D271405E21D00F45B22 /* hit_sfx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = hit_sfx.cpp; path = ../../graphics/hit_sfx.cpp; sourceTree = SOURCE_ROOT; };
957A2D281405E21D00F45B22 /* hit_sfx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = hit_sfx.hpp; path = ../../graphics/hit_sfx.hpp; sourceTree = SOURCE_ROOT; }; 957A2D281405E21D00F45B22 /* hit_sfx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = hit_sfx.hpp; path = ../../graphics/hit_sfx.hpp; sourceTree = SOURCE_ROOT; };
@ -2289,6 +2292,8 @@
95E6A0BF11DCF37800AE088A /* addons_loading.hpp */, 95E6A0BF11DCF37800AE088A /* addons_loading.hpp */,
95E246BC111A2959000C965D /* confirm_resolution_dialog.cpp */, 95E246BC111A2959000C965D /* confirm_resolution_dialog.cpp */,
95E246BD111A2959000C965D /* confirm_resolution_dialog.hpp */, 95E246BD111A2959000C965D /* confirm_resolution_dialog.hpp */,
957957A014A3CA3900E72497 /* custom_video_settings.cpp */,
957957A114A3CA3900E72497 /* custom_video_settings.hpp */,
95833237101243ED00C5137E /* enter_player_name_dialog.cpp */, 95833237101243ED00C5137E /* enter_player_name_dialog.cpp */,
95833238101243ED00C5137E /* enter_player_name_dialog.hpp */, 95833238101243ED00C5137E /* enter_player_name_dialog.hpp */,
95634EF01126272C009C145D /* gp_info_dialog.cpp */, 95634EF01126272C009C145D /* gp_info_dialog.cpp */,
@ -3207,6 +3212,7 @@
95E5C335148C19F500AD3FCC /* story_mode_new.cpp in Sources */, 95E5C335148C19F500AD3FCC /* story_mode_new.cpp in Sources */,
95E5C3C2148C418100AD3FCC /* game_slot.cpp in Sources */, 95E5C3C2148C418100AD3FCC /* game_slot.cpp in Sources */,
9593366B149EC9B10031FD41 /* overworld.cpp in Sources */, 9593366B149EC9B10031FD41 /* overworld.cpp in Sources */,
957957A214A3CA3900E72497 /* custom_video_settings.cpp in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -0,0 +1,122 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 Marianne Gagnon
//
// 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/custom_video_settings.hpp"
#include "config/user_config.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp"
#include "states_screens/options_screen_video.hpp"
#include "utils/translation.hpp"
#include <IGUIEnvironment.h>
using namespace GUIEngine;
using namespace irr;
using namespace irr::core;
using namespace irr::gui;
// -----------------------------------------------------------------------------
CustomVideoSettingsialog::CustomVideoSettingsialog(const float w, const float h) :
ModalDialog(w, h)
{
loadFromFile("custom_video_settings.stkgui");
}
// -----------------------------------------------------------------------------
CustomVideoSettingsialog::~CustomVideoSettingsialog()
{
}
// -----------------------------------------------------------------------------
void CustomVideoSettingsialog::beforeAddingWidgets()
{
getWidget<CheckBoxWidget>("anim_gfx")->setState( UserConfigParams::m_graphical_effects );
getWidget<CheckBoxWidget>("weather_gfx")->setState( UserConfigParams::m_weather_effects );
SpinnerWidget* kart_anim = getWidget<SpinnerWidget>("steering_animations");
kart_anim->addLabel( _("Disabled") ); // 0
//I18N: animations setting (only karts with human players are animated)
kart_anim->addLabel( _("Human players only") ); // 1
//I18N: animations setting (all karts are animated)
kart_anim->addLabel( _("Enabled for all") ); // 2
kart_anim->setValue( UserConfigParams::m_show_steering_animations );
SpinnerWidget* filtering = getWidget<SpinnerWidget>("filtering");
int value = 0;
if (UserConfigParams::m_anisotropic) value = 2;
else if (UserConfigParams::m_trilinear) value = 1;
filtering->addLabel( L"Bilinear" ); // 0
filtering->addLabel( L"Trilinear" ); // 1
filtering->addLabel( L"Anisotropic" ); // 2
printf("filtering : %i\n", value);
filtering->setValue( value );
getWidget<CheckBoxWidget>("antialiasing")->setState( UserConfigParams::m_fullscreen_antialiasing );
getWidget<CheckBoxWidget>("postprocessing")->setState( UserConfigParams::m_postprocess_enabled );
}
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation CustomVideoSettingsialog::processEvent(const std::string& eventSource)
{
if (eventSource == "close")
{
UserConfigParams::m_graphical_effects =
getWidget<CheckBoxWidget>("anim_gfx")->getState();
UserConfigParams::m_weather_effects =
getWidget<CheckBoxWidget>("weather_gfx")->getState();
UserConfigParams::m_fullscreen_antialiasing =
getWidget<CheckBoxWidget>("antialiasing")->getState();
UserConfigParams::m_postprocess_enabled =
getWidget<CheckBoxWidget>("postprocessing")->getState();
UserConfigParams::m_show_steering_animations =
getWidget<SpinnerWidget>("steering_animations")->getValue();
switch (getWidget<SpinnerWidget>("filtering")->getValue())
{
case 0:
UserConfigParams::m_anisotropic = false;
UserConfigParams::m_trilinear = false;
break;
case 1:
UserConfigParams::m_anisotropic = false;
UserConfigParams::m_trilinear = true;
break;
case 2:
UserConfigParams::m_anisotropic = true;
UserConfigParams::m_trilinear = true;
break;
}
user_config->saveConfig();
ModalDialog::dismiss();
OptionsScreenVideo::getInstance()->updateGfxSlider();
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET;
}
// -----------------------------------------------------------------------------

View File

@ -0,0 +1,44 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009 Marianne Gagnon
//
// 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_CUSTOM_VIDEO_SETTINGS_HPP
#define HEADER_CUSTOM_VIDEO_SETTINGS_HPP
#include "guiengine/modaldialog.hpp"
/**
* \brief Dialog that allows the player to select custom video settings
* \ingroup states_screens
*/
class CustomVideoSettingsialog : public GUIEngine::ModalDialog
{
public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
CustomVideoSettingsialog(const float percentWidth, const float percentHeight);
~CustomVideoSettingsialog();
virtual void beforeAddingWidgets();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
};
#endif

View File

@ -28,6 +28,7 @@
#include "guiengine/widgets/spinner_widget.hpp" #include "guiengine/widgets/spinner_widget.hpp"
#include "guiengine/widget.hpp" #include "guiengine/widget.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "states_screens/dialogs/custom_video_settings.hpp"
#include "states_screens/options_screen_audio.hpp" #include "states_screens/options_screen_audio.hpp"
#include "states_screens/options_screen_input.hpp" #include "states_screens/options_screen_input.hpp"
#include "states_screens/options_screen_players.hpp" #include "states_screens/options_screen_players.hpp"
@ -275,19 +276,7 @@ void OptionsScreenVideo::init()
// --- set gfx settings values // --- set gfx settings values
for (int l=0; l<GFX_LEVEL_AMOUNT; l++) updateGfxSlider();
{
if (UserConfigParams::m_show_steering_animations == GFX_ANIM_KARTS[l]&&
UserConfigParams::m_graphical_effects == GFX[l] &&
UserConfigParams::m_weather_effects == GFX_WEATHER[l] &&
UserConfigParams::m_fullscreen_antialiasing == GFX_ANTIALIAS[l] &&
UserConfigParams::m_postprocess_enabled == GFX_POSTPROCESSING[l])
{
gfx->setValue(l+1);
break;
}
}
// ---- forbid changing resolution or animation settings from in-game // ---- forbid changing resolution or animation settings from in-game
// (we need to disable them last because some items can't be edited when // (we need to disable them last because some items can't be edited when
@ -300,12 +289,42 @@ void OptionsScreenVideo::init()
gfx->setDeactivated(); gfx->setDeactivated();
} }
updateTooltip(); updateTooltip();
} // init } // init
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void OptionsScreenVideo::updateGfxSlider()
{
GUIEngine::SpinnerWidget* gfx =
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
assert( gfx != NULL );
bool found = false;
for (int l=0; l<GFX_LEVEL_AMOUNT; l++)
{
if (UserConfigParams::m_show_steering_animations == GFX_ANIM_KARTS[l]&&
UserConfigParams::m_graphical_effects == GFX[l] &&
UserConfigParams::m_weather_effects == GFX_WEATHER[l] &&
UserConfigParams::m_fullscreen_antialiasing == GFX_ANTIALIAS[l] &&
UserConfigParams::m_postprocess_enabled == GFX_POSTPROCESSING[l])
{
gfx->setValue(l+1);
found = true;
break;
}
}
if (!found)
{
//I18N: custom video settings
gfx->setCustomText( _("Custom") );
}
}
// ----------------------------------------------------------------------------
void OptionsScreenVideo::updateTooltip() void OptionsScreenVideo::updateTooltip()
{ {
GUIEngine::SpinnerWidget* gfx = GUIEngine::SpinnerWidget* gfx =
@ -376,6 +395,10 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
{ {
StateManager::get()->escapePressed(); StateManager::get()->escapePressed();
} }
else if(name == "custom")
{
new CustomVideoSettingsialog(0.8f, 0.8f);
}
else if(name == "apply_resolution") else if(name == "apply_resolution")
{ {
using namespace GUIEngine; using namespace GUIEngine;

View File

@ -57,6 +57,8 @@ public:
/** \brief implement optional callback from parent class GUIEngine::Screen */ /** \brief implement optional callback from parent class GUIEngine::Screen */
virtual void unloaded(); virtual void unloaded();
void updateGfxSlider();
}; };
#endif #endif