diff --git a/QSB/Menus/PreflightChecklistAdjustment.cs b/QSB/Menus/PreflightChecklistAdjustment.cs new file mode 100644 index 00000000..95b411f4 --- /dev/null +++ b/QSB/Menus/PreflightChecklistAdjustment.cs @@ -0,0 +1,62 @@ +using QSB.Utility; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace QSB.Menus; + +internal class PreflightChecklistAdjustment : MonoBehaviour, IAddComponentOnStart +{ + private string[] _preflightOptionsToRemove = new string[] + { + "UIElement-FreezeTimeTranslating", + "UIElement-FreezeTimeShipLog", + "UIElement-FreezeTimeConversations", + "UIElement-FreezeTimeTranslator", + "UIElement-FreezeTimeDialogue" + }; + + private MenuOption[] DestroyFreezeTimeOptions(MenuOption[] options) + { + var remainingMenuOptions = new List(); + foreach (var preflightChecklistOption in options) + { + if (_preflightOptionsToRemove.Contains(preflightChecklistOption.name)) + { + GameObject.Destroy(preflightChecklistOption.gameObject); + } + else + { + remainingMenuOptions.Add(preflightChecklistOption); + } + } + return remainingMenuOptions.ToArray(); + } + + public void Awake() + { + QSBSceneManager.OnPostSceneLoad += (_, loadScene) => + { + if (QSBCore.IsInMultiplayer && loadScene.IsUniverseScene()) + { + // PREFLIGHT MENU IN THE SHIP + var suitMenuManager = GameObject.FindObjectOfType()._mainMenu; + suitMenuManager._menuOptions = DestroyFreezeTimeOptions(suitMenuManager._menuOptions); + + // Remove cosmetic elements from ship preflight checklist + var suitOptionsMenu = GameObject.Find("PauseMenu/PreFlightCanvas/OptionsMenu-Panel/SuitOptionsDisplayPanel/SuitOptionsMainMenu/"); + GameObject.Destroy(suitOptionsMenu.transform.Find("FreezeTimeImage").gameObject); + GameObject.Destroy(suitOptionsMenu.transform.Find("Box-FreezeTimeBorder").gameObject); + + + // PREFLIGHT MENU IN THE OPTIONS MENU + var settingsMenuView = GameObject.FindObjectOfType(); + settingsMenuView._listSettingsOptions = DestroyFreezeTimeOptions(settingsMenuView._listSettingsOptions); + + // This one also points to the same options, so just update the list to not have the old broken ones + var menuGameplayPreFlight = GameObject.Find("PauseMenu/OptionsCanvas/OptionsMenu-Panel/OptionsDisplayPanel/GameplayMenu/MenuGameplayPreFl/").GetComponent(); + menuGameplayPreFlight._menuOptions = settingsMenuView._listSettingsOptions; + } + }; + } +}