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

#include <C4Achievement.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 20 of file C4Achievement.h.

Constructor & Destructor Documentation

C4AchievementGraphics::C4AchievementGraphics ( )

Definition at line 26 of file C4Achievement.h.

26 : idGrp(0) {}

Member Function Documentation

void C4AchievementGraphics::Clear ( )

Definition at line 60 of file C4Achievement.cpp.

Referenced by C4GraphicsResource::Clear().

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

Here is the caller graph for this function:

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

Definition at line 68 of file C4Achievement.cpp.

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

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

Here is the caller graph for this function:

bool C4AchievementGraphics::Init ( C4Group File)

Definition at line 23 of file C4Achievement.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().

24 {
25  // Load all graphics matching achievement filename and register them to map
26  char FileName[_MAX_FNAME];
27  File.ResetSearch();
28  while (File.FindNextEntry(C4CFN_Achievements, FileName))
29  {
30  C4FacetSurface *new_fct = new C4FacetSurface();
31  if (!new_fct->Load(File, FileName, C4FCT_Height, C4FCT_Full, false, 0))
32  {
33  delete new_fct;
34  LogF(LoadResStr("IDS_PRC_NOGFXFILE"), FileName, LoadResStr("IDS_ERR_NOFILE"));
35  return false;
36  }
37  // Register under filename excluding the leading "Achv" part. Delete any existing file with same name.
38  RemoveExtension(FileName);
39  int32_t id_offset = SCharPos('*', C4CFN_Achievements); assert(id_offset>=0);
40  StdCopyStrBuf sFileName(FileName + id_offset);
41  auto i = Graphics.find(sFileName);
42  if (i != Graphics.end()) delete i->second;
43  Graphics[sFileName] = new_fct;
44  }
45  // done. success no matter how many files were loaded.
46  return true;
47 }
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:210
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 49 of file C4Achievement.cpp.

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

50 {
51  int32_t idNewGrp=0;
52  C4Group *pGrp = Files.FindEntry(C4CFN_Achievements, nullptr, &idNewGrp);
53  if (!pGrp) return true; // no achievement gfx. That's OK.
54  if (idNewGrp == idGrp) return true; // no update
55  idGrp = idNewGrp;
56  // OK, load from this group
57  return Init(*pGrp);
58 }
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: