1 /* 2 * OpenClonk, http://www.openclonk.org 3 * 4 * Copyright (c) 2008-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 // game over dialog showing winners and losers 17 18 #ifndef INC_C4GameOverDlg 19 #define INC_C4GameOverDlg 20 21 #include "gui/C4Gui.h" 22 #include "control/C4RoundResults.h" 23 24 // horizontal display of goal symbols; filfilled goals marked 25 // maybe to be reused for a game goal dialog? 26 class C4GoalDisplay : public C4GUI::Window 27 { 28 private: 29 // element that draws one goal 30 class GoalPicture : public C4GUI::Window 31 { 32 private: 33 C4ID idGoal; 34 bool fFulfilled; 35 C4FacetSurface Picture; 36 37 public: 38 GoalPicture(const C4Rect &rcBounds, C4ID idGoal, bool fFulfilled); 39 40 protected: 41 void DrawElement(C4TargetFacet &cgo) override; 42 }; 43 44 public: C4GoalDisplay(const C4Rect & rcBounds)45 C4GoalDisplay(const C4Rect &rcBounds) : C4GUI::Window() { SetBounds(rcBounds); } 46 ~C4GoalDisplay() override = default; 47 48 void SetGoals(const C4IDList &rAllGoals, const C4IDList &rFulfilledGoals, int32_t iGoalSymbolHeight); 49 }; 50 51 class C4GameOverDlg : public C4GUI::Dialog, private C4ApplicationSec1Timer 52 { 53 private: 54 static bool is_shown; 55 int32_t iPlrListCount; 56 class C4PlayerInfoListBox **ppPlayerLists; 57 C4GoalDisplay *pGoalDisplay; 58 C4GUI::Label *pNetResultLabel{nullptr}; // label showing league result, disconnect, etc. 59 C4GUI::Button *pBtnExit, *pBtnContinue; 60 bool fIsNetDone{false}; // set if league is evaluated and round results arrived 61 bool fIsQuitBtnVisible; // quit button available? set if not host or when fIsNetDone 62 bool fHasNextMissionButton{false}; // continue button replaced by "next mission"-button? 63 64 private: 65 void OnExitBtn(C4GUI::Control *btn); // callback: exit button pressed 66 void OnContinueBtn(C4GUI::Control *btn); // callback: continue button pressed 67 68 void Update(); 69 void SetNetResult(const char *szResultString, C4RoundResults::NetResult eResultType, size_t iPendingStreamingData, bool fIsStreaming); 70 71 protected: 72 void OnShown() override; 73 void OnClosed(bool fOK) override; 74 OnEnter()75 bool OnEnter() override { if (fIsQuitBtnVisible) OnExitBtn(nullptr); return true; } // enter on non-button: Always quit OnEscape()76 bool OnEscape() override { if (fIsQuitBtnVisible) UserClose(false); return true; } // escape ignored if still streaming 77 78 // true for dialogs that should span the whole screen 79 // not just the mouse-viewport IsFreePlaceDialog()80 bool IsFreePlaceDialog() override { return true; } 81 82 // true for dialogs that receive full keyboard and mouse input even in shared mode IsExclusiveDialog()83 bool IsExclusiveDialog() override { return true; } 84 85 // sec1 timer OnSec1Timer()86 void OnSec1Timer() override { Update(); } 87 88 public: 89 C4GameOverDlg(); 90 ~C4GameOverDlg() override; 91 IsShown()92 static bool IsShown() { return is_shown; } 93 }; 94 95 96 #endif // INC_C4GameOverDlg 97