roadEditorGui.cs 6.8 KB

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