From 41add628ad5d9d683af49869041f45f36c1545f5 Mon Sep 17 00:00:00 2001 From: JeffR Date: Fri, 6 May 2022 23:39:16 -0500 Subject: [PATCH] Implements a more standardized way to format usual UI pages by having the ability to utilize the UINavigation namespace for page stack navigation Also fixes behavior handling of menu input buttons not refreshing reliably Adds ability to define a control on a MenuList to act as a highlighter over the currently selected control Cleaned up BaseUI pages to use UINavigation which reduced a lot of duplication of elements and code --- .../game/core/gui/scripts/profiles.tscript | 6 + Templates/BaseGame/game/data/UI/UI.tscript | 6 + .../data/UI/guis/MainMenuButtons.asset.taml | 5 + .../game/data/UI/guis/MainMenuButtons.gui | 78 ++++ .../game/data/UI/guis/MainMenuButtons.tscript | 67 +++ .../game/data/UI/guis/chooseLevelDlg.gui | 216 +--------- .../game/data/UI/guis/chooseLevelDlg.tscript | 33 +- .../game/data/UI/guis/joinServerMenu.gui | 406 +----------------- .../game/data/UI/guis/joinServerMenu.tscript | 37 +- .../BaseGame/game/data/UI/guis/mainMenu.gui | 287 +++---------- .../game/data/UI/guis/mainMenu.tscript | 68 +-- .../game/data/UI/guis/optionsMenu.gui | 143 +++--- .../game/data/UI/guis/optionsMenu.tscript | 119 +++-- .../BaseGame/game/data/UI/guis/pauseMenu.gui | 189 ++++---- .../game/data/UI/guis/pauseMenu.tscript | 27 +- .../Keyboard_Black_Mouse_Left.png | Bin 0 -> 3184 bytes .../Keyboard_Black_Mouse_Middle.png | Bin 0 -> 3089 bytes .../Keyboard_Black_Mouse_Right.png | Bin 0 -> 3227 bytes .../data/UI/scripts/menuInputHandling.tscript | 121 ++++-- .../data/UI/scripts/menuNavigation.tscript | 220 ++++++++++ 20 files changed, 811 insertions(+), 1217 deletions(-) create mode 100644 Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml create mode 100644 Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui create mode 100644 Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript create mode 100644 Templates/BaseGame/game/data/UI/images/Inputs/Keyboard & Mouse/Keyboard_Black_Mouse_Left.png create mode 100644 Templates/BaseGame/game/data/UI/images/Inputs/Keyboard & Mouse/Keyboard_Black_Mouse_Middle.png create mode 100644 Templates/BaseGame/game/data/UI/images/Inputs/Keyboard & Mouse/Keyboard_Black_Mouse_Right.png create mode 100644 Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript diff --git a/Templates/BaseGame/game/core/gui/scripts/profiles.tscript b/Templates/BaseGame/game/core/gui/scripts/profiles.tscript index f09e1d542..150783b46 100644 --- a/Templates/BaseGame/game/core/gui/scripts/profiles.tscript +++ b/Templates/BaseGame/game/core/gui/scripts/profiles.tscript @@ -81,6 +81,12 @@ new GuiControlProfile (GuiDefaultProfile) cursorColor = "0 0 0 255"; }; +if(!isObject(GuiNonModalDefaultProfile)) +new GuiControlProfile (GuiNonModalDefaultProfile : GuiDefaultProfile) +{ + modal = false; +}; + if(!isObject(GuiToolTipProfile)) new GuiControlProfile (GuiToolTipProfile) { diff --git a/Templates/BaseGame/game/data/UI/UI.tscript b/Templates/BaseGame/game/data/UI/UI.tscript index cd645f86f..ee2c111e7 100644 --- a/Templates/BaseGame/game/data/UI/UI.tscript +++ b/Templates/BaseGame/game/data/UI/UI.tscript @@ -35,12 +35,18 @@ function UI::initClient(%this) //Profiles %this.queueExec("./scripts/profiles"); + //Navigation Utility Scripts + %this.queueExec("./scripts/menuNavigation"); + //Now gui files %this.queueExec("./scripts/menuInputHandling"); %this.queueExec("./guis/mainMenu"); %this.queueExec("./guis/mainMenu.gui"); + %this.queueExec("./guis/mainMenuButtons"); + %this.queueExec("./guis/mainMenuButtons.gui"); + %this.queueExec("./guis/chooseLevelDlg"); %this.queueExec("./guis/chooseLevelDlg.gui"); diff --git a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml new file mode 100644 index 000000000..2ab6cfeef --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml @@ -0,0 +1,5 @@ + diff --git a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui new file mode 100644 index 000000000..8664b312e --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui @@ -0,0 +1,78 @@ +//--- OBJECT WRITE BEGIN --- +$guiContent = new GuiControl(MainMenuButtons) { + extent = "1024 768"; + profile = "GuiNonModalDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + canSaveDynamicFields = "1"; + originalAssetName = "MainMenuButtons"; + + new GuiStackControl(MainMenuButtonList) { + padding = "15"; + dynamicSize = "0"; + position = "312 145"; + extent = "400 477"; + horizSizing = "center"; + vertSizing = "center"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; + + new GuiButtonCtrl(MainMenuSinglePlayerBtn) { + text = "Single Player"; + extent = "400 55"; + profile = "GuiMenuButtonProfile"; + command = "openSinglePlayerMenu();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuCreateSrvrBtn) { + text = "Create Server"; + position = "0 70"; + extent = "400 55"; + profile = "GuiMenuButtonProfile"; + command = "openMultiPlayerMenu();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuJoinSrvrBtn) { + text = "Join Server"; + position = "0 140"; + extent = "400 55"; + profile = "GuiMenuButtonProfile"; + command = "openJoinServerMenu();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuOptionBtn) { + text = "Options"; + position = "0 210"; + extent = "400 55"; + profile = "GuiMenuButtonProfile"; + command = "openOptionsMenu();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuWorldEditBtn) { + text = "Open World Editor"; + position = "0 280"; + extent = "400 55"; + profile = "GuiMenuButtonProfile"; + command = "openWorldEditorBtn();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuGuiEditBtn) { + text = "Open GUI Editor"; + position = "0 350"; + extent = "400 55"; + profile = "GuiMenuButtonProfile"; + command = "openGUIEditorBtn();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuExitBtn) { + text = "Exit"; + position = "0 420"; + extent = "400 55"; + profile = "GuiMenuButtonProfile"; + command = "quit();"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript new file mode 100644 index 000000000..2dd07c18a --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript @@ -0,0 +1,67 @@ +function MainMenuButtons::onWake(%this) +{ +} + +function MainMenuButtons::onSleep(%this) +{ +} + +//Optional, as the check defaults to true, but here as an example case +function MainMenuButtonList::canOpen(%this) +{ + return true; +} + +function MainMenuButtonList::onOpen(%this) +{ + MainMenuButtonList.setAsActiveMenuList(); + + $activeMenuButtonContainer-->button1.disable(); + $activeMenuButtonContainer-->button2.disable(); + $activeMenuButtonContainer-->button3.disable(); + $activeMenuButtonContainer-->button4.set("btn_a", "Return", "Go", "MainMenuButtonList.activate();"); + $activeMenuButtonContainer-->button5.disable(); +} + +//Optional, as the check defaults to true, but here as an example case +function MainMenuButtonList::canClose(%this) +{ + return true; +} + + +function MainMenuButtonList::onClose(%this) +{ +} + +function openSinglePlayerMenu() +{ + $pref::HostMultiPlayer=false; + MainMenuGui.pushPage(ChooseLevelDlg); +} + +function openMultiPlayerMenu() +{ + $pref::HostMultiPlayer=true; + MainMenuGui.pushPage(ChooseLevelDlg); +} + +function openJoinServerMenu() +{ + MainMenuGui.pushPage(JoinServerMenu); +} + +function openOptionsMenu() +{ + MainMenuGui.pushPage(OptionsMenu); +} + +function openWorldEditorBtn() +{ + fastLoadWorldEdit(1); +} + +function openGUIEditorBtn() +{ + fastLoadGUIEdit(1); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui index 775e910f0..414f1ccb3 100644 --- a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui @@ -1,17 +1,12 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiControl(ChooseLevelDlg) { - position = "0 0"; extent = "1024 768"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; + profile = "GuiNonModalDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; canSaveDynamicFields = "1"; Enabled = "1"; launchInEditor = "0"; @@ -20,294 +15,91 @@ $guiContent = new GuiControl(ChooseLevelDlg) { new GuiControl(ChooseLevelWindow) { position = "48 56"; extent = "928 655"; - minExtent = "8 2"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiBitmapBarCtrl() { - percent = "100"; - vertical = "0"; - flipClip = "0"; - bitmapAsset = "UI:panel_image"; - color = "255 255 255 255"; - position = "0 0"; + BitmapAsset = "UI:panel_image"; extent = "927 40"; - minExtent = "8 2"; horizSizing = "width"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl(LevelSelectTitle) { text = "SINGLE PLAYER"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "22 10"; extent = "307 28"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "MenuHeaderText"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiBitmapBarCtrl() { - percent = "100"; - vertical = "0"; - flipClip = "0"; - bitmapAsset = "UI:panel_low_image"; - color = "255 255 255 255"; + BitmapAsset = "UI:panel_low_image"; position = "0 40"; extent = "927 618"; - minExtent = "8 2"; horizSizing = "width"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiBitmapCtrl() { - bitmapAsset = "UI:no_preview_image"; - color = "255 255 255 255"; - wrap = "0"; + BitmapAsset = "Core_Rendering:missingTexture_image"; position = "513 71"; extent = "400 300"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; internalName = "CurrentPreview"; - canSave = "1"; canSaveDynamicFields = "1"; Enabled = "1"; }; new GuiTextCtrl() { text = "Example Level"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "514 375"; extent = "398 27"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "MenuHeaderText"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; internalName = "LevelName"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl() { text = "Description:"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "522 410"; extent = "91 18"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "MenuSubHeaderText"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; internalName = "LevelDescriptionLabel"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiMLTextCtrl() { - lineSpacing = "2"; - allowColorChars = "0"; - maxChars = "-1"; text = "This is placeholder text"; - useURLMouseCursor = "0"; position = "522 436"; extent = "391 14"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMLWhiteTextProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; internalName = "LevelDescription"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiScrollCtrl() { - willFirstRespond = "1"; hScrollBar = "dynamic"; vScrollBar = "dynamic"; - lockHorizScroll = "0"; - lockVertScroll = "0"; - constantThumbHeight = "0"; - childMargin = "0 0"; - mouseWheelScrollSpeed = "-1"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "0 40"; extent = "450 580"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMenuScrollProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiGameListMenuCtrl(LevelList) { - debugRender = "0"; callbackOnInputs = "1"; position = "1 1"; extent = "450 90"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "DefaultListMenuProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; class = "UIMenuButtonList"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - }; }; - new GuiControl(ChooseLevelButtonHolder) { - position = "189 711"; - extent = "646 40"; - minExtent = "8 2"; - horizSizing = "center"; - vertSizing = "top"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - class = "MenuInputButtonContainer"; - canSave = "1"; - canSaveDynamicFields = "0"; - - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "./"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "363 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "goButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "./"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Back"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "507 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "backButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript index adfb088b0..d15887f72 100644 --- a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript +++ b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript @@ -26,6 +26,12 @@ function ChooseLevelDlg::onWake( %this ) if(!isObject(LevelListEntries)) new ArrayObject(LevelListEntries){}; + if(!isObject(ChooseLevelAssetQuery)) + new AssetQuery(ChooseLevelAssetQuery); +} + +function ChooseLevelDlg::onOpen(%this) +{ LevelList.clearRows(); LevelListEntries.empty(); @@ -33,10 +39,10 @@ function ChooseLevelDlg::onWake( %this ) ChooseLevelWindow->LevelDescriptionLabel.visible = false; ChooseLevelWindow->LevelDescription.visible = false; - %assetQuery = new AssetQuery(); - AssetDatabase.findAssetType(%assetQuery, "LevelAsset"); + ChooseLevelAssetQuery.clear(); + AssetDatabase.findAssetType(ChooseLevelAssetQuery, "LevelAsset"); - %count = %assetQuery.getCount(); + %count = ChooseLevelAssetQuery.getCount(); if(%count == 0 && !IsDirectory("tools")) { @@ -44,13 +50,13 @@ function ChooseLevelDlg::onWake( %this ) MessageBoxOK("Error", "No levels were found in any modules. Please ensure you have modules loaded that contain gameplay code and level files.", "Canvas.popDialog(ChooseLevelDlg); if(isObject(ChooseLevelDlg.returnGui) && ChooseLevelDlg.returnGui.isMethod(\"onReturnTo\")) ChooseLevelDlg.returnGui.onReturnTo();"); - %assetQuery.delete(); + ChooseLevelAssetQuery.delete(); return; } for(%i=0; %i < %count; %i++) { - %assetId = %assetQuery.getAsset(%i); + %assetId = ChooseLevelAssetQuery.getAsset(%i); if(AssetDatabase.getAssetModule(%assetId).ModuleId $= "ToolsModule") continue; @@ -97,12 +103,12 @@ function ChooseLevelDlg::onWake( %this ) LevelSelectTitle.setText("CREATE SERVER"); ChooseLevelButtonHolder.setActive(); -} -function ChooseLevelButtonHolder::onWake(%this) -{ - %this-->goButton.set("btn_a", "Return", "Start Level", "ChooseLevelDlg.beginLevel();"); - %this-->backButton.set("btn_b", "Escape", "Back", "ChooseLevelDlg.backOut();"); + $activeMenuButtonContainer-->button1.disable(); + $activeMenuButtonContainer-->button2.disable(); + $activeMenuButtonContainer-->button3.disable(); + $activeMenuButtonContainer-->button4.set("btn_a", "Return", "Start Level", "ChooseLevelDlg.beginLevel();"); + $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", %this @ ".navigation.popPage();"); } function ChooseLevelDlg::onSleep( %this ) @@ -202,10 +208,3 @@ function ChooseLevelDlg::beginLevel(%this) StartGame(); } } - -function ChooseLevelDlg::backOut(%this) -{ - Canvas.popDialog(ChooseLevelDlg); - if(isObject(ChooseLevelDlg.returnGui) && ChooseLevelDlg.returnGui.isMethod("onReturnTo")) - ChooseLevelDlg.returnGui.onReturnTo(); -} diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui index c812e624c..758d1bf32 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui @@ -1,559 +1,159 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiControl(JoinServerMenu) { - position = "0 0"; extent = "1024 768"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; + profile = "GuiNonModalDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "1"; - returnGui = "MainMenuGui"; - - new GuiInputCtrl(JoinServerMenuInputHandler) { - sendAxisEvents = "1"; - sendBreakEvents = "1"; - sendModifierEvents = "0"; - ignoreMouseEvents = "1"; - lockMouse = "0"; - position = "-10 0"; - extent = "10 10"; - minExtent = "8 2"; horizSizing = "width"; vertSizing = "height"; - profile = "GuiInputCtrlProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; canSaveDynamicFields = "0"; - }; + new GuiControl(JoinServerWindow) { position = "48 56"; extent = "928 655"; - minExtent = "8 2"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiBitmapBarCtrl() { - percent = "100"; - vertical = "0"; - flipClip = "0"; BitmapAsset = "UI:panel_image"; - color = "255 255 255 255"; - position = "0 0"; extent = "927 40"; - minExtent = "8 2"; horizSizing = "width"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl() { text = "JOIN SERVER"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "22 10"; extent = "207 28"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "MenuHeaderText"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiBitmapBarCtrl() { - percent = "100"; - vertical = "0"; - flipClip = "0"; BitmapAsset = "UI:panel_low_image"; - color = "255 255 255 255"; position = "0 40"; extent = "927 618"; - minExtent = "8 2"; horizSizing = "width"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl(JS_status) { text = "No servers found."; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "392 47"; extent = "148 18"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "MenuSubHeaderText"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl() { text = "Players"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "269 67"; extent = "36 18"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMLWhiteTextProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl() { text = "Version"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "335 67"; extent = "38 18"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMLWhiteTextProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl() { text = "Game"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "412 67"; extent = "28 18"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMLWhiteTextProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl() { text = "Ping"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "212 67"; extent = "20 18"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMLWhiteTextProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl() { text = "Server Name"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "12 67"; extent = "63 18"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMLWhiteTextProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiScrollCtrl() { - willFirstRespond = "1"; hScrollBar = "dynamic"; vScrollBar = "dynamic"; - lockHorizScroll = "0"; - lockVertScroll = "0"; - constantThumbHeight = "0"; - childMargin = "0 0"; - mouseWheelScrollSpeed = "-1"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "19 98"; extent = "890 501"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMenuScrollProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiStackControl(JoinServerList) { - stackingType = "Vertical"; - horizStacking = "Left to Right"; - vertStacking = "Top to Bottom"; padding = "10"; - dynamicSize = "1"; - dynamicNonStackExtent = "0"; - dynamicPos = "0"; changeChildSizeToFit = "0"; - changeChildPosition = "1"; position = "1 1"; extent = "888 16"; - minExtent = "16 16"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - class = "MenuList"; + superClass = "MenuList"; }; }; new GuiControl(JS_queryStatus) { position = "16 615"; extent = "900 35"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; visible = "0"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; hidden = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiProgressCtrl(JS_statusBar) { - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "84 0"; extent = "695 35"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiProgressProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiButtonCtrl(JS_cancelQuery) { text = "Cancel!"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 0"; extent = "84 35"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; command = "JoinServerDlg.cancel();"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl(JS_statusText) { text = "Querying master server"; maxLength = "255"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "84 0"; extent = "695 35"; minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - }; }; - new GuiControl(JoinServerButtonHolder) { - position = "116 711"; - extent = "791 40"; - minExtent = "8 2"; - horizSizing = "center"; - vertSizing = "top"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - class = "MenuInputButtonContainer"; - canSave = "1"; - canSaveDynamicFields = "0"; - - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - BitmapAsset = "UI:Keyboard_Black_Return_image"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Join"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "507 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "0"; - command = "JoinServerMenu.join();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "joinButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - BitmapAsset = "UI:Keyboard_Black_Escape_image"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Back"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "651 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "JoinServerMenu.backOut();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "backButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - BitmapAsset = "UI:Keyboard_Black_Q_image"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Query LAN"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "JoinServerMenu.queryLan();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "queryLANButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - BitmapAsset = "UI:Keyboard_Black_E_image"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Query Online"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "144 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "JoinServerMenu.query();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "queryInternetButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - BitmapAsset = "UI:Keyboard_Black_R_image"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Refresh"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "325 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "JoinServerMenu.refresh();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "refreshButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript index 1fe75bd46..c4d9fff24 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript @@ -1,26 +1,17 @@ function JoinServerMenu::onWake(%this) { - JoinServerButtonHolder.setActive(); - - JoinServerList.setAsActiveMenuList(); - - JoinServerMenuInputHandler.setFirstResponder(); } -function JoinServerButtonHolder::onWake(%this) +function JoinServerMenu::onOpen(%this) { - %this-->joinButton.set("btn_start", "Return", "Join", "JoinServerMenu.join();"); - %this-->backButton.set("btn_b", "Escape", "Back", "JoinServerMenu.backOut();"); - %this-->refreshButton.set("btn_y", "R", "Refresh", "JoinServerMenu.refresh();"); - %this-->queryLANButton.set("btn_a", "Q", "Query LAN", "JoinServerMenu.queryLan();"); - %this-->queryInternetButton.set("btn_x", "E", "Query Online", "JoinServerMenu.query();"); -} + JoinServerList.setAsActiveMenuList(); -function JoinServerMenuInputHandler::onInputEvent(%this, %device, %action, %state) -{ - if(%state) - $activeMenuButtonContainer.processInputs(%device, %action); + $activeMenuButtonContainer-->button1.set("btn_y", "R", "Refresh", "JoinServerMenu.refresh();"); + $activeMenuButtonContainer-->button2.set("btn_a", "Q", "Query LAN", "JoinServerMenu.queryLan();"); + $activeMenuButtonContainer-->button3.set("btn_x", "E", "Query Online", "JoinServerMenu.query();"); + $activeMenuButtonContainer-->button4.set("btn_start", "Return", "Join", "JoinServerMenu.join();"); + $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", "cancelServerQuery(); " @ %this @ ".navigation.popPage();"); } //---------------------------------------- @@ -79,7 +70,7 @@ function JoinServerMenu::join(%this) function JoinServerMenu::refresh(%this) { cancelServerQuery(); - %index= JS_serverList.getSelectedId(); + %index= JoinServerList.getActiveRow(); // The server info index is stored in the row along with the // rest of displayed info. @@ -93,16 +84,6 @@ function JoinServerMenu::refreshSelectedServer( %this ) querySingleServer( $JoinGameAddress, 0 ); } -//---------------------------------------- -function JoinServerMenu::backOut(%this) -{ - cancelServerQuery(); - - Canvas.popDialog(JoinServerMenu); - if(isObject(JoinServerMenu.returnGui) && JoinServerMenu.returnGui.isMethod("onReturnTo")) - JoinServerMenu.returnGui.onReturnTo(); -} - //---------------------------------------- function JoinServerMenu::update(%this) { @@ -124,7 +105,7 @@ function JoinServerMenu::update(%this) JoinServerList.add(%serverBtn); } - JoinServerButtonHolder-->joinButton.setActive(JoinServerList.getCount() > 0); + $activeMenuButtonContainer-->button4.setActive(JoinServerList.getCount() > 0); } //---------------------------------------- diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui index 6b1dad9ee..ab1fbb714 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui @@ -1,41 +1,23 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { BitmapAsset = "UI:backgrounddark_image"; - useVariable = "0"; - tile = "0"; - position = "0 0"; extent = "1024 768"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "1"; - Enabled = "1"; - isDecoy = "0"; - navigationIndex = "-1"; + superClass = "UINavigation"; + canSaveDynamicFields = "0"; new GuiBitmapCtrl(MainMenuAppLogo) { BitmapAsset = "UI:Torque_3D_logo_alt_image"; - color = "255 255 255 255"; - wrap = "0"; position = "550 30"; extent = "443 139"; - minExtent = "8 2"; horizSizing = "left"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; canSaveDynamicFields = "1"; autoFitExtents = "0"; bitmapMode = "Stretched"; @@ -45,239 +27,98 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { useModifiers = "0"; useStates = "1"; }; - new GuiStackControl(MainMenuButtonList) { - stackingType = "Vertical"; - horizStacking = "Left to Right"; - vertStacking = "Top to Bottom"; - padding = "15"; - dynamicSize = "0"; - dynamicNonStackExtent = "0"; - dynamicPos = "0"; - changeChildSizeToFit = "1"; - changeChildPosition = "1"; - position = "312 111"; - extent = "400 477"; - minExtent = "16 16"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - class = "MenuList"; - - new GuiButtonCtrl(MainMenuSinglePlayerBtn) { - text = "Single Player"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 0"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "openSinglePlayerMenu();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(MainMenuCreateSrvrBtn) { - text = "Create Server"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 70"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "openMultiPlayerMenu();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(MainMenuJoinSrvrBtn) { - text = "Join Server"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 140"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "openJoinServerMenu();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(MainMenuOptionBtn) { - text = "Options"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 210"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "openOptionsMenu();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(MainMenuWorldEditBtn) { - text = "Open World Editor"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 280"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "openWorldEditorBtn();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(MainMenuGuiEditBtn) { - text = "Open GUI Editor"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 350"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "openGUIEditorBtn();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(MainMenuExitBtn) { - text = "Exit"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 420"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "quit();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - }; new GuiControl(MainMenuButtonHolder) { - position = "189 711"; - extent = "646 40"; - minExtent = "8 2"; + position = "143 711"; + extent = "736 40"; horizSizing = "center"; vertSizing = "top"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; class = "MenuInputButtonContainer"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiIconButtonCtrl() { - buttonMargin = "4 4"; BitmapAsset = "UI:Keyboard_Black_Return_image"; - iconLocation = "Left"; sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "507 0"; + position = "11 0"; extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; + command = "MainMenuButtonList.activate();"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "goButton"; + internalName = "button1"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Right"; + text = "Go"; + position = "155 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuButtonList.activate();"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button2"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Right"; + text = "Go"; + position = "299 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuButtonList.activate();"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button3"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Right"; + text = "Go"; + position = "443 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuButtonList.activate();"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button4"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Right"; + text = "Go"; + position = "587 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuButtonList.activate();"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button5"; class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; }; }; new GuiInputCtrl(MainMenuInputHandler) { - class = "MenuInputHandler"; sendAxisEvents = "1"; sendBreakEvents = "1"; - sendModifierEvents = "0"; ignoreMouseEvents = "1"; - lockMouse = "0"; position = "-50 0"; extent = "10 10"; - minExtent = "8 2"; horizSizing = "width"; vertSizing = "height"; profile = "GuiInputCtrlProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; + class = "MenuInputHandler"; }; }; //--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript index c626c4952..0fc08009e 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript @@ -5,66 +5,20 @@ function MainMenuGui::onAdd(%this) function MainMenuGui::onWake(%this) { - MainMenuButtonList.setAsActiveMenuList(); MainMenuButtonHolder.setActive(); MainMenuInputHandler.setFirstResponder(); -} - -function MainMenuGui::onSleep(%this) -{ - MainMenuButtonHolder.hidden = true; + + %this.setRootPage(MainMenuButtonList); + + %this.resizePages = true; } function MainMenuButtonHolder::onWake(%this) { - %this-->goButton.set("btn_a", "Return", "Go", "MainMenuButtonList.activate();"); -} - -function openSinglePlayerMenu() -{ - $pref::HostMultiPlayer=false; - Canvas.pushDialog(ChooseLevelDlg); - ChooseLevelDlg.returnGui = MainMenuGui; - MainMenuButtonList.hidden = true; - MainMenuButtonHolder.hidden = true; -} - -function openMultiPlayerMenu() -{ - $pref::HostMultiPlayer=true; - Canvas.pushDialog(ChooseLevelDlg); - ChooseLevelDlg.returnGui = MainMenuGui; - MainMenuButtonList.hidden = true; -} - -function openJoinServerMenu() -{ - Canvas.pushDialog(JoinServerMenu); - JoinServerMenu.returnGui = MainMenuGui; - MainMenuButtonList.hidden = true; -} - -function openOptionsMenu() -{ - Canvas.pushDialog(OptionsMenu); - OptionsMenu.returnGui = MainMenuGui; - MainMenuButtonList.hidden = true; -} - -function openWorldEditorBtn() -{ - fastLoadWorldEdit(1); -} - -function openGUIEditorBtn() -{ - fastLoadGUIEdit(1); -} - -function MainMenuGui::onReturnTo(%this) -{ - MainMenuButtonList.hidden = false; - MainMenuButtonList.setFirstResponder(); - MainMenuButtonHolder.setActive(); - MainMenuButtonList.setAsActiveMenuList(); -} + //clean slate + %this-->button1.disable(); + %this-->button2.disable(); + %this-->button3.disable(); + %this-->button4.disable(); + %this-->button5.disable(); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index 3b1999ed9..8e80ed1cd 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -1,12 +1,14 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiControl(OptionsMenu) { extent = "1024 768"; - profile = "GuiDefaultProfile"; + profile = "GuiNonModalDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; + horizSizing = "width"; + vertSizing = "height"; canSaveDynamicFields = "0"; - new GuiControl() { + new GuiControl(OptionsMenuContainer) { position = "48 56"; extent = "928 655"; horizSizing = "aspectCenter"; @@ -33,7 +35,7 @@ $guiContent = new GuiControl(OptionsMenu) { new GuiTextCtrl() { text = "OPTIONS"; position = "22 7"; - extent = "120 28"; + extent = "220 28"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; @@ -77,7 +79,7 @@ $guiContent = new GuiControl(OptionsMenu) { vertSizing = "height"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - class = "MenuList"; + superClass = "MenuList"; new GuiButtonCtrl() { text = "Display"; @@ -118,6 +120,14 @@ $guiContent = new GuiControl(OptionsMenu) { command = "populateGamepadSettingsList();"; tooltipProfile = "GuiToolTipProfile"; }; + new GuiButtonCtrl() { + text = "Example Options"; + position = "0 225"; + extent = "248 35"; + profile = "GuiMenuButtonProfile"; + command = "testExampleOptions();"; + tooltipProfile = "GuiToolTipProfile"; + }; }; }; new GuiPanel() { @@ -141,81 +151,76 @@ $guiContent = new GuiControl(OptionsMenu) { padding = "5"; changeChildSizeToFit = "0"; position = "1 1"; - extent = "661 30"; + extent = "661 170"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - class = "MenuList"; + superClass = "MenuList"; + new GuiGameSettingsCtrl() { + PreviousBitmapAsset = "UI:previousOption_n_image"; + NextBitmapAsset = "UI:nextOption_n_image"; + columnSplit = "198"; + useMouseEvents = "1"; + extent = "661 30"; + horizSizing = "width"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuOptionsButton"; + }; + new GuiGameSettingsCtrl() { + PreviousBitmapAsset = "UI:previousOption_n_image"; + NextBitmapAsset = "UI:nextOption_n_image"; + columnSplit = "198"; + useMouseEvents = "1"; + position = "0 35"; + extent = "661 30"; + horizSizing = "width"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuOptionsButton"; + }; + new GuiGameSettingsCtrl() { + PreviousBitmapAsset = "UI:previousOption_n_image"; + NextBitmapAsset = "UI:nextOption_n_image"; + columnSplit = "198"; + useMouseEvents = "1"; + position = "0 70"; + extent = "661 30"; + horizSizing = "width"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuOptionsButton"; + }; + new GuiGameSettingsCtrl() { + PreviousBitmapAsset = "UI:previousOption_n_image"; + NextBitmapAsset = "UI:nextOption_n_image"; + columnSplit = "198"; + useMouseEvents = "1"; + position = "0 105"; + extent = "661 30"; + horizSizing = "width"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuOptionsButton"; + }; + new GuiGameSettingsCtrl() { + PreviousBitmapAsset = "UI:previousOption_n_image"; + NextBitmapAsset = "UI:nextOption_n_image"; + columnSplit = "198"; + useMouseEvents = "1"; + position = "0 140"; + extent = "661 30"; + horizSizing = "width"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuOptionsButton"; }; }; }; }; }; - new GuiControl(OptionsButtonHolder) { - position = "116 711"; - extent = "791 40"; - horizSizing = "center"; - vertSizing = "top"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - class = "MenuInputButtonContainer"; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_R_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Reset"; - position = "173 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - command = "OptionsMenu.resetToDefaults();"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "resetButton"; - class = "MenuInputButton"; - }; - new GuiIconButtonCtrl(OptionsMenuSelectButton) { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Select"; - position = "507 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - command = ""; - tooltipProfile = "GuiToolTipProfile"; - internalName = "SelectButton"; - class = "MenuInputButton"; - }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Escape_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Back"; - position = "651 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - command = "OptionsMenu.backOut();"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "backButton"; - class = "MenuInputButton"; - }; - }; - new GuiInputCtrl(OptionsMenuInputHandler) { - sendAxisEvents = "1"; - sendBreakEvents = "1"; - ignoreMouseEvents = "1"; - position = "-50 0"; - extent = "10 10"; - horizSizing = "left"; - vertSizing = "top"; - profile = "GuiInputCtrlProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuInputHandler"; }; }; //--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 40540c1ab..5d04d4588 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -72,16 +72,7 @@ function OptionsMenu::onAdd(%this) callOnModules("populateOptionsMenuCategories", "Game"); } -function OptionsMenuSettingsList::onAdd(%this) -{ -} - -function OptionsMenuSettingsList::getOptionsList(%this, %index) -{ - -} - -function OptionsMenu::onWake(%this) +function OptionsMenu::onOpen(%this) { OptionsMenuCategoryList.clear(); @@ -116,22 +107,48 @@ function OptionsMenu::onWake(%this) %this.unappliedChanges.empty(); - MainMenuButtonList.hidden = true; - OptionsMenuCategoryList.setAsActiveMenuList(); - OptionsButtonHolder.setActive(); + $activeMenuButtonContainer-->button1.set("btn_back", "R", "Reset", "OptionsMenu.resetToDefaults();"); + $activeMenuButtonContainer-->button1.disable(); + $activeMenuButtonContainer-->button3.set("", "Space", "Apply", "OptionsMenu.apply();"); + $activeMenuButtonContainer-->button4.set("btn_a", "", "Select", "OptionsMenu.select();"); + $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", %this @ ".navigation.popPage();"); +} - OptionsMenuInputHandler.setFirstResponder(); +function OptionsMenu::canClose(%this) +{ + if(OptionsMenuSettingsList.isActiveMenuList()) + { + OptionsMenuCategoryList.setAsActiveMenuList(); + %this.updateSelectButton(); + return false; + } + else + { + if(%this.unappliedChanges.count() != 0) + { + MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", + "OptionsMenu.apply(); MainMenuGUI.popPage();", "%this.unappliedChanges.empty(); " @ %this @ ".navigation.popPage();", + "Apply", "Discard"); + return false; + } + } + + return true; } -function OptionsButtonHolder::onWake(%this) +function OptionsMenu::onClose(%this) { - %this-->resetButton.set("btn_back", "R", "Reset", "OptionsMenu.resetToDefaults();"); - %this-->selectButton.set("btn_a", "Return", "Select", "OptionsMenu.select();", true); - %this-->backButton.set("btn_b", "Escape", "Back", "OptionsMenu.backOut();"); - //OptionsMenuCategoryList.getObject(0).performClick(); +} + +function OptionsMenuSettingsList::onAdd(%this) +{ +} + +function OptionsMenuSettingsList::getOptionsList(%this, %index) +{ } function OptionsMenu::select(%this) @@ -281,9 +298,6 @@ function OptionsMenu::apply(%this) export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); OptionsMenu.unappliedChanges.empty(); - - //Now we can back out of the options menu - OptionsMenu.doOptionsMenuBackOut(); } function OptionsMenu::resetToDefaults(%this) @@ -346,7 +360,9 @@ function populateDisplaySettingsList() OptionsMenu.currentCategory = "Display"; + if(isObject(OptionName)) OptionName.setText(""); + if(isObject(OptionDescription)) OptionDescription.setText(""); %apiList = ""; @@ -433,7 +449,9 @@ function populateGraphicsSettingsList() OptionsMenu.currentCategory = "Graphics"; + if(isObject(OptionName)) OptionName.setText(""); + if(isObject(OptionDescription)) OptionDescription.setText(""); %yesNoList = "No\tYes"; @@ -598,7 +616,9 @@ function populateAudioSettingsList() OptionsMenu.currentCategory = "Audio"; + if(isObject(OptionName)) OptionName.setText(""); + if(isObject(OptionDescription)) OptionDescription.setText(""); %buffer = sfxGetAvailableDevices(); @@ -691,7 +711,9 @@ function populateKeyboardMouseSettingsList() OptionsMenu.currentCategory = "Keyboard & Mouse"; + if(isObject(OptionName)) OptionName.setText(""); + if(isObject(OptionDescription)) OptionDescription.setText(""); $remapListDevice = "keyboard"; @@ -706,7 +728,9 @@ function populateGamepadSettingsList() OptionsMenu.currentCategory = "Gamepad"; + if(isObject(OptionName)) OptionName.setText(""); + if(isObject(OptionDescription)) OptionDescription.setText(""); $remapListDevice = "gamepad"; @@ -723,48 +747,6 @@ function OptionsMenuList::activateRow(%this) OptionsMenuSettingsList.setFirstResponder(); } -function OptionsMenu::backOut(%this) -{ - if(OptionsMenuSettingsList.isActiveMenuList()) - { - OptionsMenuCategoryList.setAsActiveMenuList(); - %this.updateSelectButton(); - } - else - { - if(%this.unappliedChanges.count() != 0) - { - MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", "OptionsMenu.apply();", "OptionsMenu.doOptionsMenuBackOut();", "Apply", "Discard"); - } - else - { - %this.doOptionsMenuBackOut(); - } - } -} - -function OptionsMenu::doOptionsMenuBackOut(%this) -{ - //save the settings and then back out - if(OptionsMain.hidden == false) - { - //we're not in a specific menu, so we're actually exiting - Canvas.popDialog(OptionsMenu); - - if(isObject(OptionsMenu.returnGui) && OptionsMenu.returnGui.isMethod("onReturnTo")) - OptionsMenu.returnGui.onReturnTo(); - } - else - { - OptionsMain.hidden = false; - ControlsMenu.hidden = true; - GraphicsMenu.hidden = true; - CameraMenu.hidden = true; - AudioMenu.hidden = true; - ScreenBrightnessMenu.hidden = true; - } -} - function OptionsMenuSettingsList::setRowEnabled(%this, %row, %status) { %option = %this.getObject(%row); @@ -955,16 +937,25 @@ function getDisplayDeviceName() // function MenuOptionsButton::onMouseEnter(%this) { + if(isObject(OptionName)) OptionName.setText(%this.getLabel()); + if(isObject(OptionDescription)) OptionDescription.setText(%this.getToolTip()); } function MenuOptionsButton::onMouseLeave(%this) { + if(isObject(OptionName)) OptionName.setText(""); + if(isObject(OptionDescription)) OptionDescription.setText(""); } +function MenuOptionsButton::onHighlighted(%this, %state) +{ + MenuListButton::onHighlighted(%this, %state); +} + function MenuOptionsButton::onChange(%this) { %optionMode = %this.getMode(); diff --git a/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui b/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui index 0ba6e7ce5..f0b9494e7 100644 --- a/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui @@ -1,178 +1,163 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiControl(PauseMenu) { - position = "0 0"; extent = "1024 768"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; + superClass = "UINavigation"; canSaveDynamicFields = "1"; - tamlReader = "19772"; - tile = "0"; - useVariable = "0"; new GuiChunkedBitmapCtrl(PauseMenuBG) { - bitmapAsset = "UI:hudfill_image"; - useVariable = "0"; - tile = "0"; - position = "0 0"; + BitmapAsset = "UI:hudfill_image"; extent = "1024 768"; - minExtent = "8 2"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; canSaveDynamicFields = "1"; }; new GuiControl() { position = "162 125"; extent = "700 518"; - minExtent = "8 2"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiStackControl(PauseMenuList) { - stackingType = "Vertical"; - horizStacking = "Left to Right"; - vertStacking = "Top to Bottom"; padding = "15"; dynamicSize = "0"; - dynamicNonStackExtent = "0"; - dynamicPos = "0"; - changeChildSizeToFit = "1"; - changeChildPosition = "1"; - position = "0 0"; extent = "700 320"; - minExtent = "16 16"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - class = "MenuList"; + superClass = "MenuList"; + + new GuiButtonCtrl() { + text = "Options"; + extent = "700 55"; + profile = "GuiMenuButtonProfile"; + command = "openPauseMenuOptions();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Exit to Menu"; + position = "0 70"; + extent = "700 55"; + profile = "GuiMenuButtonProfile"; + command = "pauseMenuExitToMenu();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Exit to Desktop"; + position = "0 140"; + extent = "700 55"; + profile = "GuiMenuButtonProfile"; + command = "pauseMenuExitToDesktop();"; + tooltipProfile = "GuiToolTipProfile"; + }; }; }; new GuiControl(PauseButtonHolder) { - position = "189 711"; - extent = "646 40"; - minExtent = "8 2"; + position = "144 711"; + extent = "736 40"; horizSizing = "center"; vertSizing = "top"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; class = "MenuInputButtonContainer"; - canSave = "1"; - canSaveDynamicFields = "0"; new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter"; - iconLocation = "Left"; + BitmapAsset = "UI:Keyboard_Black_Return_image"; sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "OK"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "363 0"; + position = "11 0"; extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "PauseMenuList.activateRow();"; + visible = "0"; + active = "0"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "goButton"; + internalName = "button1"; class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; + hidden = "1"; }; new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Esc"; - iconLocation = "Left"; + BitmapAsset = "UI:Keyboard_Black_Return_image"; sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Back"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "507 0"; + position = "155 0"; extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "Canvas.popDialog();"; + visible = "0"; + active = "0"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "backButton"; + internalName = "button2"; class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; + hidden = "1"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Right"; + position = "299 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + visible = "0"; + active = "0"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button3"; + class = "MenuInputButton"; + hidden = "1"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Right"; + position = "443 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + visible = "0"; + active = "0"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button4"; + class = "MenuInputButton"; + hidden = "1"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Right"; + position = "587 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + visible = "0"; + active = "0"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button5"; + class = "MenuInputButton"; + hidden = "1"; }; }; new GuiInputCtrl(PauseMenuInputHandler) { - class = "MenuInputHandler"; sendAxisEvents = "1"; sendBreakEvents = "1"; - sendModifierEvents = "0"; ignoreMouseEvents = "1"; - lockMouse = "0"; position = "-50 0"; extent = "10 10"; - minExtent = "8 2"; horizSizing = "width"; vertSizing = "height"; profile = "GuiInputCtrlProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; + class = "MenuInputHandler"; }; }; //--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript b/Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript index 8751c16ef..715690443 100644 --- a/Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript @@ -23,6 +23,8 @@ function PauseMenu::onWake(%this) PauseMenuList.setAsActiveMenuList(); PauseButtonHolder.setActive(); PauseMenuInputHandler.setFirstResponder(); + + %this.resizePages = true; } @@ -35,37 +37,28 @@ function PauseMenu::onSleep(%this) } } -function PauseMenu::onReturnTo(%this) -{ - PauseMenuList.hidden = false; - PauseMenuList.setAsActiveMenuList(); - PauseButtonHolder.setActive(); - PauseMenuInputHandler.setFirstResponder(); -} - function openPauseMenuOptions() { - Canvas.pushDialog(OptionsMenu); - OptionsMenu.returnGui = PauseMenu; - PauseMenuList.hidden = true; + PauseMenu.pushPage(OptionsMenu); } function pauseMenuExitToMenu() { - PauseMenuList.hidden = true; - MessageBoxOKCancel("Exit?", "Do you wish to exit to the Main Menu?", "escapeFromGame();", "PauseMenu.onReturnTo();"); + MessageBoxOKCancel("Exit?", "Do you wish to exit to the Main Menu?", "escapeFromGame();", ""); } function pauseMenuExitToDesktop() { - PauseMenuList.hidden = true; - MessageBoxOKCancel("Exit?", "Do you wish to exit to the desktop?", "quit();", "PauseMenu.onReturnTo();"); + MessageBoxOKCancel("Exit?", "Do you wish to exit to the desktop?", "quit();", ""); } function PauseButtonHolder::onWake(%this) { - %this-->goButton.set("btn_a", "Return", "OK", "PauseMenuList.activate();", true); - %this-->backButton.set("btn_b", "Escape", "Back", "Canvas.popDialog();"); + %this-->button1.disable(); + %this-->button2.disable(); + %this-->button3.disable(); + %this-->button4.set("btn_a", "", "OK", "PauseMenuList.activate();"); + %this-->button4.set("btn_b", "Escape", "Back", "Canvas.popDialog();"); } function PauseMenu::addPauseMenuButton(%this, %buttonText, %buttonCallback) diff --git a/Templates/BaseGame/game/data/UI/images/Inputs/Keyboard & Mouse/Keyboard_Black_Mouse_Left.png b/Templates/BaseGame/game/data/UI/images/Inputs/Keyboard & Mouse/Keyboard_Black_Mouse_Left.png new file mode 100644 index 0000000000000000000000000000000000000000..1b1eb8639a400413ca5fb3fe43b59a0f73358359 GIT binary patch literal 3184 zcmV-$43G1PP)2~nWLACX7lkhC<`*pqR_qOMJfQ@=lYz{-0{uv*(@9;|ce2kQp}?%LdXt=fKqx0;DSlM0C3p-{{R3C z!#F%YKd($$XVI7`A^Cj%Z|F4q=BNgi4NB<&I)ojRN~M3!sve;elFQ}(N(k8_gzSc0 z_Bf!F9#Bf3yng-qKVg;|Dk1rN{vjdcQJ7^4!2YXOul^oZVWAL`PN$QJL}DMno~S&x zx3_V6dWzH2Q%}04X;@lXLZu?kEKo`h4a3+C!`6gCNTE>pHv*8cy}gY@B7v=~E$F(A zt*tEpK(SclKL7OTQ#^h8)RT7e=1ttZd6WBmkED9N4%@cfzd^{OlpdB!r9X{)a7sjE z7m&~AA7TI*+uPeH7K`}kqmS_J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(CcYRGFq}1KpoUBqm;0+wFD-KG38j3`4Ywm@y{hfJ#}T ztgpZs_GYs=b*zh{xk2rO$C3bUK|-_GVlJY_tAKM&42gaUAEXSS+^3r40g# zvf#R|&)bh0tyU|@pi3b{ifjDx<;!106`J-es9A)lO^mU!tP^)+#wzys1jli16e*@@ z1`X*ylU0T^LMoNYH@yRXJuppE`1R21hHkeTC>@nbMau3eKyq-=ahx3p9K~w2daX(6 z9~c&Z&t#S*b9o!%(mx-Oc{CTg`>pwrg}V{D%> z_DIz!pFl(h+!u?*e*pMvm}lehI1-73Qd`pxtJt>f`^;<*7-MD2vL2~EbV N002ovPDHLkV1n9-G)Vve literal 0 HcmV?d00001 diff --git a/Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript b/Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript index 66d6aaf39..78cefa95c 100644 --- a/Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript @@ -54,23 +54,41 @@ function UIMenuButtonList::onAxisEvent(%this, %device, %action, %axisVal) /// \param %keyboardButton (string) The button to set for when using keyboard/mouse input. /// \param %text (string) The text to display next to the A button graphic. /// \param %command (string) The command executed when the A button is pressed. -/// \param %gamepadOnly (bool) If true, will only show the button when working in the gamepad input mode -function MenuInputButton::set(%this, %gamepadButton, %keyboardButton, %text, %command, %gamepadOnly) +function MenuInputButton::set(%this, %gamepadButton, %keyboardButton, %text, %command) { + %this.setHidden(false); + %set = (! ((%text $= "") && (%command $= ""))); - %this.setText(%text); - %this.setActive(%set); - %this.setVisible(%set); %this.gamepadButton = %gamepadButton; %this.keyboardButton = %keyboardButton; - if(%gamepadOnly $= "") - %gamepadOnly = false; + if(%gamepadButton $= "") + %this.gamepadValid = false; + else + %this.gamepadValid = true; - %this.gamepadOnly = %gamepadOnly; + if(%keyboardButton $= "") + %this.kbmValid = false; + else + %this.kbmValid = true; + if((!%this.kbmValid && $activeControllerType !$= "gamepad") || + (!%this.gamepadValid && $activeControllerType $= "gamepad")) + %set = false; + + %this.setText(%text); %this.Command = %command; + + %this.refresh(); +} + +function MenuInputButton::disable(%this) +{ + %this.setText(""); + %this.Command = ""; + %this.setActive(false); + %this.setVisible(false); } /// Refreshes the specific button, updating it's visbility status and the displayed input image @@ -78,8 +96,10 @@ function MenuInputButton::refresh(%this) { %set = (! ((%this.text $= "") && (%this.command $= ""))); - //Special-case of where we're in keyboard+mouse mode, but the menubutton is gamepad only mode, so we early out - if(%this.gamepadOnly && $activeControllerType !$= "gamepad") + //Do a check so if a MenuInput is selectively bound and we're not using the + //matched input type, then we skip + if((!%this.kbmValid && $activeControllerType !$= "gamepad") || + (!%this.gamepadValid && $activeControllerType $= "gamepad")) %set = false; %this.setActive(%set); @@ -430,7 +450,7 @@ function MenuList::setAsActiveMenuList(%this, %startPosition, %menuMode) $activeMenuList = %this; $activeMenuList.hidden = false; - $activeMenuListPosition = %startPosition; + $activeMenuList.ListPosition = %startPosition; $activeMenuListMode = %menuMode; %this.refresh(); @@ -440,21 +460,21 @@ function MenuList::setAsActiveMenuList(%this, %startPosition, %menuMode) function MenuList::activate(%this) { //check for a highlighted element - if($activeMenuListPosition.y > -1 && $activeMenuListPosition < $activeMenuList.getCount()) + if($activeMenuList.ListPosition.y > -1 && $activeMenuList.ListPosition < $activeMenuList.getCount()) { - %btn = $activeMenuList.getObject($activeMenuListPosition.y); + %btn = $activeMenuList.getObject($activeMenuList.ListPosition.y); %btn.performClick(); } } function MenuList::refresh(%this) { - %selectedObject = 0; + %selectedObject = -1; for(%i=0; %i < $activeMenuList.getCount(); %i++) { %btn = $activeMenuList.getObject(%i); - %isSelected = %i == $activeMenuListPosition.y; + %isSelected = %i == $activeMenuList.ListPosition.y; %btn.setHighlighted(%isSelected); @@ -462,8 +482,32 @@ function MenuList::refresh(%this) %selectedObject = %i; } + if(isObject(%this.buttonPointerCtrl)) + { + if(%selectedObject != -1) + { + %this.buttonPointerCtrl.setHidden(false); + + %buttonCenter = $activeMenuList.getObject(%selectedObject).getGlobalCenter(); + + if(%this.centerButtonPointerCtrl) + { + %this.buttonPointerCtrl.setCenter(%buttonCenter.x, %buttonCenter.y); + } + else + { + //if we're not centering, then left-justify + %this.buttonPointerCtrl.setCenter(%buttonCenter.x - $activeMenuList.getObject(%selectedObject).extent.x / 2, %buttonCenter.y); + } + } + else + { + %this.buttonPointerCtrl.setHidden(true); + } + } + if($activeMenuList.isMethod("onNavigate")) - $activeMenuList.onNavigate($activeMenuListPosition.y); + $activeMenuList.onNavigate($activeMenuList.ListPosition.y); %parent = $activeMenuList.getParent(); if(%parent.getClassName() $= "GuiScrollCtrl") @@ -474,18 +518,18 @@ function MenuList::refresh(%this) function MenuList::navigateUp(%this) { - $activeMenuListPosition.y -= 1; - if($activeMenuListPosition.y < 0) - $activeMenuListPosition.y = 0; + $activeMenuList.ListPosition.y -= 1; + if($activeMenuList.ListPosition.y < 0) + $activeMenuList.ListPosition.y = 0; %this.refresh(); } function MenuList::navigateDown(%this) { - $activeMenuListPosition.y += 1; - if($activeMenuListPosition.y >= $activeMenuList.getCount()) - $activeMenuListPosition.y = $activeMenuList.getCount()-1; + $activeMenuList.ListPosition.y += 1; + if($activeMenuList.ListPosition.y >= $activeMenuList.getCount()) + $activeMenuList.ListPosition.y = $activeMenuList.getCount()-1; %this.refresh(); } @@ -496,7 +540,7 @@ function MenuList::navigateLeft() //this could readily be expanded upon to handle grids like for inventory screens //or the like - %btn = $activeMenuList.getObject($activeMenuListPosition.y); + %btn = $activeMenuList.getObject($activeMenuList.ListPosition.y); if(%btn.getClassName() $= "GuiGameSettingsCtrl" && %btn.isEnabled()) { %mode = %btn.getMode(); @@ -522,7 +566,7 @@ function MenuList::navigateLeft() function MenuList::navigateRight() { - %btn = $activeMenuList.getObject($activeMenuListPosition.y); + %btn = $activeMenuList.getObject($activeMenuList.ListPosition.y); if(%btn.getClassName() $= "GuiGameSettingsCtrl" && %btn.isEnabled()) { %mode = %btn.getMode(); @@ -548,5 +592,32 @@ function MenuList::navigateRight() function MenuList::getActiveRow(%this) { - return $activeMenuListPosition.y; + return $activeMenuList.ListPosition.y; +} + +function MenuListButton::onHighlighted(%this, %state) +{ + %parentContainer = %this.getParent(); + if(%parentContainer.class $= "MenuList" || %parentContainer.superClass $= "MenuList") + { + if(isObject(%parentContainer.buttonPointerCtrl)) + { + if(%state) + { + %parentContainer.buttonPointerCtrl.setHidden(false); + + %buttonCenter = %this.getGlobalCenter(); + + if(%parentContainer.centerButtonPointerCtrl) + { + %parentContainer.buttonPointerCtrl.setGlobalCenter(%buttonCenter.x, %buttonCenter.y); + } + else + { + //if we're not centering, then left-justify + %parentContainer.buttonPointerCtrl.setGlobalCenter(%buttonCenter.x - %this.extent.x / 2, %buttonCenter.y); + } + } + } + } } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript b/Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript new file mode 100644 index 000000000..d10e5847d --- /dev/null +++ b/Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript @@ -0,0 +1,220 @@ +function UINavigation::setRootPage(%this, %rootPage) +{ + if(!isObject(%this.pageStack)) + { + %this.pageStack = new ArrayObject(); + } + + if(isObject(%this.rootPage)) + { + %canClose = true; + if(%this.rootPage.isMethod("canClose")) + %canClose = %this.rootPage.call("canClose"); + + if(!%canClose) + return; //if we're not allowed to close, just bail out wholesale because clearly + //something is blocking changes to pages + + %this.remove(%this.rootPage); + if(%this.rootPage.isMethod("onClose")) + %this.rootPage.call("onClose"); + + %this.rootPage.navigation = ""; + } + + %this.rootPage = %rootPage; + + %this.add(%rootPage); + if(%this.resizePages) + { + %rootPage.resize(%this.position.x, %this.position.y, + %this.extent.x, %this.extent.y); + } + %rootPage.navigation = %this; + + if(%rootPage.isMethod("onOpen")) + %rootPage.call("onOpen"); +} + +function UINavigation::pushPage(%this, %newPage, %callback) +{ + if(!isObject(%this.pageStack)) + { + %this.pageStack = new ArrayObject(); + } + + %canChange = true; + if(%newPage.isMethod("canOpen")) + %canChange = %newPage.call("canOpen"); + + if(!%canChange) + return; + + %currentPage = %this.getCurrentPage(); + if(isObject(%currentPage)) + { + if(%currentPage.isMethod("canClose")) + %canChange = %currentPage.call("canClose"); + + if(!%canChange) + return; + + if(%currentPage.isMethod("onClose")) + %currentPage.call("onClose"); + } + + %this.pageStack.push_back(%newPage); + %this.add(%newPage); + if(%this.resizePages) + { + %newPage.resize(%this.position.x, %this.position.y, + %this.extent.x, %this.extent.y); + } + + if(%newPage.isMethod("onOpen")) + %newPage.call("onOpen"); + + %newPage.navigation = %this; + + if(%callback !$= "") + eval(%callback); +} + +function UINavigation::popPage(%this, %callback) +{ + if(%this.pageStack.count() == 0) + return; + + %currentPage = %this.getCurrentPage(); + if(isObject(%currentPage)) + { + %canChange = true; + if(%currentPage.isMethod("canClose")) + %canChange = %currentPage.call("canClose"); + + if(!%canChange) + return; + } + + %prevPage = %this.getPreviousPage(); + if(isObject(%prevPage)) + { + %canChange = true; + if(%prevPage.isMethod("canOpen")) + %canChange = %prevPage.call("canOpen"); + + if(!%canChange) + return; + } + + if(isObject(%currentPage)) + { + if(%currentPage.isMethod("onClose")) + { + %currentPage.call("onClose"); + } + + %this.pageStack.pop_back(); + %this.remove(%currentPage); + + %currentPage.navigation = ""; + } + + %newTopPage = %this.getCurrentPage(); + if(%newTopPage.isMethod("onOpen")) + %newTopPage.call("onOpen"); + + if(%callback !$= "") + eval(%callback); +} + +function UINavigation::popToRoot(%this, %callback) +{ + %pageChanged = false; + while(%this.getPageCount() != 0) + { + %currentPage = %this.getCurrentPage(); + if(isObject(%currentPage)) + { + if(%currentPage.isMethod("canClose")) + %canChange = %currentPage.call("canClose"); + + if(!%canChange) + return; + } + + %prevPage = %this.getPreviousPage(); + if(isObject(%prevPage)) + { + if(%prevPage.isMethod("canOpen")) + %canChange = %prevPage.call("canOpen"); + + if(!%canChange) + return; + } + + if(isObject(%currentPage)) + { + if(%currentPage.isMethod("onClose")) + { + %currentPage.call("onClose"); + } + + %this.pageStack.pop_back(); + %this.remove(%currentPage); + + %currentPage.navigation = ""; + } + + %newTopPage = %this.getCurrentPage(); + if(%newTopPage.isMethod("onOpen")) + %newTopPage.call("onOpen"); + + %pageChanged = true; + } + + if(%pageChanged && %callback !$= "") + eval(%callback); +} + +function UINavigation::getCurrentPage(%this) +{ + if(isObject(%this.pageStack) && %this.pageStack.count() != 0) + { + return %this.pageStack.getKey(%this.pageStack.count()-1); + } + else + { + if(isObject(%this.rootPage)) + return %this.rootPage; + } + + return 0; +} + +function UINavigation::getPreviousPage(%this) +{ + if(isObject(%this.pageStack) && %this.pageStack.count() > 1) + { + return %this.pageStack.getKey(%this.pageStack.count()-2); + } + else + { + if(isObject(%this.rootPage)) + return %this.rootPage; + } + + return 0; +} + +function UINavigation::getPageCount(%this) +{ + %count = 0; + if(isObject(%this.pageStack)) + %count = %this.pageStack.count(); + + if(isObject(%this.rootPage)) + %count++; + + return %count; +} \ No newline at end of file