Got the general machine menu tabs to look better with summary and inventory menus. Also fixed inventory transfer menu messing up inventories and not adding things in when they should.
This commit is contained in:
parent
c7b6ba8495
commit
1a63bcc34d
|
@ -258,7 +258,7 @@ namespace Revitalize.Framework.Menus
|
|||
}
|
||||
else
|
||||
{
|
||||
Vector2 newPos = new Vector2(100 + (48) * (count + 1), this.yPositionOnScreen + (24 * 4) * (count + 1));
|
||||
Vector2 newPos = new Vector2(100 + (48), this.yPositionOnScreen + (24 * 4) * (count + 1));
|
||||
Button.Position = newPos;
|
||||
this.CraftingTabs.Add(name, Button);
|
||||
this.craftingItemsToDisplay.Add(name, new List<CraftingRecipeButton>());
|
||||
|
|
|
@ -208,8 +208,23 @@ namespace Revitalize.Framework.Menus
|
|||
}
|
||||
}
|
||||
if (To.isFull == false)
|
||||
{
|
||||
//
|
||||
bool addedItem = false;
|
||||
for(int i = 0; i < To.items.Count; i++)
|
||||
{
|
||||
if (To.items[i] == null)
|
||||
{
|
||||
To.items[i] = From.activeItem;
|
||||
addedItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addedItem == false)
|
||||
{
|
||||
To.items.Add(From.activeItem);
|
||||
}
|
||||
|
||||
From.items.Remove(From.activeItem);
|
||||
From.activeItem = null;
|
||||
From.populateClickableItems();
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using StardewValley;
|
||||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
|
||||
|
||||
namespace Revitalize.Framework.Menus.Machines
|
||||
{
|
||||
public class MachineMenu : IClickableMenuExtended
|
||||
{
|
||||
|
||||
public Dictionary<string,KeyValuePair<AnimatedButton,IClickableMenuExtended>> menuPages;
|
||||
public string currentTab;
|
||||
public string hoverText;
|
||||
|
||||
public IClickableMenuExtended CurrentMenu
|
||||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrEmpty(this.currentTab)) return null;
|
||||
else
|
||||
{
|
||||
if (this.menuPages.ContainsKey(this.currentTab))
|
||||
{
|
||||
return this.menuPages[this.currentTab].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public MachineMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MachineMenu(int x, int y, int width, int height) : base(x, y, width, height, false)
|
||||
{
|
||||
this.menuPages = new Dictionary<string, KeyValuePair<AnimatedButton, IClickableMenuExtended>>();
|
||||
}
|
||||
|
||||
public void addInMenuTab(string Name,AnimatedButton Button, IClickableMenuExtended Menu,bool DefaultTab=false)
|
||||
{
|
||||
int count = this.menuPages.Count;
|
||||
|
||||
Vector2 newPos = new Vector2(208 + (24 * 2) * (count+1), this.yPositionOnScreen+(80));
|
||||
Button.Position = newPos;
|
||||
this.menuPages.Add(Name,new KeyValuePair<AnimatedButton, IClickableMenuExtended>(Button, Menu));
|
||||
|
||||
if (DefaultTab)
|
||||
{
|
||||
this.currentTab = Name;
|
||||
}
|
||||
}
|
||||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
foreach (var v in this.menuPages)
|
||||
{
|
||||
if (v.Value.Key.containsPoint(x, y))
|
||||
{
|
||||
this.currentTab = v.Key;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.CurrentMenu != null)
|
||||
{
|
||||
this.CurrentMenu.receiveLeftClick(x, y, playSound);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public override void receiveKeyPress(Keys key)
|
||||
{
|
||||
if (this.CurrentMenu != null)
|
||||
{
|
||||
this.CurrentMenu.receiveKeyPress(key);
|
||||
}
|
||||
}
|
||||
|
||||
public override void performHoverAction(int x, int y)
|
||||
{
|
||||
|
||||
bool hovered = false;
|
||||
|
||||
foreach(var v in this.menuPages)
|
||||
{
|
||||
if (v.Value.Key.containsPoint(x, y))
|
||||
{
|
||||
this.hoverText = v.Key;
|
||||
hovered = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.CurrentMenu != null)
|
||||
{
|
||||
this.CurrentMenu.performHoverAction(x, y);
|
||||
}
|
||||
|
||||
if (hovered == false)
|
||||
{
|
||||
this.hoverText = "";
|
||||
}
|
||||
}
|
||||
|
||||
public override void receiveRightClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
if (this.CurrentMenu != null)
|
||||
{
|
||||
this.CurrentMenu.receiveRightClick(x, y,playSound);
|
||||
}
|
||||
}
|
||||
|
||||
public override void update(GameTime time)
|
||||
{
|
||||
if (this.CurrentMenu != null)
|
||||
{
|
||||
this.CurrentMenu.update(time);
|
||||
}
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
foreach(KeyValuePair<AnimatedButton,IClickableMenuExtended> button in this.menuPages.Values)
|
||||
{
|
||||
button.Key.draw(b);
|
||||
}
|
||||
if (this.CurrentMenu != null)
|
||||
{
|
||||
this.CurrentMenu.draw(b);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(this.hoverText) == false)
|
||||
{
|
||||
IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont);
|
||||
}
|
||||
|
||||
this.drawMouse(b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ using StardewValley;
|
|||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
|
||||
|
||||
namespace Revitalize.Framework.Menus
|
||||
namespace Revitalize.Framework.Menus.Machines
|
||||
{
|
||||
public class MachineSummaryMenu : IClickableMenuExtended
|
||||
{
|
||||
|
@ -35,7 +35,6 @@ namespace Revitalize.Framework.Menus
|
|||
private AnimatedButton battergyEnergyGuage;
|
||||
private Vector2 energyPosition;
|
||||
private Texture2D energyTexture;
|
||||
private Rectangle energyMeterBounds;
|
||||
private Vector2 itemDisplayOffset;
|
||||
|
||||
private EnergyManager energy
|
||||
|
@ -63,7 +62,7 @@ namespace Revitalize.Framework.Menus
|
|||
this.batteryBackground =new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)),Color.White),new Rectangle(0,0,32,64),4f);
|
||||
this.battergyEnergyGuage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryEnergyGuage", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryEnergyGuage"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f);
|
||||
|
||||
this.itemDisplayOffset=this.getDimensionOffsetFromItem();
|
||||
this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource);
|
||||
}
|
||||
|
||||
public override void performHoverAction(int x, int y)
|
||||
|
@ -112,11 +111,14 @@ namespace Revitalize.Framework.Menus
|
|||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Swaps the color for the energy bar meter depending on how much energy is left.
|
||||
/// </summary>
|
||||
|
||||
private void colorSwap()
|
||||
{
|
||||
Color col = new Color();
|
||||
ModCore.log("Energy is: " + this.energy.energyPercentRemaining);
|
||||
//ModCore.log("Energy is: " + this.energy.energyPercentRemaining);
|
||||
if (this.energy.energyPercentRemaining > .75d)
|
||||
{
|
||||
col = Color.Green;
|
||||
|
@ -144,20 +146,5 @@ namespace Revitalize.Framework.Menus
|
|||
};
|
||||
this.energyTexture.SetData<Color>(color);
|
||||
}
|
||||
|
||||
|
||||
private Vector2 getDimensionOffsetFromItem()
|
||||
{
|
||||
if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), this.objectSource.GetType()))
|
||||
{
|
||||
return new Vector2(64f, 64f);
|
||||
}
|
||||
if (ObjectUtilities.IsSameType(typeof(Revitalize.Framework.Objects.MultiTiledObject), this.objectSource.GetType()))
|
||||
{
|
||||
return new Vector2(64f * (this.objectSource as MultiTiledObject).Width, 64f * (this.objectSource as MultiTiledObject).Height);
|
||||
}
|
||||
|
||||
return new Vector2(64f, 64f);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ using Revitalize.Framework.Menus;
|
|||
using Revitalize.Framework.Objects.CraftingTables;
|
||||
using Revitalize.Framework.Objects.Items.Tools;
|
||||
using StardewValley.Tools;
|
||||
using Revitalize.Framework.Menus.Machines;
|
||||
|
||||
namespace Revitalize
|
||||
{
|
||||
|
@ -332,10 +333,17 @@ namespace Revitalize
|
|||
*/
|
||||
if (e.Button == SButton.U)
|
||||
{
|
||||
CustomObject test = ObjectManager.GetItem("SandBox");
|
||||
MultiTiledObject test =(MultiTiledObject) ObjectManager.GetItem("SandBox");
|
||||
test.EnergyManager.maxEnergy = 100;
|
||||
test.EnergyManager.produceEnergy(100);
|
||||
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = new MachineSummaryMenu((Game1.viewport.Width/2)-400, 0, 800, 600,Color.White,test);
|
||||
MachineSummaryMenu m= new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width/2)-400, 48, 800, 600,Color.White,test);
|
||||
InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, test.info.inventory.items, 36);
|
||||
MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600);
|
||||
|
||||
machineMenu.addInMenuTab("Summary",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab",new Vector2(),new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest,"Menus","MenuTab"),new Animation(0,0,24,24)),Color.White),new Rectangle(0,0,24,24),2f),m,true);
|
||||
machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, true);
|
||||
|
||||
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = machineMenu;
|
||||
}
|
||||
/*
|
||||
if (e.Button == SButton.Y)
|
||||
|
|
|
@ -86,7 +86,8 @@
|
|||
<Compile Include="Framework\Illuminate\LightManager.cs" />
|
||||
<Compile Include="Framework\Menus\CraftingInformationPage.cs" />
|
||||
<Compile Include="Framework\Menus\CraftingMenuV1.cs" />
|
||||
<Compile Include="Framework\Menus\MachineSummaryMenu.cs" />
|
||||
<Compile Include="Framework\Menus\Machines\MachineMenu.cs" />
|
||||
<Compile Include="Framework\Menus\Machines\MachineSummaryMenu.cs" />
|
||||
<Compile Include="Framework\Menus\InventoryMenuPage.cs" />
|
||||
<Compile Include="Framework\Menus\InventoryTransferMenu.cs" />
|
||||
<Compile Include="Framework\Menus\MenuComponents\CraftingRecipeButton.cs" />
|
||||
|
|
Loading…
Reference in New Issue