Files
crystall-punk-14/Content.Client/Research/LatheQueueMenu.cs

137 lines
3.7 KiB
C#
Raw Normal View History

using Content.Client.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility;
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;
2019-04-29 13:12:50 +02:00
private Label NameLabel;
private Label Description;
private TextureRect Icon;
2019-08-14 22:04:35 +02:00
public LatheQueueMenu()
{
2019-08-14 22:04:35 +02:00
Title = "Lathe Queue";
var margin = new MarginContainer()
{
/*MarginTop = 5f,
MarginLeft = 5f,
MarginRight = -5f,
MarginBottom = -5f,*/
};
// margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);
2019-08-14 22:04:35 +02:00
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,
};
2019-08-14 22:04:35 +02:00
var hBox = new HBoxContainer()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
};
Icon = new TextureRect()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 2,
};
2019-08-14 22:04:35 +02:00
var vBoxInfo = new VBoxContainer()
{
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 3,
};
2019-04-29 13:12:50 +02:00
NameLabel = 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
};
2019-08-14 22:04:35 +02:00
vBoxInfo.AddChild(NameLabel);
vBoxInfo.AddChild(Description);
2019-08-14 22:04:35 +02:00
hBox.AddChild(Icon);
hBox.AddChild(vBoxInfo);
2019-08-14 22:04:35 +02:00
descMargin.AddChild(hBox);
2019-08-14 22:04:35 +02:00
vBox.AddChild(descMargin);
vBox.AddChild(QueueList);
2019-08-14 22:04:35 +02:00
margin.AddChild(vBox);
Contents.AddChild(margin);
ClearInfo();
}
public void SetInfo(LatheRecipePrototype recipe)
{
Icon.Texture = recipe.Icon.Frame0();
if (recipe.Name != null)
2019-04-29 13:12:50 +02:00
NameLabel.Text = recipe.Name;
if (recipe.Description != null)
Description.Text = recipe.Description;
}
public void ClearInfo()
{
Icon.Texture = Texture.Transparent;
2019-04-29 13:12:50 +02:00
NameLabel.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());
idx++;
}
}
}
}