AEExternalTooling.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. #include "AtomicEditor.h"
  5. #include <Atomic/IO/Log.h>
  6. #include <Atomic/IO/FileSystem.h>
  7. #include "AEExternalTooling.h"
  8. #include "AtomicTiled.h"
  9. namespace AtomicEditor
  10. {
  11. ExternalTooling::ExternalTooling(Context* context) :
  12. Object(context)
  13. {
  14. }
  15. ExternalTooling::~ExternalTooling()
  16. {
  17. }
  18. void ExternalTooling::LaunchOrOpen(const String& name, const String& fullpath)
  19. {
  20. if (tools_.Contains(name))
  21. {
  22. // TODO: open
  23. return;
  24. }
  25. if (name == "AtomicTiled")
  26. {
  27. SharedPtr<ExternalTool> tiled(new AtomicTiled(context_));
  28. if (tiled->Launch(fullpath))
  29. {
  30. tools_[name] = tiled;
  31. }
  32. }
  33. }
  34. void ExternalTooling::ToolExited(const String& name)
  35. {
  36. if (!tools_.Contains(name))
  37. return;
  38. tools_[name] = 0;
  39. }
  40. String ExternalTooling::GetToolApplicationPath()
  41. {
  42. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  43. String appDir = fileSystem->GetProgramDir();
  44. #ifdef ATOMIC_PLATFORM_WINDOWS
  45. appDir += "/Applications/";
  46. #else
  47. unsigned p = appDir.Find("/Contents/MacOS");
  48. if (p != String::NPOS)
  49. {
  50. appDir.Erase(p, appDir.Length() - p);
  51. appDir += "/Contents/Applications/";
  52. }
  53. #endif
  54. return appDir;
  55. }
  56. }