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

#include <C4ScenarioParameters.h>

Public Member Functions

 C4AchievementGraphics ()
bool Init (C4Group &File)
bool Init (C4GroupSet &Files)
void Clear ()
C4FacetSurfaceFindByName (const char *name) const

Detailed Description

Definition at line 24 of file C4ScenarioParameters.h.

Constructor & Destructor Documentation

C4AchievementGraphics::C4AchievementGraphics ( )

Definition at line 30 of file C4ScenarioParameters.h.

30 : idGrp(0) {}

Member Function Documentation

void C4AchievementGraphics::Clear ( )

Definition at line 62 of file C4ScenarioParameters.cpp.

Referenced by C4GraphicsResource::Clear().

63 {
64  for (auto i = Graphics.begin(); i != Graphics.end(); ++i)
65  delete i->second;
66  Graphics.clear();
67  idGrp = 0;
68 }

Here is the caller graph for this function:

C4FacetSurface * C4AchievementGraphics::FindByName ( const char *  name) const

Definition at line 70 of file C4ScenarioParameters.cpp.

Referenced by C4ScenarioListLoader::Scenario::LoadCustomPre().

71 {
72  auto i = Graphics.find(StdCopyStrBuf(name));
73  if (i != Graphics.end()) return i->second; else return nullptr;
74 }

Here is the caller graph for this function:

bool C4AchievementGraphics::Init ( C4Group File)

Definition at line 25 of file C4ScenarioParameters.cpp.

References _MAX_FNAME, C4CFN_Achievements, C4FCT_Full, C4FCT_Height, C4Group::FindNextEntry(), C4FacetSurface::Load(), LoadResStr(), LogF(), RemoveExtension(), C4Group::ResetSearch(), and SCharPos().

Referenced by Init(), and C4GraphicsResource::Init().

26 {
27  // Load all graphics matching achievement filename and register them to map
28  char FileName[_MAX_FNAME];
29  File.ResetSearch();
30  while (File.FindNextEntry(C4CFN_Achievements, FileName))
31  {
32  C4FacetSurface *new_fct = new C4FacetSurface();
33  if (!new_fct->Load(File, FileName, C4FCT_Height, C4FCT_Full, false, 0))
34  {
35  delete new_fct;
36  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
37  return false;
38  }
39  // Register under filename excluding the leading "Achv" part. Delete any existing file with same name.
40  RemoveExtension(FileName);
41  int32_t id_offset = SCharPos('*', C4CFN_Achievements); assert(id_offset>=0);
42  StdCopyStrBuf sFileName(FileName + id_offset);
43  auto i = Graphics.find(sFileName);
44  if (i != Graphics.end()) delete i->second;
45  Graphics[sFileName] = new_fct;
46  }
47  // done. success no matter how many files were loaded.
48  return true;
49 }
bool Load(C4Group &hGroup, const char *szName, int iWdt, int iHgt, bool fNoErrIfNotFound, int iFlags)
Definition: C4FacetEx.cpp:78
const int C4FCT_Height
Definition: C4FacetEx.h:27
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
#define _MAX_FNAME
void RemoveExtension(char *szFilename)
Definition: StdFile.cpp:316
#define C4CFN_Achievements
Definition: C4Components.h:90
bool FindNextEntry(const char *szWildCard, StdStrBuf *sFileName=nullptr, size_t *iSize=nullptr, bool fStartAtFilename=false)
Definition: C4Group.cpp:1780
void ResetSearch(bool reload_contents=false)
Definition: C4Group.cpp:1013
int SCharPos(char cTarget, const char *szInStr, int iIndex)
Definition: Standard.cpp:203
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
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 C4AchievementGraphics::Init ( C4GroupSet Files)

Definition at line 51 of file C4ScenarioParameters.cpp.

References C4CFN_Achievements, C4GroupSet::FindEntry(), and Init().

52 {
53  int32_t idNewGrp=0;
54  C4Group *pGrp = Files.FindEntry(C4CFN_Achievements, nullptr, &idNewGrp);
55  if (!pGrp) return true; // no achievement gfx. That's OK.
56  if (idNewGrp == idGrp) return true; // no update
57  idGrp = idNewGrp;
58  // OK, load from this group
59  return Init(*pGrp);
60 }
bool Init(C4Group &File)
C4Group * FindEntry(const char *szWildcard, int32_t *pPriority=nullptr, int32_t *pID=nullptr)
Definition: C4GroupSet.cpp:177
#define C4CFN_Achievements
Definition: C4Components.h:90

Here is the call graph for this function:

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