| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- //-----------------------------------------------------------------------------
- // 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 MissionAreaEditorGui::onWake(%this)
- {
- %fixedWindow = MissionAreaEditorTerrainWindow;
- %fluidWindow = MissionAreaEditorPropertiesWindow;
-
- 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();
- }
- }
- function MissionAreaEditorGui::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 = MissionAreaEditorTerrainWindow;
- %fluidWindow = MissionAreaEditorPropertiesWindow;
- %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 MissionAreaEditorTerrainWindow::onMouseDragged(%this)
- {
- %parent = MissionAreaEditorGui;
-
- if(%parent.panelHidden == true)
- {
- %parent.showSidePanel();
- }
-
- if(%parent.resizing == false && %parent.docked == true)
- {
- %parent.resizing = true;
- %parent.maxSize(%this);
- }
- }
- function MissionAreaEditorPropertiesWindow::onMouseDragged(%this)
- {
- %parent = MissionAreaEditorGui;
-
- if(%parent.panelHidden == true)
- {
- %parent.showSidePanel();
- }
-
- if(%parent.resizing == false && %parent.docked == true)
- {
- %parent.resizing = true;
- %parent.maxSize(%this);
- }
- }
- function MissionAreaEditorGui::onResize(%this, %newPosition, %newExtent)
- {
- // Window to focus on (mostly the fluid window)
- %window = MissionAreaEditorPropertiesWindow;
-
- if(%window.panelHidden == true)
- {
- %window.showSidePanel();
- }
-
- if(%this.resizing == false && %this.docked == true)
- {
- // Only resize once
- %this.resizing = true;
- %this.maxSize(%window);
- }
- }
- function MissionAreaEditorGui::dockSidePanel()
- {
- %parent = MissionAreaEditorGui;
- %fixedWindow = MissionAreaEditorTerrainWindow;
- %fluidWindow = MissionAreaEditorPropertiesWindow;
-
- 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";
-
- MissionAreaEditorGui_UnDockBtn.Visible = "1";
- MissionAreaEditorGui_DockBtn.Visible = "0";
-
- MissionAreaEditorGui_showBtn.Visible = "0";
- MissionAreaEditorGui_hideBtn.Visible = "1";
- }
- function MissionAreaEditorGui::releaseSidePanel()
- {
- %parent = MissionAreaEditorGui;
- %fixedWindow = MissionAreaEditorTerrainWindow;
- %fluidWindow = MissionAreaEditorPropertiesWindow;
-
- if(%parent.docked == false)
- return;
-
- // Unlock the windows so that be moved
- %fixedWindow.canCollapse = "1";
- %fixedWindow.canMove = "1";
-
- %fluidWindow.canCollapse = "1";
- %fluidWindow.canMove = "1";
-
- MissionAreaEditorGui_UnDockBtn.Visible = "0";
- MissionAreaEditorGui_DockBtn.Visible = "1";
-
- MissionAreaEditorGui_showBtn.Visible = "0";
- MissionAreaEditorGui_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 MissionAreaEditorGui::hideSidePanel()
- {
- %parent = MissionAreaEditorGui;
- %fixedWindow = MissionAreaEditorTerrainWindow;
- %fluidWindow = MissionAreaEditorPropertiesWindow;
-
- MissionAreaEditorGui_showBtn.Visible = "1";
- MissionAreaEditorGui_hideBtn.Visible = "0";
-
- // hide the content of the panels
- %fixedWindow.titleText = %fixedWindow.text;
- %fluidWindow.titleText = %fluidWindow.text;
-
- %fixedWindow.text = "";
- MissionAreaEditorTerrainPanel.Visible = "0";
-
- %fluidWindow.text = "";
- MissionAreaEditorPropertiesPanel.Visible = "0";
- MissionAreaInspectorPanel.Visible = "0";
- MissionAreaFieldInfoControlPanel.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 MissionAreaEditorGui::showSidePanel()
- {
- %parent = MissionAreaEditorGui;
- %fixedWindow = MissionAreaEditorTerrainWindow;
- %fluidWindow = MissionAreaEditorPropertiesWindow;
-
- MissionAreaEditorGui_showBtn.Visible = "0";
- MissionAreaEditorGui_hideBtn.Visible = "1";
-
- // show the content of the panels
- %fixedWindow.text = %fixedWindow.titleText;
- MissionAreaEditorTerrainPanel.Visible = "1";
-
- %fluidWindow.text = %fluidWindow.titleText;
- MissionAreaEditorPropertiesPanel.Visible = "1";
- MissionAreaInspectorPanel.Visible = "1";
- MissionAreaFieldInfoControlPanel.Visible = "1";
-
- %parent.resizing = true;
- %parent.maxSize(%fluidWindow);
-
- %parent.panelHidden = false;
- }
- //------------------------------------------------------------------------------
-
- function MissionAreaEditorGui::onEditorActivated( %this )
- {
- EWorldEditor.clearSelection();
-
- %ma = getMissionAreaServerObject();
- if( isObject( %ma ) )
- {
- EWorldEditor.selectObject( %ma );
- EWorldEditor.syncGui();
- MissionAreaEditorTerrainEditor.updateTerrain();
- %this.setSelectedMissionArea( %ma );
- %this.onMissionAreaSelected( %this.getSelectedMissionArea() );
- }
- }
- function MissionAreaEditorGui::onEditorDeactivated( %this )
- {
- }
- function MissionAreaEditorGui::onMissionAreaSelected( %this, %missionArea )
- {
- %this.missionArea = %missionArea;
- MissionAreaEditorTerrainEditor.setMissionArea( %missionArea );
- MissionAreaInspector.inspect( %missionArea );
- }
- //-----------------------------------------------------------------------------
- function MissionAreaEditorTerrainEditor::onMissionAreaModified( %this )
- {
- MissionAreaInspector.refresh();
- }
- function MissionAreaEditorTerrainEditor::onUndo( %this )
- {
- MissionAreaInspector.refresh();
- }
- //-----------------------------------------------------------------------------
- function MissionAreaInspector::inspect( %this, %obj )
- {
- %name = "";
- if ( isObject( %obj ) )
- %name = %obj.getName();
- else
- MissionAreaFieldInfoControl.setText( "" );
-
- //RiverInspectorNameEdit.setValue( %name );
- Parent::inspect( %this, %obj );
- }
- function MissionAreaInspector::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 MissionAreaInspector::onFieldSelected( %this, %fieldName, %fieldTypeStr, %fieldDoc )
- {
- MissionAreaFieldInfoControl.setText( "<font:" @ $Gui::fontTypeBold @ ":16>" @ %fieldName @ "<font:" @ $Gui::fontTypeItalic @ ":16> (" @ %fieldTypeStr @ ") " NL "<font:" @ $Gui::fontTypeRegular @ ":16>" @ %fieldDoc );
- }
|