AssetParticleGraphTool.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 AssetParticleGraphTool::onAdd(%this)
  23. {
  24. %this.init();
  25. %this.addItem("Lifetime Scale");
  26. %this.addItem("Quantity Scale");
  27. %this.addItem("SizeX Scale");
  28. %this.addItem("SizeY Scale");
  29. %this.addItem("Speed Scale");
  30. %this.addItem("Spin Scale");
  31. %this.addItem("Fixed Force Scale");
  32. %this.addItem("Random Motion Scale");
  33. %this.addItem("Alpha Channel Scale");
  34. }
  35. function AssetParticleGraphEmitterTool::onAdd(%this)
  36. {
  37. %this.init();
  38. %this.initEmitter();
  39. %this.addItem("Lifetime");
  40. %this.addItem("Quantity");
  41. %this.addItem("SizeX");
  42. %this.addItem("SizeY");
  43. %this.addItem("Speed");
  44. %this.addItem("Spin");
  45. %this.addItem("Fixed Force");
  46. %this.addItem("Random Motion");
  47. %this.addItem("Emission Force");
  48. %this.addItem("Emission Angle");
  49. %this.addItem("Emission Arc");
  50. %this.addItem("Red Channel");
  51. %this.addItem("Green Channel");
  52. %this.addItem("Blue Channel");
  53. %this.addItem("Alpha Channel");
  54. }
  55. function AssetParticleGraphTool::init(%this)
  56. {
  57. %this.listScroll = new GuiScrollCtrl()
  58. {
  59. HorizSizing="right";
  60. VertSizing="height";
  61. Position="0 0";
  62. Extent="200" SPC getWord(%this.extent, 1);
  63. hScrollBar="alwaysOff";
  64. vScrollBar="alwaysOn";
  65. constantThumbHeight="0";
  66. showArrowButtons="1";
  67. scrollBarThickness="14";
  68. };
  69. ThemeManager.setProfile(%this.listScroll, "scrollingPanelProfile");
  70. ThemeManager.setProfile(%this.listScroll, "scrollingPanelThumbProfile", "ThumbProfile");
  71. ThemeManager.setProfile(%this.listScroll, "scrollingPanelTrackProfile", "TrackProfile");
  72. ThemeManager.setProfile(%this.listScroll, "scrollingPanelArrowProfile", "ArrowProfile");
  73. %this.add(%this.listScroll);
  74. %this.baseList = new GuiListBoxCtrl()
  75. {
  76. Class = "AssetParticleGraphToolList";
  77. HorizSizing="width";
  78. VertSizing="height";
  79. Position="0 0";
  80. Extent= "200 100";
  81. hScrollBar="dynamic";
  82. vScrollBar="dynamic";
  83. };
  84. %this.startListening(%this.baseList);
  85. ThemeManager.setProfile(%this.baseList, "listBoxProfile");
  86. %this.listScroll.add(%this.baseList);
  87. %this.toolScroll = new GuiScrollCtrl()
  88. {
  89. HorizSizing="width";
  90. VertSizing="height";
  91. Position="200 0";
  92. Extent= (getWord(%this.extent, 0) - 200) SPC getWord(%this.extent, 1);
  93. hScrollBar="dynamic";
  94. vScrollBar="dynamic";
  95. constantThumbHeight="0";
  96. showArrowButtons="1";
  97. scrollBarThickness="14";
  98. };
  99. ThemeManager.setProfile(%this.toolScroll, "scrollingPanelProfile");
  100. ThemeManager.setProfile(%this.toolScroll, "scrollingPanelThumbProfile", "ThumbProfile");
  101. ThemeManager.setProfile(%this.toolScroll, "scrollingPanelTrackProfile", "TrackProfile");
  102. ThemeManager.setProfile(%this.toolScroll, "scrollingPanelArrowProfile", "ArrowProfile");
  103. %this.add(%this.toolScroll);
  104. %itemWidth = 360;
  105. %this.toolGrid = new GuiGridCtrl()
  106. {
  107. HorizSizing="width";
  108. VertSizing="height";
  109. Position="0 0";
  110. Extent = (getWord(%this.toolScroll.Extent, 0) - 14) SPC getWord(%this.extent, 1);
  111. CellSizeX = %itemWidth;
  112. CellSizeY = 0;
  113. CellModeX = variable;
  114. CellModeY = variable;
  115. CellSpacingX = 4;
  116. CellSpacingY = 4;
  117. OrderMode = "LRTB";
  118. };
  119. ThemeManager.setProfile(%this.toolGrid, "emptyProfile");
  120. %this.toolScroll.add(%this.toolGrid);
  121. %this.baseGraph = new GuiControl()
  122. {
  123. Class = "AssetParticleGraphUnit";
  124. HorizSizing="right";
  125. VertSizing="bottom";
  126. Position="0 0";
  127. Extent= %itemWidth SPC (getWord(%this.extent, 1) - 30);
  128. Text = "Base Value";
  129. };
  130. ThemeManager.setProfile(%this.baseGraph, "labelProfile");
  131. %this.toolGrid.add(%this.baseGraph);
  132. }
  133. function AssetParticleGraphEmitterTool::initEmitter(%this)
  134. {
  135. %this.variGraph = new GuiControl()
  136. {
  137. Class = "AssetParticleGraphUnit";
  138. HorizSizing="right";
  139. VertSizing="bottom";
  140. Position="0 0";
  141. Extent= %itemWidth SPC (getWord(%this.extent, 1) - 30);
  142. Text = "Variation";
  143. Tool = %this.toolGrid;
  144. };
  145. ThemeManager.setProfile(%this.variGraph, "labelProfile");
  146. %this.toolGrid.add(%this.variGraph);
  147. %this.baseGraph.setVarianceGraph(%this.variGraph);
  148. %this.lifeGraph = new GuiControl()
  149. {
  150. Class = "AssetParticleGraphUnit";
  151. HorizSizing="right";
  152. VertSizing="bottom";
  153. Position="0 0";
  154. Extent= %itemWidth SPC (getWord(%this.extent, 1) - 30);
  155. Text = "Scale Over Particle Lifetime";
  156. Tool = %this.toolGrid;
  157. };
  158. ThemeManager.setProfile(%this.lifeGraph, "labelProfile");
  159. %this.toolGrid.add(%this.lifeGraph);
  160. }
  161. function AssetParticleGraphTool::addItem(%this, %item, %color)
  162. {
  163. if(%color !$= "")
  164. {
  165. %this.baseList.addItem(%item, %color);
  166. }
  167. else
  168. {
  169. %this.baseList.addItem(%item);
  170. }
  171. }
  172. function AssetParticleGraphTool::inspect(%this, %asset, %emitterID)
  173. {
  174. %this.asset = %asset;
  175. %this.baseGraph.graph.inspect(%asset);
  176. if(isObject(%this.variGraph))
  177. {
  178. %this.variGraph.graph.inspect(%asset);
  179. }
  180. if(isObject(%this.lifeGraph))
  181. {
  182. %this.lifeGraph.graph.inspect(%asset);
  183. }
  184. %this.baseList.clearSelection();
  185. %this.emitterID = %emitterID;
  186. %this.baseList.setCurSel(0);
  187. }
  188. function AssetParticleGraphToolList::onSelect(%this, %index, %text, %id)
  189. {
  190. %this.postEvent("Select", %index);
  191. }
  192. function AssetParticleGraphTool::onSelect(%this, %index)
  193. {
  194. %i = 0;
  195. %graphTable[%i] = "LifeTimeScale"; %i++;
  196. %graphTable[%i] = "QuantityScale"; %i++;
  197. %graphTable[%i] = "SizeXScale"; %i++;
  198. %graphTable[%i] = "SizeYScale"; %i++;
  199. %graphTable[%i] = "SpeedScale"; %i++;
  200. %graphTable[%i] = "SpinScale"; %i++;
  201. %graphTable[%i] = "FixedForceScale"; %i++;
  202. %graphTable[%i] = "RandomMotionScale"; %i++;
  203. %graphTable[%i] = "AlphaChannelScale";
  204. %name = %graphTable[%index];
  205. %this.baseGraph.setToScale(%name);
  206. %this.baseGraph.setValueController(%this.getValueController(%name));
  207. %this.baseGraph.setTimeController(%this.getTimeController(%name));
  208. }
  209. function AssetParticleGraphTool::getValueController(%this, %name)
  210. {
  211. if(%name $= "")
  212. {
  213. return "";
  214. }
  215. return new ScriptObject()
  216. {
  217. class = ParticleGraphCameraController;
  218. fieldName = %name;
  219. isTime = false;
  220. asset = %this.asset;
  221. };
  222. }
  223. function AssetParticleGraphTool::getTimeController(%this, %name)
  224. {
  225. if(%name $= "")
  226. {
  227. return "";
  228. }
  229. return new ScriptObject()
  230. {
  231. class = ParticleGraphCameraController;
  232. fieldName = %name;
  233. isTime = true;
  234. asset = %this.asset;
  235. };
  236. }
  237. function AssetParticleGraphEmitterTool::onSelect(%this, %index)
  238. {
  239. %i = 0;
  240. %graphTable[%i] = "Lifetime"; %i++;
  241. %graphTable[%i] = "Quantity"; %i++;
  242. %graphTable[%i] = "SizeX"; %i++;
  243. %graphTable[%i] = "SizeY"; %i++;
  244. %graphTable[%i] = "Speed"; %i++;
  245. %graphTable[%i] = "Spin"; %i++;
  246. %graphTable[%i] = "FixedForce"; %i++;
  247. %graphTable[%i] = "RandomMotion"; %i++;
  248. %graphTable[%i] = "EmissionForce"; %i++;
  249. %graphTable[%i] = "EmissionAngle"; %i++;
  250. %graphTable[%i] = "EmissionArc"; %i++;
  251. %graphTable[%i] = "RedChannel"; %i++;
  252. %graphTable[%i] = "GreenChannel"; %i++;
  253. %graphTable[%i] = "BlueChannel"; %i++;
  254. %graphTable[%i] = "AlphaChannel";
  255. for(%i = 0; %i < 11; %i++)
  256. {
  257. %varTable[%i] = %graphTable[%i] @ "Variation";
  258. }
  259. for(%i = 2; %i < 8; %i++)
  260. {
  261. %lifeTable[%i] = %graphTable[%i] @ "Life";
  262. }
  263. %name = %graphTable[%index];
  264. %this.baseGraph.setToBase(%name, %varTable[%index], %this.emitterID);
  265. %this.baseGraph.setValueController(%this.getValueController(%name));
  266. %this.baseGraph.setTimeController(%this.getTimeController(%name));
  267. %name = %varTable[%index];
  268. %this.variGraph.setToVari( %name, %this.emitterID);
  269. %this.variGraph.setValueController(%this.getValueController(%name));
  270. %this.variGraph.setTimeController(%this.getTimeController(%name));
  271. %name = %lifeTable[%index];
  272. %this.lifeGraph.setToLife( %name, %this.emitterID);
  273. %this.lifeGraph.setValueController(%this.getValueController(%name));
  274. %this.lifeGraph.setTimeController(%this.getTimeController(%name));
  275. }