Files
OldThink/Content.Client/Lathe/UI/LatheQueueMenu.cs

115 lines
3.2 KiB
C#
Raw Normal View History

2021-06-09 22:19:39 +02:00
using Content.Shared.Research.Prototypes;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility;
2021-02-21 12:38:56 +01:00
using Robust.Shared.Localization;
using Robust.Shared.ViewVariables;
using static Robust.Client.UserInterface.Controls.BoxContainer;
2021-06-09 22:19:39 +02:00
namespace Content.Client.Lathe.UI
{
public sealed class LatheQueueMenu : DefaultWindow
{
public LatheBoundUserInterface Owner { get; set; }
[ViewVariables]
private readonly ItemList _queueList;
private readonly Label _nameLabel;
private readonly Label _description;
private readonly TextureRect _icon;
public LatheQueueMenu(LatheBoundUserInterface owner)
{
Owner = owner;
2021-02-21 12:38:56 +01:00
SetSize = MinSize = (300, 450);
Title = Loc.GetString("lathequeue-menu-title");
var vBox = new BoxContainer
{
Orientation = LayoutOrientation.Vertical
};
var hBox = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
2021-02-21 12:38:56 +01:00
HorizontalExpand = true,
SizeFlagsStretchRatio = 2,
};
_icon = new TextureRect()
{
2021-02-21 12:38:56 +01:00
HorizontalExpand = true,
SizeFlagsStretchRatio = 2,
};
var vBoxInfo = new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
2021-02-21 12:38:56 +01:00
VerticalExpand = true,
SizeFlagsStretchRatio = 3,
};
_nameLabel = new Label()
{
RectClipContent = true,
};
_description = new Label()
{
RectClipContent = true,
2021-02-21 12:38:56 +01:00
VerticalAlignment = VAlignment.Stretch,
VerticalExpand = true
};
_queueList = new ItemList()
{
2021-02-21 12:38:56 +01:00
VerticalExpand = true,
SizeFlagsStretchRatio = 3,
SelectMode = ItemList.ItemListSelectMode.None
};
vBoxInfo.AddChild(_nameLabel);
vBoxInfo.AddChild(_description);
hBox.AddChild(_icon);
2019-08-14 22:04:35 +02:00
hBox.AddChild(vBoxInfo);
2021-02-21 12:38:56 +01:00
vBox.AddChild(hBox);
vBox.AddChild(_queueList);
2021-02-21 12:38:56 +01:00
Contents.AddChild(vBox);
ClearInfo();
}
public void SetInfo(LatheRecipePrototype recipe)
{
_icon.Texture = recipe.Icon.Frame0();
if (recipe.Name != null)
_nameLabel.Text = recipe.Name;
if (recipe.Description != null)
_description.Text = recipe.Description;
}
public void ClearInfo()
{
_icon.Texture = Texture.Transparent;
_nameLabel.Text = "-------";
_description.Text = Loc.GetString("lathequeue-menu-not-producing-text");
}
public void PopulateList()
{
_queueList.Clear();
var idx = 1;
foreach (var recipe in Owner.QueuedRecipes)
{
_queueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0());
idx++;
}
}
}
}