CModHandler.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #include "Filesystem/CResourceLoader.h"
  3. #include "VCMI_Lib.h"
  4. #include "CCreatureHandler.h"
  5. #include "CArtHandler.h"
  6. /*
  7. * CModHandler.h, part of VCMI engine
  8. *
  9. * Authors: listed in file AUTHORS in main folder
  10. *
  11. * License: GNU General Public License v2.0 or later
  12. * Full text of license available in license.txt file, in main folder
  13. *
  14. */
  15. class CModHandler;
  16. class CModIndentifier;
  17. class CModInfo;
  18. typedef si32 artID;
  19. typedef si32 creID;
  20. class DLL_LINKAGE CModIdentifier
  21. {
  22. //TODO? are simple integer identifiers enough?
  23. int id;
  24. public:
  25. // int operator ()() {return 0;};
  26. bool operator < (CModIdentifier rhs) const {return true;}; //for map
  27. template <typename Handler> void serialize(Handler &h, const int version)
  28. {
  29. h & id;
  30. }
  31. };
  32. class DLL_LINKAGE CModInfo
  33. {
  34. public:
  35. std::vector <CModIdentifier> requirements;
  36. std::vector <ResourceID> usedFiles;
  37. //TODO: config options?
  38. //items added by this mod
  39. std::vector <artID> artifacts;
  40. std::vector <creID> creatures;
  41. //TODO: some additional scripts?
  42. template <typename Handler> void serialize(Handler &h, const int version)
  43. {
  44. h & requirements & artifacts & creatures;
  45. //h & usedFiles; //TODO: make seralizable?
  46. }
  47. };
  48. class DLL_LINKAGE CModHandler
  49. {
  50. public:
  51. std::string currentConfig; //save settings in this file
  52. //list of all possible objects in game, including inactive mods or not allowed
  53. std::vector <ConstTransitivePtr<CCreature> > creatures;
  54. std::vector <ConstTransitivePtr<CArtifact> > artifacts;
  55. std::map <CModIdentifier, CModInfo> allMods;
  56. std::set <CModIdentifier> activeMods;
  57. //create unique object indentifier
  58. artID addNewArtifact (CArtifact * art);
  59. creID addNewCreature (CCreature * cre);
  60. void loadConfigFromFile (std::string name);
  61. void saveConfigToFile (std::string name);
  62. void recreateHandlers();
  63. CModHandler();
  64. ~CModHandler();
  65. template <typename Handler> void serialize(Handler &h, const int version)
  66. {
  67. h & creatures & artifacts;
  68. h & allMods & activeMods;
  69. }
  70. };