CModHandler.h 2.0 KB

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