SuperTuxKart
Loading...
Searching...
No Matches
message_dialog.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2010-2015 Marianne Gagnon
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19#ifndef HEADER_CONFIRM_DIALOG_HPP
20#define HEADER_CONFIRM_DIALOG_HPP
21
22#include "guiengine/modaldialog.hpp"
23#include "utils/cpp2011.hpp"
24#include "utils/leak_check.hpp"
25
31{
32public:
33
39 {
40 public:
41
42 LEAK_CHECK()
43
45 virtual ~IConfirmDialogListener() {}
46
51 virtual void onConfirm() { ModalDialog::dismiss(); };
52
57 virtual void onCancel() { ModalDialog::dismiss(); };
58
62 virtual void onDialogUpdate(float dt) {}
63 };
64
65 enum MessageDialogType { MESSAGE_DIALOG_OK, MESSAGE_DIALOG_CONFIRM,
66 MESSAGE_DIALOG_OK_CANCEL, MESSAGE_DIALOG_YESNO,
67 MESSAGE_DIALOG_OK_DONTSHOWAGAIN };
68
69 MessageDialogType m_type;
70
71private:
72
73 IConfirmDialogListener* m_listener;
74 bool m_own_listener;
75 irr::core::stringw m_msg;
76 void doInit(bool from_queue);
77
81
82public:
83
90 MessageDialog(const irr::core::stringw &msg, MessageDialogType type,
91 IConfirmDialogListener* listener, bool delete_listener,
92 bool from_queue = false, float width = 0.6f, float height = 0.6f,
93 bool focus_on_cancel = false);
94
99 MessageDialog(const irr::core::stringw &msg, bool from_queue = false,
100 bool focus_on_cancel = false);
101
103
104 virtual void onEnterPressedInternal() OVERRIDE;
105 virtual void onUpdate(float dt) OVERRIDE;
106 virtual void load() OVERRIDE;
107
108 GUIEngine::EventPropagation processEvent(const std::string& eventSource) OVERRIDE;
109
110 virtual void loadedFromFile() OVERRIDE;
111
115 virtual void init() OVERRIDE;
116};
117
118
119#endif
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:56
Listener interface to get notified of whether the user chose to confirm or cancel.
Definition: message_dialog.hpp:39
virtual void onDialogUpdate(float dt)
Optional callback.
Definition: message_dialog.hpp:62
virtual void onConfirm()
Implement to be notified of dialog confirmed.
Definition: message_dialog.hpp:51
virtual void onCancel()
Implement to be notified of dialog cancelled.
Definition: message_dialog.hpp:57
Generic dialog to ask the user to confirm something, or to show a simple message box.
Definition: message_dialog.hpp:31
virtual void onUpdate(float dt) OVERRIDE
Override to be notified of updates.
Definition: message_dialog.cpp:193
void doInit(bool from_queue)
If necessary schedules a pause, and loads the xml file if necessary.
Definition: message_dialog.cpp:87
GUIEngine::EventPropagation processEvent(const std::string &eventSource) OVERRIDE
Returns whether to block event propagation (usually, you will want to block events you processed)
Definition: message_dialog.cpp:157
bool m_focus_on_cancel
If set this will set the focus on 'cancel'/'no' instead of "yes"/"ok".
Definition: message_dialog.hpp:80
virtual void init() OVERRIDE
Optional callback invoked after widgets have been add()ed.
Definition: message_dialog.cpp:200
virtual void loadedFromFile() OVERRIDE
Callback invoked when the dialog was loaded from the XML file (if the constructor that takes a XML fi...
Definition: message_dialog.cpp:112
void setFocusCancel()
Calling this will make sure that the focus is set on the 'cancel' or 'no'.
Definition: message_dialog.hpp:114
virtual void load() OVERRIDE
Called from the DialogQueue, used to load the actual xml file and init the dialog.
Definition: message_dialog.cpp:77
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33