OpenClonk
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::C4GraphicsResource ( )

Definition at line 31 of file C4GraphicsResource.cpp.

References Default().

Here is the call graph for this function:

◆ ~C4GraphicsResource()

C4GraphicsResource::~C4GraphicsResource ( )

Definition at line 37 of file C4GraphicsResource.cpp.

38 {
39  Clear();
40 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void C4GraphicsResource::Clear ( )

Definition at line 90 of file C4GraphicsResource.cpp.

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 }
void Default()
Definition: C4Facet.cpp:31
void Clear()
Definition: C4FacetEx.h:76
C4AchievementGraphics Achievements
C4GUI::DynBarFacet barButton
C4FacetID fctButtonHighlightRound
C4GUI::DynBarFacet barButtonD
C4GUI::DynBarFacet barCaption
void Clear()
Definition: C4Surface.cpp:126
void SetCustomImages(CustomImages *pHandler)
Definition: C4FontLoader.h:186
void Clear()
Definition: C4Gui.h:355

References Achievements, barButton, barButtonD, barCaption, C4FacetID::Clear(), C4Surface::Clear(), C4GUI::DynBarFacet::Clear(), C4AchievementGraphics::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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearFonts()

void C4GraphicsResource::ClearFonts ( )

Definition at line 170 of file C4GraphicsResource.cpp.

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

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

Referenced by C4Application::Quit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseFiles()

void C4GraphicsResource::CloseFiles ( )

Definition at line 356 of file C4GraphicsResource.cpp.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Default()

void C4GraphicsResource::Default ( )

Definition at line 42 of file C4GraphicsResource.cpp.

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: C4FacetEx.h:75
void Default()
Definition: C4Surface.cpp:71

References C4Facet::Default(), C4FacetID::Default(), C4Surface::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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindLoadRes()

bool C4GraphicsResource::FindLoadRes ( C4Group pSecondFile,
const char *  szName 
)
protected

◆ GetFontByHeight()

CStdFont & C4GraphicsResource::GetFontByHeight ( int32_t  iHgt,
float *  pfZoom = nullptr 
)

Definition at line 425 of file C4GraphicsResource.cpp.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

bool C4GraphicsResource::Init ( )

Definition at line 179 of file C4GraphicsResource.cpp.

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 }
#define C4CFN_ShaderFiles
Definition: C4Components.h:183
CStdGL * pGL
Definition: C4DrawGL.cpp:907
const int C4FCT_Full
Definition: C4FacetEx.h:26
const int C4FCT_Height
Definition: C4FacetEx.h:27
C4Game Game
Definition: C4Globals.cpp:52
#define C4GUI_IconHgt
Definition: C4Gui.h:94
#define C4GUI_ControllerIconHgt
Definition: C4Gui.h:98
#define C4GUI_ControllerIconWdt
Definition: C4Gui.h:97
#define C4GUI_IconExHgt
Definition: C4Gui.h:96
#define C4GUI_IconWdt
Definition: C4Gui.h:93
#define C4GUI_IconExWdt
Definition: C4Gui.h:95
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:239
const int C4SF_Tileable
Definition: C4Surface.h:49
bool Init(C4Group &File)
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
C4Surface * Surface
Definition: C4Facet.h:117
float Hgt
Definition: C4Facet.h:118
float Wdt
Definition: C4Facet.h:118
bool GetPhaseNum(int32_t &rX, int32_t &rY)
Definition: C4Facet.cpp:472
int32_t idSourceGroup
Definition: C4FacetEx.h:71
bool CreateClrByOwner(C4Surface *pBySurface)
Definition: C4FacetEx.cpp:73
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
void SetInitProgress(float to_progress)
Definition: C4Game.cpp:4207
bool LoadFile(C4FacetID &fct, const char *szName, C4GroupSet &rGfxSet, int32_t iWdt, int32_t iHgt, bool fNoWarnIfNotFound, int iFlags)
C4GUI::ScrollBarFacets sfctScroll
int32_t PreCacheEntries(const char *szEntryMask)
Definition: C4GroupSet.cpp:375
int Hgt
Definition: C4Surface.h:65
bool InitShaders(C4GroupSet *pGroups)
Definition: C4DrawGL.cpp:714
void SetHorizontal(C4Surface &rBySfc, int iHeight=0, int iBorderWidth=0)
Definition: C4Gui.cpp:119
void Set(const C4Facet &rByFct, int32_t iPinIndex=0)
Definition: C4Gui.cpp:136

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(), C4Facet::Hgt, C4Surface::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(), C4Facet::Set(), C4FacetSurface::Set(), C4GUI::ScrollBarFacets::Set(), C4GUI::DynBarFacet::SetHorizontal(), C4Game::SetInitProgress(), sfcButton, sfcButtonD, sfcCaption, sfcClonkSkins, sfcContext, sfcControl, sfcScroll, sfctScroll, C4Facet::Surface, and C4Facet::Wdt.

Referenced by C4Application::PreInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitFonts()

bool C4GraphicsResource::InitFonts ( )

Definition at line 150 of file C4GraphicsResource.cpp.

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 }
C4Config Config
Definition: C4Config.cpp:930
C4FontLoader FontLoader
C4DefList Definitions
Definition: C4Globals.cpp:49
char RXFontName[CFG_MaxString+1]
Definition: C4Config.h:42
int32_t RXFontSize
Definition: C4Config.h:43
C4ConfigGeneral General
Definition: C4Config.h:255
bool InitFont(CStdFont *Font, const char *szFontName, FontType eType, int32_t iSize, C4GroupSet *pGfxGroups, bool fDoShadow=true)
C4Scenario C4S
Definition: C4Game.h:74
std::string Font
Definition: C4Scenario.h:66
C4SHead Head
Definition: C4Scenario.h:232

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsInitialized()

bool C4GraphicsResource::IsInitialized ( )
inline

Definition at line 115 of file C4GraphicsResource.h.

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

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

Here is the caller graph for this function:

◆ LoadCursorGfx()

bool C4GraphicsResource::LoadCursorGfx ( )
protected

Definition at line 312 of file C4GraphicsResource.cpp.

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 }

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

Referenced by Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFile() [1/2]

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.

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 }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
#define _MAX_FNAME
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:84

References _MAX_FNAME.

Referenced by Init(), and LoadCursorGfx().

Here is the caller graph for this function:

◆ LoadFile() [2/2]

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

Definition at line 399 of file C4GraphicsResource.cpp.

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 }
bool Load(C4Group &hGroup, const char *szFilename, bool fOwnPal, bool fNoErrIfNotFound, int iFlags)

References _MAX_FNAME.

◆ RegisterGlobalGraphics()

bool C4GraphicsResource::RegisterGlobalGraphics ( )

Definition at line 322 of file C4GraphicsResource.cpp.

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 }
#define C4CFN_Graphics
Definition: C4Components.h:28
#define C4GSPrio_Base
Definition: C4GroupSet.h:23
#define C4GSCnt_Graphics
Definition: C4GroupSet.h:34
C4Reloc Reloc
Definition: C4Reloc.cpp:21
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
bool RegisterGroup(C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true)
Definition: C4GroupSet.cpp:88
bool Open(C4Group &group, const char *filename) const
Definition: C4Reloc.cpp:156
const char * getData() const
Definition: StdBuf.h:442

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterMainGroups()

bool C4GraphicsResource::RegisterMainGroups ( )

Definition at line 348 of file C4GraphicsResource.cpp.

349 {
350  // register main groups
353  return true;
354 }
C4GroupSet GroupSet
Definition: C4Game.h:87
int32_t GetLastID()
Definition: C4GroupSet.h:105
bool RegisterGroups(const C4GroupSet &rCopy, int32_t Contents, const char *szFilename=nullptr, int32_t iMaxSkipID=0)
Definition: C4GroupSet.cpp:128

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReloadResolutionDependantFiles()

bool C4GraphicsResource::ReloadResolutionDependantFiles ( )

Definition at line 445 of file C4GraphicsResource.cpp.

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 }

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

Referenced by C4Game::OnResolutionChanged().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ C4StartupGraphics

friend class C4StartupGraphics
friend

Definition at line 129 of file C4GraphicsResource.h.

Member Data Documentation

◆ Achievements

C4AchievementGraphics C4GraphicsResource::Achievements

◆ barButton

C4GUI::DynBarFacet C4GraphicsResource::barButton

Definition at line 81 of file C4GraphicsResource.h.

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

◆ barButtonD

C4GUI::DynBarFacet C4GraphicsResource::barButtonD

Definition at line 81 of file C4GraphicsResource.h.

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

◆ barCaption

C4GUI::DynBarFacet C4GraphicsResource::barCaption

Definition at line 81 of file C4GraphicsResource.h.

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

