Lathes (#207)
* Recipe stuff. * Lathe GUI and stuff * god dammit * Lathe menu works, yay. * EventArgs henk * Some work * SS14 -> Robust * More SS14 -> Robust * Lathe materials * Lathe works, Lathe GUI, Queue GUI, etc too many changes to name them here * Remove materials button, add ViewVariables and update lathe on connect * Add Autolathe RSI * Adds new recipes, fixes a few bugs. * Remove unused ScrollContainers * Use same delegate for spawn. * Removes client-side LatheComponent in favor of BoundUserInterface * Remove GetMaterial and TryGetMaterial * Use auto-properties in a few places. * Adds LatheDatabase, and a bunch of other changes * Remove useless log. * Remove lathetype from prototypes. * Turns Storage, Lathe and Database into autoproperties * Remove Hacked property from LatheRecipePrototype * Remove unneeded dependency injection from components * Refactors LatheDatabaseComponent to use ComponentState * Refactors MaterialStorageComponent to use ComponentState * Oopsie * Another oopsie * Last oopsie, I hope * Fix missing Close call.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
092539ae59
commit
fe0414eda7
@@ -86,6 +86,9 @@
|
||||
<Compile Include="GameObjects\Components\Items\ItemComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\ApcBoundUserInterface.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\PowerCellVisualizer2D.cs" />
|
||||
<Compile Include="GameObjects\Components\Research\LatheBoundUserInterface.cs" />
|
||||
<Compile Include="GameObjects\Components\Research\LatheDatabaseComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Research\MaterialStorageComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Sound\SoundComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Storage\ClientStorageComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\SubFloorHideComponent.cs" />
|
||||
@@ -114,6 +117,8 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="GameObjects\Components\Items\ClientHandsComponent.cs" />
|
||||
<Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" />
|
||||
<Compile Include="Research\LatheMenu.cs" />
|
||||
<Compile Include="Research\LatheQueueMenu.cs" />
|
||||
<Compile Include="UserInterface\HandsGui.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\PowerDebugTool.cs" />
|
||||
<Compile Include="UserInterface\LobbyGui.cs" />
|
||||
|
||||
@@ -28,11 +28,15 @@ using System;
|
||||
using Content.Client.Chat;
|
||||
using Content.Client.GameObjects.Components;
|
||||
using Content.Client.GameObjects.Components.Mobs;
|
||||
using Content.Client.GameObjects.Components.Research;
|
||||
using Content.Client.GameObjects.Components.Sound;
|
||||
using Content.Client.Interfaces.Chat;
|
||||
using Content.Client.Research;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.GameObjects.Components.Markers;
|
||||
using Content.Shared.GameObjects.Components.Materials;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Research;
|
||||
using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Shared.Log;
|
||||
|
||||
@@ -72,7 +76,6 @@ namespace Content.Client
|
||||
|
||||
factory.RegisterIgnore("Storeable");
|
||||
|
||||
factory.RegisterIgnore("Material");
|
||||
factory.RegisterIgnore("Stack");
|
||||
|
||||
factory.Register<HandsComponent>();
|
||||
@@ -86,7 +89,10 @@ namespace Content.Client
|
||||
factory.Register<DamageableComponent>();
|
||||
factory.Register<ClothingComponent>();
|
||||
factory.Register<ItemComponent>();
|
||||
factory.Register<MaterialComponent>();
|
||||
factory.Register<SoundComponent>();
|
||||
factory.Register<MaterialStorageComponent>();
|
||||
factory.RegisterReference<MaterialStorageComponent, SharedMaterialStorageComponent>();
|
||||
|
||||
factory.RegisterReference<ClothingComponent, ItemComponent>();
|
||||
|
||||
@@ -114,6 +120,11 @@ namespace Content.Client
|
||||
|
||||
factory.Register<SharedSpawnPointComponent>();
|
||||
|
||||
factory.Register<SharedLatheComponent>();
|
||||
factory.Register<LatheDatabaseComponent>();
|
||||
|
||||
factory.RegisterReference<LatheDatabaseComponent, SharedLatheDatabaseComponent>();
|
||||
|
||||
factory.Register<CameraRecoilComponent>();
|
||||
factory.RegisterReference<CameraRecoilComponent, SharedCameraRecoilComponent>();
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.Research;
|
||||
using Content.Shared.GameObjects.Components.Research;
|
||||
using Content.Shared.Research;
|
||||
using Robust.Client.GameObjects.Components.UserInterface;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Research
|
||||
{
|
||||
public class LatheBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
[Dependency]
|
||||
private IDisplayManager _displayManager;
|
||||
[Dependency]
|
||||
private IPrototypeManager _prototypeManager;
|
||||
#pragma warning restore
|
||||
[ViewVariables]
|
||||
private LatheMenu menu;
|
||||
[ViewVariables]
|
||||
private LatheQueueMenu queueMenu;
|
||||
|
||||
public MaterialStorageComponent Storage { get; private set; }
|
||||
public SharedLatheComponent Lathe { get; private set; }
|
||||
public LatheDatabaseComponent Database { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public Queue<LatheRecipePrototype> QueuedRecipes => _queuedRecipes;
|
||||
private Queue<LatheRecipePrototype> _queuedRecipes = new Queue<LatheRecipePrototype>();
|
||||
|
||||
public LatheBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
SendMessage(new SharedLatheComponent.LatheSyncRequestMessage());
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
if (!Owner.Owner.TryGetComponent(out MaterialStorageComponent storage)
|
||||
|| !Owner.Owner.TryGetComponent(out SharedLatheComponent lathe)
|
||||
|| !Owner.Owner.TryGetComponent(out LatheDatabaseComponent database)) return;
|
||||
|
||||
Storage = storage;
|
||||
Lathe = lathe;
|
||||
Database = database;
|
||||
|
||||
menu = new LatheMenu(_displayManager) {Owner = this};
|
||||
queueMenu = new LatheQueueMenu(_displayManager) { Owner = this };
|
||||
|
||||
menu.OnClose += Close;
|
||||
|
||||
menu.AddToScreen();
|
||||
menu.Populate();
|
||||
menu.PopulateMaterials();
|
||||
queueMenu.AddToScreen();
|
||||
|
||||
menu.QueueButton.OnPressed += (args) => { queueMenu.OpenCentered(); };
|
||||
|
||||
storage.OnMaterialStorageChanged += menu.PopulateDisabled;
|
||||
storage.OnMaterialStorageChanged += menu.PopulateMaterials;
|
||||
|
||||
menu.OpenCentered();
|
||||
}
|
||||
|
||||
public void Queue(LatheRecipePrototype recipe, int quantity = 1)
|
||||
{
|
||||
SendMessage(new SharedLatheComponent.LatheQueueRecipeMessage(recipe.ID, quantity));
|
||||
}
|
||||
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case SharedLatheComponent.LatheProducingRecipeMessage msg:
|
||||
if (!_prototypeManager.TryIndex(msg.ID, out LatheRecipePrototype recipe)) break;
|
||||
queueMenu.SetInfo(recipe);
|
||||
break;
|
||||
case SharedLatheComponent.LatheStoppedProducingRecipeMessage msg:
|
||||
queueMenu.ClearInfo();
|
||||
break;
|
||||
case SharedLatheComponent.LatheFullQueueMessage msg:
|
||||
_queuedRecipes.Clear();
|
||||
foreach (var id in msg.Recipes)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(id, out LatheRecipePrototype recipePrototype)) break;
|
||||
_queuedRecipes.Enqueue(recipePrototype);
|
||||
}
|
||||
queueMenu.PopulateList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing) return;
|
||||
menu?.Dispose();
|
||||
queueMenu?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Content.Shared.GameObjects.Components.Research;
|
||||
using Content.Shared.Research;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Research
|
||||
{
|
||||
public class LatheDatabaseComponent : SharedLatheDatabaseComponent
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
[Dependency]
|
||||
private IPrototypeManager _prototypeManager;
|
||||
#pragma warning restore
|
||||
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
if (!(curState is LatheDatabaseState state)) return;
|
||||
Clear();
|
||||
foreach (var ID in state.Recipes)
|
||||
{
|
||||
if(!_prototypeManager.TryIndex(ID, out LatheRecipePrototype recipe)) continue;
|
||||
AddRecipe(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects.Components.Research;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Research
|
||||
{
|
||||
public class MaterialStorageComponent : SharedMaterialStorageComponent
|
||||
{
|
||||
protected override Dictionary<string, int> Storage { get; set; } = new Dictionary<string, int>();
|
||||
|
||||
public event Action OnMaterialStorageChanged;
|
||||
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
if (!(curState is MaterialStorageState state)) return;
|
||||
Storage = state.Storage;
|
||||
OnMaterialStorageChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
255
Content.Client/Research/LatheMenu.cs
Normal file
255
Content.Client/Research/LatheMenu.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components.Research;
|
||||
using Content.Shared.Materials;
|
||||
using Content.Shared.Research;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timers;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Research
|
||||
{
|
||||
public class LatheMenu : SS14Window
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
[Dependency]
|
||||
private IPrototypeManager PrototypeManager;
|
||||
[Dependency]
|
||||
private IResourceCache ResourceCache;
|
||||
#pragma warning restore
|
||||
|
||||
private ItemList Items;
|
||||
private ItemList Materials;
|
||||
private LineEdit AmountLineEdit;
|
||||
private LineEdit SearchBar;
|
||||
public Button QueueButton;
|
||||
protected override Vector2? CustomSize => (300, 450);
|
||||
|
||||
public LatheBoundUserInterface Owner { get; set; }
|
||||
|
||||
private List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
|
||||
private List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>();
|
||||
|
||||
public LatheMenu(IDisplayManager displayMan) : base(displayMan)
|
||||
{
|
||||
}
|
||||
|
||||
public LatheMenu(IDisplayManager displayMan, string name) : base(displayMan, name)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
HideOnClose = true;
|
||||
Title = "Lathe Menu";
|
||||
Visible = false;
|
||||
|
||||
var margin = new MarginContainer()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
MarginTop = 5f,
|
||||
MarginLeft = 5f,
|
||||
MarginRight = -5f,
|
||||
MarginBottom = -5f,
|
||||
};
|
||||
|
||||
margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);
|
||||
|
||||
var vbox = new VBoxContainer()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SeparationOverride = 5,
|
||||
};
|
||||
|
||||
vbox.SetAnchorAndMarginPreset(LayoutPreset.Wide);
|
||||
|
||||
var hboxButtons = new HBoxContainer()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1,
|
||||
};
|
||||
|
||||
QueueButton = new Button()
|
||||
{
|
||||
Text = "Queue",
|
||||
TextAlign = Button.AlignMode.Center,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1,
|
||||
};
|
||||
|
||||
var spacer = new Control()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 3,
|
||||
};
|
||||
|
||||
spacer.SetAnchorAndMarginPreset(LayoutPreset.Wide);
|
||||
|
||||
var hboxFilter = new HBoxContainer()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1
|
||||
};
|
||||
|
||||
SearchBar = new LineEdit()
|
||||
{
|
||||
PlaceHolder = "Search Designs",
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 3
|
||||
};
|
||||
|
||||
SearchBar.OnTextChanged += Populate;
|
||||
|
||||
var filterButton = new Button()
|
||||
{
|
||||
Text = "Filter",
|
||||
TextAlign = Button.AlignMode.Center,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1,
|
||||
Disabled = true,
|
||||
};
|
||||
|
||||
Items = new ItemList()
|
||||
{
|
||||
SizeFlagsStretchRatio = 8,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
};
|
||||
|
||||
|
||||
|
||||
Items.OnItemSelected += ItemSelected;
|
||||
|
||||
AmountLineEdit = new LineEdit()
|
||||
{
|
||||
PlaceHolder = "Amount",
|
||||
Text = "1",
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
};
|
||||
|
||||
AmountLineEdit.OnTextChanged += PopulateDisabled;
|
||||
|
||||
Materials = new ItemList()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 3
|
||||
};
|
||||
|
||||
hboxButtons.AddChild(spacer);
|
||||
hboxButtons.AddChild(QueueButton);
|
||||
|
||||
hboxFilter.AddChild(SearchBar);
|
||||
hboxFilter.AddChild(filterButton);
|
||||
|
||||
vbox.AddChild(hboxButtons);
|
||||
vbox.AddChild(hboxFilter);
|
||||
vbox.AddChild(Items);
|
||||
vbox.AddChild(AmountLineEdit);
|
||||
vbox.AddChild(Materials);
|
||||
|
||||
margin.AddChild(vbox);
|
||||
|
||||
Contents.AddChild(margin);
|
||||
}
|
||||
|
||||
public void ItemSelected(ItemList.ItemListSelectedEventArgs args)
|
||||
{
|
||||
int.TryParse(AmountLineEdit.Text, out var quantity);
|
||||
if (quantity <= 0) quantity = 1;
|
||||
Owner.Queue(_shownRecipes[args.ItemIndex], quantity);
|
||||
Items.SelectMode = ItemList.ItemListSelectMode.None;
|
||||
Timer.Spawn(100, () =>
|
||||
{
|
||||
Items.Unselect(args.ItemIndex);
|
||||
Items.SelectMode = ItemList.ItemListSelectMode.Single;
|
||||
});
|
||||
}
|
||||
|
||||
public void PopulateMaterials()
|
||||
{
|
||||
Materials.Clear();
|
||||
|
||||
foreach (var (id, amount) in Owner.Storage)
|
||||
{
|
||||
if (!PrototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue;
|
||||
var material = materialPrototype.Material;
|
||||
Materials.AddItem($"{material.Name} {amount} cm3", material.Icon.Frame0(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables or enables shown recipes depending on whether there are enough materials for it or not.
|
||||
/// </summary>
|
||||
public void PopulateDisabled()
|
||||
{
|
||||
int.TryParse(AmountLineEdit.Text, out var quantity);
|
||||
if (quantity <= 0) quantity = 1;
|
||||
for (var i = 0; i < _shownRecipes.Count; i++)
|
||||
{
|
||||
var prototype = _shownRecipes[i];
|
||||
Items.SetItemDisabled(i, !Owner.Lathe.CanProduce(prototype, quantity));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="PopulateDisabled()"/>
|
||||
public void PopulateDisabled(LineEdit.LineEditEventArgs args)
|
||||
{
|
||||
PopulateDisabled();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds shown recipes to the ItemList control.
|
||||
/// </summary>
|
||||
public void PopulateList()
|
||||
{
|
||||
Items.Clear();
|
||||
for (var i = 0; i < _shownRecipes.Count; i++)
|
||||
{
|
||||
var prototype = _shownRecipes[i];
|
||||
Items.AddItem(prototype.Name, prototype.Icon.Frame0());
|
||||
}
|
||||
|
||||
PopulateDisabled();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populates the list of recipes that will actually be shown, using the current filters.
|
||||
/// </summary>
|
||||
public void Populate()
|
||||
{
|
||||
_shownRecipes.Clear();
|
||||
|
||||
foreach (var prototype in Owner.Database)
|
||||
{
|
||||
if (SearchBar.Text.Trim().Length != 0)
|
||||
{
|
||||
if (prototype.Name.ToLowerInvariant().Contains(SearchBar.Text.Trim().ToLowerInvariant()))
|
||||
_shownRecipes.Add(prototype);
|
||||
continue;
|
||||
}
|
||||
|
||||
_shownRecipes.Add(prototype);
|
||||
}
|
||||
|
||||
PopulateList();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Populate"/>
|
||||
public void Populate(LineEdit.LineEditEventArgs args)
|
||||
{
|
||||
Populate();
|
||||
}
|
||||
}
|
||||
}
|
||||
149
Content.Client/Research/LatheQueueMenu.cs
Normal file
149
Content.Client/Research/LatheQueueMenu.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
using Content.Client.GameObjects.Components.Research;
|
||||
using Content.Shared.Research;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.Research
|
||||
{
|
||||
public class LatheQueueMenu : SS14Window
|
||||
{
|
||||
protected override Vector2? CustomSize => (300, 450);
|
||||
|
||||
public LatheBoundUserInterface Owner { get; set; }
|
||||
|
||||
[ViewVariables]
|
||||
private ItemList QueueList;
|
||||
private Label Name;
|
||||
private Label Description;
|
||||
private TextureRect Icon;
|
||||
|
||||
public LatheQueueMenu(IDisplayManager displayManager) : base(displayManager)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
HideOnClose = true;
|
||||
Title = "Lathe Queue";
|
||||
Visible = false;
|
||||
|
||||
var margin = new MarginContainer()
|
||||
{
|
||||
MarginTop = 5f,
|
||||
MarginLeft = 5f,
|
||||
MarginRight = -5f,
|
||||
MarginBottom = -5f,
|
||||
};
|
||||
|
||||
margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);
|
||||
|
||||
var vbox = new VBoxContainer();
|
||||
|
||||
vbox.SetAnchorAndMarginPreset(LayoutPreset.Wide);
|
||||
|
||||
var descMargin = new MarginContainer()
|
||||
{
|
||||
MarginTop = 5f,
|
||||
MarginLeft = 5f,
|
||||
MarginRight = -5f,
|
||||
MarginBottom = -5f,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 2,
|
||||
};
|
||||
|
||||
var hbox = new HBoxContainer()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
};
|
||||
|
||||
Icon = new TextureRect()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 2,
|
||||
};
|
||||
|
||||
var vboxInfo = new VBoxContainer()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 3,
|
||||
};
|
||||
|
||||
Name = new Label()
|
||||
{
|
||||
RectClipContent = true,
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
};
|
||||
|
||||
Description = new Label()
|
||||
{
|
||||
RectClipContent = true,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
|
||||
};
|
||||
|
||||
QueueList = new ItemList()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 3,
|
||||
SelectMode = ItemList.ItemListSelectMode.None
|
||||
};
|
||||
|
||||
vboxInfo.AddChild(Name);
|
||||
vboxInfo.AddChild(Description);
|
||||
|
||||
hbox.AddChild(Icon);
|
||||
hbox.AddChild(vboxInfo);
|
||||
|
||||
descMargin.AddChild(hbox);
|
||||
|
||||
vbox.AddChild(descMargin);
|
||||
vbox.AddChild(QueueList);
|
||||
|
||||
margin.AddChild(vbox);
|
||||
|
||||
Contents.AddChild(margin);
|
||||
|
||||
ClearInfo();
|
||||
}
|
||||
|
||||
public void SetInfo(LatheRecipePrototype recipe)
|
||||
{
|
||||
Icon.Texture = recipe.Icon.Frame0();
|
||||
if (recipe.Name != null)
|
||||
Name.Text = recipe.Name;
|
||||
if (recipe.Description != null)
|
||||
Description.Text = recipe.Description;
|
||||
}
|
||||
|
||||
public void ClearInfo()
|
||||
{
|
||||
Icon.Texture = Texture.Transparent;
|
||||
Name.Text = "-------";
|
||||
Description.Text = "Not producing anything.";
|
||||
}
|
||||
|
||||
public void PopulateList()
|
||||
{
|
||||
QueueList.Clear();
|
||||
var idx = 1;
|
||||
foreach (var recipe in Owner.QueuedRecipes)
|
||||
{
|
||||
QueueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0(), false);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user