private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e) { // Ignore if player hasn't loaded a save yet if (!Context.IsWorldReady || Game1.activeClickableMenu == null) { return; } // Stop triggering the heavy redraws if (this.ChangedPurchaseAnimalsMenuClickableComponents) { return; } if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.PurchaseAnimalsMenu)) { if (!(Game1.activeClickableMenu is StardewValley.Menus.PurchaseAnimalsMenu)) { return; } StardewValley.Menus.PurchaseAnimalsMenu purchaseAnimalsMenu = Game1.activeClickableMenu as StardewValley.Menus.PurchaseAnimalsMenu; // We need to completely redo the animalsToPurchase to account for the custom sprites Dictionary <string, Texture2D> textures = new Dictionary <string, Texture2D>(); int iconHeight = 0; foreach (KeyValuePair <string, ConfigFarmAnimal> entry in this.Config.FarmAnimals) { if (entry.Value.CanBePurchased()) { Texture2D texture = this.Helper.Content.Load <Texture2D>(entry.Value.AnimalShop.Icon, ContentSource.ModFolder); iconHeight = texture.Height; textures.Add(entry.Value.Category, texture); } } Player player = new Player(Game1.player, this.Helper); AnimalShop animalShop = this.GetAnimalShop(player); purchaseAnimalsMenu.animalsToPurchase = animalShop.FarmAnimalStock.DetermineClickableComponents(purchaseAnimalsMenu, textures); int rows = (int)Math.Ceiling((float)purchaseAnimalsMenu.animalsToPurchase.Count / 3); // Always at least one row // Adjust the size of the menud if there are more or less rows than it normally handles if (iconHeight > 0) { purchaseAnimalsMenu.height = (int)(iconHeight * 2f) + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth / 2 + rows * 85; } this.ChangedPurchaseAnimalsMenuClickableComponents = true; return; } }
public static List <string> SanitizeBlueChickens(List <string> types, SDV.Farmer farmer) { var str = BlueChicken.ToString(); if (types.Contains(str) && !AnimalShop.IsBlueChickenAvailableForPurchase(farmer)) { types.Remove(str); } return(types); }
private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { this.Player = new Player(Game1.player, this.Helper); // Set up everything else BlueConfig blueConfig = new BlueConfig(this.Player.HasSeenEvent(BlueVariation.EVENT_ID)); this.BlueFarmAnimals = new BlueVariation(blueConfig); VoidConfig voidConfig = new VoidConfig(this.Config.VoidFarmAnimalsInShop, this.Player.HasCompletedQuest(VoidVariation.QUEST_ID)); this.VoidFarmAnimals = new VoidVariation(voidConfig); List <FarmAnimalForPurchase> farmAnimalsForPurchase = this.Config.GetFarmAnimalsForPurchase(Game1.getFarm()); StockConfig stockConfig = new StockConfig(farmAnimalsForPurchase, this.BlueFarmAnimals, this.VoidFarmAnimals); Stock stock = new Stock(stockConfig); this.AnimalShop = new AnimalShop(stock); }
private void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e) { this.Player = new Player(Game1.player, this.Helper); // Set up everything else BlueConfig blueConfig = new BlueConfig(this.Player.HasSeenEvent(Blue.EVENT_ID)); this.BlueFarmAnimals = new Blue(blueConfig); VoidConfig voidConfig = new VoidConfig(this.Config.VoidFarmAnimalsInShop, this.Player.HasCompletedQuest(Void.QUEST_ID)); this.VoidFarmAnimals = new Void(voidConfig); Dictionary <Stock.Name, string[]> available = this.Config.MapFarmAnimalsToAvailableAnimalShopStock(); StockConfig stockConfig = new StockConfig(available, this.BlueFarmAnimals, this.VoidFarmAnimals); Stock stock = new Stock(stockConfig); this.AnimalShop = new AnimalShop(stock); }
private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { // Ignore if player hasn't loaded a save yet if (!Context.IsWorldReady) { return; } // We only care about left mouse clicks right now if (e.Button != SButton.MouseLeft) { return; } ActiveClickableMenu activeClickableMenu = new ActiveClickableMenu(Game1.activeClickableMenu); if (!activeClickableMenu.IsOpen()) { return; } if (!(activeClickableMenu.GetMenu() is StardewValley.Menus.PurchaseAnimalsMenu)) { return; } // Purchasing a new animal StardewValley.Menus.PurchaseAnimalsMenu purchaseAnimalsMenu = activeClickableMenu.GetMenu() as StardewValley.Menus.PurchaseAnimalsMenu; Player player = new Player(Game1.player, this.Helper); AnimalShop animalShop = this.GetAnimalShop(player); PurchaseFarmAnimal purchaseFarmAnimal = new PurchaseFarmAnimal(player, animalShop); PurchaseFarmAnimalMenu purchaseFarmAnimalMenu = new PurchaseFarmAnimalMenu(purchaseAnimalsMenu, purchaseFarmAnimal); purchaseFarmAnimalMenu.HandleTap(e); }
public PurchaseFarmAnimal(Player farmer, AnimalShop animalShop) { this.Farmer = farmer; this.AnimalShop = animalShop; }