Exemple #1
0
        private void OnItemSlotRendered(object sender, ItemSlotRenderedEventArgs e)
        {
            //  Draw a toggle to enable/disable autofilling this item
            if (BoundedBag.Autofill && (e.IsHovered || IBM.IsHoveringAutofillButton))
            {
                Rectangle AutofillDestination;
                float     Transparency;
                if (IBM.IsHoveringAutofillButton)
                {
                    double PercentSize = 0.75;
                    int    Width       = (int)(e.Slot.Width * PercentSize);
                    int    Height      = (int)(e.Slot.Height * PercentSize);

                    AutofillDestination = new Rectangle(e.Slot.Center.X - Width / 2, e.Slot.Center.Y - Height / 2, Width, Height);
                    Transparency        = 1.0f;
                }
                else
                {
                    AutofillDestination = GetAutofillToggleDrawPosition(e.Slot);
                    Transparency        = GetAutofillToggleClickableRegion(e.Slot).Contains(CurrentMousePosition) ? 1.0f : 0.75f;
                }

                Rectangle HandIconSourceRect = new Rectangle(32, 0, 10, 10);
                int       HandIconSize       = (int)(HandIconSourceRect.Width * 2.0 / 32.0 * AutofillDestination.Width);
                //b.Draw(Game1.menuTexture, AutofillDestination, new Rectangle(128, 128, 64, 64), Color.White);
                e.SB.Draw(Game1.mouseCursors, new Rectangle(AutofillDestination.X + (AutofillDestination.Width - HandIconSize) / 2, AutofillDestination.Y + (AutofillDestination.Height - HandIconSize) / 2, HandIconSize, HandIconSize), HandIconSourceRect, Color.White * Transparency);

                if (!BoundedBag.CanAutofillWithItem(e.Item))
                {
                    Rectangle DisabledIconSourceRect  = new Rectangle(322, 498, 12, 12);
                    int       DisabledIconSize        = (int)(DisabledIconSourceRect.Width * 1.5 / 32.0 * AutofillDestination.Width);
                    Rectangle DisabledIconDestination = new Rectangle(AutofillDestination.Right - DisabledIconSize - 2, AutofillDestination.Bottom - DisabledIconSize - 2, DisabledIconSize, DisabledIconSize);
                    e.SB.Draw(Game1.mouseCursors, DisabledIconDestination, DisabledIconSourceRect, Color.White * Transparency);
                }
            }
        }