AssetAdmin.cs 6.7 KB

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