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
 
int32_t idSfcButton
 
int32_t idSfcButtonD
 
int32_t idSfcScroll
 
int32_t idSfcContext
 
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 33 of file C4GraphicsResource.cpp.

References Default().

33  :
36 {
37  Default();
38 }

Here is the call graph for this function:

C4GraphicsResource::~C4GraphicsResource ( )

Definition at line 40 of file C4GraphicsResource.cpp.

References Clear().

41 {
42  Clear();
43 }

Here is the call graph for this function:

Member Function Documentation

void C4GraphicsResource::Clear ( )

Definition at line 93 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().

94 {
95  fInitialized = false;
96 
97  sfcControl.Clear();
98  idSfcControl = 0;
100  idSfcClonkSkins = 0;
101 
102  fctCrewClr.Clear();
103  fctFlagClr.Clear();
105 
106  fctPlayer.Clear();
107  fctFlag.Clear();
108  fctCrew.Clear();
109  fctWealth.Clear();
110  fctRank.Clear();
111  fctFire.Clear();
113  fctCaptain.Clear();
116  fctMenu.Clear();
118  fctLogo.Clear();
120  fctEnergy.Clear();
121  fctOptions.Clear();
122  fctArrow.Clear();
123  fctExit.Clear();
124  fctHand.Clear();
125  fctGamepad.Clear();
126  fctBuild.Clear();
128  // GUI data
135  fctSubmenu.Clear();
136  fctCheckbox.Clear();
140 
141 
142  // unhook deflist from font
143  FontRegular.SetCustomImages(nullptr);
144 
146 
147  // closing the group set will also close the graphics.ocg
148  // this is just for games that failed to init
149  // normally, this is done after successful init anyway
150  CloseFiles();
151 }
C4GUI::DynBarFacet barCaption
C4GUI::DynBarFacet barButtonD
void SetCustomImages(CustomImages *pHandler)
Definition: C4FontLoader.h:193
void Clear()
Definition: C4Surface.cpp:136
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 173 of file C4GraphicsResource.cpp.

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

Referenced by C4Application::Quit().

174 {
175  FontRegular.Clear();
176  FontTitle.Clear();
177  FontCaption.Clear();
178  FontTiny.Clear();
179  FontTooltip.Clear();
180 }
void Clear()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GraphicsResource::CloseFiles ( )

Definition at line 359 of file C4GraphicsResource.cpp.

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

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

360 {
361  // closes main gfx group; releases dependencies into game group set
362  Files.Clear();
364 }
void Clear()
Definition: C4GroupSet.cpp:52
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 45 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().

46 {
47  fInitialized = false;
48 
50  idSfcControl = 0;
52  idSfcClonkSkins = 0;
53 
55  fctFlag.Default();
57  fctCrew.Default();
59  fctRank.Default();
60  fctFire.Default();
65  fctMenu.Default();
67  fctLogo.Default();
70  fctArrow.Default();
71  fctExit.Default();
72  fctHand.Default();
74  fctBuild.Default();
75 
79 
83  fctKey.Default();
85  fctMouse.Default();
86 
88 
89  iNumRanks=1;
91 }
void Default()
Definition: C4Surface.cpp:81
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 428 of file C4GraphicsResource.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::Init ( )

Definition at line 182 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().

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

154 {
155  // this regards scenario-specific fonts or overloads in Extra.ocg
156  const char *szFont;
157  if (!Game.C4S.Head.Font.empty()) szFont = Game.C4S.Head.Font.c_str(); else szFont = Config.General.RXFontName;
166  if (!::FontLoader.InitFont(&FontTooltip, szFont, C4FontLoader::C4FT_Main, Config.General.RXFontSize, &Files, false)) return false;
168  // assign def list as custom image source
170  return true;
171 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3389
C4Config Config
Definition: C4Config.cpp:837
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:76
C4ConfigGeneral General
Definition: C4Config.h:252
void SetCustomImages(CustomImages *pHandler)
Definition: C4FontLoader.h:193
char RXFontName[CFG_MaxString+1]
Definition: C4Config.h:42
C4FontLoader FontLoader
int32_t RXFontSize
Definition: C4Config.h:43
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 315 of file C4GraphicsResource.cpp.

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

Referenced by Init().

316 {
317  // Determine appropriate GFX file by screen resolution
318  const char *szCursorFilename;
319  szCursorFilename = "Cursor";
320  if (!LoadFile(fctMouseCursor, szCursorFilename, Files, C4FCT_Height, C4FCT_Full, false, 0))
321  return false;
322  return true;
323 }
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 373 of file C4GraphicsResource.cpp.

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

Referenced by Init(), and LoadCursorGfx().

374 {
375  char FileName[_MAX_FNAME]; int32_t ID = 0;
376  C4Group *pGrp = FindSuitableFile(szName, rGfxSet, FileName, &ID);
377  if (!pGrp)
378  {
379  // FIXME: Use LogFatal here
380  if (!fNoWarnIfNotFound)
381  {
382  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), szName, LoadResStr("IDS_PRC_FILENOTFOUND"));
383  }
384  return false;
385  }
386  // check group
387  if (fct.idSourceGroup == ID)
388  // already up-to-date
389  return true;
390  // load
391  if (!fct.Load(*pGrp, FileName, iWdt, iHgt, false, iFlags))
392  {
393  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
394  return false;
395  }
396  fct.idSourceGroup = ID;
399  return true;
400 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3389
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:253

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 402 of file C4GraphicsResource.cpp.

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

403 {
404  // find
405  char FileName[_MAX_FNAME]; int32_t ID = 0;
406  C4Group *pGrp = FindSuitableFile(szName, rGfxSet, FileName, &ID);
407  if (!pGrp)
408  {
409  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), szName, LoadResStr("IDS_PRC_FILENOTFOUND"));
410  return false;
411  }
412  // check group
413  if (ID == ridCurrSfc)
414  // already up-to-date
415  return true;
416  // load
417  if (!sfc.Load(*pGrp, FileName, false, false, iFlags))
418  {
419  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
420  return false;
421  }
422  ridCurrSfc = ID;
425  return true;
426 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3389
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:253

Here is the call graph for this function:

bool C4GraphicsResource::RegisterGlobalGraphics ( )

Definition at line 325 of file C4GraphicsResource.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GraphicsResource::RegisterMainGroups ( )

Definition at line 351 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().

352 {
353  // register main groups
356  return true;
357 }
C4Game Game
Definition: C4Globals.cpp:52
C4GroupSet GroupSet
Definition: C4Game.h:89
bool RegisterGroups(const C4GroupSet &rCopy, int32_t Contents, const char *szFilename=nullptr, int32_t iMaxSkipID=0)
Definition: C4GroupSet.cpp:130
#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 448 of file C4GraphicsResource.cpp.

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

Referenced by C4Game::OnResolutionChanged().

449 {
450  if(!fInitialized) return false;
451  // reload any files that depend on the current resolution
452  // reloads the cursor
453 
454  // Re-open the graphics files if they are not open anymore -- this
455  // happens when the game is running.
456  // Note also that at the moment there are no resolution dependent
457  // graphics files...
458  const bool hadGroupsRegistered = (idRegisteredMainGroupSetFiles != -1);
459  if(!hadGroupsRegistered)
460  {
463  }
464 
466  const bool result = true;
467 
468  if(!hadGroupsRegistered)
469  CloseFiles();
470 
471  return result;
472 }
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
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

int32_t C4GraphicsResource::idSfcButtonD
protected

Definition at line 40 of file C4GraphicsResource.h.

Referenced by Clear(), and Init().

int32_t C4GraphicsResource::idSfcCaption
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
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
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: