// Constructors:
        #region Constructors

        public ChestConfigPanel(CustomItemGrabMenu hostMenu)
            : base(GlobalVars.gUIViewport, Colours.gTransparent)
        {
            var       menu_colour  = Colours.GenerateFromMenuTiles();
            var       player_chest = hostMenu.GetSourceAs <Chest>();
            Rectangle player_menu_content_bounds = hostMenu.inventory.GetBounds();

            this.colouringChest = new ExtendedChest(new Rectangle(player_menu_content_bounds.X - 24 - 64, player_menu_content_bounds.Center.Y - 32, 64, 64),
                                                    player_chest.GetCustomConfigHingesColour(),
                                                    hostMenu.mSourceType);
            this.colouringChest.playerChoiceColor.Value = player_chest.playerChoiceColor.Value;

            this.colouringModeSwitcher = new ColouringMenuSwitcher(new Rectangle(player_menu_content_bounds.X - 8,
                                                                                 player_menu_content_bounds.Y - 8,
                                                                                 48,
                                                                                 player_menu_content_bounds.Height + 16),
                                                                   menu_colour * 0.75f,
                                                                   this.switchColouringMode);
            this.colouringModeSwitcher.AddSwitcher(CONST_MODE_HSV_CHEST, menu_colour, TexturePresets.gChestColouringModeTexture, "Chest colour");
            this.colouringModeSwitcher.AddSwitcher(CONST_MODE_HSV_HINGES, menu_colour, TexturePresets.gChestHingesColouringModeTexture, "Chest hinges colour");
            this.colouringModeSwitcher.AddSwitcher(CONST_MODE_RESET, menu_colour, "R", "Reset colours");
            this.colouringModeSwitcher.AddSwitcher(CONST_MODE_HEX, menu_colour, "#", "Chest colours (HEX)");

            this.colouringHEXMenu = new ColouringHEXMenu(new Rectangle(this.colouringModeSwitcher.mBounds.GetTextureBoxRectangle().Right - 8,
                                                                       player_menu_content_bounds.Y - 8,
                                                                       player_menu_content_bounds.Width / 4,
                                                                       player_menu_content_bounds.Height + 16),
                                                         menu_colour * 0.75f,
                                                         this.onHEXFinalColour);
            this.colouringHEXMenu.SetVisible(false);

            this.colouringHSVMenu = new ColouringHSVMenu(new Rectangle(this.colouringModeSwitcher.mBounds.GetTextureBoxRectangle().Right - 8,
                                                                       player_menu_content_bounds.Y - 8,
                                                                       player_menu_content_bounds.Width / 4,
                                                                       player_menu_content_bounds.Height + 16),
                                                         menu_colour * 0.75f,
                                                         player_chest.playerChoiceColor.Value,
                                                         this.onHSVTryColour,
                                                         this.onHSVFinalColour);
            var chest_settings = new ChestSettings(new Rectangle(this.colouringHSVMenu.mBounds.GetTextureBoxRectangle().Right - 12,
                                                                 player_menu_content_bounds.Y + 14,
                                                                 player_menu_content_bounds.Width - this.colouringHSVMenu.mBounds.Width - this.colouringModeSwitcher.mBounds.Width,
                                                                 player_menu_content_bounds.Height - 28),
                                                   menu_colour,
                                                   player_chest);

            this.hostMenu = hostMenu;
            this.mComponents.AddRange(new ICustomComponent[] { chest_settings, this.colouringHEXMenu, this.colouringHSVMenu, this.colouringModeSwitcher });
        }
Example #2
0
        private static void OnMenuChanged(object sender, MenuChangedEventArgs e)
        {
            ModMonitor.VerboseLog("New menu: " + e.NewMenu?.GetType());
            if (e.NewMenu is CustomItemGrabMenu customItemGrabMenu)
            {
                ActiveItemGrabMenu = customItemGrabMenu;
                return;
            }

            if (!(e.NewMenu is ItemGrabMenu itemGrabMenu) || !(itemGrabMenu.context is CustomChest customChest))
            {
                return;
            }

            ActiveItemGrabMenu        = customChest.CreateItemGrabMenu();
            Game1.activeClickableMenu = ActiveItemGrabMenu;
        }