OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GameDialogs.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2005-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 // main game dialogs (abort game dlg, observer dlg)
17 
18 #include "C4Include.h"
19 #include "gui/C4GameDialogs.h"
20 
21 #include "game/C4Game.h"
22 #include "network/C4Network2.h"
23 
24 bool C4AbortGameDialog::is_shown = false;
25 
26 // ---------------------------------------------------
27 // C4GameAbortDlg
28 
30  : C4GUI::ConfirmationDialog(LoadResStr("IDS_HOLD_ABORT"),
31  LoadResStr("IDS_DLG_ABORT"),
32  nullptr,
33  MessageDialog::btnYesNo,
34  true,
35  C4GUI::Ico_Exit),
36  fGameHalted(false)
37 {
38  is_shown = true; // assume dlg will be shown, soon
39 }
40 
42 {
43  is_shown = false;
44 }
45 
47 {
48  if (!::Network.isEnabled())
49  {
50  fGameHalted = true;
51  Game.HaltCount++;
52  }
53 }
54 
56 {
57  if (fGameHalted)
58  Game.HaltCount--;
59  // inherited
60  typedef C4GUI::ConfirmationDialog Base;
61  Base::OnClosed(fOK);
62  // abort
63  if (fOK)
64  Game.Abort();
65 }
virtual void OnClosed(bool fOK)
C4Game Game
Definition: C4Globals.cpp:52
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
static bool is_shown
Definition: C4GameDialogs.h:30
void Abort(bool fApproved=false)
Definition: C4Game.cpp:3670
virtual void OnShown()
bool isEnabled() const
Definition: C4Network2.h:203
int32_t HaltCount
Definition: C4Game.h:114