AssetAdmin.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. %this.guiPage = EditorCore.RegisterEditor("Asset Manager", %this);
  38. %this.guiPage.add(%this.buildAssetWindow());
  39. %this.guiPage.add(%this.buildAudioPlayButton());
  40. %this.guiPage.add(%this.buildLibrary());
  41. %this.guiPage.add(%this.buildInspector());
  42. EditorCore.FinishRegistration(%this.guiPage);
  43. %this.isOpen = false;
  44. }
  45. function AssetAdmin::buildLibrary(%this)
  46. {
  47. %this.libScroller = new GuiScrollCtrl()
  48. {
  49. HorizSizing="left";
  50. VertSizing="height";
  51. Position="700 0";
  52. Extent="324 768";
  53. MinExtent="162 384";
  54. hScrollBar="dynamic";
  55. vScrollBar="alwaysOn";
  56. constantThumbHeight="0";
  57. showArrowButtons="1";
  58. scrollBarThickness="14";
  59. };
  60. ThemeManager.setProfile(%this.libScroller, "scrollingPanelProfile");
  61. ThemeManager.setProfile(%this.libScroller, "scrollingPanelThumbProfile", ThumbProfile);
  62. ThemeManager.setProfile(%this.libScroller, "scrollingPanelTrackProfile", TrackProfile);
  63. ThemeManager.setProfile(%this.libScroller, "scrollingPanelArrowProfile", ArrowProfile);
  64. %this.dictionaryList = new GuiChainCtrl()
  65. {
  66. HorizSizing="right";
  67. VertSizing="bottom";
  68. Position="0 0";
  69. Extent="310 768";
  70. MinExtent="220 200";
  71. };
  72. ThemeManager.setProfile(%this.dictionaryList, "emptyProfile");
  73. %this.libScroller.add(%this.dictionaryList);
  74. %this.dictionaryList.add(%this.buildDictionary("Images", "ImageAsset"));
  75. %this.dictionaryList.add(%this.buildDictionary("Animations", "AnimationAsset"));
  76. %this.dictionaryList.add(%this.buildDictionary("Particle Effects", "ParticleAsset"));
  77. %this.dictionaryList.add(%this.buildDictionary("Fonts", "FontAsset"));
  78. %this.dictionaryList.add(%this.buildDictionary("Audio", "AudioAsset"));
  79. //%this.dictionaryList.add(%this.buildDictionary("Spines", "SpineAsset"));
  80. return %this.libScroller;
  81. }
  82. function AssetAdmin::buildDictionary(%this, %title, %type)
  83. {
  84. %this.Dictionary[%type] = new GuiPanelCtrl()
  85. {
  86. Class = AssetDictionary;
  87. Text=%title;
  88. command="";
  89. HorizSizing="right";
  90. VertSizing="bottom";
  91. Position="0 0";
  92. Extent="310 22";
  93. MinExtent="80 22";
  94. Type = %type;
  95. };
  96. %this.Dictionary[%type].setExpandEase("EaseInOut", 1000);
  97. ThemeManager.setProfile(%this.Dictionary[%type], "panelProfile");
  98. return %this.Dictionary[%type];
  99. }
  100. function AssetAdmin::buildInspector(%this)
  101. {
  102. %this.inspector = new GuiControl()
  103. {
  104. class = "AssetInspector";
  105. HorizSizing="width";
  106. VertSizing="top";
  107. Position="0 444";
  108. Extent="700 324";
  109. MinExtent="350 222";
  110. };
  111. ThemeManager.setProfile(%this.inspector, "overlayProfile");
  112. return %this.inspector;
  113. }
  114. function AssetAdmin::buildAssetWindow(%this)
  115. {
  116. %this.assetScene = new Scene();
  117. %this.assetScene.setScenePause(true);
  118. %this.assetWindow = new SceneWindow()
  119. {
  120. class = AssetWindow;
  121. profile = ThemeManager.activeTheme.overlayProfile;
  122. position = "0 0";
  123. extent = "700 444";
  124. HorizSizing="width";
  125. VertSizing="height";
  126. minExtent = "0 0";
  127. cameraPosition = "0 0";
  128. cameraSize = "175 111";
  129. useWindowInputEvents = true;
  130. useObjectInputEvents = true;
  131. constantThumbHeight = false;
  132. scrollBarThickness = 14;
  133. showArrowButtons = false;
  134. };
  135. ThemeManager.setProfile(%this.assetWindow, "thumbProfile", ThumbProfile);
  136. ThemeManager.setProfile(%this.assetWindow, "trackProfile", TrackProfile);
  137. ThemeManager.setProfile(%this.assetWindow, "scrollArrowProfile", ArrowProfile);
  138. %this.assetWindow.setScene(%this.assetScene);
  139. %this.assetWindow.setViewLimitOn("-87.5 -55.5 87.5 55.5");
  140. %this.assetWindow.setShowScrollBar(true);
  141. %this.assetWindow.setMouseWheelScrolls(false);
  142. return %this.assetWindow;
  143. }
  144. function AssetAdmin::buildAudioPlayButton(%this)
  145. {
  146. %this.audioPlayButtonContainer = new GuiControl()
  147. {
  148. position = "0 0";
  149. extent = "700 444";
  150. HorizSizing="width";
  151. VertSizing="height";
  152. Visible="0";
  153. };
  154. ThemeManager.setProfile(%this.audioPlayButtonContainer, "emptyProfile");
  155. %this.audioPlayButton = new GuiButtonCtrl()
  156. {
  157. class="AssetAudioPlayButton";
  158. HorizSizing="center";
  159. VertSizing="center";
  160. Extent="100 48";
  161. Text = "Play";
  162. };
  163. ThemeManager.setProfile(%this.audioPlayButton, "buttonProfile");
  164. %this.audioPlayButtonContainer.add(%this.audioPlayButton);
  165. return %this.audioPlayButtonContainer;
  166. }
  167. function AssetAdmin::destroy(%this)
  168. {
  169. }
  170. function AssetAdmin::open(%this)
  171. {
  172. %this.Dictionary["ImageAsset"].load();
  173. %this.Dictionary["AnimationAsset"].load();
  174. %this.Dictionary["ParticleAsset"].load();
  175. %this.Dictionary["FontAsset"].load();
  176. %this.Dictionary["AudioAsset"].load();
  177. //%this.Dictionary["SpineAsset"].load();
  178. %this.assetScene.setScenePause(false);
  179. %this.isOpen = true;
  180. }
  181. function AssetAdmin::close(%this)
  182. {
  183. %this.Dictionary["ImageAsset"].unload();
  184. %this.Dictionary["AnimationAsset"].unload();
  185. %this.Dictionary["ParticleAsset"].unload();
  186. %this.Dictionary["FontAsset"].unload();
  187. %this.Dictionary["AudioAsset"].unload();
  188. //%this.Dictionary["SpineAsset"].unload();
  189. %this.assetScene.setScenePause(true);
  190. %this.isOpen = false;
  191. }
  192. function AssetBase::onRefresh(%this)
  193. {
  194. if(AssetAdmin.isOpen && isObject(AssetAdmin.chosenButton))
  195. {
  196. AssetAdmin.chosenButton.onClick();
  197. }
  198. }