Enable all message dialogs to work in the DialogQueue.
This commit is contained in:
parent
2e14a8fe20
commit
a74a20c699
@ -27,37 +27,77 @@
|
|||||||
|
|
||||||
using namespace GUIEngine;
|
using namespace GUIEngine;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Complete constructor, which allows setting of listener, type etc.
|
||||||
MessageDialog::MessageDialog(const irr::core::stringw &msg, MessageDialogType type,
|
* \param msg The text to be shown in the dialog.
|
||||||
IConfirmDialogListener* listener, bool own_listener) :
|
* \param type The type of dialog (OK, confirm, ok/cancel, ...).
|
||||||
ModalDialog(0.6f, 0.6f)
|
* \param listener An optional listener object.
|
||||||
|
* \param own_listener If true the dialog will free the listener.
|
||||||
|
* \param from_queue If the object is placed into the DialogQueue. If so,
|
||||||
|
* loadFromFile() is not called (it will be called when the dialog
|
||||||
|
* is finally being removed from the queue and shown).
|
||||||
|
*/
|
||||||
|
MessageDialog::MessageDialog(const irr::core::stringw &msg,
|
||||||
|
MessageDialogType type,
|
||||||
|
IConfirmDialogListener* listener,
|
||||||
|
bool own_listener, bool from_queue)
|
||||||
|
: ModalDialog(0.6f, 0.6f)
|
||||||
{
|
{
|
||||||
m_msg = msg;
|
m_msg = msg;
|
||||||
doInit(type, listener, own_listener);
|
m_type = type;
|
||||||
|
m_listener = listener;
|
||||||
|
m_own_listener = own_listener;
|
||||||
|
doInit(from_queue);
|
||||||
} // MessageDialog(stringw, type, listener, own_listener)
|
} // MessageDialog(stringw, type, listener, own_listener)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Simple constructor for a notification message (i.e. only OK button shown).
|
||||||
MessageDialog::MessageDialog(const irr::core::stringw &msg, bool from_queue) :
|
* \param msg The message to show.
|
||||||
ModalDialog(0.6f, 0.6f)
|
* \param from_queue If the object is placed into the DialogQueue. If so,
|
||||||
|
* loadFromFile() is not called (it will be called when the dialog
|
||||||
|
* is finally being removed from the queue and shown).
|
||||||
|
*/
|
||||||
|
MessageDialog::MessageDialog(const irr::core::stringw &msg, bool from_queue)
|
||||||
|
: ModalDialog(0.6f, 0.6f)
|
||||||
{
|
{
|
||||||
m_msg = msg;
|
m_msg = msg;
|
||||||
if(!from_queue) load();
|
m_type = MessageDialog::MESSAGE_DIALOG_OK;
|
||||||
|
m_listener = NULL;
|
||||||
|
m_own_listener = false;
|
||||||
|
if (!from_queue) doInit(false);
|
||||||
} // MessageDialog(stringw)
|
} // MessageDialog(stringw)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
/** Called from the DialogQueue, used to load the actual xml file and init
|
||||||
|
* the dialog.
|
||||||
|
*/
|
||||||
void MessageDialog::load()
|
void MessageDialog::load()
|
||||||
{
|
{
|
||||||
doInit(MessageDialog::MESSAGE_DIALOG_OK, NULL, false);
|
doInit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
/** If necessary schedules a pause, and loads the xml file if necessary.
|
||||||
|
* \param from_queue If the dialog is queued, do not load the xml file,
|
||||||
|
* this will be done later in the case of a queued dialog.
|
||||||
|
*/
|
||||||
|
void MessageDialog::doInit(bool from_queue)
|
||||||
|
{
|
||||||
|
if (StateManager::get()->getGameState() == GUIEngine::GAME)
|
||||||
|
{
|
||||||
|
World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!from_queue)
|
||||||
|
loadFromFile("confirm_dialog.stkgui");
|
||||||
|
} // doInit
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
MessageDialog::~MessageDialog()
|
MessageDialog::~MessageDialog()
|
||||||
{
|
{
|
||||||
if (m_own_listener) delete m_listener; m_listener = NULL;
|
if (m_own_listener) delete m_listener;
|
||||||
|
m_listener = NULL;
|
||||||
|
|
||||||
if (StateManager::get()->getGameState() == GUIEngine::GAME)
|
if (StateManager::get()->getGameState() == GUIEngine::GAME)
|
||||||
{
|
{
|
||||||
@ -65,27 +105,11 @@ MessageDialog::~MessageDialog()
|
|||||||
}
|
}
|
||||||
} // ~MessageDialog
|
} // ~MessageDialog
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MessageDialog::doInit(MessageDialogType type,
|
|
||||||
IConfirmDialogListener* listener, bool own_listener)
|
|
||||||
{
|
|
||||||
if (StateManager::get()->getGameState() == GUIEngine::GAME)
|
|
||||||
{
|
|
||||||
World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_type = type;
|
|
||||||
m_listener = listener;
|
|
||||||
m_own_listener = own_listener;
|
|
||||||
|
|
||||||
loadFromFile("confirm_dialog.stkgui");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessageDialog::loadedFromFile()
|
void MessageDialog::loadedFromFile()
|
||||||
{
|
{
|
||||||
LabelWidget* message = getWidget<LabelWidget>("title");
|
LabelWidget* message = getWidget<LabelWidget>("title");
|
||||||
message->setText( m_msg.c_str(), false );
|
message->setText( m_msg, false );
|
||||||
|
|
||||||
// If the dialog is a simple 'OK' dialog, then hide the "Yes" button and
|
// If the dialog is a simple 'OK' dialog, then hide the "Yes" button and
|
||||||
// change "Cancel" to "OK"
|
// change "Cancel" to "OK"
|
||||||
@ -112,13 +136,13 @@ void MessageDialog::loadedFromFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MessageDialog::onEnterPressedInternal()
|
void MessageDialog::onEnterPressedInternal()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
GUIEngine::EventPropagation MessageDialog::processEvent(const std::string& eventSource)
|
GUIEngine::EventPropagation MessageDialog::processEvent(const std::string& eventSource)
|
||||||
{
|
{
|
||||||
@ -153,7 +177,7 @@ GUIEngine::EventPropagation MessageDialog::processEvent(const std::string& event
|
|||||||
return GUIEngine::EVENT_LET;
|
return GUIEngine::EVENT_LET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void MessageDialog::onUpdate(float dt)
|
void MessageDialog::onUpdate(float dt)
|
||||||
{
|
{
|
||||||
|
@ -71,8 +71,7 @@ private:
|
|||||||
IConfirmDialogListener* m_listener;
|
IConfirmDialogListener* m_listener;
|
||||||
bool m_own_listener;
|
bool m_own_listener;
|
||||||
irr::core::stringw m_msg;
|
irr::core::stringw m_msg;
|
||||||
void doInit(MessageDialogType type, IConfirmDialogListener* listener,
|
void doInit(bool from_queue);
|
||||||
bool own_listener);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -83,7 +82,8 @@ public:
|
|||||||
* along with the dialog.
|
* along with the dialog.
|
||||||
*/
|
*/
|
||||||
MessageDialog(const irr::core::stringw &msg, MessageDialogType type,
|
MessageDialog(const irr::core::stringw &msg, MessageDialogType type,
|
||||||
IConfirmDialogListener* listener, bool delete_listener);
|
IConfirmDialogListener* listener, bool delete_listener,
|
||||||
|
bool from_queue=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variant of MessageDialog where cancelling is not possible (i.e. just shows a message box with OK)
|
* Variant of MessageDialog where cancelling is not possible (i.e. just shows a message box with OK)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user