Add a new 'Display' option tab

The video settings were getting crowded with the benchmark mode, and with large font size the benchmark buttons ended off-screen.
This commit is contained in:
Alayan 2024-05-05 14:24:56 +02:00
parent aba99c22b6
commit 7ad4040b2d
No known key found for this signature in database
22 changed files with 676 additions and 374 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<icon-button id="back" x="1%" y="0" height="9%" icon="gui/icons/back.png"/>
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
<header width="80%" height="8%" align="center" text="SuperTuxKart Options" text_align="center"/>
<spacer width="100%" height="1%"/>
<div width="100%" height="91%" layout="horizontal-row" >
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"
I18N="Section in the settings menu" text="Audio"/>
<icon-button id="tab_ui" width="128" height="128" icon="gui/icons/options_ui.png"
I18N="Section in the settings menu" text="Interface"/>
<icon-button id="tab_players" width="128" height="128" icon="gui/icons/options_players.png"
I18N="Section in the settings menu" text="Players"/>
<icon-button id="tab_controls" width="128" height="128" icon="gui/icons/options_input.png"
I18N="Section in the settings menu" text="Controls"/>
<icon-button id="tab_language" width="128" height="128" icon="gui/icons/options_language.png"
I18N="Section in the settings menu" text="Language"/>
</vertical-tabs>
<spacer width="2%" height="100%"/>
<box width="78%" height="100%" layout="vertical-row">
<!-- ************ RESOLUTION CHOICE ************ -->
<label width="100%" I18N="In the display settings" text="Resolution"/>
<spacer width="5" height="1%"/>
<div layout="horizontal-row" width="100%" height="fit">
<div proportion="2" height="fit" layout="horizontal-row" >
<spacer width="5%" height="100%" />
<checkbox id="fullscreen"/>
<spacer width="2%" height="100%" />
<label id="fullscreenText" height="100%" I18N="In the display settings" text="Fullscreen"/>
</div>
<div proportion="3" layout="horizontal-row" height="fit">
<spacer width="5%" height="100%" />
<checkbox id="rememberWinpos"/>
<spacer width="2%" height="100%" />
<label id="rememberWinposText" height="100%" I18N="In the display settings" text="Remember window location"/>
</div>
</div>
<spacer width="5" height="1%"/>
<scrollable_ribbon id="resolutions" height="20%" label_location="each"
width="100%" square_items="false"
align="center" child_width="128" child_height="128" />
<spacer width="5" height="2%"/>
<div width="100%" height="fit" layout="horizontal-row" >
<spacer width="5%" height="100%" />
<button id="apply_resolution"
I18N="In the display settings" text="Apply new resolution" />
</div>
</box>
</div>
</div>
</stkgui>

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"
@ -87,43 +89,6 @@
<button id="custom" text="Custom settings..." I18N="In the video settings" align="center"/>
</div>
<spacer width="5" height="3%"/>
<!-- ************ RESOLUTION CHOICE ************ -->
<label width="100%" I18N="In the video settings" text="Resolution"/>
<spacer width="5" height="1%"/>
<div layout="horizontal-row" width="100%" height="fit">
<div proportion="2" height="fit" layout="horizontal-row" >
<spacer width="5%" height="100%" />
<checkbox id="fullscreen"/>
<spacer width="2%" height="100%" />
<label id="fullscreenText" height="100%" I18N="In the video settings" text="Fullscreen"/>
</div>
<div proportion="3" layout="horizontal-row" height="fit">
<spacer width="5%" height="100%" />
<checkbox id="rememberWinpos"/>
<spacer width="2%" height="100%" />
<label id="rememberWinposText" height="100%" I18N="In the video settings" text="Remember window location"/>
</div>
</div>
<spacer width="5" height="1%"/>
<scrollable_ribbon id="resolutions" height="20%" label_location="each"
width="100%" square_items="false"
align="center" child_width="128" child_height="128" />
<spacer width="5" height="2%"/>
<div width="100%" height="fit" layout="horizontal-row" >
<spacer width="5%" height="100%" />
<button id="apply_resolution"
I18N="In the video settings" text="Apply new resolution" />
</div>
<!-- ************ BENCHMARK OPTIONS ************ -->
<spacer width="5" height="3%"/>

