riverEditorGui.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 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. $River::EditorOpen = false;
  23. $River::wireframe = true;
  24. $River::showSpline = true;
  25. $River::showRiver = true;
  26. $River::showWalls = true;
  27. function RiverEditorGui::onEditorActivated( %this )
  28. {
  29. %count = EWorldEditor.getSelectionSize();
  30. for ( %i = 0; %i < %count; %i++ )
  31. {
  32. %obj = EWorldEditor.getSelectedObject(%i);
  33. if ( %obj.getClassName() !$= "River" )
  34. EWorldEditor.unselectObject( %obj );
  35. else
  36. %this.setSelectedRiver( %obj );
  37. }
  38. %this.onRiverSelected( %this.getSelectedRiver() );
  39. %this.onNodeSelected(-1);
  40. }
  41. function RiverEditorGui::onEditorDeactivated( %this )
  42. {
  43. }
  44. function RiverEditorGui::createRiver( %this )
  45. {
  46. %river = new River()
  47. {
  48. rippleDir[0] = "0.000000 1.000000";
  49. rippleDir[1] = "0.707000 0.707000";
  50. rippleDir[2] = "0.500000 0.860000";
  51. rippleSpeed[0] = "-0.065";
  52. rippleSpeed[1] = "0.09";
  53. rippleSpeed[2] = "0.04";
  54. rippleTexScale[0] = "7.140000 7.140000";
  55. rippleTexScale[1] = "6.250000 12.500000";
  56. rippleTexScale[2] = "50.000000 50.000000";
  57. waveDir[0] = "0.000000 1.000000";
  58. waveDir[1] = "0.707000 0.707000";
  59. waveDir[2] = "0.500000 0.860000";
  60. waveSpeed[0] = "1";
  61. waveSpeed[1] = "1";
  62. waveSpeed[2] = "1";
  63. waveMagnitude[0] = "0.2";
  64. waveMagnitude[1] = "0.2";
  65. waveMagnitude[2] = "0.2";
  66. baseColor = "45 108 171 255";
  67. rippleTex = "art/water/ripple.dds";
  68. foamTex = "art/water/foam";
  69. depthGradientTex = "art/water/depthcolor_ramp";
  70. };
  71. return %river;
  72. }
  73. function RiverEditorGui::paletteSync( %this, %mode )
  74. {
  75. %evalShortcut = "ToolsPaletteArray-->" @ %mode @ ".setStateOn(1);";
  76. eval(%evalShortcut);
  77. }
  78. function RiverEditorGui::onEscapePressed( %this )
  79. {
  80. if( %this.getMode() $= "RiverEditorAddNodeMode" )
  81. {
  82. %this.prepSelectionMode();
  83. return true;
  84. }
  85. return false;
  86. }
  87. function RiverEditorGui::onRiverSelected( %this, %river )
  88. {
  89. %this.river = %river;
  90. RiverInspector.inspect( %river );
  91. RiverTreeView.buildVisibleTree(true);
  92. if( RiverTreeView.getSelectedObject() != %river )
  93. {
  94. RiverTreeView.clearSelection();
  95. %treeId = RiverTreeView.findItemByObjectId( %river );
  96. RiverTreeView.selectItem( %treeId );
  97. }
  98. }
  99. function RiverEditorGui::onNodeSelected( %this, %nodeIdx )
  100. {
  101. if ( %nodeIdx == -1 )
  102. {
  103. RiverEditorOptionsWindow-->position.setActive( false );
  104. RiverEditorOptionsWindow-->position.setValue( "" );
  105. RiverEditorOptionsWindow-->rotation.setActive( false );
  106. RiverEditorOptionsWindow-->rotation.setValue( "" );
  107. RiverEditorOptionsWindow-->width.setActive( false );
  108. RiverEditorOptionsWindow-->width.setValue( "" );
  109. RiverEditorOptionsWindow-->depth.setActive( false );
  110. RiverEditorOptionsWindow-->depth.setValue( "" );
  111. }
  112. else
  113. {
  114. RiverEditorOptionsWindow-->position.setActive( true );
  115. RiverEditorOptionsWindow-->position.setValue( %this.getNodePosition() );
  116. RiverEditorOptionsWindow-->rotation.setActive( true );
  117. RiverEditorOptionsWindow-->rotation.setValue( %this.getNodeNormal() );
  118. RiverEditorOptionsWindow-->width.setActive( true );
  119. RiverEditorOptionsWindow-->width.setValue( %this.getNodeWidth() );
  120. RiverEditorOptionsWindow-->depth.setActive( true );
  121. RiverEditorOptionsWindow-->depth.setValue( %this.getNodeDepth() );
  122. }
  123. }
  124. function RiverEditorGui::onNodeModified( %this, %nodeIdx )
  125. {
  126. RiverEditorOptionsWindow-->position.setValue( %this.getNodePosition() );
  127. RiverEditorOptionsWindow-->rotation.setValue( %this.getNodeNormal() );
  128. RiverEditorOptionsWindow-->width.setValue( %this.getNodeWidth() );
  129. RiverEditorOptionsWindow-->depth.setValue( %this.getNodeDepth() );
  130. }
  131. function RiverEditorGui::editNodeDetails( %this )
  132. {
  133. %this.setNodePosition( RiverEditorOptionsWindow-->position.getText() );
  134. %this.setNodeNormal( RiverEditorOptionsWindow-->rotation.getText() );
  135. %this.setNodeWidth( RiverEditorOptionsWindow-->width.getText() );
  136. %this.setNodeDepth( RiverEditorOptionsWindow-->depth.getText() );
  137. }
  138. function RiverInspector::inspect( %this, %obj )
  139. {
  140. %name = "";
  141. if ( isObject( %obj ) )
  142. %name = %obj.getName();
  143. else
  144. RiverFieldInfoControl.setText( "" );
  145. //RiverInspectorNameEdit.setValue( %name );
  146. Parent::inspect( %this, %obj );
  147. }
  148. function RiverInspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue )
  149. {
  150. // Same work to do as for the regular WorldEditor Inspector.
  151. Inspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue );
  152. }
  153. function RiverInspector::onFieldSelected( %this, %fieldName, %fieldTypeStr, %fieldDoc )
  154. {
  155. RiverFieldInfoControl.setText( "<font:ArialBold:14>" @ %fieldName @ "<font:ArialItalic:14> (" @ %fieldTypeStr @ ") " NL "<font:Arial:14>" @ %fieldDoc );
  156. }
  157. function RiverTreeView::onInspect(%this, %obj)
  158. {
  159. RiverInspector.inspect(%obj);
  160. }
  161. function RiverTreeView::onSelect(%this, %obj)
  162. {
  163. RiverEditorGui.road = %obj;
  164. RiverInspector.inspect( %obj );
  165. if(%obj != RiverEditorGui.getSelectedRiver())
  166. {
  167. RiverEditorGui.setSelectedRiver( %obj );
  168. }
  169. }
  170. function RiverEditorGui::prepSelectionMode( %this )
  171. {
  172. %mode = %this.getMode();
  173. if ( %mode $= "RiverEditorAddNodeMode" )
  174. {
  175. if ( isObject( %this.getSelectedRiver() ) )
  176. %this.deleteNode();
  177. }
  178. %this.setMode( "RiverEditorSelectMode" );
  179. ToolsPaletteArray-->RiverEditorSelectMode.setStateOn(1);
  180. }
  181. //------------------------------------------------------------------------------
  182. function ERiverEditorSelectModeBtn::onClick(%this)
  183. {
  184. EditorGuiStatusBar.setInfo(%this.ToolTip);
  185. }
  186. function ERiverEditorAddModeBtn::onClick(%this)
  187. {
  188. EditorGuiStatusBar.setInfo(%this.ToolTip);
  189. }
  190. function ERiverEditorMoveModeBtn::onClick(%this)
  191. {
  192. EditorGuiStatusBar.setInfo(%this.ToolTip);
  193. }
  194. function ERiverEditorRotateModeBtn::onClick(%this)
  195. {
  196. EditorGuiStatusBar.setInfo(%this.ToolTip);
  197. }
  198. function ERiverEditorScaleModeBtn::onClick(%this)
  199. {
  200. EditorGuiStatusBar.setInfo(%this.ToolTip);
  201. }
  202. function ERiverEditorInsertModeBtn::onClick(%this)
  203. {
  204. EditorGuiStatusBar.setInfo(%this.ToolTip);
  205. }
  206. function ERiverEditorRemoveModeBtn::onClick(%this)
  207. {
  208. EditorGuiStatusBar.setInfo(%this.ToolTip);
  209. }
  210. function RiverDefaultWidthSliderCtrlContainer::onWake(%this)
  211. {
  212. RiverDefaultWidthSliderCtrlContainer-->slider.setValue(RiverDefaultWidthTextEditContainer-->textEdit.getText());
  213. }
  214. function RiverDefaultDepthSliderCtrlContainer::onWake(%this)
  215. {
  216. RiverDefaultDepthSliderCtrlContainer-->slider.setValue(RiverDefaultDepthTextEditContainer-->textEdit.getText());
  217. }