void IContent.OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     if (InterfaceHelpers.CheckIfNavigationIsAllowed(e.Source.OriginalString) == false)
     {
         e.Cancel = true;
     }
 }
        // --------------------- Functionality ---------------------

        private void ShowSelectors()
        {
            // initialize lists of interface-objects
            _listOfAxisComboBoxes         = new List <ComboBox>();
            _listOfLevelComboBoxes        = new List <ComboBox>();
            _listOfFilterComboBoxes       = new List <ListBox>();
            _listOfSelectAllButtons       = new List <Button>();
            _listOfSelectNoneButtons      = new List <Button>();
            _listOfQuicksearchTextfields  = new List <TextBox>();
            _listOfQuicksearchFirstSearch = new List <Boolean>();

            DimensionList.Children.Clear();

            // create and view Grids, Separators and Headings
            DimensionList.Children.Add(InterfaceHelpers.CreateTextBlock("DIMENSIONS", "Heading2", 0, 0, 0, 8));
            DimensionList.Children.Add(CreateSelectorGrid(1));
            DimensionList.Children.Add(InterfaceHelpers.CreateSeparator());
            DimensionList.Children.Add(CreateSelectorGrid(2));
            DimensionList.Children.Add(InterfaceHelpers.CreateSeparator());

            DimensionList.Children.Add(InterfaceHelpers.CreateTextBlock("FILTERS", "Heading2", 0, 0, 0, 8));

            for (var filternumber = 3; filternumber < DBWorker.MetaData.ListOfFactDimensions.Count; filternumber++)
            {
                DimensionList.Children.Add(CreateSelectorGrid(filternumber));
                DimensionList.Children.Add(InterfaceHelpers.CreateSeparator());
            }
        }
示例#3
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 Counter

                _counter = canvasGameObject.GetComponentInChildren <Text>();
                #endregion

                #region Hit

                var interactionFace = InterfaceHelpers.FindGameObject(canvasGameObject, "Hit");
                var catcher         = interactionFace.AddComponent <InterfaceButton>();
                catcher.ButtonMode         = InterfaceButtonMode.TextColor;
                catcher.OnInterfaceButton += OnInterfaceButton;

                #endregion

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
示例#4
0
        public void SetupGrid(int colorsPerPage, GameObject colorItemPrefab, GameObject colorPage, Action <string, object> onButtonClick, Color startColor, Color hoverColor, int maxInteractionRange = 5, string prevBtnNAme = "PrevBTN", string nextBtnName = "NextBTN", string gridName = "Grid", string paginatorName = "Paginator", string homeBtnName = "HomeBTN")
        {
            _colorsPerPage      = colorsPerPage;
            _colorItemPrefab    = colorItemPrefab;
            _colorPageContainer = InterfaceHelpers.FindGameObject(colorPage, gridName);
            _colorPageNumber    = InterfaceHelpers.FindGameObject(colorPage, paginatorName)?.GetComponent <Text>();

            #region Prev Color Button
            var prevColorBtn = InterfaceHelpers.FindGameObject(colorPage, prevBtnNAme);

            InterfaceHelpers.CreatePaginator(prevColorBtn, -1, ChangeColorPageBy, startColor, hoverColor);
            #endregion

            #region Next Color Button
            var nextColorBtn = InterfaceHelpers.FindGameObject(colorPage, nextBtnName);

            InterfaceHelpers.CreatePaginator(nextColorBtn, 1, ChangeColorPageBy, startColor, hoverColor);
            #endregion

            #region HomeButton
            var homeBTN = InterfaceHelpers.FindGameObject(colorPage, homeBtnName);

            InterfaceHelpers.CreateButton(homeBTN, "HomeBTN", InterfaceButtonMode.Background,
                                          onButtonClick, startColor, hoverColor, maxInteractionRange, HomeButtonMessage);

            #endregion

            _onButtonClick = onButtonClick;
            DrawColorPage(1);
        }
示例#5
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;
        }
