ProjectManager.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. function ProjectManager::create(%this)
  23. {
  24. exec("./scripts/ProjectModulePanel.cs");
  25. exec("./scripts/ProjectGamePanel.cs");
  26. exec("./scripts/ProjectLibraryPanel.cs");
  27. exec("./scripts/ProjectModuleCard.cs");
  28. exec("./scripts/ProjectModuleDependList.cs");
  29. exec("./scripts/ProjectModuleAssetList.cs");
  30. exec("./scripts/NewDependencyDialog.cs");
  31. exec("./scripts/DeclaredAssetForm.cs");
  32. exec("./scripts/NewDeclaredAssetDialog.cs");
  33. exec("./scripts/NewModuleDialog.cs");
  34. exec("./scripts/EditModuleDialog.cs");
  35. %this.guiPage = EditorCore.RegisterEditor("Project Manager", %this);
  36. %this.scroller = new GuiScrollCtrl()
  37. {
  38. HorizSizing="width";
  39. VertSizing="height";
  40. Position="0 0";
  41. Extent="1024 768";
  42. hScrollBar="dynamic";
  43. vScrollBar="dynamic";
  44. constantThumbHeight="0";
  45. showArrowButtons="1";
  46. scrollBarThickness="14";
  47. };
  48. ThemeManager.setProfile(%this.scroller, "emptyProfile");
  49. ThemeManager.setProfile(%this.scroller, "thumbProfile", "ThumbProfile");
  50. ThemeManager.setProfile(%this.scroller, "trackProfile", "TrackProfile");
  51. ThemeManager.setProfile(%this.scroller, "scrollArrowProfile", "ArrowProfile");
  52. %this.guiPage.add(%this.scroller);
  53. %this.container = new GuiControl()
  54. {
  55. HorizSizing="width";
  56. VertSizing="height";
  57. Position="0 0";
  58. Extent="1024 768";
  59. MinExtent="1024 500";
  60. };
  61. ThemeManager.setProfile(%this.container, "emptyProfile");
  62. %this.scroller.add(%this.container);
  63. %this.libraryPanel = new GuiControl()
  64. {
  65. Class = "ProjectLibraryPanel";
  66. superclass = "ProjectModulePanel";
  67. HorizSizing="relative";
  68. VertSizing="height";
  69. Position="0 0";
  70. Extent="512 768";
  71. };
  72. ThemeManager.setProfile(%this.libraryPanel, "emptyProfile");
  73. %this.container.add(%this.libraryPanel);
  74. %this.libraryPanel.load();
  75. %this.startListening(%this.libraryPanel);
  76. %this.gamePanel = new GuiControl()
  77. {
  78. Class = "ProjectGamePanel";
  79. superclass = "ProjectModulePanel";
  80. HorizSizing="relative";
  81. VertSizing="height";
  82. Position="512 0";
  83. Extent="512 768";
  84. };
  85. ThemeManager.setProfile(%this.gamePanel, "emptyProfile");
  86. %this.container.add(%this.gamePanel);
  87. %this.startListening(%this.gamePanel);
  88. EditorCore.FinishRegistration(%this.guiPage);
  89. }
  90. function ProjectManager::destroy(%this)
  91. {
  92. %this.postEvent("ShutDown");
  93. }
  94. function ProjectManager::open(%this)
  95. {
  96. %allModules = ModuleDatabase.findModules(false);
  97. %this.gamePanel.onOpen(%allModules);
  98. %this.libraryPanel.onOpen(%allModules);
  99. }
  100. function ProjectManager::close(%this)
  101. {
  102. %this.libraryPanel.onClose();
  103. %this.gamePanel.onClose();
  104. }
  105. function ProjectManager::setProjectFolder(%this, %folder)
  106. {
  107. %this.projectFolder = %folder;
  108. }
  109. function ProjectManager::getProjectFolder(%this)
  110. {
  111. if(%this.projectFolder $= "")
  112. {
  113. %appCore = ModuleDatabase.findModule("AppCore", 1);
  114. %appCorePath = %appCore.getModulePath();
  115. %mainCsPath = getMainDotCsDir();
  116. %mainLen = strLen(%mainCsPath);
  117. %lastChar = getSubStr(%mainCsPath, %mainLen-1, 1);
  118. if(%lastChar $= "\\" || %lastChar $= "\/")
  119. {
  120. %relativePath = getSubStr(%appCorePath, strlen(%mainCsPath), strlen(%appCorePath) - %mainLen);
  121. }
  122. else
  123. {
  124. %relativePath = getSubStr(%appCorePath, strlen(%mainCsPath) + 1, strlen(%appCorePath) - (%mainLen + 1));
  125. }
  126. %unwantedPortion1 = strchr(%relativePath, "\\");
  127. %unwantedPortion2 = strchr(%relativePath, "\/");
  128. if(%unwantedPortion1 !$= "")
  129. {
  130. %this.projectFolder = getSubStr(%relativePath, 0, strlen(%relativePath) - strlen(%unwantedPortion1));
  131. }
  132. else if(%unwantedPortion2 !$= "")
  133. {
  134. %this.projectFolder = getSubStr(%relativePath, 0, strlen(%relativePath) - strlen(%unwantedPortion2));
  135. }
  136. else
  137. {
  138. %this.projectFolder = %relativePath;
  139. }
  140. }
  141. return pathConcat(getMainDotCsDir(), %this.projectFolder);
  142. }
  143. function ProjectManager::onModuleInstalled(%this, %module)
  144. {
  145. %allModules = ModuleDatabase.findModules(false);
  146. %this.gamePanel.onOpen(%allModules);
  147. %this.libraryPanel.onOpen(%allModules);
  148. }