private void OnLoadDisplay(DisplayData data)
        {
            List <FCSController> items = null;

            if (SelectedTab == QTTabs.Global)
            {
                items = BaseManager.GlobalUnits.Where(x => x != _mono).ToList();
            }
            else if (SelectedTab == QTTabs.Intra)
            {
                items = _mono.Manager.BaseUnits.Where(x => x != _mono).ToList();
            }

            if (items == null)
            {
                QuickLogger.Error <QTDisplayManager>("Items list returned null");
                return;
            }

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

            _teleportGrid.ClearPage();

            for (int i = data.StartPosition; i < data.EndPosition; i++)
            {
                var unit     = items[i];
                var unitName = unit.GetName();

                if (unit == _mono)
                {
                    continue;
                }

                GameObject itemDisplay = Instantiate(data.ItemsPrefab);
                var        statusLBL   = InterfaceHelpers.FindGameObject(itemDisplay, "Status_LBL");

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

                itemDisplay.transform.SetParent(data.ItemsGrid.transform, false);
                var textField = itemDisplay.transform.Find("Location_LBL").gameObject;
                var text      = textField.GetComponent <Text>();
                text.text = unitName;

                var statusUpdater = itemDisplay.AddComponent <ItemDisplayStatusHandler>();
                statusUpdater.Initialize((QuantumTeleporterController)unit, textField, statusLBL, this, MaxInteractionRange);

                var itemButton = itemDisplay.AddComponent <InterfaceButton>();
                itemButton.ButtonMode          = InterfaceButtonMode.TextColor;
                itemButton.Tag                 = unit;
                itemButton.TextComponent       = text;
                itemButton.OnButtonClick      += OnButtonClick;
                itemButton.BtnName             = "Unit";
                itemButton.MaxInteractionRange = MaxInteractionRange;

                QuickLogger.Debug($"Added Unit {unitName}");
            }

            _teleportGrid.UpdaterPaginator(items.Count);
        }
