OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GraphicsResource Class Reference

#include <C4GraphicsResource.h>

Collaboration diagram for C4GraphicsResource:
[legend]

Public Member Functions

 C4GraphicsResource ()
 
 ~C4GraphicsResource ()
 
CStdFontGetFontByHeight (int32_t iHgt, float *pfZoom=nullptr)
 
void Default ()
 
void Clear ()
 
bool InitFonts ()
 
void ClearFonts ()
 
bool Init ()
 
bool IsInitialized ()
 
bool RegisterGlobalGraphics ()
 
bool RegisterMainGroups ()
 
void CloseFiles ()
 
bool ReloadResolutionDependantFiles ()
 

Public Attributes

C4GroupSet Files
 
float ProgressStart
 
float ProgressIncrement
 
C4FacetID fctPlayer
 
C4FacetID fctFlag
 
C4FacetID fctCrew
 
C4FacetID fctWealth
 
C4FacetID fctRank
 
int32_t iNumRanks
 
C4FacetID fctFire
 
C4FacetID fctBackground
 
C4FacetID fctCaptain
 
C4FacetID fctMouseCursor
 
C4FacetID fctSelectMark
 
C4FacetID fctOptions
 
C4FacetID fctMenu
 
C4FacetID fctUpperBoard
 
C4FacetID fctLogo
 
C4FacetID fctConstruction
 
C4FacetID fctEnergy
 
C4FacetID fctArrow
 
C4FacetID fctExit
 
C4FacetID fctHand
 
C4FacetID fctGamepad
 
C4FacetID fctBuild
 
C4Facet fctClonkSkin
 
C4Facet fctKeyboard
 
C4Facet fctMouse
 
C4Facet fctCommand
 
C4Facet fctKey
 
C4Facet fctOKCancel
 
C4FacetID fctTransformKnob
 
C4FacetID fctCrewClr
 
C4FacetID fctFlagClr
 
C4FacetID fctPlayerClr
 
C4GUI::DynBarFacet barCaption
 
C4GUI::DynBarFacet barButton
 
C4GUI::DynBarFacet barButtonD
 
C4FacetID fctButtonHighlight
 
C4FacetID fctButtonHighlightRound
 
C4FacetID fctIcons
 
C4FacetID fctIconsEx
 
C4FacetID fctControllerIcons
 
C4FacetID fctSubmenu
 
C4FacetID fctCheckbox
 
C4FacetID fctBigArrows
 
C4FacetID fctProgressBar
 
C4GUI::ScrollBarFacets sfctScroll
 
C4Facet fctContext
 
CStdFontCaptionFont
 
CStdFontTitleFont
 
CStdFontTextFont
 
CStdFontMiniFont
 
CStdFontTooltipFont
 
CStdFont FontTiny
 
CStdFont FontRegular
 
CStdFont FontCaption
 
CStdFont FontTitle
 
CStdFont FontTooltip
 
C4AchievementGraphics Achievements
 

Protected Member Functions

bool LoadFile (C4FacetID &fct, const char *szName, C4GroupSet &rGfxSet, int32_t iWdt, int32_t iHgt, bool fNoWarnIfNotFound, int iFlags)
 
bool LoadFile (C4Surface &sfc, const char *szName, C4GroupSet &rGfxSet, int32_t &ridCurrSfc, int iFlags)
 
bool FindLoadRes (C4Group *pSecondFile, const char *szName)
 
bool LoadCursorGfx ()
 

Protected Attributes

C4Surface sfcControl
 
C4Surface sfcClonkSkins
 
C4Surface sfcCaption
 
C4Surface sfcButton
 
C4Surface sfcButtonD
 
C4Surface sfcScroll
 
C4Surface sfcContext
 
int32_t idSfcCaption {0}
 
int32_t idSfcButton {0}
 
int32_t idSfcButtonD {0}
 
int32_t idSfcScroll {0}
 
int32_t idSfcContext {0}
 
int32_t idSfcClonkSkins
 
int32_t idSfcControl
 
int32_t idRegisteredMainGroupSetFiles
 

Friends

class C4StartupGraphics
 

Detailed Description

Definition at line 29 of file C4GraphicsResource.h.

Constructor & Destructor Documentation

C4GraphicsResource::C4GraphicsResource ( )

Definition at line 31 of file C4GraphicsResource.cpp.

References Default().

Here is the call graph for this function:

C4GraphicsResource::~C4GraphicsResource ( )

Definition at line 37 of file C4GraphicsResource.cpp.

References Clear().

38 {
39  Clear();
40 }

Here is the call graph for this function:

Member Function Documentation

void C4GraphicsResource::Clear ( )

Definition at line 90 of file C4GraphicsResource.cpp.

References Achievements, barButton, barButtonD, barCaption, C4AchievementGraphics::Clear(), C4FacetID::Clear(), C4Surface::Clear(), C4GUI::DynBarFacet::Clear(), CloseFiles(), C4Facet::Default(), fctArrow, fctBackground, fctBigArrows, fctBuild, fctButtonHighlight, fctButtonHighlightRound, fctCaptain, fctCheckbox, fctConstruction, fctContext, fctControllerIcons, fctCrew, fctCrewClr, fctEnergy, fctExit, fctFire, fctFlag, fctFlagClr, fctGamepad, fctHand, fctIcons, fctIconsEx, fctLogo, fctMenu, fctMouseCursor, fctOptions, fctPlayer, fctPlayerClr, fctProgressBar, fctRank, fctSelectMark, fctSubmenu, fctTransformKnob, fctUpperBoard, fctWealth, FontRegular, idSfcButton, idSfcButtonD, idSfcCaption, idSfcClonkSkins, idSfcContext, idSfcControl, idSfcScroll, CStdFont::SetCustomImages(), sfcButton, sfcButtonD, sfcCaption, sfcClonkSkins, sfcContext, sfcControl, and sfcScroll.

