Beispiel #1
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 #2
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}");
            }
        }