public override void Initialize()
        {
            QuickLogger.Debug("Initialize Formatter", true);

            _slotState = Animator.StringToHash("SlotState");

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <AnimationManager>();
            }

            if (ColorManager == null)
            {
                ColorManager = gameObject.AddComponent <ColorManager>();
                ColorManager.Initialize(gameObject, DSSModelPrefab.BodyMaterial);
            }

            if (DisplayManager == null)
            {
                DisplayManager = gameObject.AddComponent <DSSServerFormattingStationDisplay>();
                DisplayManager.Setup(this);
            }

            if (DumpContainer == null)
            {
                DumpContainer = new DumpContainer();
                DumpContainer.Initialize(transform, AuxPatchers.BaseDumpReceptacle(), AuxPatchers.NotAllowed(), AuxPatchers.CannotBeStored(), this, 1, 1);
            }

            IsInitialized = true;
        }
Beispiel #2
0
        public override void Initialize()
        {
            if (DumpContainer == null)
            {
                DumpContainer = new DumpContainer();
                DumpContainer.Initialize(transform, "Item Display Receptical", AuxPatchers.NotAllowed(), AuxPatchers.CannotBeStored(), this, 1, 1);
            }

            var icon = GameObjectHelpers.FindGameObject(gameObject, "Icon");

            _icon   = icon?.AddComponent <uGUI_Icon>();
            _button = InterfaceHelpers.CreateButton(icon, "IconClick", InterfaceButtonMode.Background,
                                                    OnButtonClick, Color.white, Color.gray, 5.0f);


            _amount = GameObjectHelpers.FindGameObject(gameObject, "Text")?.GetComponent <Text>();

            var addBTN = GameObjectHelpers.FindGameObject(gameObject, "AddBTN");

            InterfaceHelpers.CreateButton(addBTN, "AddBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, Color.gray, Color.white, 5.0f, AuxPatchers.ColorPage());

            var deleteBTN = GameObjectHelpers.FindGameObject(gameObject, "DeleteBTN");

            InterfaceHelpers.CreateButton(deleteBTN, "DeleteBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, Color.gray, Color.white, 5.0f, AuxPatchers.ColorPage());

            AddToBaseManager();

            InvokeRepeating(nameof(UpdateScreen), 1f, 1f);

            IsInitialized = true;
        }
Beispiel #3
0
        private void CreateButton(DisplayData data, GameObject buttonPrefab, ButtonData buttonData, ButtonType buttonType, string btnText, string btnName)
        {
            buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
            var mainBtn = buttonPrefab.AddComponent <DSSUIButton>();
            var text    = buttonPrefab.GetComponentInChildren <Text>();

            text.text              = btnText;
            mainBtn.ButtonMode     = InterfaceButtonMode.Background;
            mainBtn.STARTING_COLOR = _startColor;
            mainBtn.HOVER_COLOR    = _hoverColor;
            mainBtn.BtnName        = btnName;
            mainBtn.OnButtonClick  = OnButtonClick;

            switch (buttonType)
            {
            case ButtonType.Home:
                mainBtn.TextLineOne = AuxPatchers.Home();
                mainBtn.Tag         = new TransferData {
                    Manager = buttonData.Manager, ButtonType = buttonType
                };
                break;

            case ButtonType.Item:
                var amount = buttonPrefab.GetComponentInChildren <Text>();
                amount.text = buttonData.Amount.ToString();
                mainBtn.Tag = buttonData.TechType;
                uGUI_Icon trashIcon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                trashIcon.sprite = SpriteManager.Get(buttonData.TechType);
                break;

            case ButtonType.Vehicle:
                mainBtn.TextLineOne = string.Format(AuxPatchers.ViewVehicleStorageFormat(), buttonData.Vehicle.GetName());
                mainBtn.Tag         = new TransferData {
                    Vehicle = buttonData.Vehicle
                };
                uGUI_Icon trashIcon2 = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                trashIcon2.sprite = SpriteManager.Get(buttonData.Vehicle is SeaMoth ? TechType.Seamoth : TechType.Exosuit);
                mainBtn.Vehicle   = buttonData.Vehicle;
                mainBtn.Label     = text;
                break;

            case ButtonType.Container:
                mainBtn.TextLineOne = "";
                mainBtn.Tag         = new TransferData {
                    Container = buttonData.Container
                };
                uGUI_Icon trashIcon3 = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                trashIcon3.sprite = SpriteManager.Get(TechType.VehicleStorageModule);
                mainBtn.Label     = text;
                break;

            case ButtonType.Base:
                mainBtn.TextLineOne = AuxPatchers.ViewBaseStorageFormat();
                mainBtn.Tag         = new TransferData {
                    Manager = buttonData.Manager, ButtonType = buttonType
                };
                break;
            }
        }
Beispiel #4
0
 public void Refresh()
 {
     _baseGrid?.DrawPage();
     _baseItemsGrid?.DrawPage();
     if (_baseNameLabel != null)
     {
         _baseNameLabel.text = _currentBase?.GetBaseName() ?? AuxPatchers.FailedToGetBaseName();
     }
 }
 public override bool CanDeconstruct(out string reason)
 {
     if (_items != null)
     {
         reason = AuxPatchers.HasItemsMessage();
         return(false);
     }
     reason = string.Empty;
     return(true);
 }
Beispiel #6
0
        public static void Patch()
        {
            try
            {
                QuickLogger.Info($"Started patching. Version: {QuickLogger.GetAssemblyVersion(Assembly.GetExecutingAssembly())}");

#if DEBUG
                QuickLogger.DebugLogsEnabled = true;
                QuickLogger.Debug("Debug logs enabled");
#endif

                GlobalBundle = FcAssetBundlesService.PublicAPI.GetAssetBundleByName(FcAssetBundlesService.PublicAPI.GlobalBundleName);

                Configuration = Mod.LoadConfiguration();

                OptionsPanelHandler.RegisterModOptions(new Options());

                AuxPatchers.AdditionalPatching();

                DSSModelPrefab.GetPrefabs();

                AddTechFabricatorItems();

                var antenna = new AntennaBuildable();
                antenna.Patch();

                //Floor Mounted Rack Has Been Cut
                //var floorMountedRack = new FloorMountedRackBuildable();
                //floorMountedRack.Patch();

                var wallMountedRack = new WallMountedRackBuildable();
                wallMountedRack.Patch();

                var terminal = new DSSTerminalC48Buildable();
                terminal.Patch();

                var serverFormattingStation = new ServerFormattingStationBuildable();
                serverFormattingStation.Patch();

                var harmony = new Harmony("com.datastoragesolutions.fstudios");

                harmony.PatchAll(Assembly.GetExecutingAssembly());

                PatchEasyCraft(harmony);
                PatchToolTipFactory(harmony);

                IsDockedVehicleStorageAccessInstalled = QModServices.Main.ModPresent("DockedVehicleStorageAccess");

                QuickLogger.Info("Finished patching");
            }
            catch (Exception ex)
            {
                QuickLogger.Error(ex);
            }
        }
Beispiel #7
0
 public override void UpdateScreen()
 {
     if (_icon == null || _currentTechType == TechType.None)
     {
         return;
     }
     _icon.sprite        = SpriteManager.Get(_currentTechType);
     _amount.text        = $"x{Manager.GetItemCount(_currentTechType)}";
     _button.TextLineOne = string.Format(AuxPatchers.TakeFormatted(), Language.main.Get(_currentTechType));
     _icon.gameObject.SetActive(true);
 }
        private static void GetFilters(StringBuilder sb, bool isFormatted, DSSServerController controller)
        {
            sb.AppendFormat("\n<size=20><color=#FFA500FF>{0}</color> <color=#DDDEDEFF>{1}</color></size>",
                            AuxPatchers.FiltersCheck(), isFormatted);

            if (isFormatted)
            {
                sb.AppendFormat("\n<size=20><color=#FFA500FF>{0}:</color>\n<color=#DDDEDEFF>{1}</color></size>", $"Filters",
                                controller.FCSFilteredStorage.FormatFiltersData());
            }
        }
        internal bool HasVehicles(bool verbose = false)
        {
            var value = DockingBays.Count > 0 && Vehicles.Count > 0;

            if (!value && verbose)
            {
                QuickLogger.Message(AuxPatchers.NoVehiclesDocked(), true);
            }

            return(value);
        }
        public void OnHandHover(GUIHand hand)
        {
            HandReticle main  = HandReticle.main;
            var         state = PowerManager?.GetPowerState() == FCSPowerStates.Powered ? "On" : "Off";

#if SUBNAUTICA
            main.SetInteractTextRaw(Manager?.GetBaseName(), $"{AuxPatchers.Antenna()}: {state} || {AuxPatchers.PowerUsage()}: {PowerManager?.GetPowerUsage():F1}");
#elif BELOWZERO
            main.SetText(HandReticle.TextType.Info, Manager.GetBaseName(), false);
#endif
            main.SetIcon(HandReticle.IconType.Info, 1f);
        }
        public bool AddItemToContainer(InventoryItem item)
        {
            var food = item.item.GetComponentInChildren <Eatable>();

            if (food != null)
            {
                bool successful = false;
                if ((!food.decomposes || item.item.GetTechType() == TechType.CreepvinePiece) && CanBeStored(DumpContainer.GetCount() + 1, item.item.GetTechType()))
                {
                    var rackController = FindValidRack(item.item.GetTechType(), 1, out var slot);
                    if (rackController == null)
                    {
                        return(false);
                    }
                    rackController.AddItemToAServer(item, slot);
                    successful = true;
                }
                else
                {
                    foreach (KeyValuePair <string, FCSConnectableDevice> fcsConnectable in FCSConnectables)
                    {
                        if (fcsConnectable.Value.CanBeStored(1, item.item.GetTechType()) && fcsConnectable.Value.GetTechType() == Mod.GetSeaBreezeTechType())
                        {
                            var result = fcsConnectable.Value.AddItemToContainer(new InventoryItem(item.item), out string reason);
                            successful = true;

                            if (!result)
                            {
                                QuickLogger.Error(reason);
                            }
                            break;
                        }
                    }
                }

                if (!successful)
                {
                    QuickLogger.Message(string.Format(AuxPatchers.NoEmptySeaBreezeFormat(), item.item.GetTechType()), true);
                    return(false);
                }
            }
            else
            {
                var rackController = FindValidRack(item.item.GetTechType(), 1, out var slot);
                if (rackController == null)
                {
                    return(false);
                }
                rackController.AddItemToAServer(item, slot);
            }

            return(true);
        }
        public bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            var successful = false;
            var food       = pickupable.GetComponentInChildren <Eatable>();

            if (food != null)
            {
#if DEBUG
                QuickLogger.Debug($"Food Check {CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType())}", true);
#endif

                if ((!food.decomposes || AllowedFoodItems.Contains(pickupable.GetTechType())) && CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType()))
                {
                    successful = true;
                }
                else
                {
                    foreach (KeyValuePair <string, FCSConnectableDevice> seaBreeze in FCSConnectables)
                    {
                        if (seaBreeze.Value.GetTechType() != Mod.GetSeaBreezeTechType())
                        {
                            continue;
                        }
                        if (!seaBreeze.Value.CanBeStored(1, pickupable.GetTechType()))
                        {
                            continue;
                        }
                        successful = true;
                    }
                }

                if (!successful)
                {
                    QuickLogger.Message(AuxPatchers.NoFoodItems(), true);
                }


                QuickLogger.Debug($"Food Allowed Result: {successful}", true);
                return(successful);
            }
#if DEBUG
            QuickLogger.Debug($"{DumpContainer.GetCount() + 1}", true);
#endif

            if (!CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType()))
            {
                QuickLogger.Message(AuxPatchers.CannotBeStored(), true);
                return(false);
            }

            return(true);
        }