Referenced by ~C4GraphicsResource().

91 {
92  fInitialized = false;
93 
94  sfcControl.Clear();
95  idSfcControl = 0;
97  idSfcClonkSkins = 0;
98 
99  fctCrewClr.Clear();
100  fctFlagClr.Clear();
102 
103  fctPlayer.Clear();
104  fctFlag.Clear();
105  fctCrew.Clear();
106  fctWealth.Clear();
107  fctRank.Clear();
108  fctFire.Clear();
110  fctCaptain.Clear();
113  fctMenu.Clear();
115  fctLogo.Clear();
117  fctEnergy.Clear();
118  fctOptions.Clear();
119  fctArrow.Clear();
120  fctExit.Clear();
121  fctHand.Clear();
122  fctGamepad.Clear();
123  fctBuild.Clear();
125  // GUI data
132  fctSubmenu.Clear();
133  fctCheckbox.Clear();
137 
138 
139  // unhook deflist from font
140  FontRegular.SetCustomImages(nullptr);
141 
143 
144  // closing the group set will also close the graphics.ocg
145  // this is just for games that failed to init
146  // normally, this is done after successful init anyway
147  CloseFiles();
148 }
C4GUI::DynBarFacet barCaption
C4GUI::DynBarFacet barButtonD
void SetCustomImages(CustomImages *pHandler)
Definition: C4FontLoader.h:186
void Clear()
Definition: C4Surface.cpp:126
void Default()
Definition: C4Facet.cpp:31
C4FacetID fctButtonHighlightRound
C4GUI::DynBarFacet barButton
void Clear()
Definition: C4FacetEx.h:76
C4AchievementGraphics Achievements
void Clear()
Definition: C4Gui.h:355

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsResource::ClearFonts ( )

Definition at line 170 of file C4GraphicsResource.cpp.

References CStdFont::Clear(), FontCaption, FontRegular, FontTiny, FontTitle, and FontTooltip.

Referenced by C4Application::Quit().

171 {
172  FontRegular.Clear();
173  FontTitle.Clear();
174  FontCaption.Clear();
175  FontTiny.Clear();
176  FontTooltip.Clear();
177 }
void Clear()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsResource::CloseFiles ( )

Definition at line 356 of file C4GraphicsResource.cpp.

References C4GroupSet::Clear(), Files, and idRegisteredMainGroupSetFiles.

Referenced by Clear(), C4Game::InitGame(), C4Game::ReloadDef(), and ReloadResolutionDependantFiles().

357 {
358  // closes main gfx group; releases dependencies into game group set
359  Files.Clear();
361 }
void Clear()
Definition: C4GroupSet.cpp:50
int32_t idRegisteredMainGroupSetFiles

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsResource::Default ( )

Definition at line 42 of file C4GraphicsResource.cpp.

References C4FacetID::Default(), C4Surface::Default(), C4Facet::Default(), fctArrow, fctBackground, fctBuild, fctCaptain, fctClonkSkin, fctCommand, fctConstruction, fctCrew, fctCrewClr, fctEnergy, fctExit, fctFire, fctFlag, fctFlagClr, fctGamepad, fctHand, fctKey, fctKeyboard, fctLogo, fctMenu, fctMouse, fctMouseCursor, fctOKCancel, fctPlayer, fctPlayerClr, fctRank, fctSelectMark, fctTransformKnob, fctUpperBoard, fctWealth, idRegisteredMainGroupSetFiles, idSfcClonkSkins, idSfcControl, iNumRanks, sfcClonkSkins, and sfcControl.

Referenced by C4GraphicsResource().

43 {
44  fInitialized = false;
45 
47  idSfcControl = 0;
49  idSfcClonkSkins = 0;
50 
52  fctFlag.Default();
54  fctCrew.Default();
56  fctRank.Default();
57  fctFire.Default();
62  fctMenu.Default();
64  fctLogo.Default();
67  fctArrow.Default();
68  fctExit.Default();
69  fctHand.Default();
71  fctBuild.Default();
72 
76 
80  fctKey.Default();
82  fctMouse.Default();
83 
85 
86  iNumRanks=1;
88 }
void Default()
Definition: C4Surface.cpp:71
void Default()
Definition: C4Facet.cpp:31
int32_t idRegisteredMainGroupSetFiles
void Default()
Definition: C4FacetEx.h:75

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::FindLoadRes ( C4Group pSecondFile,
const char *  szName 
)
protected
CStdFont & C4GraphicsResource::GetFontByHeight ( int32_t  iHgt,
float *  pfZoom = nullptr 
)

Definition at line 425 of file C4GraphicsResource.cpp.

References CaptionFont, CStdFont::GetLineHeight(), MiniFont, TextFont, and TitleFont.