View File

@ -10,6 +10,8 @@
<vertical-tabs id="options_choice" height="100%" width="20%">
<icon-button id="tab_general" width="128" height="128" icon="gui/icons/options_general.png"
I18N="Section in the settings menu" text="General"/>
<icon-button id="tab_display" width="128" height="128" icon="gui/icons/options_display.png"
I18N="Section in the settings menu" text="Display"/>
<icon-button id="tab_video" width="128" height="128" icon="gui/icons/options_video.png"
I18N="Section in the settings menu" text="Graphics"/>
<icon-button id="tab_audio" width="128" height="128" icon="gui/icons/options_audio.png"

View File

@ -27,13 +27,14 @@
#include "guiengine/widgets/spinner_widget.hpp"
#include "guiengine/widget.hpp"
#include "io/file_manager.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_language.hpp"
#include "states_screens/options/options_screen_ui.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/options/user_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include <iostream>
@ -110,7 +111,9 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name,
Screen *screen = NULL;
//if (selection == "tab_audio")
// screen = OptionsScreenAudio::getInstance();
if (selection == "tab_video")
if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")
screen = TabbedUserScreen::getInstance();

View File

@ -36,13 +36,14 @@
#include "states_screens/dialogs/press_a_key_dialog.hpp"
#include "states_screens/dialogs/general_text_field_dialog.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_language.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/options/options_screen_ui.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/options/user_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
@ -541,6 +542,8 @@ void OptionsScreenDevice::eventCallback(Widget* widget,
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")

View File

@ -0,0 +1,460 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009-2015 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/options/options_screen_display.hpp"
#include "audio/sfx_manager.hpp"
#include "audio/sfx_base.hpp"
#include "config/user_config.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp"
#include "guiengine/widget.hpp"
#include "io/file_manager.hpp"
#include "race/race_manager.hpp"
#include "replay/replay_play.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_language.hpp"
#include "states_screens/options/options_screen_ui.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/options/user_screen.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
#ifndef SERVER_ONLY
#include <ge_main.hpp>
#include <ge_vulkan_driver.hpp>
#include <ge_vulkan_texture_descriptor.hpp>
#include <SDL_video.h>
#include "../../lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h"
#endif
#include <IrrlichtDevice.h>
#include <functional>
#include <iostream>
#include <iterator>
#include <sstream>
using namespace GUIEngine;
bool OptionsScreenDisplay::m_fullscreen_checkbox_focus = false;
// --------------------------------------------------------------------------------------------
OptionsScreenDisplay::OptionsScreenDisplay() : Screen("options/options_display.stkgui")
{
m_inited = false;
} // OptionsScreenDisplay
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::loadedFromFile()
{
m_inited = false;
} // loadedFromFile
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::init()
{
Screen::init();
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
assert(ribbon != NULL);
ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
ribbon->select( "tab_display", PLAYER_ID_GAME_MASTER );
GUIEngine::ButtonWidget* applyBtn =
getWidget<GUIEngine::ButtonWidget>("apply_resolution");
assert( applyBtn != NULL );
// ---- video modes
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
assert(res != NULL);
res->registerScrollCallback(onScrollResolutionsList, this);
CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen");
assert( full != NULL );
full->setState( UserConfigParams::m_fullscreen );
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
assert( rememberWinpos != NULL );
rememberWinpos->setState(UserConfigParams::m_remember_window_location);
rememberWinpos->setActive(!UserConfigParams::m_fullscreen);
#ifdef DEBUG
LabelWidget* full_text = getWidget<LabelWidget>("fullscreenText");
assert( full_text != NULL );
LabelWidget* rememberWinposText =
getWidget<LabelWidget>("rememberWinposText");
assert( rememberWinposText != NULL );
#endif
bool is_vulkan_fullscreen_desktop = false;
#ifndef SERVER_ONLY
is_vulkan_fullscreen_desktop =
GE::getDriver()->getDriverType() == video::EDT_VULKAN &&
GE::getGEConfig()->m_fullscreen_desktop;
#endif
configResolutionsList();
// ---- forbid changing resolution or animation settings from in-game
// (we need to disable them last because some items can't be edited when
// disabled)
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
res->setActive(!in_game || is_vulkan_fullscreen_desktop);
full->setActive(!in_game || is_vulkan_fullscreen_desktop);
applyBtn->setActive(!in_game);
#if defined(MOBILE_STK) || defined(__SWITCH__)
applyBtn->setVisible(false);
full->setVisible(false);
getWidget<LabelWidget>("fullscreenText")->setVisible(false);
rememberWinpos->setVisible(false);
getWidget<LabelWidget>("rememberWinposText")->setVisible(false);
#endif
updateResolutionsList();
} // init
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::onResize()
{
Screen::onResize();
configResolutionsList();
if (m_fullscreen_checkbox_focus)
{
m_fullscreen_checkbox_focus = false;
Widget* full = getWidget("fullscreen");
if (full->isActivated() && full->isVisible())
full->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
} // onResize
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::configResolutionsList()
{
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
if (res == NULL)
return;
bool is_fullscreen_desktop = false;
#ifndef SERVER_ONLY
is_fullscreen_desktop =
GE::getGEConfig()->m_fullscreen_desktop;
#endif
res->clearItems();
const std::vector<IrrDriver::VideoMode>& modes =
irr_driver->getVideoModes();
const int amount = (int)modes.size();
m_resolutions.clear();
Resolution r;
bool found_config_res = false;
// for some odd reason, irrlicht sometimes fails to report the good
// old standard resolutions
// those are always useful for windowed mode
bool found_1024_768 = false;
bool found_1280_720 = false;
for (int n=0; n<amount; n++)
{
r.width = modes[n].getWidth();
r.height = modes[n].getHeight();
r.fullscreen = true;
m_resolutions.push_back(r);
if (r.width == UserConfigParams::m_real_width &&
r.height == UserConfigParams::m_real_height)
{
found_config_res = true;
}
if (r.width == 1024 && r.height == 768)
{
found_1024_768 = true;
}
if (r.width == 1280 && r.height == 720)
{
found_1280_720 = true;
}
}
// Use fullscreen desktop so only show current screen size
if (is_fullscreen_desktop)
{
found_config_res = false;
m_resolutions.clear();
found_1024_768 = true;
found_1280_720 = true;
}
if (!found_config_res)
{
r.width = UserConfigParams::m_real_width;
r.height = UserConfigParams::m_real_height;
r.fullscreen = is_fullscreen_desktop;
m_resolutions.push_back(r);
if (r.width == 1024 && r.height == 768)
{
found_1024_768 = true;
}
if (r.width == 1280 && r.height == 720)
{
found_1280_720 = true;
}
} // next found resolution
#if !defined(MOBILE_STK) && !defined(__SWITCH__)
// Add default resolutions that were not found by irrlicht
if (!found_1024_768)
{
r.width = 1024;
r.height = 768;
r.fullscreen = false;
m_resolutions.push_back(r);
}
if (!found_1280_720)
{
r.width = 1280;
r.height = 720;
r.fullscreen = false;
m_resolutions.push_back(r);
}
#endif
// Sort resolutions by size
std::sort(m_resolutions.begin(), m_resolutions.end());
// Add resolutions list
for(std::vector<Resolution>::iterator it = m_resolutions.begin();
it != m_resolutions.end(); it++)
{
const float ratio = it->getRatio();
char name[32];
sprintf(name, "%ix%i", it->width, it->height);
core::stringw label;
label += it->width;
label += L"\u00D7";
label += it->height;
#define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01)
if (ABOUT_EQUAL( ratio, (5.0f/4.0f) ))
res->addItem(label, name, "/gui/icons/screen54.png");
else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) ))
res->addItem(label, name, "/gui/icons/screen43.png");
else if (ABOUT_EQUAL( ratio, (16.0f/10.0f)))
res->addItem(label, name, "/gui/icons/screen1610.png");
else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) ))
res->addItem(label, name, "/gui/icons/screen53.png");
else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) ))
res->addItem(label, name, "/gui/icons/screen32.png");
else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) ))
res->addItem(label, name, "/gui/icons/screen169.png");
else
res->addItem(label, name, "/gui/icons/screen_other.png");
#undef ABOUT_EQUAL
} // add next resolution
res->updateItemDisplay();
// ---- select current resolution every time
char searching_for[32];
snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_real_width,
(int)UserConfigParams::m_real_height);
if (!res->setSelection(searching_for, PLAYER_ID_GAME_MASTER,
false /* focus it */, true /* even if deactivated*/))
{
Log::error("OptionsScreenDisplay", "Cannot find resolution %s", searching_for);
}
} // configResolutionsList
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::updateResolutionsList()
{
CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen");
assert(full != NULL);
bool fullscreen_selected = full->getState();
for (auto resolution : m_resolutions)
{
DynamicRibbonWidget* drw = getWidget<DynamicRibbonWidget>("resolutions");
assert(drw != NULL);
assert(drw->m_rows.size() == 1);
char name[128];
sprintf(name, "%ix%i", resolution.width, resolution.height);
Widget* w = drw->m_rows[0].findWidgetNamed(name);
if (w != NULL)
{
bool active = !fullscreen_selected || resolution.fullscreen;
w->setActive(active);
}
}
}
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::onScrollResolutionsList(void* data)
{
OptionsScreenDisplay* screen = (OptionsScreenDisplay*)data;
screen->updateResolutionsList();
}
// --------------------------------------------------------------------------------------------
extern "C" void update_fullscreen_desktop(int val);
extern "C" void reset_network_body();
void OptionsScreenDisplay::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == "options_choice")
{
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
//else if (selection == "tab_display")
// screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")
screen = TabbedUserScreen::getInstance();
else if (selection == "tab_controls")
screen = OptionsScreenInput::getInstance();
else if (selection == "tab_ui")
screen = OptionsScreenUI::getInstance();
else if (selection == "tab_general")
screen = OptionsScreenGeneral::getInstance();
else if (selection == "tab_language")
screen = OptionsScreenLanguage::getInstance();
if(screen)
StateManager::get()->replaceTopMostScreen(screen);
}
else if(name == "back")
{
StateManager::get()->escapePressed();
}
else if(name == "apply_resolution")
{
using namespace GUIEngine;
DynamicRibbonWidget* w1=getWidget<DynamicRibbonWidget>("resolutions");
assert(w1 != NULL);
assert(w1->m_rows.size() == 1);
int index = w1->m_rows[0].getSelection(PLAYER_ID_GAME_MASTER);
Widget* selected_widget = &w1->m_rows[0].getChildren()[index];
if (!selected_widget->isActivated())
return;
const std::string& res =
w1->getSelectionIDString(PLAYER_ID_GAME_MASTER);
int w = -1, h = -1;
if (sscanf(res.c_str(), "%ix%i", &w, &h) != 2 || w == -1 || h == -1)
{
Log::error("OptionsScreenDisplay", "Failed to decode resolution %s", res.c_str());
return;
}
CheckBoxWidget* w2 = getWidget<CheckBoxWidget>("fullscreen");
assert(w2 != NULL);
irr_driver->changeResolution(w, h, w2->getState());
}
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");
rememberWinpos->setActive(!fullscreen->getState());
#ifndef SERVER_ONLY
GE::GEVulkanDriver* gevk = GE::getVKDriver();
if (gevk && GE::getGEConfig()->m_fullscreen_desktop)
{
UserConfigParams::m_fullscreen = fullscreen->getState();
update_fullscreen_desktop(UserConfigParams::m_fullscreen);
OptionsScreenDisplay::m_fullscreen_checkbox_focus = true;
}
else
updateResolutionsList();
#endif
}
} // eventCallback
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::tearDown()
{
#ifndef SERVER_ONLY
Screen::tearDown();
// save changes when leaving screen
user_config->saveConfig();
#endif
} // tearDown
// --------------------------------------------------------------------------------------------
bool OptionsScreenDisplay::onEscapePressed()
{
GUIEngine::focusNothingForPlayer(PLAYER_ID_GAME_MASTER);
return true;
}
// --------------------------------------------------------------------------------------------
void OptionsScreenDisplay::unloaded()
{
m_inited = false;
} // unloaded
// --------------------------------------------------------------------------------------------

