Fixed crafting menu multi tiled objects not displaying.
This commit is contained in:
parent
a2b66afb65
commit
048dfc9dc0
|
@ -6,6 +6,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Revitalize.Framework.Menus;
|
||||
using Revitalize.Framework.Objects;
|
||||
using Revitalize.Framework.Objects.Machines;
|
||||
using Revitalize.Framework.Utilities;
|
||||
using StardewValley;
|
||||
|
@ -257,6 +258,43 @@ namespace Revitalize.Framework.Crafting
|
|||
}
|
||||
|
||||
InitializeRecipeBooks();
|
||||
|
||||
|
||||
for(int bookIndex=0;bookIndex<CraftingRecipesByGroup.Count;bookIndex++)
|
||||
{
|
||||
|
||||
KeyValuePair<string, CraftingRecipeBook> pair = CraftingRecipesByGroup.ElementAt(bookIndex);
|
||||
for(int recipeIndex=0;recipeIndex<pair.Value.craftingRecipes.Count;recipeIndex++)
|
||||
{
|
||||
KeyValuePair<string, UnlockableCraftingRecipe> recipe = pair.Value.craftingRecipes.ElementAt(recipeIndex);
|
||||
for (int i = 0; i < recipe.Value.recipe.ingredients.Count; i++)
|
||||
{
|
||||
if (recipe.Value.recipe.ingredients[i].item is MultiTiledObject)
|
||||
{
|
||||
ModCore.log("Found a multi tiled object as an output!");
|
||||
//ModCore.log("Found a multi tiled object!");
|
||||
Type t = recipe.Value.recipe.ingredients[i].item.GetType();
|
||||
string id = (recipe.Value.recipe.ingredients[i].item as MultiTiledObject).info.id;
|
||||
recipe.Value.recipe.ingredients[i].item = ModCore.ObjectManager.getItemByIDAndType(id, t);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < recipe.Value.recipe.outputs.Count; i++)
|
||||
{
|
||||
if (recipe.Value.recipe.outputs[i].item is MultiTiledObject)
|
||||
{
|
||||
ModCore.log("Found a multi tiled object as an output!");
|
||||
//ModCore.log("Found a multi tiled object!");
|
||||
Type t = recipe.Value.recipe.outputs[i].item.GetType();
|
||||
string id = (recipe.Value.recipe.outputs[i].item as MultiTiledObject).info.id;
|
||||
recipe.Value.recipe.outputs[i].item = ModCore.ObjectManager.getItemByIDAndType(id, t);
|
||||
|
||||
ModCore.log("Components are: "+(recipe.Value.recipe.outputs[i].item as MultiTiledObject).objects.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void InitializeRecipeBooks()
|
||||
|
|
|
@ -19,15 +19,10 @@ namespace Revitalize.Framework.Crafting
|
|||
/// </summary>
|
||||
public List<CraftingRecipeComponent> outputs;
|
||||
|
||||
/// <summary>
|
||||
/// The item that is displayed for the crafting recipe.
|
||||
/// </summary>
|
||||
private Item displayItem;
|
||||
|
||||
public Item DisplayItem
|
||||
{
|
||||
get => this.displayItem ?? this.outputs.ElementAt(0).item;
|
||||
set => this.displayItem = value;
|
||||
get => this.outputs.ElementAt(0).item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -57,7 +52,6 @@ namespace Revitalize.Framework.Crafting
|
|||
public Recipe(List<CraftingRecipeComponent> inputs, CraftingRecipeComponent output, StatCost StatCost = null,int TimeToCraft=0)
|
||||
{
|
||||
this.ingredients = inputs;
|
||||
this.DisplayItem = output.item;
|
||||
this.outputDescription = output.item.getDescription();
|
||||
this.outputName = output.item.DisplayName;
|
||||
this.outputs = new List<CraftingRecipeComponent>()
|
||||
|
@ -74,7 +68,6 @@ namespace Revitalize.Framework.Crafting
|
|||
this.outputs = outputs;
|
||||
this.outputName = OutputName;
|
||||
this.outputDescription = OutputDescription;
|
||||
this.DisplayItem = DisplayItem;
|
||||
this.statCost = StatCost ?? new StatCost();
|
||||
this.timeToCraft = TimeToCraft;
|
||||
}
|
||||
|
|
|
@ -213,7 +213,10 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16)+new Vector2(32,32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow);
|
||||
{
|
||||
//ModCore.log(location + (pair.Key * 16) + new Vector2(32, 32));
|
||||
pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16) + new Vector2(32, 32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow);
|
||||
}
|
||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow);
|
||||
}
|
||||
|
||||
|
@ -366,7 +369,7 @@ namespace Revitalize.Framework.Objects
|
|||
Dictionary<Vector2, MultiTiledComponent> objs = new Dictionary<Vector2, MultiTiledComponent>();
|
||||
foreach (var pair in this.objects)
|
||||
{
|
||||
objs.Add(pair.Key, (MultiTiledComponent)pair.Value);
|
||||
objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne());
|
||||
}
|
||||
return new MultiTiledObject(this.data, this.info.Copy(), this.TileLocation, objs);
|
||||
}
|
||||
|
|
|
@ -356,13 +356,13 @@ namespace Revitalize.Framework.Objects
|
|||
/// <param name="Key"></param>
|
||||
/// <param name="Stack"></param>
|
||||
/// <returns></returns>
|
||||
public CustomObject GetItem(string Key,int Stack=1)
|
||||
public Item GetItem(string Key,int Stack=1)
|
||||
{
|
||||
if (this.ItemsByName.ContainsKey(Key))
|
||||
{
|
||||
Item I= this.ItemsByName[Key].getOne();
|
||||
I.Stack = Stack;
|
||||
return (CustomObject)I;
|
||||
return I;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -330,20 +330,16 @@ namespace Revitalize
|
|||
*/
|
||||
if (e.Button == SButton.U)
|
||||
{
|
||||
MultiTiledObject test =(MultiTiledObject) ObjectManager.GetItem("SandBox");
|
||||
test.EnergyManager.maxEnergy = 100;
|
||||
test.EnergyManager.produceEnergy(100);
|
||||
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);
|
||||
CraftingMenuV1 craftingMenu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items);
|
||||
|
||||
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);
|
||||
machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting 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), craftingMenu, true);
|
||||
|
||||
|
||||
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = machineMenu;
|
||||
CraftingMenuV1 craft = new CraftingMenuV1(100, 100, 600, 800, Color.White, Game1.player.Items);
|
||||
craft.addInCraftingPageTab("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));
|
||||
craft.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new List<CraftingRecipeComponent>()
|
||||
{
|
||||
//Inputs here
|
||||
new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20)
|
||||
}, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)),null,new Vector2(),new Rectangle(0,0,32,32),1f,false,Color.White),"Default");
|
||||
craft.currentTab = "Default";
|
||||
craft.sortRecipes();
|
||||
Game1.activeClickableMenu = craft;
|
||||
}
|
||||
/*
|
||||
if (e.Button == SButton.Y)
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
|
|||
{
|
||||
//this.background.draw(b);
|
||||
//if(this.item!=null)this.item.drawInMenu(b, this.position, this.scale);
|
||||
this.draw(b, 1f, Alpha, false);
|
||||
this.draw(b, 0f, Alpha, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,11 +122,10 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
|
|||
public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow)
|
||||
{
|
||||
if(this.background!=null)this.background.draw(b, this.scale, Depth,Alpha);
|
||||
if (this.item == null)
|
||||
if (this.item != null)
|
||||
{
|
||||
ModCore.log("ITEM IS NULL!!!!");
|
||||
this.item.drawInMenu(b, this.position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow);
|
||||
}
|
||||
if(this.item!=null)this.item.drawInMenu(b, this.position, 1f,Alpha,Depth,this.drawStackNumber,this.drawColor,DrawShadow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -140,10 +139,9 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
|
|||
public void draw(SpriteBatch b,Vector2 Position ,float Depth, float Alpha, bool DrawShadow)
|
||||
{
|
||||
if (this.background != null) this.background.draw(b,Position,this.scale, Depth, Alpha);
|
||||
if (this.item != null) this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow);
|
||||
if (this.item == null)
|
||||
if (this.item != null)
|
||||
{
|
||||
ModCore.log("ITEM IS NULL!!!!");
|
||||
this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,10 +149,6 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
|
|||
{
|
||||
this.background.draw(b, this.scale, Depth, Alpha);
|
||||
if (this.item != null) this.item.drawInMenu(b, this.position, ItemScale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow);
|
||||
if (this.item == null)
|
||||
{
|
||||
ModCore.log("ITEM IS NULL!!!!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -167,10 +161,6 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
|
|||
/// <param name="DrawShadow">Should the shadow be drawn for the item?</param>
|
||||
public void drawJustItem(SpriteBatch b,float Scale,float Depth, float Alpha, bool DrawShadow)
|
||||
{
|
||||
if (this.item == null)
|
||||
{
|
||||
ModCore.log("ITEM IS NULL!!!!");
|
||||
}
|
||||
if (this.item != null) this.item.drawInMenu(b, this.position, Scale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue