From 833d17ccfcf1d75c61425609c7c5e00b67412d81 Mon Sep 17 00:00:00 2001 From: Areloch Date: Thu, 4 Jan 2024 20:30:11 -0600 Subject: [PATCH] - Cleaned up elements in ChooseLevelMenu and ensured onscreen button had correct command - Ensured there's always a level selected by default on the chooseLevelMenu - Added a small delay to try and ensure the level/server config tab key hints align properly - Added logic so you can't swap to server config page on chooseLevelMenu if in single player mode - Added server description to server details line on JoinServerMenu - Ensured programmatically added elements aren't saved out if GUIs are edited - Fixed back-out prompt in OptionsMenu properly backs out so it doesn't break menu nav --- .../game/data/UI/guis/ChooseLevelMenu.gui | 6 +++--- .../game/data/UI/guis/ChooseLevelMenu.tscript | 16 +++++++++------- .../BaseGame/game/data/UI/guis/GameMenu.tscript | 1 + .../game/data/UI/guis/joinServerMenu.tscript | 3 ++- .../game/data/UI/guis/optionsMenu.tscript | 13 ++++++------- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui index fb98ec6e9..15ad905d0 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -120,7 +120,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { }; }; new GuiBitmapCtrl(LevelPreviewBitmap) { - BitmapAsset = "testMaps:EmptyLevel_preview_image"; + BitmapAsset = ""; position = "448 0"; extent = "440 440"; horizSizing = "left"; @@ -128,7 +128,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl(LevelNameText) { - text = "EmptyLevel"; + text = ""; position = "448 445"; extent = "440 20"; horizSizing = "left"; @@ -324,7 +324,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "OptionsMenu.applySettings();"; + command = "ChooseLevelBegin(1);"; tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl(ChooseLevelBackBtn) { diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index 6d22b40d4..970ff0f87 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -103,6 +103,8 @@ function ChooseLevelMenu::onWake(%this) LevelPreviewArray.add(%preview); } + LevelPreviewArray.listPosition = 0; + // Also add the new level mission as defined in the world editor settings // if we are choosing a level to launch in the editor. if ( %this.launchInEditor ) @@ -115,7 +117,10 @@ function ChooseLevelMenu::onWake(%this) else ChooseLevelTitleText.setText("CREATE SERVER"); - %this.openMenu(0); + ChooseLevelMenuTabList.visible = $pref::HostMultiPlayer; + ChooseLevelMenuNavButtonOverlay.visible = $pref::HostMultiPlayer; + + %this.schedule(32, openMenu, 0); } if(!isObject( ChooseLevelActionMap ) ) @@ -144,7 +149,7 @@ function ChooseLevelMenu::syncGUI(%this) %btn.setHighlighted(true); %buttonPosX = %btn.position.x + ChooseLevelMenuTabList.position.x; - + ChooseLevelMenuPrevNavIcon.position.x = %buttonPosX; ChooseLevelMenuNextNavIcon.position.x = %buttonPosX + %btn.extent.x - 40; @@ -154,9 +159,6 @@ function ChooseLevelMenu::syncGUI(%this) ChooseLevelMenuPrevNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuPrevMenu")); ChooseLevelMenuNextNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuNextMenu")); - - ChooseLevelMenuTabList.visible = $pref::HostMultiPlayer; - ChooseLevelMenuNavButtonOverlay.visible = $pref::HostMultiPlayer; } function LevelPreviewArray::syncGUI(%this) @@ -169,7 +171,7 @@ function LevelPreviewArray::syncGUI(%this) function ChooseLevelMenuPrevMenu(%val) { - if(%val) + if(%val && $pref::HostMultiPlayer) { %currentIdx = ChooseLevelMenu.currentMenuIdx; ChooseLevelMenu.currentMenuIdx -= 1; @@ -185,7 +187,7 @@ function ChooseLevelMenuPrevMenu(%val) function ChooseLevelMenuNextMenu(%val) { - if(%val) + if(%val && $pref::HostMultiPlayer) { %currentIdx = ChooseLevelMenu.currentMenuIdx; ChooseLevelMenu.currentMenuIdx += 1; diff --git a/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript index 23a86e491..58f9fd145 100644 --- a/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript @@ -33,6 +33,7 @@ function GameMenu::onWake(%this) text = %buttonText; class = "GameMenuButton"; command = "GameMenu.openGameMenu(\"" @ %buttonText @ "\");"; + canSave = false; }; %stackWidth += %textWidth + 40; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript index a0f5f38a9..24aad2152 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript @@ -116,7 +116,7 @@ function JoinServerMenu::update(%this) %serverEntry = %this.addServerEntry(); %serverEntry-->serverNameTxt.text = $ServerInfo::Name; - %serverEntry-->serverDetailsTxt.text = $ServerInfo::MissionName @ " | v" @ $ServerInfo::Version @ " | " @ $ServerInfo::MissionType; + %serverEntry-->serverDetailsTxt.text = $ServerInfo::MissionName @ " | v" @ $ServerInfo::Version @ " | " @ $ServerInfo::MissionType @ " | " @ $ServerInfo::Info; %serverEntry-->pingTxt.text = $ServerInfo::Ping @ " ms"; %serverEntry-->playerCountTxt.text = $ServerInfo::PlayerCount @ "|" @ $ServerInfo::MaxPlayers; @@ -165,6 +165,7 @@ function JoinServerMenu::addServerEntry(%this) horizSizing = "width"; vertSizing = "bottom"; class = "JoinServerServerEntry"; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index f297b1159..44321630a 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -688,7 +688,7 @@ function tryCloseOptionsMenu(%val) if(%unappliedVideoChanges || %unappliedAudioChanges) { MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", - "OptionsMenu.applyChangedOptions();", "Canvas.popDialog(OptionsMenu);", + "OptionsMenu.applyChangedOptions(); BaseUIBackOut(1);", "BaseUIBackOut(1);", "Apply", "Discard"); } else @@ -732,9 +732,7 @@ function OptionsMenu::applyChangedOptions(%this) //Finally, write our prefs to file %prefPath = getPrefpath(); export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); - - BaseUIBackOut(1); - + if($optionsChangeRequiresRestart) MessageBoxOK("Restart Required", "Some of your changes require the game to be restarted."); } @@ -767,6 +765,7 @@ function addOptionGroup(%displayName) extent = "500 45"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; + canSave = false; }; return %group; @@ -822,7 +821,7 @@ function addOptionEntry(%optionObj) optionsObject = %optionObj; currentOptionIndex = %qualityLevelIndex; selectionID = OptionsMenu.optsListCount; - canSave = "0"; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; @@ -918,7 +917,7 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide horizSizing = "width"; vertSizing = "bottom"; class = "OptionsListSliderEntry"; - canSave = "0"; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; @@ -1012,11 +1011,11 @@ function addActionMapEntry(%actionMap, %device, %keyMap, %index, %description) horizSizing = "width"; vertSizing = "bottom"; class = "OptionsKeybindEntry"; - canSave = "0"; actionMap = %actionMap; device = %device; keymap = %keyMap; remapIndex = %index; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile;