1/*
2 * LegacyClonk
3 *
4 * Copyright (c) RedWolf Design
5 * Copyright (c) 2005, Sven2
6 * Copyright (c) 2017-2019, 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// Startup screen for non-parameterized engine start
19
20#pragma once
21
22#include "C4Gui.h"
23#include "C4GuiDialogs.h"
24
25#define C4CFN_StartupBackgroundMain "LoaderGoldmine1"
26
27// special colors for startup designs
28const int32_t C4StartupFontClr = 0xff000000,
29 C4StartupFontClrDisabled = 0xff7f7f7f,
30 C4StartupEditBGColor = 0xff000000,
31 C4StartupEditBorderColor = 0x00a4947a,
32 C4StartupBtnFontClr = 0xff202020,
33 C4StartupBtnBorderColor1 = 0x00ccc3b4,
34 C4StartupBtnBorderColor2 = 0x0094846a;
35
36// graphics needed only by startup
37class C4StartupGraphics
38{
39private:
40 bool LoadFile(C4FacetExID &rToFct, const char *szFilename);
41
42public:
43 // backgrounds
44 C4FacetExID fctScenSelBG; // for scenario selection screen
45 C4FacetExID fctPlrSelBG; // for player selection screen
46 C4FacetExID fctPlrPropBG; // for player property subpage
47 C4FacetExID fctNetBG; // for network screen
48 C4FacetExID fctAboutBG; // for about screen
49
50 // big buttons used in main menu
51 C4FacetExID fctMainButtons, fctMainButtonsDown;
52 C4GUI::DynBarFacet barMainButtons, barMainButtonsDown;
53
54 // scroll bars in book
55 C4FacetExID fctBookScroll;
56 C4GUI::ScrollBarFacets sfctBookScroll, sfctBookScrollR, sfctBookScrollG, sfctBookScrollB;
57
58 // color preview
59 C4FacetExID fctCrew, fctCrewClr; // ColorByOwner-surface of fctCrew
60
61 // scenario selection: Scenario and folder icons
62 C4FacetExID fctScenSelIcons;
63 // scenario selection: Title overlay
64 C4FacetExID fctScenSelTitleOverlay;
65 // scenario selection and player selection book fonts
66 CStdFont BookFontCapt, BookFont, BookFontTitle, BookSmallFont;
67
68 // context button for combo boxes on white
69 C4FacetExID fctContext;
70
71 // player selection: player property control type buttons
72 C4FacetExID fctPlrCtrlType;
73
74 // options dlg gfx
75 C4FacetExID fctOptionsDlgPaper, fctOptionsIcons, fctOptionsTabClip;
76
77 // net dlg gfx
78 C4FacetExID fctNetGetRef;
79
80 bool Init();
81 bool InitFonts();
82
83 CStdFont &GetBlackFontByHeight(int32_t iHgt, float *pfZoom); // get optimal font for given control size
84};
85
86// base class for all startup dialogs
87class C4StartupDlg : public C4GUI::FullscreenDialog
88{
89public:
90 C4StartupDlg(const char *szTitle) : C4GUI::FullscreenDialog(szTitle, nullptr) {}
91};
92
93class C4Startup
94{
95public:
96 C4Startup();
97 ~C4Startup();
98
99public:
100 C4StartupGraphics Graphics;
101
102 enum DialogID { SDID_Main = 0, SDID_ScenSel, SDID_ScenSelNetwork, SDID_NetJoin, SDID_Options, SDID_About, SDID_PlrSel, SDID_Back };
103
104private:
105 bool fInStartup, fAborted, fLastDlgWasBack;
106 static C4Startup *pInstance; // singleton instance
107 static DialogID eLastDlgID;
108
109 C4StartupDlg *pLastDlg, *pCurrDlg; // startup dlg that is currently shown, and dialog that was last shown
110
111protected:
112 // break modal loop and...
113 void Start(); // ...start game
114 void Exit(); // ...quit to system
115
116 bool DoStartup(); // run main dlg
117 class C4StartupDlg *SwitchDialog(DialogID eToDlg, bool fFade = true); // do transition to another dialog
118
119 friend class C4StartupMainDlg;
120 friend class C4StartupNetDlg;
121 friend class C4StartupScenSelDlg;
122 friend class C4StartupOptionsDlg;
123 friend class C4StartupAboutDlg;
124 friend class C4StartupPlrSelDlg;
125
126public:
127 static C4Startup *EnsureLoaded(); // create and load startup data if not done yet
128 static void Unload(); // make sure startup data is destroyed
129 static bool Execute(); // run startup - return false if game is to be closed
130 static bool SetStartScreen(const char *szScreen); // set screen that is shown first by case insensitive identifier
131
132 static C4Startup *Get() { assert(pInstance); return pInstance; }
133};
134