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 DigitEntryMenu(string message, behaviorOnNumberSelect behaviorOnSelection, int price = -1, int minValue = 0, int maxValue = 99, int defaultNumber = 0) : base(message, behaviorOnSelection, price, minValue, maxValue, defaultNumber) { Game1.dialogueFont.MeasureString(message); _ = IClickableMenu.borderWidth; int buttonsPerRow = 3; int buttonWidth = 44; int buttonHeight = buttonWidth; int bufferX = 8; int bufferY = bufferX; int rowWidth = buttonsPerRow * buttonWidth + (buttonsPerRow - 1) * bufferX; calculatorWidth = buttonWidth * buttonsPerRow + bufferX * (buttonsPerRow - 1) + IClickableMenu.spaceToClearSideBorder * 2 + 128; calculatorHeight = buttonHeight * 4 + bufferY * 3 + IClickableMenu.spaceToClearTopBorder * 2; calculatorX = Game1.viewport.Width / 2 - calculatorWidth / 2; calculatorY = Game1.viewport.Height / 2 - calculatorHeight; int buttonX = Game1.viewport.Width / 2; int buttonY = Game1.viewport.Height / 2 - 384 + 24 + IClickableMenu.spaceToClearTopBorder; for (int i = 0; i < 11; i++) { string digit = (i + 1).ToString(); switch (i) { case 9: digit = clear; break; case 10: digit = "0"; break; } digits.Add(new ClickableComponent(new Rectangle(buttonX - rowWidth / 2 + i % buttonsPerRow * (bufferX + buttonWidth), buttonY + i / buttonsPerRow * (bufferY + buttonHeight), buttonWidth, buttonHeight), digit) { myID = i, rightNeighborID = -99998, leftNeighborID = -99998, downNeighborID = -99998, upNeighborID = -99998 }); } populateClickableComponentList(); }