ModScope.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * ModScope.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. VCMI_LIB_NAMESPACE_BEGIN
  12. namespace ModScope
  13. {
  14. /// returns true if scope is reserved for internal use and can not be used by mods
  15. inline bool isScopeReserved(const std::string & scope)
  16. {
  17. //following scopes are reserved - either in use by mod system or by filesystem
  18. static const std::array<std::string, 9> reservedScopes = {
  19. "core", "map", "game", "root", "saves", "config", "local", "initial", "mapEditor"
  20. };
  21. return std::find(reservedScopes.begin(), reservedScopes.end(), scope) != reservedScopes.end();
  22. }
  23. /// reserved scope name for referencing built-in (e.g. H3) objects
  24. inline const std::string & scopeBuiltin()
  25. {
  26. static const std::string scope = "core";
  27. return scope;
  28. }
  29. /// reserved scope name for accessing objects from any loaded mod
  30. inline const std::string & scopeGame()
  31. {
  32. static const std::string scope = "game";
  33. return scope;
  34. }
  35. /// reserved scope name for accessing object for map loading
  36. inline const std::string & scopeMap()
  37. {
  38. //TODO: implement accessing map dependencies for both H3 and VCMI maps
  39. // for now, allow access to any identifiers
  40. static const std::string scope = "game";
  41. return scope;
  42. }
  43. };
  44. VCMI_LIB_NAMESPACE_END