Removed APC gui dependence on tscn file

This commit is contained in:
moneyl
2019-05-14 23:23:00 -04:00
parent 3fa2e0c976
commit 2917a87ce7
2 changed files with 42 additions and 235 deletions

View File

@@ -1,7 +1,9 @@
using System;
using Content.Shared.GameObjects.Components.Power;
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;
@@ -21,12 +23,47 @@ namespace Content.Client.GameObjects.Components.Power
{
base.Open();
_window = new ApcWindow(IoCManager.Resolve<IDisplayManager>());
_window = new SS14Window(IoCManager.Resolve<IDisplayManager>())
{
MarginRight = 426.0f, MarginBottom = 270.0f
};
_window.OnClose += Close;
_breakerButton = _window.Contents.GetChild<BaseButton>("Rows/Breaker/Breaker");
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();
_breakerButton.OnPressed += _ => SendMessage(new ApcToggleMainBreakerMessage());
_externalPowerStateLabel = _window.Contents.GetChild<Label>("Rows/ExternalStatus/Status");
_chargeBar = _window.Contents.GetChild<ProgressBar>("Rows/Charge/Charge");
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);
_window.Contents.AddChild(rows);
_window.AddToScreen();
}
@@ -71,7 +108,7 @@ namespace Content.Client.GameObjects.Components.Power
private class ApcWindow : SS14Window
{
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Power/Apc.tscn");
//protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Power/Apc.tscn");
public ApcWindow(IDisplayManager displayMan) : base(displayMan) { }
}

View File

@@ -1,230 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Engine/Scenes/SS14Window/SS14Window.tscn" type="PackedScene" id=1]
[node name="SS14Window" index="0" instance=ExtResource( 1 )]
margin_right = 426.0
margin_bottom = 270.0
rect_clip_content = false
[node name="Contents" parent="." index="0"]
rect_clip_content = false
[node name="Rows" type="VBoxContainer" parent="Contents" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="StatusHeader" type="Label" parent="Contents/Rows" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 306.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Power Status:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Breaker" type="HBoxContainer" parent="Contents/Rows" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 18.0
margin_right = 306.0
margin_bottom = 58.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="Label" type="Label" parent="Contents/Rows/Breaker" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 13.0
margin_right = 100.0
margin_bottom = 27.0
rect_min_size = Vector2( 100, 0 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Main Breaker:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Rect" ]
[node name="Breaker" type="CheckButton" parent="Contents/Rows/Breaker" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 104.0
margin_right = 180.0
margin_bottom = 40.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = true
pressed = true
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 0
[node name="ExternalStatus" type="HBoxContainer" parent="Contents/Rows" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 62.0
margin_right = 306.0
margin_bottom = 76.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="Label" type="Label" parent="Contents/Rows/ExternalStatus" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 100.0
margin_bottom = 14.0
rect_min_size = Vector2( 100, 0 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "External Power:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Rect" ]
[node name="Status" type="Label" parent="Contents/Rows/ExternalStatus" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 104.0
margin_right = 138.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Good"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Charge" type="HBoxContainer" parent="Contents/Rows" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 80.0
margin_right = 306.0
margin_bottom = 94.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="Label" type="Label" parent="Contents/Rows/Charge" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 100.0
margin_bottom = 14.0
rect_min_size = Vector2( 100, 0 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
text = "Charge:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Rect" ]
[node name="Charge" type="ProgressBar" parent="Contents/Rows/Charge" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 104.0
margin_right = 306.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 0
min_value = 0.0
max_value = 1.0
step = 1.0
page = 0.0
value = 0.5
exp_edit = false
rounded = false
allow_greater = false
allow_lesser = false
percent_visible = true
_sections_unfolded = [ "Percent" ]
[node name="Header" parent="." index="1"]
editor/display_folded = true
rect_clip_content = false
[node name="Header Text" parent="Header" index="0"]
rect_clip_content = false
[node name="CloseButton" parent="Header" index="1"]
rect_clip_content = false