CModHandler.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "StdInc.h"
  2. #include "CModHandler.h"
  3. /*
  4. * CModHandler.h, part of VCMI engine
  5. *
  6. * Authors: listed in file AUTHORS in main folder
  7. *
  8. * License: GNU General Public License v2.0 or later
  9. * Full text of license available in license.txt file, in main folder
  10. *
  11. */
  12. class CArtHandler;
  13. class CHeroHandler;
  14. class CCreatureHandler;
  15. class CSpellHandler;
  16. class CBuildingHandler;
  17. class CObjectHandler;
  18. class CDefObjInfoHandler;
  19. class CTownHandler;
  20. class CGeneralTextHandler;
  21. CModHandler::CModHandler()
  22. {
  23. VLC->modh = this;
  24. //CResourceHandler::loadModsFilesystems(); //scan for all mods
  25. //TODO: mod filesystem is already initialized at LibClasses launch
  26. //TODO: load default (last?) config
  27. }
  28. artID CModHandler::addNewArtifact (CArtifact * art)
  29. {
  30. int id = artifacts.size();
  31. artifacts.push_back (art);
  32. return id;
  33. }
  34. creID CModHandler::addNewCreature (CCreature * cre)
  35. {
  36. int id = creatures.size();
  37. creatures.push_back (cre);
  38. return id;
  39. }
  40. void CModHandler::loadConfigFromFile (std::string name)
  41. {}
  42. void CModHandler::saveConfigToFile (std::string name)
  43. {}
  44. void CModHandler::recreateHandlers()
  45. {
  46. //TODO: consider some template magic to unify all handlers?
  47. VLC->arth->artifacts.clear();
  48. VLC->creh->creatures.clear(); //TODO: what about items from original game?
  49. BOOST_FOREACH (auto mod, activeMods)
  50. {
  51. BOOST_FOREACH (auto art, allMods[mod].artifacts)
  52. {
  53. VLC->arth->artifacts.push_back (artifacts[art]);
  54. }
  55. BOOST_FOREACH (auto creature, allMods[mod].creatures)
  56. {
  57. VLC->creh->creatures.push_back (creatures[creature]);
  58. }
  59. }
  60. }
  61. CModHandler::~CModHandler()
  62. {
  63. }