Show confirm dialog before permanently erasing keyboard config (the confirm dialog I added is reusable, so should we ever need another confirm dialog we can reuse this one)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5931 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
bb659ba7c8
commit
372e82374b
19
data/gui/confirm_dialog.stkgui
Normal file
19
data/gui/confirm_dialog.stkgui
Normal file
@ -0,0 +1,19 @@
|
||||
<stkgui>
|
||||
|
||||
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
|
||||
|
||||
<label id="title" width="100%" text_align="center" word_wrap="true" proportion="1" />
|
||||
|
||||
<spacer height="25" width="10" />
|
||||
|
||||
<button id="confirm" I18N="In a 'are you sure?' dialog" text="Yes" align="center"/>
|
||||
|
||||
<spacer height="15" width="10" />
|
||||
|
||||
<button id="cancel" I18N="In a 'are you sure?' dialog" text="Cancel" align="center"/>
|
||||
|
||||
<spacer height="10" width="10" />
|
||||
|
||||
</div>
|
||||
|
||||
</stkgui>
|
@ -272,6 +272,8 @@ supertuxkart_SOURCES = \
|
||||
states_screens/credits.hpp \
|
||||
states_screens/dialogs/add_device_dialog.cpp \
|
||||
states_screens/dialogs/add_device_dialog.hpp \
|
||||
states_screens/dialogs/confirm_dialog.cpp \
|
||||
states_screens/dialogs/confirm_dialog.hpp \
|
||||
states_screens/dialogs/confirm_resolution_dialog.cpp \
|
||||
states_screens/dialogs/confirm_resolution_dialog.hpp \
|
||||
states_screens/dialogs/enter_player_name_dialog.cpp \
|
||||
|
@ -47,6 +47,7 @@
|
||||
953789730FC7829100DD1F8E /* graph_node.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953789720FC7829100DD1F8E /* graph_node.cpp */; };
|
||||
953789820FC7831400DD1F8E /* quad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953789810FC7831400DD1F8E /* quad.cpp */; };
|
||||
953F8B2111F7C13C00205E66 /* scalable_font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 953F8B1F11F7C13C00205E66 /* scalable_font.cpp */; };
|
||||
954378D51238493C00F57707 /* confirm_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 954378D41238493C00F57707 /* confirm_dialog.cpp */; };
|
||||
95453ACA11808B8700A155B9 /* emergency_animation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95453AC811808B8700A155B9 /* emergency_animation.cpp */; };
|
||||
9545ABCA11E3E38300D3C37A /* progress_bar_widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9545ABC811E3E38300D3C37A /* progress_bar_widget.cpp */; };
|
||||
954E486A11B19C4100B1DF63 /* fribidi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 954E486911B19C4100B1DF63 /* fribidi.framework */; };
|
||||
@ -408,6 +409,8 @@
|
||||
953F8B2011F7C13C00205E66 /* scalable_font.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = scalable_font.hpp; path = ../../guiengine/scalable_font.hpp; sourceTree = SOURCE_ROOT; };
|
||||
9540E2560FD5F8FD002985B8 /* ptr_vector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ptr_vector.hpp; path = ../../utils/ptr_vector.hpp; sourceTree = SOURCE_ROOT; };
|
||||
9540E2570FD5F8FD002985B8 /* no_copy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = no_copy.hpp; path = ../../utils/no_copy.hpp; sourceTree = SOURCE_ROOT; };
|
||||
954378D41238493C00F57707 /* confirm_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = confirm_dialog.cpp; path = ../../states_screens/dialogs/confirm_dialog.cpp; sourceTree = SOURCE_ROOT; };
|
||||
954378E712384BEB00F57707 /* confirm_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = confirm_dialog.hpp; path = ../../states_screens/dialogs/confirm_dialog.hpp; sourceTree = SOURCE_ROOT; };
|
||||
95453AC811808B8700A155B9 /* emergency_animation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = emergency_animation.cpp; path = ../../karts/emergency_animation.cpp; sourceTree = SOURCE_ROOT; };
|
||||
95453AC911808B8700A155B9 /* emergency_animation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = emergency_animation.hpp; path = ../../karts/emergency_animation.hpp; sourceTree = SOURCE_ROOT; };
|
||||
9545ABC811E3E38300D3C37A /* progress_bar_widget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = progress_bar_widget.cpp; path = ../../guiengine/widgets/progress_bar_widget.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@ -1383,6 +1386,8 @@
|
||||
956541E010DD628C00C83E99 /* add_device_dialog.hpp */,
|
||||
95E6A0BE11DCF37800AE088A /* addons_loading.cpp */,
|
||||
95E6A0BF11DCF37800AE088A /* addons_loading.hpp */,
|
||||
954378D41238493C00F57707 /* confirm_dialog.cpp */,
|
||||
954378E712384BEB00F57707 /* confirm_dialog.hpp */,
|
||||
95E246BC111A2959000C965D /* confirm_resolution_dialog.cpp */,
|
||||
95E246BD111A2959000C965D /* confirm_resolution_dialog.hpp */,
|
||||
95833237101243ED00C5137E /* enter_player_name_dialog.cpp */,
|
||||
@ -2648,6 +2653,7 @@
|
||||
956039BA1218C09E00EB96C4 /* abstract_top_level_container.cpp in Sources */,
|
||||
9552C1FB1231249000347B6C /* world_with_rank.cpp in Sources */,
|
||||
956B0A9F1232D2E900767CCD /* bubble_widget.cpp in Sources */,
|
||||
954378D51238493C00F57707 /* confirm_dialog.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
69
src/states_screens/dialogs/confirm_dialog.cpp
Normal file
69
src/states_screens/dialogs/confirm_dialog.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "states_screens/dialogs/confirm_dialog.hpp"
|
||||
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
ConfirmDialog::ConfirmDialog(irr::core::stringw msg, IConfirmDialogListener* listener) :
|
||||
ModalDialog(0.6f, 0.6f)
|
||||
{
|
||||
loadFromFile("confirm_dialog.stkgui");
|
||||
|
||||
m_listener = listener;
|
||||
|
||||
LabelWidget* message = getWidget<LabelWidget>("title");
|
||||
message->setText( msg.c_str() );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void ConfirmDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation ConfirmDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
|
||||
if (eventSource == "cancel")
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
|
||||
m_listener->onCancel();
|
||||
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "confirm")
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
|
||||
m_listener->onConfirm();
|
||||
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
54
src/states_screens/dialogs/confirm_dialog.hpp
Normal file
54
src/states_screens/dialogs/confirm_dialog.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 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_DIALOG_HPP
|
||||
#define HEADER_CONFIRM_DIALOG_HPP
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
|
||||
|
||||
class ConfirmDialog : public GUIEngine::ModalDialog
|
||||
{
|
||||
public:
|
||||
class IConfirmDialogListener
|
||||
{
|
||||
public:
|
||||
IConfirmDialogListener() {}
|
||||
virtual ~IConfirmDialogListener() {}
|
||||
|
||||
/** \brief Implement to be notified of dialog confirmed */
|
||||
virtual void onConfirm() = 0;
|
||||
|
||||
/** \brief Implement to be notified of dialog cancelled */
|
||||
virtual void onCancel() {}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
IConfirmDialogListener* m_listener;
|
||||
|
||||
public:
|
||||
|
||||
ConfirmDialog(irr::core::stringw msg, IConfirmDialogListener* listener);
|
||||
void onEnterPressedInternal();
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -390,12 +390,8 @@ void OptionsScreenInput2::eventCallback(Widget* widget, const std::string& name,
|
||||
}
|
||||
else if (name == "delete")
|
||||
{
|
||||
// TODO: ask for confirmation before deleting
|
||||
const bool success = input_manager->getDeviceList()->deleteConfig(m_config);
|
||||
assert(success);
|
||||
m_config = NULL;
|
||||
input_manager->getDeviceList()->serialize();
|
||||
StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
//I18N: shown before deleting an input configuration
|
||||
new ConfirmDialog( _("Are you sure you want to permanently delete this configuration?"), this );
|
||||
}
|
||||
|
||||
} // eventCallback
|
||||
@ -415,3 +411,14 @@ bool OptionsScreenInput2::onEscapePressed()
|
||||
} // onEscapePressed
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void OptionsScreenInput2::onConfirm()
|
||||
{
|
||||
const bool success = input_manager->getDeviceList()->deleteConfig(m_config);
|
||||
assert(success);
|
||||
m_config = NULL;
|
||||
input_manager->getDeviceList()->serialize();
|
||||
StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "irrlicht.h"
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "states_screens/dialogs/confirm_dialog.hpp"
|
||||
|
||||
namespace GUIEngine { class Widget; }
|
||||
class DeviceConfig;
|
||||
@ -31,11 +32,14 @@ namespace irr { namespace gui { class STKModifiedSpriteBank; } }
|
||||
|
||||
struct Input;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Input options screen
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class OptionsScreenInput2 : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenInput2>
|
||||
class OptionsScreenInput2 : public GUIEngine::Screen,
|
||||
public GUIEngine::ScreenSingleton<OptionsScreenInput2>,
|
||||
public ConfirmDialog::IConfirmDialogListener
|
||||
{
|
||||
OptionsScreenInput2();
|
||||
|
||||
@ -70,6 +74,9 @@ public:
|
||||
* Updates the input bindings accordingly with the sensed input.
|
||||
*/
|
||||
void gotSensedInput(Input* sensedInput);
|
||||
|
||||
/** \brief Implement IConfirmDialogListener callback */
|
||||
virtual void onConfirm();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user