OpenClonk
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 "network/C4Network2.h"
22 
23 bool C4AbortGameDialog::is_shown = false;
24 
25 // ---------------------------------------------------
26 // C4GameAbortDlg
27 
29  : C4GUI::ConfirmationDialog(LoadResStr("IDS_HOLD_ABORT"),
30  LoadResStr("IDS_DLG_ABORT"),
31  nullptr,
32  MessageDialog::btnYesNo,
33  true,
34  C4GUI::Ico_Exit)
35 {
36  is_shown = true; // assume dlg will be shown, soon
37 }
38 
40 {
41  is_shown = false;
42 }
43 
45 {
46  if (!::Network.isEnabled())
47  {
48  fGameHalted = true;
49  Game.HaltCount++;
50  }
51 }
52 
54 {
55  if (fGameHalted)
56  Game.HaltCount--;
57  // inherited
58  typedef C4GUI::ConfirmationDialog Base;
59  Base::OnClosed(fOK);
60  // abort
61  if (fOK)
62  Game.Abort();
63 }
C4Game Game
Definition: C4Globals.cpp:52
C4Network2 Network
Definition: C4Globals.cpp:53
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void OnClosed(bool fOK) override
~C4AbortGameDialog() override
static bool is_shown
Definition: C4GameDialogs.h:30
void OnShown() override
bool fOK
Definition: C4Gui.h:2083
void Abort(bool fApproved=false)
Definition: C4Game.cpp:4546
int32_t HaltCount
Definition: C4Game.h:112
bool isEnabled() const
Definition: C4Network2.h:203
@ Ico_Exit
Definition: C4Gui.h:677