public NumberSelectionMenu(string message, behaviorOnNumberSelect behaviorOnSelection, int price = -1, int minValue = 0, int maxValue = 99, int defaultNumber = 0) { Vector2 vector = Game1.dialogueFont.MeasureString(message); int menuWidth = Math.Max((int)vector.X, 600) + IClickableMenu.borderWidth * 2; int menuHeight = (int)vector.Y + IClickableMenu.borderWidth * 2 + 160; int menuX = (int)centerPosition.X - menuWidth / 2; int menuY = (int)centerPosition.Y - menuHeight / 2; initialize(menuX, menuY, menuWidth, menuHeight); this.message = message; this.price = price; this.minValue = minValue; this.maxValue = maxValue; currentValue = defaultNumber; behaviorFunction = behaviorOnSelection; numberSelectedBox = new TextBox(Game1.content.Load <Texture2D>("LooseSprites\\textBox"), null, Game1.smallFont, Game1.textColor) { X = xPositionOnScreen + IClickableMenu.borderWidth + 56, Y = yPositionOnScreen + IClickableMenu.borderWidth + height / 2, Text = string.Concat(currentValue), numbersOnly = true, textLimit = string.Concat(maxValue).Length }; numberSelectedBox.SelectMe(); leftButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + IClickableMenu.borderWidth, yPositionOnScreen + IClickableMenu.borderWidth + height / 2, 48, 44), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f) { myID = 101, rightNeighborID = 102, upNeighborID = -99998 }; rightButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + IClickableMenu.borderWidth + 64 + numberSelectedBox.Width, yPositionOnScreen + IClickableMenu.borderWidth + height / 2, 48, 44), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f) { myID = 102, leftNeighborID = 101, rightNeighborID = 103, upNeighborID = -99998 }; okButton = new ClickableTextureComponent("OK", new Rectangle(xPositionOnScreen + width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 128, yPositionOnScreen + height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + 21, 64, 64), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f) { myID = 103, leftNeighborID = 102, rightNeighborID = 104, upNeighborID = -99998 }; cancelButton = new ClickableTextureComponent("OK", new Rectangle(xPositionOnScreen + width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 64, yPositionOnScreen + height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + 21, 64, 64), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47), 1f) { myID = 104, leftNeighborID = 103, upNeighborID = -99998 }; if (Game1.options.SnappyMenus) { populateClickableComponentList(); snapToDefaultClickableComponent(); } }
public override void receiveLeftClick(int x, int y) { textBox.SelectMe(); textBox.Update(); }