Пример #1
0
        public override void Initialize()
        {
            if (DumpContainer == null)
            {
                DumpContainer = new DumpContainer();
                DumpContainer.Initialize(transform, "Item Display Receptical", AuxPatchers.NotAllowed(), AuxPatchers.CannotBeStored(), this, 1, 1);
            }

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

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


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

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

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

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

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

            AddToBaseManager();

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

            IsInitialized = true;
        }
Пример #2
0
        public InterfaceButton AddButton(Func <Rectangle> position, Action <Player> pressAction, Action <Player, SpriteBatch> hoverAction)
        {
            InterfaceButton button = new InterfaceButton(position, pressAction, hoverAction);

            Buttons.Add(button);
            return(button);
        }
Пример #3
0
    void processGaze()
    {
        RaycastHit hitInfo;

        if (gazeProvider)
        {
            if (Physics.Raycast(gazeProvider.GazeOrigin, gazeProvider.GazeDirection, out hitInfo, gazeMaxDistance, gazeLayerMask)) //Gaze hit something
            {
                //Debug.Log("<color=blue>Unity Gaze hit: " + hitInfo.collider.name + "</color>");
                gazeStatus   = GazeStatus.VALID;
                gazeHitpoint = hitInfo.point; //Store hitInfo until next frame

                if (uiState == UIState.DISPLAYING_MENU || uiState == UIState.IDLE)
                {
                    GameObject objHit = hitInfo.collider.gameObject;
                    if (buttonInGaze && buttonInGaze.gameObject != objHit) //Hit a button last frame and objHit is not that button
                    {
                        buttonInGaze.onHoverStop(primaryColor);            //Was hovering on button
                    }

                    buttonInGaze = objHit.GetComponent <InterfaceButton>();

                    if (buttonInGaze) //objHit is an InterfaceButton
                    {
                        buttonInGaze.onHoverStart(buttonHighlightColor);
                    }
                }
                else if (uiState == UIState.MARKING_HAZARD || uiState == UIState.SETTING_WAYPOINT)
                {
                    if (markerBeingPlaced && gazeProvider.HitInfo.collider.gameObject != markerBeingPlaced) //Marker is not null && not looking at the marker
                    {
                        markerBeingPlaced.transform.position = gazeHitpoint;
                    }
                    buttonInGaze = null;
                }
            }
            else
            {
                buttonInGaze = null;
                gazeStatus   = GazeStatus.INVALID;
                //Debug.Log("<color=red>Gaze hit nothing</color>");
            }
        }
        else
        {
            gazeStatus = GazeStatus.INVALID;
            //Debug.Log("<color=red>Gaze Provider is null</color>");
        }
    }
Пример #4
0
        internal void UpdateListItems(TechType techType = TechType.None)
        {
            QuickLogger.Debug($"In Update List: Target = {techType} || OreButtons {OreButtons?.Count}");

            if (OreButtons != null)
            {
                foreach (InterfaceButton button in OreButtons)
                {
                    if ((TechType)button.Tag == techType)
                    {
                        button.Focus();
                        _button = button;
                        QuickLogger.Debug($"Match found for TechType {techType}", true);
                    }
                    else
                    {
                        button.RemoveFocus();
                    }
                }
            }

            UpdateFocusStates();
        }
        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);
        }
Пример #6
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);
        }
Пример #7
0
        public override bool FindAllComponents()
        {
            #region Canvas

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

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

            #endregion

            // == Canvas Elements == //

            #region Navigation Dock
            var navigationDock = canvasGameObject.transform.Find("Navigation_Dock")?.gameObject;
            if (navigationDock == null)
            {
                QuickLogger.Error("Dock: Navigation_Dock not found.");
                return(false);
            }
            #endregion

            // == Navigation Button Elements == //

            #region Screen Holder

            GameObject screenHolder = canvasGameObject.transform.Find("Screens")?.gameObject;

            if (screenHolder == null)
            {
                QuickLogger.Error("Screen Holder GameObject not found.");
                return(false);
            }

            #endregion

            // == Screen Holder Elements == //

            #region Welcome Screen

            var welcomeScreen = screenHolder.FindChild("WelcomePage")?.gameObject;
            if (welcomeScreen == null)
            {
                QuickLogger.Error("Screen: WelcomeScreen not found.");
                return(false);
            }

            #endregion

            #region Version Label
            var versionLbl = welcomeScreen.FindChild("Logo_Intro").FindChild("Version_Text")?.gameObject;

            if (versionLbl == null)
            {
                QuickLogger.Error("Cannot find Version_Text Game Object");
            }

            string assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            versionLbl.GetComponent <Text>().text = $"V{assemblyVersion}";
            #endregion

            #region Settings Screen

            var settingsScreen = screenHolder.FindChild("SettingsPage")?.gameObject;
            if (settingsScreen == null)
            {
                QuickLogger.Error("Screen: SettingsPage not found.");
                return(false);
            }

            #endregion

            #region Battery Monitor Page
            var batteryMonitorPage = screenHolder.FindChild("BatteryMonitorPage")?.gameObject;
            if (batteryMonitorPage == null)
            {
                QuickLogger.Error("Screen: BatteryMonitorPage not found.");
                return(false);
            }

            QuickLogger.Info("Finding Meters");
            #endregion

            #region Battery Grid
            _batteryGrid = batteryMonitorPage.FindChild("Grid")?.gameObject;
            if (_batteryGrid == null)
            {
                QuickLogger.Error("Screen: BatteryMonitorPage not found.");
                return(false);
            }

            QuickLogger.Debug($"Meter Count {_batteryGrid.transform.childCount}");


            for (int i = 0; i < _mono.BatteryCount; i++)
            {
                QuickLogger.Info($"Meter {i}");
                var powercell = _mono.PowerManager.GetPowerCell(i);
                QuickLogger.Debug($"Battery {powercell.GetName()}");
                powercell.SetMeter(_batteryGrid.transform.GetChild(i).gameObject);
            }
            #endregion

            #region Power Off Page
            var powerOffPage = screenHolder.FindChild("PowerOffPage")?.gameObject;
            if (powerOffPage == null)
            {
                QuickLogger.Error("Screen: PowerOffPage not found.");
                return(false);
            }
            #endregion

            #region Boot Page
            var bootingPage = screenHolder.FindChild("BootingPage")?.gameObject;
            if (bootingPage == null)
            {
                QuickLogger.Error("Screen: BootingPage not found.");
                return(false);
            }
            #endregion

            // == Powered off Elements
            #region PoweredOff LBL

            var poweredOffLbl = powerOffPage.FindChild("Powered_Off_LBL").GetComponent <Text>();
            if (poweredOffLbl == null)
            {
                QuickLogger.Error("Screen: Powered_Off_LBL  not found.");
                return(false);
            }
            poweredOffLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.PoweredOffKey);

            #endregion


            // == Battery MonitorPage Elements

            #region Battery Monitor Power Amount Label
            _batteryMonitorAmountLbl = batteryMonitorPage.FindChild("Battery_Monitor_Amount_LBL").GetComponent <Text>();
            if (_batteryMonitorAmountLbl == null)
            {
                QuickLogger.Error("Screen: Battery_Monitor_Amount_LBL not found.");
                return(false);
            }
            #endregion

            #region Battery Monitor Label

            var batteryMonitorLbl = batteryMonitorPage.FindChild("Battery_Monitor_LBL").GetComponent <Text>();
            if (batteryMonitorLbl == null)
            {
                QuickLogger.Error("Screen: Battery_Monitor_LBL not found.");
                return(false);
            }
            batteryMonitorLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.BatteryMetersKey);

            #endregion

            #region Trickle Mode BTN
            var trickleModeBtn = batteryMonitorPage.FindChild("Trickle_Mode")?.gameObject;
            if (trickleModeBtn == null)
            {
                QuickLogger.Error("Screen: Trickle_Mode not found.");
                return(false);
            }

            InterfaceButton trickleBTN = trickleModeBtn.AddComponent <InterfaceButton>();
            trickleBTN.OnButtonClick += OnButtonClick;
            trickleBTN.ButtonMode     = InterfaceButtonMode.None;
            trickleBTN.BtnName        = "TrickleModeBTN";

            #endregion

            #region Charge Mode BTN
            var chargeModeBtn = batteryMonitorPage.FindChild("Charge_Mode")?.gameObject;
            if (chargeModeBtn == null)
            {
                QuickLogger.Error("Screen: Charge_Mode not found.");
                return(false);
            }

            InterfaceButton chargeBTN = chargeModeBtn.AddComponent <InterfaceButton>();
            chargeBTN.ButtonMode     = InterfaceButtonMode.None;
            chargeBTN.OnButtonClick += OnButtonClick;
            chargeBTN.BtnName        = "ChargeModeBTN";
            #endregion


            // == Boot Page Elements == //

            #region Booting LBL

            var bootingLbl = bootingPage.FindChild("Booting_TXT").GetComponent <Text>();
            if (bootingLbl == null)
            {
                QuickLogger.Error("Screen: _bootingLBL  not found.");
                return(false);
            }
            bootingLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.BootingKey);

            #endregion

            // == Settings Page Elements == //
            #region Color Picker
            var colorPicker = settingsScreen.FindChild("Color_Picker")?.gameObject;
            if (colorPicker == null)
            {
                QuickLogger.Error("Screen: _color_Picker not found.");
                return(false);
            }

            InterfaceButton colorPickerBTN = colorPicker.AddComponent <InterfaceButton>();
            colorPickerBTN.OnButtonClick += OnButtonClick;
            colorPickerBTN.ButtonMode     = InterfaceButtonMode.None;
            colorPickerBTN.BtnName        = "ColorPickerBTN";
            #endregion

            #region Color Picker LBL

            var colorPickerLbl = colorPicker.FindChild("Label").GetComponent <Text>();
            if (colorPickerLbl == null)
            {
                QuickLogger.Error("Screen: Color Picker Label not found.");
                return(false);
            }
            colorPickerLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.ColorPickerKey);

            #endregion

            #region Settings LBL

            var settingsLbl = settingsScreen.FindChild("Setting_LBL").GetComponent <Text>();
            if (settingsLbl == null)
            {
                QuickLogger.Error("Screen: Settings Page Label not found.");
                return(false);
            }
            settingsLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.SettingsKey);

            #endregion

            #region System Settings LBL

            var storageModeLbl = settingsScreen.FindChild("System_Settings_LBL").GetComponent <Text>();
            if (storageModeLbl == null)
            {
                QuickLogger.Error("Screen: Storage Mode Label not found.");
                return(false);
            }
            storageModeLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.SystemSettingsLblKey);

            #endregion

            #region Grid
            var grid = settingsScreen.FindChild("Grid")?.gameObject;
            if (grid == null)
            {
                QuickLogger.Error("Screen: Grid not found.");
                return(false);
            }
            #endregion

            #region Auto Activate BTN
            var autoActivateBtn = grid.FindChild("Auto_Activate")?.gameObject;
            if (autoActivateBtn == null)
            {
                QuickLogger.Error("Screen: Auto_Activate not found.");
                return(false);
            }

            var autoActivateTxt = autoActivateBtn.FindChild("Label").GetComponent <Text>();

            if (autoActivateTxt == null)
            {
                QuickLogger.Error("Screen: Auto_Activate text not found.");
                return(false);
            }

            autoActivateTxt.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.AutoActivateKey);

            InterfaceButton autoABTN = autoActivateBtn.AddComponent <InterfaceButton>();
            autoABTN.ButtonMode     = InterfaceButtonMode.None;
            autoABTN.OnButtonClick += OnButtonClick;
            autoABTN.BtnName        = "AutoActivateBTN";

            #endregion

            #region Sync BTN
            var syncBtn = grid.FindChild("Sync")?.gameObject;
            if (syncBtn == null)
            {
                QuickLogger.Error("Screen: Sync not found.");
                return(false);
            }

            var syncAllBtnTxt = syncBtn.FindChild("Label").GetComponent <Text>();

            if (syncAllBtnTxt == null)
            {
                QuickLogger.Error("Screen: Sync All text not found.");
                return(false);
            }

            syncAllBtnTxt.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.SyncAllKey);

            InterfaceButton syncBTN = syncBtn.AddComponent <InterfaceButton>();
            syncBTN.ButtonMode     = InterfaceButtonMode.None;
            syncBTN.OnButtonClick += OnButtonClick;
            syncBTN.BtnName        = "SyncBTN";

            #endregion

            #region Auto Activate Limit
            var autoActivateLimitBtn = grid.FindChild("Auto_Activate_Limit")?.gameObject;
            if (autoActivateLimitBtn == null)
            {
                QuickLogger.Error("Screen: Auto_Activate_Limit not found.");
                return(false);
            }

            var autoActivateLimitTxt = autoActivateLimitBtn.FindChild("Label").GetComponent <Text>();

            if (autoActivateLimitTxt == null)
            {
                QuickLogger.Error("Screen: Auto_Activate_limit text not found.");
                return(false);
            }

            autoActivateLimitTxt.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.AutoActivateAtKey);

            var autoActivateLimitTextBox = autoActivateLimitBtn.FindChild("Background").FindChild("Text")?.gameObject;

            if (autoActivateLimitTextBox == null)
            {
                QuickLogger.Error("Screen:btnName Text not found.");
                return(false);
            }

            _autoActivateTextB      = autoActivateLimitTextBox.GetComponent <Text>();
            _autoActivateTextB.text = _mono.GetAutoActivateAt().ToString();

            var autoActivateResult = CreateSystemButton(autoActivateLimitTextBox,
                                                        LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.AutoActivateDescKey), LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.AutoActivateOnHoverKey),
                                                        _mono.GetAutoActivateAt, _mono.ValidateAutoConfigUnits);

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

            #endregion

            #region Base Drain Protection BTN
            var baseDrainProtectionBtn = grid.FindChild("Base_Drain_Protection")?.gameObject;
            if (baseDrainProtectionBtn == null)
            {
                QuickLogger.Error("Screen: Base_Drain_Protection not found.");
                return(false);
            }

            var baseDrianProtectionTxt = baseDrainProtectionBtn.FindChild("Label").GetComponent <Text>();

            if (baseDrianProtectionTxt == null)
            {
                QuickLogger.Error("Screen: Base_Drain_protection text not found.");
                return(false);
            }

            baseDrianProtectionTxt.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.BaseDrainProtectionKey);

            InterfaceButton bDPBTN = baseDrainProtectionBtn.AddComponent <InterfaceButton>();
            bDPBTN.ButtonMode     = InterfaceButtonMode.None;
            bDPBTN.OnButtonClick += OnButtonClick;
            bDPBTN.BtnName        = "BaseDrainBTN";
            #endregion

            #region Base Drain Limit
            var baseDrainlimitBtn = grid.FindChild("Base_Drain_Limit")?.gameObject;

            if (baseDrainlimitBtn == null)
            {
                QuickLogger.Error("Screen: Base_Drain_Limit not found.");
                return(false);
            }

            var baseDrianLimitTxt = baseDrainlimitBtn.FindChild("Label").GetComponent <Text>();

            if (baseDrianLimitTxt == null)
            {
                QuickLogger.Error("Screen: Base_Drain_Limit  text not found.");
                return(false);
            }

            baseDrianLimitTxt.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.BaseDrainLimitKey);

            var baseDrainlimitTextBox = baseDrainlimitBtn.FindChild("Background").FindChild("Text")?.gameObject;

            if (baseDrainlimitTextBox == null)
            {
                QuickLogger.Error("Screen:baseDrainlimitTextBox Text not found.");
                return(false);
            }

            _baseDrainLimitTextB      = baseDrainlimitTextBox.GetComponent <Text>();
            _baseDrainLimitTextB.text = _mono.GetBasePowerProtectionGoal().ToString();

            var baseDrainResult = CreateSystemButton(baseDrainlimitTextBox,
                                                     LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.BaseDrainLimitDescKey), LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.BaseDrainLimitOnHoverKey),
                                                     _mono.GetBasePowerProtectionGoal, _mono.ValidateBaseProtectionUnits);

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


            //TODO Add langugae for btns

            #region Discharge Mode LBL
            var trickleModeLbl = trickleModeBtn.FindChild("Label").GetComponent <Text>();
            if (trickleModeLbl == null)
            {
                QuickLogger.Error("Screen: TrickleModeLabel not found.");
                return(false);
            }
            trickleModeLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.DischargeKey);

            #endregion

            #region Charge Mode LBL

            var chargeModeLbl = chargeModeBtn.FindChild("Label").GetComponent <Text>();
            if (chargeModeLbl == null)
            {
                QuickLogger.Error("Screen: Charge Mode LBL not found.");
                return(false);
            }
            chargeModeLbl.text = LanguageHelpers.GetLanguage(FCSPowerStorageBuildable.ChargeKey);

            #endregion

            // == Color Picker Elements == //

            #region Color Picker Page
            var colorPickerPage = screenHolder.FindChild("ColorPickerPage")?.gameObject;
            if (colorPickerPage == null)
            {
                QuickLogger.Error("Screen: ColorPicker not found.");
                return(false);
            }
            #endregion

            _colorPicker = colorPickerPage.FindChild("ColorPicker")?.gameObject;
            if (_colorPicker == null)
            {
                QuickLogger.Error("GameObject: ColorPicker not found.");
                return(false);
            }

            #region Color Picker Previous Page BTN
            _previousPageGameObject = colorPickerPage.FindChild("Back_Arrow_BTN")?.gameObject;
            if (_previousPageGameObject == null)
            {
                QuickLogger.Error("Screen: Back_Arrow_BTN not found.");
                return(false);
            }

            var prevPageBTN = _previousPageGameObject.AddComponent <PaginatorButton>();
            prevPageBTN.AmountToChangePageBy = -1;
            prevPageBTN.ChangePageBy         = ChangePageBy;
            #endregion

            #region Color Picker Next Page BTN
            _nextPageGameObject = colorPickerPage.FindChild("Forward_Arrow_BTN")?.gameObject;
            if (_nextPageGameObject == null)
            {
                QuickLogger.Error("Screen: Forward_Arrow_BTN not found.");
                return(false);
            }

            var nextPageBTN = _nextPageGameObject.AddComponent <PaginatorButton>();
            nextPageBTN.ChangePageBy         = ChangePageBy;
            nextPageBTN.AmountToChangePageBy = 1;
            #endregion

            #region Color Picker Page Counter
            _pageCounter = colorPickerPage.FindChild("Page_Number")?.gameObject;
            if (_pageCounter == null)
            {
                QuickLogger.Error("Screen: Page_Number not found.");
                return(false);
            }

            _pageCounterText = _pageCounter.GetComponent <Text>();
            if (_pageCounterText == null)
            {
                QuickLogger.Error("Screen: _pageCounterText not found.");
                return(false);
            }
            #endregion

            // == Navigation Dock Elements == //

            #region Settings Button
            var settingButton = navigationDock.transform.Find("Settings_BTN")?.gameObject;
            if (settingButton == null)
            {
                QuickLogger.Error("Dock: Settings_BTN not found.");
                return(false);
            }


            InterfaceButton settingsBTN = settingButton.AddComponent <InterfaceButton>();
            settingsBTN.OnButtonClick = OnButtonClick;
            settingsBTN.BtnName       = "SettingsBTN";
            settingsBTN.ButtonMode    = InterfaceButtonMode.Background;
            #endregion

            #region Home Button
            var homeButton = navigationDock.transform.Find("Home_BTN")?.gameObject;
            if (homeButton == null)
            {
                QuickLogger.Error("Dock: Home_BTN not found.");
                return(false);
            }

            InterfaceButton home = homeButton.AddComponent <InterfaceButton>();
            home.OnButtonClick = OnButtonClick;
            home.BtnName       = "HomeBTN";
            home.ButtonMode    = InterfaceButtonMode.Background;
            #endregion

            #region Power Button
            var powerButton = navigationDock.transform.Find("Power_BTN")?.gameObject;
            if (powerButton == null)
            {
                QuickLogger.Error("Dock: Power_BTN not found.");
                return(false);
            }

            InterfaceButton power = powerButton.AddComponent <InterfaceButton>();
            power.OnButtonClick = OnButtonClick;
            power.BtnName       = "PowerBTN";
            power.ButtonMode    = InterfaceButtonMode.Background;

            #endregion

            return(true);
        }
        internal static bool CreateButton(GameObject parent, string childName, string btnName, InterfaceButtonMode btnMode, Color startColor, Color hoverColor, Action <string, object> onButtonClick, out InterfaceButton customButton)
        {
            customButton = null;
            var go = parent.FindChild(childName)?.gameObject;

            if (go == null)
            {
                QuickLogger.Error($"{childName} cannot be found");
                return(false);
            }

            var button = go.AddComponent <InterfaceButton>();

            button.BtnName        = btnName;
            button.ButtonMode     = btnMode;
            button.STARTING_COLOR = startColor;
            button.HOVER_COLOR    = hoverColor;
            button.OnButtonClick  = onButtonClick;
            customButton          = button;
            return(true);
        }
        internal static bool CreateButton(GameObject parent, string childName, string btnName, InterfaceButtonMode btnMode, Action <string, object> onButtonClick, out InterfaceButton button)
        {
            var result = CreateButton(parent, childName, btnName, btnMode, Color.white, ColorBlue, onButtonClick, out InterfaceButton cusButton);

            button = cusButton;
            return(result);
        }
        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("Home cannot be found");
                return(false);
            }
            #endregion

            #region Oxygen Preloader
            var oxPreloaderlbl = home.FindChild("Ox_Preloader")?.FindChild("percentage")?.GetComponent <Text>();

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

            _oxPreloaderLBL = oxPreloaderlbl;
            #endregion

            #region Oxygen Preloader Bar
            var oxPreloaderBar = home.FindChild("Ox_Preloader")?.FindChild("PreLoader_Bar_Front")?.GetComponent <Image>();

            if (oxPreloaderBar == null)
            {
                QuickLogger.Error("Ox_Preloader Bar cannot be found");
                return(false);
            }

            _oxPreloaderBar = oxPreloaderBar;
            #endregion

            #region Health Preloader
            var healthPreloaderlbl = home.FindChild("Health_Preloader")?.FindChild("percentage")?.GetComponent <Text>();

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

            _healthPreloaderlbl = healthPreloaderlbl;
            #endregion

            #region Health Preloader Bar
            var healthPreloaderBar = home.FindChild("Health_Preloader")?.FindChild("PreLoader_Bar_Front")?.GetComponent <Image>();

            if (healthPreloaderBar == null)
            {
                QuickLogger.Error("Health_Preloader Bar cannot be found");
                return(false);
            }

            _healthPreloaderBar = healthPreloaderBar;
            #endregion

            #region Take O2 BTN
            _giveO2BTN = home.transform.Find("Button")?.gameObject;
            if (_giveO2BTN == null)
            {
                QuickLogger.Error("Button not found.");
                return(false);
            }

            _giveOIntBtn                = _giveO2BTN.AddComponent <InterfaceButton>();
            _giveOIntBtn.ButtonMode     = InterfaceButtonMode.Background;
            _giveOIntBtn.STARTING_COLOR = dark_bg;
            _giveOIntBtn.OnButtonClick  = OnButtonClick;
            _giveOIntBtn.BtnName        = "giveO2";
            #endregion

            #region Take O2 BTN LBL
            _buttonLbl = home.transform.Find("Button").Find("Text")?.gameObject.GetComponent <Text>();
            if (_buttonLbl == null)
            {
                QuickLogger.Error("Button Text not found.");
                return(false);
            }

            _buttonLbl.text = OxStationBuildable.TakeOxygen();

            #endregion

            #region Power Usage
            var powerUsage = home.transform.Find("Power_Usage")?.GetComponent <Text>();
            if (powerUsage == null)
            {
                QuickLogger.Error("Power_Usage not found.");
                return(false);
            }

            _powerUsage = powerUsage;
            #endregion

            return(true);
        }
Пример #11
0
 public void RemoveButton(InterfaceButton button)
 {
     Buttons.Remove(button);
 }
Пример #12
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);
        }