Exemple #2
0
        public override bool FindAllComponents()
        {
            try
            {
                #region Canvas

                var canvas = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

                if (canvas == null)
                {
                    QuickLogger.Error("Canvas could not be found!");
                    return(false);
                }

                #endregion

                #region Home Screen

                var home = InterfaceHelpers.FindGameObject(canvas, "Home");

                #endregion

                #region Multiplier

                var multiplier = InterfaceHelpers.FindGameObject(home, "Multiplier");

                #endregion

                #region Item Count

                _itemCount = InterfaceHelpers.FindGameObject(home, "StorageAmount")?.GetComponent <Text>();

                #endregion

                #region Plier

                _plier = InterfaceHelpers.FindGameObject(multiplier, "plier")?.GetComponent <Text>();

                #endregion

                #region Storage Labels

                _storageLabels = InterfaceHelpers.FindGameObject(home, "Storage_Labels");

                #endregion

                #region Grid

                var grid = InterfaceHelpers.FindGameObject(home, "Grid");
                _grid = _mono.gameObject.AddComponent <GridHelper>();
                _grid.OnLoadDisplay += OnLoadDisplay;
                _grid.Setup(16, ExStorageDepotBuildable.ItemPrefab, home, _startColor, _hoverColor, OnButtonClick);

                #endregion

                #region Dump Button

                var dumpBTN = InterfaceHelpers.FindGameObject(home, "Dump_Button");
                InterfaceHelpers.CreateButton(dumpBTN, "DumpBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ExStorageDepotBuildable.AddToExStorage());

                #endregion

                #region Rename Button

                var renameBTN = InterfaceHelpers.FindGameObject(home, "Rename_Button");
                InterfaceHelpers.CreateButton(renameBTN, "RenameBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ExStorageDepotBuildable.RenameStorage());

                #endregion

                #region Multiplier Previous Button

                var multiplierPrevBtn = InterfaceHelpers.FindGameObject(multiplier, "Prev_BTN");
                InterfaceHelpers.CreateButton(multiplierPrevBtn, "LButton", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, "");

                #endregion

                #region Multiplier Next Button

                var multiplierNextBtn = InterfaceHelpers.FindGameObject(multiplier, "Next_BTN");
                InterfaceHelpers.CreateButton(multiplierNextBtn, "RButton", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, "");

                #endregion

                _unitID = GameObjectHelpers.FindGameObject(home, "UnitID")?.GetComponent <Text>();
            }
            catch (Exception e)
            {
                QuickLogger.Error($"{e.Message}:\n{e.StackTrace}");
                return(false);
            }
            return(true);
        }
        public override bool FindAllComponents()
        {
            #region Canvas
            var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

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

            #region L_Panel

            var lPanel = canvasGameObject.FindChild("Left_Panel")?.gameObject;

            if (lPanel == null)
            {
                QuickLogger.Error("Unable to find L_Panel GameObject");
                return(false);
            }
            #endregion

            #region R_Panel

            var rPanel = canvasGameObject.FindChild("Right_Panel")?.gameObject;

            if (rPanel == null)
            {
                QuickLogger.Error("Unable to find R_Panel GameObject");
                return(false);
            }
            #endregion

            #region Home

            var home = canvasGameObject.FindChild("Home")?.gameObject;

            if (home == null)
            {
                QuickLogger.Error("Unable to find Home GameObject");
                return(false);
            }
            #endregion

            #region confirmation

            var confirmation = canvasGameObject.FindChild("Confirmation")?.gameObject;

            if (confirmation == null)
            {
                QuickLogger.Error("Unable to find Home GameObject");
                return(false);
            }
            #endregion

            #region ColorPicker

            var colorPicker = canvasGameObject.FindChild("ColorPicker")?.gameObject;

            if (colorPicker == null)
            {
                QuickLogger.Error("Unable to find colorPicker GameObject");
                return(false);
            }
            #endregion

            #region Color Picker Button
            var colorPickerBtn = InterfaceHelpers.FindGameObject(rPanel, "ColorPickerBTN");

            if (colorPickerBtn == null)
            {
                return(false);
            }

            InterfaceHelpers.CreateButton(colorPickerBtn, "ColorPageBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, _startColor, _hoverColor, MaxInteractionRange);
            #endregion

            #region Color Picker Button
            var renameBtn = InterfaceHelpers.FindGameObject(rPanel, "RenameBTN");

            if (renameBtn == null)
            {
                return(false);
            }

            InterfaceHelpers.CreateButton(renameBtn, "RenameBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, _startColor, _hoverColor, MaxInteractionRange);
            #endregion

            #region Text Field

            _textField = InterfaceHelpers.FindGameObject(lPanel, "UnitName")?.GetComponent <Text>();

            #endregion

            #region Grid
            _teleportGrid.Setup(7, QuantumTeleporterBuildable.ItemPrefab, home, _startColor, _hoverColor, OnButtonClick,
                                5, "PrevBTN", "NextBTN", "Grid", "Paginator", string.Empty);
            _teleportGrid.OnLoadDisplay += OnLoadDisplay;
            #endregion

            #region Color Grid
            var _colorGrid = InterfaceHelpers.FindGameObject(colorPicker, "Grid");

            if (_colorGrid == null)
            {
                QuickLogger.Error <QTDisplayManager>("Cant find color page on home page");
                return(false);
            }
            #endregion

            #region Color Paginator
            var _colorPaginator = InterfaceHelpers.FindGameObject(colorPicker, "Paginator");

            if (_colorPaginator == null)
            {
                QuickLogger.Error <QTDisplayManager>("Cant find paginator on color picker page");
                return(false);
            }
            #endregion

            #region ColorPage
            _colorPage.SetupGrid(30, QuantumTeleporterBuildable.ColorItemPrefab, _colorGrid, _colorPaginator.GetComponent <Text>(), OnButtonClick);
            #endregion

            #region Home Button
            var homeBtn = InterfaceHelpers.FindGameObject(colorPicker, "HomeBTN");

            if (homeBtn == null)
            {
                return(false);
            }

            InterfaceHelpers.CreateButton(homeBtn, "HomeBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, _startColor, _hoverColor, MaxInteractionRange);
            #endregion

            #region Prev Color Button
            var prevColorBtn = InterfaceHelpers.FindGameObject(colorPicker, "PrevBTN");

            if (prevColorBtn == null)
            {
                return(false);
            }

            InterfaceHelpers.CreatePaginator(prevColorBtn, -1, _colorPage.ChangeColorPageBy, _startColor, _hoverColor);
            #endregion

            #region Next Color Button
            var nextColorBtn = InterfaceHelpers.FindGameObject(colorPicker, "NextBTN");

            if (nextColorBtn == null)
            {
                return(false);
            }

            InterfaceHelpers.CreatePaginator(nextColorBtn, 1, _colorPage.ChangeColorPageBy, _startColor, _hoverColor);
            #endregion

            #region Global Toggle
            var isGlobalToggle = InterfaceHelpers.FindGameObject(lPanel, "Toggle");

            if (isGlobalToggle == null)
            {
                return(false);
            }

            var globalToggleLabel = InterfaceHelpers.FindGameObject(isGlobalToggle, "Label");
            if (globalToggleLabel == null)
            {
                return(false);
            }
            globalToggleLabel.GetComponent <Text>().text = QuantumTeleporterBuildable.MakeGlobalUnit();

            _isGlobalToggle = isGlobalToggle.GetComponent <Toggle>();
            _isGlobalToggle.onValueChanged.AddListener(delegate
            {
                ToggleValueChanged(_isGlobalToggle);
            });
            #endregion

            #region Intra Tele Button
            var intraTele = InterfaceHelpers.FindGameObject(home, "Intra_TeleBtn");

            if (intraTele == null)
            {
                return(false);
            }

            _intraTeleBtn = InterfaceHelpers.CreateButton(intraTele, "IntraTeleBtn", InterfaceButtonMode.Background,
                                                          OnButtonClick, Color.black, Color.white, MaxInteractionRange);
            _intraTeleBtn.ChangeText(QuantumTeleporterBuildable.LocalNetwork());
            #endregion

            #region GLobal Tele Button
            var globalTele = InterfaceHelpers.FindGameObject(home, "Global_TeleBtn");

            if (globalTele == null)
            {
                return(false);
            }

            _globalTeleBtn = InterfaceHelpers.CreateButton(globalTele, "GlobalTeleBtn", InterfaceButtonMode.Background,
                                                           OnButtonClick, Color.black, Color.white, MaxInteractionRange);
            _globalTeleBtn.ChangeText(QuantumTeleporterBuildable.GlobalNetwork());
            #endregion

            #region Information Label
            var unitInfo = InterfaceHelpers.FindGameObject(lPanel, "UnitNameInfo");

            if (unitInfo == null)
            {
                return(false);
            }

            var infoText = unitInfo.GetComponent <Text>();

            infoText.text = LeftPanelText();
            #endregion

            #region Yes Button
            var yesBTNGO = InterfaceHelpers.FindGameObject(confirmation, "YesBTN");

            if (yesBTNGO == null)
            {
                return(false);
            }

            var yesBTN = InterfaceHelpers.CreateButton(yesBTNGO, "ConfirmYesBtn", InterfaceButtonMode.Background,
                                                       OnButtonClick, Color.black, Color.white, MaxInteractionRange);
            yesBTN.ChangeText(QuantumTeleporterBuildable.Confirm());
            #endregion

            #region No Button
            var noBTNGO = InterfaceHelpers.FindGameObject(confirmation, "NoBTN");

            if (noBTNGO == null)
            {
                return(false);
            }

            var noBTN = InterfaceHelpers.CreateButton(noBTNGO, "ConfirmNoBtn", InterfaceButtonMode.Background,
                                                      OnButtonClick, Color.black, Color.white, MaxInteractionRange);
            noBTN.ChangeText(QuantumTeleporterBuildable.Cancel());
            #endregion

            #region Confirmation
            var confirmMessage = InterfaceHelpers.FindGameObject(confirmation, "Message");

            if (confirmMessage == null)
            {
                return(false);
            }

            confirmMessage.GetComponent <Text>().text = QuantumTeleporterBuildable.ConfirmMessage();
            #endregion

            #region Destination
            var destination = InterfaceHelpers.FindGameObject(confirmation, "Destination");

            if (destination == null)
            {
                return(false);
            }

            _destination = destination.GetComponent <Text>();
            #endregion

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

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

            #region Home

            var home = canvasGameObject.FindChild("Home")?.gameObject;

            if (home == null)
            {
                QuickLogger.Error("Unable to find Home GameObject");
                return(false);
            }
            #endregion

            #region Settings

            var settings = canvasGameObject.FindChild("Settings")?.gameObject;

            if (settings == null)
            {
                QuickLogger.Error("Unable to find Settings GameObject");
                return(false);
            }
            #endregion

            #region ColorPicker

            var colorPicker = canvasGameObject.FindChild("ColorPicker")?.gameObject;

            if (colorPicker == null)
            {
                QuickLogger.Error("Unable to find colorPicker GameObject");
                return(false);
            }
            #endregion

            #region Doors
            var doorsResult = InterfaceHelpers.FindGameObject(canvasGameObject, "Doors", out var doorsOutput);

            if (!doorsResult)
            {
                return(false);
            }

            var doors = doorsOutput;
            #endregion

            #region Start Button
            var startButtonResult = InterfaceHelpers.CreateButton(home, "Button", "startBTN", InterfaceButtonMode.Background,
                                                                  _startColor, _hoverColor, OnButtonClick, out var startButton);
            startButton.TextLineOne = "Start Cooking";

            if (!startButtonResult)
            {
                return(false);
            }
            _startButton = startButton;
            #endregion

            #region Color Picker
            var colorPickerResult = InterfaceHelpers.CreateButton(settings, "Paint_BTN", "colorPickerBTN", InterfaceButtonMode.Background,
                                                                  OnButtonClick, out var colorPickerButton);
            colorPickerButton.TextLineOne = "Color Picker Page";

            if (!colorPickerResult)
            {
                return(false);
            }
            #endregion

            #region Settings BTN
            var settingsResult = InterfaceHelpers.CreateButton(home, "Settings", "settingsBTN", InterfaceButtonMode.Background,
                                                               OnButtonClick, out var settingsButton);
            settingsButton.TextLineOne = SeaCookerBuildable.GoToSettingsPage();

            if (!settingsResult)
            {
                return(false);
            }
            #endregion

            #region Settings Color BTN
            var settingsCResult = InterfaceHelpers.CreateButton(colorPicker, "Home_BTN", "settingsBTN", InterfaceButtonMode.TextColor,
                                                                OnButtonClick, out var settings_C_BTN);
            settings_C_BTN.ChangeText($"< {SeaCookerBuildable.SettingsPage()}");
            settings_C_BTN.TextLineOne = $"{SeaCookerBuildable.GoToSettingsPage()}";

            if (!settingsCResult)
            {
                QuickLogger.Error($"Can't find settingsBTN");
                return(false);
            }
            #endregion

            #region Open Input BTN
            var openInputBTN = InterfaceHelpers.CreateButton(doors, "Open_Input", "openInputBTN", InterfaceButtonMode.TextColor,
                                                             OnButtonClick, out var openInputButton);
            openInputButton.TextLineOne = "Open Input Container";

            if (!openInputBTN)
            {
                return(false);
            }
            #endregion

            #region Open Export BTN
            var openExportBTN = InterfaceHelpers.CreateButton(doors, "Open_Export", "openExportBTN", InterfaceButtonMode.TextColor,
                                                              OnButtonClick, out var openExportButton);
            openExportButton.TextLineOne = "Open Export Container";

            if (!openExportBTN)
            {
                return(false);
            }
            #endregion

            #region Next BTN
            var nextBTN = InterfaceHelpers.CreatePaginator(colorPicker, "NextPage", 1, _colorPage.ChangeColorPageBy, out var nextButton);
            nextButton.TextLineOne = "Next Page";

            if (!nextBTN)
            {
                return(false);
            }
            #endregion

            #region Prev BTN
            var prevBTN = InterfaceHelpers.CreatePaginator(colorPicker, "PrevPage", -1, _colorPage.ChangeColorPageBy, out var prevButton);
            prevButton.TextLineOne = "Previous Page";

            if (!prevBTN)
            {
                return(false);
            }
            #endregion

            #region Color Grid
            var colorGridResult = InterfaceHelpers.FindGameObject(colorPicker, "Grid", out var colorGrid);

            if (!colorGridResult)
            {
                return(false);
            }
            _colorGrid = colorGrid;
            #endregion

            #region SeaBreeze Grid
            var seaBreezeGridResult = InterfaceHelpers.FindGameObject(settings, "Grid", out var seaBreezeGrid);

            if (!seaBreezeGridResult)
            {
                return(false);
            }

            _seaBreezeGrid.Setup(4, SeaCookerBuildable.SeaBreezeItemPrefab, settings, Color.white, new Color(0.07f, 0.38f, 0.7f, 1f), OnButtonClick);
            _seaBreezeGrid.OnLoadDisplay += OnLoadDisplay;
            #endregion

            #region From Image OMIT
            //var fromImage = InterfaceHelpers.FindGameObject(home, "from_Image", out var from_Image);

            //if (!fromImage)
            //{
            //    return false;
            //}
            //_fromImage = from_Image;
            //uGUI_Icon fromIcon = _fromImage.gameObject.AddComponent<uGUI_Icon>();
            #endregion

            #region To Image OMIT
            var toImage = InterfaceHelpers.FindGameObject(home, "to_Image", out var to_Image);

            if (!toImage)
            {
                return(false);
            }
            _toImage = to_Image;
            uGUI_Icon toIcon = _toImage.gameObject.AddComponent <uGUI_Icon>();
            #endregion

            #region Percentage Bar
            var percentageResult = InterfaceHelpers.FindGameObject(home, "Preloader_Bar", out var percentage);

            if (!percentageResult)
            {
                return(false);
            }
            _percentage = percentage.GetComponent <Image>();
            #endregion

            #region Version
            var versionResult = InterfaceHelpers.FindGameObject(canvasGameObject, "Version", out var version);

            if (!versionResult)
            {
                return(false);
            }
            var versionLbl = version.GetComponent <Text>();
            versionLbl.text = $"{SeaCookerBuildable.Version()}: {QPatch.Version}";
            #endregion

            #region Paginator
            var paginatorResult = InterfaceHelpers.FindGameObject(colorPicker, "Paginator", out var paginator);

            if (!paginatorResult)
            {
                return(false);
            }
            _paginator = paginator.GetComponent <Text>();
            #endregion

            #region Seabreeze Toggle
            var toggleResult = InterfaceHelpers.FindGameObject(settings, "Toggle_SB_Export", out var toggle);

            if (!toggleResult)
            {
                QuickLogger.Error($"Cannot find Toggle_SB_Export on GameObject");
                return(false);
            }

            _cusToggle               = toggle.AddComponent <CustomToggle>();
            _cusToggle.BtnName       = "seaBreezeToggle";
            _cusToggle.ButtonMode    = InterfaceButtonMode.Background;
            _cusToggle.OnButtonClick = OnButtonClick;
            _cusToggle.Tag           = _cusToggle;
            #endregion

            #region Auto Toggle
            var autoResult = InterfaceHelpers.FindGameObject(settings, "Auto_Toggle", out var autoToggle);

            if (!autoResult)
            {
                QuickLogger.Error($"Cannot find Auto_Toggle on GameObject");
                return(false);
            }

            _autoToggle               = autoToggle.AddComponent <CustomToggle>();
            _autoToggle.BtnName       = "autoToggle";
            _autoToggle.ButtonMode    = InterfaceButtonMode.Background;
            _autoToggle.OnButtonClick = OnButtonClick;
            _autoToggle.Tag           = _autoToggle;
            #endregion

            return(true);
        }
        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 homePage = InterfaceHelpers.FindGameObject(canvasGameObject, "HomePage");
                #endregion

                #region Color Picker
                var colorPicker = InterfaceHelpers.FindGameObject(canvasGameObject, "ColorPickerPage");
                #endregion

                #region Items Page
                var itemsPage = InterfaceHelpers.FindGameObject(canvasGameObject, "ItemsPage");
                #endregion

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

                #region Maintenance Page
                var maintenancePage = InterfaceHelpers.FindGameObject(canvasGameObject, "MaintenancePage");
                #endregion

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

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


                //================= Home Page ================//


                #region Items Button

                var itemsBTN = GameObjectHelpers.FindGameObject(homePage, "ItemsBTN");
                InterfaceHelpers.CreateButton(itemsBTN, "ItemsBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.ItemsButton());

                #endregion

                #region Maintenance Button

                var maintenanceBTN = GameObjectHelpers.FindGameObject(homePage, "MaintenanceBTN");
                InterfaceHelpers.CreateButton(maintenanceBTN, "MaintenanceBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.MaintenanceButton());

                #endregion

                #region Programming Button

                var programmingBTN = GameObjectHelpers.FindGameObject(homePage, "ProgrammingBTN");
                InterfaceHelpers.CreateButton(programmingBTN, "ProgrammingBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.ProgrammingButton());

                #endregion

                #region Programming Button

                var settingsBTN = GameObjectHelpers.FindGameObject(homePage, "SettingsBTN");
                InterfaceHelpers.CreateButton(settingsBTN, "SettingsBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.SettingsButton());

                #endregion

                #region Power Button

                var hPowerBtn = GameObjectHelpers.FindGameObject(homePage, "PowerBTN");
                InterfaceHelpers.CreateButton(hPowerBtn, "PowerBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.PowerButton());

                #endregion

                #region Battery Meter

                var batteryMeter = GameObjectHelpers.FindGameObject(homePage, "battery");
                _batteryFill = batteryMeter?.FindChild("Fill")?.GetComponent <Image>();

                if (_batteryFill != null)
                {
                    _batteryFill.color      = _colorEmpty;
                    _batteryFill.fillAmount = 0f;
                }

                _batteryPercentage = batteryMeter?.FindChild("Percentage")?.GetComponent <Text>();


                #endregion

                #region Oil Meter

                var oilMeter = GameObjectHelpers.FindGameObject(homePage, "Oil");
                _oilFill = oilMeter?.FindChild("Fill")?.GetComponent <Image>();

                if (_oilFill != null)
                {
                    _oilFill.color      = _colorEmpty;
                    _oilFill.fillAmount = 0f;
                }

                #endregion

                #region Items Per Day
                _itemsPerDay = GameObjectHelpers.FindGameObject(homePage, "ItemsPerDayLBL")?.GetComponent <Text>();
                #endregion

                #region Power Usage

                _powerUsage = GameObjectHelpers.FindGameObject(homePage, "PowerUsageLBL")?.GetComponent <Text>();
                #endregion


                //================= Power Off Page ================//

                #region Power Button

                var pPowerBtn = GameObjectHelpers.FindGameObject(poweredOffPage, "PowerBTN");
                InterfaceHelpers.CreateButton(pPowerBtn, "PowerBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.PowerButton());

                #endregion

                //================= Items Page ================//

                #region Items Grid

                _itemsGrid = _mono.gameObject.AddComponent <GridHelper>();
                _itemsGrid.OnLoadDisplay += OnLoadItemsGrid;
                _itemsGrid.Setup(9, FCSDeepDrillerBuildable.ItemPrefab, itemsPage, _startColor, _hoverColor, OnButtonClick);

                #endregion

                _itemCounter = GameObjectHelpers.FindGameObject(itemsPage, "ItemsCounter")?.GetComponent <Text>();

                //================= Settings Page ================//

                #region Filter Grid

                _filterGrid = _mono.gameObject.AddComponent <GridHelper>();
                _filterGrid.OnLoadDisplay += OnLoadFilterGrid;
                _filterGrid.Setup(4, FCSDeepDrillerBuildable.ListItemPrefab, settingsPage, _startColor, _hoverColor, OnButtonClick);

                #endregion

                #region Solar Panel Button

                var solarPanelBTN = GameObjectHelpers.FindGameObject(settingsPage, "SolarPanelBTN");
                _solarPanelBtnIcon = GameObjectHelpers.FindGameObject(solarPanelBTN, "Icon")?.GetComponent <Image>();
                InterfaceHelpers.CreateButton(solarPanelBTN, "SolarPanelBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.SolarButton());

                #endregion

                #region Filter Toggle Button

                var filterToggleBTN = GameObjectHelpers.FindGameObject(settingsPage, "FilterBTN");

                _filterBTNText = filterToggleBTN.GetComponentInChildren <Text>();


                InterfaceHelpers.CreateButton(filterToggleBTN, "FilterBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.FilterButton());

                #endregion


                #region Export Toggle Button

                var exportToggleBTN = GameObjectHelpers.FindGameObject(settingsPage, "ExportToggleBTN");

                _exportToggleBTNText = exportToggleBTN.GetComponentInChildren <Text>();

                InterfaceHelpers.CreateButton(exportToggleBTN, "ExportToggleBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.ExportToggleButton());

                #endregion

                #region Blacklist Toggle

                _blackListToggle = GameObjectHelpers.FindGameObject(settingsPage, "Toggle").GetComponent <Toggle>();
                _blackListToggle.onValueChanged.AddListener((toggleState) =>
                {
                    _mono.OreGenerator.SetBlackListMode(toggleState);
                });
                #endregion

                #region Color Picker Button

                var colorPickerBTN = GameObjectHelpers.FindGameObject(settingsPage, "ColorPickerBTN");

                InterfaceHelpers.CreateButton(colorPickerBTN, "ColorPickerBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.ColorButton());

                #endregion

                #region ColorPage
                _colorPage.SetupGrid(36, FCSDeepDrillerBuildable.ColorItemPrefab, colorPicker, OnButtonClick, _startColor, _hoverColor);
                #endregion

                #region Solar Panel Button

                var rangeToggleBTN = GameObjectHelpers.FindGameObject(settingsPage, "RangeToggleBTN");
                _rangeToggleBTNIcon = GameObjectHelpers.FindGameObject(rangeToggleBTN, "Icon")?.GetComponent <Image>();
                InterfaceHelpers.CreateButton(rangeToggleBTN, "RangeToggleBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.ToggleRangeButton());

                #endregion

                //================= Maintenance Page ================//

                #region Maintenance Home Button


                var maintenanceHomeBTN = GameObjectHelpers.FindGameObject(maintenancePage, "HomeBTN");
                InterfaceHelpers.CreateButton(maintenanceHomeBTN, "HomeBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.MaintenanceButton());

                #endregion

                #region Oil Dump Button

                var oilDumpBTN = GameObjectHelpers.FindGameObject(maintenancePage, "OilBTN");
                InterfaceHelpers.CreateButton(oilDumpBTN, "OilDumpBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.AddOil());

                #endregion

                #region Powercell Dump Button

                var powercellDumpBTN = GameObjectHelpers.FindGameObject(maintenancePage, "PowerBTN");
                InterfaceHelpers.CreateButton(powercellDumpBTN, "PowercellDumpBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.AddPower());

                #endregion

                //================= Programming Page ================//

                #region Programming Grid

                _programmingGrid = _mono.gameObject.AddComponent <GridHelper>();
                _programmingGrid.OnLoadDisplay += OnLoadProgrammingGrid;
                _programmingGrid.Setup(6, FCSDeepDrillerBuildable.ProgrammingItemPrefab, programmingPage, _startColor, _hoverColor, OnButtonClick);

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

                InterfaceHelpers.CreateButton(addBTN, "AddProgramBTN", InterfaceButtonMode.Background, OnButtonClick,
                                              _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, FCSDeepDrillerBuildable.AddProgramButton());


                #endregion

                #region Find Unit

                _unitID = GameObjectHelpers.FindGameObject(homePage, "UnitID")?.GetComponent <Text>();

                #endregion
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Has been caught:");
                QuickLogger.Error($"Message:\n {e.Message}");
                QuickLogger.Error($"StackTrace:\n {e.StackTrace}");
                return(false);
            }

            return(true);
        }
Exemple #6
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 NotOnBase
                var notOnbase = InterfaceHelpers.FindGameObject(canvasGameObject, "NotOnBase")?.GetComponentInChildren <Text>();
                if (notOnbase != null)
                {
                    notOnbase.text = HydroponicHarvestersBuildable.NotOnBaseMessage();
                }
                #endregion

                #region Controls
                var controls = InterfaceHelpers.FindGameObject(home, "Controls");
                #endregion

                #region LightButton
                var lightBTN = InterfaceHelpers.FindGameObject(controls, "LightBTN");

                InterfaceHelpers.CreateButton(lightBTN, "LightBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, HydroponicHarvestersBuildable.ToggleLightMessage());

                var ligtIcon = InterfaceHelpers.FindGameObject(lightBTN, "Icon").AddComponent <uGUI_Icon>();
                ligtIcon.sprite = SpriteManager.Get(TechType.Flashlight);
                #endregion

                #region DNA Counter
                _dnaCounter = InterfaceHelpers.FindGameObject(home, "Limit")?.GetComponent <Text>();
                #endregion

                #region Power Usage
                _powerUsage = InterfaceHelpers.FindGameObject(home, "PowerUsage")?.GetComponent <Text>();
                #endregion

                #region ItemsCount
                _itemsCount = InterfaceHelpers.FindGameObject(home, "ItemsCount")?.GetComponent <Text>();
                #endregion

                #region TimeLeft
                _timeLeft = InterfaceHelpers.FindGameObject(home, "TimeLeft")?.GetComponent <Text>();
                #endregion

                #region CleanerButton
                var cleanerButtonObj = InterfaceHelpers.FindGameObject(controls, "CleanerBTN");

                var cleanerIcon = InterfaceHelpers.FindGameObject(cleanerButtonObj, "Icon").AddComponent <uGUI_Icon>();
                cleanerIcon.sprite = ImageUtils.LoadSpriteFromFile(Path.Combine(Mod.GetAssetFolder(), "FloraKleen.png"));

                InterfaceHelpers.CreateButton(cleanerButtonObj, "CleanerBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, HydroponicHarvestersBuildable.CleanerBTNMessage());
                #endregion

                #region DumpBTNButton
                var dumpBTNButtonObj = InterfaceHelpers.FindGameObject(controls, "DumpBTN");

                InterfaceHelpers.CreateButton(dumpBTNButtonObj, "DumpBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, HydroponicHarvestersBuildable.DumpBTNMessage());
                #endregion

                #region ColorPicker Button

                var colorBTN = InterfaceHelpers.FindGameObject(controls, "ColorBTN");

                InterfaceHelpers.CreateButton(colorBTN, "ColorBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, HydroponicHarvestersBuildable.ColorPickerBTNMessage());

                #endregion

                #region ColorPicker

                var colorPicker = InterfaceHelpers.FindGameObject(canvasGameObject, "ColorPicker");
                #endregion

                #region ColorPage
                _colorPage.SetupGrid(50, HydroponicHarvestersModelPrefab.ColorItemPrefab, colorPicker, OnButtonClick, _startColor, _hoverColor);
                #endregion

                #region PowerLevelButton
                var powerLevelBTN = InterfaceHelpers.FindGameObject(controls, "PowerLevelBTN");
                _powerLevelText = InterfaceHelpers.FindGameObject(powerLevelBTN, "Text").GetComponent <Text>();

                InterfaceHelpers.CreateButton(powerLevelBTN, "PowerLevelBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, HydroponicHarvestersBuildable.PowerLevelBTNMessage());

                #endregion

                #region DNA

                _dnaGrid = _mono.gameObject.AddComponent <GridHelper>();
                _dnaGrid.OnLoadDisplay += OnLoadDnaGrid;
                _dnaGrid.Setup(4, HydroponicHarvestersModelPrefab.ItemPrefab, home, _startColor, _hoverColor, OnButtonClick, 5, string.Empty, string.Empty, "Slots", string.Empty, string.Empty);
                #endregion

                #region ModeButton
                var modeBTN = InterfaceHelpers.FindGameObject(controls, "ModeBTN");

                _modeIcon        = InterfaceHelpers.FindGameObject(modeBTN, "Icon").AddComponent <uGUI_Icon>();
                _modeIcon.sprite = MelonIconSprite;

                InterfaceHelpers.CreateButton(modeBTN, "ModeBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, HydroponicHarvestersBuildable.ModeBTNMessage());

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

            return(true);
        }
        public override bool FindAllComponents()
        {
            try
            {
                #region Canvas

                var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

                if (canvasGameObject == null)
                {
                    QuickLogger.Error("Canvas not found.");
                    return(false);
                }

                #endregion

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

                #region Battery

                var homeBattery = InterfaceHelpers.FindGameObject(home, "Battery");
                _batteryPercent = InterfaceHelpers.FindGameObject(homeBattery, "Text").GetComponent <Text>();
                _batteryFill    = InterfaceHelpers.FindGameObject(homeBattery, "Fill").GetComponent <Image>();

                #endregion

                #region Food
                var food = InterfaceHelpers.FindGameObject(canvasGameObject, "FoodScreen");
                #endregion

                #region Drinks
                var drinks = InterfaceHelpers.FindGameObject(canvasGameObject, "DrinksScreen");
                #endregion

                #region Trash
                var trash = InterfaceHelpers.FindGameObject(canvasGameObject, "TrashScreen");
                #endregion

                #region Color Picker
                var colorPicker = InterfaceHelpers.FindGameObject(canvasGameObject, "ColorPicker");
                #endregion

                #region PowerOff
                var powerOff = InterfaceHelpers.FindGameObject(canvasGameObject, "PoweredOffScreen");
                #endregion

                #region PowerButton
                var powerBtn = InterfaceHelpers.FindGameObject(home, "Power_BTN");

                InterfaceHelpers.CreateButton(powerBtn, "HPPBtn", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.PowerBTNMessage());
                #endregion

                #region PowerOFf PowerButton
                var ppowerBtn = InterfaceHelpers.FindGameObject(powerOff, "Power_BTN");

                InterfaceHelpers.CreateButton(ppowerBtn, "PPBtn", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.PowerBTNMessage());
                #endregion

                #region PowerOFf PowerButton
                var powerOffLbl = InterfaceHelpers.FindGameObject(powerOff, "Powered_Off_LBL");
                powerOffLbl.GetComponent <Text>().text = ARSSeaBreezeFCS32Buildable.NoPower();
                #endregion

                #region DumpBTNButton
                var dumpBtn = InterfaceHelpers.FindGameObject(home, "DumpBTN");

                InterfaceHelpers.CreateButton(dumpBtn, "DumpBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.DumpButton(), ARSSeaBreezeFCS32Buildable.DumpMessage());
                #endregion

                #region FoodCButton
                var foodContainterBtn = InterfaceHelpers.FindGameObject(home, "FoodCBTN");

                InterfaceHelpers.CreateButton(foodContainterBtn, "FoodCBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.FoodCButton());
                #endregion

                #region WaterCButton
                var WaterContainterBtn = InterfaceHelpers.FindGameObject(home, "WaterCBTN");

                InterfaceHelpers.CreateButton(WaterContainterBtn, "WaterCBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.WaterCButton());
                #endregion

                #region Rename Button
                var RenameBtn = InterfaceHelpers.FindGameObject(home, "RenameBTN");

                InterfaceHelpers.CreateButton(RenameBtn, "RenameBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.RenameButton());
                #endregion

                #region Trash Button
                var TrashBtn = InterfaceHelpers.FindGameObject(home, "TrashCBTN");

                InterfaceHelpers.CreateButton(TrashBtn, "TrashBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.TrashButton(), ARSSeaBreezeFCS32Buildable.TrashMessage());
                #endregion

                #region ColorBTN Button
                var colorBtn = InterfaceHelpers.FindGameObject(home, "ColorPickerBTN");

                InterfaceHelpers.CreateButton(colorBtn, "ColorBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.ColorPicker());
                #endregion

                #region ColorPage
                _colorPage.SetupGrid(48, ARSSeaBreezeFCS32Buildable.ColorItemPrefab, colorPicker, OnButtonClick, _startColor, _hoverColor);
                #endregion

                #region Food Page

                _foodPage = _mono.gameObject.AddComponent <GridHelper>();
                _foodPage.OnLoadDisplay += OnLoadFoodDisplay;
                _foodPage.Setup(17, ARSSeaBreezeFCS32Buildable.ItemPrefab, food, _startColor, _hoverColor, OnButtonClick);

                #endregion

                #region Drink Page

                _waterPage = _mono.gameObject.AddComponent <GridHelper>();
                _waterPage.OnLoadDisplay += OnLoadWaterDisplay;
                _waterPage.Setup(17, ARSSeaBreezeFCS32Buildable.ItemPrefab, drinks, _startColor, _hoverColor, OnButtonClick);

                #endregion

                #region Trash Page

                _trashPage = _mono.gameObject.AddComponent <GridHelper>();
                _trashPage.OnLoadDisplay += OnLoadTrashDisplay;
                _trashPage.Setup(17, ARSSeaBreezeFCS32Buildable.ItemPrefab, trash, _startColor, _hoverColor, OnButtonClick);

                #endregion

                #region StorageAmount

                _itemCounter_LBL = InterfaceHelpers.FindGameObject(home, "ItemCounter_LBL").GetComponent <Text>();

                #endregion

                #region Unit Name

                _seaBreeze_LBL = InterfaceHelpers.FindGameObject(home, "SeaBreeze_LBL").GetComponent <Text>();

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

            return(true);
        }
        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);
            }
        }
        public override bool FindAllComponents()
        {
            try
            {
                if (_isInitialized)
                {
                    return(true);
                }
                #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 Amount
                _amountOfPodsCount = InterfaceHelpers.FindGameObject(home, "AmountOfPodsCount")?.GetComponent <Text>();
                #endregion

                #region GasPodButton
                var gasPodButtonObj = InterfaceHelpers.FindGameObject(home, "GasPodButton");

                InterfaceHelpers.CreateButton(gasPodButtonObj, "GasPodBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, GaspodCollectorBuildable.TakeGaspod());

                var image   = gasPodButtonObj.transform.Find("Image");
                var guiIcon = image.gameObject.EnsureComponent <uGUI_Icon>();
                guiIcon.sprite = SpriteManager.Get(TechType.GasPod);

                #endregion

                #region DumpBTNButton
                var dumpBTNButtonObj = InterfaceHelpers.FindGameObject(home, "DumpBTN");

                InterfaceHelpers.CreateButton(dumpBTNButtonObj, "DumpBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, GaspodCollectorBuildable.DumpPull(), GaspodCollectorBuildable.DumpMessage());
                #endregion

                #region Messages
                InterfaceHelpers.FindGameObject(home, "AmountOfPods").GetComponent <Text>().text = GaspodCollectorBuildable.AmountOfPodsMessage();
                InterfaceHelpers.FindGameObject(home, "ClickToTake").GetComponent <Text>().text  = GaspodCollectorBuildable.InstructionsMessage();
                InterfaceHelpers.FindGameObject(home, "Battery (1)").FindChild("Battery Label").GetComponent <Text>().text = $"{GaspodCollectorBuildable.Battery()} 1";
                InterfaceHelpers.FindGameObject(home, "Battery (2)").FindChild("Battery Label").GetComponent <Text>().text = $"{GaspodCollectorBuildable.Battery()} 2";
                #endregion

                #region ColorPicker Button

                var colorBTN = InterfaceHelpers.FindGameObject(home, "ColorBTN");

                InterfaceHelpers.CreateButton(colorBTN, "ColorBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, GaspodCollectorBuildable.ColorPicker());

                #endregion

                #region Battery Button

                var batteryBTN = InterfaceHelpers.FindGameObject(home, "BatteryBTN").FindChild("Fill");

                InterfaceHelpers.CreateButton(batteryBTN, "BatteryBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _greenColor, _fireBrickColor, MAX_INTERACTION_DISTANCE, GaspodCollectorBuildable.BatteryReceptacle());

                #endregion

                #region ColorPicker

                var colorPicker = InterfaceHelpers.FindGameObject(canvasGameObject, "ColorPicker");
                #endregion

                #region Color Paginator
                var _colorPaginator = InterfaceHelpers.FindGameObject(colorPicker, "Paginator");
                #endregion

                #region Color Grid
                var _colorGrid = InterfaceHelpers.FindGameObject(colorPicker, "Grid");
                #endregion

                #region ColorPage
                _colorPage.SetupGrid(66, GaspodCollectorBuildable.ColorItemPrefab, _colorGrid, _colorPaginator.GetComponent <Text>(), OnButtonClick);
                #endregion

                #region Prev Color Button
                var prevColorBtn = InterfaceHelpers.FindGameObject(colorPicker, "PrevBTN");

                InterfaceHelpers.CreatePaginator(prevColorBtn, -1, _colorPage.ChangeColorPageBy, _startColor, _hoverColor);
                #endregion

                #region Next Color Button
                var nextColorBtn = InterfaceHelpers.FindGameObject(colorPicker, "NextBTN");

                InterfaceHelpers.CreatePaginator(nextColorBtn, 1, _colorPage.ChangeColorPageBy, _startColor, _hoverColor);
                #endregion

                #region HomeButton
                var homeBTN = InterfaceHelpers.FindGameObject(colorPicker, "HomeBTN");

                InterfaceHelpers.CreateButton(homeBTN, "HomeBTN", InterfaceButtonMode.Background,
                                              OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, GaspodCollectorBuildable.GoHome());

                #endregion

                #region Batteries

                var b1 = InterfaceHelpers.FindGameObject(home, "Battery (1)");
                var b2 = InterfaceHelpers.FindGameObject(home, "Battery (2)");

                _b1Fill = InterfaceHelpers.FindGameObject(b1, "Fill")?.GetComponent <Image>();
                _b2Fill = InterfaceHelpers.FindGameObject(b2, "Fill")?.GetComponent <Image>();

                _b1Amount = InterfaceHelpers.FindGameObject(b1, "Amount")?.GetComponent <Text>();
                _b2Amount = InterfaceHelpers.FindGameObject(b2, "Amount")?.GetComponent <Text>();

                #endregion

                return(true);
            }
            catch (Exception e)
            {
                QuickLogger.Error <GasopodCollectorDisplayManager>($"{e.Message}\n{e.StackTrace}");
                return(false);
            }
        }
Exemple #10
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);
            }
        }
Exemple #11
0
        public override bool FindAllComponents()
        {
            #region Canvas
            var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

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

            canvasGameObject.gameObject.GetComponent <GraphicRaycaster>().ignoreReversedGraphics = false;
            #endregion

            #region Home

            var home = canvasGameObject.FindChild("Home")?.gameObject;

            if (home == null)
            {
                QuickLogger.Error("Unable to find Home GameObject");
                return(false);
            }
            #endregion

            #region ColorPicker

            var colorPicker = canvasGameObject.FindChild("ColorPicker")?.gameObject;

            if (colorPicker == null)
            {
                QuickLogger.Error("Unable to find colorPicker GameObject");
                return(false);
            }
            #endregion



            var takeWaterResult = InterfaceHelpers.CreateButton(home, "Button_1", "takeWaterBTN", InterfaceButtonMode.Background,
                                                                _startColor, _hoverColor, OnButtonClick, out var takeWaterButton);
            takeWaterButton.TextLineOne = "Take Water";

            if (!takeWaterResult)
            {
                return(false);
            }
            _startButton = takeWaterButton;

            var colorPickerResult = InterfaceHelpers.CreateButton(home, "Paint_BTN", "colorPickerBTN", InterfaceButtonMode.Background,
                                                                  OnButtonClick, out var colorPickerButton);
            colorPickerButton.TextLineOne = "Color Picker Page";


            if (!colorPickerResult)
            {
                return(false);
            }

            var fuelTankResult = InterfaceHelpers.CreateButton(home, "Button_2", "waterContainerBTN", InterfaceButtonMode.Background,
                                                               _startColor, _hoverColor, OnButtonClick, out var fuelTankButton);
            fuelTankButton.TextLineOne = !QPatch.Configuration.AutoGenerateMode ? "Take Water Bottle" : "Open Water Container";


            if (!fuelTankResult)
            {
                return(false);
            }

            var homeBTN = InterfaceHelpers.CreateButton(colorPicker, "Home_BTN", "homeBTN", InterfaceButtonMode.Background,
                                                        OnButtonClick, out var homeButton);
            homeButton.TextLineOne       = "Home Page";
            homeButton.OnInterfaceButton = SetOnInterfaceButton;

            if (!homeBTN)
            {
                return(false);
            }

            var nextBTN = InterfaceHelpers.CreatePaginator(colorPicker, "NextPage", 1, _colorPage.ChangeColorPageBy, out var nextButton);
            nextButton.TextLineOne = "Next Page";


            if (!nextBTN)
            {
                return(false);
            }

            var prevBTN = InterfaceHelpers.CreatePaginator(colorPicker, "PrevPage", -1, _colorPage.ChangeColorPageBy, out var prevButton);
            prevButton.TextLineOne = "Previous Page";



            if (!prevBTN)
            {
                return(false);
            }

            var gridResult = InterfaceHelpers.FindGameObject(colorPicker, "Grid", out var grid);

            if (!gridResult)
            {
                return(false);
            }
            _grid = grid;

            var paginatorResult = InterfaceHelpers.FindGameObject(colorPicker, "Paginator", out var paginator);

            if (!paginatorResult)
            {
                return(false);
            }
            _paginator = paginator.GetComponent <Text>();

            var button1ProgressResult = InterfaceHelpers.FindGameObject(home, "Button_1_Progress", out var button1Progress);

            if (!button1ProgressResult)
            {
                return(false);
            }
            _button1Progress = button1Progress.GetComponent <Image>();

            var button1ProgressNumResult = InterfaceHelpers.FindGameObject(home, "Button_1_Progress_Number", out var button1ProgressNumber);

            if (!button1ProgressNumResult)
            {
                return(false);
            }
            _button1ProgressNumber      = button1ProgressNumber.GetComponent <Text>();
            _button1ProgressNumber.text = $"(0%)";

            var button2ProgressResult = InterfaceHelpers.FindGameObject(home, "Button_2_Progress", out var button2Progress);

            if (!button2ProgressResult)
            {
                return(false);
            }
            _button2Progress = button2Progress.GetComponent <Image>();

            if (!QPatch.Configuration.AutoGenerateMode)
            {
                _button2Progress.fillAmount = 1;
            }

            var button2ProgressNumResult = InterfaceHelpers.FindGameObject(home, "Button_2_Amount_Number", out var button2ProgressNumber);

            if (!button2ProgressNumResult)
            {
                return(false);
            }
            _button2ProgressNumber      = button2ProgressNumber.GetComponent <Text>();
            _button2ProgressNumber.text = QPatch.Configuration.AutoGenerateMode ? $"0 {MiniFountainFilterBuildable.Bottles()}" : string.Empty;

            //var versionResult = InterfaceHelpers.FindGameObject(canvasGameObject, "Version", out var version);

            //if (!versionResult)
            //{
            //    return false;
            //}
            //var versionLbl = version.GetComponent<Text>();
            //versionLbl.text = $"{MiniFountainFilterBuildable.Version()}: {QPatch.Version}";

            return(true);
        }
Exemple #12
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);
        }
Exemple #13
0
        private void OnLoadItemsGrid(DisplayData data)
        {
            if (_isBeingDestroyed || _mono == null || _mono?.Manager == null)
            {
                return;
            }

            _itemTechTypeGrid.ClearPage();
            _itemTechTypeList.Clear();

            var grouped = Mod.AllTechTypes;

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

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

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

            QuickLogger.Debug($"1");

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

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

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

                var button = buttonPrefab.AddComponent <OperationInterfaceButton>();
                if (grouped[i] == _itemTechType)
                {
                    button.SetCheck(true);
                }
                buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
                button.BtnName       = "ItemTechBTN";
                button.OnButtonClick = OnButtonClick;
                button.Tag           = new OperatorButtonData {
                    Button = button, TechType = grouped[i]
                };
                button.TextLineOne = $"Send {Language.main.Get(grouped[i])}";
                buttonPrefab.GetComponentInChildren <Text>().text = Language.main.Get(grouped[i]);
                uGUI_Icon icon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                icon.sprite = SpriteManager.Get(grouped[i]);
                _itemTechTypeList.Add(button);
            }

            _itemTechTypeGrid.UpdaterPaginator(grouped.Count);
        }
Exemple #14
0
        private void OnLoadVisibilityGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed || _mono == null || _mono?.Manager == null)
                {
                    return;
                }

                _visibilityGrid.ClearPage();


                var grouped = _mono.Manager.FCSConnectables;

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

                if (!string.IsNullOrEmpty(_visibilityCurrentSearchString?.Trim()))
                {
                    grouped = grouped.Where(p => p.Value.UnitID.StartsWith(_visibilityCurrentSearchString.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 connectable = grouped.ElementAt(i);

                    if (connectable.Value.IsBase() || !connectable.Value.CanBeVisible())
                    {
                        continue;
                    }

                    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 Unit: {connectable.Value.UnitID}", true);

                    buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
                    var button = buttonPrefab.AddComponent <OperationInterfaceButton>();
                    button.BtnName = "VisibilityItemBTN";
                    button.Tag     = new OperatorButtonData {
                        Button = button, Connectable = connectable.Value
                    };
                    button.TextLineOne   = $"Make {Language.main.Get(connectable.Value.GetTechType())} visible to the terminal";
                    button.OnButtonClick = OnButtonClick;
                    button.SetCheck(connectable.Value.IsVisible);
                    buttonPrefab.GetComponentInChildren <Text>().text = connectable.Value.UnitID;
                    uGUI_Icon icon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                    icon.sprite = connectable.Value.IsBase() ? SpriteManager.Get(TechType.BaseRoom) : SpriteManager.Get(connectable.Value.GetTechType());
                }

                _visibilityGrid.UpdaterPaginator(grouped.Count);
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }
Exemple #15
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}");
            }
        }
Exemple #16
0
        private void OnLoadOperationsGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed || _mono == null || _mono?.Manager == null)
                {
                    return;
                }

                _operationsGrid.ClearPage();

                var grouped = BaseManager.Operations;

                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 connectable = grouped.ElementAt(i);

                    if (connectable.FromDevice == null || connectable.ToDevice == null)
                    {
                        continue;
                    }

                    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);
                    var button = buttonPrefab.AddComponent <OperationInterfaceButton>();

                    button.BtnName     = "OperationBTN";
                    button.Tag         = null;
                    button.TextLineOne = $"{connectable.FromDevice.UnitID} => {Language.main.Get(connectable.TechType)} => {connectable.ToDevice.UnitID}";
                    //buttonPrefab.GetComponentInChildren<Text>().text = connectable.Value.UnitID;
                    uGUI_Icon icon = InterfaceHelpers.FindGameObject(InterfaceHelpers.FindGameObject(buttonPrefab, "FromIcon"), "Image").AddComponent <uGUI_Icon>();
                    icon.sprite = connectable.FromDevice.IsBase() ? SpriteManager.Get(TechType.BaseRoom) : SpriteManager.Get(connectable.FromDevice.GetTechType());

                    uGUI_Icon icon1 = InterfaceHelpers.FindGameObject(InterfaceHelpers.FindGameObject(buttonPrefab, "TechTypeIcon"), "Image").AddComponent <uGUI_Icon>();
                    icon1.sprite = SpriteManager.Get(connectable.TechType);

                    uGUI_Icon icon2 = InterfaceHelpers.FindGameObject(InterfaceHelpers.FindGameObject(buttonPrefab, "ToIcon"), "Image").AddComponent <uGUI_Icon>();
                    icon2.sprite = connectable.ToDevice.IsBase() ? SpriteManager.Get(TechType.BaseRoom) : SpriteManager.Get(connectable.ToDevice.GetTechType());

                    var deleteBTN = buttonPrefab.GetComponentInChildren <Button>();
                    deleteBTN.onClick.AddListener(() => { _mono.Manager.DeleteOperator(connectable); });
                }

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