示例#6
0
        private void CreateFilterButton(DisplayData data, GameObject buttonPrefab, List <Filter> grouped, int i, bool isMain = false)
        {
            buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
            buttonPrefab.GetComponentInChildren <Text>().text = grouped[i].GetString();

            if (!grouped[i].IsCategory())
            {
                var icon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon");
                icon.AddComponent <uGUI_Icon>().sprite = SpriteManager.Get(grouped[i].Types[0]);
            }

            var buttonToggle = buttonPrefab.GetComponent <Toggle>();

            if (isMain)
            {
                buttonToggle.isOn = true;
            }

            var mainBTN = buttonPrefab.AddComponent <InterfaceButton>();

            mainBTN.ButtonMode     = InterfaceButtonMode.Background;
            mainBTN.STARTING_COLOR = _startColor;
            mainBTN.HOVER_COLOR    = _hoverColor;
            mainBTN.BtnName        = "FilterBTN";
            mainBTN.Tag            = new FilterTransferData {
                Filter = grouped[i], Toggle = buttonToggle
            };
            mainBTN.OnButtonClick = OnButtonClick;
            _trackedButtons.Add(mainBTN);
        }
        private void OnLoadItemsGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed)
                {
                    return;
                }

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

                _itemsGrid.ClearPage();


                var grouped = _mono.DeepDrillerContainer.GetItemsWithin();


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

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

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

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

                    uGUI_Icon trashIcon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                    trashIcon.sprite = SpriteManager.Get(grouped.ElementAt(i).Key);
                }
                _itemsGrid.UpdaterPaginator(grouped.Count());
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }
示例#8
0
        private void CreateButton(DisplayData data, GameObject buttonPrefab, ButtonData buttonData, ButtonType buttonType, string btnText, string btnName)
        {
            buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
            var mainBtn = buttonPrefab.AddComponent <DSSUIButton>();
            var text    = buttonPrefab.GetComponentInChildren <Text>();

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

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

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

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

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

            case ButtonType.Base:
                mainBtn.TextLineOne = AuxPatchers.ViewBaseStorageFormat();
                mainBtn.Tag         = new TransferData {
                    Manager = buttonData.Manager, ButtonType = buttonType
                };
                break;
            }
        }
        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 Damage Screen

                var damageScreen = InterfaceHelpers.FindGameObject(canvasGameObject, "DamagesScreen");

                #endregion

                #region Damage Amount Text

                _damageAmountText = InterfaceHelpers.FindGameObject(damageScreen, "DamageAmount").GetComponent <Text>();

                #endregion

                #region Ping BTN

                var pingBTN     = InterfaceHelpers.FindGameObject(damageScreen, "PingBTN");
                var pingBTNText = pingBTN?.GetComponentInChildren <Text>();
                pingBTNText.text = "PING ALL";

                #endregion

                #region Info Screen

                var infoScreen = InterfaceHelpers.FindGameObject(canvasGameObject, "InfoScreen");

                #endregion

                #region Grid

                var grid = infoScreen?.GetComponentInChildren <GridLayoutGroup>().gameObject;
                _oxGrid = gameObject.AddComponent <GridHelper>();
                _oxGrid.Setup(6, OxStationModelPrefab.ItemPrefab, infoScreen, Color.black, Color.white, OnButtonClick,
                              5, "PrevBTN", "NextBTN", "Grid", "Paginator", string.Empty);
                _oxGrid.OnLoadDisplay += OnLoadDisplay;

                #endregion
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                return(false);
            }

            return(true);
        }
        public void CheckIfNavigationIsAllowedTest2()
        {
            // [0] P1connection.xaml",
            // [1] P2metadata.xaml",
            // [2] P3dimensionselection.xaml",
            // [3] P4eventselection.xaml",
            // [4] P5configuration.xaml",
            // [5] P6mining.xaml",
            // [6] P8results.xaml"

            bool expected = true;
            bool actual   = true;

            DBWorker.MetaData = new MetaDataRepository();

            if (actual)
            {
                InterfaceHelpers.CurrentPage = PageList[0];
                actual = InterfaceHelpers.CheckIfNavigationIsAllowed(PageList[1]);
            }

            if (actual)
            {
                InterfaceHelpers.CurrentPage = PageList[1];
                actual = InterfaceHelpers.CheckIfNavigationIsAllowed(PageList[2]);
            }

            if (actual)
            {
                InterfaceHelpers.CurrentPage = PageList[2];
                actual = InterfaceHelpers.CheckIfNavigationIsAllowed(PageList[3]);
            }

            if (actual)
            {
                InterfaceHelpers.CurrentPage = PageList[3];
                actual = InterfaceHelpers.CheckIfNavigationIsAllowed(PageList[4]);
            }

            if (actual)
            {
                MinerSettings.IsAlgorithmSet = true;
                InterfaceHelpers.CurrentPage = PageList[4];
                actual = InterfaceHelpers.CheckIfNavigationIsAllowed(PageList[5]);
            }


            if (actual)
            {
                InterfaceHelpers.MiningIsCompleted = true;
                InterfaceHelpers.CurrentPage       = PageList[5];
                actual = InterfaceHelpers.CheckIfNavigationIsAllowed(PageList[6]);
            }

            Assert.AreEqual(expected, actual);
        }
示例#11
0
        private void OnLoadDnaGrid(DisplayData info)
        {
            _dnaGrid.ClearPage();

            var grouped = _mono.HydroHarvContainer.Items.ToList();

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

            for (int i = info.StartPosition; i < info.EndPosition; i++)
            {
                var techType = grouped[i].Key;

                GameObject buttonPrefab = Instantiate(info.ItemsPrefab);

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

                buttonPrefab.transform.SetParent(info.ItemsGrid.transform, false);
                buttonPrefab.GetComponentInChildren <Text>().text = grouped[i].Value.ToString();

                var mainButton = buttonPrefab.FindChild("MainButton");

                var mainBTN = mainButton.AddComponent <ItemButton>();
                mainBTN.Mode           = ButtonMode.Take;
                mainBTN.Type           = techType;
                mainBTN.ButtonMode     = InterfaceButtonMode.Background;
                mainBTN.STARTING_COLOR = _startColor;
                mainBTN.HOVER_COLOR    = _hoverColor;
                mainBTN.OnButtonClick  = _mono.HydroHarvContainer.RemoveItemFromContainer;

                uGUI_Icon icon = InterfaceHelpers.FindGameObject(mainButton, "Icon").AddComponent <uGUI_Icon>();
                icon.sprite = SpriteManager.Get(techType);

                var deleteButton = buttonPrefab.FindChild("DeleteBTN");

                var deleteBTN = deleteButton.AddComponent <ItemButton>();
                deleteBTN.ButtonMode     = InterfaceButtonMode.Background;
                deleteBTN.Mode           = ButtonMode.Delete;
                deleteBTN.Type           = techType;
                deleteBTN.STARTING_COLOR = _startColor;
                deleteBTN.HOVER_COLOR    = _hoverColor;
                deleteBTN.OnButtonClick  = _mono.HydroHarvContainer.DeleteItemFromContainer;

                uGUI_Icon trashIcon = InterfaceHelpers.FindGameObject(deleteButton, "Icon").AddComponent <uGUI_Icon>();
                trashIcon.sprite = SpriteManager.Get(TechType.Trashcans);
            }
        }
示例#12
0
        public SettingsFlyoutStreaming()
        {
            this.InitializeComponent();

            InterfaceHelpers.SetupVideoBitrate(videoBitrate);
            InterfaceHelpers.SetupVideoMaxWidth(videoMaxWidth);
            InterfaceHelpers.SetupAudioBitrate(audioBitrate);
            InterfaceHelpers.SetupAudioChannel(audioChannels);
            InterfaceHelpers.SetupAudioCodec(audioCodecs);
            InterfaceHelpers.SetupEnableStreamCopy(enableStreamCopy);
        }
        public void CreateComboBoxTest()
        {
            string name  = "TestName";
            string style = string.Empty;

            ComboBox expected = new ComboBox {
                Name = name, Margin = new Thickness(0, 0, 0, 0), Style = new Style()
            };
            ComboBox actual;

            actual = InterfaceHelpers.CreateComboBox(name, style);
            Assert.IsTrue(actual.Name == expected.Name && actual.Margin == expected.Margin);
        }
示例#14
0
        void IContent.OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            if (DBWorker.MetaData == null && e.Source.OriginalString == "/Pages/P2metadata.xaml")
            {
                ModernDialog.ShowMessage("You have to establish a database connection first.", "Connection", MessageBoxButton.OK);
                e.Cancel = true;
            }

            if (InterfaceHelpers.CheckIfNavigationIsAllowed(e.Source.OriginalString) == false)
            {
                e.Cancel = true;
            }
        }
示例#15
0
        void IContent.OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            if (DBWorker.MetaData.EventClassifier == "")
            {
                e.Cancel = true;
                ModernDialog.ShowMessage("Please select a classifier", "Metadata", MessageBoxButton.OK);
            }

            if (InterfaceHelpers.CheckIfNavigationIsAllowed(e.Source.OriginalString) == false)
            {
                e.Cancel = true;
            }
        }
        public void CreateLabelTest()
        {
            string text  = "TestText";
            string style = string.Empty;

            Label expected = new Label {
                Content = text, Margin = new Thickness(0, 0, 0, 0), Style = new Style()
            };

            Label actual;

            actual = InterfaceHelpers.CreateLabel(text, style);
            Assert.IsTrue(actual.Content == expected.Content && actual.Margin == expected.Margin);
        }
        public void CreateTextBlockTest()
        {
            string text  = "TestText";
            string style = string.Empty;

            TextBlock expected = new TextBlock {
                Text = text, Margin = new Thickness(0, 0, 0, 0), Style = new Style()
            };

            TextBlock actual;

            actual = InterfaceHelpers.CreateTextBlock(text, style);
            Assert.IsTrue(actual.Text == expected.Text && actual.Margin == expected.Margin);
        }
        public void CheckIfNavigationIsAllowedTest()
        {
            bool expected = true;
            bool actual;

            DBWorker.MetaData            = new MetaDataRepository();
            InterfaceHelpers.CurrentPage = PageList[6];

            foreach (String navigateToPage in PageList)
            {
                actual = InterfaceHelpers.CheckIfNavigationIsAllowed(navigateToPage);
                Assert.AreEqual(expected, actual);
            }
        }
        public void CheckIfNavigationIsAllowedTest3()
        {
            // [0] P1connection.xaml",
            // [1] P2metadata.xaml",
            // [2] P3dimensionselection.xaml",
            // [3] P4eventselection.xaml",
            // [4] P5configuration.xaml",
            // [5] P6mining.xaml",
            // [6] P8results.xaml"

            bool expected = true;
            bool actual;

            actual = InterfaceHelpers.CheckIfNavigationIsAllowed("StringThatIsNotInPageList");
            Assert.AreEqual(expected, actual);
        }
