Seperated Reagent item list and Solid item list to allow for vaporizing particular reagents at will. (also fixes a really nasty null reference exception because they shared the same list before D: )
This commit is contained in:
@@ -23,22 +23,33 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
private MicrowaveMenu _menu;
|
private MicrowaveMenu _menu;
|
||||||
|
|
||||||
private Dictionary<int, EntityUid> _solids = new Dictionary<int, EntityUid>();
|
private Dictionary<int, EntityUid> _solids = new Dictionary<int, EntityUid>();
|
||||||
|
private Dictionary<int, Solution.ReagentQuantity> _reagents =new Dictionary<int, Solution.ReagentQuantity>();
|
||||||
|
|
||||||
public MicrowaveBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner,uiKey)
|
public MicrowaveBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner,uiKey)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Open()
|
protected override void Open()
|
||||||
{
|
{
|
||||||
base.Open();
|
base.Open();
|
||||||
_menu = new MicrowaveMenu(this);
|
_menu = new MicrowaveMenu(this);
|
||||||
|
|
||||||
_menu.OpenCentered();
|
_menu.OpenCentered();
|
||||||
_menu.OnClose += Close;
|
_menu.OnClose += Close;
|
||||||
_menu.StartButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveStartCookMessage());
|
_menu.StartButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveStartCookMessage());
|
||||||
_menu.EjectButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveEjectMessage());
|
_menu.EjectButton.OnPressed += args => SendMessage(new SharedMicrowaveComponent.MicrowaveEjectMessage());
|
||||||
_menu.IngredientsList.OnItemSelected += args => SendMessage(new SharedMicrowaveComponent.MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex]));
|
_menu.IngredientsList.OnItemSelected += args =>
|
||||||
|
{
|
||||||
|
SendMessage(new SharedMicrowaveComponent.MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex]));
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
_menu.IngredientsListReagents.OnItemSelected += args =>
|
||||||
|
{
|
||||||
|
SendMessage(
|
||||||
|
new SharedMicrowaveComponent.MicrowaveVaporizeReagentIndexedMessage(_reagents[args.ItemIndex]));
|
||||||
|
};
|
||||||
|
|
||||||
_menu.OnCookTimeSelected += args =>
|
_menu.OnCookTimeSelected += args =>
|
||||||
{
|
{
|
||||||
var actualButton = args.Button as Button;
|
var actualButton = args.Button as Button;
|
||||||
@@ -76,25 +87,28 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
private void RefreshContentsDisplay(IReadOnlyList<Solution.ReagentQuantity> reagents, List<EntityUid> solids)
|
private void RefreshContentsDisplay(IReadOnlyList<Solution.ReagentQuantity> reagents, List<EntityUid> solids)
|
||||||
{
|
{
|
||||||
_menu.IngredientsList.Clear();
|
_reagents.Clear();
|
||||||
foreach (var item in reagents)
|
_menu.IngredientsListReagents.Clear();
|
||||||
|
foreach (var reagent in reagents)
|
||||||
{
|
{
|
||||||
_prototypeManager.TryIndex(item.ReagentId, out ReagentPrototype proto);
|
_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto);
|
||||||
|
var reagentAdded = _menu.IngredientsListReagents.AddItem($"{reagent.Quantity} {proto.Name}");
|
||||||
_menu.IngredientsList.AddItem($"{item.Quantity} {proto.Name}");
|
var reagentIndex = _menu.IngredientsListReagents.IndexOf(reagentAdded);
|
||||||
|
_reagents.Add(reagentIndex, reagent);
|
||||||
}
|
}
|
||||||
|
|
||||||
_solids.Clear();
|
_solids.Clear();
|
||||||
|
_menu.IngredientsList.Clear();
|
||||||
foreach (var entityID in solids)
|
foreach (var entityID in solids)
|
||||||
{
|
{
|
||||||
var entity = _entityManager.GetEntity(entityID);
|
var entity = _entityManager.GetEntity(entityID);
|
||||||
|
|
||||||
if (entity.TryGetComponent(out IconComponent icon))
|
if (entity.TryGetComponent(out IconComponent icon))
|
||||||
{
|
{
|
||||||
var itemItem = _menu.IngredientsList.AddItem(entity.Name, icon.Icon.Default);
|
var solidItem = _menu.IngredientsList.AddItem(entity.Name, icon.Icon.Default);
|
||||||
|
|
||||||
var index = _menu.IngredientsList.IndexOf(itemItem);
|
var solidIndex = _menu.IngredientsList.IndexOf(solidItem);
|
||||||
_solids.Add(index, entityID);
|
_solids.Add(solidIndex, entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
private VBoxContainer CookTimeButtonVbox { get; }
|
private VBoxContainer CookTimeButtonVbox { get; }
|
||||||
|
|
||||||
public ItemList IngredientsList { get;}
|
public ItemList IngredientsList { get;}
|
||||||
|
|
||||||
|
public ItemList IngredientsListReagents { get; }
|
||||||
private Label _cookTimeInfoLabel { get; }
|
private Label _cookTimeInfoLabel { get; }
|
||||||
|
|
||||||
public MicrowaveMenu(MicrowaveBoundUserInterface owner = null)
|
public MicrowaveMenu(MicrowaveBoundUserInterface owner = null)
|
||||||
@@ -39,16 +41,31 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
SizeFlagsVertical = SizeFlags.Fill
|
SizeFlagsVertical = SizeFlags.Fill
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IngredientsListReagents = new ItemList
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SelectMode = ItemList.ItemListSelectMode.Button,
|
||||||
|
SizeFlagsStretchRatio = 2,
|
||||||
|
CustomMinimumSize = (100,128)
|
||||||
|
};
|
||||||
|
|
||||||
IngredientsList = new ItemList
|
IngredientsList = new ItemList
|
||||||
{
|
{
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
SelectMode = ItemList.ItemListSelectMode.Button,
|
SelectMode = ItemList.ItemListSelectMode.Button,
|
||||||
SizeFlagsStretchRatio = 8,
|
SizeFlagsStretchRatio = 2,
|
||||||
CustomMinimumSize = (200,256)
|
CustomMinimumSize = (100,128)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hSplit.AddChild(IngredientsListReagents);
|
||||||
|
//Padding between the lists.
|
||||||
|
hSplit.AddChild(new Control
|
||||||
|
{
|
||||||
|
CustomMinimumSize = (0,5),
|
||||||
|
});
|
||||||
|
|
||||||
hSplit.AddChild(IngredientsList);
|
hSplit.AddChild(IngredientsList);
|
||||||
|
|
||||||
var vSplit = new VBoxContainer
|
var vSplit = new VBoxContainer
|
||||||
|
|||||||
@@ -145,7 +145,16 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
UpdateUserInterface();
|
UpdateUserInterface();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MicrowaveVaporizeReagentIndexedMessage msg:
|
||||||
|
if (HasContents)
|
||||||
|
{
|
||||||
|
_solution.TryRemoveReagent(msg.ReagentQuantity.ReagentId, msg.ReagentQuantity.Quantity);
|
||||||
|
ClickSound();
|
||||||
|
UpdateUserInterface();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case MicrowaveSelectCookTimeMessage msg:
|
case MicrowaveSelectCookTimeMessage msg:
|
||||||
_currentCookTimerTime = msg.newCookTime;
|
_currentCookTimerTime = msg.newCookTime;
|
||||||
ClickSound();
|
ClickSound();
|
||||||
@@ -305,7 +314,11 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
private void VaporizeReagents()
|
private void VaporizeReagents()
|
||||||
{
|
{
|
||||||
_solution.RemoveAllSolution();
|
_solution.RemoveAllSolution();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void VaporizeReagentWithIndex()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VaporizeSolids()
|
private void VaporizeSolids()
|
||||||
|
|||||||
@@ -41,6 +41,17 @@ namespace Content.Shared.Kitchen
|
|||||||
EntityID = entityID;
|
EntityID = entityID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public class MicrowaveVaporizeReagentIndexedMessage : BoundUserInterfaceMessage
|
||||||
|
{
|
||||||
|
|
||||||
|
public Solution.ReagentQuantity ReagentQuantity;
|
||||||
|
public MicrowaveVaporizeReagentIndexedMessage(Solution.ReagentQuantity reagentQuantity)
|
||||||
|
{
|
||||||
|
ReagentQuantity = reagentQuantity;
|
||||||
|
}
|
||||||
|
}
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage
|
public class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user