Merge pull request #1933 from Areloch/SDLMenubarFixins

Fixes editor handling of menubars when opening/closing.
This commit is contained in:
Areloch 2017-01-30 13:31:46 -06:00 committed by GitHub
commit ca4204be14
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,11 +75,26 @@ function toggleGuiEditor( %make )
if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui )
toggleEditor( true );
GuiEdit();
if( !isObject( GuiEditCanvas ) )
new GuiControl( GuiEditCanvas, EditorGuiGroup );
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
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
// has elapsed.
cancel($Game::Schedule);
}
}
@ -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 )
{
@ -143,27 +137,19 @@ function toggleEditor(%make)
}
else
{
if ( !$GuiEditorBtnPressed )
{
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
}
else
{
$GuiEditorBtnPressed = false;
}
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
Editor.open();
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
cancel($Game::Schedule);
if (theLevelInfo.type $= "DemoScene")
commandToServer('dropCameraAtPlayer', true);
canvas.popDialog(EditorLoadingGui);
}

View file

@ -42,47 +42,59 @@ 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.
%this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions)
// 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))
{
superClass = "MenuBuilder";
class = "EditorCameraSpeedMenu";
%this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions)
{
superClass = "MenuBuilder";
class = "EditorCameraSpeedMenu";
item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5";
item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35";
item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70";
item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100";
item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130";
item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165";
item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200";
};
%this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions)
item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5";
item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35";
item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70";
item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100";
item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130";
item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165";
item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200";
};
}
if(!isObject(EditorFreeCameraTypeOptions))
{
superClass = "MenuBuilder";
class = "EditorFreeCameraTypeMenu";
%this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions)
{
superClass = "MenuBuilder";
class = "EditorFreeCameraTypeMenu";
item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");";
item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");";
Item[2] = "-";
item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");";
item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");";
};
%this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions)
item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");";
item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");";
Item[2] = "-";
item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");";
item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");";
};
}
if(!isObject(EditorPlayerCameraTypeOptions))
{
superClass = "MenuBuilder";
class = "EditorPlayerCameraTypeMenu";
%this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions)
{
superClass = "MenuBuilder";
class = "EditorPlayerCameraTypeMenu";
Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");";
Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");";
};
%this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks)
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))
{
superClass = "MenuBuilder";
class = "EditorCameraBookmarksMenu";
%this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks)
{
superClass = "MenuBuilder";
class = "EditorCameraBookmarksMenu";
//item[0] = "None";
};
//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,11 +75,26 @@ function toggleGuiEditor( %make )
if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui )
toggleEditor( true );
GuiEdit();
if( !isObject( GuiEditCanvas ) )
new GuiControl( GuiEditCanvas, EditorGuiGroup );
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
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
// has elapsed.
cancel($Game::Schedule);
}
}
@ -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 )
{
@ -143,27 +137,19 @@ function toggleEditor(%make)
}
else
{
if ( !$GuiEditorBtnPressed )
{
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
}
else
{
$GuiEditorBtnPressed = false;
}
canvas.pushDialog( EditorLoadingGui );
canvas.repaint();
Editor.open();
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
// Cancel the scheduled event to prevent
// the level from cycling after it's duration
// has elapsed.
cancel($Game::Schedule);
if (theLevelInfo.type $= "DemoScene")
commandToServer('dropCameraAtPlayer', true);
canvas.popDialog(EditorLoadingGui);
}

View file

@ -42,47 +42,59 @@ 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.
%this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions)
// 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))
{
superClass = "MenuBuilder";
class = "EditorCameraSpeedMenu";
%this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions)
{
superClass = "MenuBuilder";
class = "EditorCameraSpeedMenu";
item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5";
item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35";
item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70";
item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100";
item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130";
item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165";
item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200";
};
%this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions)
item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5";
item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35";
item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70";
item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100";
item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130";
item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165";
item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200";
};
}
if(!isObject(EditorFreeCameraTypeOptions))
{
superClass = "MenuBuilder";
class = "EditorFreeCameraTypeMenu";
%this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions)
{
superClass = "MenuBuilder";
class = "EditorFreeCameraTypeMenu";
item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");";
item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");";
Item[2] = "-";
item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");";
item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");";
};
%this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions)
item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");";
item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");";
Item[2] = "-";
item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");";
item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");";
};
}
if(!isObject(EditorPlayerCameraTypeOptions))
{
superClass = "MenuBuilder";
class = "EditorPlayerCameraTypeMenu";
%this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions)
{
superClass = "MenuBuilder";
class = "EditorPlayerCameraTypeMenu";
Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");";
Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");";
};
%this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks)
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))
{
superClass = "MenuBuilder";
class = "EditorCameraBookmarksMenu";
%this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks)
{
superClass = "MenuBuilder";
class = "EditorCameraBookmarksMenu";
//item[0] = "None";
};
//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;
};