Added in hover bubble for machines which displays when they are full. Also made a config to adjust alpha and if it displays.

This commit is contained in:
JoshuaNavarro 2019-09-18 15:05:51 -07:00
parent 620c1b4b70
commit 0de19a904f
5 changed files with 45 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

View File

@ -15,12 +15,16 @@ namespace Revitalize.Framework.Configs
public double solarPanelNonSunnyDayEnergyMultiplier;
public double solarPanelNightEnergyGenerationMultiplier;
public bool showMachineNotificationBubble_InventoryFull;
public float machineNotificationBubbleAlpha;
public GlobalMachineConfig()
{
this.doMachinesConsumeEnergy = true;
this.solarPanelNonSunnyDayEnergyMultiplier = 0.0d;
this.solarPanelNightEnergyGenerationMultiplier = .125d;
this.showMachineNotificationBubble_InventoryFull = true;
this.machineNotificationBubbleAlpha = 0.75f;
}
public static GlobalMachineConfig InitializeConfig()

View File

@ -123,6 +123,9 @@ namespace Revitalize.Framework.Objects.Machines
public string craftingRecipeBook;
[JsonIgnore]
protected AnimationManager machineStatusBubbleBox;
[JsonIgnore]
public bool ProducesItems
{
@ -166,6 +169,8 @@ namespace Revitalize.Framework.Objects.Machines
this.updatesContainerObjectForProduction = UpdatesContainer;
this.MinutesUntilReady = TimeToProduce;
this.craftingRecipeBook = CraftingBook;
this.createStatusBubble();
}
public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List<ResourceInformation> ProducedResources=null,int EnergyRequiredPer10Minutes=0,int TimeToProduce=0,bool UpdatesContainer=false, string CraftingBook = "", MultiTiledObject obj=null) : base(PyTKData, info, TileLocation)
@ -177,6 +182,7 @@ namespace Revitalize.Framework.Objects.Machines
this.updatesContainerObjectForProduction = UpdatesContainer;
this.MinutesUntilReady = TimeToProduce;
this.craftingRecipeBook = CraftingBook;
this.createStatusBubble();
}
public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey,List<ResourceInformation> ProducedResources=null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce=0,bool UpdatesContainer=false, string CraftingBook = "", MultiTiledObject obj = null) : base(PyTKData, info, TileLocation)
@ -189,6 +195,17 @@ namespace Revitalize.Framework.Objects.Machines
this.updatesContainerObjectForProduction = UpdatesContainer;
this.MinutesUntilReady = TimeToProduce;
this.craftingRecipeBook = CraftingBook;
this.createStatusBubble();
}
protected virtual void createStatusBubble()
{
this.machineStatusBubbleBox = new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "HUD", "MachineStatusBubble"), new Animation(0, 0, 20, 24), new Dictionary<string, List<Animation>>()
{
{"Default",new List<Animation>(){new Animation(0,0,20,24)}},
{"Empty",new List<Animation>(){new Animation(20,0,20,24)}},
{"InventoryFull",new List<Animation>(){new Animation(40,0,20,24)}}
}, "Default", 0);
}
public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
@ -386,6 +403,8 @@ namespace Revitalize.Framework.Objects.Machines
addedDepth += 1.0f;
}
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f);
this.drawStatusBubble(spriteBatch, x, y, alpha);
try
{
this.animationManager.tickAnimation();
@ -424,6 +443,22 @@ namespace Revitalize.Framework.Objects.Machines
}
protected virtual void drawStatusBubble(SpriteBatch b,int x, int y,float Alpha)
{
if (this.updatesContainerObjectForProduction == false) return;
if (this.InventoryManager.IsFull && this.ProducesItems && ModCore.Configs.machinesConfig.showMachineNotificationBubble_InventoryFull)
{
y--;
float num = (float)(4.0 * Math.Round(Math.Sin(DateTime.UtcNow.TimeOfDay.TotalMilliseconds / 250.0), 2));
this.machineStatusBubbleBox.playAnimation("InventoryFull");
this.machineStatusBubbleBox.draw(b, this.machineStatusBubbleBox.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize+num)), new Rectangle?(this.machineStatusBubbleBox.currentAnimation.sourceRectangle), Color.White*ModCore.Configs.machinesConfig.machineNotificationBubbleAlpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)((y+2) * Game1.tileSize) / 10000f) + .00001f);
}
else
{
}
}
}
}

View File

@ -318,6 +318,9 @@ namespace Revitalize
TextureManager.AddTextureManager(Manifest, "CraftingMenu");
TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu"));
TextureManager.AddTextureManager(Manifest, "HUD");
TextureManager.GetTextureManager(Manifest,"HUD").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "HUD"));
TextureManager.AddTextureManager(Manifest, "Objects.Crafting");
TextureManager.GetTextureManager(Manifest, "Objects.Crafting").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Crafting"));

View File

@ -205,6 +205,9 @@
<None Include="manifest.json" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\Graphics\HUD\MachineStatusBubble.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Items\Resources\Misc\Glass.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>