Fixed crafting not working for player inventory. Fixed machine summary menu crashing when displaying empty tanks. Fixed animaation managers not copying over correctly.

This commit is contained in:
JoshuaNavarro 2019-10-09 00:18:45 -07:00
parent 106b7a9474
commit 89ef844ab3
21 changed files with 161 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

View File

@ -306,13 +306,13 @@ namespace Revitalize.Framework.Crafting
#region
CraftingRecipeBook WorkbenchRecipes = new CraftingRecipeBook("Workbench");
WorkbenchRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f),true);
WorkbenchRecipes.addInCraftingTab("Furniture", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Furniture Tab", new Vector2(100 + 48, 100 + (24 * 4)*2), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), false);
WorkbenchRecipes.addCraftingRecipe("Anvil", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
//Inputs here
new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20)
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)), true));
WorkbenchRecipes.addCraftingRecipe("Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20),
@ -332,36 +332,30 @@ namespace Revitalize.Framework.Crafting
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20),
}, new CraftingRecipeComponent(new StardewValley.Tools.WateringCan() { UpgradeLevel = 0 }, 1)), true));
WorkbenchRecipes.addCraftingRecipe("Copper Wire", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1),
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"),2),null,0),true));
WorkbenchRecipes.addCraftingRecipe("Alloy Furnace", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Clay,20),10),
new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 10)
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AlloyFurnace"), 1), null, 0), true));
WorkbenchRecipes.addCraftingRecipe("Sand Box", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100),
new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 25)
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SandBox"), 1), null, 0), true));
WorkbenchRecipes.addCraftingRecipe("Battery Bin", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100),
new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"),10)
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BatteryBin"), 1), null, 0), true));
WorkbenchRecipes.addCraftingRecipe("Capacitor", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,50),50),
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,10),10)
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1), null, 0), true));
WorkbenchRecipes.addCraftingRecipe("Charging Station", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
{
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100),
@ -370,8 +364,21 @@ namespace Revitalize.Framework.Crafting
new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1)
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ChargingStation"), 1), null, 0), true));
WorkbenchRecipes.addCraftingRecipe("Oak Chair", new UnlockableCraftingRecipe("Furniture", new Recipe(new List<CraftingRecipeComponent>(),new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Oak Chair"),1),new StatCost(0,0,100,0),0), true));
if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup))
{
foreach(KeyValuePair<string,AnimatedButton> pair in WorkbenchRecipes.craftingMenuTabs)
{
if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key))
{
}
else
{
CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value);
}
}
foreach(KeyValuePair<string, UnlockableCraftingRecipe> recipe in WorkbenchRecipes.craftingRecipes)
{
if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key))
@ -558,6 +565,17 @@ namespace Revitalize.Framework.Crafting
if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup))
{
foreach (KeyValuePair<string, AnimatedButton> pair in AnvilRecipes.craftingMenuTabs)
{
if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key))
{
}
else
{
CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value);
}
}
foreach (KeyValuePair<string, UnlockableCraftingRecipe> recipe in AnvilRecipes.craftingRecipes)
{
if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key))

View File

@ -58,7 +58,7 @@ namespace Revitalize.Framework.Crafting
{
output
};
this.statCost = StatCost ?? new StatCost();
this.statCost = StatCost;
this.timeToCraft = TimeToCraft;
}
@ -68,7 +68,7 @@ namespace Revitalize.Framework.Crafting
this.outputs = outputs;
this.outputName = OutputName;
this.outputDescription = OutputDescription;
this.statCost = StatCost ?? new StatCost();
this.statCost = StatCost;
this.timeToCraft = TimeToCraft;
}
@ -87,6 +87,7 @@ namespace Revitalize.Framework.Crafting
/// <summary>Checks if an inventory contains all items.</summary>
public bool InventoryContainsAllIngredient(IList<Item> items)
{
if (this.ingredients.Count == 0) return true;
foreach (CraftingRecipeComponent pair in this.ingredients)
if (!this.InventoryContainsIngredient(items, pair)) return false;
return true;
@ -176,7 +177,7 @@ namespace Revitalize.Framework.Crafting
/// <param name="isPlayerInventory">Checks to see if the invventory is the player's</param>
public void craft(ref IList<Item> from, ref IList<Item> to, bool dropToGround = false, bool isPlayerInventory = false)
{
InventoryManager manager = new InventoryManager(to);
InventoryManager manager = new InventoryManager(to,Game1.player.MaxItems);
if (manager.ItemCount + this.outputs.Count >= manager.capacity)
{
if (isPlayerInventory)
@ -198,7 +199,11 @@ namespace Revitalize.Framework.Crafting
Game1.player.Items = playerItems; //Set the items to be post consumption.
foreach (Item I in outPutItems)
Game1.player.addItemToInventory(I); //Add all items produced.
{
Item copy = I.getOne();
copy.Stack = I.Stack;
Game1.player.addItemToInventory(copy); //Add all items produced.
}
this.statCost.payCost();
}
@ -209,7 +214,14 @@ namespace Revitalize.Framework.Crafting
public bool CanCraft(IList<Item> items)
{
return this.InventoryContainsAllIngredient(items);
if (this.statCost == null)
{
return this.InventoryContainsAllIngredient(items);
}
else
{
return this.InventoryContainsAllIngredient(items) && this.statCost.canSafelyAffordCost();
}
}
}
}

View File

@ -9,10 +9,10 @@ namespace Revitalize.Framework.Crafting
{
public class StatCost
{
int health;
int stamina;
int magic;
int gold;
public int health;
public int stamina;
public int magic;
public int gold;
public StatCost(int Stamina = 0, int Health = 0, int Gold = 0, int Magic = 0){
this.stamina = Stamina;

View File

@ -325,6 +325,7 @@ namespace Revitalize.Framework.Factories.Objects
foreach (var v in chairObjects)
{
ModCore.ObjectManager.chairs.Add(v.Value.info.id, v.Value);
ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value);
}
}
}
@ -406,6 +407,7 @@ namespace Revitalize.Framework.Factories.Objects
foreach (var v in chairObjects)
{
ModCore.ObjectManager.tables.Add(v.Value.info.id, v.Value);
ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value);
}
}
}
@ -488,6 +490,7 @@ namespace Revitalize.Framework.Factories.Objects
foreach (var v in chairObjects)
{
ModCore.ObjectManager.furnitureStorage.Add(v.Value.info.id, v.Value);
ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value);
}
}
}

View File

@ -98,5 +98,10 @@ namespace Revitalize.Framework.Managers
return self;
}
public ColorManager Copy()
{
return new ColorManager(this._blendInfluence, this._colorMixMode);
}
}
}

View File

@ -34,6 +34,7 @@ namespace Revitalize.Framework.Menus
private Dictionary<ItemDisplayButton,int> requiredItems;
public AnimatedButton craftingButton;
public AnimatedButton goldButton;
public bool isPlayerInventory;
@ -70,6 +71,14 @@ namespace Revitalize.Framework.Menus
}
this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f);
this.outputInventory = this.inventory;
if (this.infoButton.recipe.statCost != null)
{
if (this.infoButton.recipe.statCost.gold > 0)
{
this.goldButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("GoldButton", this.getMoneyRequiredOffset(), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "GoldButton"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f);
}
}
}
public CraftingInformationPage(int x, int y, int width, int height, Color BackgroundColor, CraftingRecipeButton ItemToDisplay, ref IList<Item> Inventory,ref IList<Item> OutputInventory ,bool IsPlayerInventory, Machine Machine) : base(x, y, width, height, false)
@ -92,6 +101,13 @@ namespace Revitalize.Framework.Menus
{
this.outputInventory = this.inventory;
}
if (this.infoButton.recipe.statCost != null)
{
if (this.infoButton.recipe.statCost.gold > 0)
{
this.goldButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("GoldButton", this.getMoneyRequiredOffset(), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "GoldButton"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f);
}
}
this.outputInventory = OutputInventory;
this.machine = Machine;
}
@ -104,7 +120,15 @@ namespace Revitalize.Framework.Menus
{
Game1.soundBank.PlayCue("coin");
this.infoButton.craftItem(this.inventory, this.outputInventory);
if (this.isPlayerInventory)
{
this.infoButton.craftItem();
}
else
{
this.infoButton.craftItem(this.inventory, this.outputInventory);
}
if (this.machine != null)
{
if (this.infoButton.recipe.timeToCraft == 0)
@ -177,9 +201,13 @@ namespace Revitalize.Framework.Menus
button.Key.draw(b);
b.DrawString(Game1.smallFont, button.Key.item.DisplayName+ " x "+button.Value.ToString(), button.Key.Position + new Vector2(64, 16), this.getNameColor(button.Key.item, button.Value));
}
if (this.goldButton != null)
{
this.goldButton.draw(b);
b.DrawString(Game1.smallFont, this.infoButton.recipe.statCost.gold+" G", this.goldButton.Position +new Vector2(0,32),Color.Black);
}
this.craftingButton.draw(b, this.getCraftableColor().A);
this.drawMouse(b);
}
@ -264,11 +292,9 @@ namespace Revitalize.Framework.Menus
/// Gets the height position for where to draw a required ingredient.
/// </summary>
/// <returns></returns>
private Vector2 getIngredientHeightOffset()
private Vector2 getMoneyRequiredOffset()
{
string parsedDescription = Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width);
Vector2 offset=Game1.smallFont.MeasureString(parsedDescription);
return this.getItemDescriptionOffset()+offset+ new Vector2(0,64*(this.requiredItems.Count));
return new Vector2(this.xPositionOnScreen+64+this.width,this.yPositionOnScreen+128);
}
private float getCraftingButtonHeight()