Beispiel #13
0
        private void Update()
        {
            if (!hover)
            {
                return;
            }
            HandReticle.main.SetIcon(HandReticle.IconType.Rename);
#if SUBNAUTICA
            HandReticle.main.SetInteractTextRaw(AuxPatchers.SearchForItemsMessage(), "");
#elif BELOWZERO
            HandReticle.main.SetTextRaw(HandReticle.TextType.Hand, AuxPatchers.SearchForItemsMessage());
#endif
        }
        private bool ValidateCheck(InventoryItem item)
        {
            if (Mod.IsFilterAddedWithType(item.item.GetTechType()))
            {
                QuickLogger.Info(string.Format(AuxPatchers.BlackListFormat(), Language.main.Get(item.item.GetTechType())),
                                 true);
                return(true);
            }

            if (!_manager.IsAllowedToAdd(item.item, true))
            {
                return(true);
            }

            return(false);
        }
        private void Initialize(SubRoot habitat)
        {
            ReadySaveData();
            FCSConnectableAwake_Patcher.AddEventHandlerIfMissing(AlertedNewFCSConnectablePlaced);
            FCSConnectableDestroy_Patcher.AddEventHandlerIfMissing(AlertedFCSConnectableDestroyed);

            GetFCSConnectables();


            if (NameController == null)
            {
                NameController = new NameController();
                NameController.Initialize(AuxPatchers.Submit(), Mod.AntennaFriendlyName);
                NameController.OnLabelChanged += OnLabelChangedMethod;

                if (string.IsNullOrEmpty(_savedData?.InstanceID))
                {
                    NameController.SetCurrentName(GetDefaultName());
                }
                else
                {
                    NameController.SetCurrentName(_savedData?.BaseName);
                }
            }

            if (DumpContainer == null)
            {
                DumpContainer = habitat.gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(habitat.transform, AuxPatchers.BaseDumpReceptacle(), AuxPatchers.NotAllowed(),
                                         AuxPatchers.CannotBeStored(), this);
            }

            if (DockingManager == null)
            {
                DockingManager = habitat.gameObject.AddComponent <DSSVehicleDockingManager>();
                DockingManager.Initialize(habitat, this);
                DockingManager.ToggleIsEnabled(_savedData?.AllowDocking ?? false);
            }

            _hasBreakerTripped = _savedData?.HasBreakerTripped ?? false;
        }
