| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) RedWolf Design |
| 5 | * Copyright (c) 2008, Sven2 |
| 6 | * Copyright (c) 2017-2021, The LegacyClonk Team and contributors |
| 7 | * |
| 8 | * Distributed under the terms of the ISC license; see accompanying file |
| 9 | * "COPYING" for details. |
| 10 | * |
| 11 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 12 | * See accompanying file "TRADEMARK" for details. |
| 13 | * |
| 14 | * To redistribute this file separately, substitute the full license texts |
| 15 | * for the above references. |
| 16 | */ |
| 17 | |
| 18 | // game over dialog showing winners and losers |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <C4Gui.h> |
| 23 | #include <C4GuiDialogs.h> |
| 24 | #include <C4RoundResults.h> |
| 25 | |
| 26 | // horizontal display of goal symbols; filfilled goals marked |
| 27 | // maybe to be reused for a game goal dialog? |
| 28 | class C4GoalDisplay : public C4GUI::Window |
| 29 | { |
| 30 | private: |
| 31 | // element that draws one goal |
| 32 | class GoalPicture : public C4GUI::Window |
| 33 | { |
| 34 | private: |
| 35 | C4ID idGoal; |
| 36 | bool fFulfilled; |
| 37 | C4FacetExSurface Picture; |
| 38 | |
| 39 | public: |
| 40 | GoalPicture(const C4Rect &rcBounds, C4ID idGoal, bool fFulfilled); |
| 41 | |
| 42 | protected: |
| 43 | virtual void DrawElement(C4FacetEx &cgo) override; |
| 44 | }; |
| 45 | |
| 46 | public: |
| 47 | C4GoalDisplay(const C4Rect &rcBounds) : C4GUI::Window() { SetBounds(rcBounds); } |
| 48 | virtual ~C4GoalDisplay() {} |
| 49 | |
| 50 | void SetGoals(const C4IDList &rAllGoals, const C4IDList &rFulfilledGoals, int32_t iGoalSymbolHeight); |
| 51 | }; |
| 52 | |
| 53 | class C4GameOverDlg : public C4GUI::Dialog |
| 54 | { |
| 55 | private: |
| 56 | static bool is_shown; |
| 57 | C4Sec1TimerCallback<C4GameOverDlg> *pSec1Timer; // engine timer hook for player list update |
| 58 | int32_t iPlrListCount; |
| 59 | class C4PlayerInfoListBox **ppPlayerLists; |
| 60 | C4GoalDisplay *pGoalDisplay; |
| 61 | C4GUI::Label *pNetResultLabel; // label showing league result, disconnect, etc. |
| 62 | C4GUI::Button *pBtnExit, *pBtnContinue, *pBtnRestart, *pBtnNextMission; |
| 63 | bool fIsNetDone; // set if league is evaluated and round results arrived |
| 64 | bool fIsQuitBtnVisible; // quit button available? set if not host or when fIsNetDone |
| 65 | enum NextMissionMode |
| 66 | { |
| 67 | None, |
| 68 | Restart, |
| 69 | NextMission |
| 70 | }; |
| 71 | NextMissionMode nextMissionMode = None; |
| 72 | |
| 73 | private: |
| 74 | void OnExitBtn(C4GUI::Control *btn); // callback: exit button pressed |
| 75 | void OnContinueBtn(C4GUI::Control *btn); // callback: continue button pressed |
| 76 | void OnRestartBtn(C4GUI::Control *btn); // callback: restart button pressed |
| 77 | void OnNextMissionBtn(C4GUI::Control *btn); // callback: next mission button pressed |
| 78 | |
| 79 | void Update(); |
| 80 | void SetNetResult(const char *szResultString, C4RoundResults::NetResult eResultType, size_t iPendingStreamingData, bool fIsStreaming); |
| 81 | |
| 82 | protected: |
| 83 | virtual void OnShown() override; |
| 84 | virtual void OnClosed(bool fOK) override; |
| 85 | |
| 86 | virtual bool OnEnter() override; |
| 87 | virtual bool OnEscape() override { if (fIsQuitBtnVisible) UserClose(fOK: false); return true; } // escape ignored if still streaming |
| 88 | |
| 89 | // true for dialogs that should span the whole screen |
| 90 | // not just the mouse-viewport |
| 91 | virtual bool IsFreePlaceDialog() override { return true; } |
| 92 | |
| 93 | // true for dialogs that receive full keyboard and mouse input even in shared mode |
| 94 | virtual bool IsExclusiveDialog() override { return true; } |
| 95 | |
| 96 | public: |
| 97 | C4GameOverDlg(); |
| 98 | ~C4GameOverDlg(); |
| 99 | |
| 100 | static bool IsShown() { return is_shown; } |
| 101 | void OnSec1Timer() { Update(); } |
| 102 | }; |
| 103 | |