| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- //-----------------------------------------------------------------------------
- // 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;
-
- %fixedWindow = RoadEditorTreeWindow;
- %fluidWindow = RoadEditorOptionsWindow;
-
- if(EditorSettings.value( "WorldEditor/forceSidebarToSide" ) == 1)
- {
- // Let's dock the side panel to the right side
- %this.docked = false;
- %this.resizing = true;
- %this.dockSidePanel();
- }
- else
- {
- // Let's release the side panel so it can be moved
- %this.docked = true;
- %this.resizing = false;
- %this.releaseSidePanel();
- }
-
- %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::maxSize(%this, %window)
- {
- // Resize the windows to the max height
- // and force these to the right side if set
- if(EditorSettings.value( "WorldEditor/forceSidebarToSide" ) == 1 && %this.resizing == true)
- {
- // prevent onResize after a resize
- %this.resizing = false;
-
- %fixedWindow = RoadEditorTreeWindow;
- %fluidWindow = RoadEditorOptionsWindow;
- %offset = -1; // tweak the vertical offset so that it aligns neatly
- %top = EditorGuiToolbar.extent.y + %offset;
- %bottom = %top + 59;
- %maxHeight = Canvas.extent.y - %top - %bottom;
-
- // --- Fixed window (top) ------------------------------------------------
- // put it back if it moved
- %fixedWindow.position.x = Canvas.extent.x - %fixedWindow.extent.x;
- %fixedWindow.position.y = %top;
-
- // don't go beyond the canvas
- if(%fixedWindow.extent.y > %maxHeight)
- %fixedWindow.extent.y = %maxHeight - %fluidWindow.extent.y;
- %position = %fixedWindow.position.x SPC %fixedWindow.position.y;
- %extent = %window.extent.x SPC %fixedWindow.extent.y;
- %fixedWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
-
- // --- Fluid window (bottom) ---------------------------------------------
- // position is relative to the top window
- %position = %fixedWindow.position.x SPC %fixedWindow.extent.y + %top;
- %extent = %window.extent.x SPC Canvas.extent.y - %fixedWindow.extent.y - %bottom;
- %fluidWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
-
- // --- AssetBrowser window ----------------------------------------------
- if(isObject(AssetBrowserWindow))
- {
- // Only resize the AssetBrowser if it's docked
- if(AssetBrowserWindow.docked == true)
- {
- // The width is relative to the sidepanel
- %browserWidth = Canvas.extent.x - %extent.x;
- %browserHeight = AssetBrowserWindow.extent.y;
- %browserPosY = Canvas.extent.y - AssetBrowserWindow.extent.y - 33;
- AssetBrowserWindow.resize(0, %browserPosY, %browserWidth, %browserHeight);
- }
- }
- // --- Windowed Console --------------------------------------------------
- if(isObject(windowConsoleControl))
- {
- // Only resize the AssetBrowser if it's docked
- if(windowConsoleControl.docked == true)
- {
- // The width is relative to the sidepanel
- %consoleWidth = Canvas.extent.x - %extent.x;
- %consoleHeight = windowConsoleControl.extent.y;
- %consolePosY = Canvas.extent.y - windowConsoleControl.extent.y - 33;
- windowConsoleControl.resize(0, %consolePosY, %consoleWidth, %consoleHeight);
- }
- }
- }
- }
- function RoadEditorTreeWindow::onMouseDragged(%this)
- {
- %parent = RoadEditorGui;
-
- if(%parent.panelHidden == true)
- {
- %parent.showSidePanel();
- }
-
- if(%parent.resizing == false && %parent.docked == true)
- {
- %parent.resizing = true;
- %parent.maxSize(%this);
- }
- }
- function RoadEditorOptionsWindow::onMouseDragged(%this)
- {
- %parent = RoadEditorGui;
-
- if(%parent.panelHidden == true)
- {
- %parent.showSidePanel();
- }
-
- if(%parent.resizing == false && %parent.docked == true)
- {
- %parent.resizing = true;
- %parent.maxSize(%this);
- }
- }
- function RoadEditorGui::onResize(%this, %newPosition, %newExtent)
- {
- // Window to focus on (mostly the fluid window)
- %window = RoadEditorOptionsWindow;
-
- if(%window.panelHidden == true)
- {
- %window.showSidePanel();
- }
-
- if(%this.resizing == false && %this.docked == true)
- {
- // Only resize once
- %this.resizing = true;
- %this.maxSize(%window);
- }
- }
- function RoadEditorGui::dockSidePanel()
- {
- %parent = RoadEditorGui;
- %fixedWindow = RoadEditorTreeWindow;
- %fluidWindow = RoadEditorOptionsWindow;
-
- if(%parent.docked == true)
- return;
-
- // Move and resize the window(s)
- %parent.resizing = true;
- %parent.maxSize(%fluidWindow);
-
- %parent.docked = true;
- %fluidWindow.onMouseDragged();
- // Lock the windows in place
- %fixedWindow.canCollapse = "0";
- %fixedWindow.canMove = "0";
-
- %fluidWindow.canCollapse = "0";
- %fluidWindow.canMove = "0";
-
- RoadEditorGui_UnDockBtn.Visible = "1";
- RoadEditorGui_DockBtn.Visible = "0";
-
- RoadEditorGui_showBtn.Visible = "0";
- RoadEditorGui_hideBtn.Visible = "1";
- }
- function RoadEditorGui::releaseSidePanel()
- {
- %parent = RoadEditorGui;
- %fixedWindow = RoadEditorTreeWindow;
- %fluidWindow = RoadEditorOptionsWindow;
-
- if(%parent.docked == false)
- return;
-
- // Unlock the windows so that be moved
- %fixedWindow.canCollapse = "1";
- %fixedWindow.canMove = "1";
-
- %fluidWindow.canCollapse = "1";
- %fluidWindow.canMove = "1";
-
- RoadEditorGui_UnDockBtn.Visible = "0";
- RoadEditorGui_DockBtn.Visible = "1";
-
- RoadEditorGui_showBtn.Visible = "0";
- RoadEditorGui_hideBtn.Visible = "0";
-
- // Let's do a small resize so it's visually clear we're undocking
- %position = %fixedWindow.position.x - 6 SPC %fixedWindow.position.y + 6;
- %extent = %fixedWindow.extent.x SPC %fixedWindow.extent.y;
- %fixedWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
- %position = %fluidWindow.position.x - 6 SPC %fluidWindow.position.y + 6;
- %extent = %fluidWindow.extent.x SPC %fluidWindow.extent.y - 12;
- %fluidWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
-
- %parent.docked = false;
- %parent.resizing = false;
- }
- function RoadEditorGui::hideSidePanel()
- {
- %parent = RoadEditorGui;
- %fixedWindow = RoadEditorTreeWindow;
- %fluidWindow = RoadEditorOptionsWindow;
-
- RoadEditorGui_showBtn.Visible = "1";
- RoadEditorGui_hideBtn.Visible = "0";
-
- // hide the content of the panels
- %fixedWindow.titleText = %fixedWindow.text;
- %fluidWindow.titleText = %fluidWindow.text;
-
- %fixedWindow.text = "";
- RoadEditorTreeWPanel.Visible = "0";
-
- %fluidWindow.text = "";
- RoadEditorProperties.Visible = "0";
- RoadEditorPropPanel.Visible = "0";
- RoadEditorPropScroll.Visible = "0";
-
- // Let's do a resize so that the panel is collapsed to the side
- %position = Canvas.extent.x - 24 SPC %fixedWindow.position.y;
- %extent = %fixedWindow.extent.x SPC %fixedWindow.extent.y;
- %fixedWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
- %position = Canvas.extent.x - 24 SPC %fluidWindow.position.y;
- %extent = %fluidWindow.extent.x SPC %fluidWindow.extent.y;
- %fluidWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
-
- %parent.panelHidden = true;
- }
- function RoadEditorGui::showSidePanel()
- {
- %parent = RoadEditorGui;
- %fixedWindow = RoadEditorTreeWindow;
- %fluidWindow = RoadEditorOptionsWindow;
-
- RoadEditorGui_showBtn.Visible = "0";
- RoadEditorGui_hideBtn.Visible = "1";
-
- // show the content of the panels
- // hide the content of the panels
- %fixedWindow.text = %fixedWindow.titleText;
- RoadEditorTreeWPanel.Visible = "1";
-
- %fluidWindow.text = %fluidWindow.titleText;
- RoadEditorProperties.Visible = "1";
- RoadEditorPropPanel.Visible = "1";
- RoadEditorPropScroll.Visible = "1";
-
- %parent.resizing = true;
- %parent.maxSize(%fluidWindow);
-
- %parent.panelHidden = 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
- {
- toolsMessageBoxOKCancel( "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 )
- {
- %this.road.MaterialAsset = "Core_GameObjects:DefaultDecalRoadMaterial";
- }
- 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:" @ $Gui::fontTypeBold @ ":16>" @ %fieldName @ "<font:" @ $Gui::fontTypeItalic @ ":16> (" @ %fieldTypeStr @ ") " NL "<font:" @ $Gui::fontTypeRegular @ ":16>" @ %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 ESettingsWindow::getRoadEditorSettings(%this)
- {
- SettingsInspector.startGroup("Defaults");
- SettingsInspector.addSettingsField("RoadEditor/DefaultWidth", "Width", "string", "");
- SettingsInspector.addSettingsField("RoadEditor/MaterialName", "Material", "string", "");
- SettingsInspector.endGroup();
-
- SettingsInspector.startGroup("Colors");
- SettingsInspector.addSettingsField("RoadEditor/HoverSplineColor", "Hover Spline", "colorI", "");
- SettingsInspector.addSettingsField("RoadEditor/SelectedSplineColor", "Selected Spline", "colorI", "");
- SettingsInspector.endGroup();
- }
- //------------------------------------------------------------------------------
- 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());
- }
|