Referenced by C4MapFolderData::CreateGUIElements(), and C4GUI::FacetButton::DrawElement().

426 {
427  // get optimal font for given control size
428  CStdFont *pUseFont;
429  if (iHgt <= MiniFont.GetLineHeight()) pUseFont = &MiniFont;
430  else if (iHgt <= TextFont.GetLineHeight()) pUseFont = &TextFont;
431  else if (iHgt <= CaptionFont.GetLineHeight()) pUseFont = &CaptionFont;
432  else pUseFont = &TitleFont;
433  // determine zoom
434  if (pfZoom)
435  {
436  int32_t iLineHgt = pUseFont->GetLineHeight();
437  if (iLineHgt)
438  *pfZoom = (float) iHgt / (float) iLineHgt;
439  else
440  *pfZoom = 1.0f; // error
441  }
442  return *pUseFont;
443 }
int GetLineHeight() const
Definition: C4FontLoader.h:125

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::Init ( )

Definition at line 179 of file C4GraphicsResource.cpp.

References Achievements, barButton, barButtonD, barCaption, C4CFN_ShaderFiles, C4FCT_Full, C4FCT_Height, C4GUI_ControllerIconHgt, C4GUI_ControllerIconWdt, C4GUI_IconExHgt, C4GUI_IconExWdt, C4GUI_IconHgt, C4GUI_IconWdt, C4SF_Tileable, C4FacetSurface::CreateClrByOwner(), fctArrow, fctBackground, fctBigArrows, fctBuild, fctButtonHighlight, fctButtonHighlightRound, fctCaptain, fctCheckbox, fctClonkSkin, fctCommand, fctConstruction, fctContext, fctControllerIcons, fctCrew, fctCrewClr, fctEnergy, fctExit, fctFire, fctFlag, fctFlagClr, fctGamepad, fctHand, fctIcons, fctIconsEx, fctKey, fctKeyboard, fctLogo, fctMenu, fctMouse, fctOKCancel, fctOptions, fctPlayer, fctPlayerClr, fctProgressBar, fctRank, fctSelectMark, fctSubmenu, fctTransformKnob, fctUpperBoard, fctWealth, Files, Game, C4Facet::GetPhaseNum(), C4Surface::Hgt, C4Facet::Hgt, idSfcButton, idSfcButtonD, idSfcCaption, idSfcClonkSkins, idSfcContext, idSfcControl, idSfcScroll, C4FacetID::idSourceGroup, C4AchievementGraphics::Init(), InitFonts(), CStdGL::InitShaders(), iNumRanks, LoadCursorGfx(), LoadFile(), LoadResStr(), LogFatal(), pGL, C4GroupSet::PreCacheEntries(), ProgressIncrement, ProgressStart, RegisterGlobalGraphics(), RegisterMainGroups(), C4FacetSurface::Set(), C4Facet::Set(), C4GUI::ScrollBarFacets::Set(), C4GUI::DynBarFacet::SetHorizontal(), C4Game::SetInitProgress(), sfcButton, sfcButtonD, sfcCaption, sfcClonkSkins, sfcContext, sfcControl, sfcScroll, sfctScroll, C4Facet::Surface, and C4Facet::Wdt.

Referenced by C4Game::InitGame(), and C4Application::PreInit().

