AssetParticleGraphUnit.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. function AssetParticleGraphUnit::onAdd(%this)
  2. {
  3. %this.graph = new GuiParticleGraphInspector()
  4. {
  5. HorizSizing="width";
  6. VertSizing="height";
  7. Position="30 18";
  8. Extent= (getWord(%this.extent, 0) - 40) SPC (getWord(%this.extent, 1) - 60);
  9. };
  10. ThemeManager.setProfile(%this.graph, "graphProfile");
  11. %this.add(%this.graph);
  12. //Value zoom buttons
  13. %center = 6 + mRound(getWord(%this.graph.extent, 1) / 2);
  14. %this.valueZoomInButton = new GuiButtonCtrl()
  15. {
  16. Class = "EditorIconButton";
  17. Frame = 0;
  18. Position = "2" SPC (%center + 13);
  19. Command = %this.getId() @ ".valueZoomIn();";
  20. Tooltip = "Zoom In";
  21. };
  22. ThemeManager.setProfile(%this.valueZoomInButton, "iconButtonProfile");
  23. %this.add(%this.valueZoomInButton);
  24. %this.valueZoomOutButton = new GuiButtonCtrl()
  25. {
  26. Class = "EditorIconButton";
  27. Frame = 1;
  28. Position = "2" SPC (%center - 13);
  29. Command = %this.getId() @ ".valueZoomOut();";
  30. Tooltip = "Zoom Out";
  31. };
  32. ThemeManager.setProfile(%this.valueZoomOutButton, "iconButtonProfile");
  33. %this.add(%this.valueZoomOutButton);
  34. //Value move buttons
  35. %this.valueMoveUpButton = new GuiButtonCtrl()
  36. {
  37. Class = "EditorIconButton";
  38. Frame = 2;
  39. Position = "2 18";
  40. Command = %this.getId() @ ".valueMoveUp();";
  41. Tooltip = "Move Graph Up";
  42. };
  43. ThemeManager.setProfile(%this.valueMoveUpButton, "iconButtonProfile");
  44. %this.add(%this.valueMoveUpButton);
  45. %this.valueMoveDownButton = new GuiButtonCtrl()
  46. {
  47. Class = "EditorIconButton";
  48. Frame = 6;
  49. Position = "2" SPC (getWord(%this.extent, 1) - 66);
  50. Command = %this.getId() @ ".valueMoveDown();";
  51. Tooltip = "Move Graph Down";
  52. };
  53. ThemeManager.setProfile(%this.valueMoveDownButton, "iconButtonProfile");
  54. %this.add(%this.valueMoveDownButton);
  55. //time zoom buttons
  56. %center = 18 + mRound(getWord(%this.graph.extent, 0));
  57. %bottom = getWord(%this.extent, 1) - 38;
  58. %this.timeZoomContainer = new GuiControl()
  59. {
  60. HorizSizing = "Center";
  61. Position = "0" SPC %bottom;
  62. Extent = "50 24";
  63. };
  64. ThemeManager.setProfile(%this.timeZoomContainer, "emptyProfile");
  65. %this.add(%this.timeZoomContainer);
  66. %this.timeZoomInButton = new GuiButtonCtrl()
  67. {
  68. Class = "EditorIconButton";
  69. Frame = 0;
  70. Position = "0 0";
  71. Command = %this.getId() @ ".timeZoomIn();";
  72. Tooltip = "Zoom In";
  73. };
  74. ThemeManager.setProfile(%this.timeZoomInButton, "iconButtonProfile");
  75. %this.timeZoomContainer.add(%this.timeZoomInButton);
  76. %this.timeZoomOutButton = new GuiButtonCtrl()
  77. {
  78. Class = "EditorIconButton";
  79. Frame = 1;
  80. Position = "26 0";
  81. Command = %this.getId() @ ".timeZoomOut();";
  82. Tooltip = "Zoom Out";
  83. };
  84. ThemeManager.setProfile(%this.timeZoomOutButton, "iconButtonProfile");
  85. %this.timeZoomContainer.add(%this.timeZoomOutButton);
  86. //Time move buttons
  87. %this.timeMoveBackButton = new GuiButtonCtrl()
  88. {
  89. Class = "EditorIconButton";
  90. Frame = 8;
  91. HorizSizing = "right";
  92. Position = "30" SPC %bottom;
  93. Command = %this.getId() @ ".timeMoveBack();";
  94. Tooltip = "Move Graph Back";
  95. };
  96. ThemeManager.setProfile(%this.timeMoveBackButton, "iconButtonProfile");
  97. %this.add(%this.timeMoveBackButton);
  98. %this.timeMoveForwardButton = new GuiButtonCtrl()
  99. {
  100. Class = "EditorIconButton";
  101. Frame = 4;
  102. HorizSizing = "left";
  103. Position = (getWord(%this.graph.extent, 0) + 6) SPC %bottom;
  104. Command = %this.getId() @ ".timeMoveForward();";
  105. Tooltip = "Move Graph Forward";
  106. };
  107. ThemeManager.setProfile(%this.timeMoveForwardButton, "iconButtonProfile");
  108. %this.add(%this.timeMoveForwardButton);
  109. }
  110. function AssetParticleGraphUnit::setToScale(%this, %scaleName)
  111. {
  112. %this.graph.setDisplayLabels("Time", "Scale");
  113. %this.graph.setDisplayField(%scaleName);
  114. }
  115. function AssetParticleGraphUnit::setToBase(%this, %baseName, %variName, %emitterID)
  116. {
  117. %this.graph.setDisplayLabels("Time", "Base Value");
  118. %this.graph.setDisplayField(%baseName, %emitterID);
  119. }
  120. function AssetParticleGraphUnit::setToVari(%this, %variName, %emitterID)
  121. {
  122. if(%variName $= "")
  123. {
  124. if(%this.Tool.isMember(%this))
  125. {
  126. %this.Tool.remove(%this);
  127. }
  128. return;
  129. }
  130. if(!%this.Tool.isMember(%this))
  131. {
  132. %this.Tool.add(%this);
  133. }
  134. %this.graph.setDisplayLabels("Time", "Variation");
  135. %this.graph.setDisplayField(%variName, %emitterID);
  136. }
  137. function AssetParticleGraphUnit::setToLife(%this, %lifeName, %emitterID)
  138. {
  139. if(%lifeName $= "")
  140. {
  141. if(%this.Tool.isMember(%this))
  142. {
  143. %this.Tool.remove(%this);
  144. }
  145. return;
  146. }
  147. if(!%this.Tool.isMember(%this))
  148. {
  149. %this.Tool.add(%this);
  150. }
  151. %this.graph.setDisplayLabels("Time", "Scale");
  152. %this.graph.setDisplayField(%lifeName, %emitterID);
  153. }
  154. function AssetParticleGraphUnit::setValueController(%this, %controller)
  155. {
  156. if(!isObject(%controller))
  157. {
  158. return;
  159. }
  160. if(isObject(%this.valueController))
  161. {
  162. %this.valueController.delete();
  163. }
  164. %this.valueController = %controller;
  165. %this.refreshCamera();
  166. }
  167. function AssetParticleGraphUnit::setTimeController(%this, %controller)
  168. {
  169. if(!isObject(%controller))
  170. {
  171. return;
  172. }
  173. if(isObject(%this.timeController))
  174. {
  175. %this.timeController.delete();
  176. }
  177. %this.timeController = %controller;
  178. %this.refreshCamera();
  179. }
  180. function AssetParticleGraphUnit::refreshCamera(%this)
  181. {
  182. if(!isObject(%this.timeController) || !isObject(%this.valueController))
  183. {
  184. return;
  185. }
  186. %xMin = %this.timeController.getCameraMin();
  187. %xMax = %this.timeController.getCameraMax();
  188. %yMin = %this.valueController.getCameraMin();
  189. %yMax = %this.valueController.getCameraMax();
  190. %this.graph.setDisplayArea(%xMin SPC %yMin SPC %xMax SPC %yMax);
  191. %this.valueMoveUpButton.setActive(%this.valueController.getMoveUpEnabled());
  192. %this.valueMoveDownButton.setActive(%this.valueController.getMoveDownEnabled());
  193. %this.valueZoomInButton.setActive(%this.valueController.getZoomInEnabled());
  194. %this.valueZoomOutButton.setActive(%this.valueController.getZoomOutEnabled());
  195. %this.timeMoveForwardButton.setActive(%this.timeController.getMoveUpEnabled());
  196. %this.timeMoveBackButton.setActive(%this.timeController.getMoveDownEnabled());
  197. %this.timeZoomInButton.setActive(%this.timeController.getZoomInEnabled());
  198. %this.timeZoomOutButton.setActive(%this.timeController.getZoomOutEnabled());
  199. }
  200. function AssetParticleGraphUnit::valueZoomIn(%this)
  201. {
  202. %this.valueController.zoomIn();
  203. %this.refreshCamera();
  204. }
  205. function AssetParticleGraphUnit::valueZoomOut(%this)
  206. {
  207. %this.valueController.zoomOut();
  208. %this.refreshCamera();
  209. }
  210. function AssetParticleGraphUnit::valueMoveUp(%this)
  211. {
  212. %this.valueController.moveUp();
  213. %this.refreshCamera();
  214. }
  215. function AssetParticleGraphUnit::valueMoveDown(%this)
  216. {
  217. %this.valueController.moveDown();
  218. %this.refreshCamera();
  219. }
  220. function AssetParticleGraphUnit::timeZoomIn(%this)
  221. {
  222. %this.timeController.zoomIn();
  223. %this.refreshCamera();
  224. }
  225. function AssetParticleGraphUnit::timeZoomOut(%this)
  226. {
  227. %this.timeController.zoomOut();
  228. %this.refreshCamera();
  229. }
  230. function AssetParticleGraphUnit::timeMoveBack(%this)
  231. {
  232. %this.timeController.moveDown();
  233. %this.refreshCamera();
  234. }
  235. function AssetParticleGraphUnit::timeMoveForward(%this)
  236. {
  237. %this.timeController.moveUp();
  238. %this.refreshCamera();
  239. }
  240. function AssetParticleGraphUnit::setVarianceGraph(%this, %variGraph)
  241. {
  242. %this.graph.setVariationGraphInspector(%variGraph.graph);
  243. }