meshRoadEditorGui.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. $MeshRoad::wireframe = true;
  23. $MeshRoad::showSpline = true;
  24. $MeshRoad::showReflectPlane = false;
  25. $MeshRoad::showRoad = true;
  26. $MeshRoad::breakAngle = 3.0;
  27. function MeshRoadEditorGui::onWake( %this )
  28. {
  29. $MeshRoad::EditorOpen = true;
  30. %count = EWorldEditor.getSelectionSize();
  31. for ( %i = 0; %i < %count; %i++ )
  32. {
  33. %obj = EWorldEditor.getSelectedObject(%i);
  34. if ( %obj.getClassName() !$= "MeshRoad" )
  35. EWorldEditor.unselectObject();
  36. else
  37. %this.setSelectedRoad( %obj );
  38. }
  39. //%this-->TabBook.selectPage(0);
  40. %this.onNodeSelected(-1);
  41. }
  42. function MeshRoadEditorGui::onSleep( %this )
  43. {
  44. $MeshRoad::EditorOpen = false;
  45. }
  46. function MeshRoadEditorGui::paletteSync( %this, %mode )
  47. {
  48. %evalShortcut = "ToolsPaletteArray-->" @ %mode @ ".setStateOn(1);";
  49. eval(%evalShortcut);
  50. }
  51. function MeshRoadEditorGui::onEscapePressed( %this )
  52. {
  53. if( %this.getMode() $= "MeshRoadEditorAddNodeMode" )
  54. {
  55. %this.prepSelectionMode();
  56. return true;
  57. }
  58. return false;
  59. }
  60. function MeshRoadEditorGui::onRoadSelected( %this, %road )
  61. {
  62. %this.road = %road;
  63. // Update the materialEditorList
  64. if( isObject( %road ) )
  65. $Tools::materialEditorList = %road.getId();
  66. MeshRoadInspector.inspect( %road );
  67. MeshRoadTreeView.buildVisibleTree(true);
  68. if( MeshRoadTreeView.getSelectedObject() != %road )
  69. {
  70. MeshRoadTreeView.clearSelection();
  71. %treeId = MeshRoadTreeView.findItemByObjectId( %road );
  72. MeshRoadTreeView.selectItem( %treeId );
  73. }
  74. }
  75. function MeshRoadEditorGui::onNodeSelected( %this, %nodeIdx )
  76. {
  77. if ( %nodeIdx == -1 )
  78. {
  79. MeshRoadEditorOptionsWindow-->position.setActive( false );
  80. MeshRoadEditorOptionsWindow-->position.setValue( "" );
  81. MeshRoadEditorOptionsWindow-->rotation.setActive( false );
  82. MeshRoadEditorOptionsWindow-->rotation.setValue( "" );
  83. MeshRoadEditorOptionsWindow-->width.setActive( false );
  84. MeshRoadEditorOptionsWindow-->width.setValue( "" );
  85. MeshRoadEditorOptionsWindow-->depth.setActive( false );
  86. MeshRoadEditorOptionsWindow-->depth.setValue( "" );
  87. }
  88. else
  89. {
  90. MeshRoadEditorOptionsWindow-->position.setActive( true );
  91. MeshRoadEditorOptionsWindow-->position.setValue( %this.getNodePosition() );
  92. MeshRoadEditorOptionsWindow-->rotation.setActive( true );
  93. MeshRoadEditorOptionsWindow-->rotation.setValue( %this.getNodeNormal() );
  94. MeshRoadEditorOptionsWindow-->width.setActive( true );
  95. MeshRoadEditorOptionsWindow-->width.setValue( %this.getNodeWidth() );
  96. MeshRoadEditorOptionsWindow-->depth.setActive( true );
  97. MeshRoadEditorOptionsWindow-->depth.setValue( %this.getNodeDepth() );
  98. }
  99. }
  100. function MeshRoadEditorGui::onNodeModified( %this, %nodeIdx )
  101. {
  102. MeshRoadEditorOptionsWindow-->position.setValue( %this.getNodePosition() );
  103. MeshRoadEditorOptionsWindow-->rotation.setValue( %this.getNodeNormal() );
  104. MeshRoadEditorOptionsWindow-->width.setValue( %this.getNodeWidth() );
  105. MeshRoadEditorOptionsWindow-->depth.setValue( %this.getNodeDepth() );
  106. }
  107. function MeshRoadEditorGui::editNodeDetails( %this )
  108. {
  109. %this.setNodePosition( MeshRoadEditorOptionsWindow-->position.getText() );
  110. %this.setNodeNormal( MeshRoadEditorOptionsWindow-->rotation.getText() );
  111. %this.setNodeWidth( MeshRoadEditorOptionsWindow-->width.getText() );
  112. %this.setNodeDepth( MeshRoadEditorOptionsWindow-->depth.getText() );
  113. }
  114. function MeshRoadEditorGui::onBrowseClicked( %this )
  115. {
  116. //%filename = RETextureFileCtrl.getText();
  117. %dlg = new OpenFileDialog()
  118. {
  119. Filters = "All Files (*.*)|*.*|";
  120. DefaultPath = MeshRoadEditorGui.lastPath;
  121. DefaultFile = %filename;
  122. ChangePath = false;
  123. MustExist = true;
  124. };
  125. %ret = %dlg.Execute();
  126. if(%ret)
  127. {
  128. MeshRoadEditorGui.lastPath = filePath( %dlg.FileName );
  129. %filename = %dlg.FileName;
  130. MeshRoadEditorGui.setTextureFile( %filename );
  131. MeshRoadEditorTextureFileCtrl.setText( %filename );
  132. }
  133. %dlg.delete();
  134. }
  135. function MeshRoadInspector::inspect( %this, %obj )
  136. {
  137. %name = "";
  138. if ( isObject( %obj ) )
  139. %name = %obj.getName();
  140. else
  141. MeshFieldInfoControl.setText( "" );
  142. //RiverInspectorNameEdit.setValue( %name );
  143. Parent::inspect( %this, %obj );
  144. }
  145. function MeshRoadInspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue )
  146. {
  147. // Same work to do as for the regular WorldEditor Inspector.
  148. Inspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue );
  149. }
  150. function MeshRoadInspector::onFieldSelected( %this, %fieldName, %fieldTypeStr, %fieldDoc )
  151. {
  152. MeshFieldInfoControl.setText( "<font:ArialBold:14>" @ %fieldName @ "<font:ArialItalic:14> (" @ %fieldTypeStr @ ") " NL "<font:Arial:14>" @ %fieldDoc );
  153. }
  154. function MeshRoadTreeView::onInspect(%this, %obj)
  155. {
  156. MeshRoadInspector.inspect(%obj);
  157. }
  158. function MeshRoadTreeView::onSelect(%this, %obj)
  159. {
  160. MeshRoadEditorGui.road = %obj;
  161. MeshRoadInspector.inspect( %obj );
  162. if(%obj != MeshRoadEditorGui.getSelectedRoad())
  163. {
  164. MeshRoadEditorGui.setSelectedRoad( %obj );
  165. }
  166. }
  167. function MeshRoadEditorGui::prepSelectionMode( %this )
  168. {
  169. %mode = %this.getMode();
  170. if ( %mode $= "MeshRoadEditorAddNodeMode" )
  171. {
  172. if ( isObject( %this.getSelectedRoad() ) )
  173. %this.deleteNode();
  174. }
  175. %this.setMode( "MeshRoadEditorSelectMode" );
  176. ToolsPaletteArray-->MeshRoadEditorSelectMode.setStateOn(1);
  177. }
  178. //------------------------------------------------------------------------------
  179. function EMeshRoadEditorSelectModeBtn::onClick(%this)
  180. {
  181. EditorGuiStatusBar.setInfo(%this.ToolTip);
  182. }
  183. function EMeshRoadEditorAddModeBtn::onClick(%this)
  184. {
  185. EditorGuiStatusBar.setInfo(%this.ToolTip);
  186. }
  187. function EMeshRoadEditorMoveModeBtn::onClick(%this)
  188. {
  189. EditorGuiStatusBar.setInfo(%this.ToolTip);
  190. }
  191. function EMeshRoadEditorRotateModeBtn::onClick(%this)
  192. {
  193. EditorGuiStatusBar.setInfo(%this.ToolTip);
  194. }
  195. function EMeshRoadEditorScaleModeBtn::onClick(%this)
  196. {
  197. EditorGuiStatusBar.setInfo(%this.ToolTip);
  198. }
  199. function EMeshRoadEditorInsertModeBtn::onClick(%this)
  200. {
  201. EditorGuiStatusBar.setInfo(%this.ToolTip);
  202. }
  203. function EMeshRoadEditorRemoveModeBtn::onClick(%this)
  204. {
  205. EditorGuiStatusBar.setInfo(%this.ToolTip);
  206. }
  207. function MeshRoadDefaultWidthSliderCtrlContainer::onWake(%this)
  208. {
  209. MeshRoadDefaultWidthSliderCtrlContainer-->slider.setValue(MeshRoadDefaultWidthTextEditContainer-->textEdit.getText());
  210. }
  211. function MeshRoadDefaultDepthSliderCtrlContainer::onWake(%this)
  212. {
  213. MeshRoadDefaultDepthSliderCtrlContainer-->slider.setValue(MeshRoadDefaultDepthTextEditContainer-->textEdit.getText());
  214. }