public void UpdateMenusBackground() { buttons.Clear(); foreach (var bg in ConstantValues.Background.Skip(2)) { Texture2D iconTexture = new Texture2D(1, 1); iconTexture.SetPixel(0, 0, new Color32(1, 1, 1, 1)); iconTexture.Apply(); CustomTextureButton button = new CustomTextureButton(iconTexture); string modelName = String.Copy(bg.Key); button.Text = modelName; MenuInfo menuCopy = MenuInfo.MakeBackgroundMenu(bg.Value); button.Click += (o, e) => func(menuCopy); buttons.Add(button); } }
public void UpdateMenusBGObject() { buttons.Clear(); if (PhotoBGObjectData.data == null) { PhotoBGObjectData.Create(); } foreach (PhotoBGObjectData data in PhotoBGObjectData.data) { Texture2D iconTexture = new Texture2D(1, 1); iconTexture.SetPixel(0, 0, new Color32(1, 1, 1, 1)); iconTexture.Apply(); CustomTextureButton button = new CustomTextureButton(iconTexture); string modelName = String.Copy(data.name); button.Text = modelName; MenuInfo menuCopy = MenuInfo.MakeBGObjectMenu(data); button.Click += (o, e) => func(menuCopy); buttons.Add(button); } }
public void UpdateMenus(MPN category) { buttons.Clear(); List <MenuInfo> existing; if (!Menus.TryGetValue(category, out existing)) { return; } foreach (MenuInfo menu in existing) { try{ if (menu != null) { if (menu.delOnly) { continue; } if (menu.partCategory == category) { Texture2D iconTexture = AssetLoader.LoadTexture(menu.iconTextureName); if (iconTexture == null) { iconTexture = new Texture2D(1, 1); iconTexture.SetPixel(0, 0, new Color32(1, 1, 1, 1)); iconTexture.Apply(); } CustomTextureButton button = new CustomTextureButton(iconTexture); if (menu.modelName == null) { continue; } string modelName = String.Copy(menu.modelName); button.Text = modelName; string modelIconName; if (menu.iconTextureName != null) { modelIconName = String.Copy(menu.iconTextureName); } else { modelIconName = ""; } MenuInfo menuCopy = new MenuInfo(menu); button.Click += (o, e) => func(menuCopy); buttons.Add(button); } } else { Debug.LogError("Null MenuInfo"); } } catch { // Debug.LogError( e ); } } }
// Protected: #region Protected // Overrides: #region Overrides protected override void CreateOrganizationButtons(Boolean createChestColorPicker, Boolean createOrganizeButton, Boolean createFillStacksButton) { this.mComponents.Clear(); Rectangle source_menu_bounds = this.mSourceInventoryOptions.mDialogueBoxBounds; Rectangle player_menu_bounds = this.mPlayerInventoryOptions.mDialogueBoxBounds; if (createChestColorPicker && this.mSourceType != ExtendedChest.ChestType.Fridge) { this.configPanel = new ChestConfigPanel(this); this.configPanel.SetVisible(false); this.configButton = new CustomTextureButton(new Rectangle(source_menu_bounds.Right + 16, source_menu_bounds.Top + 16, 64, 64), Colours.gTurnTranslucentOnAction, TexturePresets.gConfigButtonTexture, "Open configuration panel", () => this.configPanel.SetVisible(!this.configPanel.mIsVisible)) { myID = region_colorPickToggle, upNeighborID = this.colorPickerToggleButton?.myID ?? -500, downNeighborID = region_organizeButton, leftNeighborID = ClickableComponent.SNAP_AUTOMATIC, region = region_organizationButtons }; } if (createFillStacksButton) { this.fillStacksButton = new CustomClickableTextureComponent(new Rectangle(source_menu_bounds.Right + 16, this.configButton?.mBounds.Bottom + 16 ?? source_menu_bounds.Top + 16, 64, 64), Colours.gTurnTranslucentOnAction, TexturePresets.gFillStacksPickerButtonTexture, Game1.content.LoadString("Strings\\UI:ItemGrab_FillStacks")) { myID = region_fillStacksButton, upNeighborID = this.configButton?.myID ?? -500, downNeighborID = region_organizeButton, leftNeighborID = ClickableComponent.SNAP_AUTOMATIC, region = region_organizationButtons }; } if (createOrganizeButton) { this.organizeButton = new CustomClickableTextureComponent(new Rectangle(source_menu_bounds.Right + 16, this.fillStacksButton?.bounds.Bottom + 16 ?? source_menu_bounds.Top + 16, 64, 64), Colours.gTurnTranslucentOnAction, TexturePresets.gOrganizeButtonTexture, Game1.content.LoadString("Strings\\UI:ItemGrab_Organize")) { myID = region_organizeButton, upNeighborID = region_fillStacksButton, downNeighborID = region_trashCan, leftNeighborID = ClickableComponent.SNAP_AUTOMATIC, region = region_organizationButtons }; } if (this.dropItemInvisibleButton is not null) { this.dropItemInvisibleButton.bounds = new Rectangle(this.mSourceInventoryOptions.mDialogueBoxBounds.Right, this.mSourceInventoryOptions.mDialogueBoxBounds.Top, GlobalVars.gUIViewport.Width - this.mSourceInventoryOptions.mDialogueBoxBounds.Right, this.mPlayerInventoryOptions.mDialogueBoxBounds.Bottom); } if (this.trashCan is not null) { this.trashCan.bounds = new Rectangle(this.mPlayerInventoryOptions.mDialogueBoxBounds.Right + 24, this.mPlayerInventoryOptions.mDialogueBoxBounds.Top + 32, this.trashCan.bounds.Width, this.trashCan.bounds.Height); } this.okButton = new CustomClickableTextureComponent(new Rectangle(player_menu_bounds.Right + 24, this.trashCan?.bounds.Bottom + 16 ?? this.mPlayerInventoryOptions.mDialogueBoxBounds.Top + 32, 64, 64), Colours.gTurnTranslucentOnAction, TexturePresets.gOKButtonTexture) { myID = region_okButton, upNeighborID = region_trashCan, leftNeighborID = 11 }; for (Int32 i = 0; i < this.inventory.inventory.Count; i += 11) { if (this.inventory.inventory[i] is ClickableComponent cc) { cc.rightNeighborID = this.okButton.myID; } } this.mComponents.AddRange(new ICustomComponent[] { this.configPanel, this.newOKButton, this.newOrganizeButton, this.newFillStacksButton, this.configButton } .Where(c => c is not null)); }