Reworks the open/close functions of the gui and world editors so they will properly toggle between and clean up when closed.

This commit is contained in:
Areloch 2017-01-21 17:11:54 -06:00
parent 0aea1d5c33
commit f8b650f7a1
16 changed files with 238 additions and 142 deletions

View file

@ -106,7 +106,7 @@
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
command = "GuiEdit();";
command = "toggleGuiEditor(1);";
tooltipProfile = "GuiToolTipProfile";
tooltip = "The GUI Editor is accessible in-game by pressing F10";
hovertime = "1000";

View file

@ -105,7 +105,7 @@ function EditorInspectorBase::onAdd( %this )
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "Edit Profile" TAB "" TAB "if( !$InGuiEditor ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );";
item[ 0 ] = "Edit Profile" TAB "" TAB "if( !GuiEditorIsActive() ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );";
item[ 1 ] = "Jump to Definition in Torsion" TAB "" TAB "EditorOpenDeclarationInTorsion( %this.inspectorField.getData() );";
item[ 2 ] = "Inspect Object" TAB "" TAB "inspectObject( %this.inspectorField.getData() );";
item[ 3 ] = "-";

View file

@ -86,7 +86,7 @@
minExtent = "8 8";
canSave = "1";
visible = "1";
command = "GuiEditor.switchToWorldEditor();";
command = "toggleEditor(1);";
tooltipProfile = "ToolsGuiToolTipProfile";
ToolTip = "World Editor";
hovertime = "1000";

View file

@ -75,7 +75,22 @@ function toggleGuiEditor( %make )
if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui )
toggleEditor( true );
GuiEdit();
if( !isObject( GuiEditCanvas ) )
new GuiControl( GuiEditCanvas, EditorGuiGroup );
if( GuiEditorIsActive() )
{
GuiEditor.close();
}
else
{
GuiEditor.open();
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
cancel($Game::Schedule);
}
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
@ -98,6 +113,26 @@ package GuiEditor_BlockDialogs
//---------------------------------------------------------------------------------------------
function GuiEditor::open(%this)
{
GuiEditCanvas.onCreateMenu();
GuiEditContent(Canvas.getContent());
}
function GuiEditor::close(%this)
{
// prevent the mission editor from opening while the GuiEditor is open.
if(Canvas.getContent() != GuiEditorGui.getId())
return;
GuiGroup.add(GuiEditorGui);
Canvas.setContent(GuiEditor.lastContent);
GuiEditCanvas.onDestroyMenu();
}
function GuiEditor::openForEditing( %this, %content )
{
Canvas.setContent( GuiEditorGui );

View file

@ -67,7 +67,7 @@
MinExtent = "8 8";
canSave = "1";
Visible = "1";
Command = "toggleEditor( true ); GuiEdit(); $GuiEditorBtnPressed = true;";
Command = "toggleGuiEditor(true); $GuiEditorBtnPressed = true;";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Open the GuiEditor";
hovertime = "1000";

View file

@ -35,8 +35,6 @@ function EditorGui::init(%this)
$NextOperationId = 1;
$HeightfieldDirtyRow = -1;
%this.buildMenus();
if( !isObject( %this-->ToolsPaletteWindow ) )
{
// Load Creator/Inspector GUI
@ -1914,6 +1912,8 @@ function Editor::open(%this)
if(Canvas.getContent() == GuiEditorGui.getId())
return;
EditorGui.buildMenus();
if( !EditorGui.isInitialized )
EditorGui.init();
@ -1929,6 +1929,21 @@ function Editor::close(%this, %gui)
if(isObject(MessageHud))
MessageHud.close();
EditorGui.writeCameraSettings();
EditorGui.onDestroyMenu();
}
function EditorGui::onDestroyMenu(%this)
{
if( !isObject( %this.menuBar ) )
return;
// Destroy menus
while( %this.menuBar.getCount() != 0 )
%this.menuBar.getObject( 0 ).delete();
%this.menuBar.removeFromCanvas();
%this.menuBar.delete();
}
$RelightCallback = "";

View file

@ -99,18 +99,12 @@ function Editor::checkActiveLoadDone()
//------------------------------------------------------------------------------
function toggleEditor(%make)
{
if (Canvas.isFullscreen())
{
MessageBoxOK("Windowed Mode Required", "Please switch to windowed mode to access the Mission Editor.");
return;
}
if (%make)
{
%timerId = startPrecisionTimer();
if( $InGuiEditor )
GuiEdit();
if( GuiEditorIsActive() )
toggleGuiEditor(1);
if( !$missionRunning )
{
@ -142,16 +136,9 @@ function toggleEditor(%make)
}
}
else
{
if ( !$GuiEditorBtnPressed )
{
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
}
else
{
$GuiEditorBtnPressed = false;
}
Editor.open();
@ -163,7 +150,6 @@ function toggleEditor(%make)
if (theLevelInfo.type $= "DemoScene")
commandToServer('dropCameraAtPlayer', true);
canvas.popDialog(EditorLoadingGui);
}

View file

@ -44,6 +44,8 @@ function EditorGui::buildMenus(%this)
// Sub menus (temporary, until MenuBuilder gets updated)
// The speed increments located here are overwritten in EditorCameraSpeedMenu::setupDefaultState.
// The new min/max for the editor camera speed range can be set in each level's levelInfo object.
if(!isObject(EditorCameraSpeedOptions))
{
%this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions)
{
superClass = "MenuBuilder";
@ -57,6 +59,9 @@ function EditorGui::buildMenus(%this)
item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165";
item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200";
};
}
if(!isObject(EditorFreeCameraTypeOptions))
{
%this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions)
{
superClass = "MenuBuilder";
@ -68,6 +73,9 @@ function EditorGui::buildMenus(%this)
item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");";
item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");";
};
}
if(!isObject(EditorPlayerCameraTypeOptions))
{
%this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions)
{
superClass = "MenuBuilder";
@ -76,6 +84,9 @@ function EditorGui::buildMenus(%this)
Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");";
Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");";
};
}
if(!isObject(EditorCameraBookmarks))
{
%this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks)
{
superClass = "MenuBuilder";
@ -83,6 +94,7 @@ function EditorGui::buildMenus(%this)
//item[0] = "None";
};
}
%this.viewTypeMenu = new PopupMenu()
{
superClass = "MenuBuilder";
@ -98,7 +110,7 @@ function EditorGui::buildMenus(%this)
};
// Menu bar
%this.menuBar = new MenuBar()
%this.menuBar = new MenuBar(WorldEditorMenubar)
{
dynamicItemInsertPos = 3;
};

