2
0

CModHandler.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. struct DLL_LINKAGE hardcodedFeatures
  64. {
  65. int CREEP_SIZE; // neutral stacks won't grow beyond this number
  66. int WEEKLY_GROWTH; //percent
  67. int NEUTRAL_STACK_EXP;
  68. bool DWELLINGS_ACCUMULATE_CREATURES;
  69. bool ALL_CREATURES_GET_DOUBLE_MONTHS;
  70. template <typename Handler> void serialize(Handler &h, const int version)
  71. {
  72. h & CREEP_SIZE & WEEKLY_GROWTH & NEUTRAL_STACK_EXP;
  73. h & DWELLINGS_ACCUMULATE_CREATURES & ALL_CREATURES_GET_DOUBLE_MONTHS;
  74. }
  75. } settings;
  76. CModHandler();
  77. ~CModHandler();
  78. template <typename Handler> void serialize(Handler &h, const int version)
  79. {
  80. h & creatures & artifacts;
  81. h & allMods & activeMods & settings;
  82. }
  83. };