AssetAdmin.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 AssetAdmin::create(%this)
  23. {
  24. exec("./AssetDictionary.cs");
  25. exec("./AssetWindow.cs");
  26. exec("./AssetDictionaryButton.cs");
  27. exec("./AssetInspector.cs");
  28. exec("./AssetAudioPlayButton.cs");
  29. exec("./NewAssetButton.cs");
  30. exec("./NewImageAssetDialog.cs");
  31. exec("./NewAnimationAssetDialog.cs");
  32. exec("./NewParticleAssetDialog.cs");
  33. exec("./NewFontAssetDialog.cs");
  34. exec("./NewAudioAssetDialog.cs");
  35. exec("./DeleteAssetDialog.cs");
  36. exec("./ParticleEditor/exec.cs");
  37. exec("./ImageEditor/exec.cs");
  38. %this.guiPage = EditorCore.RegisterEditor("Asset Manager", %this);
  39. %this.content = %this.createFrameSet();
  40. %this.buildAssetWindow();
  41. %this.buildAudioPlayButton();
  42. %this.buildInspector();
  43. %this.buildLibrary();
  44. EditorCore.FinishRegistration(%this.guiPage);
  45. %this.isOpen = false;
  46. }
  47. function AssetAdmin::createFrameSet(%this)
  48. {
  49. %content = new GuiFrameSetCtrl() {
  50. HorizSizing = "width";
  51. VertSizing = "height";
  52. Position = "0 0";
  53. Extent = %this.guiPage.getExtent();
  54. DividerThickness = 6;
  55. };
  56. ThemeManager.setProfile(%content, "frameSetProfile");
  57. ThemeManager.setProfile(%content, "dropButtonProfile", "dropButtonProfile");
  58. ThemeManager.setProfile(%content, "frameSetTabBookProfile", "tabBookProfile");
  59. ThemeManager.setProfile(%content, "frameSetTabProfile", "tabProfile");
  60. ThemeManager.setProfile(%content, "frameSetTabPageProfile", "tabPageProfile");
  61. %this.guiPage.add(%content);
  62. %idList = %content.createHorizontalSplit(1);
  63. %leftID = getWord(%idList, 0);
  64. %rightID = getWord(%idList, 1);
  65. %content.anchorFrame(%rightID);
  66. %content.setFrameSize(%rightID, 324);
  67. %ids = %content.createVerticalSplit(%leftID);
  68. %centerFrameID = getWord(%ids, 0);
  69. %inspectorFrameID = getWord(%ids, 1);
  70. %content.anchorFrame(%inspectorFrameID);
  71. %content.setFrameSize(%inspectorFrameID, 360);
  72. return %content;
  73. }
  74. function AssetAdmin::buildLibrary(%this)
  75. {
  76. %this.libWindow = new GuiWindowCtrl()
  77. {
  78. HorizSizing = "right";
  79. VertSizing = "bottom";
  80. Position = "0 0";
  81. Extent = "330 380";
  82. MinExtent = "200 100";
  83. text = "Asset Library";
  84. canMove = true;
  85. canClose = false;
  86. canMinimize = true;
  87. canMaximize = false;
  88. resizeWidth = true;
  89. resizeHeight = true;
  90. };
  91. ThemeManager.setProfile(%this.libWindow, "windowProfile");
  92. ThemeManager.setProfile(%this.libWindow, "windowContentProfile", "ContentProfile");
  93. ThemeManager.setProfile(%this.libWindow, "windowButtonProfile", "CloseButtonProfile");
  94. ThemeManager.setProfile(%this.libWindow, "windowButtonProfile", "MinButtonProfile");
  95. ThemeManager.setProfile(%this.libWindow, "windowButtonProfile", "MaxButtonProfile");
  96. %this.content.add(%this.libWindow);
  97. %this.libScroller = new GuiScrollCtrl()
  98. {
  99. HorizSizing = "width";
  100. VertSizing = "height";
  101. Position="0 0";
  102. Extent="324 356";
  103. MinExtent="0 0";
  104. hScrollBar="dynamic";
  105. vScrollBar="alwaysOn";
  106. constantThumbHeight="0";
  107. showArrowButtons="1";
  108. scrollBarThickness="14";
  109. };
  110. ThemeManager.setProfile(%this.libScroller, "scrollingPanelProfile");
  111. ThemeManager.setProfile(%this.libScroller, "scrollingPanelThumbProfile", ThumbProfile);
  112. ThemeManager.setProfile(%this.libScroller, "scrollingPanelTrackProfile", TrackProfile);
  113. ThemeManager.setProfile(%this.libScroller, "scrollingPanelArrowProfile", ArrowProfile);
  114. %this.libWindow.add(%this.libScroller);
  115. %this.dictionaryList = new GuiChainCtrl()
  116. {
  117. HorizSizing="width";
  118. VertSizing="height";
  119. Position="0 0";
  120. Extent="310 768";
  121. MinExtent="220 200";
  122. };
  123. ThemeManager.setProfile(%this.dictionaryList, "emptyProfile");
  124. %this.libScroller.add(%this.dictionaryList);
  125. %this.dictionaryList.add(%this.buildDictionary("Images", "ImageAsset"));
  126. %this.dictionaryList.add(%this.buildDictionary("Animations", "AnimationAsset"));
  127. %this.dictionaryList.add(%this.buildDictionary("Particle Effects", "ParticleAsset"));
  128. %this.dictionaryList.add(%this.buildDictionary("Fonts", "FontAsset"));
  129. %this.dictionaryList.add(%this.buildDictionary("Audio", "AudioAsset"));
  130. //%this.dictionaryList.add(%this.buildDictionary("Spines", "SpineAsset"));
  131. }
  132. function AssetAdmin::buildDictionary(%this, %title, %type)
  133. {
  134. %this.Dictionary[%type] = new GuiPanelCtrl()
  135. {
  136. Class = AssetDictionary;
  137. Text=%title;
  138. command="";
  139. HorizSizing="width";
  140. VertSizing="bottom";
  141. Position="0 0";
  142. Extent="306 22";
  143. MinExtent="80 22";
  144. Type = %type;
  145. };
  146. %this.Dictionary[%type].setExpandEase("EaseInOut", 1000);
  147. ThemeManager.setProfile(%this.Dictionary[%type], "panelProfile");
  148. return %this.Dictionary[%type];
  149. }
  150. function AssetAdmin::buildInspector(%this)
  151. {
  152. %this.inspectorWindow = new GuiWindowCtrl()
  153. {
  154. HorizSizing = "right";
  155. VertSizing = "bottom";
  156. text = "Asset Inspector";
  157. Extent = "706 380";
  158. MinExtent = "500 250";
  159. canMove = true;
  160. canClose = false;
  161. canMinimize = true;
  162. canMaximize = false;
  163. resizeWidth = true;
  164. resizeHeight = true;
  165. };
  166. ThemeManager.setProfile(%this.inspectorWindow, "windowProfile");
  167. ThemeManager.setProfile(%this.inspectorWindow, "windowContentProfile", "ContentProfile");
  168. ThemeManager.setProfile(%this.inspectorWindow, "windowButtonProfile", "CloseButtonProfile");
  169. ThemeManager.setProfile(%this.inspectorWindow, "windowButtonProfile", "MinButtonProfile");
  170. ThemeManager.setProfile(%this.inspectorWindow, "windowButtonProfile", "MaxButtonProfile");
  171. %this.content.add(%this.inspectorWindow);
  172. %this.inspector = new GuiControl()
  173. {
  174. class = "AssetInspector";
  175. Extent="700 370";
  176. HorizSizing = "fill";
  177. VertSizing = "fill";
  178. };
  179. ThemeManager.setProfile(%this.inspector, "overlayProfile");
  180. %this.inspectorWindow.add(%this.inspector);
  181. }
  182. function AssetAdmin::buildAssetWindow(%this)
  183. {
  184. %this.background = new GuiSpriteCtrl() {
  185. HorizSizing = "right";
  186. VertSizing = "bottom";
  187. Position = "0 0";
  188. Extent = "100 100";
  189. imageColor = "255 255 255 255";
  190. Image = "EditorCore:editorGrid";
  191. singleFrameBitmap = "1";
  192. tileImage = "1";
  193. positionOffset = "0 0";
  194. imageSize = "128 128";
  195. fullSize = "0";
  196. constrainProportions = "1";
  197. };
  198. ThemeManager.setProfile(%this.background, "emptyProfile");
  199. %this.content.add(%this.background);
  200. %this.assetScene = new Scene();
  201. %this.assetScene.setScenePause(true);
  202. %this.assetWindow = new SceneWindow()
  203. {
  204. class = AssetWindow;
  205. profile = ThemeManager.activeTheme.overlayProfile;
  206. position = "0 0";
  207. extent = %this.background.extent;
  208. HorizSizing = "width";
  209. VertSizing = "height";
  210. minExtent = "0 0";
  211. cameraPosition = "0 0";
  212. cameraSize = "175 111";
  213. useWindowInputEvents = true;
  214. useObjectInputEvents = true;
  215. constantThumbHeight = false;
  216. scrollBarThickness = 14;
  217. showArrowButtons = false;
  218. };
  219. ThemeManager.setProfile(%this.assetWindow, "thumbProfile", ThumbProfile);
  220. ThemeManager.setProfile(%this.assetWindow, "trackProfile", TrackProfile);
  221. ThemeManager.setProfile(%this.assetWindow, "scrollArrowProfile", ArrowProfile);
  222. %this.assetWindow.setScene(%this.assetScene);
  223. %this.assetWindow.setViewLimitOn("-87.5 -55.5 87.5 55.5");
  224. %this.assetWindow.setShowScrollBar(true);
  225. %this.assetWindow.setMouseWheelScrolls(false);
  226. %this.background.add(%this.assetWindow);
  227. }
  228. function AssetAdmin::buildAudioPlayButton(%this)
  229. {
  230. %this.audioPlayButtonContainer = new GuiControl()
  231. {
  232. position = "0 0";
  233. extent = %this.background.extent;
  234. HorizSizing="width";
  235. VertSizing="height";
  236. Visible="0";
  237. };
  238. ThemeManager.setProfile(%this.audioPlayButtonContainer, "emptyProfile");
  239. %this.audioPlayButton = new GuiButtonCtrl()
  240. {
  241. class="AssetAudioPlayButton";
  242. HorizSizing="center";
  243. VertSizing="center";
  244. Extent="100 48";
  245. Text = "Play";
  246. };
  247. ThemeManager.setProfile(%this.audioPlayButton, "buttonProfile");
  248. %this.audioPlayButtonContainer.add(%this.audioPlayButton);
  249. %this.background.add(%this.audioPlayButtonContainer);
  250. }
  251. function AssetAdmin::destroy(%this)
  252. {
  253. }
  254. function AssetAdmin::open(%this)
  255. {
  256. %this.Dictionary["ImageAsset"].load();
  257. %this.Dictionary["AnimationAsset"].load();
  258. %this.Dictionary["ParticleAsset"].load();
  259. %this.Dictionary["FontAsset"].load();
  260. %this.Dictionary["AudioAsset"].load();
  261. //%this.Dictionary["SpineAsset"].load();
  262. %this.assetScene.setScenePause(false);
  263. %this.isOpen = true;
  264. }
  265. function AssetAdmin::close(%this)
  266. {
  267. %this.Dictionary["ImageAsset"].unload();
  268. %this.Dictionary["AnimationAsset"].unload();
  269. %this.Dictionary["ParticleAsset"].unload();
  270. %this.Dictionary["FontAsset"].unload();
  271. %this.Dictionary["AudioAsset"].unload();
  272. //%this.Dictionary["SpineAsset"].unload();
  273. %this.assetScene.setScenePause(true);
  274. %this.isOpen = false;
  275. }
  276. function AssetBase::onRefresh(%this)
  277. {
  278. if(AssetAdmin.isOpen && isObject(AssetAdmin.chosenButton))
  279. {
  280. AssetAdmin.chosenButton.onClick();
  281. }
  282. }