openclonk/src/gui/C4GameDialogs.cpp

64 lines
1.5 KiB
C++
Raw Permalink Normal View History

2009-05-08 13:28:41 +00:00
/*
* OpenClonk, http://www.openclonk.org
*
* Copyright (c) 2005-2009, RedWolf Design GmbH, http://www.clonk.de/
2016-04-03 18:18:29 +00:00
* Copyright (c) 2009-2016, The OpenClonk Team and contributors
2009-05-08 13:28:41 +00:00
*
* Distributed under the terms of the ISC license; see accompanying file
* "COPYING" for details.
2009-05-08 13:28:41 +00:00
*
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
* See accompanying file "TRADEMARK" for details.
2009-05-08 13:28:41 +00:00
*
* To redistribute this file separately, substitute the full license texts
* for the above references.
2009-05-08 13:28:41 +00:00
*/
// main game dialogs (abort game dlg, observer dlg)
#include "C4Include.h"
#include "gui/C4GameDialogs.h"
2009-05-08 13:28:41 +00:00
#include "network/C4Network2.h"
2009-05-08 13:28:41 +00:00
bool C4AbortGameDialog::is_shown = false;
// ---------------------------------------------------
// C4GameAbortDlg
C4AbortGameDialog::C4AbortGameDialog()
2010-03-28 18:58:01 +00:00
: C4GUI::ConfirmationDialog(LoadResStr("IDS_HOLD_ABORT"),
LoadResStr("IDS_DLG_ABORT"),
nullptr,
2010-03-28 18:58:01 +00:00
MessageDialog::btnYesNo,
true,
C4GUI::Ico_Exit)
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
is_shown = true; // assume dlg will be shown, soon
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
C4AbortGameDialog::~C4AbortGameDialog()
2010-03-28 18:58:01 +00:00
{
2009-05-08 13:28:41 +00:00
is_shown = false;
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4AbortGameDialog::OnShown()
2010-03-28 18:58:01 +00:00
{
if (!::Network.isEnabled())
2009-05-08 13:28:41 +00:00
{
fGameHalted = true;
Game.HaltCount++;
}
2010-03-28 18:58:01 +00:00
}
2009-05-08 13:28:41 +00:00
void C4AbortGameDialog::OnClosed(bool fOK)
2010-03-28 18:58:01 +00:00
{
if (fGameHalted)
2009-05-08 13:28:41 +00:00
Game.HaltCount--;
// inherited
typedef C4GUI::ConfirmationDialog Base;
Base::OnClosed(fOK);
// abort
2010-03-28 18:58:01 +00:00
if (fOK)
2009-05-08 13:28:41 +00:00
Game.Abort();
2010-03-28 18:58:01 +00:00
}