180 {
181  if (!RegisterGlobalGraphics())
182  return false;
183  // update group set
184  if (!RegisterMainGroups())
185  {
186  LogFatal(LoadResStr("IDS_ERR_GFX_REGISTERMAIN"));
187  return false;
188  }
189 
190 #ifndef USE_CONSOLE
191  // Pre-load all shader files
193  if (!pGL->InitShaders(&Files))
194  {
195  LogFatal(LoadResStr("IDS_ERR_GFX_INITSHADERS"));
196  return false;
197  }
198 #endif
199 
200  Game.SetInitProgress(11.0f);
201  ProgressStart = 12.0f; ProgressIncrement = 0.35f; // TODO: This should be changed so that it stops at 25%, no matter how many graphics we load.
202  // The progress bar is the only graphic besides the background that is
203  // used during startup, so load it early
204  if (!LoadFile(fctProgressBar, "GUIProgress", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
206 
207  if (!InitFonts()) return false;
208 
209  // load GUI files
210  if (!LoadFile(sfcCaption, "GUICaption", Files, idSfcCaption, 0)) return false;
212  if (!LoadFile(sfcButton, "GUIButton", Files, idSfcButton, 0)) return false;
214  if (!LoadFile(sfcButtonD, "GUIButtonDown", Files, idSfcButtonD, 0)) return false;
216  if (!LoadFile(fctButtonHighlight, "GUIButtonHighlight", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
217  if (!LoadFile(fctButtonHighlightRound, "GUIButtonHighlightRound", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
218  if (!LoadFile(fctIcons, "GUIIcons", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
220  if (!LoadFile(fctIconsEx, "GUIIcons2", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
222  if (!LoadFile(fctControllerIcons, "ControllerIcons", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
224  if (!LoadFile(sfcScroll, "GUIScroll", Files, idSfcScroll, 0)) return false;
225  sfctScroll.Set(C4Facet(&sfcScroll,0,0,32,32));
226  if (!LoadFile(sfcContext, "GUIContext", Files, idSfcContext, 0)) return false;
227  fctContext.Set(&sfcContext,0,0,16,16);
228  if (!LoadFile(fctSubmenu, "GUISubmenu", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
229  if (!LoadFile(fctCheckbox, "GUICheckbox", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
231  if (!LoadFile(fctBigArrows, "GUIBigArrows", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
233 
234  // Control
235  if (!LoadFile(sfcControl, "Control", Files, idSfcControl, 0)) return false;
236  fctKeyboard.Set(&sfcControl,0,0,80,36);
237  fctCommand.Set(&sfcControl,0,36,32,32);
238  fctKey.Set(&sfcControl,0,100,64,64);
239  fctOKCancel.Set(&sfcControl,128,100,32,32);
240  fctMouse.Set(&sfcControl,198,100,32,32);
241 
242  // Clonk style selection
243  if (!LoadFile(sfcClonkSkins, "ClonkSkins", Files, idSfcClonkSkins, 0)) return false;
244  fctClonkSkin.Set(&sfcClonkSkins,0,0,64,64);
245 
246  // Facet bitmap resources
247  if (!LoadFile(fctFire, "Fire", Files, C4FCT_Height, C4FCT_Full, false, 0)) return false;
248  if (!LoadFile(fctBackground, "Background", Files, C4FCT_Full, C4FCT_Full, false, C4SF_Tileable)) return false; // tileable
249  if (!LoadFile(fctFlag, "Flag", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false; // (new format)
250  if (!LoadFile(fctCrew, "Crew", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false; // (new format)
251  if (!LoadFile(fctWealth, "Wealth", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false; // (new)
252  if (!LoadFile(fctPlayer, "Player", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false; // (new format)
253  if (!LoadFile(fctRank, "Rank", Files, C4FCT_Height, C4FCT_Full, false, 0)) return false;
254  if (!LoadFile(fctCaptain, "Captain", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
255  if (!LoadCursorGfx()) return false;
256  if (!LoadFile(fctSelectMark, "SelectMark", Files, C4FCT_Height, C4FCT_Full, false, 0)) return false;
257  if (!LoadFile(fctMenu, "Menu", Files, 35, 35, false, 0)) return false;
258  if (!LoadFile(fctLogo, "Logo", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
259  if (!LoadFile(fctConstruction,"Construction", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false; // (new)
260  if (!LoadFile(fctEnergy, "Energy", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false; // (new)
261  if (!LoadFile(fctOptions, "Options", Files, C4FCT_Height, C4FCT_Full, false, 0)) return false;
262  if (!LoadFile(fctUpperBoard, "UpperBoard", Files, C4FCT_Full, C4FCT_Full, false, C4SF_Tileable)) return false; // tileable
263  if (!LoadFile(fctArrow, "Arrow", Files, C4FCT_Height, C4FCT_Full, false, 0)) return false;
264  if (!LoadFile(fctExit, "Exit", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
265  if (!LoadFile(fctHand, "Hand", Files, C4FCT_Height, C4FCT_Full, false, 0)) return false;
266  if (!LoadFile(fctGamepad, "Gamepad", Files, 80, C4FCT_Full, false, 0)) return false;
267  if (!LoadFile(fctBuild, "Build", Files, C4FCT_Full, C4FCT_Full, false, 0)) return false;
268  if (!LoadFile(fctTransformKnob,"TransformKnob",Files,C4FCT_Full, C4FCT_Full, false, 0)) return false;
269 
270  // achievements
271  if (!Achievements.Init(Files)) return false;
272 
273  // create ColorByOwner overlay surfaces
275  {
276  if (!fctCrewClr.CreateClrByOwner(fctCrew.Surface)) { LogFatal("ClrByOwner error! (1)"); return false; }
280  }
282  {
283  if (!fctFlagClr.CreateClrByOwner(fctFlag.Surface)) { LogFatal("ClrByOwner error! (1)"); return false; }
287  }
289  {
290  if (!fctPlayerClr.CreateClrByOwner(fctPlayer.Surface)) { LogFatal("ClrByOwner error! (1)"); return false; }
294  }
295 
296  // get number of ranks
297  int32_t Q; fctRank.GetPhaseNum(iNumRanks, Q);
298  if (!iNumRanks) iNumRanks=1;
299 
300  // CloseFiles() must not be called now:
301  // The sky still needs to be loaded from the global graphics
302  // group in C4Game::InitGame -> C4Sky::Init so we need to keep the group(s) open.
303  // In activated NETWORK2, the files mustn't be closed either, because there will be
304  // multiple calls to this function to allow overloadings
305 
306  // mark initialized
307  fInitialized = true;
308 
309  return true;
310 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3385
C4GUI::DynBarFacet barCaption
C4Game Game
Definition: C4Globals.cpp:52
C4GUI::DynBarFacet barButtonD
int32_t PreCacheEntries(const char *szEntryMask)
Definition: C4GroupSet.cpp:375
bool GetPhaseNum(int32_t &rX, int32_t &rY)
Definition: C4Facet.cpp:472
#define C4GUI_IconExHgt
Definition: C4Gui.h:96
#define C4GUI_IconExWdt
Definition: C4Gui.h:95
const int C4FCT_Height
Definition: C4FacetEx.h:27
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
int Hgt
Definition: C4Surface.h:65
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool LoadFile(C4FacetID &fct, const char *szName, C4GroupSet &rGfxSet, int32_t iWdt, int32_t iHgt, bool fNoWarnIfNotFound, int iFlags)
#define C4CFN_ShaderFiles
Definition: C4Components.h:183
bool Init(C4Group &File)
#define C4GUI_IconWdt
Definition: C4Gui.h:93
bool CreateClrByOwner(C4Surface *pBySurface)
Definition: C4FacetEx.cpp:67
const int C4SF_Tileable
Definition: C4Surface.h:49
#define C4GUI_IconHgt
Definition: C4Gui.h:94
C4FacetID fctButtonHighlightRound
#define C4GUI_ControllerIconWdt
Definition: C4Gui.h:97
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:227
C4GUI::DynBarFacet barButton
void Set(const C4Facet &rByFct, int32_t iPinIndex=0)
Definition: C4Gui.cpp:136
int32_t idSourceGroup
Definition: C4FacetEx.h:71
void SetHorizontal(C4Surface &rBySfc, int iHeight=0, int iBorderWidth=0)
Definition: C4Gui.cpp:119
float Hgt
Definition: C4Facet.h:118
C4AchievementGraphics Achievements
bool InitShaders(C4GroupSet *pGroups)
Definition: C4DrawGL.cpp:715
C4GUI::ScrollBarFacets sfctScroll
CStdGL * pGL
Definition: C4DrawGL.cpp:905
C4Surface * Surface
Definition: C4Facet.h:117
const int C4FCT_Full
Definition: C4FacetEx.h:26
float Wdt
Definition: C4Facet.h:118
#define C4GUI_ControllerIconHgt
Definition: C4Gui.h:98

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::InitFonts ( )

Definition at line 150 of file C4GraphicsResource.cpp.

References C4FontLoader::C4FT_Caption, C4FontLoader::C4FT_Log, C4FontLoader::C4FT_Main, C4FontLoader::C4FT_Title, C4Game::C4S, Config, Definitions, Files, C4SHead::Font, FontCaption, FontLoader, FontRegular, FontTiny, FontTitle, FontTooltip, Game, C4Config::General, C4Scenario::Head, C4FontLoader::InitFont(), ProgressIncrement, ProgressStart, C4ConfigGeneral::RXFontName, C4ConfigGeneral::RXFontSize, CStdFont::SetCustomImages(), and C4Game::SetInitProgress().

Referenced by Init(), and C4Application::SetGameFont().

151 {
152  // this regards scenario-specific fonts or overloads in Extra.ocg
153  const char *szFont;
154  if (!Game.C4S.Head.Font.empty()) szFont = Game.C4S.Head.Font.c_str(); else szFont = Config.General.RXFontName;
163  if (!::FontLoader.InitFont(&FontTooltip, szFont, C4FontLoader::C4FT_Main, Config.General.RXFontSize, &Files, false)) return false;
165  // assign def list as custom image source
167  return true;
168 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3385
C4Config Config
Definition: C4Config.cpp:833
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:74
C4ConfigGeneral General
Definition: C4Config.h:251
void SetCustomImages(CustomImages *pHandler)
Definition: C4FontLoader.h:186
char RXFontName[CFG_MaxString+1]
Definition: C4Config.h:41
C4FontLoader FontLoader
int32_t RXFontSize
Definition: C4Config.h:42
std::string Font
Definition: C4Scenario.h:66
C4DefList Definitions
Definition: C4Globals.cpp:49
C4SHead Head
Definition: C4Scenario.h:230
bool InitFont(CStdFont *Font, const char *szFontName, FontType eType, int32_t iSize, C4GroupSet *pGfxGroups, bool fDoShadow=true)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::IsInitialized ( )
inline

Definition at line 115 of file C4GraphicsResource.h.

Referenced by C4GUI::Screen::Draw(), and C4Game::InitFullscreenComponents().

115 { return fInitialized; } // return whether any gfx are loaded (so dlgs can be shown)

Here is the caller graph for this function:

bool C4GraphicsResource::LoadCursorGfx ( )
protected

Definition at line 312 of file C4GraphicsResource.cpp.

References C4FCT_Full, C4FCT_Height, fctMouseCursor, Files, and LoadFile().

Referenced by Init().

313 {
314  // Determine appropriate GFX file by screen resolution
315  const char *szCursorFilename;
316  szCursorFilename = "Cursor";
317  if (!LoadFile(fctMouseCursor, szCursorFilename, Files, C4FCT_Height, C4FCT_Full, false, 0))
318  return false;
319  return true;
320 }
const int C4FCT_Height
Definition: C4FacetEx.h:27
bool LoadFile(C4FacetID &fct, const char *szName, C4GroupSet &rGfxSet, int32_t iWdt, int32_t iHgt, bool fNoWarnIfNotFound, int iFlags)
const int C4FCT_Full
Definition: C4FacetEx.h:26

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::LoadFile ( C4FacetID fct,
const char *  szName,
C4GroupSet rGfxSet,
int32_t  iWdt,
int32_t  iHgt,
bool  fNoWarnIfNotFound,
int  iFlags 
)
protected

Definition at line 370 of file C4GraphicsResource.cpp.

References _MAX_FNAME, Game, C4FacetID::idSourceGroup, C4FacetSurface::Load(), LoadResStr(), LogF(), ProgressIncrement, ProgressStart, and C4Game::SetInitProgress().

Referenced by Init(), and LoadCursorGfx().

371 {
372  char FileName[_MAX_FNAME]; int32_t ID = 0;
373  C4Group *pGrp = FindSuitableFile(szName, rGfxSet, FileName, &ID);
374  if (!pGrp)
375  {
376  // FIXME: Use LogFatal here
377  if (!fNoWarnIfNotFound)
378  {
379  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), szName, LoadResStr("IDS_PRC_FILENOTFOUND"));
380  }
381  return false;
382  }
383  // check group
384  if (fct.idSourceGroup == ID)
385  // already up-to-date
386  return true;
387  // load
388  if (!fct.Load(*pGrp, FileName, iWdt, iHgt, false, iFlags))
389  {
390  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
391  return false;
392  }
393  fct.idSourceGroup = ID;
396  return true;
397 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3385
C4Game Game
Definition: C4Globals.cpp:52
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:78
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
#define _MAX_FNAME
int32_t idSourceGroup
Definition: C4FacetEx.h:71
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:250

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::LoadFile ( C4Surface sfc,
const char *  szName,
C4GroupSet rGfxSet,
int32_t &  ridCurrSfc,
int  iFlags 
)
protected

Definition at line 399 of file C4GraphicsResource.cpp.

References _MAX_FNAME, Game, C4Surface::Load(), LoadResStr(), LogF(), ProgressIncrement, ProgressStart, and C4Game::SetInitProgress().

400 {
401  // find
402  char FileName[_MAX_FNAME]; int32_t ID = 0;
403  C4Group *pGrp = FindSuitableFile(szName, rGfxSet, FileName, &ID);
404  if (!pGrp)
405  {
406  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), szName, LoadResStr("IDS_PRC_FILENOTFOUND"));
407  return false;
408  }
409  // check group
410  if (ID == ridCurrSfc)
411  // already up-to-date
412  return true;
413  // load
414  if (!sfc.Load(*pGrp, FileName, false, false, iFlags))
415  {
416  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
417  return false;
418  }
419  ridCurrSfc = ID;
422  return true;
423 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3385
C4Game Game
Definition: C4Globals.cpp:52
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
#define _MAX_FNAME
bool Load(C4Group &hGroup, const char *szFilename, bool fOwnPal, bool fNoErrIfNotFound, int iFlags)
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:250

Here is the call graph for this function:

bool C4GraphicsResource::RegisterGlobalGraphics ( )

Definition at line 322 of file C4GraphicsResource.cpp.

References C4CFN_Graphics, C4GSCnt_Graphics, C4GSPrio_Base, Files, FormatString(), LoadResStr(), LogFatal(), C4Reloc::Open(), C4GroupSet::RegisterGroup(), and Reloc.

Referenced by Init(), C4Game::ReloadDef(), and ReloadResolutionDependantFiles().

323 {
324  // Create main gfx group - register with fixed ID 1, to prevent unnecessary font reloading.
325  // FontLoader-initializations always check whether the font has already been initialized
326  // with the same parameters. If the game is simply reloaded in console-mode, this means
327  // that fonts are not reinitialized. This will also apply for InGame-scenario switches yet
328  // to be implemented.
329  // Bitmap fonts from other groups are always reloaded, because the group indices of the gfx
330  // group set are not reset, and will then differ for subsequent group registrations.
331  // Resetting the group index of the gfx group set at game reset would cause problems if a
332  // scenario with its own font face is being closed, and then another scenario with another,
333  // overloaded font face is opened. The group indices could match and the old font would
334  // then be kept.
335  // The cleanest alternative would be to reinit all the fonts whenever a scenario is reloaded
336  // FIXME: Test whether vector fonts from a scenario are correctly reloaded
337  auto *pMainGfxGrp = new C4Group();
338  if (!Reloc.Open(*pMainGfxGrp, C4CFN_Graphics) || !Files.RegisterGroup(*pMainGfxGrp, true, C4GSPrio_Base, C4GSCnt_Graphics, true))
339  {
340  // error
341  LogFatal(FormatString(LoadResStr("IDS_PRC_NOGFXFILE"),C4CFN_Graphics,pMainGfxGrp->GetError()).getData());
342  delete pMainGfxGrp;
343  return false;
344  }
345  return true;
346 }
bool RegisterGroup(C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true)
Definition: C4GroupSet.cpp:88
#define C4GSCnt_Graphics
Definition: C4GroupSet.h:34
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Open(C4Group &hGroup, const char *filename) const
Definition: C4Reloc.cpp:82
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:227
C4Reloc Reloc
Definition: C4Reloc.cpp:21
#define C4CFN_Graphics
Definition: C4Components.h:28
#define C4GSPrio_Base
Definition: C4GroupSet.h:23
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::RegisterMainGroups ( )

Definition at line 348 of file C4GraphicsResource.cpp.

References C4CFN_Graphics, C4GSCnt_Graphics, Files, Game, C4GroupSet::GetLastID(), C4Game::GroupSet, idRegisteredMainGroupSetFiles, and C4GroupSet::RegisterGroups().

Referenced by Init(), C4Game::ReloadDef(), and ReloadResolutionDependantFiles().

349 {
350  // register main groups
353  return true;
354 }
C4Game Game
Definition: C4Globals.cpp:52
C4GroupSet GroupSet
Definition: C4Game.h:87
bool RegisterGroups(const C4GroupSet &rCopy, int32_t Contents, const char *szFilename=nullptr, int32_t iMaxSkipID=0)
Definition: C4GroupSet.cpp:128
#define C4GSCnt_Graphics
Definition: C4GroupSet.h:34
int32_t GetLastID()
Definition: C4GroupSet.h:105
#define C4CFN_Graphics
Definition: C4Components.h:28
int32_t idRegisteredMainGroupSetFiles

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::ReloadResolutionDependantFiles ( )

Definition at line 445 of file C4GraphicsResource.cpp.

References CloseFiles(), fctMouseCursor, idRegisteredMainGroupSetFiles, C4FacetID::idSourceGroup, RegisterGlobalGraphics(), and RegisterMainGroups().

Referenced by C4Game::OnResolutionChanged().

446 {
447  if(!fInitialized) return false;
448  // reload any files that depend on the current resolution
449  // reloads the cursor
450 
451  // Re-open the graphics files if they are not open anymore -- this
452  // happens when the game is running.
453  // Note also that at the moment there are no resolution dependent
454  // graphics files...
455  const bool hadGroupsRegistered = (idRegisteredMainGroupSetFiles != -1);
456  if(!hadGroupsRegistered)
457  {
460  }
461 
463  const bool result = true;
464 
465  if(!hadGroupsRegistered)
466  CloseFiles();
467 
468  return result;
469 }
int32_t idSourceGroup
Definition: C4FacetEx.h:71
int32_t idRegisteredMainGroupSetFiles

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4StartupGraphics
friend

Definition at line 129 of file C4GraphicsResource.h.

Member Data Documentation

C4AchievementGraphics C4GraphicsResource::Achievements
C4GUI::DynBarFacet C4GraphicsResource::barButton

Definition at line 81 of file C4GraphicsResource.h.

Referenced by Clear(), C4GUI::Button::DrawElement(), and Init().

C4GUI::DynBarFacet C4GraphicsResource::barButtonD

Definition at line 81 of file C4GraphicsResource.h.

Referenced by Clear(), C4GUI::Button::DrawElement(), and Init().

C4GUI::DynBarFacet C4GraphicsResource::barCaption

Definition at line 81 of file C4GraphicsResource.h.

Referenced by Clear(), C4GUI::WoodenLabel::DrawElement(), and Init().

C4FacetID C4GraphicsResource::fctArrow

Definition at line 65 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctBackground
C4FacetID C4GraphicsResource::fctBuild

Definition at line 69 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctButtonHighlight
C4FacetID C4GraphicsResource::fctCaptain
C4FacetID C4GraphicsResource::fctCheckbox

Definition at line 87 of file C4GraphicsResource.h.

Referenced by Clear(), C4GUI::CheckBox::DrawElement(), and Init().

C4Facet C4GraphicsResource::fctClonkSkin
C4Facet C4GraphicsResource::fctCommand

Definition at line 73 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

C4FacetID C4GraphicsResource::fctConstruction

Definition at line 63 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), C4Object::DrawTopFace(), and Init().

C4Facet C4GraphicsResource::fctContext
C4FacetID C4GraphicsResource::fctControllerIcons

Definition at line 85 of file C4GraphicsResource.h.

Referenced by Clear(), C4GUI::Icon::GetIconFacet(), and Init().

C4FacetID C4GraphicsResource::fctCrew

Definition at line 50 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctCrewClr
C4FacetID C4GraphicsResource::fctEnergy

Definition at line 64 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctExit

Definition at line 66 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctFire

Definition at line 54 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctFlag

Definition at line 49 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctFlagClr
C4FacetID C4GraphicsResource::fctGamepad
C4FacetID C4GraphicsResource::fctHand

Definition at line 67 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctIcons
C4FacetID C4GraphicsResource::fctIconsEx

Definition at line 84 of file C4GraphicsResource.h.

Referenced by Clear(), C4GUI::Icon::GetIconFacet(), and Init().

C4Facet C4GraphicsResource::fctKey

Definition at line 74 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

C4FacetID C4GraphicsResource::fctLogo

Definition at line 62 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), C4UpperBoard::Draw(), and Init().

C4FacetID C4GraphicsResource::fctMenu

Definition at line 60 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), C4Player::DrawHostility(), and Init().

C4Facet C4GraphicsResource::fctMouse

Definition at line 72 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

C4FacetID C4GraphicsResource::fctMouseCursor
C4Facet C4GraphicsResource::fctOKCancel

Definition at line 75 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

C4FacetID C4GraphicsResource::fctOptions

Definition at line 59 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

C4FacetID C4GraphicsResource::fctPlayer

Definition at line 48 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctProgressBar
C4FacetID C4GraphicsResource::fctRank

Definition at line 52 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), C4GraphicsOverlay::DrawRankSymbol(), and Init().

C4FacetID C4GraphicsResource::fctSelectMark

Definition at line 58 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4FacetID C4GraphicsResource::fctSubmenu
C4FacetID C4GraphicsResource::fctUpperBoard
C4FacetID C4GraphicsResource::fctWealth

Definition at line 51 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), C4Menu::DrawElement(), and Init().

CStdFont C4GraphicsResource::FontCaption

Definition at line 101 of file C4GraphicsResource.h.

Referenced by ClearFonts(), C4ScriptGuiWindow::Draw(), and InitFonts().

CStdFont C4GraphicsResource::FontTiny

Definition at line 99 of file C4GraphicsResource.h.

Referenced by ClearFonts(), C4LoaderScreen::Draw(), and InitFonts().

CStdFont C4GraphicsResource::FontTitle

Definition at line 102 of file C4GraphicsResource.h.

Referenced by ClearFonts(), C4LoaderScreen::Draw(), and InitFonts().

CStdFont C4GraphicsResource::FontTooltip

Definition at line 103 of file C4GraphicsResource.h.

Referenced by ClearFonts(), and InitFonts().

int32_t C4GraphicsResource::idRegisteredMainGroupSetFiles
protected
int32_t C4GraphicsResource::idSfcButton {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

int32_t C4GraphicsResource::idSfcButtonD {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

int32_t C4GraphicsResource::idSfcCaption {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

int32_t C4GraphicsResource::idSfcClonkSkins
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

int32_t C4GraphicsResource::idSfcContext {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

int32_t C4GraphicsResource::idSfcControl
protected

Definition at line 41 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

int32_t C4GraphicsResource::idSfcScroll {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

int32_t C4GraphicsResource::iNumRanks

Definition at line 53 of file C4GraphicsResource.h.

Referenced by Default(), C4GraphicsOverlay::DrawRankSymbol(), and Init().

CStdFont& C4GraphicsResource::MiniFont

Definition at line 97 of file C4GraphicsResource.h.

Referenced by C4Chart::DrawElement(), and GetFontByHeight().

float C4GraphicsResource::ProgressIncrement

Definition at line 47 of file C4GraphicsResource.h.

Referenced by C4StartupGraphics::Init(), Init(), InitFonts(), and LoadFile().

float C4GraphicsResource::ProgressStart

Definition at line 47 of file C4GraphicsResource.h.

Referenced by C4StartupGraphics::Init(), Init(), InitFonts(), and LoadFile().

C4Surface C4GraphicsResource::sfcButton
protected

Definition at line 38 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

C4Surface C4GraphicsResource::sfcButtonD
protected

Definition at line 38 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

C4Surface C4GraphicsResource::sfcCaption
protected

Definition at line 38 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

C4Surface C4GraphicsResource::sfcClonkSkins
protected

Definition at line 37 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4Surface C4GraphicsResource::sfcContext
protected

Definition at line 39 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

C4Surface C4GraphicsResource::sfcControl
protected

Definition at line 37 of file C4GraphicsResource.h.

Referenced by Clear(), Default(), and Init().

C4Surface C4GraphicsResource::sfcScroll
protected

Definition at line 39 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

C4GUI::ScrollBarFacets C4GraphicsResource::sfctScroll

Definition at line 90 of file C4GraphicsResource.h.

Referenced by C4GUI::ScrollBar::DrawElement(), and Init().

CStdFont& C4GraphicsResource::TextFont

Definition at line 96 of file C4GraphicsResource.h.

Referenced by C4GUI::InfoDialog::AddLine(), C4ChatControl::C4ChatControl(), C4DownloadDlg::C4DownloadDlg(), C4GameOverDlg::C4GameOverDlg(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4FileSelDlg::DefaultListItem::DefaultListItem(), C4GUI::Tabular::Sheet::DrawCaption(), C4StartupMainDlg::DrawElement(), C4GUI::ProgressBar::DrawElement(), C4GUI::Button::DrawElement(), C4GUI::IconButton::DrawElement(), C4GUI::CheckBox::DrawElement(), C4GUI::ContextMenu::Entry::DrawElement(), C4GUI::ComboBox::DrawElement(), C4GUI::Edit::Edit(), C4GUI::ContextMenu::Entry::Entry(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::Tabular::Sheet::GetCaptionSize(), C4GUI::LabeledEdit::GetControlSize(), C4GUI::Edit::GetDefaultEditHeight(), C4GUI::WoodenLabel::GetDefaultHeight(), C4GUI::ComboBox::GetDefaultHeight(), C4GUI::Dialog::GetDefaultTitleHeight(), GetFontByHeight(), C4GUI::CheckBox::GetStandardCheckBoxSize(), C4GUI::InfoDialog::InfoDialog(), C4FileSelDlg::InitElements(), C4GUI::InputDialog::InputDialog(), IsSmallInputQuery(), C4GUI::Label::Label(), C4GUI::LabeledEdit::LabeledEdit(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), C4ChatControl::ChatSheet::NickItem::NickItem(), C4GameLobby::MainDlg::OnError(), C4GameLobby::MainDlg::OnLog(), C4GameLobby::MainDlg::OnMessage(), C4GUI::ProgressDialog::ProgressDialog(), C4GUI::Dialog::SetTitle(), C4FileSelDlg::UpdateSelection(), C4ChatControl::UpdateSize(), and C4GUI::Dialog::UpdateSize().

CStdFont& C4GraphicsResource::TooltipFont

Definition at line 98 of file C4GraphicsResource.h.

Referenced by C4GUI::Screen::DrawToolTip().


The documentation for this class was generated from the following files: