private void DoSmash(Item item, ModEntry.SmashType smashType) { if (item.maximumStackSize() <= 1) { return; } Game1.playSound("clubhit"); if (smashType == ModEntry.SmashType.Color) { if (item.category == -80 && item is ColoredObject c) { c.color.Value = default; } } if (smashType == ModEntry.SmashType.Quality) { if (item is StardewValley.Object o && o.Quality != 0) { o.Quality /= 2; } } }
public QSButton(ModEntry.SmashType smashType, Texture2D texture, Rectangle buttonClickableArea) { this.smashType = smashType; this.texture = texture; clickable = new ClickableTextureComponent(Rectangle.Empty, texture, buttonClickableArea, 4f); }
public void RemoveButton(ModEntry.SmashType smashType) { for (int i = 0; i < qsButtons.Count; i++) { if (qsButtons[i].smashType == smashType) { qsButtons.RemoveAt(i); return; } } }
public void AddButton(ModEntry.SmashType smashType, Texture2D texture, Rectangle clickableArea) { // Make sure button doesn't already exist if (qsButtons.Any(button => button.smashType == smashType)) { return; } QSButton newButton = new QSButton(smashType, texture, clickableArea); newButton.UpdateHoverText(""); qsButtons.Add(newButton); }
private bool IsSmashable(Item item, ModEntry.SmashType smashType) { if (item == null) { return(false); } if (smashType == ModEntry.SmashType.Color) { if (item.category == -80 && item is ColoredObject c) { return(true); } } if (smashType == ModEntry.SmashType.Quality) { if (item is StardewValley.Object o && o.Quality != 0) { return(true); } } return(false); }
private void DoSmash(ItemGrabMenu menu, ModEntry.SmashType smashType) { var areItemsChanged = false; var containerInventory = menu.ItemsToGrabMenu.actualInventory; var itemsProcessed = new List <Item>(); for (var i = 0; i < containerInventory.Count; i++) { if (containerInventory[i] == null || !(containerInventory[i] is StardewValley.Object)) { continue; } if (smashType == ModEntry.SmashType.Color) { if (!(containerInventory[i] is ColoredObject c) || c.Category != -80 || config.IgnoreItemsColor.Contains(containerInventory[i].ParentSheetIndex)) { continue; } areItemsChanged = true; c.color.Value = default; itemsProcessed.Add(containerInventory[i]); containerInventory.RemoveAt(i); i--; } else if (smashType == ModEntry.SmashType.Quality) { if ((containerInventory[i] as StardewValley.Object)?.Quality == 0) { continue; } if (config.IgnoreItemsQuality.Contains(containerInventory[i].ParentSheetIndex) || config.IgnoreItemsCategory.Contains(containerInventory[i].Category)) { continue; } if (!config.IgnoreIridiumItemExceptions.Contains(containerInventory[i].ParentSheetIndex) && !config.IgnoreIridiumCategoryExceptions.Contains(containerInventory[i].Category)) { if (config.IgnoreIridium && (containerInventory[i] as StardewValley.Object)?.Quality == 4) { continue; } } if (config.IgnoreGold && (containerInventory[i] as StardewValley.Object)?.Quality == 2) { continue; } if (config.IgnoreSilver && (containerInventory[i] as StardewValley.Object)?.Quality == 1) { continue; } // Filtering complete areItemsChanged = true; if (containerInventory[i] is StardewValley.Object o) { o.Quality = 0; } itemsProcessed.Add(containerInventory[i]); containerInventory.RemoveAt(i); i--; } } if (!areItemsChanged) { return; } // There's probably a simpler way to do this built into the game, but I don't see it. // Prime the container with some of each item AddSomeOfEach(menu, itemsProcessed); // Use a modified version of game's quick stack code to add the rest FillOutStacks(menu, itemsProcessed); }
public void RemoveButton(ModEntry.SmashType smashType) { this.buttonHandler.RemoveButton(smashType); }
public void AddButton(ModEntry.SmashType smashType, Texture2D image, Rectangle clickableArea) { this.buttonHandler.AddButton(smashType, image, clickableArea); }
private void DoSmash(ItemGrabMenu menu, ModEntry.SmashType smashType) { var areItemsChanged = false; var containerInventory = menu.ItemsToGrabMenu.actualInventory.ToList(); var itemsProcessed = new List <Item>(); if (smashType == ModEntry.SmashType.Quality) { var itemsToSmash = containerInventory.FindAll(item => !IsFiltered(item)); if (itemsToSmash.Count > 0) { areItemsChanged = true; containerInventory.RemoveAll(item => !IsFiltered(item)); itemsToSmash.ForEach(i1 => { if (i1 is StardewValley.Object o) { o.Quality = itemsToSmash .FindAll(i2 => i2.ParentSheetIndex == i1.ParentSheetIndex) .Cast <StardewValley.Object>() .Min(i3 => i3.Quality); } }); itemsProcessed = itemsToSmash; } } else if (smashType == ModEntry.SmashType.Color) { for (var i = 0; i < containerInventory.Count; i++) { if (containerInventory[i] == null || !(containerInventory[i] is StardewValley.Object)) { continue; } if (config.EnableEggColorSmashing && containerInventory[i].Category == -5) { if (containerInventory[i].ParentSheetIndex == 180) { containerInventory[i].ParentSheetIndex = 176; } if (containerInventory[i].ParentSheetIndex == 182) { containerInventory[i].ParentSheetIndex = 174; } areItemsChanged = true; itemsProcessed.Add(containerInventory[i]); containerInventory.RemoveAt(i); i--; continue; } if (!(containerInventory[i] is ColoredObject c) || c.Category != -80 || config.IgnoreItemsColor.Contains(containerInventory[i].ParentSheetIndex)) { continue; } areItemsChanged = true; c.color.Value = default; itemsProcessed.Add(containerInventory[i]); containerInventory.RemoveAt(i); i--; } } if (!areItemsChanged) { return; } menu.ItemsToGrabMenu.actualInventory.Clear(); foreach (Item item in containerInventory) { menu.ItemsToGrabMenu.actualInventory.Add(item); } // There's probably a simpler way to do this built into the game, but I don't see it. // Prime the container with some of each item AddSomeOfEach(menu, itemsProcessed); // Use a modified version of game's quick stack code to add the rest FillOutStacks(menu, itemsProcessed); }