◆ CaptionFont

◆ fctArrow

C4FacetID C4GraphicsResource::fctArrow

Definition at line 65 of file C4GraphicsResource.h.

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

◆ fctBackground

C4FacetID C4GraphicsResource::fctBackground

◆ fctBigArrows

◆ fctBuild

C4FacetID C4GraphicsResource::fctBuild

Definition at line 69 of file C4GraphicsResource.h.

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

◆ fctButtonHighlight

C4FacetID C4GraphicsResource::fctButtonHighlight

◆ fctButtonHighlightRound

◆ fctCaptain

C4FacetID C4GraphicsResource::fctCaptain

◆ fctCheckbox

C4FacetID C4GraphicsResource::fctCheckbox

Definition at line 87 of file C4GraphicsResource.h.

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

◆ fctClonkSkin

C4Facet C4GraphicsResource::fctClonkSkin

◆ fctCommand

C4Facet C4GraphicsResource::fctCommand

Definition at line 73 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

◆ fctConstruction

C4FacetID C4GraphicsResource::fctConstruction

Definition at line 63 of file C4GraphicsResource.h.

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

◆ fctContext

C4Facet C4GraphicsResource::fctContext

◆ fctControllerIcons

C4FacetID C4GraphicsResource::fctControllerIcons

Definition at line 85 of file C4GraphicsResource.h.

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

◆ fctCrew

C4FacetID C4GraphicsResource::fctCrew

Definition at line 50 of file C4GraphicsResource.h.

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

◆ fctCrewClr

C4FacetID C4GraphicsResource::fctCrewClr

◆ fctEnergy

C4FacetID C4GraphicsResource::fctEnergy

Definition at line 64 of file C4GraphicsResource.h.

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

◆ fctExit

C4FacetID C4GraphicsResource::fctExit

Definition at line 66 of file C4GraphicsResource.h.

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

◆ fctFire

C4FacetID C4GraphicsResource::fctFire

Definition at line 54 of file C4GraphicsResource.h.

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

◆ fctFlag

C4FacetID C4GraphicsResource::fctFlag

Definition at line 49 of file C4GraphicsResource.h.

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

◆ fctFlagClr

C4FacetID C4GraphicsResource::fctFlagClr

◆ fctGamepad

C4FacetID C4GraphicsResource::fctGamepad

◆ fctHand

C4FacetID C4GraphicsResource::fctHand

Definition at line 67 of file C4GraphicsResource.h.

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

◆ fctIcons

C4FacetID C4GraphicsResource::fctIcons

◆ fctIconsEx

C4FacetID C4GraphicsResource::fctIconsEx

Definition at line 84 of file C4GraphicsResource.h.

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

◆ fctKey

C4Facet C4GraphicsResource::fctKey

Definition at line 74 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

◆ fctKeyboard

◆ fctLogo

C4FacetID C4GraphicsResource::fctLogo

Definition at line 62 of file C4GraphicsResource.h.

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

◆ fctMenu

C4FacetID C4GraphicsResource::fctMenu

Definition at line 60 of file C4GraphicsResource.h.

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

◆ fctMouse

C4Facet C4GraphicsResource::fctMouse

Definition at line 72 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

◆ fctMouseCursor

C4FacetID C4GraphicsResource::fctMouseCursor

◆ fctOKCancel

C4Facet C4GraphicsResource::fctOKCancel

Definition at line 75 of file C4GraphicsResource.h.

Referenced by Default(), and Init().

◆ fctOptions

C4FacetID C4GraphicsResource::fctOptions

Definition at line 59 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ fctPlayer

C4FacetID C4GraphicsResource::fctPlayer

Definition at line 48 of file C4GraphicsResource.h.

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

◆ fctPlayerClr

◆ fctProgressBar

C4FacetID C4GraphicsResource::fctProgressBar

◆ fctRank

C4FacetID C4GraphicsResource::fctRank

Definition at line 52 of file C4GraphicsResource.h.

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

◆ fctSelectMark

C4FacetID C4GraphicsResource::fctSelectMark

Definition at line 58 of file C4GraphicsResource.h.

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

◆ fctSubmenu

C4FacetID C4GraphicsResource::fctSubmenu

◆ fctTransformKnob

◆ fctUpperBoard

C4FacetID C4GraphicsResource::fctUpperBoard

◆ fctWealth

C4FacetID C4GraphicsResource::fctWealth

