UI system refactor; submodule update.

This commit is contained in:
Pieter-Jan Briers
2019-08-14 22:04:35 +02:00
parent 6be135a137
commit 9cb37a6376
12 changed files with 150 additions and 199 deletions

View File

@@ -24,12 +24,12 @@ namespace Content.Client.Chat
private ILocalizationManager localize = IoCManager.Resolve<ILocalizationManager>(); private ILocalizationManager localize = IoCManager.Resolve<ILocalizationManager>();
public LineEdit Input { get; private set; } public LineEdit Input { get; private set; }
public OutputPanel contents; public OutputPanel Contents { get; }
// Buttons for filtering // Buttons for filtering
public Button AllButton; public Button AllButton { get; }
public Button LocalButton; public Button LocalButton { get; }
public Button OOCButton; public Button OOCButton { get; }
/// <summary> /// <summary>
/// Index while cycling through the input history. -1 means not going through history. /// Index while cycling through the input history. -1 means not going through history.
@@ -48,10 +48,8 @@ namespace Content.Client.Chat
public bool ReleaseFocusOnEnter { get; set; } = true; public bool ReleaseFocusOnEnter { get; set; } = true;
protected override void Initialize() public ChatBox()
{ {
base.Initialize();
MarginLeft = -475.0f; MarginLeft = -475.0f;
MarginTop = 10.0f; MarginTop = 10.0f;
MarginRight = -10.0f; MarginRight = -10.0f;
@@ -79,8 +77,8 @@ namespace Content.Client.Chat
MarginLeftOverride = 4, MarginRightOverride = 4, MarginLeftOverride = 4, MarginRightOverride = 4,
SizeFlagsVertical = SizeFlags.FillExpand SizeFlagsVertical = SizeFlags.FillExpand
}; };
contents = new OutputPanel(); Contents = new OutputPanel();
contentMargin.AddChild(contents); contentMargin.AddChild(Contents);
vBox.AddChild(contentMargin); vBox.AddChild(contentMargin);
Input = new LineEdit(); Input = new LineEdit();
@@ -176,18 +174,6 @@ namespace Content.Client.Chat
} }
} }
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
TextSubmitted = null;
Input = null;
contents = null;
}
}
public event TextSubmitHandler TextSubmitted; public event TextSubmitHandler TextSubmitted;
public event FilterToggledHandler FilterToggled; public event FilterToggledHandler FilterToggled;
@@ -203,7 +189,7 @@ namespace Content.Client.Chat
formatted.PushColor(color); formatted.PushColor(color);
formatted.AddText(message); formatted.AddText(message);
formatted.Pop(); formatted.Pop();
contents.AddMessage(formatted); Contents.AddMessage(formatted);
} }
private void Input_OnTextEntered(LineEdit.LineEditEventArgs args) private void Input_OnTextEntered(LineEdit.LineEditEventArgs args)

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Client.Interfaces.Chat; using Content.Client.Interfaces.Chat;
using Content.Shared.Chat; using Content.Shared.Chat;
using Robust.Client;
using Robust.Client.Console; using Robust.Client.Console;
using Robust.Client.Interfaces.Graphics.ClientEye; using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.UserInterface; using Robust.Client.Interfaces.UserInterface;
@@ -274,7 +273,7 @@ namespace Content.Client.Chat
private void RepopulateChat(IEnumerable<StoredChatMessage> filteredMessages) private void RepopulateChat(IEnumerable<StoredChatMessage> filteredMessages)
{ {
_currentChatBox.contents.Clear(); _currentChatBox.Contents.Clear();
foreach (var msg in filteredMessages) foreach (var msg in filteredMessages)
{ {

View File

@@ -1,5 +1,4 @@
using Content.Client.Interfaces.Chat; using Content.Client.Interfaces.Chat;
using Robust.Client;
using Robust.Client.Interfaces.Graphics.ClientEye; using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
@@ -32,14 +31,14 @@ namespace Content.Client.Chat
private readonly IEntity _senderEntity; private readonly IEntity _senderEntity;
private readonly IChatManager _chatManager; private readonly IChatManager _chatManager;
private Control _panel; private readonly Control _panel;
private float _timeLeft = TotalTime; private float _timeLeft = TotalTime;
public float VerticalOffset { get; set; } public float VerticalOffset { get; set; }
private float _verticalOffsetAchieved; private float _verticalOffsetAchieved;
public float ContentHeight { get; } public float ContentHeight { get; private set; }
public SpeechBubble(string text, IEntity senderEntity, IEyeManager eyeManager, IChatManager chatManager) public SpeechBubble(string text, IEntity senderEntity, IEyeManager eyeManager, IChatManager chatManager)
{ {
@@ -68,6 +67,8 @@ namespace Content.Client.Chat
AddChild(_panel); AddChild(_panel);
ForceRunStyleUpdate();
_panel.Size = _panel.CombinedMinimumSize; _panel.Size = _panel.CombinedMinimumSize;
ContentHeight = _panel.Height; ContentHeight = _panel.Height;
Size = (_panel.Width, 0); Size = (_panel.Width, 0);

View File

@@ -85,14 +85,11 @@ namespace Content.Client
private float _timeLeft; private float _timeLeft;
public Vector2 InitialPos { get; set; } public Vector2 InitialPos { get; set; }
protected override void Initialize() public PopupLabel()
{ {
base.Initialize();
ShadowOffsetXOverride = 1; ShadowOffsetXOverride = 1;
ShadowOffsetYOverride = 1; ShadowOffsetYOverride = 1;
FontColorShadowOverride = Color.Black; FontColorShadowOverride = Color.Black;
} }
public void Update(FrameEventArgs eventArgs) public void Update(FrameEventArgs eventArgs)

View File

@@ -3,62 +3,50 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Client.GameObjects.Components.Construction; using Content.Client.GameObjects.Components.Construction;
using Content.Shared.Construction; using Content.Shared.Construction;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.Interfaces.Placement; using Robust.Client.Interfaces.Placement;
using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Placement; using Robust.Client.Placement;
using Robust.Client.ResourceManagement; using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility; using Robust.Client.Utility;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Interfaces.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Client.Construction namespace Content.Client.Construction
{ {
public class ConstructionMenu : SS14Window public class ConstructionMenu : SS14Window
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649
[Dependency] [Dependency] readonly IPrototypeManager PrototypeManager;
readonly IPrototypeManager PrototypeManager; [Dependency] readonly IResourceCache ResourceCache;
[Dependency]
readonly IResourceCache ResourceCache;
#pragma warning restore #pragma warning restore
public ConstructorComponent Owner { get; set; } public ConstructorComponent Owner { get; set; }
Button BuildButton; private readonly Button BuildButton;
Button EraseButton; private readonly Button EraseButton;
LineEdit SearchBar; private readonly LineEdit SearchBar;
Tree RecipeList; private readonly Tree RecipeList;
TextureRect InfoIcon; private readonly TextureRect InfoIcon;
Label InfoLabel; private readonly Label InfoLabel;
ItemList StepList; private readonly ItemList StepList;
private CategoryNode RootCategory;
CategoryNode RootCategory;
// This list is flattened in such a way that the top most deepest category is first. // This list is flattened in such a way that the top most deepest category is first.
List<CategoryNode> FlattenedCategories; private List<CategoryNode> FlattenedCategories;
PlacementManager Placement; private readonly PlacementManager Placement;
public ConstructionMenu() public ConstructionMenu()
{ {
Size = new Vector2(500.0f, 350.0f); Size = (500, 350);
}
protected override void Initialize()
{
base.Initialize();
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
Placement = (PlacementManager)IoCManager.Resolve<IPlacementManager>(); Placement = (PlacementManager) IoCManager.Resolve<IPlacementManager>();
Placement.PlacementCanceled += OnPlacementCanceled; Placement.PlacementCanceled += OnPlacementCanceled;
Title = "Construction"; Title = "Construction";
@@ -66,18 +54,18 @@ namespace Content.Client.Construction
var hSplitContainer = new HSplitContainer(); var hSplitContainer = new HSplitContainer();
// Left side // Left side
var recipes = new VBoxContainer("Recipes") {CustomMinimumSize = new Vector2(150.0f, 0.0f)}; var recipes = new VBoxContainer {CustomMinimumSize = new Vector2(150.0f, 0.0f)};
SearchBar = new LineEdit("Search") {PlaceHolder = "Search"}; SearchBar = new LineEdit {PlaceHolder = "Search"};
RecipeList = new Tree("Tree") {SizeFlagsVertical = SizeFlags.FillExpand, HideRoot = true}; RecipeList = new Tree {SizeFlagsVertical = SizeFlags.FillExpand, HideRoot = true};
recipes.AddChild(SearchBar); recipes.AddChild(SearchBar);
recipes.AddChild(RecipeList); recipes.AddChild(RecipeList);
hSplitContainer.AddChild(recipes); hSplitContainer.AddChild(recipes);
// Right side // Right side
var guide = new VBoxContainer("Guide"); var guide = new VBoxContainer();
var info = new HBoxContainer("Info"); var info = new HBoxContainer();
InfoIcon = new TextureRect("TextureRect"); InfoIcon = new TextureRect();
InfoLabel = new Label("Label") InfoLabel = new Label
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.ShrinkCenter SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.ShrinkCenter
}; };
@@ -85,7 +73,7 @@ namespace Content.Client.Construction
info.AddChild(InfoLabel); info.AddChild(InfoLabel);
guide.AddChild(info); guide.AddChild(info);
var stepsLabel = new Label("Label") var stepsLabel = new Label
{ {
SizeFlagsHorizontal = SizeFlags.ShrinkCenter, SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsVertical = SizeFlags.ShrinkCenter,
@@ -93,14 +81,14 @@ namespace Content.Client.Construction
}; };
guide.AddChild(stepsLabel); guide.AddChild(stepsLabel);
StepList = new ItemList("StepsList") StepList = new ItemList
{ {
SizeFlagsVertical = SizeFlags.FillExpand, SelectMode = ItemList.ItemListSelectMode.None SizeFlagsVertical = SizeFlags.FillExpand, SelectMode = ItemList.ItemListSelectMode.None
}; };
guide.AddChild(StepList); guide.AddChild(StepList);
var buttonsContainer = new HBoxContainer("Buttons"); var buttonsContainer = new HBoxContainer();
BuildButton = new Button("BuildButton") BuildButton = new Button
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
TextAlign = Button.AlignMode.Center, TextAlign = Button.AlignMode.Center,
@@ -108,7 +96,7 @@ namespace Content.Client.Construction
Disabled = true, Disabled = true,
ToggleMode = false ToggleMode = false
}; };
EraseButton = new Button("EraseButton") EraseButton = new Button
{ {
TextAlign = Button.AlignMode.Center, Text = "Clear Ghosts", ToggleMode = true TextAlign = Button.AlignMode.Center, Text = "Clear Ghosts", ToggleMode = true
}; };
@@ -140,7 +128,7 @@ namespace Content.Client.Construction
void OnItemSelected() void OnItemSelected()
{ {
var prototype = (ConstructionPrototype)RecipeList.Selected.Metadata; var prototype = (ConstructionPrototype) RecipeList.Selected.Metadata;
if (prototype == null) if (prototype == null)
{ {
@@ -163,6 +151,7 @@ namespace Content.Client.Construction
{ {
continue; continue;
} }
Texture icon; Texture icon;
string text; string text;
switch (forward) switch (forward)
@@ -171,20 +160,24 @@ namespace Content.Client.Construction
switch (mat.Material) switch (mat.Material)
{ {
case ConstructionStepMaterial.MaterialType.Metal: case ConstructionStepMaterial.MaterialType.Metal:
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/sheet_metal.png"); icon = ResourceCache.GetResource<TextureResource>(
"/Textures/Objects/sheet_metal.png");
text = $"Metal x{mat.Amount}"; text = $"Metal x{mat.Amount}";
break; break;
case ConstructionStepMaterial.MaterialType.Glass: case ConstructionStepMaterial.MaterialType.Glass:
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/sheet_glass.png"); icon = ResourceCache.GetResource<TextureResource>(
"/Textures/Objects/sheet_glass.png");
text = $"Glass x{mat.Amount}"; text = $"Glass x{mat.Amount}";
break; break;
case ConstructionStepMaterial.MaterialType.Cable: case ConstructionStepMaterial.MaterialType.Cable:
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/cable_coil.png"); icon = ResourceCache.GetResource<TextureResource>(
"/Textures/Objects/cable_coil.png");
text = $"Cable Coil x{mat.Amount}"; text = $"Cable Coil x{mat.Amount}";
break; break;
default: default:
throw new NotImplementedException(); throw new NotImplementedException();
} }
break; break;
case ConstructionStepTool tool: case ConstructionStepTool tool:
switch (tool.Tool) switch (tool.Tool)
@@ -198,20 +191,24 @@ namespace Content.Client.Construction
text = "Crowbar"; text = "Crowbar";
break; break;
case ConstructionStepTool.ToolType.Screwdriver: case ConstructionStepTool.ToolType.Screwdriver:
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/screwdriver.png"); icon = ResourceCache.GetResource<TextureResource>(
"/Textures/Objects/screwdriver.png");
text = "Screwdriver"; text = "Screwdriver";
break; break;
case ConstructionStepTool.ToolType.Welder: case ConstructionStepTool.ToolType.Welder:
icon = ResourceCache.GetResource<RSIResource>("/Textures/Objects/tools.rsi").RSI["welder"].Frame0; icon = ResourceCache.GetResource<RSIResource>("/Textures/Objects/tools.rsi")
.RSI["welder"].Frame0;
text = $"Welding tool ({tool.Amount} fuel)"; text = $"Welding tool ({tool.Amount} fuel)";
break; break;
case ConstructionStepTool.ToolType.Wirecutters: case ConstructionStepTool.ToolType.Wirecutters:
icon = ResourceCache.GetResource<TextureResource>("/Textures/Objects/wirecutter.png"); icon = ResourceCache.GetResource<TextureResource>(
"/Textures/Objects/wirecutter.png");
text = "Wirecutters"; text = "Wirecutters";
break; break;
default: default:
throw new NotImplementedException(); throw new NotImplementedException();
} }
break; break;
default: default:
throw new NotImplementedException(); throw new NotImplementedException();
@@ -230,7 +227,7 @@ namespace Content.Client.Construction
void OnBuildPressed(Button.ButtonEventArgs args) void OnBuildPressed(Button.ButtonEventArgs args)
{ {
var prototype = (ConstructionPrototype)RecipeList.Selected.Metadata; var prototype = (ConstructionPrototype) RecipeList.Selected.Metadata;
if (prototype == null) if (prototype == null)
{ {
return; return;
@@ -278,6 +275,7 @@ namespace Content.Client.Construction
subNode = new CategoryNode(category, currentNode); subNode = new CategoryNode(category, currentNode);
currentNode.ChildCategories.Add(category, subNode); currentNode.ChildCategories.Add(category, subNode);
} }
currentNode = subNode; currentNode = subNode;
} }
@@ -356,6 +354,7 @@ namespace Content.Client.Construction
continue; continue;
} }
} }
var subItem = RecipeList.CreateItem(ItemForNode(node)); var subItem = RecipeList.CreateItem(ItemForNode(node));
subItem.Text = prototype.Name; subItem.Text = prototype.Name;
subItem.Metadata = prototype; subItem.Metadata = prototype;
@@ -377,7 +376,10 @@ namespace Content.Client.Construction
{ {
public readonly string Name; public readonly string Name;
public readonly CategoryNode Parent; public readonly CategoryNode Parent;
public SortedDictionary<string, CategoryNode> ChildCategories = new SortedDictionary<string, CategoryNode>();
public SortedDictionary<string, CategoryNode>
ChildCategories = new SortedDictionary<string, CategoryNode>();
public List<ConstructionPrototype> Prototypes = new List<ConstructionPrototype>(); public List<ConstructionPrototype> Prototypes = new List<ConstructionPrototype>();
public int FlattenedIndex = -1; public int FlattenedIndex = -1;

View File

@@ -1,18 +1,13 @@
using System; using System;
using Content.Client.UserInterface; using Content.Client.UserInterface;
using Content.Shared.GameObjects.Components.Power; using Content.Shared.GameObjects.Components.Power;
using NJsonSchema.Validation;
using OpenTK.Graphics.OpenGL4;
using Robust.Client.GameObjects.Components.UserInterface; using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Client.Graphics.Drawing; using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.GameObjects.Components.UserInterface; using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Utility;
namespace Content.Client.GameObjects.Components.Power namespace Content.Client.GameObjects.Components.Power
{ {
@@ -72,34 +67,34 @@ namespace Content.Client.GameObjects.Components.Power
_chargeBar.Value = castState.Charge; _chargeBar.Value = castState.Charge;
UpdateChargeBarColor(castState.Charge); UpdateChargeBarColor(castState.Charge);
float ChargePercentage = (castState.Charge / _chargeBar.MaxValue) * 100.0f; var chargePercentage = (castState.Charge / _chargeBar.MaxValue) * 100.0f;
_window.ChargePercentage.Text = " " + ChargePercentage.ToString("0.00") + "%"; _window.ChargePercentage.Text = " " + chargePercentage.ToString("0.00") + "%";
} }
private void UpdateChargeBarColor(float charge) private void UpdateChargeBarColor(float charge)
{ {
float normalizedCharge = charge / _chargeBar.MaxValue; var normalizedCharge = charge / _chargeBar.MaxValue;
float leftHue = 0.0f;// Red const float leftHue = 0.0f; // Red
float middleHue = 0.066f;// Orange const float middleHue = 0.066f; // Orange
float rightHue = 0.33f;// Green const float rightHue = 0.33f; // Green
float saturation = 1.0f;// Uniform saturation const float saturation = 1.0f; // Uniform saturation
float value = 0.8f;// Uniform value / brightness const float value = 0.8f; // Uniform value / brightness
float alpha = 1.0f;// Uniform alpha const float alpha = 1.0f; // Uniform alpha
// These should add up to 1.0 or your transition won't be smooth // These should add up to 1.0 or your transition won't be smooth
float leftSideSize = 0.5f;// Fraction of _chargeBar lerped from leftHue to middleHue const float leftSideSize = 0.5f; // Fraction of _chargeBar lerped from leftHue to middleHue
float rightSideSize = 0.5f;// Fraction of _chargeBar lerped from middleHue to rightHue const float rightSideSize = 0.5f; // Fraction of _chargeBar lerped from middleHue to rightHue
float finalHue; float finalHue;
if (normalizedCharge <= leftSideSize) if (normalizedCharge <= leftSideSize)
{ {
normalizedCharge /= leftSideSize;// Adjust range to 0.0 to 1.0 normalizedCharge /= leftSideSize; // Adjust range to 0.0 to 1.0
finalHue = FloatMath.Lerp(leftHue, middleHue, normalizedCharge); finalHue = FloatMath.Lerp(leftHue, middleHue, normalizedCharge);
} }
else else
{ {
normalizedCharge = (normalizedCharge - leftSideSize) / rightSideSize;// Adjust range to 0.0 to 1.0. normalizedCharge = (normalizedCharge - leftSideSize) / rightSideSize; // Adjust range to 0.0 to 1.0.
finalHue = FloatMath.Lerp(middleHue, rightHue, normalizedCharge); finalHue = FloatMath.Lerp(middleHue, rightHue, normalizedCharge);
} }
@@ -109,7 +104,7 @@ namespace Content.Client.GameObjects.Components.Power
_chargeBar.ForegroundStyleBoxOverride = new StyleBoxFlat(); _chargeBar.ForegroundStyleBoxOverride = new StyleBoxFlat();
} }
var foregroundStyleBoxOverride = (StyleBoxFlat)_chargeBar.ForegroundStyleBoxOverride; var foregroundStyleBoxOverride = (StyleBoxFlat) _chargeBar.ForegroundStyleBoxOverride;
foregroundStyleBoxOverride.BackgroundColor = foregroundStyleBoxOverride.BackgroundColor =
Color.FromHsv(new Vector4(finalHue, saturation, value, alpha)); Color.FromHsv(new Vector4(finalHue, saturation, value, alpha));
} }
@@ -134,29 +129,29 @@ namespace Content.Client.GameObjects.Components.Power
public ApcWindow() public ApcWindow()
{ {
Title = "APC"; Title = "APC";
var rows = new VBoxContainer("Rows"); var rows = new VBoxContainer();
var statusHeader = new Label("StatusHeader") { Text = "Power Status: " }; var statusHeader = new Label {Text = "Power Status: "};
rows.AddChild(statusHeader); rows.AddChild(statusHeader);
var breaker = new HBoxContainer("Breaker"); var breaker = new HBoxContainer();
var breakerLabel = new Label("Label") { Text = "Main Breaker: " }; var breakerLabel = new Label {Text = "Main Breaker: "};
BreakerButton = new CheckButton {Name = "Breaker", Text = "Toggle"}; BreakerButton = new CheckButton {Text = "Toggle"};
breaker.AddChild(breakerLabel); breaker.AddChild(breakerLabel);
breaker.AddChild(BreakerButton); breaker.AddChild(BreakerButton);
rows.AddChild(breaker); rows.AddChild(breaker);
var externalStatus = new HBoxContainer("ExternalStatus"); var externalStatus = new HBoxContainer();
var externalStatusLabel = new Label("Label") { Text = "External Power: " }; var externalStatusLabel = new Label {Text = "External Power: "};
ExternalPowerStateLabel = new Label("Status") { Text = "Good" }; ExternalPowerStateLabel = new Label {Text = "Good"};
ExternalPowerStateLabel.SetOnlyStyleClass(NanoStyle.StyleClassPowerStateGood); ExternalPowerStateLabel.SetOnlyStyleClass(NanoStyle.StyleClassPowerStateGood);
externalStatus.AddChild(externalStatusLabel); externalStatus.AddChild(externalStatusLabel);
externalStatus.AddChild(ExternalPowerStateLabel); externalStatus.AddChild(ExternalPowerStateLabel);
rows.AddChild(externalStatus); rows.AddChild(externalStatus);
var charge = new HBoxContainer("Charge"); var charge = new HBoxContainer();
var chargeLabel = new Label("Label") { Text = "Charge:" }; var chargeLabel = new Label {Text = "Charge:"};
ChargeBar = new ProgressBar("Charge") ChargeBar = new ProgressBar
{ {
SizeFlagsHorizontal = Control.SizeFlags.FillExpand, SizeFlagsHorizontal = Control.SizeFlags.FillExpand,
MinValue = 0.0f, MinValue = 0.0f,
@@ -164,7 +159,7 @@ namespace Content.Client.GameObjects.Components.Power
Page = 0.0f, Page = 0.0f,
Value = 0.5f Value = 0.5f
}; };
ChargePercentage = new Label("ChargePercentage"); ChargePercentage = new Label();
charge.AddChild(chargeLabel); charge.AddChild(chargeLabel);
charge.AddChild(ChargeBar); charge.AddChild(ChargeBar);
charge.AddChild(ChargePercentage); charge.AddChild(ChargePercentage);

View File

@@ -30,7 +30,7 @@ namespace Content.Client.GameObjects.Components.Storage
base.OnAdd(); base.OnAdd();
Window = new StorageWindow() Window = new StorageWindow()
{ StorageEntity = this}; {StorageEntity = this};
} }
public override void OnRemove() public override void OnRemove()
@@ -44,7 +44,8 @@ namespace Content.Client.GameObjects.Components.Storage
base.ExposeData(serializer); base.ExposeData(serializer);
} }
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null) public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null,
IComponent component = null)
{ {
switch (message) switch (message)
{ {
@@ -108,32 +109,27 @@ namespace Content.Client.GameObjects.Components.Storage
public StorageWindow() public StorageWindow()
{ {
Size = new Vector2(180.0f, 320.0f); Size = (180, 320);
}
protected override void Initialize()
{
base.Initialize();
Title = "Storage Item"; Title = "Storage Item";
RectClipContent = true; RectClipContent = true;
VSplitContainer = new VBoxContainer("VSplitContainer"); VSplitContainer = new VBoxContainer();
Information = new Label("Information") Information = new Label
{ {
Text = "Items: 0 Volume: 0/0 Stuff", Text = "Items: 0 Volume: 0/0 Stuff",
SizeFlagsVertical = SizeFlags.ShrinkCenter SizeFlagsVertical = SizeFlags.ShrinkCenter
}; };
VSplitContainer.AddChild(Information); VSplitContainer.AddChild(Information);
var listScrollContainer = new ScrollContainer("ListScrollContainer") var listScrollContainer = new ScrollContainer
{ {
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
HScrollEnabled = true, HScrollEnabled = true,
VScrollEnabled = true VScrollEnabled = true
}; };
EntityList = new VBoxContainer("EntityList") EntityList = new VBoxContainer
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand SizeFlagsHorizontal = SizeFlags.FillExpand
}; };
@@ -182,7 +178,8 @@ namespace Content.Client.GameObjects.Components.Storage
//Sets information about entire storage container current capacity //Sets information about entire storage container current capacity
if (StorageEntity.StorageCapacityMax != 0) if (StorageEntity.StorageCapacityMax != 0)
{ {
Information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storagelist.Count, StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax); Information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storagelist.Count,
StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax);
} }
else else
{ {
@@ -196,7 +193,7 @@ namespace Content.Client.GameObjects.Components.Storage
/// <param name="args"></param> /// <param name="args"></param>
private void OnItemButtonToggled(BaseButton.ButtonToggledEventArgs args) private void OnItemButtonToggled(BaseButton.ButtonToggledEventArgs args)
{ {
var control = (EntityButton)args.Button.Parent; var control = (EntityButton) args.Button.Parent;
args.Button.Pressed = false; args.Button.Pressed = false;
StorageEntity.Interact(control.EntityuID); StorageEntity.Interact(control.EntityuID);
} }
@@ -208,17 +205,15 @@ namespace Content.Client.GameObjects.Components.Storage
private class EntityButton : PanelContainer private class EntityButton : PanelContainer
{ {
public EntityUid EntityuID { get; set; } public EntityUid EntityuID { get; set; }
public Button ActualButton { get; private set; } public Button ActualButton { get; }
public SpriteView EntitySpriteView { get; private set; } public SpriteView EntitySpriteView { get; }
public Control EntityControl { get; private set; } public Control EntityControl { get; }
public Label EntityName { get; private set; } public Label EntityName { get; }
public Label EntitySize { get; private set; } public Label EntitySize { get; }
protected override void Initialize() public EntityButton()
{ {
base.Initialize(); ActualButton = new Button
ActualButton = new Button("Button")
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
@@ -227,12 +222,12 @@ namespace Content.Client.GameObjects.Components.Storage
}; };
AddChild(ActualButton); AddChild(ActualButton);
var hBoxContainer = new HBoxContainer("HBoxContainer") {MouseFilter = MouseFilterMode.Ignore}; var hBoxContainer = new HBoxContainer {MouseFilter = MouseFilterMode.Ignore};
EntitySpriteView = new SpriteView("SpriteView") EntitySpriteView = new SpriteView
{ {
CustomMinimumSize = new Vector2(32.0f, 32.0f), MouseFilter = MouseFilterMode.Ignore CustomMinimumSize = new Vector2(32.0f, 32.0f), MouseFilter = MouseFilterMode.Ignore
}; };
EntityName = new Label("Name") EntityName = new Label
{ {
SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsVertical = SizeFlags.ShrinkCenter,
Text = "Backpack", Text = "Backpack",
@@ -241,11 +236,11 @@ namespace Content.Client.GameObjects.Components.Storage
hBoxContainer.AddChild(EntitySpriteView); hBoxContainer.AddChild(EntitySpriteView);
hBoxContainer.AddChild(EntityName); hBoxContainer.AddChild(EntityName);
EntityControl = new Control("Control") EntityControl = new Control
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, MouseFilter = MouseFilterMode.Ignore SizeFlagsHorizontal = SizeFlags.FillExpand, MouseFilter = MouseFilterMode.Ignore
}; };
EntitySize = new Label("Size") EntitySize = new Label
{ {
SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsVertical = SizeFlags.ShrinkCenter,
Text = "Size 6", Text = "Size 6",

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.GameObjects.EntitySystemMessages; using Content.Shared.GameObjects.EntitySystemMessages;
using Content.Shared.Input; using Content.Shared.Input;
@@ -66,7 +65,7 @@ namespace Content.Client.GameObjects.EntitySystems
_currentPopup = new Popup(); _currentPopup = new Popup();
_currentPopup.UserInterfaceManager.StateRoot.AddChild(_currentPopup); _currentPopup.UserInterfaceManager.StateRoot.AddChild(_currentPopup);
_currentPopup.OnPopupHide += _closeContextMenu; _currentPopup.OnPopupHide += _closeContextMenu;
var vBox = new VBoxContainer("ButtonBox"); var vBox = new VBoxContainer();
_currentPopup.AddChild(vBox); _currentPopup.AddChild(vBox);
vBox.AddChild(new Label {Text = "Waiting on Server..."}); vBox.AddChild(new Label {Text = "Waiting on Server..."});
@@ -94,7 +93,7 @@ namespace Content.Client.GameObjects.EntitySystems
_currentPopup = new Popup(); _currentPopup = new Popup();
_currentPopup.OnPopupHide += _closeContextMenu; _currentPopup.OnPopupHide += _closeContextMenu;
var vBox = new VBoxContainer("ButtonBox"); var vBox = new VBoxContainer();
_currentPopup.AddChild(vBox); _currentPopup.AddChild(vBox);
foreach (var entity in entities) foreach (var entity in entities)
{ {

View File

@@ -2,8 +2,6 @@ using System.Collections.Generic;
using Content.Client.GameObjects.Components.Research; using Content.Client.GameObjects.Components.Research;
using Content.Shared.Materials; using Content.Shared.Materials;
using Content.Shared.Research; using Content.Shared.Research;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
@@ -12,15 +10,13 @@ using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timers; using Robust.Shared.Timers;
using Robust.Shared.Utility;
namespace Content.Client.Research namespace Content.Client.Research
{ {
public class LatheMenu : SS14Window public class LatheMenu : SS14Window
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649
[Dependency] [Dependency] private IPrototypeManager PrototypeManager;
private IPrototypeManager PrototypeManager;
#pragma warning restore #pragma warning restore
private ItemList Items; private ItemList Items;
@@ -37,15 +33,6 @@ namespace Content.Client.Research
public LatheMenu() public LatheMenu()
{ {
}
public LatheMenu(string name) : base(name)
{
}
protected override void Initialize()
{
base.Initialize();
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
Title = "Lathe Menu"; Title = "Lathe Menu";
@@ -62,15 +49,15 @@ namespace Content.Client.Research
margin.SetAnchorAndMarginPreset(LayoutPreset.Wide); margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);
var vbox = new VBoxContainer() var vBox = new VBoxContainer()
{ {
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
SeparationOverride = 5, SeparationOverride = 5,
}; };
vbox.SetAnchorAndMarginPreset(LayoutPreset.Wide); vBox.SetAnchorAndMarginPreset(LayoutPreset.Wide);
var hboxButtons = new HBoxContainer() var hBoxButtons = new HBoxContainer()
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
@@ -93,7 +80,7 @@ namespace Content.Client.Research
spacer.SetAnchorAndMarginPreset(LayoutPreset.Wide); spacer.SetAnchorAndMarginPreset(LayoutPreset.Wide);
var hboxFilter = new HBoxContainer() var hBoxFilter = new HBoxContainer()
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
@@ -124,8 +111,6 @@ namespace Content.Client.Research
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
}; };
Items.OnItemSelected += ItemSelected; Items.OnItemSelected += ItemSelected;
AmountLineEdit = new LineEdit() AmountLineEdit = new LineEdit()
@@ -143,19 +128,19 @@ namespace Content.Client.Research
SizeFlagsStretchRatio = 3 SizeFlagsStretchRatio = 3
}; };
hboxButtons.AddChild(spacer); hBoxButtons.AddChild(spacer);
hboxButtons.AddChild(QueueButton); hBoxButtons.AddChild(QueueButton);
hboxFilter.AddChild(SearchBar); hBoxFilter.AddChild(SearchBar);
hboxFilter.AddChild(filterButton); hBoxFilter.AddChild(filterButton);
vbox.AddChild(hboxButtons); vBox.AddChild(hBoxButtons);
vbox.AddChild(hboxFilter); vBox.AddChild(hBoxFilter);
vbox.AddChild(Items); vBox.AddChild(Items);
vbox.AddChild(AmountLineEdit); vBox.AddChild(AmountLineEdit);
vbox.AddChild(Materials); vBox.AddChild(Materials);
margin.AddChild(vbox); margin.AddChild(vBox);
Contents.AddChild(margin); Contents.AddChild(margin);
} }

View File

@@ -1,13 +1,9 @@
using Content.Client.GameObjects.Components.Research; using Content.Client.GameObjects.Components.Research;
using Content.Shared.Research; using Content.Shared.Research;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility; using Robust.Client.Utility;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -25,10 +21,8 @@ namespace Content.Client.Research
private Label Description; private Label Description;
private TextureRect Icon; private TextureRect Icon;
protected override void Initialize() public LatheQueueMenu()
{ {
base.Initialize();
Title = "Lathe Queue"; Title = "Lathe Queue";
var margin = new MarginContainer() var margin = new MarginContainer()
@@ -41,9 +35,9 @@ namespace Content.Client.Research
margin.SetAnchorAndMarginPreset(LayoutPreset.Wide); margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);
var vbox = new VBoxContainer(); var vBox = new VBoxContainer();
vbox.SetAnchorAndMarginPreset(LayoutPreset.Wide); vBox.SetAnchorAndMarginPreset(LayoutPreset.Wide);
var descMargin = new MarginContainer() var descMargin = new MarginContainer()
{ {
@@ -55,7 +49,7 @@ namespace Content.Client.Research
SizeFlagsStretchRatio = 2, SizeFlagsStretchRatio = 2,
}; };
var hbox = new HBoxContainer() var hBox = new HBoxContainer()
{ {
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand,
}; };
@@ -66,7 +60,7 @@ namespace Content.Client.Research
SizeFlagsStretchRatio = 2, SizeFlagsStretchRatio = 2,
}; };
var vboxInfo = new VBoxContainer() var vBoxInfo = new VBoxContainer()
{ {
SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 3, SizeFlagsStretchRatio = 3,
@@ -94,18 +88,18 @@ namespace Content.Client.Research
SelectMode = ItemList.ItemListSelectMode.None SelectMode = ItemList.ItemListSelectMode.None
}; };
vboxInfo.AddChild(NameLabel); vBoxInfo.AddChild(NameLabel);
vboxInfo.AddChild(Description); vBoxInfo.AddChild(Description);
hbox.AddChild(Icon); hBox.AddChild(Icon);
hbox.AddChild(vboxInfo); hBox.AddChild(vBoxInfo);
descMargin.AddChild(hbox); descMargin.AddChild(hBox);
vbox.AddChild(descMargin); vBox.AddChild(descMargin);
vbox.AddChild(QueueList); vBox.AddChild(QueueList);
margin.AddChild(vbox); margin.AddChild(vBox);
Contents.AddChild(margin); Contents.AddChild(margin);

View File

@@ -37,14 +37,12 @@ namespace Content.Client.UserInterface
private UIBox2i _handL; private UIBox2i _handL;
private UIBox2i _handR; private UIBox2i _handR;
private SpriteView LeftSpriteView; private readonly SpriteView LeftSpriteView;
private SpriteView RightSpriteView; private readonly SpriteView RightSpriteView;
private TextureRect ActiveHandRect; private readonly TextureRect ActiveHandRect;
protected override void Initialize() public HandsGui()
{ {
base.Initialize();
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
ToolTip = _loc.GetString("Your hands"); ToolTip = _loc.GetString("Your hands");