2010-05-15 12:12:41 -04:00
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
2013-11-15 06:43:21 -05:00
|
|
|
// Copyright (C) 2009-2013 Marianne Gagnon
|
2010-05-15 12:12:41 -04:00
|
|
|
//
|
|
|
|
// 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/options_screen_video.hpp"
|
|
|
|
|
|
|
|
#include "audio/music_manager.hpp"
|
|
|
|
#include "audio/sfx_manager.hpp"
|
|
|
|
#include "audio/sfx_base.hpp"
|
2014-02-25 20:52:16 -05:00
|
|
|
#include "config/user_config.hpp"
|
2010-05-15 12:12:41 -04:00
|
|
|
#include "graphics/irr_driver.hpp"
|
|
|
|
#include "guiengine/screen.hpp"
|
2010-05-15 14:51:29 -04:00
|
|
|
#include "guiengine/widgets/button_widget.hpp"
|
2010-05-15 12:12:41 -04:00
|
|
|
#include "guiengine/widgets/check_box_widget.hpp"
|
|
|
|
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
|
|
|
#include "guiengine/widgets/spinner_widget.hpp"
|
|
|
|
#include "guiengine/widget.hpp"
|
|
|
|
#include "io/file_manager.hpp"
|
2011-12-22 16:14:57 -05:00
|
|
|
#include "states_screens/dialogs/custom_video_settings.hpp"
|
2010-08-14 21:15:19 -04:00
|
|
|
#include "states_screens/options_screen_audio.hpp"
|
|
|
|
#include "states_screens/options_screen_input.hpp"
|
|
|
|
#include "states_screens/options_screen_players.hpp"
|
2011-03-20 14:50:20 -04:00
|
|
|
#include "states_screens/options_screen_ui.hpp"
|
2010-05-15 12:12:41 -04:00
|
|
|
#include "states_screens/state_manager.hpp"
|
2010-05-15 14:10:55 -04:00
|
|
|
#include "utils/string_utils.hpp"
|
2011-03-18 12:50:22 -04:00
|
|
|
#include "utils/translation.hpp"
|
2010-05-15 12:12:41 -04:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
using namespace GUIEngine;
|
|
|
|
|
|
|
|
DEFINE_SCREEN_SINGLETON( OptionsScreenVideo );
|
|
|
|
|
2011-01-13 22:10:04 -05:00
|
|
|
// Look-up table for GFX levels
|
2013-12-01 14:18:14 -05:00
|
|
|
static const bool GFX [] = {false, true, true, true, true, true, true};
|
|
|
|
static const int GFX_ANIM_KARTS[] = {0, 1, 2, 2, 2, 2, 2 };
|
|
|
|
static const bool GFX_WEATHER [] = {false, false, true, true, true, true, true};
|
|
|
|
static const bool GFX_MOTIONBLUR[] = {false, false, false, false, true, true, true};
|
2013-11-30 16:33:06 -05:00
|
|
|
static const bool GFX_PIXEL_SHADERS[] =
|
2013-12-01 14:18:14 -05:00
|
|
|
{false, false, true, true, true, true, true};
|
|
|
|
static const bool GFX_MLAA[] = {false, false, false, false, false, true, true};
|
|
|
|
static const int GFX_SSAO[] = {0, 0, 0, 1, 1, 1, 2 };
|
|
|
|
static const int GFX_SHADOWS[] = {0, 0, 0, 1, 1, 2, 2 };
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
|
2013-12-01 14:18:14 -05:00
|
|
|
static const int GFX_LEVEL_AMOUNT = 7;
|
2011-01-13 22:10:04 -05:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-15 12:12:41 -04:00
|
|
|
|
|
|
|
OptionsScreenVideo::OptionsScreenVideo() : Screen("options_video.stkgui")
|
|
|
|
{
|
|
|
|
m_inited = false;
|
2010-08-14 21:15:19 -04:00
|
|
|
} // OptionsScreenVideo
|
2010-05-15 12:12:41 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-15 12:12:41 -04:00
|
|
|
|
|
|
|
void OptionsScreenVideo::loadedFromFile()
|
|
|
|
{
|
|
|
|
m_inited = false;
|
2010-05-15 14:10:55 -04:00
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
GUIEngine::SpinnerWidget* gfx =
|
2011-11-01 19:00:22 -04:00
|
|
|
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
|
2013-05-29 18:04:35 -04:00
|
|
|
gfx->m_properties[GUIEngine::PROP_MAX_VALUE] =
|
2011-11-01 19:00:22 -04:00
|
|
|
StringUtils::toString(GFX_LEVEL_AMOUNT);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-08-14 21:15:19 -04:00
|
|
|
} // loadedFromFile
|
2010-05-15 12:12:41 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-15 12:12:41 -04:00
|
|
|
|
|
|
|
void OptionsScreenVideo::init()
|
|
|
|
{
|
2010-08-14 21:15:19 -04:00
|
|
|
Screen::init();
|
2011-11-01 19:00:22 -04:00
|
|
|
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
|
2010-05-15 12:12:41 -04:00
|
|
|
if (ribbon != NULL) ribbon->select( "tab_video", PLAYER_ID_GAME_MASTER );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-03-20 15:49:55 -04:00
|
|
|
ribbon->getRibbonChildren()[1].setTooltip( _("Audio") );
|
|
|
|
ribbon->getRibbonChildren()[2].setTooltip( _("User Interface") );
|
|
|
|
ribbon->getRibbonChildren()[3].setTooltip( _("Players") );
|
|
|
|
ribbon->getRibbonChildren()[4].setTooltip( _("Controls") );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
GUIEngine::ButtonWidget* applyBtn =
|
2011-11-01 19:00:22 -04:00
|
|
|
getWidget<GUIEngine::ButtonWidget>("apply_resolution");
|
2010-05-15 14:51:29 -04:00
|
|
|
assert( applyBtn != NULL );
|
2011-01-13 22:10:04 -05:00
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::SpinnerWidget* gfx =
|
2011-11-01 19:00:22 -04:00
|
|
|
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
|
2010-11-19 16:44:20 -05:00
|
|
|
assert( gfx != NULL );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
GUIEngine::CheckBoxWidget* vsync =
|
|
|
|
getWidget<GUIEngine::CheckBoxWidget>("vsync");
|
2011-03-20 14:50:20 -04:00
|
|
|
assert( vsync != NULL );
|
|
|
|
vsync->setState( UserConfigParams::m_vsync );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
// ---- video modes
|
2011-11-01 19:00:22 -04:00
|
|
|
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
|
2010-05-15 12:12:41 -04:00
|
|
|
assert( res != NULL );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen");
|
2010-05-15 12:12:41 -04:00
|
|
|
assert( full != NULL );
|
|
|
|
full->setState( UserConfigParams::m_fullscreen );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-03-28 21:04:07 -04:00
|
|
|
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
|
|
|
|
rememberWinpos->setState(UserConfigParams::m_remember_window_location);
|
|
|
|
|
|
|
|
if (UserConfigParams::m_fullscreen) rememberWinpos->setDeactivated();
|
|
|
|
else rememberWinpos->setActivated();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-06-12 14:51:05 -04:00
|
|
|
// Enable back widgets if they were visited in-game previously
|
|
|
|
if (StateManager::get()->getGameState() != GUIEngine::INGAME_MENU)
|
|
|
|
{
|
|
|
|
res->setActivated();
|
|
|
|
full->setActivated();
|
|
|
|
applyBtn->setActivated();
|
|
|
|
gfx->setActivated();
|
2011-12-25 15:22:37 -05:00
|
|
|
getWidget<ButtonWidget>("custom")->setActivated();
|
2011-06-12 14:51:05 -04:00
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
// --- get resolution list from irrlicht the first time
|
|
|
|
if (!m_inited)
|
|
|
|
{
|
2010-06-26 11:00:13 -04:00
|
|
|
res->clearItems();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
const std::vector<IrrDriver::VideoMode>& modes =
|
2011-10-12 07:28:35 -04:00
|
|
|
irr_driver->getVideoModes();
|
2010-05-15 12:12:41 -04:00
|
|
|
const int amount = modes.size();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-01-16 19:50:07 -05:00
|
|
|
bool found_config_res = false;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
// for some odd reason, irrlicht sometimes fails to report the good
|
2011-11-01 19:00:22 -04:00
|
|
|
// old standard resolutions
|
2011-01-16 19:50:07 -05:00
|
|
|
// those are always useful for windowed mode
|
|
|
|
bool found_800_600 = false;
|
|
|
|
bool found_1024_640 = false;
|
|
|
|
bool found_1024_768 = false;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-04-06 18:39:54 -04:00
|
|
|
for (int n=0; n<amount; n++)
|
2010-05-15 12:12:41 -04:00
|
|
|
{
|
2011-10-12 07:28:35 -04:00
|
|
|
const int w = modes[n].getWidth();
|
|
|
|
const int h = modes[n].getHeight();
|
2010-05-15 12:12:41 -04:00
|
|
|
const float ratio = (float)w / h;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
if (w == UserConfigParams::m_width &&
|
2011-11-01 19:00:22 -04:00
|
|
|
h == UserConfigParams::m_height)
|
2011-01-16 19:50:07 -05:00
|
|
|
{
|
|
|
|
found_config_res = true;
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-03-01 19:28:09 -05:00
|
|
|
if (w == 800 && h == 600)
|
2011-01-16 19:50:07 -05:00
|
|
|
{
|
|
|
|
found_800_600 = true;
|
|
|
|
}
|
|
|
|
else if (w == 1024 && h == 640)
|
|
|
|
{
|
|
|
|
found_1024_640 = true;
|
|
|
|
}
|
|
|
|
else if (w == 1024 && h == 768)
|
|
|
|
{
|
|
|
|
found_1024_768 = true;
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
char name[32];
|
|
|
|
sprintf( name, "%ix%i", w, h );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-06-12 11:29:32 -04:00
|
|
|
core::stringw label;
|
|
|
|
label += w;
|
|
|
|
label += L"\u00D7";
|
|
|
|
label += h;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
#define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01)
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
if (ABOUT_EQUAL( ratio, (5.0f/4.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen54.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen43.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (16.0f/10.0f)))
|
|
|
|
res->addItem(label, name, "/gui/screen1610.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen53.png");
|
2013-05-29 18:04:35 -04:00
|
|
|
else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) ))
|
2011-11-01 19:00:22 -04:00
|
|
|
res->addItem(label, name, "/gui/screen32.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen169.png");
|
2013-05-29 18:04:35 -04:00
|
|
|
else
|
2011-11-01 19:00:22 -04:00
|
|
|
res->addItem(label, name, "/gui/screen_other.png");
|
2010-05-15 12:12:41 -04:00
|
|
|
#undef ABOUT_EQUAL
|
|
|
|
} // next resolution
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-01-16 19:50:07 -05:00
|
|
|
if (!found_config_res)
|
|
|
|
{
|
|
|
|
const int w = UserConfigParams::m_width;
|
|
|
|
const int h = UserConfigParams::m_height;
|
|
|
|
const float ratio = (float)w / h;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-03-01 19:28:09 -05:00
|
|
|
if (w == 800 && h == 600)
|
|
|
|
{
|
|
|
|
found_800_600 = true;
|
|
|
|
}
|
|
|
|
else if (w == 1024 && h == 640)
|
|
|
|
{
|
|
|
|
found_1024_640 = true;
|
|
|
|
}
|
|
|
|
else if (w == 1024 && h == 768)
|
|
|
|
{
|
|
|
|
found_1024_768 = true;
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-01-16 19:50:07 -05:00
|
|
|
char name[32];
|
|
|
|
sprintf( name, "%ix%i", w, h );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-06-12 14:43:27 -04:00
|
|
|
core::stringw label;
|
|
|
|
label += w;
|
|
|
|
label += L"\u00D7";
|
|
|
|
label += h;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-01-16 19:50:07 -05:00
|
|
|
#define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01)
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
if (ABOUT_EQUAL( ratio, (5.0f/4.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen54.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen43.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (16.0f/10.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen1610.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen53.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen32.png");
|
|
|
|
else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) ))
|
|
|
|
res->addItem(label, name, "/gui/screen169.png");
|
|
|
|
else
|
|
|
|
res->addItem(label, name, "/gui/screen_other.png");
|
2011-01-16 19:50:07 -05:00
|
|
|
#undef ABOUT_EQUAL
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-01-16 19:50:07 -05:00
|
|
|
if (!found_800_600)
|
|
|
|
{
|
2011-06-12 11:29:32 -04:00
|
|
|
res->addItem(L"800\u00D7600", "800x600", "/gui/screen43.png");
|
2011-01-16 19:50:07 -05:00
|
|
|
}
|
|
|
|
if (!found_1024_640)
|
|
|
|
{
|
2011-06-12 11:29:32 -04:00
|
|
|
res->addItem(L"1024\u00D7640", "1024x640", "/gui/screen1610.png");
|
2011-01-16 19:50:07 -05:00
|
|
|
}
|
|
|
|
if (!found_1024_768)
|
|
|
|
{
|
2011-06-12 11:29:32 -04:00
|
|
|
res->addItem(L"1024\u00D7768", "1024x768", "/gui/screen43.png");
|
2011-01-16 19:50:07 -05:00
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
} // end if not inited
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
res->updateItemDisplay();
|
2011-06-12 14:51:05 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
// ---- select current resolution every time
|
2011-01-16 19:50:07 -05:00
|
|
|
char searching_for[32];
|
2013-05-29 18:04:35 -04:00
|
|
|
snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_width,
|
2011-11-01 19:00:22 -04:00
|
|
|
(int)UserConfigParams::m_height);
|
2011-06-18 11:43:23 -04:00
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
if (res->setSelection(searching_for, PLAYER_ID_GAME_MASTER,
|
2011-11-01 19:00:22 -04:00
|
|
|
false /* focus it */, true /* even if deactivated*/))
|
2010-05-15 12:12:41 -04:00
|
|
|
{
|
2011-04-06 18:28:57 -04:00
|
|
|
// ok found
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
std::cerr << "[OptionsScreenVideo] Cannot find resolution '"
|
2011-11-01 19:00:22 -04:00
|
|
|
<< searching_for << "'\n";
|
2011-04-06 18:28:57 -04:00
|
|
|
}
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-11-19 16:44:20 -05:00
|
|
|
// --- set gfx settings values
|
2011-12-22 16:14:57 -05:00
|
|
|
updateGfxSlider();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-12-22 16:14:57 -05:00
|
|
|
// ---- forbid changing resolution or animation settings from in-game
|
2013-05-29 18:04:35 -04:00
|
|
|
// (we need to disable them last because some items can't be edited when
|
2011-12-22 16:14:57 -05:00
|
|
|
// disabled)
|
|
|
|
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
|
|
|
|
{
|
|
|
|
res->setDeactivated();
|
|
|
|
full->setDeactivated();
|
|
|
|
applyBtn->setDeactivated();
|
|
|
|
gfx->setDeactivated();
|
2011-12-25 15:22:37 -05:00
|
|
|
getWidget<ButtonWidget>("custom")->setDeactivated();
|
2011-12-22 16:14:57 -05:00
|
|
|
}
|
|
|
|
} // init
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OptionsScreenVideo::updateGfxSlider()
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::SpinnerWidget* gfx =
|
2011-12-22 16:14:57 -05:00
|
|
|
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
|
|
|
|
assert( gfx != NULL );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-12-22 16:14:57 -05:00
|
|
|
bool found = false;
|
2011-01-13 22:10:04 -05:00
|
|
|
for (int l=0; l<GFX_LEVEL_AMOUNT; l++)
|
|
|
|
{
|
2011-11-01 19:00:22 -04:00
|
|
|
if (UserConfigParams::m_show_steering_animations == GFX_ANIM_KARTS[l]&&
|
2011-01-13 22:10:04 -05:00
|
|
|
UserConfigParams::m_graphical_effects == GFX[l] &&
|
2011-03-20 13:39:05 -04:00
|
|
|
UserConfigParams::m_weather_effects == GFX_WEATHER[l] &&
|
2013-12-01 14:05:44 -05:00
|
|
|
//UserConfigParams::m_antialiasing == GFX_ANTIALIAS[l] &&
|
2013-11-30 16:33:06 -05:00
|
|
|
UserConfigParams::m_motionblur == GFX_MOTIONBLUR[l] &&
|
|
|
|
UserConfigParams::m_mlaa == GFX_MLAA[l] &&
|
|
|
|
UserConfigParams::m_ssao == GFX_SSAO[l] &&
|
|
|
|
UserConfigParams::m_shadows == GFX_SHADOWS[l] &&
|
2014-04-14 16:11:20 -04:00
|
|
|
// UserConfigParams::m_pixel_shaders == GFX_PIXEL_SHADERS[l])
|
|
|
|
true)
|
2011-01-13 22:10:04 -05:00
|
|
|
{
|
|
|
|
gfx->setValue(l+1);
|
2011-12-22 16:14:57 -05:00
|
|
|
found = true;
|
2011-01-13 22:10:04 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-12-22 16:14:57 -05:00
|
|
|
if (!found)
|
2011-06-12 14:51:05 -04:00
|
|
|
{
|
2011-12-22 16:14:57 -05:00
|
|
|
//I18N: custom video settings
|
|
|
|
gfx->setCustomText( _("Custom") );
|
2011-06-12 14:51:05 -04:00
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-08-02 10:17:34 -04:00
|
|
|
updateTooltip();
|
2011-12-22 16:14:57 -05:00
|
|
|
}
|
2010-05-15 12:12:41 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-15 12:12:41 -04:00
|
|
|
|
2011-03-18 12:50:22 -04:00
|
|
|
void OptionsScreenVideo::updateTooltip()
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::SpinnerWidget* gfx =
|
2011-11-01 19:00:22 -04:00
|
|
|
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
|
2011-03-18 12:50:22 -04:00
|
|
|
assert( gfx != NULL );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-03-18 12:50:22 -04:00
|
|
|
core::stringw tooltip;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
//I18N: in the graphical options tooltip;
|
2011-11-01 19:00:22 -04:00
|
|
|
// indicates a graphical feature is enabled
|
2013-11-30 16:33:06 -05:00
|
|
|
const core::stringw enabled = _LTR("Enabled");
|
2013-05-29 18:04:35 -04:00
|
|
|
//I18N: in the graphical options tooltip;
|
2011-11-01 19:00:22 -04:00
|
|
|
// indicates a graphical feature is disabled
|
2013-11-30 16:33:06 -05:00
|
|
|
const core::stringw disabled = _LTR("Disabled");
|
2011-03-18 12:50:22 -04:00
|
|
|
//I18N: if all kart animations are enabled
|
2013-11-30 16:33:06 -05:00
|
|
|
const core::stringw all = _LTR("All");
|
2011-03-18 12:50:22 -04:00
|
|
|
//I18N: if some kart animations are enabled
|
2013-11-30 16:33:06 -05:00
|
|
|
const core::stringw me = _LTR("Me Only");
|
2011-03-18 12:50:22 -04:00
|
|
|
//I18N: if no kart animations are enabled
|
2013-11-30 16:33:06 -05:00
|
|
|
const core::stringw none = _LTR("None");
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-12-01 14:05:44 -05:00
|
|
|
/*
|
2012-04-25 11:44:17 -04:00
|
|
|
core::stringw antialias_label;
|
|
|
|
switch ((int)UserConfigParams::m_antialiasing)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
antialias_label = disabled; break;
|
|
|
|
case 1:
|
|
|
|
antialias_label = L"x2"; break;
|
|
|
|
case 2:
|
|
|
|
antialias_label = L"x4"; break;
|
|
|
|
case 3:
|
|
|
|
antialias_label = L"x8"; break;
|
|
|
|
}
|
2013-12-01 14:05:44 -05:00
|
|
|
*/
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
//I18N: in graphical options
|
2014-04-14 16:11:20 -04:00
|
|
|
// tooltip = tooltip + L"\n" + _("Pixel shaders : %s",
|
|
|
|
// UserConfigParams::m_pixel_shaders ? enabled : disabled);
|
2011-03-20 13:39:05 -04:00
|
|
|
//I18N: in graphical options
|
2013-05-29 18:04:35 -04:00
|
|
|
tooltip = _("Animated Scenery : %s",
|
2011-11-01 19:00:22 -04:00
|
|
|
UserConfigParams::m_graphical_effects ? enabled : disabled);
|
2011-03-20 13:39:05 -04:00
|
|
|
//I18N: in graphical options
|
2013-05-29 18:04:35 -04:00
|
|
|
tooltip = tooltip + L"\n" + _("Weather Effects : %s",
|
2011-11-01 19:00:22 -04:00
|
|
|
UserConfigParams::m_weather_effects ? enabled : disabled);
|
2011-03-20 13:39:05 -04:00
|
|
|
//I18N: in graphical options
|
2011-11-01 19:00:22 -04:00
|
|
|
tooltip = tooltip + L"\n" + _("Animated Characters : %s",
|
2013-05-29 18:04:35 -04:00
|
|
|
UserConfigParams::m_show_steering_animations == 2
|
|
|
|
? all
|
2011-11-01 19:00:22 -04:00
|
|
|
: (UserConfigParams::m_show_steering_animations == 1 ? me : none));
|
2011-03-20 13:39:05 -04:00
|
|
|
//I18N: in graphical options
|
2013-12-01 14:05:44 -05:00
|
|
|
//tooltip = tooltip + L"\n" + _("Anti-aliasing (requires restart) : %s",
|
|
|
|
// antialias_label);
|
2011-07-25 16:35:44 -04:00
|
|
|
//I18N: in graphical options
|
2013-11-30 16:33:06 -05:00
|
|
|
tooltip = tooltip + L"\n" + _("Motion blur: %s",
|
|
|
|
UserConfigParams::m_motionblur ? enabled : disabled);
|
2011-12-25 15:22:37 -05:00
|
|
|
//I18N: in graphical options
|
2013-12-01 14:05:44 -05:00
|
|
|
tooltip = tooltip + L"\n" + _("Anti-aliasing : %s",
|
2013-11-30 16:33:06 -05:00
|
|
|
UserConfigParams::m_mlaa ? enabled : disabled);
|
|
|
|
//I18N: in graphical options
|
2013-12-01 14:05:44 -05:00
|
|
|
tooltip = tooltip + L"\n" + _("Ambient occlusion : %s",
|
2013-11-30 16:33:06 -05:00
|
|
|
UserConfigParams::m_ssao == 1 ? "low" : UserConfigParams::m_ssao == 2 ?
|
|
|
|
"high" : disabled);
|
|
|
|
//I18N: in graphical options
|
|
|
|
tooltip = tooltip + L"\n" + _("Shadows: %s",
|
|
|
|
UserConfigParams::m_shadows == 1 ? "low" : UserConfigParams::m_shadows == 2 ?
|
|
|
|
"high" : disabled);
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-18 12:50:22 -04:00
|
|
|
gfx->setTooltip(tooltip);
|
2011-11-01 19:00:22 -04:00
|
|
|
} // updateTooltip
|
2011-03-18 12:50:22 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2011-03-18 12:50:22 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|
|
|
const int playerID)
|
2010-05-15 12:12:41 -04:00
|
|
|
{
|
|
|
|
if (name == "options_choice")
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
std::string selection =
|
2011-11-01 19:00:22 -04:00
|
|
|
((RibbonWidget*)widget)
|
|
|
|
->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
Screen *screen = NULL;
|
2013-05-29 18:04:35 -04:00
|
|
|
if (selection == "tab_audio")
|
2011-11-01 19:00:22 -04:00
|
|
|
screen = OptionsScreenAudio::getInstance();
|
|
|
|
else if (selection == "tab_video")
|
|
|
|
screen = OptionsScreenVideo::getInstance();
|
|
|
|
else if (selection == "tab_players")
|
|
|
|
screen = OptionsScreenPlayers::getInstance();
|
2013-05-29 18:04:35 -04:00
|
|
|
else if (selection == "tab_controls")
|
2011-11-01 19:00:22 -04:00
|
|
|
screen = OptionsScreenInput::getInstance();
|
2013-05-29 18:04:35 -04:00
|
|
|
else if (selection == "tab_ui")
|
2011-11-01 19:00:22 -04:00
|
|
|
screen = OptionsScreenUI::getInstance();
|
|
|
|
if(screen)
|
|
|
|
StateManager::get()->replaceTopMostScreen(screen);
|
2010-05-15 12:12:41 -04:00
|
|
|
}
|
|
|
|
else if(name == "back")
|
|
|
|
{
|
|
|
|
StateManager::get()->escapePressed();
|
|
|
|
}
|
2011-12-22 16:14:57 -05:00
|
|
|
else if(name == "custom")
|
|
|
|
{
|
|
|
|
new CustomVideoSettingsialog(0.8f, 0.8f);
|
|
|
|
}
|
2010-05-15 12:12:41 -04:00
|
|
|
else if(name == "apply_resolution")
|
|
|
|
{
|
|
|
|
using namespace GUIEngine;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
DynamicRibbonWidget* w1=getWidget<DynamicRibbonWidget>("resolutions");
|
2010-05-15 12:12:41 -04:00
|
|
|
assert(w1 != NULL);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
const std::string& res =
|
2011-11-01 19:00:22 -04:00
|
|
|
w1->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
int w = -1, h = -1;
|
|
|
|
if (sscanf(res.c_str(), "%ix%i", &w, &h) != 2 || w == -1 || h == -1)
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
std::cerr << "Failed to decode resolution : " << res.c_str()
|
2011-11-01 19:00:22 -04:00
|
|
|
<< std::endl;
|
2010-05-15 12:12:41 -04:00
|
|
|
return;
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
CheckBoxWidget* w2 = getWidget<CheckBoxWidget>("fullscreen");
|
2010-05-15 12:12:41 -04:00
|
|
|
assert(w2 != NULL);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-05-15 12:12:41 -04:00
|
|
|
|
|
|
|
irr_driver->changeResolution(w, h, w2->getState());
|
|
|
|
}
|
2011-01-13 22:10:04 -05:00
|
|
|
else if (name == "gfx_level")
|
2010-11-19 16:44:20 -05:00
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::SpinnerWidget* gfx_level =
|
2011-11-01 19:00:22 -04:00
|
|
|
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
|
2011-01-13 22:10:04 -05:00
|
|
|
assert( gfx_level != NULL );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-01-13 22:10:04 -05:00
|
|
|
const int level = gfx_level->getValue();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-01-13 22:10:04 -05:00
|
|
|
UserConfigParams::m_show_steering_animations = GFX_ANIM_KARTS[level-1];
|
|
|
|
UserConfigParams::m_graphical_effects = GFX[level-1];
|
2011-01-13 22:40:26 -05:00
|
|
|
UserConfigParams::m_weather_effects = GFX_WEATHER[level-1];
|
2013-12-01 14:05:44 -05:00
|
|
|
//UserConfigParams::m_antialiasing = GFX_ANTIALIAS[level-1];
|
2013-11-30 16:33:06 -05:00
|
|
|
UserConfigParams::m_motionblur = GFX_MOTIONBLUR[level-1];
|
2014-04-14 16:11:20 -04:00
|
|
|
// UserConfigParams::m_pixel_shaders = GFX_PIXEL_SHADERS[level-1];
|
2013-11-30 16:33:06 -05:00
|
|
|
UserConfigParams::m_mlaa = GFX_MLAA[level-1];
|
|
|
|
UserConfigParams::m_ssao = GFX_SSAO[level-1];
|
|
|
|
UserConfigParams::m_shadows = GFX_SHADOWS[level-1];
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-08-02 10:18:11 -04:00
|
|
|
updateGfxSlider();
|
2010-11-19 16:44:20 -05:00
|
|
|
}
|
2011-03-20 14:52:59 -04:00
|
|
|
else if (name == "vsync")
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::CheckBoxWidget* vsync =
|
2011-11-01 19:00:22 -04:00
|
|
|
getWidget<GUIEngine::CheckBoxWidget>("vsync");
|
2011-03-20 14:52:59 -04:00
|
|
|
assert( vsync != NULL );
|
|
|
|
UserConfigParams::m_vsync = vsync->getState();
|
|
|
|
}
|
2012-03-28 21:04:07 -04:00
|
|
|
else if (name == "rememberWinpos")
|
|
|
|
{
|
|
|
|
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
|
|
|
|
UserConfigParams::m_remember_window_location = rememberWinpos->getState();
|
|
|
|
}
|
|
|
|
else if (name == "fullscreen")
|
|
|
|
{
|
|
|
|
CheckBoxWidget* fullscreen = getWidget<CheckBoxWidget>("fullscreen");
|
|
|
|
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-03-28 21:04:07 -04:00
|
|
|
if (fullscreen->getState()) rememberWinpos->setDeactivated();
|
|
|
|
else rememberWinpos->setActivated();
|
|
|
|
}
|
2010-08-14 21:15:19 -04:00
|
|
|
} // eventCallback
|
2010-05-15 12:12:41 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-15 12:12:41 -04:00
|
|
|
|
|
|
|
void OptionsScreenVideo::tearDown()
|
|
|
|
{
|
2010-08-14 21:15:19 -04:00
|
|
|
Screen::tearDown();
|
2010-05-15 14:10:55 -04:00
|
|
|
// save changes when leaving screen
|
|
|
|
user_config->saveConfig();
|
2010-08-14 21:15:19 -04:00
|
|
|
} // tearDown
|
2010-05-15 12:12:41 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-15 12:12:41 -04:00
|
|
|
|
|
|
|
void OptionsScreenVideo::unloaded()
|
|
|
|
{
|
|
|
|
m_inited = false;
|
2010-08-14 21:15:19 -04:00
|
|
|
} // unloaded
|
2010-05-15 12:12:41 -04:00
|
|
|
|
2011-11-01 19:00:22 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-15 12:12:41 -04:00
|
|
|
|