Exemplo n.º 1
0
        /// <summary>Constructs an instance.</summary>
        /// <param name="inputHelper">The SMAPI input helper.</param>
        /// <param name="textSubmittedCallback">The callback for when the text is submitted.</param>
        /// <param name="heldStackAmount">The default stack amount to set the text to.</param>
        public StackSplitMenu(TextSubmittedDelegate textSubmittedCallback, int heldStackAmount, IInputHelper inputHelper)
        {
            this.OnTextSubmitted = textSubmittedCallback;
            this.HeldStackAmount = heldStackAmount;

            // Character limit of 4 since max stack size of anything (afaik is 999).
            this.InputTextBox = new InputTextBox(inputHelper, 4, heldStackAmount.ToString())
            {
                Position    = new Vector2(Game1.getMouseX(), Game1.getMouseY() - Game1.tileSize),
                Extent      = new Vector2(Game1.tileSize * 2, Game1.tileSize),
                NumbersOnly = true,
                Selected    = true,
            };
            this.InputTextBox.OnSubmit         += (sender) => Submit(sender.Text);
            Game1.keyboardDispatcher.Subscriber = this.InputTextBox;

            // TODO: clean up
            this.OKButton = new ClickableTextureComponent(
                new Rectangle((int)this.InputTextBox.Position.X + (int)this.InputTextBox.Extent.X + Game1.pixelZoom,
                              (int)this.InputTextBox.Position.Y,
                              Game1.tileSize,
                              Game1.tileSize),
                Game1.mouseCursors,
                Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1),
                1f,
                false);
        }
Exemplo n.º 2
0
 /// <summary>Closes the split menu so it stops receiving input.</summary>
 public void Close()
 {
     // Remove from the subscriber so it stops getting input.
     this.InputTextBox = null;
     Game1.keyboardDispatcher.Subscriber = null;
 }