public NewAnimalQueryMenu(CustomFarmAnimal animal) : base(Game1.viewport.Width / 2 - width / 2, Game1.viewport.Height / 2 - height / 2, width, height, false) { Game1.player.Halt(); Game1.player.faceGeneralDirection(animal.position, 0); NewAnimalQueryMenu.width = Game1.tileSize * 6; NewAnimalQueryMenu.height = Game1.tileSize * 8; this.animal = animal; this.textBox = new TextBox(null, null, Game1.dialogueFont, Game1.textColor); this.textBox.X = Game1.viewport.Width / 2 - Game1.tileSize * 2 - 12; this.textBox.Y = this.yPositionOnScreen - 4 + Game1.tileSize * 2; this.textBox.Width = Game1.tileSize * 4; this.textBox.Height = Game1.tileSize * 3; this.textBoxCC = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X, this.textBox.Y, this.textBox.Width, Game1.tileSize), "") { myID = 110, downNeighborID = 104 }; this.textBox.Text = animal.displayName; Game1.keyboardDispatcher.Subscriber = this.textBox; this.textBox.Selected = false; if (animal.parentId != -1L) { FarmAnimal farmAnimal = Utility.getAnimal(animal.parentId); if (farmAnimal != null) { this.parentName = farmAnimal.displayName; } } if (animal.sound != null && Game1.soundBank != null) { Cue expr_1B2 = Game1.soundBank.GetCue(animal.sound); expr_1B2.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201))); expr_1B2.Play(); } this.okButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false) { myID = 101, upNeighborID = 103 }; this.sellButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(0, 384, 16, 16), 4f, false) { myID = 103, downNeighborID = 101, upNeighborID = 104 }; this.moveHomeButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 4 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(16, 384, 16, 16), 4f, false) { myID = 104, downNeighborID = 103, upNeighborID = 110 }; if (!animal.isBaby() && !animal.isCoopDweller()) { allowReproductionButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + width + Game1.pixelZoom * 4, yPositionOnScreen + height - Game1.tileSize * 2 - borderWidth + Game1.pixelZoom * 2, Game1.pixelZoom * 9, Game1.pixelZoom * 9), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(animal.allowReproduction ? 128 : 137, 393, 9, 9), 4f, false) { myID = 106 }; } this.love = new ClickableTextureComponent(Math.Round((double)animal.friendshipTowardFarmer, 0) / 10.0 + "<", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + Game1.tileSize / 2 + 16, this.yPositionOnScreen - Game1.tileSize / 2 + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 2, AnimalQueryMenu.width - Game1.tileSize * 2, Game1.tileSize), null, "Friendship", Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(172, 512, 16, 16), 4f, false) { myID = 102 }; this.loveHover = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 3 - Game1.tileSize / 2, AnimalQueryMenu.width, Game1.tileSize), "Friendship") { myID = 109 }; this.fullnessLevel = (double)((float)animal.fullness / 255f); if (animal.home != null && animal.home.indoors != null) { int num = animal.home.indoors.numberOfObjectsWithName("Hay"); if (num > 0) { int count = (animal.home.indoors as AnimalHouse).animalsThatLiveHere.Count; this.fullnessLevel = Math.Min(1.0, this.fullnessLevel + (double)num / (double)count); } } else { Utility.fixAllAnimals(); } this.happinessLevel = (double)((float)animal.happiness / 255f); this.loveLevel = (double)((float)animal.friendshipTowardFarmer / 1000f); if (Game1.options.SnappyMenus) { base.populateClickableComponentList(); this.snapToDefaultClickableComponent(); } }
public override void receiveLeftClick(int x, int y, bool playSound = true) { if (Game1.globalFade || this.freeze) { return; } if (this.okButton != null && this.okButton.containsPoint(x, y) && this.readyToClose()) { if (this.onFarm) { Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForReturnToShopMenu), 0.02f); Game1.playSound("smallSelect"); } else { Game1.exitActiveMenu(); Game1.playSound("bigDeSelect"); } } if (this.onFarm) { Vector2 tile = new Vector2((float)((x + Game1.viewport.X) / Game1.tileSize), (float)((y + Game1.viewport.Y) / Game1.tileSize)); Building buildingAt = (Game1.getLocationFromName("Farm") as Farm).getBuildingAt(tile); if (buildingAt != null && !this.namingAnimal) { if (buildingAt.buildingType.Contains(this.animalBeingPurchased.buildingTypeILiveIn)) { if ((buildingAt.indoors as AnimalHouse).isFull()) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11321", new object[0])); } else if (this.animalBeingPurchased.harvestType != 2) { this.namingAnimal = true; this.newAnimalHome = buildingAt; if (this.animalBeingPurchased.sound != null && Game1.soundBank != null) { Cue expr_15B = Game1.soundBank.GetCue(this.animalBeingPurchased.sound); expr_15B.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201))); expr_15B.Play(); } this.textBox.OnEnterPressed += this.e; this.textBox.Text = this.animalBeingPurchased.displayName; Game1.keyboardDispatcher.Subscriber = this.textBox; if (Game1.options.SnappyMenus) { this.currentlySnappedComponent = base.getComponentWithID(104); this.snapCursorToCurrentSnappedComponent(); } } else if (Game1.player.money >= this.priceOfAnimal) { this.newAnimalHome = buildingAt; this.animalBeingPurchased.home = this.newAnimalHome; this.animalBeingPurchased.homeLocation = new Vector2((float)this.newAnimalHome.tileX, (float)this.newAnimalHome.tileY); this.animalBeingPurchased.setRandomPosition(this.animalBeingPurchased.home.indoors); (this.newAnimalHome.indoors as NewAnimalHouse).animals.Add(animalBeingPurchased.myId, animalBeingPurchased); (this.newAnimalHome.indoors as NewAnimalHouse).animalsThatLiveHere.Add(this.animalBeingPurchased.myId); this.newAnimalHome = null; this.namingAnimal = false; if (this.animalBeingPurchased.sound != null && Game1.soundBank != null) { Cue expr_2DC = Game1.soundBank.GetCue(this.animalBeingPurchased.sound); expr_2DC.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201))); expr_2DC.Play(); } Game1.player.money -= this.priceOfAnimal; Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11324", new object[] { this.animalBeingPurchased.displayType }), Color.LimeGreen, 3500f)); this.animalBeingPurchased = new CustomFarmAnimal(this.animalBeingPurchased.type, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID); } else if (Game1.player.money < this.priceOfAnimal) { Game1.dayTimeMoneyBox.moneyShakeTimer = 1000; } } else { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11326", new object[] { this.animalBeingPurchased.displayType })); } } if (this.namingAnimal) { if (this.doneNamingButton.containsPoint(x, y)) { this.textBoxEnter(this.textBox); Game1.playSound("smallSelect"); } else if (this.namingAnimal && this.randomButton.containsPoint(x, y)) { this.animalBeingPurchased.name = Dialogue.randomName(); this.animalBeingPurchased.displayName = this.animalBeingPurchased.name; this.textBox.Text = this.animalBeingPurchased.displayName; this.randomButton.scale = this.randomButton.baseScale; Game1.playSound("drumkit6"); } this.textBox.Update(); return; } } else { foreach (ClickableTextureComponent current in this.animalsToPurchase) { if (current.containsPoint(x, y) && (current.item as StardewValley.Object).type == null) { int num = current.item.salePrice(); if (Game1.player.money >= num) { Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForAnimalPlacement), 0.02f); Game1.playSound("smallSelect"); this.onFarm = true; this.animalBeingPurchased = new CustomFarmAnimal(current.hoverText, MultiplayerUtility.getNewID(), Game1.player.uniqueMultiplayerID); this.priceOfAnimal = num; } else { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11325", new object[0]), Color.Red, 3500f)); } } } } }