View File

@ -0,0 +1,97 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2009-2015 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_OPTIONS_SCREEN_DISPLAY_HPP__
#define __HEADER_OPTIONS_SCREEN_DISPLAY_HPP__
#include <string>
#include "guiengine/screen.hpp"
namespace GUIEngine { class Widget; }
struct Resolution
{
int width;
int height;
bool fullscreen;
Resolution()
{
width = 0;
height = 0;
}
Resolution(int w, int h)
{
width = w;
height = h;
}
bool operator< (Resolution r) const
{
return width < r.width || (width == r.width && height < r.height);
}
float getRatio() const
{
return (float) width / height;
}
};
/**
* \brief Display options screen
* \ingroup states_screens
*/
class OptionsScreenDisplay : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenDisplay>
{
private:
static bool m_fullscreen_checkbox_focus;
OptionsScreenDisplay();
bool m_inited;
std::vector<Resolution> m_resolutions;
void updateResolutionsList();
void configResolutionsList();
void initPresets();
static void onScrollResolutionsList(void* data);
public:
friend class GUIEngine::ScreenSingleton<OptionsScreenDisplay>;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void loadedFromFile() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
const int playerID) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void tearDown() OVERRIDE;
/** \brief implement optional callback from parent class GUIEngine::Screen */
virtual void unloaded() OVERRIDE;
virtual bool onEscapePressed() OVERRIDE;
virtual void onResize() OVERRIDE;
};
#endif

View File

@ -42,12 +42,13 @@
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_language.hpp"
#include "states_screens/options/options_screen_ui.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/options/user_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/extract_mobile_assets.hpp"
#include "utils/log.hpp"
#include "utils/string_utils.hpp"
@ -137,6 +138,8 @@ void OptionsScreenGeneral::eventCallback(Widget* widget, const std::string& name
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")

View File

@ -31,14 +31,15 @@
#include "io/file_manager.hpp"
#include "states_screens/options/options_screen_device.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_language.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/options/options_screen_ui.hpp"
#include "states_screens/options/user_screen.hpp"
#include "states_screens/dialogs/add_device_dialog.hpp"
#include "states_screens/dialogs/multitouch_settings_dialog.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/options/user_screen.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
@ -248,6 +249,8 @@ void OptionsScreenInput::eventCallback(Widget* widget, const std::string& name,
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")

View File

@ -40,12 +40,13 @@
#include "online/request_manager.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_ui.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/options/user_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "tips/tips_manager.hpp"
#include "utils/log.hpp"
#include "utils/string_utils.hpp"
@ -138,6 +139,8 @@ void OptionsScreenLanguage::eventCallback(Widget* widget, const std::string& nam
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")

View File

@ -48,12 +48,13 @@
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/dialogs/custom_camera_settings.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_language.hpp"
#include "states_screens/options/options_screen_video.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/options/user_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/log.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
@ -394,6 +395,8 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")

View File

@ -34,6 +34,7 @@
#include "replay/replay_play.hpp"
#include "states_screens/dialogs/custom_video_settings.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_language.hpp"
@ -59,7 +60,6 @@
#include <sstream>
using namespace GUIEngine;
bool OptionsScreenVideo::m_fullscreen_checkbox_focus = false;
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::initPresets()
@ -242,10 +242,6 @@ void OptionsScreenVideo::init()
ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
ribbon->select( "tab_video", PLAYER_ID_GAME_MASTER );
GUIEngine::ButtonWidget* applyBtn =
getWidget<GUIEngine::ButtonWidget>("apply_resolution");
assert( applyBtn != NULL );
GUIEngine::SpinnerWidget* gfx =
getWidget<GUIEngine::SpinnerWidget>("gfx_level");
assert( gfx != NULL );
@ -300,49 +296,16 @@ void OptionsScreenVideo::init()
scale_rtts->addLabel("95%");
scale_rtts->addLabel("100%");
// ---- video modes
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
assert(res != NULL);
res->registerScrollCallback(onScrollResolutionsList, this);
CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen");
assert( full != NULL );
full->setState( UserConfigParams::m_fullscreen );
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
assert( rememberWinpos != NULL );
rememberWinpos->setState(UserConfigParams::m_remember_window_location);
rememberWinpos->setActive(!UserConfigParams::m_fullscreen);
#ifdef DEBUG
LabelWidget* full_text = getWidget<LabelWidget>("fullscreenText");
assert( full_text != NULL );
LabelWidget* rememberWinposText =
getWidget<LabelWidget>("rememberWinposText");
assert( rememberWinposText != NULL );
#endif
bool is_vulkan_fullscreen_desktop = false;
#ifndef SERVER_ONLY
is_vulkan_fullscreen_desktop =
GE::getDriver()->getDriverType() == video::EDT_VULKAN &&
GE::getGEConfig()->m_fullscreen_desktop;
#endif
configResolutionsList();
// --- set gfx settings values
updateGfxSlider();
updateBlurSlider();
updateScaleRTTsSlider();
// ---- forbid changing resolution or animation settings from in-game
// ---- forbid changing graphic settings from in-game
// (we need to disable them last because some items can't be edited when
// disabled)
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
res->setActive(!in_game || is_vulkan_fullscreen_desktop);
full->setActive(!in_game || is_vulkan_fullscreen_desktop);
applyBtn->setActive(!in_game);
#ifndef SERVER_ONLY
gfx->setActive(!in_game && CVS->isGLSL());
getWidget<ButtonWidget>("custom")->setActive(!in_game || !CVS->isGLSL());
@ -354,16 +317,6 @@ void OptionsScreenVideo::init()
getWidget<ButtonWidget>("benchmarkCurrent")->setActive(!in_game);
#endif
#if defined(MOBILE_STK) || defined(__SWITCH__)
applyBtn->setVisible(false);
full->setVisible(false);
getWidget<LabelWidget>("fullscreenText")->setVisible(false);
rememberWinpos->setVisible(false);
getWidget<LabelWidget>("rememberWinposText")->setVisible(false);
#endif
updateResolutionsList();
// If a benchmark was requested and the game had to reload
// the graphics engine, start the benchmark when the
// video settings screen is loaded back afterwards.
@ -376,203 +329,10 @@ void OptionsScreenVideo::init()
void OptionsScreenVideo::onResize()
{
Screen::onResize();
configResolutionsList();
if (m_fullscreen_checkbox_focus)
{
m_fullscreen_checkbox_focus = false;
Widget* full = getWidget("fullscreen");
if (full->isActivated() && full->isVisible())
full->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
} // onResize
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::configResolutionsList()
{
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
if (res == NULL)
return;
bool is_fullscreen_desktop = false;
#ifndef SERVER_ONLY
is_fullscreen_desktop =
GE::getGEConfig()->m_fullscreen_desktop;
#endif
res->clearItems();
const std::vector<IrrDriver::VideoMode>& modes =
irr_driver->getVideoModes();
const int amount = (int)modes.size();
m_resolutions.clear();
Resolution r;
bool found_config_res = false;
// for some odd reason, irrlicht sometimes fails to report the good
// old standard resolutions
// those are always useful for windowed mode
bool found_1024_768 = false;
bool found_1280_720 = false;
for (int n=0; n<amount; n++)
{
r.width = modes[n].getWidth();
r.height = modes[n].getHeight();
r.fullscreen = true;
m_resolutions.push_back(r);
if (r.width == UserConfigParams::m_real_width &&
r.height == UserConfigParams::m_real_height)
{
found_config_res = true;
}
if (r.width == 1024 && r.height == 768)
{
found_1024_768 = true;
}
if (r.width == 1280 && r.height == 720)
{
found_1280_720 = true;
}
}
// Use fullscreen desktop so only show current screen size
if (is_fullscreen_desktop)
{
found_config_res = false;
m_resolutions.clear();
found_1024_768 = true;
found_1280_720 = true;
}
if (!found_config_res)
{
r.width = UserConfigParams::m_real_width;
r.height = UserConfigParams::m_real_height;
r.fullscreen = is_fullscreen_desktop;
m_resolutions.push_back(r);
if (r.width == 1024 && r.height == 768)
{
found_1024_768 = true;
}
if (r.width == 1280 && r.height == 720)
{
found_1280_720 = true;
}
} // next found resolution
#if !defined(MOBILE_STK) && !defined(__SWITCH__)
// Add default resolutions that were not found by irrlicht
if (!found_1024_768)
{
r.width = 1024;
r.height = 768;
r.fullscreen = false;
m_resolutions.push_back(r);
}
if (!found_1280_720)
{
r.width = 1280;
r.height = 720;
r.fullscreen = false;
m_resolutions.push_back(r);
}
#endif
// Sort resolutions by size
std::sort(m_resolutions.begin(), m_resolutions.end());
// Add resolutions list
for(std::vector<Resolution>::iterator it = m_resolutions.begin();
it != m_resolutions.end(); it++)
{
const float ratio = it->getRatio();
char name[32];
sprintf(name, "%ix%i", it->width, it->height);
core::stringw label;
label += it->width;
label += L"\u00D7";
label += it->height;
#define ABOUT_EQUAL(a , b) (fabsf( a - b ) < 0.01)
if (ABOUT_EQUAL( ratio, (5.0f/4.0f) ))
res->addItem(label, name, "/gui/icons/screen54.png");
else if (ABOUT_EQUAL( ratio, (4.0f/3.0f) ))
res->addItem(label, name, "/gui/icons/screen43.png");
else if (ABOUT_EQUAL( ratio, (16.0f/10.0f)))
res->addItem(label, name, "/gui/icons/screen1610.png");
else if (ABOUT_EQUAL( ratio, (5.0f/3.0f) ))
res->addItem(label, name, "/gui/icons/screen53.png");
else if (ABOUT_EQUAL( ratio, (3.0f/2.0f) ))
res->addItem(label, name, "/gui/icons/screen32.png");
else if (ABOUT_EQUAL( ratio, (16.0f/9.0f) ))
res->addItem(label, name, "/gui/icons/screen169.png");
else
res->addItem(label, name, "/gui/icons/screen_other.png");
#undef ABOUT_EQUAL
} // add next resolution
res->updateItemDisplay();
// ---- select current resolution every time
char searching_for[32];
snprintf(searching_for, 32, "%ix%i", (int)UserConfigParams::m_real_width,
(int)UserConfigParams::m_real_height);
if (!res->setSelection(searching_for, PLAYER_ID_GAME_MASTER,
false /* focus it */, true /* even if deactivated*/))
{
Log::error("OptionsScreenVideo", "Cannot find resolution %s", searching_for);
}
} // configResolutionsList
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::updateResolutionsList()
{
CheckBoxWidget* full = getWidget<CheckBoxWidget>("fullscreen");
assert(full != NULL);
bool fullscreen_selected = full->getState();
for (auto resolution : m_resolutions)
{
DynamicRibbonWidget* drw = getWidget<DynamicRibbonWidget>("resolutions");
assert(drw != NULL);
assert(drw->m_rows.size() == 1);
char name[128];
sprintf(name, "%ix%i", resolution.width, resolution.height);
Widget* w = drw->m_rows[0].findWidgetNamed(name);
if (w != NULL)
{
bool active = !fullscreen_selected || resolution.fullscreen;
w->setActive(active);
}
}
}
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::onScrollResolutionsList(void* data)
{
OptionsScreenVideo* screen = (OptionsScreenVideo*)data;
screen->updateResolutionsList();
}
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::updateGfxSlider()
{
GUIEngine::SpinnerWidget* gfx = getWidget<GUIEngine::SpinnerWidget>("gfx_level");
@ -773,7 +533,6 @@ void OptionsScreenVideo::updateBlurTooltip()
// --------------------------------------------------------------------------------------------
extern "C" void update_swap_interval(int swap_interval);
extern "C" void update_fullscreen_desktop(int val);
extern "C" void reset_network_body();
void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
@ -786,6 +545,8 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
//else if (selection == "tab_video")
// screen = OptionsScreenVideo::getInstance();
else if (selection == "tab_players")
@ -809,36 +570,6 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
{
new CustomVideoSettingsDialog(0.8f, 0.9f);
}
else if(name == "apply_resolution")
{
using namespace GUIEngine;
DynamicRibbonWidget* w1=getWidget<DynamicRibbonWidget>("resolutions");
assert(w1 != NULL);
assert(w1->m_rows.size() == 1);
int index = w1->m_rows[0].getSelection(PLAYER_ID_GAME_MASTER);
Widget* selected_widget = &w1->m_rows[0].getChildren()[index];
if (!selected_widget->isActivated())
return;
const std::string& res =
w1->getSelectionIDString(PLAYER_ID_GAME_MASTER);
int w = -1, h = -1;
if (sscanf(res.c_str(), "%ix%i", &w, &h) != 2 || w == -1 || h == -1)
{
Log::error("OptionsScreenVideo", "Failed to decode resolution %s", res.c_str());
return;
}
CheckBoxWidget* w2 = getWidget<CheckBoxWidget>("fullscreen");
assert(w2 != NULL);
irr_driver->changeResolution(w, h, w2->getState());
}
else if (name == "gfx_level")
{
GUIEngine::SpinnerWidget* gfx_level =
@ -968,29 +699,6 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
{
// DO NOTHING FOR NOW
}*/
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");
rememberWinpos->setActive(!fullscreen->getState());
#ifndef SERVER_ONLY
GE::GEVulkanDriver* gevk = GE::getVKDriver();
if (gevk && GE::getGEConfig()->m_fullscreen_desktop)
{
UserConfigParams::m_fullscreen = fullscreen->getState();
update_fullscreen_desktop(UserConfigParams::m_fullscreen);
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
}
else
updateResolutionsList();
#endif
}
} // eventCallback
// --------------------------------------------------------------------------------------------

View File

@ -53,35 +53,6 @@ struct ScaleRttsCustomPreset
float value;
};
struct Resolution
{
int width;
int height;
bool fullscreen;
Resolution()
{
width = 0;
height = 0;
}
Resolution(int w, int h)
{
width = w;
height = h;
}
bool operator< (Resolution r) const
{
return width < r.width || (width == r.width && height < r.height);
}
float getRatio() const
{
return (float) width / height;
}
};
/**
* \brief Graphics options screen
* \ingroup states_screens
@ -89,7 +60,6 @@ struct Resolution
class OptionsScreenVideo : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenVideo>
{
private:
static bool m_fullscreen_checkbox_focus;
bool m_prev_adv_pipline;
int m_prev_img_quality;
OptionsScreenVideo();
@ -97,12 +67,9 @@ private:
std::vector<GFXPreset> m_presets;
std::vector<BlurPreset> m_blur_presets;
std::vector<ScaleRttsCustomPreset> m_scale_rtts_custom_presets;
std::vector<Resolution> m_resolutions;
void updateTooltip();
void updateBlurTooltip();
void updateResolutionsList();
void configResolutionsList();
void initPresets();
void startBenchmark();
static void onScrollResolutionsList(void* data);

View File

@ -37,6 +37,7 @@
#include "states_screens/dialogs/recovery_dialog.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/options/options_screen_audio.hpp"
#include "states_screens/options/options_screen_display.hpp"
#include "states_screens/options/options_screen_general.hpp"
#include "states_screens/options/options_screen_input.hpp"
#include "states_screens/options/options_screen_language.hpp"
@ -747,6 +748,8 @@ void TabbedUserScreen::eventCallback(GUIEngine::Widget* widget,
Screen *screen = NULL;
if (selection == "tab_audio")
screen = OptionsScreenAudio::getInstance();
else if (selection == "tab_display")
screen = OptionsScreenDisplay::getInstance();
else if (selection == "tab_video")
screen = OptionsScreenVideo::getInstance();
//else if (selection == "tab_players")

View File

@ -152,7 +152,7 @@ class TabbedUserScreen : public BaseUserScreen,
public GUIEngine::ScreenSingleton<TabbedUserScreen>
{
private:
TabbedUserScreen() : BaseUserScreen("user_screen_tab.stkgui")
TabbedUserScreen() : BaseUserScreen("options/user_screen_tab.stkgui")
{}
public: