void ReInitializePresetsBrowser() { SavePresets(); colorPages = new List <ColorPage>(); savedPresets = PlayerPrefsX.GetColorArray(COLOR_PRESETS_KEY); if (savedPresets == null || savedPresets.Length == 0) { savedPresets = defaultColors; } int pagesCount = Mathf.CeilToInt((float)savedPresets.Length / (float)presetsDisplay.Length); int presetIndex = 0; int remainingPresetsCount = savedPresets.Length; for (int i = 0; i < pagesCount; i++) { var cp = new ColorPage() { ContainsSelectedColor = false, PageColors = new List <Color>() }; int j = 0; while (presetIndex < savedPresets.Length && j < presetsDisplay.Length) { cp.PageColors.Add(savedPresets[presetIndex]); presetIndex++; j++; } colorPages.Add(cp); } }
public void AddNewColor(Color newColor) { newColor.a = 1; var lastPageIndex = colorPages.Count - 1; var lastPage = colorPages.ElementAt(lastPageIndex); if (lastPage.PageColors.Count < presetsDisplay.Length) { lastPage.PageColors.Add(newColor); lastPage.SelectedColorIndexInPage = lastPage.PageColors.Count - 1; lastPage.ContainsSelectedColor = true; DisplayPage(lastPageIndex); nextPageButton.EnableButton(NextPageAvailable); previousPageButton.EnableButton(PreviousPageAvailable); } else { var cp = new ColorPage() { ContainsSelectedColor = true, PageColors = new List <Color>(), SelectedColorIndexInPage = 0 }; cp.PageColors.Add(newColor); colorPages.Add(cp); DisplayPage(colorPages.Count - 1); if (!previousPageButton.ButtonEnabled) { previousPageButton.EnableButton(true); } if (nextPageButton.ButtonEnabled) { nextPageButton.EnableButton(false); } } SelectedPresetColor = newColor; SavePresets(); }
public override void OnButtonClick(string btnName, object tag) { if (btnName == string.Empty) { return; } switch (btnName) { case "BaseBTN": if (!SubrootCheck()) { return; } _currentBase = ((TransferData)tag).Manager; _currentData = (TransferData)tag; _baseNameLabel.text = _currentBase.GetBaseName(); if (_currentData.ButtonType == ButtonType.Home) { GoToPage(TerminalPages.BaseItemsDirect); } else if (_currentData.ButtonType == ButtonType.Base) { _gettingData.text = string.Format(AuxPatchers.GettingData(), _currentBase.GetBaseName()); GoToPage(TerminalPages.BaseItems); } Refresh(); break; case "HomeBTN": GoToPage(TerminalPages.Home); break; case "ItemBTN": _currentBase?.RemoveItemFromContainer((TechType)tag); break; case "DumpBTN": _currentBase?.OpenDump(_currentData); break; case "VehicleDumpBTN": _vehicleContainersGrid.DrawPage(); GoToPage(TerminalPages.StorageContainer); break; case "VehicleContainerBTN": _mono.Manager.DockingManager.OpenContainer(_currentVehicle, ((TransferData)tag).Container); break; case "TerminalColorBTN": GoToPage(TerminalPages.TerminalColorPage); _currentColorPage = ColorPage.Terminal; break; case "AntennaColorBTN": var antennas = _mono.Manager.GetCurrentBaseAntenna(); if (antennas != null) { GoToPage(TerminalPages.AntennaColorPage); _currentColorPage = ColorPage.Antenna; UpdateAntennaColorPage(); } else if (_mono.Manager.Habitat.isBase) { QuickLogger.Message(AuxPatchers.NoAntennaOnBase(), true); } else if (_mono.Manager.Habitat.isCyclops) { QuickLogger.Message(AuxPatchers.CannotChangeCyclopsAntenna(), true); } break; case "ColorPickerBTN": GoToPage(TerminalPages.ColorPageMain); break; case "ColorItem": if (_currentColorPage == ColorPage.Terminal) { _mono.TerminalColorManager.ChangeColorMask((Color)tag); } else { ChangeAntennaColor((Color)tag); } break; case "RenameBTN": _mono.Manager.ChangeBaseName(); break; case "PowerBTN": _mono.Manager.ToggleBreaker(); break; case "SettingsBTN": GoToPage(TerminalPages.SettingsPage); break; case "VehiclesPageBTN": if (_mono.Manager.DockingManager.HasVehicles(true)) { _vehicleGrid.DrawPage(); GoToPage(TerminalPages.VehiclesPage); } else { GoToPage(TerminalPages.Home); } break; case "VehicleBTN": _currentVehicle = ((TransferData)tag).Vehicle; _vehicleContainersGrid.DrawPage(); GoToPage(TerminalPages.StorageContainer); break; case "AutoDockBTN": _toggle.isOn = _mono.Manager.DockingManager.GetToggleState(); GoToPage(TerminalPages.DockSettingPage); break; case "FilterBTN": var data = (FilterTransferData)tag; if (Mod.IsFilterAdded(data.Filter)) { Mod.RemoveBlackListFilter(data.Filter); return; } Mod.AddBlackListFilter(data.Filter); break; } }