예제 #1
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);
        }
예제 #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.
     Game1.keyboardDispatcher.Subscriber = null;
     // Cleanup
     this.InputTextBox = null;
     this.OKButton     = null;
 }