Beispiel #16
0
        public override void OnButtonClick(string btnName, object tag)
        {
            if (btnName == string.Empty)
            {
                return;
            }

            switch (btnName)
            {
            case "BaseBTN":
                if (!SubrootCheck())
                {
                    return;
                }
                _currentBase        = ((TransferData)tag).Manager;
                _currentData        = (TransferData)tag;
                _baseNameLabel.text = _currentBase.GetBaseName();

                if (_currentData.ButtonType == ButtonType.Home)
                {
                    GoToPage(TerminalPages.BaseItemsDirect);
                }
                else if (_currentData.ButtonType == ButtonType.Base)
                {
                    _gettingData.text = string.Format(AuxPatchers.GettingData(), _currentBase.GetBaseName());
                    GoToPage(TerminalPages.BaseItems);
                }

                Refresh();
                break;

            case "HomeBTN":
                GoToPage(TerminalPages.Home);
                break;

            case "ItemBTN":
                _currentBase?.RemoveItemFromContainer((TechType)tag);
                break;

            case "DumpBTN":
                _currentBase?.OpenDump(_currentData);
                break;

            case "VehicleDumpBTN":
                _vehicleContainersGrid.DrawPage();
                GoToPage(TerminalPages.StorageContainer);
                break;

            case "VehicleContainerBTN":
                _mono.Manager.DockingManager.OpenContainer(_currentVehicle, ((TransferData)tag).Container);
                break;

            case "TerminalColorBTN":
                GoToPage(TerminalPages.TerminalColorPage);
                _currentColorPage = ColorPage.Terminal;
                break;

            case "AntennaColorBTN":
                var antennas = _mono.Manager.GetCurrentBaseAntenna();

                if (antennas != null)
                {
                    GoToPage(TerminalPages.AntennaColorPage);
                    _currentColorPage = ColorPage.Antenna;
                    UpdateAntennaColorPage();
                }
                else if (_mono.Manager.Habitat.isBase)
                {
                    QuickLogger.Message(AuxPatchers.NoAntennaOnBase(), true);
                }
                else if (_mono.Manager.Habitat.isCyclops)
                {
                    QuickLogger.Message(AuxPatchers.CannotChangeCyclopsAntenna(), true);
                }
                break;

            case "ColorPickerBTN":
                GoToPage(TerminalPages.ColorPageMain);
                break;

            case "ColorItem":
                if (_currentColorPage == ColorPage.Terminal)
                {
                    _mono.TerminalColorManager.ChangeColorMask((Color)tag);
                }
                else
                {
                    ChangeAntennaColor((Color)tag);
                }
                break;

            case "RenameBTN":
                _mono.Manager.ChangeBaseName();
                break;

            case "PowerBTN":
                _mono.Manager.ToggleBreaker();
                break;

            case "SettingsBTN":
                GoToPage(TerminalPages.SettingsPage);
                break;

            case "VehiclesPageBTN":
                if (_mono.Manager.DockingManager.HasVehicles(true))
                {
                    _vehicleGrid.DrawPage();
                    GoToPage(TerminalPages.VehiclesPage);
                }
                else
                {
                    GoToPage(TerminalPages.Home);
                }
                break;

            case "VehicleBTN":
                _currentVehicle = ((TransferData)tag).Vehicle;
                _vehicleContainersGrid.DrawPage();
                GoToPage(TerminalPages.StorageContainer);
                break;

            case "AutoDockBTN":
                _toggle.isOn = _mono.Manager.DockingManager.GetToggleState();
                GoToPage(TerminalPages.DockSettingPage);
                break;

            case "FilterBTN":
                var data = (FilterTransferData)tag;
                if (Mod.IsFilterAdded(data.Filter))
                {
                    Mod.RemoveBlackListFilter(data.Filter);
                    return;
                }
                Mod.AddBlackListFilter(data.Filter);
                break;
            }
        }
