InterfaceBuilder.h 928 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * InterfaceBuilder.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "CIntObject.h"
  12. #include "../../lib/JsonNode.h"
  13. class InterfaceBuilder: public CIntObject
  14. {
  15. public:
  16. InterfaceBuilder();
  17. InterfaceBuilder(const JsonNode & config);
  18. protected:
  19. //must be called after adding callbacks
  20. void init(const JsonNode & config);
  21. void addCallback(const std::string & callbackName, std::function<void(int)> callback);
  22. const std::shared_ptr<CIntObject> widget(const std::string &) const;
  23. private:
  24. std::map<std::string, std::shared_ptr<CIntObject>> widgets;
  25. std::map<std::string, std::function<void(int)>> callbacks;
  26. std::shared_ptr<CIntObject> buildWidget(const JsonNode & config);
  27. std::string buildText(const JsonNode & param) const;
  28. };