ToolSystem.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include <Atomic/Core/Context.h>
  2. #include <Atomic/IO/FileSystem.h>
  3. #include <Atomic/Resource/ResourceCache.h>
  4. #include "Platform/PlatformWeb.h"
  5. #include "Net/CurlManager.h"
  6. #include "License/LicenseSystem.h"
  7. #include "Build/BuildSystem.h"
  8. #include "ToolSystem.h"
  9. #include "Project/Project.h"
  10. namespace ToolCore
  11. {
  12. ToolSystem::ToolSystem(Context* context) : Object(context)
  13. {
  14. context_->RegisterSubsystem(new CurlManager(context_));
  15. context_->RegisterSubsystem(new LicenseSystem(context_));
  16. context_->RegisterSubsystem(new BuildSystem(context_));
  17. // platform registration
  18. RegisterPlatform(new PlatformWeb(context));
  19. }
  20. ToolSystem::~ToolSystem()
  21. {
  22. }
  23. bool ToolSystem::LoadProject(const String& fullpath)
  24. {
  25. String path = GetPath(fullpath);
  26. ResourceCache* cache = GetSubsystem<ResourceCache>();
  27. cache->AddResourceDir(path, 0);
  28. String resourcePath = path;
  29. resourcePath += "Resources";
  30. cache->AddResourceDir(resourcePath, 0);
  31. project_ = new Project(context_);
  32. project_->SetResourcePath(resourcePath);
  33. project_->Load(fullpath);
  34. return true;
  35. }
  36. void ToolSystem::SetCurrentPlatform(PlatformID platform)
  37. {
  38. if (!platforms_.Contains((unsigned) platform))
  39. return;
  40. currentPlatform_ = platforms_[(unsigned)platform];
  41. }
  42. PlatformID ToolSystem::GetCurrentPlatform()
  43. {
  44. if (currentPlatform_.Null())
  45. return PLATFORMID_UNDEFINED;
  46. return currentPlatform_->GetPlatformID();
  47. }
  48. void ToolSystem::RegisterPlatform(Platform* platform)
  49. {
  50. platforms_.Insert(MakePair((unsigned)platform->GetPlatformID(), SharedPtr<Platform>(platform)));
  51. }
  52. }