| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- function RoadEditorGui::onWake( %this )
- {
- $DecalRoad::EditorOpen = true;
-
- %count = EWorldEditor.getSelectionSize();
- for ( %i = 0; %i < %count; %i++ )
- {
- %obj = EWorldEditor.getSelectedObject(%i);
- if ( %obj.getClassName() !$= "DecalRoad" )
- EWorldEditor.unselectObject();
- else
- %this.setSelectedRoad( %obj );
- }
-
- %this.onNodeSelected(-1);
- }
- function RoadEditorGui::onSleep( %this )
- {
- $DecalRoad::EditorOpen = false;
- }
- function RoadEditorGui::paletteSync( %this, %mode )
- {
- %evalShortcut = "ToolsPaletteArray-->" @ %mode @ ".setStateOn(1);";
- eval(%evalShortcut);
- }
- function RoadEditorGui::onDeleteKey( %this )
- {
- %road = %this.getSelectedRoad();
- %node = %this.getSelectedNode();
-
- if ( !isObject( %road ) )
- return;
-
- if ( %node != -1 )
- {
- %this.deleteNode();
- }
- else
- {
- MessageBoxOKCancel( "Notice", "Delete selected DecalRoad?", "RoadEditorGui.deleteRoad();", "" );
- }
- }
- function RoadEditorGui::onEscapePressed( %this )
- {
- if( %this.getMode() $= "RoadEditorAddNodeMode" )
- {
- %this.prepSelectionMode();
- return true;
- }
- return false;
- }
- //just in case we need it later
- function RoadEditorGui::onRoadCreation( %this )
- {
- }
- function RoadEditorGui::onRoadSelected( %this, %road )
- {
- %this.road = %road;
-
- // Update the materialEditorList
- if(isObject( %road ))
- $Tools::materialEditorList = %road.getId();
-
- RoadInspector.inspect( %road );
- RoadTreeView.buildVisibleTree(true);
- if( RoadTreeView.getSelectedObject() != %road )
- {
- RoadTreeView.clearSelection();
- %treeId = RoadTreeView.findItemByObjectId( %road );
- RoadTreeView.selectItem( %treeId );
- }
- }
- function RoadEditorGui::onNodeSelected( %this, %nodeIdx )
- {
-
- if ( %nodeIdx == -1 )
- {
- RoadEditorProperties-->position.setActive( false );
- RoadEditorProperties-->position.setValue( "" );
-
- RoadEditorProperties-->width.setActive( false );
- RoadEditorProperties-->width.setValue( "" );
- }
- else
- {
- RoadEditorProperties-->position.setActive( true );
- RoadEditorProperties-->position.setValue( %this.getNodePosition() );
-
- RoadEditorProperties-->width.setActive( true );
- RoadEditorProperties-->width.setValue( %this.getNodeWidth() );
- }
-
- }
- function RoadEditorGui::onNodeModified( %this, %nodeIdx )
- {
-
- RoadEditorProperties-->position.setValue( %this.getNodePosition() );
- RoadEditorProperties-->width.setValue( %this.getNodeWidth() );
- }
- function RoadEditorGui::editNodeDetails( %this )
- {
-
- %this.setNodePosition( RoadEditorProperties-->position.getText() );
- %this.setNodeWidth( RoadEditorProperties-->width.getText() );
- }
- function RoadEditorGui::onBrowseClicked( %this )
- {
- //%filename = RETextureFileCtrl.getText();
-
- %dlg = new OpenFileDialog()
- {
- Filters = "All Files (*.*)|*.*|";
- DefaultPath = RoadEditorGui.lastPath;
- DefaultFile = %filename;
- ChangePath = false;
- MustExist = true;
- };
-
- %ret = %dlg.Execute();
- if(%ret)
- {
- RoadEditorGui.lastPath = filePath( %dlg.FileName );
- %filename = %dlg.FileName;
- RoadEditorGui.setTextureFile( %filename );
- RETextureFileCtrl.setText( %filename );
- }
-
- %dlg.delete();
- }
- function RoadInspector::inspect( %this, %obj )
- {
- %name = "";
- if ( isObject( %obj ) )
- %name = %obj.getName();
- else
- RoadFieldInfoControl.setText( "" );
-
- //RoadInspectorNameEdit.setValue( %name );
- Parent::inspect( %this, %obj );
- }
- function RoadInspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue )
- {
- // Same work to do as for the regular WorldEditor Inspector.
- Inspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue );
- }
- function RoadInspector::onFieldSelected( %this, %fieldName, %fieldTypeStr, %fieldDoc )
- {
- RoadFieldInfoControl.setText( "<font:ArialBold:14>" @ %fieldName @ "<font:ArialItalic:14> (" @ %fieldTypeStr @ ") " NL "<font:Arial:14>" @ %fieldDoc );
- }
- function RoadTreeView::onInspect(%this, %obj)
- {
- RoadInspector.inspect(%obj);
- }
- function RoadTreeView::onSelect(%this, %obj)
- {
- RoadEditorGui.road = %obj;
- RoadInspector.inspect( %obj );
- if(%obj != RoadEditorGui.getSelectedRoad())
- {
- RoadEditorGui.setSelectedRoad( %obj );
- }
- }
- function RoadEditorGui::prepSelectionMode( %this )
- {
- %mode = %this.getMode();
-
- if ( %mode $= "RoadEditorAddNodeMode" )
- {
- if ( isObject( %this.getSelectedRoad() ) )
- %this.deleteNode();
- }
-
- %this.setMode( "RoadEditorSelectMode" );
- ToolsPaletteArray-->RoadEditorSelectMode.setStateOn(1);
- }
- //------------------------------------------------------------------------------
- function ERoadEditorSelectModeBtn::onClick(%this)
- {
- EditorGuiStatusBar.setInfo(%this.ToolTip);
- }
- function ERoadEditorAddModeBtn::onClick(%this)
- {
- EditorGuiStatusBar.setInfo(%this.ToolTip);
- }
- function ERoadEditorMoveModeBtn::onClick(%this)
- {
- EditorGuiStatusBar.setInfo(%this.ToolTip);
- }
- function ERoadEditorScaleModeBtn::onClick(%this)
- {
- EditorGuiStatusBar.setInfo(%this.ToolTip);
- }
- function ERoadEditorInsertModeBtn::onClick(%this)
- {
- EditorGuiStatusBar.setInfo(%this.ToolTip);
- }
- function ERoadEditorRemoveModeBtn::onClick(%this)
- {
- EditorGuiStatusBar.setInfo(%this.ToolTip);
- }
- function RoadDefaultWidthSliderCtrlContainer::onWake(%this)
- {
- RoadDefaultWidthSliderCtrlContainer-->slider.setValue(RoadDefaultWidthTextEditContainer-->textEdit.getText());
- }
|