View file

@ -126,7 +126,7 @@
profile = "GuiMenuButtonProfile";
visible = "1";
active = "1";
command = "GuiEdit();";
command = "toggleGuiEditor(1);";
tooltipProfile = "GuiToolTipProfile";
tooltip = "The GUI Editor is accessible in-game by pressing F10";
hovertime = "1000";

View file

@ -105,7 +105,7 @@ function EditorInspectorBase::onAdd( %this )
superClass = "MenuBuilder";
isPopup = true;
item[ 0 ] = "Edit Profile" TAB "" TAB "if( !$InGuiEditor ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );";
item[ 0 ] = "Edit Profile" TAB "" TAB "if( !GuiEditorIsActive() ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );";
item[ 1 ] = "Jump to Definition in Torsion" TAB "" TAB "EditorOpenDeclarationInTorsion( %this.inspectorField.getData() );";
item[ 2 ] = "Inspect Object" TAB "" TAB "inspectObject( %this.inspectorField.getData() );";
item[ 3 ] = "-";

View file

@ -86,7 +86,7 @@
minExtent = "8 8";
canSave = "1";
visible = "1";
command = "GuiEditor.switchToWorldEditor();";
command = "toggleEditor(1);";
tooltipProfile = "ToolsGuiToolTipProfile";
ToolTip = "World Editor";
hovertime = "1000";

View file

