|
| 1 | +using QSB.Utility; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using UnityEngine; |
| 5 | +using UnityEngine.UI; |
| 6 | + |
| 7 | +namespace QSB.Menus; |
| 8 | + |
| 9 | +internal class PreflightChecklistAdjustment : MonoBehaviour, IAddComponentOnStart |
| 10 | +{ |
| 11 | + private string[] _preflightOptionsToRemove = new string[] |
| 12 | + { |
| 13 | + "UIElement-FreezeTimeTranslating", |
| 14 | + "UIElement-FreezeTimeShipLog", |
| 15 | + "UIElement-FreezeTimeConversations", |
| 16 | + "UIElement-FreezeTimeTranslator", |
| 17 | + "UIElement-FreezeTimeDialogue" |
| 18 | + }; |
| 19 | + |
| 20 | + private MenuOption[] DestroyFreezeTimeOptions(MenuOption[] options) |
| 21 | + { |
| 22 | + var remainingMenuOptions = new List<MenuOption>(); |
| 23 | + foreach (var preflightChecklistOption in options) |
| 24 | + { |
| 25 | + if (_preflightOptionsToRemove.Contains(preflightChecklistOption.name)) |
| 26 | + { |
| 27 | + GameObject.Destroy(preflightChecklistOption.gameObject); |
| 28 | + } |
| 29 | + else |
| 30 | + { |
| 31 | + remainingMenuOptions.Add(preflightChecklistOption); |
| 32 | + } |
| 33 | + } |
| 34 | + return remainingMenuOptions.ToArray(); |
| 35 | + } |
| 36 | + |
| 37 | + public void Awake() |
| 38 | + { |
| 39 | + QSBSceneManager.OnPostSceneLoad += (_, loadScene) => |
| 40 | + { |
| 41 | + if (QSBCore.IsInMultiplayer && loadScene.IsUniverseScene()) |
| 42 | + { |
| 43 | + // PREFLIGHT MENU IN THE SHIP |
| 44 | + var suitMenuManager = GameObject.FindObjectOfType<SuitMenuManager>()._mainMenu; |
| 45 | + suitMenuManager._menuOptions = DestroyFreezeTimeOptions(suitMenuManager._menuOptions); |
| 46 | + |
| 47 | + // Remove cosmetic elements from ship preflight checklist |
| 48 | + var suitOptionsMenu = GameObject.Find("PauseMenu/PreFlightCanvas/OptionsMenu-Panel/SuitOptionsDisplayPanel/SuitOptionsMainMenu/"); |
| 49 | + GameObject.Destroy(suitOptionsMenu.transform.Find("FreezeTimeImage").gameObject); |
| 50 | + GameObject.Destroy(suitOptionsMenu.transform.Find("Box-FreezeTimeBorder").gameObject); |
| 51 | + |
| 52 | + |
| 53 | + // PREFLIGHT MENU IN THE OPTIONS MENU |
| 54 | + var settingsMenuView = GameObject.FindObjectOfType<SettingsMenuView>(); |
| 55 | + settingsMenuView._listSettingsOptions = DestroyFreezeTimeOptions(settingsMenuView._listSettingsOptions); |
| 56 | + |
| 57 | + // This one also points to the same options, have to remove the destroyed objects from it |
| 58 | + var menuGameplayPreFlight = GameObject.Find("PauseMenu/OptionsCanvas/OptionsMenu-Panel/OptionsDisplayPanel/GameplayMenu/MenuGameplayPreFl/").GetComponent<Menu>(); |
| 59 | + Delay.RunNextFrame(() => menuGameplayPreFlight._menuOptions = menuGameplayPreFlight._menuOptions.Where(x => x != null).ToArray()); |
| 60 | + } |
| 61 | + }; |
| 62 | + } |
| 63 | +} |
0 commit comments