示例#20
0
        private void OnLoadItemsGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed)
                {
                    return;
                }

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

                _grid.ClearPage();

                var grouped = _mono.PowerManager.GetItemsWithin().ToList();

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

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

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

                    buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
                    uGUI_Icon icon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                    icon.sprite = SpriteManager.Get(grouped.ElementAt(i));
                }
                UpdateItemCount(grouped.Count(), _mono.PowerManager.MaxSlots);
                _grid.UpdaterPaginator(grouped.Count());
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }
        public void CreateSeparatorTest()
        {
            string name  = "TestName";
            string style = string.Empty;

            Separator expected = new Separator
            {
                Name   = name,
                Margin = new Thickness(10, 10, 10, 10),
                Style  = new Style()
            };

            Separator actual;

            actual = InterfaceHelpers.CreateSeparator(name, style);
            Assert.IsTrue(actual.Name == expected.Name && actual.Margin == expected.Margin);
        }
        public void CheckIfNavigationIsAllowedTest4()
        {
            // [0] P1connection.xaml",
            // [1] P2metadata.xaml",
            // [2] P3dimensionselection.xaml",
            // [3] P4eventselection.xaml",
            // [4] P5configuration.xaml",
            // [5] P6mining.xaml",
            // [6] P8results.xaml"

            bool expected = true;
            bool actual;

            InterfaceHelpers.CurrentPage = PageList[0];
            InterfaceHelpers.RestoreData = true;

            actual = InterfaceHelpers.CheckIfNavigationIsAllowed(PageList[6]);
            Assert.AreEqual(expected, actual);
        }
        public void CreateButtonTest()
        {
            string name  = "TestName";
            string text  = "TestText";
            string style = string.Empty;

            Button expected = new Button
            {
                Name    = name,
                Content = text,
                Margin  = new Thickness(0, 0, 0, 0),
                Style   = new Style()
            };

            Button actual;

            actual = InterfaceHelpers.CreateButton(name, text, style);
            Assert.IsTrue(actual.Name == expected.Name && actual.Content == expected.Content && actual.Margin == expected.Margin);
        }
        public void CreateTextBoxTest()
        {
            string name  = "TestName";
            string text  = "TestText";
            string style = string.Empty;

            TextBox expected = new TextBox
            {
                Name   = name,
                Text   = text,
                Margin = new Thickness(0, 0, 0, 0),
                Style  = new Style()
            };

            TextBox actual;

            actual = InterfaceHelpers.CreateTextBox(name, text, style);
            Assert.IsTrue(actual.Name == expected.Name && actual.Text == expected.Text && actual.Margin == expected.Margin);
        }
        private void OnLoadDisplay(DisplayData info)
        {
            _oxGrid.ClearPage();

            var grouped = _mono.TrackedDevices.ToList();

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

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

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

                    return;
                }

                buttonPrefab.transform.SetParent(info.ItemsGrid.transform, false);
                //buttonPrefab.GetComponentInChildren<Text>().text = grouped[i].Value.ToString();

                var mainButton = buttonPrefab.FindChild("PingBTN");
                var mainBTN    = mainButton.AddComponent <OxStationItemButton>();
                mainBTN.Tag             = grouped[i].Value;
                mainBTN.OxstationOxygen = InterfaceHelpers.FindGameObject(buttonPrefab, "Oxygen_Preloader_Bar_Front").GetComponent <Image>();
                mainBTN.OxstationHealth = InterfaceHelpers.FindGameObject(buttonPrefab, "Health_Preloader_Bar_Front").GetComponent <Image>();
                mainBTN.UpdateDisplay();
                mainBTN.ButtonMode     = InterfaceButtonMode.Background;
                mainBTN.STARTING_COLOR = _pingBTNStartColor;
                mainBTN.HOVER_COLOR    = _pingBTNHoverColor;
                mainBTN.OnButtonClick  = OnButtonClick;
                mainBTN.BtnName        = "PingBTN";
            }

            _oxGrid.UpdaterPaginator(grouped.Count);
        }
        private void CreateFoodItem(GameObject itemPrefab, GameObject itemsGrid, int stPos, int endPos, List <EatableEntities> list, GridHelper page, EatableType eatableType)
        {
            var grouped = list.GroupBy(x => x.TechType).Select(x => x.First()).ToList();

            if (endPos > grouped.Count)
            {
                endPos = grouped.Count;
            }

            for (int i = stPos; i < endPos; i++)
            {
                var techType = grouped[i].TechType;

                GameObject foodIcon = Instantiate(itemPrefab);

                if (foodIcon == null || itemsGrid == null)
                {
                    if (foodIcon != null)
                    {
                        Destroy(foodIcon);
                    }
                    return;
                }

                foodIcon.transform.SetParent(itemsGrid.transform, false);

                foodIcon.GetComponentInChildren <Text>().text = "x" + list.Count(x => x.TechType == techType);

                var itemButton = foodIcon.AddComponent <ItemButton>();
                itemButton.Type          = techType;
                itemButton.EatableType   = eatableType;
                itemButton.OnButtonClick = _mono.FridgeComponent.RemoveItem;

                uGUI_Icon icon = InterfaceHelpers.FindGameObject(foodIcon, "ItemImage").AddComponent <uGUI_Icon>();
                icon.sprite = SpriteManager.Get(techType);
            }

            page.UpdaterPaginator(grouped.Count);
        }
        void IContent.OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            if (InterfaceHelpers.CheckIfNavigationIsAllowed(e.Source.OriginalString) == false)
            {
                e.Cancel = true;
            }

            if (_isMinerRunning)
            {
                MessageBoxResult doNavigateAway =
                    ModernDialog.ShowMessage("Changing the view will cancel the mining-process. Continue?", "navigate",
                                             MessageBoxButton.YesNo);
                if (doNavigateAway == MessageBoxResult.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (_cancellationTokenSource != null)
            {
                _cancellationTokenSource.Cancel();
            }

            Cursor                 = Cursors.Arrow;
            _isMinerRunning        = false;
            ProgressBar.Visibility = Visibility.Hidden;

            StartCalculationButton.IsEnabled  = true;
            CancelCalculationButton.IsEnabled = false;
            MiningInfo.BBCode = "Click 'Start' to start mining " +
                                MainWindow.MatrixSelection.GetFields().Count +
                                " Fields using the " +
                                MinerSettings.MinerName + ".";

            InterfaceHelpers.MiningIsCompleted = false;
        }
示例#28
0
        public override bool FindAllComponents()
        {
            try
            {
                #region Canvas
                var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject;

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

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

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

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

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

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

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

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

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

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

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

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

                #region ScreenColorPicker

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

                #endregion

                #region AntennnaColorPicker

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

                #endregion

                #region Base Grid

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

                #endregion

                #region Vehicle Grid

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

                #endregion

                #region Vehicle Containers Grid

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

                #endregion

                #region Item Grid

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

                #endregion

                #region Category Grid

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

                #endregion

                #region Base Items Page

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                #region Toggle

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

                #endregion

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

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

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

                #endregion

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

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

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

                #region BaseItemDecription

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

                #endregion

                #region BaseName

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

                #endregion

                #region BaseItemsLoading

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

                #endregion

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

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



                return(true);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                QuickLogger.Error(e.StackTrace);
                return(false);
            }
        }
示例#29
0
        private void OnLoadBaseItemsGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed)
                {
                    return;
                }

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

                _baseItemsGrid.ClearPage();

                if (_currentBase == null)
                {
                    return;
                }

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

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

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


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

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

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

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

                    uGUI_Icon trashIcon = InterfaceHelpers.FindGameObject(buttonPrefab, "Icon").AddComponent <uGUI_Icon>();
                    trashIcon.sprite = SpriteManager.Get(grouped.ElementAt(i).Key);
                }
                _counter.text = _currentBase.GetTotalString();
                _baseItemsGrid.UpdaterPaginator(grouped.Count());
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }
示例#30
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);
        }