Definition at line 51 of file C4GraphicsResource.h.

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

◆ Files

◆ FontCaption

CStdFont C4GraphicsResource::FontCaption

Definition at line 101 of file C4GraphicsResource.h.

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

◆ FontRegular

◆ FontTiny

CStdFont C4GraphicsResource::FontTiny

Definition at line 99 of file C4GraphicsResource.h.

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

◆ FontTitle

CStdFont C4GraphicsResource::FontTitle

Definition at line 102 of file C4GraphicsResource.h.

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

◆ FontTooltip

CStdFont C4GraphicsResource::FontTooltip

Definition at line 103 of file C4GraphicsResource.h.

Referenced by ClearFonts(), and InitFonts().

◆ idRegisteredMainGroupSetFiles

int32_t C4GraphicsResource::idRegisteredMainGroupSetFiles
protected

◆ idSfcButton

int32_t C4GraphicsResource::idSfcButton {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ idSfcButtonD

int32_t C4GraphicsResource::idSfcButtonD {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ idSfcCaption

int32_t C4GraphicsResource::idSfcCaption {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ idSfcClonkSkins

int32_t C4GraphicsResource::idSfcClonkSkins
protected

Definition at line 40 of file C4GraphicsResource.h.

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

◆ idSfcContext

int32_t C4GraphicsResource::idSfcContext {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ idSfcControl

int32_t C4GraphicsResource::idSfcControl
protected

Definition at line 41 of file C4GraphicsResource.h.

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

◆ idSfcScroll

int32_t C4GraphicsResource::idSfcScroll {0}
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ iNumRanks

int32_t C4GraphicsResource::iNumRanks

Definition at line 53 of file C4GraphicsResource.h.

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

◆ MiniFont

CStdFont& C4GraphicsResource::MiniFont

Definition at line 97 of file C4GraphicsResource.h.

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

◆ ProgressIncrement

float C4GraphicsResource::ProgressIncrement

Definition at line 47 of file C4GraphicsResource.h.

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

◆ ProgressStart

float C4GraphicsResource::ProgressStart

Definition at line 47 of file C4GraphicsResource.h.

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

◆ sfcButton

C4Surface C4GraphicsResource::sfcButton
protected

Definition at line 38 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ sfcButtonD

C4Surface C4GraphicsResource::sfcButtonD
protected

Definition at line 38 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ sfcCaption

C4Surface C4GraphicsResource::sfcCaption
protected

Definition at line 38 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ sfcClonkSkins

C4Surface C4GraphicsResource::sfcClonkSkins
protected

Definition at line 37 of file C4GraphicsResource.h.

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

◆ sfcContext

C4Surface C4GraphicsResource::sfcContext
protected

Definition at line 39 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ sfcControl

C4Surface C4GraphicsResource::sfcControl
protected

Definition at line 37 of file C4GraphicsResource.h.

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

◆ sfcScroll

C4Surface C4GraphicsResource::sfcScroll
protected

Definition at line 39 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

◆ sfctScroll

C4GUI::ScrollBarFacets C4GraphicsResource::sfctScroll

Definition at line 90 of file C4GraphicsResource.h.

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

◆ TextFont

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(), C4StartupLegalDlg::C4StartupLegalDlg(), C4StartupModsDlg::C4StartupModsDlg(), C4StartupModsListEntry::C4StartupModsListEntry(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4FileSelDlg::DefaultListItem::DefaultListItem(), C4GUI::Tabular::Sheet::DrawCaption(), C4GUI::ProgressBar::DrawElement(), C4GUI::Button::DrawElement(), C4GUI::IconButton::DrawElement(), C4GUI::CheckBox::DrawElement(), C4GUI::ContextMenu::Entry::DrawElement(), C4GUI::ComboBox::DrawElement(), C4StartupMainDlg::DrawElement(), C4GUI::Edit::Edit(), C4GUI::ContextMenu::Entry::Entry(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::Tabular::Sheet::GetCaptionSize(), C4GUI::LabeledEdit::GetControlSize(), C4GUI::Edit::GetDefaultEditHeight(), C4GUI::ComboBox::GetDefaultHeight(), C4GUI::WoodenLabel::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::ProgressDialog::SetMessage(), C4GUI::Dialog::SetTitle(), C4FileSelDlg::UpdateSelection(), C4ChatControl::UpdateSize(), and C4GUI::Dialog::UpdateSize().

◆ TitleFont

◆ TooltipFont

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: