Added back support for detecting bogus resolutions when switching, and revert to the previous working one when user can't click confirmation button
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4628 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
af02da1267
commit
5d2d0973f2
@ -260,6 +260,8 @@ supertuxkart_SOURCES = \
|
|||||||
states_screens/credits.hpp \
|
states_screens/credits.hpp \
|
||||||
states_screens/dialogs/add_device_dialog.cpp \
|
states_screens/dialogs/add_device_dialog.cpp \
|
||||||
states_screens/dialogs/add_device_dialog.hpp \
|
states_screens/dialogs/add_device_dialog.hpp \
|
||||||
|
states_screens/dialogs/confirm_resolution_dialog.cpp \
|
||||||
|
states_screens/dialogs/confirm_resolution_dialog.hpp \
|
||||||
states_screens/dialogs/enter_player_name_dialog.cpp \
|
states_screens/dialogs/enter_player_name_dialog.cpp \
|
||||||
states_screens/dialogs/enter_player_name_dialog.hpp \
|
states_screens/dialogs/enter_player_name_dialog.hpp \
|
||||||
states_screens/dialogs/player_info_dialog.hpp \
|
states_screens/dialogs/player_info_dialog.hpp \
|
||||||
|
@ -215,8 +215,8 @@ namespace UserConfigParams
|
|||||||
PARAM_DEFAULT( IntUserConfigParam(800, "prev_width", &m_video_group, "Previous screen/window width") );
|
PARAM_DEFAULT( IntUserConfigParam(800, "prev_width", &m_video_group, "Previous screen/window width") );
|
||||||
PARAM_PREFIX IntUserConfigParam m_prev_height
|
PARAM_PREFIX IntUserConfigParam m_prev_height
|
||||||
PARAM_DEFAULT( IntUserConfigParam(600, "prev_height", &m_video_group,"Previous screen/window height") );
|
PARAM_DEFAULT( IntUserConfigParam(600, "prev_height", &m_video_group,"Previous screen/window height") );
|
||||||
PARAM_PREFIX BoolUserConfigParam m_prev_windowed
|
PARAM_PREFIX BoolUserConfigParam m_prev_fullscreen
|
||||||
PARAM_DEFAULT( BoolUserConfigParam(true, "prev_windowed", &m_video_group) );
|
PARAM_DEFAULT( BoolUserConfigParam(false, "prev_fullscreen", &m_video_group) );
|
||||||
|
|
||||||
// TODO : adapt to be more powerful with irrlicht
|
// TODO : adapt to be more powerful with irrlicht
|
||||||
PARAM_PREFIX BoolUserConfigParam m_graphical_effects
|
PARAM_PREFIX BoolUserConfigParam m_graphical_effects
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "karts/player_kart.hpp"
|
#include "karts/player_kart.hpp"
|
||||||
#include "main_loop.hpp"
|
#include "main_loop.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
#include "states_screens/dialogs/confirm_resolution_dialog.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
|
|
||||||
@ -276,7 +277,26 @@ void IrrDriver::hidePointer()
|
|||||||
} // hidePointer
|
} // hidePointer
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void IrrDriver::changeResolution()
|
|
||||||
|
void IrrDriver::changeResolution(const int w, const int h, const bool fullscreen)
|
||||||
|
{
|
||||||
|
// update user config values
|
||||||
|
UserConfigParams::m_prev_width = UserConfigParams::m_width;
|
||||||
|
UserConfigParams::m_prev_height = UserConfigParams::m_height;
|
||||||
|
UserConfigParams::m_prev_fullscreen = UserConfigParams::m_fullscreen;
|
||||||
|
|
||||||
|
UserConfigParams::m_width = w;
|
||||||
|
UserConfigParams::m_height = h;
|
||||||
|
UserConfigParams::m_fullscreen = fullscreen;
|
||||||
|
|
||||||
|
doApplyResSettings();
|
||||||
|
|
||||||
|
new ConfirmResolutionDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void IrrDriver::doApplyResSettings()
|
||||||
{
|
{
|
||||||
m_res_switching = true;
|
m_res_switching = true;
|
||||||
|
|
||||||
@ -299,6 +319,10 @@ void IrrDriver::changeResolution()
|
|||||||
|
|
||||||
m_device->closeDevice();
|
m_device->closeDevice();
|
||||||
m_device->drop();
|
m_device->drop();
|
||||||
|
m_device = NULL;
|
||||||
|
m_video_driver = NULL;
|
||||||
|
m_gui_env = NULL;
|
||||||
|
m_scene_manager = NULL;
|
||||||
initDevice();
|
initDevice();
|
||||||
|
|
||||||
material_manager->reInit();
|
material_manager->reInit();
|
||||||
@ -315,6 +339,17 @@ void IrrDriver::changeResolution()
|
|||||||
|
|
||||||
} // changeResolution
|
} // changeResolution
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void IrrDriver::cancelResChange()
|
||||||
|
{
|
||||||
|
UserConfigParams::m_width = UserConfigParams::m_prev_width;
|
||||||
|
UserConfigParams::m_height = UserConfigParams::m_prev_height;
|
||||||
|
UserConfigParams::m_fullscreen = UserConfigParams::m_prev_fullscreen;
|
||||||
|
|
||||||
|
doApplyResSettings();
|
||||||
|
} // cancelResChange
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Prints statistics about rendering, e.g. number of drawn and culled
|
/** Prints statistics about rendering, e.g. number of drawn and culled
|
||||||
* triangles etc. Note that printing this information will also slow
|
* triangles etc. Note that printing this information will also slow
|
||||||
|
@ -66,6 +66,9 @@ private:
|
|||||||
/** Whether the mouse cursor is currently shown */
|
/** Whether the mouse cursor is currently shown */
|
||||||
bool m_pointer_shown;
|
bool m_pointer_shown;
|
||||||
|
|
||||||
|
/** Internal method that applies the resolution in user settings. */
|
||||||
|
void doApplyResSettings();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IrrDriver();
|
IrrDriver();
|
||||||
~IrrDriver();
|
~IrrDriver();
|
||||||
@ -117,7 +120,11 @@ public:
|
|||||||
void removeCamera(Camera *camera);
|
void removeCamera(Camera *camera);
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
|
|
||||||
void changeResolution();
|
/** Call to change resolution */
|
||||||
|
void changeResolution(const int w, const int h, const bool fullscreen);
|
||||||
|
/** Call this to roll back to the previous resolution if a resolution switch attempt goes bad */
|
||||||
|
void cancelResChange();
|
||||||
|
|
||||||
void showPointer();
|
void showPointer();
|
||||||
void hidePointer();
|
void hidePointer();
|
||||||
bool isPointerShown() const { return m_pointer_shown; }
|
bool isPointerShown() const { return m_pointer_shown; }
|
||||||
|
@ -169,6 +169,14 @@ void cleanUp()
|
|||||||
|
|
||||||
g_current_screen = NULL;
|
g_current_screen = NULL;
|
||||||
needsUpdate.clearWithoutDeleting();
|
needsUpdate.clearWithoutDeleting();
|
||||||
|
|
||||||
|
if (ModalDialog::isADialogActive()) ModalDialog::dismiss();
|
||||||
|
|
||||||
|
delete g_font;
|
||||||
|
g_font = NULL;
|
||||||
|
delete g_title_font;
|
||||||
|
g_title_font = NULL;
|
||||||
|
|
||||||
// nothing else to delete for now AFAIK, irrlicht will automatically kill everything along the device
|
// nothing else to delete for now AFAIK, irrlicht will automatically kill everything along the device
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +278,8 @@ void render(float elapsed_time)
|
|||||||
// ---- some menus may need updating
|
// ---- some menus may need updating
|
||||||
if (gamestate != GAME)
|
if (gamestate != GAME)
|
||||||
{
|
{
|
||||||
getCurrentScreen()->onUpdate(elapsed_time, g_driver);
|
if (ModalDialog::isADialogActive()) ModalDialog::getCurrent()->onUpdate(dt);
|
||||||
|
else getCurrentScreen()->onUpdate(elapsed_time, g_driver);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,9 @@ public:
|
|||||||
static void onEnterPressed();
|
static void onEnterPressed();
|
||||||
static ModalDialog* getCurrent();
|
static ModalDialog* getCurrent();
|
||||||
static bool isADialogActive();
|
static bool isADialogActive();
|
||||||
|
|
||||||
|
/** Override to be notified of updates */
|
||||||
|
virtual void onUpdate(float dt) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -277,6 +277,7 @@
|
|||||||
95D950D20FE473CA002E10AD /* stk_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D950CE0FE473CA002E10AD /* stk_config.cpp */; };
|
95D950D20FE473CA002E10AD /* stk_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D950CE0FE473CA002E10AD /* stk_config.cpp */; };
|
||||||
95D950D30FE473CA002E10AD /* user_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D950D00FE473CA002E10AD /* user_config.cpp */; };
|
95D950D30FE473CA002E10AD /* user_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95D950D00FE473CA002E10AD /* user_config.cpp */; };
|
||||||
95DFC5021106933B00A043A9 /* slip_stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95DFC5001106933B00A043A9 /* slip_stream.cpp */; };
|
95DFC5021106933B00A043A9 /* slip_stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95DFC5001106933B00A043A9 /* slip_stream.cpp */; };
|
||||||
|
95E246BE111A2959000C965D /* confirm_resolution_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95E246BC111A2959000C965D /* confirm_resolution_dialog.cpp */; };
|
||||||
95ECA10010124C5000D47C5F /* button_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95ECA0EC10124C5000D47C5F /* button_widget.cpp */; };
|
95ECA10010124C5000D47C5F /* button_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95ECA0EC10124C5000D47C5F /* button_widget.cpp */; };
|
||||||
95ECA10110124C5000D47C5F /* check_box_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95ECA0EE10124C5000D47C5F /* check_box_widget.cpp */; };
|
95ECA10110124C5000D47C5F /* check_box_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95ECA0EE10124C5000D47C5F /* check_box_widget.cpp */; };
|
||||||
95ECA10210124C5000D47C5F /* icon_button_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95ECA0F010124C5000D47C5F /* icon_button_widget.cpp */; };
|
95ECA10210124C5000D47C5F /* icon_button_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95ECA0F010124C5000D47C5F /* icon_button_widget.cpp */; };
|
||||||
@ -1056,6 +1057,8 @@
|
|||||||
95D950D10FE473CA002E10AD /* user_config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = user_config.hpp; path = ../../config/user_config.hpp; sourceTree = SOURCE_ROOT; };
|
95D950D10FE473CA002E10AD /* user_config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = user_config.hpp; path = ../../config/user_config.hpp; sourceTree = SOURCE_ROOT; };
|
||||||
95DFC5001106933B00A043A9 /* slip_stream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = slip_stream.cpp; path = ../../graphics/slip_stream.cpp; sourceTree = SOURCE_ROOT; };
|
95DFC5001106933B00A043A9 /* slip_stream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = slip_stream.cpp; path = ../../graphics/slip_stream.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
95DFC5011106933B00A043A9 /* slip_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = slip_stream.hpp; path = ../../graphics/slip_stream.hpp; sourceTree = SOURCE_ROOT; };
|
95DFC5011106933B00A043A9 /* slip_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = slip_stream.hpp; path = ../../graphics/slip_stream.hpp; sourceTree = SOURCE_ROOT; };
|
||||||
|
95E246BC111A2959000C965D /* confirm_resolution_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = confirm_resolution_dialog.cpp; path = ../../states_screens/dialogs/confirm_resolution_dialog.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
|
95E246BD111A2959000C965D /* confirm_resolution_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = confirm_resolution_dialog.hpp; path = ../../states_screens/dialogs/confirm_resolution_dialog.hpp; sourceTree = SOURCE_ROOT; };
|
||||||
95ECA0EC10124C5000D47C5F /* button_widget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = button_widget.cpp; path = ../../guiengine/widgets/button_widget.cpp; sourceTree = SOURCE_ROOT; };
|
95ECA0EC10124C5000D47C5F /* button_widget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = button_widget.cpp; path = ../../guiengine/widgets/button_widget.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
95ECA0ED10124C5000D47C5F /* button_widget.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = button_widget.hpp; path = ../../guiengine/widgets/button_widget.hpp; sourceTree = SOURCE_ROOT; };
|
95ECA0ED10124C5000D47C5F /* button_widget.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = button_widget.hpp; path = ../../guiengine/widgets/button_widget.hpp; sourceTree = SOURCE_ROOT; };
|
||||||
95ECA0EE10124C5000D47C5F /* check_box_widget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_box_widget.cpp; path = ../../guiengine/widgets/check_box_widget.cpp; sourceTree = SOURCE_ROOT; };
|
95ECA0EE10124C5000D47C5F /* check_box_widget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_box_widget.cpp; path = ../../guiengine/widgets/check_box_widget.cpp; sourceTree = SOURCE_ROOT; };
|
||||||
@ -1321,6 +1324,8 @@
|
|||||||
children = (
|
children = (
|
||||||
956541DF10DD628C00C83E99 /* add_device_dialog.cpp */,
|
956541DF10DD628C00C83E99 /* add_device_dialog.cpp */,
|
||||||
956541E010DD628C00C83E99 /* add_device_dialog.hpp */,
|
956541E010DD628C00C83E99 /* add_device_dialog.hpp */,
|
||||||
|
95E246BC111A2959000C965D /* confirm_resolution_dialog.cpp */,
|
||||||
|
95E246BD111A2959000C965D /* confirm_resolution_dialog.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 */,
|
||||||
95833239101243ED00C5137E /* player_info_dialog.cpp */,
|
95833239101243ED00C5137E /* player_info_dialog.cpp */,
|
||||||
@ -2599,6 +2604,7 @@
|
|||||||
959482D410EBC0790031BADF /* track_object.cpp in Sources */,
|
959482D410EBC0790031BADF /* track_object.cpp in Sources */,
|
||||||
9553823A10FD4FEC00737979 /* constants.cpp in Sources */,
|
9553823A10FD4FEC00737979 /* constants.cpp in Sources */,
|
||||||
95DFC5021106933B00A043A9 /* slip_stream.cpp in Sources */,
|
95DFC5021106933B00A043A9 /* slip_stream.cpp in Sources */,
|
||||||
|
95E246BE111A2959000C965D /* confirm_resolution_dialog.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
150
src/states_screens/dialogs/confirm_resolution_dialog.cpp
Normal file
150
src/states_screens/dialogs/confirm_resolution_dialog.cpp
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
// 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 "config/player.hpp"
|
||||||
|
#include "guiengine/engine.hpp"
|
||||||
|
#include "guiengine/widget.hpp"
|
||||||
|
#include "input/device_manager.hpp"
|
||||||
|
#include "input/input_manager.hpp"
|
||||||
|
#include "states_screens/dialogs/confirm_resolution_dialog.hpp"
|
||||||
|
#include "states_screens/state_manager.hpp"
|
||||||
|
#include "utils/string_utils.hpp"
|
||||||
|
#include "utils/translation.hpp"
|
||||||
|
|
||||||
|
using namespace GUIEngine;
|
||||||
|
using namespace irr::gui;
|
||||||
|
using namespace irr::core;
|
||||||
|
|
||||||
|
ConfirmResolutionDialog::ConfirmResolutionDialog() : ModalDialog(0.7f, 0.7f)
|
||||||
|
{
|
||||||
|
m_countdown_message = NULL;
|
||||||
|
|
||||||
|
IGUIFont* font = GUIEngine::getFont();
|
||||||
|
const int textHeight = GUIEngine::getFontHeight();
|
||||||
|
const int buttonHeight = textHeight + 10;
|
||||||
|
|
||||||
|
const int y_bottom = m_area.getHeight() - 2*(buttonHeight + 10) - 10;
|
||||||
|
|
||||||
|
m_remaining_time = 10.99f;
|
||||||
|
|
||||||
|
// ---- Add label
|
||||||
|
core::rect<s32> text_area( 15, 15, m_area.getWidth()-15, y_bottom-15 );
|
||||||
|
|
||||||
|
m_countdown_message = GUIEngine::getGUIEnv()->addStaticText( L" ",
|
||||||
|
text_area, false , true , // border, word warp
|
||||||
|
m_irrlicht_window);
|
||||||
|
m_countdown_message->setTabStop(false);
|
||||||
|
|
||||||
|
updateMessage();
|
||||||
|
|
||||||
|
// ---- Add accept button
|
||||||
|
{
|
||||||
|
ButtonWidget* widget = new ButtonWidget();
|
||||||
|
widget->m_properties[PROP_ID] = "accept";
|
||||||
|
|
||||||
|
//I18N: In the 'confirm resolution' dialog, that's shown when switching resoluton
|
||||||
|
widget->m_text = _("Keep this resolution");
|
||||||
|
|
||||||
|
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
|
||||||
|
|
||||||
|
widget->x = m_area.getWidth()/2 - textWidth/2;
|
||||||
|
widget->y = y_bottom;
|
||||||
|
widget->w = textWidth;
|
||||||
|
widget->h = buttonHeight;
|
||||||
|
widget->setParent(m_irrlicht_window);
|
||||||
|
m_children.push_back(widget);
|
||||||
|
widget->add();
|
||||||
|
}
|
||||||
|
// ---- Add cancel button
|
||||||
|
{
|
||||||
|
ButtonWidget* widget = new ButtonWidget();
|
||||||
|
widget->m_properties[PROP_ID] = "cancel";
|
||||||
|
widget->m_text = _("Cancel");
|
||||||
|
|
||||||
|
const int textWidth = font->getDimension( widget->m_text.c_str() ).Width + 40;
|
||||||
|
|
||||||
|
widget->x = m_area.getWidth()/2 - textWidth/2;
|
||||||
|
widget->y = y_bottom + buttonHeight + 10;
|
||||||
|
widget->w = textWidth;
|
||||||
|
widget->h = buttonHeight;
|
||||||
|
widget->setParent(m_irrlicht_window);
|
||||||
|
m_children.push_back(widget);
|
||||||
|
widget->add();
|
||||||
|
|
||||||
|
widget->setFocusForPlayer( GUI_PLAYER_ID );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void ConfirmResolutionDialog::onEnterPressedInternal()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void ConfirmResolutionDialog::onUpdate(float dt)
|
||||||
|
{
|
||||||
|
const int previous_number = (int)m_remaining_time;
|
||||||
|
m_remaining_time -= dt;
|
||||||
|
|
||||||
|
if (m_remaining_time < 0)
|
||||||
|
{
|
||||||
|
ModalDialog::dismiss();
|
||||||
|
irr_driver->cancelResChange();
|
||||||
|
}
|
||||||
|
else if ((int)m_remaining_time != previous_number)
|
||||||
|
{
|
||||||
|
updateMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void ConfirmResolutionDialog::updateMessage()
|
||||||
|
{
|
||||||
|
assert(m_countdown_message != NULL);
|
||||||
|
stringw msg = StringUtils::insertValues(_("Confirm resolution within %i seconds"),
|
||||||
|
(int)m_remaining_time);
|
||||||
|
//std::cout << stringc(msg.c_str()).c_str() << std::endl;
|
||||||
|
m_countdown_message->setText( msg.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
GUIEngine::EventPropagation ConfirmResolutionDialog::processEvent(std::string& eventSource)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (eventSource == "cancel")
|
||||||
|
{
|
||||||
|
ModalDialog::dismiss();
|
||||||
|
|
||||||
|
irr_driver->cancelResChange();
|
||||||
|
return GUIEngine::EVENT_BLOCK;
|
||||||
|
}
|
||||||
|
else if (eventSource == "accept")
|
||||||
|
{
|
||||||
|
ModalDialog::dismiss();
|
||||||
|
|
||||||
|
return GUIEngine::EVENT_BLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GUIEngine::EVENT_LET;
|
||||||
|
}
|
45
src/states_screens/dialogs/confirm_resolution_dialog.hpp
Normal file
45
src/states_screens/dialogs/confirm_resolution_dialog.hpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// 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_CONFIRM_RES_DIALOG_HPP
|
||||||
|
#define HEADER_ADD_DEVICE_DIALOG_HPP
|
||||||
|
|
||||||
|
#include "config/player.hpp"
|
||||||
|
#include "guiengine/modaldialog.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
class ConfirmResolutionDialog : public GUIEngine::ModalDialog
|
||||||
|
{
|
||||||
|
/** number of seconds left before resolution is considered unplayable */
|
||||||
|
float m_remaining_time;
|
||||||
|
|
||||||
|
irr::gui::IGUIStaticText* m_countdown_message;
|
||||||
|
|
||||||
|
/** updates countdown message */
|
||||||
|
void updateMessage();
|
||||||
|
public:
|
||||||
|
|
||||||
|
ConfirmResolutionDialog();
|
||||||
|
void onEnterPressedInternal();
|
||||||
|
GUIEngine::EventPropagation processEvent(std::string& eventSource);
|
||||||
|
|
||||||
|
virtual void onUpdate(float dt);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -198,9 +198,6 @@ void OptionsScreenAV::eventCallback(Widget* widget, const std::string& name, con
|
|||||||
{
|
{
|
||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
|
|
||||||
UserConfigParams::m_prev_width = UserConfigParams::m_width;
|
|
||||||
UserConfigParams::m_prev_height = UserConfigParams::m_height;
|
|
||||||
|
|
||||||
DynamicRibbonWidget* w1 = this->getWidget<DynamicRibbonWidget>("resolutions");
|
DynamicRibbonWidget* w1 = this->getWidget<DynamicRibbonWidget>("resolutions");
|
||||||
assert(w1 != NULL);
|
assert(w1 != NULL);
|
||||||
|
|
||||||
@ -216,10 +213,8 @@ void OptionsScreenAV::eventCallback(Widget* widget, const std::string& name, con
|
|||||||
CheckBoxWidget* w2 = this->getWidget<CheckBoxWidget>("fullscreen");
|
CheckBoxWidget* w2 = this->getWidget<CheckBoxWidget>("fullscreen");
|
||||||
assert(w2 != NULL);
|
assert(w2 != NULL);
|
||||||
|
|
||||||
UserConfigParams::m_width = w;
|
|
||||||
UserConfigParams::m_height = h;
|
irr_driver->changeResolution(w, h, w2->getState());
|
||||||
UserConfigParams::m_fullscreen = w2->getState();
|
|
||||||
irr_driver->changeResolution();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user