CvArtFileMgr.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #pragma once
  2. //---------------------------------------------------------------------------------------
  3. //
  4. // ***************** Civilization IV ********************
  5. //
  6. // FILE: CvArtFileMgr.h
  7. //
  8. // AUTHOR: Jesse Smith / Mustafa Thamer 9/2004
  9. //
  10. // PURPOSE: Interfaces with Civ4ArtDefines.xml to manage the paths of art files
  11. //
  12. //---------------------------------------------------------------------------------------
  13. // Copyright (c) 2004 Firaxis Games, Inc. All rights reserved.
  14. //---------------------------------------------------------------------------------------
  15. #ifndef CIV4_ARTFILEMGR_H
  16. #define CIV4_ARTFILEMGR_H
  17. // Class: CvArtFileMgr
  18. // Purpose: To Manage the Locations of Art Assets
  19. //
  20. // Adding a New Entry:
  21. // * Create a new ArtInfo<new> in 'CvInfos.h' & add to CyInfosInterface
  22. // * Add a new ART_INFO_DECL to 'CvArtFileMgr.h'
  23. // * Add a new ART_INFO_DEFN to 'CvArtFileMgr.cpp'
  24. // * Update Python 'CyGlobalContext & CyArtFileMgr' files
  25. // * Add INIT_GLOBAL_XML_LOAD item to SetGlobalArtDefines in 'CvXMLLoadUtilitySet'
  26. // * Add <new> to 'XML\Art\CIV4ArtDefines.xml' and update the 'CIV4ArtDefinesSchema'
  27. class CvArtInfoAsset;
  28. class CvArtInfoMisc;
  29. class CvArtInfoUnit;
  30. class CvArtInfoBuilding;
  31. class CvArtInfoCivilization;
  32. class CvArtInfoLeaderhead;
  33. class CvArtInfoBonus;
  34. class CvArtInfoImprovement;
  35. class CvArtInfoTerrain;
  36. class CvArtInfoFeature;
  37. class CvArtInfoMovie;
  38. class CvArtInfoInterface;
  39. // Example usage: ART_INFO_DECL(Unit)
  40. #define ART_INFO_DECL(name) \
  41. public: \
  42. friend class Cv##name##ArtInfoItem; \
  43. DllExport CvArtInfo##name##* get##name##ArtInfo(const char *szArtDefineTag) const; \
  44. DllExport int getNum##name##ArtInfos() { return (int)m_pa##name##ArtInfo.size(); } \
  45. DllExport std::vector<CvArtInfo##name##*>& get##name##ArtInfo() { return m_pa##name##ArtInfo; } \
  46. DllExport CvArtInfo##name##& get##name##ArtInfo(int i); \
  47. private: \
  48. typedef std::map<const char* /* index */,CvArtInfo##name##* /*value */, ltstr> ArtInfo##name##MapType; \
  49. ArtInfo##name##MapType* m_map##name##ArtInfos; \
  50. std::vector<CvArtInfo##name##*> m_pa##name##ArtInfo; \
  51. class CvArtFileMgr
  52. {
  53. private:
  54. class ArtInfoItem
  55. {
  56. public:
  57. ArtInfoItem() { CvArtFileMgr::GetInstance().addArtInfoItem(this); }
  58. virtual void init() = 0;
  59. virtual void deInit() = 0;
  60. virtual void buildMap() = 0;
  61. };
  62. public:
  63. // singleton accessor
  64. DllExport static CvArtFileMgr& GetInstance();
  65. DllExport CvArtFileMgr() {};
  66. DllExport virtual ~CvArtFileMgr() {};
  67. DllExport void Init();
  68. DllExport void DeInit();
  69. // Deletes Maps, Reloads Infos from XML, Rebuilds Maps
  70. DllExport void Reset(); // Exposed to Python
  71. // Builds Maps
  72. DllExport void buildArtFileInfoMaps(); // Exposed to Python
  73. // Adds an Art File List
  74. void addArtInfoItem(CvArtFileMgr::ArtInfoItem* item) { m_artInfoItems.push_back(item); }
  75. private:
  76. struct ltstr
  77. {
  78. bool operator()(const char* s1, const char* s2) const
  79. {
  80. return strcmp(s1, s2) < 0;
  81. }
  82. };
  83. ART_INFO_DECL(Asset);
  84. ART_INFO_DECL(Misc);
  85. ART_INFO_DECL(Unit);
  86. ART_INFO_DECL(Building);
  87. ART_INFO_DECL(Civilization);
  88. ART_INFO_DECL(Leaderhead);
  89. ART_INFO_DECL(Bonus);
  90. ART_INFO_DECL(Improvement);
  91. ART_INFO_DECL(Terrain);
  92. ART_INFO_DECL(Feature);
  93. ART_INFO_DECL(Movie);
  94. ART_INFO_DECL(Interface);
  95. std::vector<ArtInfoItem*> m_artInfoItems;
  96. };
  97. // Singleton Accessor
  98. #define ARTFILEMGR CvArtFileMgr::GetInstance()
  99. #endif