Esempio 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);
        }
Esempio n. 2
0
        /// <summary>Constructs an instance.</summary>
        /// <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)
        {
            Log.TraceIfD($"[{nameof(StackSplitMenu)}] Instantiated with textSubmittedCallback = {textSubmittedCallback}, heldStackAmount = {heldStackAmount}");
            Log.TraceIfD($"[{nameof(StackSplitMenu)}] GUID = {GUID}");

            this.OnTextSubmitted = textSubmittedCallback;
            this.HeldStackAmount = heldStackAmount;

            var inputBox = this.InputTextBox = new InputTextBox(CHAR_LIMIT, heldStackAmount.ToString())
            {
                Position    = new Vector2(Game1.getMouseX(), Game1.getMouseY() - Game1.tileSize),
                Extent      = new Vector2(Game1.tileSize * 2, Game1.tileSize),
                NumbersOnly = true,
                Selected    = true,
            };

            inputBox.OnSubmit += (sender) => Submit(sender.Text);
            Game1.keyboardDispatcher.Subscriber = inputBox;

            this.OKButton = new ClickableTextureComponent(
                new Rectangle(
                    (int)inputBox.Position.X + (int)inputBox.Extent.X + Game1.pixelZoom, // pixelzoom used to give gap
                    (int)inputBox.Position.Y,
                    Game1.tileSize,
                    Game1.tileSize
                    ),
                Game1.mouseCursors,
                Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1),
                1f,
                false);
        }