Merge pull request #220 from Moneyl/no-tscn
Remove GUI dependence on tscn files
This commit is contained in:
@@ -11,8 +11,6 @@ namespace Content.Client.Chat
|
||||
{
|
||||
public class ChatBox : PanelContainer
|
||||
{
|
||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/ChatBox/ChatBox.tscn");
|
||||
|
||||
public delegate void TextSubmitHandler(ChatBox chatBox, string text);
|
||||
|
||||
private const int MaxLinePixelLength = 500;
|
||||
@@ -43,19 +41,27 @@ namespace Content.Client.Chat
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Input = GetChild<LineEdit>("VBoxContainer/Input");
|
||||
MarginLeft = -475.0f;
|
||||
MarginTop = 10.0f;
|
||||
MarginRight = -10.0f;
|
||||
MarginBottom = 185.0f;
|
||||
|
||||
AnchorLeft = 1.0f;
|
||||
AnchorRight = 1.0f;
|
||||
|
||||
var vBox = new VBoxContainer("VBoxContainer");
|
||||
|
||||
contents = new OutputPanel {SizeFlagsVertical = SizeFlags.FillExpand};
|
||||
vBox.AddChild(contents);
|
||||
|
||||
Input = new LineEdit("Input");
|
||||
Input.OnKeyDown += InputKeyDown;
|
||||
Input.OnTextEntered += Input_OnTextEntered;
|
||||
GetChild<Control>("VBoxContainer/Contents").Dispose();
|
||||
vBox.AddChild(Input);
|
||||
|
||||
contents = new OutputPanel
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
};
|
||||
GetChild("VBoxContainer").AddChild(contents);
|
||||
contents.SetPositionInParent(0);
|
||||
AddChild(vBox);
|
||||
|
||||
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Gray.WithAlpha(0.5f)};
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.Gray.WithAlpha(0.5f) };
|
||||
}
|
||||
|
||||
protected override void MouseDown(GUIMouseButtonEventArgs e)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Client.GameObjects.Components.Construction;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Construction
|
||||
@@ -8,7 +9,6 @@ namespace Content.Client.Construction
|
||||
public class ConstructionButton : Button
|
||||
{
|
||||
private readonly IDisplayManager _displayManager;
|
||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Construction/ConstructionButton.tscn");
|
||||
|
||||
public ConstructorComponent Owner
|
||||
{
|
||||
@@ -27,6 +27,12 @@ namespace Content.Client.Construction
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SetAnchorPreset(LayoutPreset.BottomRight);
|
||||
MarginLeft = -110.0f;
|
||||
MarginTop = -70.0f;
|
||||
MarginRight = -50.0f;
|
||||
MarginBottom = -50.0f;
|
||||
Text = "Crafting";
|
||||
OnPressed += IWasPressed;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Content.Client.Construction
|
||||
{
|
||||
public class ConstructionMenu : SS14Window
|
||||
{
|
||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Construction/ConstructionMenu.tscn");
|
||||
|
||||
#pragma warning disable CS0649
|
||||
[Dependency]
|
||||
@@ -49,7 +48,11 @@ namespace Content.Client.Construction
|
||||
// This list is flattened in such a way that the top most deepest category is first.
|
||||
List<CategoryNode> FlattenedCategories;
|
||||
PlacementManager Placement;
|
||||
public ConstructionMenu(IDisplayManager displayMan) : base(displayMan) { }
|
||||
|
||||
public ConstructionMenu(IDisplayManager displayMan) : base(displayMan)
|
||||
{
|
||||
Size = new Vector2(500.0f, 350.0f);
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
@@ -61,22 +64,66 @@ namespace Content.Client.Construction
|
||||
HideOnClose = true;
|
||||
Title = "Construction";
|
||||
Visible = false;
|
||||
var split = Contents.GetChild("HSplitContainer");
|
||||
var rightSide = split.GetChild("Guide");
|
||||
var info = rightSide.GetChild("Info");
|
||||
InfoIcon = info.GetChild<TextureRect>("TextureRect");
|
||||
InfoLabel = info.GetChild<Label>("Label");
|
||||
StepList = rightSide.GetChild<ItemList>("StepsList");
|
||||
var buttons = rightSide.GetChild("Buttons");
|
||||
BuildButton = buttons.GetChild<Button>("BuildButton");
|
||||
BuildButton.OnPressed += OnBuildPressed;
|
||||
EraseButton = buttons.GetChild<Button>("EraseButton");
|
||||
EraseButton.OnToggled += OnEraseToggled;
|
||||
|
||||
var leftSide = split.GetChild("Recipes");
|
||||
SearchBar = leftSide.GetChild<LineEdit>("Search");
|
||||
var hSplitContainer = new HSplitContainer();
|
||||
|
||||
// Left side
|
||||
var recipes = new VBoxContainer("Recipes") {CustomMinimumSize = new Vector2(150.0f, 0.0f)};
|
||||
SearchBar = new LineEdit("Search") {PlaceHolder = "Search"};
|
||||
RecipeList = new Tree("Tree") {SizeFlagsVertical = SizeFlags.FillExpand, HideRoot = true};
|
||||
recipes.AddChild(SearchBar);
|
||||
recipes.AddChild(RecipeList);
|
||||
hSplitContainer.AddChild(recipes);
|
||||
|
||||
// Right side
|
||||
var guide = new VBoxContainer("Guide");
|
||||
var info = new HBoxContainer("Info");
|
||||
InfoIcon = new TextureRect("TextureRect");
|
||||
InfoLabel = new Label("Label")
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.ShrinkCenter
|
||||
};
|
||||
info.AddChild(InfoIcon);
|
||||
info.AddChild(InfoLabel);
|
||||
guide.AddChild(info);
|
||||
|
||||
var stepsLabel = new Label("Label")
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter,
|
||||
Text = "Steps"
|
||||
};
|
||||
guide.AddChild(stepsLabel);
|
||||
|
||||
StepList = new ItemList("StepsList")
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand, SelectMode = ItemList.ItemListSelectMode.None
|
||||
};
|
||||
guide.AddChild(StepList);
|
||||
|
||||
var buttonsContainer = new HBoxContainer("Buttons");
|
||||
BuildButton = new Button("BuildButton")
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
TextAlign = Button.AlignMode.Center,
|
||||
Text = "Build!",
|
||||
Disabled = true,
|
||||
ToggleMode = false
|
||||
};
|
||||
EraseButton = new Button("EraseButton")
|
||||
{
|
||||
TextAlign = Button.AlignMode.Center, Text = "Clear Ghosts", ToggleMode = true
|
||||
};
|
||||
buttonsContainer.AddChild(BuildButton);
|
||||
buttonsContainer.AddChild(EraseButton);
|
||||
guide.AddChild(buttonsContainer);
|
||||
|
||||
hSplitContainer.AddChild(guide);
|
||||
Contents.AddChild(hSplitContainer);
|
||||
|
||||
BuildButton.OnPressed += OnBuildPressed;
|
||||
EraseButton.OnToggled += OnEraseToggled;
|
||||
SearchBar.OnTextChanged += OnTextEntered;
|
||||
RecipeList = leftSide.GetChild<Tree>("Tree");
|
||||
RecipeList.OnItemSelected += OnItemSelected;
|
||||
|
||||
PopulatePrototypeList();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Power;
|
||||
using NJsonSchema.Validation;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using Robust.Client.GameObjects.Components.UserInterface;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
@@ -12,7 +15,7 @@ namespace Content.Client.GameObjects.Components.Power
|
||||
{
|
||||
public class ApcBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private SS14Window _window;
|
||||
private ApcWindow _window;
|
||||
private BaseButton _breakerButton;
|
||||
private Label _externalPowerStateLabel;
|
||||
private ProgressBar _chargeBar;
|
||||
@@ -21,13 +24,18 @@ namespace Content.Client.GameObjects.Components.Power
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_window = new ApcWindow(IoCManager.Resolve<IDisplayManager>());
|
||||
_window = new ApcWindow(IoCManager.Resolve<IDisplayManager>())
|
||||
{
|
||||
MarginRight = 426.0f, MarginBottom = 270.0f
|
||||
};
|
||||
_window.OnClose += Close;
|
||||
_breakerButton = _window.Contents.GetChild<BaseButton>("Rows/Breaker/Breaker");
|
||||
_breakerButton.OnPressed += _ => SendMessage(new ApcToggleMainBreakerMessage());
|
||||
_externalPowerStateLabel = _window.Contents.GetChild<Label>("Rows/ExternalStatus/Status");
|
||||
_chargeBar = _window.Contents.GetChild<ProgressBar>("Rows/Charge/Charge");
|
||||
_window.AddToScreen();
|
||||
|
||||
_breakerButton = _window.BreakerButton;
|
||||
_breakerButton.OnPressed += _ => SendMessage(new ApcToggleMainBreakerMessage());
|
||||
|
||||
_externalPowerStateLabel = _window.ExternalPowerStateLabel;
|
||||
_chargeBar = _window.ChargeBar;
|
||||
}
|
||||
|
||||
public ApcBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
@@ -71,9 +79,47 @@ namespace Content.Client.GameObjects.Components.Power
|
||||
|
||||
private class ApcWindow : SS14Window
|
||||
{
|
||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Power/Apc.tscn");
|
||||
public Button BreakerButton { get; set; }
|
||||
public Label ExternalPowerStateLabel { get; set; }
|
||||
public ProgressBar ChargeBar { get; set; }
|
||||
|
||||
public ApcWindow(IDisplayManager displayMan) : base(displayMan) { }
|
||||
public ApcWindow(IDisplayManager displayMan) : base(displayMan)
|
||||
{
|
||||
var rows = new VBoxContainer("Rows");
|
||||
|
||||
var statusHeader = new Label("StatusHeader") { Text = "Power Status: " };
|
||||
rows.AddChild(statusHeader);
|
||||
|
||||
var breaker = new HBoxContainer("Breaker");
|
||||
var breakerLabel = new Label("Label") { Text = "Main Breaker: " };
|
||||
BreakerButton = new CheckButton {Name = "Breaker"};
|
||||
breaker.AddChild(breakerLabel);
|
||||
breaker.AddChild(BreakerButton);
|
||||
rows.AddChild(breaker);
|
||||
|
||||
var externalStatus = new HBoxContainer("ExternalStatus");
|
||||
var externalStatusLabel = new Label("Label") { Text = "External Power: " };
|
||||
ExternalPowerStateLabel = new Label("Status") { Text = "Good" };
|
||||
externalStatus.AddChild(externalStatusLabel);
|
||||
externalStatus.AddChild(ExternalPowerStateLabel);
|
||||
rows.AddChild(externalStatus);
|
||||
|
||||
var charge = new HBoxContainer("Charge");
|
||||
var chargeLabel = new Label("Label") { Text = "Charge:" };
|
||||
ChargeBar = new ProgressBar("Charge")
|
||||
{
|
||||
SizeFlagsHorizontal = Control.SizeFlags.FillExpand,
|
||||
MinValue = 0.0f,
|
||||
MaxValue = 1.0f,
|
||||
Page = 0.0f,
|
||||
Value = 0.5f
|
||||
};
|
||||
charge.AddChild(chargeLabel);
|
||||
charge.AddChild(ChargeBar);
|
||||
rows.AddChild(charge);
|
||||
|
||||
Contents.AddChild(rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using Robust.Shared.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -31,7 +32,7 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
base.OnAdd();
|
||||
|
||||
Window = new StorageWindow(IoCManager.Resolve<IDisplayManager>())
|
||||
{ StorageEntity = this };
|
||||
{ StorageEntity = this};
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
@@ -108,20 +109,42 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
private Label Information;
|
||||
public ClientStorageComponent StorageEntity;
|
||||
|
||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Storage/Storage.tscn");
|
||||
|
||||
public StorageWindow(IDisplayManager displayMan) : base(displayMan) { }
|
||||
public StorageWindow(IDisplayManager displayMan) : base(displayMan)
|
||||
{
|
||||
Size = new Vector2(180.0f, 320.0f);
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Title = "Storage Item";
|
||||
HideOnClose = true;
|
||||
Visible = false;
|
||||
RectClipContent = true;
|
||||
|
||||
// Get all the controls.
|
||||
VSplitContainer = Contents.GetChild("VSplitContainer");
|
||||
EntityList = VSplitContainer.GetChild("ListScrollContainer").GetChild<VBoxContainer>("EntityList");
|
||||
Information = VSplitContainer.GetChild<Label>("Information");
|
||||
VSplitContainer = new VBoxContainer("VSplitContainer");
|
||||
Information = new Label("Information")
|
||||
{
|
||||
Text = "Items: 0 Volume: 0/0 Stuff",
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
||||
};
|
||||
VSplitContainer.AddChild(Information);
|
||||
|
||||
var listScrollContainer = new ScrollContainer("ListScrollContainer")
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
HScrollEnabled = true,
|
||||
VScrollEnabled = true
|
||||
};
|
||||
EntityList = new VBoxContainer("EntityList")
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
};
|
||||
listScrollContainer.AddChild(EntityList);
|
||||
VSplitContainer.AddChild(listScrollContainer);
|
||||
Contents.AddChild(VSplitContainer);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
@@ -147,17 +170,15 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
{
|
||||
EntityuID = entityuid.Key
|
||||
};
|
||||
var container = button.GetChild("HBoxContainer");
|
||||
button.ActualButton.OnToggled += OnItemButtonToggled;
|
||||
//Name and Size labels set
|
||||
container.GetChild<Label>("Name").Text = entity.Name;
|
||||
container.GetChild<Control>("Control").GetChild<Label>("Size").Text = string.Format("{0}", entityuid.Value);
|
||||
button.EntityName.Text = entity.Name;
|
||||
button.EntitySize.Text = string.Format("{0}", entityuid.Value);
|
||||
|
||||
//Gets entity sprite and assigns it to button texture
|
||||
if (entity.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
var view = container.GetChild<SpriteView>("SpriteView");
|
||||
view.Sprite = sprite;
|
||||
button.EntitySpriteView.Sprite = sprite;
|
||||
}
|
||||
|
||||
EntityList.AddChild(button);
|
||||
@@ -193,13 +214,60 @@ namespace Content.Client.GameObjects.Components.Storage
|
||||
{
|
||||
public EntityUid EntityuID { get; set; }
|
||||
public Button ActualButton { get; private set; }
|
||||
|
||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Storage/StorageEntity.tscn");
|
||||
public SpriteView EntitySpriteView { get; private set; }
|
||||
public Control EntityControl { get; private set; }
|
||||
public Label EntityName { get; private set; }
|
||||
public Label EntitySize { get; private set; }
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
ActualButton = GetChild<Button>("Button");
|
||||
|
||||
ActualButton = new Button("Button")
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
ToggleMode = true,
|
||||
MouseFilter = MouseFilterMode.Stop
|
||||
};
|
||||
AddChild(ActualButton);
|
||||
|
||||
var hBoxContainer = new HBoxContainer("HBoxContainer") {MouseFilter = MouseFilterMode.Ignore};
|
||||
EntitySpriteView = new SpriteView("SpriteView")
|
||||
{
|
||||
CustomMinimumSize = new Vector2(32.0f, 32.0f), MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
EntityName = new Label("Name")
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter,
|
||||
Text = "Backpack",
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
hBoxContainer.AddChild(EntitySpriteView);
|
||||
hBoxContainer.AddChild(EntityName);
|
||||
|
||||
EntityControl = new Control("Control")
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand, MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
EntitySize = new Label("Size")
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter,
|
||||
Text = "Size 6",
|
||||
Align = Label.AlignMode.Right,
|
||||
AnchorLeft = 1.0f,
|
||||
AnchorRight = 1.0f,
|
||||
AnchorBottom = 0.5f,
|
||||
AnchorTop = 0.5f,
|
||||
MarginLeft = -38.0f,
|
||||
MarginTop = -7.0f,
|
||||
MarginRight = -5.0f,
|
||||
MarginBottom = 7.0f
|
||||
};
|
||||
|
||||
EntityControl.AddChild(EntitySize);
|
||||
hBoxContainer.AddChild(EntityControl);
|
||||
AddChild(hBoxContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user