View File

@ -263,7 +263,8 @@ namespace Revitalize.Framework.Menus
}
else
{
Vector2 newPos = new Vector2(100 + (48), this.yPositionOnScreen + (24 * 4) * (count + 1));
Vector2 newPos = new Vector2(100 + (48), (this.yPositionOnScreen+24) + ((24 * 4) * (count + 1)));
ModCore.log("newPos: " + newPos.ToString());
Button.Position = newPos;
this.CraftingTabs.Add(name, Button);
this.craftingItemsToDisplay.Add(name, new List<CraftingRecipeButton>());

View File

@ -144,30 +144,40 @@ namespace Revitalize.Framework.Menus.Machines
if (this.objectSource.info.fluidManager.InteractsWithFluids)
{
if (this.inputFluidTank1Button.containsPoint(x, y))
if (this.inputFluidTank1Button != null)
{
if (this.objectSource.info.fluidManager.inputTank1.capacity > 0)
if (this.inputFluidTank1Button.containsPoint(x, y))
{
this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString();
hovered = true;
if (this.objectSource.info.fluidManager.inputTank1.capacity > 0)
{
this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString();
hovered = true;
}
}
}
if (this.inputFluidTank2Button.containsPoint(x, y))
if (this.inputFluidTank2Button != null)
{
if (this.objectSource.info.fluidManager.inputTank2.capacity > 0)
if (this.inputFluidTank2Button.containsPoint(x, y))
{
this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString();
hovered = true;
if (this.objectSource.info.fluidManager.inputTank2.capacity > 0)
{
this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString();
hovered = true;
}
}
}
if (this.outputFluidTankButton.containsPoint(x, y))
if (this.outputFluidTankButton != null)
{
if (this.objectSource.info.fluidManager.outputTank.capacity > 0)
if (this.outputFluidTankButton.containsPoint(x, y))
{
this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString();
hovered = true;
if (this.objectSource.info.fluidManager.outputTank.capacity > 0)
{
this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString();
hovered = true;
}
}
}
}
@ -187,7 +197,6 @@ namespace Revitalize.Framework.Menus.Machines
}
else if (this.energy.producesEnergy)
{
return "Produces " + EnergyAmount + " energy per 10 minutes.";
}
else return "";

View File

@ -451,7 +451,7 @@ namespace Revitalize.Framework.Objects
/// <returns></returns>
public BasicItemInformation Copy()
{
return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager,this.fluidManager.Copy());
return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager.Copy(), this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager,this.fluidManager.Copy());
}
public bool requiresSyncUpdate()

View File

@ -440,7 +440,8 @@ namespace Revitalize.Framework.Objects
if (this.info.animationManager.animations.ContainsKey(this.generateRotationalAnimationKey()))
{
this.info.animationManager.setAnimation(this.generateRotationalAnimationKey());
this.info.animationManager.enabled = true;
this.info.animationManager.playAnimation(this.generateRotationalAnimationKey());
}
else
{
@ -451,6 +452,7 @@ namespace Revitalize.Framework.Objects
public string generateRotationalAnimationKey()
{
if (string.IsNullOrEmpty(this.info.animationManager.currentAnimationName)) return this.generateDefaultRotationalAnimationKey();
return (this.info.animationManager.currentAnimationName.Split('_')[0]) + "_" + (int)this.info.facingDirection;
}

View File

@ -180,8 +180,8 @@ namespace Revitalize.Framework.Objects.Furniture
public override Item getOne()
{
ChairTileComponent component = new ChairTileComponent(this.data,this.info.Copy(), (ChairInformation)this.furnitureInfo);
component.containerObject = this.containerObject;
component.offsetKey = this.offsetKey;
//component.containerObject = this.containerObject;
//component.offsetKey = this.offsetKey;
return component;
}

View File

@ -124,8 +124,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration
public override Item getOne()
{
SteamBoiler component = new SteamBoiler(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook);
component.containerObject = this.containerObject;
component.offsetKey = this.offsetKey;
//component.containerObject = this.containerObject;
//component.offsetKey = this.offsetKey;
return component;
return component;
}

View File

@ -140,8 +140,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration
public override Item getOne()
{
SteamEngine component = new SteamEngine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook,this.requiredFluidForOperation,this.amountOfFluidRequiredForOperation);
component.containerObject = this.containerObject;
component.offsetKey = this.offsetKey;
//component.containerObject = this.containerObject;
//component.offsetKey = this.offsetKey;
return component;
return component;
}

View File

@ -121,8 +121,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration
public override Item getOne()
{
Windmill component = new Windmill(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook, this.requiredFluidForOperation, this.amountOfFluidRequiredForOperation);
component.containerObject = this.containerObject;
component.offsetKey = this.offsetKey;
//component.containerObject = this.containerObject;
//component.offsetKey = this.offsetKey;
return component;
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Revitalize.Framework.Factories.Objects;
using Revitalize.Framework.Illuminate;
using Revitalize.Framework.Objects.CraftingTables;
using Revitalize.Framework.Objects.Extras;
@ -116,6 +117,7 @@ namespace Revitalize.Framework.Objects
this.loadInMachines();
this.loadInTools();
this.loadInAestheticsObjects();
FurnitureFactory.LoadFurnitureFiles();
}
private void loadInAestheticsObjects()

View File

@ -64,9 +64,9 @@ namespace Revitalize.Framework.Utilities
this.displayColumns = DisplayColumns;
}
public InventoryManager(IList<Item> items, int DisplayRows = 6, int DisplayColumns = 6)
public InventoryManager(IList<Item> items, int Capacity= int.MaxValue, int DisplayRows = 6, int DisplayColumns = 6)
{
this.capacity = int.MaxValue;
this.capacity = Capacity;
this.setMaxLimit(int.MaxValue);
this.items = items;
this.bufferItems = new List<Item>();

View File

@ -490,9 +490,6 @@ namespace Revitalize
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Rugs.RugTest", rug);
FurnitureFactory.LoadFurnitureFiles();
SeasideScramble sscGame = new SeasideScramble();
ArcadeCabinetTile ssc1 = new ArcadeCabinetTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), typeof(ArcadeCabinetTile), Color.White), new BasicItemInformation("Seaside Scramble Arcade Game", "Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", "A arcade to play Seaside Scramble!", "Arcades", Color.LimeGreen, -300, 0, false, 100, true, true, TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new Animation(new Rectangle(0, 0, 16, 16)), new Dictionary<string, List<Animation>>()
{

View File

@ -412,6 +412,9 @@
<Content Include="Content\Graphics\Menus\CraftingMenu\CraftButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\CraftingMenu\GoldButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\EnergyMenu\BatteryEnergyGuage.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -29,6 +29,8 @@ namespace StardustCore.Animations
public bool hasRecievedUpdateTick;
public string startingAnimationName;
/// <summary>
/// Checks to see if there is an animation playing.
/// </summary>
@ -57,6 +59,7 @@ namespace StardustCore.Animations
this.currentAnimation = this.defaultDrawFrame;
this.currentAnimationName = "";
this.animationDataString = "";
this.startingAnimationName = "";
}
public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, string animationString, string startingAnimationKey, int startingAnimationFrame = 0, bool EnabledByDefault = true)
@ -68,6 +71,7 @@ namespace StardustCore.Animations
this.animationDataString = animationString;
this.animations = parseAnimationsFromXNB(animationString);
this.startingAnimationName = startingAnimationKey;
if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList))
this.setAnimation(startingAnimationKey, startingAnimationFrame);
else
@ -85,12 +89,29 @@ namespace StardustCore.Animations
this.enabled = EnabledByDefault;
this.animations = animationString;
if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList))
this.startingAnimationName = startingAnimationKey;
if (this.animations != null)
{
this.setAnimation(startingAnimationKey, startingAnimationFrame);
this.playAnimation(startingAnimationKey, true, startingAnimationFrame);
}
if (string.IsNullOrEmpty(startingAnimationKey) == false)
{
if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList))
{
this.setAnimation(startingAnimationKey, startingAnimationFrame);
this.playAnimation(startingAnimationKey, true, startingAnimationFrame);
}
else
{
this.currentAnimation = this.defaultDrawFrame;
this.currentAnimationName = "";
}
}
else
{
this.currentAnimation = this.defaultDrawFrame;
this.currentAnimationName = "";
}
}
else
{
this.currentAnimation = this.defaultDrawFrame;
@ -485,5 +506,10 @@ namespace StardustCore.Animations
{
return this.objectTexture.getTexture();
}
public AnimationManager Copy()
{
return new AnimationManager(this.objectTexture, this.defaultDrawFrame, this.animations, this.startingAnimationName, 0, this.enabled);
}
}
}

View File

@ -17,7 +17,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
/// <summary>
/// The default bounds for the button.
/// </summary>
private Rectangle defaultBounds;
public Rectangle defaultBounds;
/// <summary>
/// The actual bounds for the button which takes scale into acount.
/// </summary>