@ -75,7 +75,22 @@ function toggleGuiEditor( %make )
if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui )
toggleEditor( true );
GuiEdit();
if( !isObject( GuiEditCanvas ) )
new GuiControl( GuiEditCanvas, EditorGuiGroup );
if( GuiEditorIsActive() )
{
GuiEditor.close();
}
else
{
GuiEditor.open();
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
cancel($Game::Schedule);
}
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
@ -98,6 +113,26 @@ package GuiEditor_BlockDialogs
//---------------------------------------------------------------------------------------------
function GuiEditor::open(%this)
{
GuiEditCanvas.onCreateMenu();
GuiEditContent(Canvas.getContent());
}
function GuiEditor::close(%this)
{
// prevent the mission editor from opening while the GuiEditor is open.
if(Canvas.getContent() != GuiEditorGui.getId())
return;
GuiGroup.add(GuiEditorGui);
Canvas.setContent(GuiEditor.lastContent);
GuiEditCanvas.onDestroyMenu();
}
function GuiEditor::openForEditing( %this, %content )
{
Canvas.setContent( GuiEditorGui );

View file

@ -67,7 +67,7 @@
MinExtent = "8 8";
canSave = "1";
Visible = "1";
Command = "toggleEditor( true ); GuiEdit(); $GuiEditorBtnPressed = true;";
Command = "toggleGuiEditor(true); $GuiEditorBtnPressed = true;";
tooltipprofile = "ToolsGuiToolTipProfile";
ToolTip = "Open the GuiEditor";
hovertime = "1000";

View file

@ -35,8 +35,6 @@ function EditorGui::init(%this)
$NextOperationId = 1;
$HeightfieldDirtyRow = -1;
%this.buildMenus();
if( !isObject( %this-->ToolsPaletteWindow ) )
{
// Load Creator/Inspector GUI
@ -1914,6 +1912,8 @@ function Editor::open(%this)
if(Canvas.getContent() == GuiEditorGui.getId())
return;
EditorGui.buildMenus();
if( !EditorGui.isInitialized )
EditorGui.init();
@ -1929,6 +1929,21 @@ function Editor::close(%this, %gui)
if(isObject(MessageHud))
MessageHud.close();
EditorGui.writeCameraSettings();
EditorGui.onDestroyMenu();
}
function EditorGui::onDestroyMenu(%this)
{
if( !isObject( %this.menuBar ) )
return;
// Destroy menus
while( %this.menuBar.getCount() != 0 )
%this.menuBar.getObject( 0 ).delete();
%this.menuBar.removeFromCanvas();
%this.menuBar.delete();
}
$RelightCallback = "";

View file

@ -99,18 +99,12 @@ function Editor::checkActiveLoadDone()
//------------------------------------------------------------------------------
function toggleEditor(%make)
{
if (Canvas.isFullscreen())
{
MessageBoxOK("Windowed Mode Required", "Please switch to windowed mode to access the Mission Editor.");
return;
}
if (%make)
{
%timerId = startPrecisionTimer();
if( $InGuiEditor )
GuiEdit();
if( GuiEditorIsActive() )
toggleGuiEditor(1);
if( !$missionRunning )
{
@ -142,16 +136,9 @@ function toggleEditor(%make)
}
}
else
{
if ( !$GuiEditorBtnPressed )
{
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
}
else
{
$GuiEditorBtnPressed = false;
}
Editor.open();
@ -163,7 +150,6 @@ function toggleEditor(%make)
if (theLevelInfo.type $= "DemoScene")
commandToServer('dropCameraAtPlayer', true);
canvas.popDialog(EditorLoadingGui);
}

View file

@ -44,6 +44,8 @@ function EditorGui::buildMenus(%this)
// Sub menus (temporary, until MenuBuilder gets updated)
// The speed increments located here are overwritten in EditorCameraSpeedMenu::setupDefaultState.
// The new min/max for the editor camera speed range can be set in each level's levelInfo object.
if(!isObject(EditorCameraSpeedOptions))
{
%this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions)
{
superClass = "MenuBuilder";
@ -57,6 +59,9 @@ function EditorGui::buildMenus(%this)
item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165";
item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200";
};
}
if(!isObject(EditorFreeCameraTypeOptions))
{
%this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions)
{
superClass = "MenuBuilder";
@ -68,6 +73,9 @@ function EditorGui::buildMenus(%this)
item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");";
item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");";
};
}
if(!isObject(EditorPlayerCameraTypeOptions))
{
%this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions)
{
superClass = "MenuBuilder";
@ -76,6 +84,9 @@ function EditorGui::buildMenus(%this)
Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");";
Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");";
};
}
if(!isObject(EditorCameraBookmarks))
{
%this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks)
{
superClass = "MenuBuilder";
@ -83,6 +94,7 @@ function EditorGui::buildMenus(%this)
//item[0] = "None";
};
}
%this.viewTypeMenu = new PopupMenu()
{
superClass = "MenuBuilder";
@ -98,7 +110,7 @@ function EditorGui::buildMenus(%this)
};
// Menu bar
%this.menuBar = new MenuBar()
%this.menuBar = new MenuBar(WorldEditorMenubar)
{
dynamicItemInsertPos = 3;
};