Beispiel #17
0
        private void OnLoadBaseGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed || _baseGrid == null || _mono?.SubRoot == null)
                {
                    return;
                }

                _baseGrid.ClearPage();

                var grouped = BaseManager.Managers;

                if (grouped == null)
                {
                    QuickLogger.Debug("Grouped returned null canceling operation");
                    return;
                }

                if (data.EndPosition > grouped.Count)
                {
                    data.EndPosition = grouped.Count;
                }

                if (data.ItemsGrid?.transform == null)
                {
                    QuickLogger.Debug("Items Grid returned null canceling operation");
                    return;
                }

                if (_baseGrid.GetCurrentPage() < 2)
                {
                    CreateButton(data, Instantiate(data.ItemsPrefab), new ButtonData {
                        Manager = _mono.Manager
                    }, ButtonType.Home, AuxPatchers.Home(), "BaseBTN");
                    CreateButton(data, Instantiate(data.ItemsPrefab), new ButtonData(), ButtonType.None, AuxPatchers.GoToVehicles(), "VehiclesPageBTN");
                }

                // QuickLogger.Debug($"Bases Count: {grouped.Count}");
                //QuickLogger.Debug($"Bases Antenna: {_mono.Manager.GetCurrentBaseAntenna()}");

                if (_mono.Manager.GetCurrentBaseAntenna() != null || _mono.Manager.Habitat.isCyclops)
                {
                    for (int i = data.StartPosition; i < data.EndPosition; i++)
                    {
                        //QuickLogger.Debug($"Hab{grouped[i].Habitat} || AS{grouped[i].Habitat.gameObject.activeSelf} || TN{grouped[i].InstanceID == _mono.Manager.InstanceID} || HAN {grouped[i].HasAntenna()} || VIS {grouped[i].IsVisible} || Instance ID : {grouped[i].InstanceID}");
                        if (grouped[i].Habitat == null || !grouped[i].Habitat.gameObject.activeSelf || grouped[i].InstanceID == _mono.Manager.InstanceID || !grouped[i].HasAntenna() || !grouped[i].IsVisible)
                        {
                            continue;
                        }
                        //QuickLogger.Debug($"Adding Base {grouped[i].InstanceID}");

                        GameObject buttonPrefab = Instantiate(data.ItemsPrefab);

                        if (buttonPrefab == null || data.ItemsGrid == null)
                        {
                            if (buttonPrefab != null)
                            {
                                QuickLogger.Debug("Destroying Tab", true);
                                Destroy(buttonPrefab);
                            }
                            return;
                        }

                        QuickLogger.Debug($"Adding Base: {grouped[i].GetBaseName()}", true);
                        CreateButton(data, buttonPrefab, new ButtonData {
                            Manager = grouped[i]
                        }, ButtonType.Base, grouped[i].GetBaseName().TruncateWEllipsis(30), "BaseBTN");
                    }
                }
                else
                {
                    QuickLogger.Debug("GetCurrentBaseAntenna most likely is null");
                }

                _baseGrid.UpdaterPaginator(grouped.Count);
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }
Beispiel #18
0
        private void OnLoadBaseItemsGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed)
                {
                    return;
                }

                QuickLogger.Debug($"OnLoadBaseItemsGrid : {data.ItemsGrid}", true);

                _baseItemsGrid.ClearPage();

                if (_currentBase == null)
                {
                    return;
                }

                var grouped = _currentBase.GetItemsWithin().OrderBy(x => x.Key).ToList();

                if (!string.IsNullOrEmpty(_currentSearchString?.Trim()))
                {
                    grouped = grouped.Where(p => Language.main.Get(p.Key).StartsWith(_currentSearchString.Trim(), StringComparison.OrdinalIgnoreCase)).ToList();
                }

                QuickLogger.Debug($"Grouped Count = {grouped.Count} || Search: {_currentSearchString}", true);


                if (data.EndPosition > grouped.Count)
                {
                    data.EndPosition = grouped.Count;
                }

                for (int i = data.StartPosition; i < data.EndPosition; i++)
                {
                    GameObject buttonPrefab = Instantiate(data.ItemsPrefab);

                    if (buttonPrefab == null || data.ItemsGrid == null)
                    {
                        if (buttonPrefab != null)
                        {
                            Destroy(buttonPrefab);
                        }
                        return;
                    }

                    buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
                    var amount = buttonPrefab.GetComponentInChildren <Text>();
                    amount.text = grouped.ElementAt(i).Value.ToString();
                    var itemBTN = buttonPrefab.AddComponent <InterfaceButton>();
                    itemBTN.ButtonMode     = InterfaceButtonMode.Background;
                    itemBTN.STARTING_COLOR = _startColor;
                    itemBTN.HOVER_COLOR    = _hoverColor;
                    itemBTN.BtnName        = "ItemBTN";
                    itemBTN.TextLineOne    = string.Format(AuxPatchers.TakeFormatted(), Language.main.Get(grouped.ElementAt(i).Key));
                    itemBTN.Tag            = grouped.ElementAt(i).Key;
                    itemBTN.OnButtonClick  = OnButtonClick;

                    uGUI_Icon trashIcon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                    trashIcon.sprite = SpriteManager.Get(grouped.ElementAt(i).Key);
                }
                _counter.text = _currentBase.GetTotalString();
                _baseItemsGrid.UpdaterPaginator(grouped.Count());
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }
Beispiel #19
0
        public override bool FindAllComponents()
        {
            try
            {
                #region Canvas
                var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

                if (canvasGameObject == null)
                {
                    throw new MissingComponentException($"A component cant be found.\nMissing Component: Canvas");
                }
                #endregion

                #region Home Page
                var home = InterfaceHelpers.FindGameObject(canvasGameObject, "HomePage");
                #endregion

                #region Filter Page
                var filterPage = InterfaceHelpers.FindGameObject(canvasGameObject, "FilterPage");
                #endregion

                #region Category Page
                var categoryPage = InterfaceHelpers.FindGameObject(canvasGameObject, "CategoryPage");
                #endregion

                #region Item Page
                var itemPage = InterfaceHelpers.FindGameObject(canvasGameObject, "ItemPage");
                #endregion

                #region Filter Grid

                _filterGrid = _mono.gameObject.AddComponent <GridHelper>();
                _filterGrid.OnLoadDisplay += OnLoadFilterGrid;
                _filterGrid.Setup(3, DSSModelPrefab.FilterItemPrefab, filterPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Item Grid

                _itemGrid = _mono.gameObject.AddComponent <GridHelper>();
                _itemGrid.OnLoadDisplay += OnLoadItemsGrid;
                _itemGrid.Setup(3, DSSModelPrefab.FilterItemPrefab, itemPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Category Grid

                _categoryGrid = _mono.gameObject.AddComponent <GridHelper>();
                _categoryGrid.OnLoadDisplay += OnLoadCategoryGrid;
                _categoryGrid.Setup(3, DSSModelPrefab.FilterItemPrefab, categoryPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Remove Server
                var removeServerBTN = InterfaceHelpers.FindGameObject(filterPage, "RemoveServerBTN");

                InterfaceHelpers.CreateButton(removeServerBTN, "RemoveServerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.RemoveServer());
                #endregion

                #region Add Server
                var addServerBTN = InterfaceHelpers.FindGameObject(home, "AddServerBTN");

                InterfaceHelpers.CreateButton(addServerBTN, "AddServerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.InsertServer());
                #endregion

                #region AddItemBTN
                var itemPageBTN = InterfaceHelpers.FindGameObject(filterPage, "AddItemBTN");

                InterfaceHelpers.CreateButton(itemPageBTN, "AddItemBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.AddFilterItem());
                #endregion

                #region AddCategoryBTN
                var categoryBTN = InterfaceHelpers.FindGameObject(filterPage, "AddCategoryBTN");

                InterfaceHelpers.CreateButton(categoryBTN, "AddCategoryBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.AddFilterCategory());
                #endregion

                return(true);
            }
            catch (Exception e)
            {
                QuickLogger.Error($"{e.Message}: {e.StackTrace}");
                return(false);
            }
        }
        public override bool FindAllComponents()
        {
            try
            {
                #region Canvas
                var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

                if (canvasGameObject == null)
                {
                    QuickLogger.Error("Canvas cannot be found");
                    return(false);
                }
                #endregion

                #region Home
                var home = InterfaceHelpers.FindGameObject(canvasGameObject, "Home");
                #endregion

                #region Powered Off Page
                var poweredOffPage = InterfaceHelpers.FindGameObject(canvasGameObject, "PoweredOff");
                #endregion

                #region ColorPickerPage

                var colorPickerPage = InterfaceHelpers.FindGameObject(canvasGameObject, "ColorPage");

                #endregion

                #region OpenRackBTNButton
                var openRackBTN = InterfaceHelpers.FindGameObject(home, "OpenBTN");

                InterfaceHelpers.CreateButton(openRackBTN, "OpenBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.OpenServerRackPage());
                #endregion

                #region CloseRackBTNButton
                var closeBTN = InterfaceHelpers.FindGameObject(home, "CloseBTN");

                InterfaceHelpers.CreateButton(closeBTN, "CloseBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.CloseServerRackPage());
                #endregion

                #region ColorPickerBTN
                var colorPickerBTN = InterfaceHelpers.FindGameObject(home, "ColorPicker");

                InterfaceHelpers.CreateButton(colorPickerBTN, "ColorPickerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.ColorPage());
                #endregion

                #region ColorPickerMainHomeBTN
                var colorPickerHomeBTN = InterfaceHelpers.FindGameObject(colorPickerPage, "HomeBTN");

                InterfaceHelpers.CreateButton(colorPickerHomeBTN, "HomeBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.GoToHome());
                #endregion

                #region ColorPage
                _colorPickerPage.SetupGrid(20, DSSModelPrefab.ColorItemPrefab, colorPickerPage, OnButtonClick, _startColor, _hoverColor);
                #endregion

                #region AddServerBTN
                var addServerBTN = InterfaceHelpers.FindGameObject(home, "AddServerBTN");

                InterfaceHelpers.CreateButton(addServerBTN, "AddServerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.AddServer());
                #endregion

                _counter = InterfaceHelpers.FindGameObject(home, "Counter")?.GetComponent <Text>();

                var poweredOffMessage = InterfaceHelpers.FindGameObject(poweredOffPage, "Text")?.GetComponent <Text>();
                poweredOffMessage.text = AuxPatchers.PoweredOff();

                return(true);
            }
            catch (Exception e)
            {
                QuickLogger.Error($"{e.Message} || {e.StackTrace}");
                return(false);
            }
        }
 internal void SendBaseMessage(bool state)
 {
     QuickLogger.Message(string.Format(AuxPatchers.BaseOnOffMessage(), GetBaseName(), state ? AuxPatchers.Online() : AuxPatchers.Offline()), true);
 }
Beispiel #22
0
        public override bool FindAllComponents()
        {
            try
            {
                #region Home

                var home = GameObjectHelpers.FindGameObject(gameObject, "Home");

                //connections BTN
                var connectionsBTNObject = GameObjectHelpers.FindGameObject(home, "ConnectionsBTN");
                InterfaceHelpers.CreateButton(connectionsBTNObject, "ConnectionsBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE);

                //Auto Craft BTN
                var autoCraftBTNObject = GameObjectHelpers.FindGameObject(home, "AutoCraftBTN");
                InterfaceHelpers.CreateButton(autoCraftBTNObject, "AutoCraftBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE);

                //Visibility BTN
                var visiblityBTNObject = GameObjectHelpers.FindGameObject(home, "VisiblityBTN");
                InterfaceHelpers.CreateButton(visiblityBTNObject, "VisibilityBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE);

                #endregion

                #region Visibility Page

                var visibilityPage = GameObjectHelpers.FindGameObject(gameObject, "VisibliltyPage");
                _visibilityGrid = _mono.gameObject.AddComponent <GridHelper>();
                _visibilityGrid.OnLoadDisplay += OnLoadVisibilityGrid;
                _visibilityGrid.Setup(18, DSSModelPrefab.OperatorItemPrefab, visibilityPage, _startColor, _hoverColor, OnButtonClick);
                _visibilityGrid.DrawPage();

                var visibilityInputField = InterfaceHelpers.FindGameObject(visibilityPage, "InputField");
                var visibilityText       = InterfaceHelpers.FindGameObject(visibilityInputField, "Placeholder")?.GetComponent <Text>();
                visibilityText.text = AuxPatchers.SearchForItemsMessage();

                var visibilitySearchField = visibilityInputField.AddComponent <SearchField>();
                visibilitySearchField.OnSearchValueChanged += OnVisibiltySearchValueChanged;

                #endregion

                #region Autocrafting Page

                var autoCraftingPage = GameObjectHelpers.FindGameObject(gameObject, "AutoCraftPage");
                _autoCraftingGrid = _mono.gameObject.AddComponent <GridHelper>();
                _autoCraftingGrid.OnLoadDisplay += OnLoadAutoCraftGrid;
                _autoCraftingGrid.Setup(6, DSSModelPrefab.AutoCraftItemPrefab, autoCraftingPage, _startColor, _hoverColor, OnButtonClick);
                _autoCraftingGrid.DrawPage();

                var addCraftBtnObject = GameObjectHelpers.FindGameObject(autoCraftingPage, "AddBTN");
                InterfaceHelpers.CreateButton(addCraftBtnObject, "AddCraftBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE);

                #region Autocrafting Items Page

                var autocraftingitemPage = GameObjectHelpers.FindGameObject(gameObject, "CraftingChoicePage");

                var autocraftingitemBTNObject = GameObjectHelpers.FindGameObject(autocraftingitemPage, "CancelBTN")?.GetComponent <Button>();
                autocraftingitemBTNObject.onClick.AddListener(OnCraftItemCancelButtonClick);

                var autocraftingBTNObject = GameObjectHelpers.FindGameObject(autocraftingitemPage, "Button")?.GetComponent <Button>();
                autocraftingBTNObject?.onClick.AddListener(() => {
                    if (BaseManager.Crafts.Any(x => x?.TechType == _craftTechType))
                    {
                        _messageBoxDialog.ShowMessageBox("This craft request already exists canceling", "craft", FCSMessageBox.OK);
                        return;
                    }
                    GoToPage(OperatorPages.AutoCraft);
                    BaseManager.AddCraft(new FCSOperation {
                        TechType = _craftTechType, Manager = _mono.Manager
                    });
                    _autoCraftingGrid.DrawPage();
                });

                _autocraftItemTechTypeGrid = _mono.gameObject.AddComponent <GridHelper>();
                _autocraftItemTechTypeGrid.OnLoadDisplay += OnLoadAutoCraftItemsGrid;
                _autocraftItemTechTypeGrid.Setup(18, DSSModelPrefab.AutoCraftItemPrefab, autocraftingitemPage, _startColor, _hoverColor, OnButtonClick);
                _autocraftItemTechTypeGrid.DrawPage();

                var autoCraftItemInputField = InterfaceHelpers.FindGameObject(autocraftingitemPage, "InputField");
                var autocraftItemText       = InterfaceHelpers.FindGameObject(autoCraftItemInputField, "Placeholder")?.GetComponent <Text>();
                autocraftItemText.text = AuxPatchers.SearchForItemsMessage();

                var autoCraftItemSearchField = autoCraftItemInputField.AddComponent <SearchField>();
                autoCraftItemSearchField.OnSearchValueChanged += OnSearchAutocraftTechValueChanged;

                #endregion

                #endregion

                #region Current Operations Page

                var currentOperationsPage = GameObjectHelpers.FindGameObject(gameObject, "OperationsPage");

                var addOperationBtnObject = GameObjectHelpers.FindGameObject(currentOperationsPage, "AddBTN");
                InterfaceHelpers.CreateButton(addOperationBtnObject, "AddBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE);

                _operationsGrid = _mono.gameObject.AddComponent <GridHelper>();
                _operationsGrid.OnLoadDisplay += OnLoadOperationsGrid;
                _operationsGrid.Setup(5, DSSModelPrefab.ItemEntryPrefab, currentOperationsPage, _startColor, _hoverColor, OnButtonClick);


                #endregion

                #region From Page

                var fromPage = GameObjectHelpers.FindGameObject(gameObject, "FromPage");

                var fromNextBTNObject = GameObjectHelpers.FindGameObject(fromPage, "Button")?.GetComponent <Button>();
                fromNextBTNObject.onClick.AddListener(FromButtonClick);
                var fromCancelBTNObject = GameObjectHelpers.FindGameObject(fromPage, "CancelBTN")?.GetComponent <Button>();
                fromCancelBTNObject.onClick.AddListener(OnOperationCancelButtonClick);



                _fromGrid = _mono.gameObject.AddComponent <GridHelper>();
                _fromGrid.OnLoadDisplay += OnLoadFromGrid;
                _fromGrid.Setup(18, DSSModelPrefab.OperatorItemPrefab, fromPage, _startColor, _hoverColor, OnButtonClick);
                _fromGrid.DrawPage();

                var fromInputField = InterfaceHelpers.FindGameObject(fromPage, "InputField");
                var text           = InterfaceHelpers.FindGameObject(fromInputField, "Placeholder")?.GetComponent <Text>();
                text.text = AuxPatchers.SearchForItemsMessage();

                var searchField = fromInputField.AddComponent <SearchField>();
                searchField.OnSearchValueChanged += OnFromSearchValueChanged;

                #endregion

                #region To Page

                var toPage = GameObjectHelpers.FindGameObject(gameObject, "ToPage");

                var toNextBTNObject   = GameObjectHelpers.FindGameObject(toPage, "Button")?.GetComponent <Button>();
                var toCancelBTNObject = GameObjectHelpers.FindGameObject(toPage, "CancelBTN")?.GetComponent <Button>();
                toCancelBTNObject.onClick.AddListener(OnOperationCancelButtonClick);
                toNextBTNObject.onClick.AddListener(ToButtonClick);

                _toGrid = _mono.gameObject.AddComponent <GridHelper>();
                _toGrid.OnLoadDisplay += OnLoadToGrid;
                _toGrid.Setup(18, DSSModelPrefab.OperatorItemPrefab, toPage, _startColor, _hoverColor, OnButtonClick);
                _toGrid.DrawPage();

                var toInputField = InterfaceHelpers.FindGameObject(toPage, "InputField");
                var toText       = InterfaceHelpers.FindGameObject(toInputField, "Placeholder")?.GetComponent <Text>();
                toText.text = AuxPatchers.SearchForItemsMessage();

                var toSearchField = toInputField.AddComponent <SearchField>();
                toSearchField.OnSearchValueChanged += OnToSearchValueChanged;

                #endregion

                #region Items Page

                var itemPage = GameObjectHelpers.FindGameObject(gameObject, "ItemPage");

                var itemNextBTNObject = GameObjectHelpers.FindGameObject(itemPage, "Button")?.GetComponent <Button>();
                itemNextBTNObject.onClick.AddListener(ItemButtonClick);
                var itemsCancelBTNObject = GameObjectHelpers.FindGameObject(itemPage, "CancelBTN")?.GetComponent <Button>();
                itemsCancelBTNObject.onClick.AddListener(OnOperationCancelButtonClick);

                _itemTechTypeGrid = _mono.gameObject.AddComponent <GridHelper>();
                _itemTechTypeGrid.OnLoadDisplay += OnLoadItemsGrid;
                _itemTechTypeGrid.Setup(18, DSSModelPrefab.OperatorItemPrefab, itemPage, _startColor, _hoverColor, OnButtonClick);
                _itemTechTypeGrid.DrawPage();

                var itemInputField = InterfaceHelpers.FindGameObject(itemPage, "InputField");
                var itemText       = InterfaceHelpers.FindGameObject(itemInputField, "Placeholder")?.GetComponent <Text>();
                itemText.text = AuxPatchers.SearchForItemsMessage();

                var itemSearchField = itemInputField.AddComponent <SearchField>();
                itemSearchField.OnSearchValueChanged += OnSearchItemValueChanged;

                #endregion

                #region MessageBox

                var messageBox = GameObjectHelpers.FindGameObject(gameObject, "MessageBox");
                _messageBoxDialog = messageBox.AddComponent <FCSMessageBoxDialog>();
                _messageBoxDialog.OnConfirmButtonClick += id =>
                {
                    switch (id)
                    {
                    case "cancel":
                        GoToPage(OperatorPages.Operations);
                        ResetData();
                        break;

                    case "itemCancel":
                        GoToPage(OperatorPages.AutoCraft);
                        ResetData();
                        break;

                    case "craft":
                        GoToPage(OperatorPages.AutoCraft);
                        _craftTechType = TechType.None;
                        break;
                    }
                };

                #endregion
            }
            catch (Exception e)
            {
                QuickLogger.Error($"Error: {e.Message} | StackTrace: {e.StackTrace}");
                return(false);
            }

            return(true);
        }
Beispiel #23
0
        public override bool FindAllComponents()
        {
            try
            {
                #region Canvas
                var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

                if (canvasGameObject == null)
                {
                    QuickLogger.Error("Canvas cannot be found");
                    return(false);
                }
                #endregion

                #region Home
                var home = InterfaceHelpers.FindGameObject(canvasGameObject, "Home");
                #endregion

                #region VehiclesPage
                var vehiclesPage = InterfaceHelpers.FindGameObject(canvasGameObject, "VehiclesPage");
                #endregion

                #region VehicleDockingSettingsPage
                var vehiclesDockingSettingsPage = InterfaceHelpers.FindGameObject(canvasGameObject, "VehicleDockingSettingsPage");
                #endregion

                #region Item Page
                var itemPage = InterfaceHelpers.FindGameObject(vehiclesDockingSettingsPage, "ItemPage");
                #endregion

                #region Category Page
                var categoryPage = InterfaceHelpers.FindGameObject(vehiclesDockingSettingsPage, "CategoryPage");
                #endregion

                #region VehiclesContainersPage
                var vehiclesContainersPage = InterfaceHelpers.FindGameObject(canvasGameObject, "VehiclesContainersPage");
                #endregion

                #region BaseItemsPage
                var baseItemsPage = InterfaceHelpers.FindGameObject(canvasGameObject, "BaseItemsPage");
                #endregion

                #region GettingDataPage
                var gettingDataPage = InterfaceHelpers.FindGameObject(canvasGameObject, "GettingData");
                #endregion

                #region Settings
                var settings = InterfaceHelpers.FindGameObject(canvasGameObject, "SettingsPage");
                #endregion

                #region PoweredOff
                var poweredOff = InterfaceHelpers.FindGameObject(canvasGameObject, "PowerOffPage");
                #endregion

                #region ColorPageMain
                var colorMainPage = InterfaceHelpers.FindGameObject(canvasGameObject, "ColorPageMain");
                #endregion

                #region ScreenColorPicker

                var screenColorPicker = InterfaceHelpers.FindGameObject(canvasGameObject, "TerminalColorPage");

                #endregion

                #region AntennnaColorPicker

                _antennaColorPicker = InterfaceHelpers.FindGameObject(canvasGameObject, "AntennaColorPage");

                #endregion

                #region Base Grid

                _baseGrid = _mono.gameObject.AddComponent <GridHelper>();
                _baseGrid.OnLoadDisplay += OnLoadBaseGrid;
                _baseGrid.Setup(12, DSSModelPrefab.BaseItemPrefab, home, _startColor, _hoverColor, OnButtonClick); //Minus 2 ItemPerPage because of the added Home button

                #endregion

                #region Vehicle Grid

                _vehicleGrid = _mono.gameObject.AddComponent <GridHelper>();
                _vehicleGrid.OnLoadDisplay += OnLoadVehicleGrid;
                _vehicleGrid.Setup(12, DSSModelPrefab.VehicleItemPrefab, vehiclesPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Vehicle Containers Grid

                _vehicleContainersGrid = _mono.gameObject.AddComponent <GridHelper>();
                _vehicleContainersGrid.OnLoadDisplay += OnLoadVehicleContainersGrid;
                _vehicleContainersGrid.Setup(12, DSSModelPrefab.VehicleItemPrefab, vehiclesContainersPage, _startColor, _hoverColor, OnButtonClick, 5,
                                             "PrevBTN", "NextBTN", "Grid", "Paginator", "HomeBTN", "VehiclesPageBTN"); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Item Grid

                _itemGrid = _mono.gameObject.AddComponent <GridHelper>();
                _itemGrid.OnLoadDisplay += OnLoadItemsGrid;
                _itemGrid.Setup(4, DSSModelPrefab.FilterItemPrefab, itemPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Category Grid

                _categoryGrid = _mono.gameObject.AddComponent <GridHelper>();
                _categoryGrid.OnLoadDisplay += OnLoadCategoryGrid;
                _categoryGrid.Setup(4, DSSModelPrefab.FilterItemPrefab, categoryPage, _startColor, _hoverColor, OnButtonClick); //Minus 1 ItemPerPage because of the added Home button

                #endregion

                #region Base Items Page

                _baseItemsGrid = _mono.gameObject.AddComponent <GridHelper>();
                _baseItemsGrid.OnLoadDisplay += OnLoadBaseItemsGrid;
                _baseItemsGrid.Setup(44, DSSModelPrefab.ItemPrefab, baseItemsPage, _startColor, _hoverColor, OnButtonClick);

                _counter = GameObjectHelpers.FindGameObject(baseItemsPage, "Counter").GetComponent <Text>();
                #endregion

                #region DumpBTNButton
                var closeBTN = InterfaceHelpers.FindGameObject(baseItemsPage, "DumpButton");

                InterfaceHelpers.CreateButton(closeBTN, "DumpBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.DumpToBase());
                #endregion

                #region ColorPickerBTN
                var colorPickerBTN = InterfaceHelpers.FindGameObject(settings, "ColorPickerBTN");

                InterfaceHelpers.CreateButton(colorPickerBTN, "ColorPickerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.ColorPage());
                #endregion

                #region RenameBTN
                var renameBTN = InterfaceHelpers.FindGameObject(settings, "RenameBaseBTN");

                InterfaceHelpers.CreateButton(renameBTN, "RenameBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.Rename());
                #endregion

                #region SettingsBTN
                var settingsBTN = InterfaceHelpers.FindGameObject(home, "SettingsBTN");

                InterfaceHelpers.CreateButton(settingsBTN, "SettingsBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.SettingPage());
                #endregion

                #region HomePowerBTN
                var homePowerBTN = InterfaceHelpers.FindGameObject(home, "PowerBTN");

                InterfaceHelpers.CreateButton(homePowerBTN, "PowerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.PowerButton());
                #endregion

                #region PoweredOffPowerBTN
                var poweredOffPowerBTN = InterfaceHelpers.FindGameObject(poweredOff, "PowerBTN");

                InterfaceHelpers.CreateButton(poweredOffPowerBTN, "PowerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.PowerButton());
                #endregion

                #region ColorPickerMainHomeBTN
                var colorPickerMainHomeBTN = InterfaceHelpers.FindGameObject(colorMainPage, "HomeBTN");

                InterfaceHelpers.CreateButton(colorPickerMainHomeBTN, "SettingsBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.SettingPage());
                #endregion

                #region SettingHomeBTN
                var settingsHomeBTN = InterfaceHelpers.FindGameObject(settings, "HomeBTN");

                InterfaceHelpers.CreateButton(settingsHomeBTN, "HomeBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.GoToHome());
                #endregion

                #region Terminal Color BTN
                var terminalColorBTN = InterfaceHelpers.FindGameObject(colorMainPage, "TerminalColorBTN");

                InterfaceHelpers.CreateButton(terminalColorBTN, "TerminalColorBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, string.Format(AuxPatchers.ColorPageFormat(), AuxPatchers.Terminal()));
                #endregion

                #region VehicleSettingsBTN
                var vehicleSettingBTN = InterfaceHelpers.FindGameObject(settings, "AutoDockBTN");

                InterfaceHelpers.CreateButton(vehicleSettingBTN, "AutoDockBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.GoToDockedVehiclesSettings());
                #endregion

                #region Toggle

                _toggle = InterfaceHelpers.FindGameObject(vehiclesDockingSettingsPage, "Toggle").GetComponent <Toggle>();
                _toggle.onValueChanged.AddListener(OnAutoPullToggled);

                #endregion

                #region Search
                var inputField = InterfaceHelpers.FindGameObject(baseItemsPage, "InputField");

                if (inputField != null)
                {
                    var text = InterfaceHelpers.FindGameObject(inputField, "Placeholder")?.GetComponent <Text>();
                    if (text != null)
                    {
                        text.text = AuxPatchers.SearchForItemsMessage();
                    }
                    else
                    {
                        return(false);
                    }

                    var searchField = inputField.AddComponent <SearchField>();
                    searchField.OnSearchValueChanged += UpdateSearch;
                }
                else
                {
                    //throw new MissingComponentException("Cannot find Input Field");
                    return(false);
                }

                #endregion

                #region Antenna Color BTN
                var antennaColorBTN = InterfaceHelpers.FindGameObject(colorMainPage, "AntennaColorBTN");

                InterfaceHelpers.CreateButton(antennaColorBTN, "AntennaColorBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, string.Format(AuxPatchers.ColorPageFormat(), AuxPatchers.Antenna()));
                #endregion

                #region ColorPage
                _terminalColorPage.SetupGrid(90, DSSModelPrefab.ColorItemPrefab, screenColorPicker, OnButtonClick, _startColor, _hoverColor, 5,
                                             "PrevBTN", "NextBTN", "Grid", "Paginator", "HomeBTN", "ColorPickerBTN");
                #endregion

                #region BaseItemDecription

                var baseItemPageDesc = InterfaceHelpers.FindGameObject(colorMainPage, "Title")?.GetComponent <Text>();
                baseItemPageDesc.text = AuxPatchers.ColorMainPageDesc();

                #endregion

                #region BaseName

                _baseNameLabel = InterfaceHelpers.FindGameObject(baseItemsPage, "BaseLabel")?.GetComponent <Text>();

                #endregion

                #region BaseItemsLoading

                _gettingData = InterfaceHelpers.FindGameObject(gettingDataPage, "Title")?.GetComponent <Text>();

                #endregion

                #region DockSettingsHomeBTN
                var dockSettingsHomeBTN = InterfaceHelpers.FindGameObject(vehiclesDockingSettingsPage, "HomeBTN");

                InterfaceHelpers.CreateButton(dockSettingsHomeBTN, "SettingsBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, AuxPatchers.SettingPage());
                #endregion



                return(true);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                QuickLogger.Error(e.StackTrace);
                return(false);
            }
        }
Beispiel #24
0
        private void OnLoadAutoCraftGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed || _mono == null || _mono?.Manager == null)
                {
                    return;
                }

                _autoCraftingGrid.ClearPage();

                var grouped = BaseManager.Crafts;

                if (grouped == null)
                {
                    QuickLogger.Debug("Grouped returned null canceling operation");
                    return;
                }

                //if (!string.IsNullOrEmpty(_toCurrentSearchString?.Trim()))
                //{
                //    grouped = grouped.Where(p => p.Value.UnitID.StartsWith(_toCurrentSearchString.Trim(), StringComparison.OrdinalIgnoreCase)).ToDictionary(p => p.Key, p => p.Value);
                //}

                if (data.EndPosition > grouped.Count)
                {
                    data.EndPosition = grouped.Count;
                }

                if (data.ItemsGrid?.transform == null)
                {
                    QuickLogger.Debug("Grid returned null canceling operation");
                    return;
                }

                for (int i = data.StartPosition; i < data.EndPosition; i++)
                {
                    var craft = grouped.ElementAt(i);

                    GameObject buttonPrefab = Instantiate(data.ItemsPrefab);

                    if (buttonPrefab == null || data.ItemsGrid == null)
                    {
                        if (buttonPrefab != null)
                        {
                            QuickLogger.Debug("Destroying Tab", true);
                            Destroy(buttonPrefab);
                        }
                        return;
                    }

                    buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);

                    uGUI_Icon icon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                    icon.sprite = SpriteManager.Get(craft.TechType);

                    var deleteBTN = InterfaceHelpers.FindGameObject(buttonPrefab, "Delete")?.AddComponent <InterfaceButton>();
                    if (deleteBTN != null)
                    {
                        deleteBTN.BtnName        = "AutoCraftItemDeleteBTN";
                        deleteBTN.TextLineOne    = AuxPatchers.Delete();
                        deleteBTN.STARTING_COLOR = _startColor;
                        deleteBTN.HOVER_COLOR    = _hoverColor;
                        deleteBTN.OnButtonClick  = delegate
                        {
                            BaseManager.DeleteAutoCraft(craft);
                            Refresh();
                        };
                    }

                    var buttonText = buttonPrefab.GetComponentInChildren <Text>();
                    buttonText.text = Language.main.Get(craft.TechType);

                    var checkbox = buttonPrefab.GetComponentInChildren <Toggle>();
                    checkbox.isOn = craft.IsCraftable;
                    checkbox.onValueChanged.AddListener((value) =>
                    {
                        craft.IsCraftable = value;
                    });

                    var craftBTN = InterfaceHelpers.FindGameObject(buttonPrefab, "AutocraftBTN")?.AddComponent <InterfaceButton>();

                    if (craftBTN != null)
                    {
                        craftBTN.BtnName        = "AutoCraftItemDeleteBTN";
                        craftBTN.TextLineOne    = AuxPatchers.Craft();
                        craftBTN.STARTING_COLOR = _startColor;
                        craftBTN.HOVER_COLOR    = _hoverColor;
                        craftBTN.OnButtonClick  = delegate { BaseManager.PerformCraft(craft); };
                    }
                }

                _autoCraftingGrid.UpdaterPaginator(grouped.Count);
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }