OpenClonk
C4Startup.h
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 // Startup screen for non-parameterized engine start
17 
18 #ifndef INC_C4Startup
19 #define INC_C4Startup
20 
21 #include "gui/C4Gui.h"
22 
23 #define C4CFN_StartupBackgroundMain "StartupMainMenuBG"
24 
25 // special colors for startup designs
26 const int32_t
27  C4StartupFontClr = 0xff000000,
29  C4StartupEditBGColor = 0x00000000,
31  C4StartupBtnFontClr = 0xff202020,
34 
35 // Titles in StartupAboutTitles
36 enum
37 {
45 };
46 
47 // graphics needed only by startup
49 {
50 private:
51  bool LoadFile(C4FacetID &rToFct, const char *szFilename);
52 
53 public:
54  // backgrounds
55  C4FacetID fctPlrPropBG; // for player property subpage
56  C4FacetID fctAboutTitles; // for about screen
58 
60 
61  // big buttons used in main menu
64 
65  // scroll bars in book
68 
69  // color preview
70  C4FacetID fctCrew, fctCrewClr; // ColorByOwner-surface of fctCrew
71 
72  // scenario selection: Scenario and folder icons
74  // scenario selection: Title overlay
76  // scenario selection and player selection book fonts
78 
79  // context button for combo boxes on white
81 
82  // options dlg gfx
84 
85  // net dlg gfx
87 
88  bool Init();
89  bool InitFonts();
90 
91  CStdFont &GetBlackFontByHeight(int32_t iHgt, float *pfZoom); // get optimal font for given control size
92 };
93 
94 // base class for all startup dialogs
96 {
97 public:
98  C4StartupDlg(const char *szTitle) : C4GUI::FullscreenDialog(szTitle, nullptr) {}
99 
100  virtual bool SetSubscreen(const char *szToScreen) { return false; } // go to specified subdialog, e.g. a specific property sheet in the options dlg
101  virtual void OnKeyboardLayoutChanged() {}
102  virtual void OnLeagueOptionChanged() {}
103 };
104 
106 {
107 public:
108  C4Startup();
109  ~C4Startup();
110 
111 public:
113 
114  enum DialogID { SDID_Main=0, SDID_ScenSel, SDID_ScenSelNetwork, SDID_NetJoin, SDID_Options, SDID_About, SDID_PlrSel, SDID_Back };
115 
116 private:
117  bool fInStartup{false}, fLastDlgWasBack;
118  static C4Startup *pInstance; // singleton instance
119  static DialogID eLastDlgID;
120  static StdCopyStrBuf sSubDialog; // subdialog to go into (e.g.: property sheet in options dialog)
121 
122  C4StartupDlg *pLastDlg{nullptr}, *pCurrDlg{nullptr}; // startup dlg that is currently shown, and dialog that was last shown
123 
124 protected:
125  void DoStartup(); // create main dlg
126  void DontStartup(); // close main dlg
127  class C4StartupDlg *SwitchDialog(DialogID eToDlg, bool fFade=true, const char *szSubDialog=nullptr); // do transition to another dialog
128 
129  friend class C4StartupMainDlg;
130  friend class C4StartupNetDlg;
131  friend class C4StartupScenSelDlg;
132  friend class C4StartupOptionsDlg;
133  friend class C4StartupAboutDlg;
134  friend class C4StartupPlrSelDlg;
135 
136 public:
137  static C4Startup *EnsureLoaded(); // create and load startup data if not done yet
138  static void Unload(); // make sure startup data is destroyed
139  static void InitStartup();
140  static void CloseStartup();
141  static bool SetStartScreen(const char *szScreen); // set screen that is shown first by case insensitive identifier
143  void OnLeagueOptionChanged(); // callback from network options dialogue: Updates settings in scenario selction
144 
145  static C4Startup *Get() { assert(pInstance); return pInstance; }
146 
147 };
148 
149 #endif // INC_C4Startup
C4FacetID fctStartupLogo
Definition: C4Startup.h:59
CStdFont BookFontTitle
Definition: C4Startup.h:77
C4GUI::DynBarFacet barMainButtonsDown
Definition: C4Startup.h:63
const int32_t C4StartupBtnFontClr
Definition: C4Startup.h:31
C4FacetID fctDlgPaper
Definition: C4Startup.h:57
C4GUI::ScrollBarFacets sfctBookScrollB
Definition: C4Startup.h:67
C4FacetID fctScenSelTitleOverlay
Definition: C4Startup.h:75
C4FacetID fctPlrPropBG
Definition: C4Startup.h:55
virtual void OnKeyboardLayoutChanged()
Definition: C4Startup.h:101
const int32_t C4StartupEditBorderColor
Definition: C4Startup.h:30
const int32_t C4StartupFontClrDisabled
Definition: C4Startup.h:28
const int32_t C4StartupBtnBorderColor2
Definition: C4Startup.h:33
const int32_t C4StartupFontClr
Definition: C4Startup.h:27
C4FacetID fctScenSelIcons
Definition: C4Startup.h:73
C4GUI::ScrollBarFacets sfctBookScrollG
Definition: C4Startup.h:67
CStdFont BookSmallFont
Definition: C4Startup.h:77
C4GUI::ScrollBarFacets sfctBookScrollR
Definition: C4Startup.h:67
C4FacetID fctOptionsIcons
Definition: C4Startup.h:83
C4FacetID fctMainButtonsDown
Definition: C4Startup.h:62
C4GUI::ScrollBarFacets sfctBookScroll
Definition: C4Startup.h:67
CStdFont BookFont
Definition: C4Startup.h:77
C4FacetID fctBookScroll
Definition: C4Startup.h:66
C4StartupDlg(const char *szTitle)
Definition: C4Startup.h:98
const int32_t C4StartupEditBGColor
Definition: C4Startup.h:29
const int32_t C4StartupBtnBorderColor1
Definition: C4Startup.h:32
virtual void OnLeagueOptionChanged()
Definition: C4Startup.h:102
C4FacetID fctContext
Definition: C4Startup.h:80
static C4Startup * Get()
Definition: C4Startup.h:145
CStdFont & GetBlackFontByHeight(int32_t iHgt, float *pfZoom)
Definition: C4Startup.cpp:96
C4FacetID fctCrew
Definition: C4Startup.h:70
C4FacetID fctNetGetRef
Definition: C4Startup.h:86
CStdFont BookFontCapt
Definition: C4Startup.h:77
C4FacetID fctOptionsTabClip
Definition: C4Startup.h:83
C4FacetID fctCrewClr
Definition: C4Startup.h:70
C4GUI::DynBarFacet barMainButtons
Definition: C4Startup.h:63
C4StartupGraphics Graphics
Definition: C4Startup.h:112
C4FacetID fctAboutTitles
Definition: C4Startup.h:56
C4FacetID fctMainButtons
Definition: C4Startup.h:62
virtual bool SetSubscreen(const char *szToScreen)
Definition: C4Startup.h:100