Remove storage menu dependence on tscn file
This commit is contained in:
@@ -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, Size = new Vector2(180.0f, 320.0f)};
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
@@ -108,20 +109,39 @@ 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) { }
|
||||
|
||||
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 +167,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 +211,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Engine/Scenes/SS14Window/closewindow.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
|
||||
content_margin_left = -1.0
|
||||
content_margin_right = -1.0
|
||||
content_margin_top = -1.0
|
||||
content_margin_bottom = -1.0
|
||||
bg_color = Color( 0.234375, 0.234375, 0.234375, 1 )
|
||||
draw_center = true
|
||||
border_width_left = 0
|
||||
border_width_top = 0
|
||||
border_width_right = 0
|
||||
border_width_bottom = 0
|
||||
border_color = Color( 0.8, 0.8, 0.8, 1 )
|
||||
border_blend = false
|
||||
corner_radius_top_left = 0
|
||||
corner_radius_top_right = 0
|
||||
corner_radius_bottom_right = 0
|
||||
corner_radius_bottom_left = 0
|
||||
corner_detail = 8
|
||||
expand_margin_left = 0.0
|
||||
expand_margin_right = 0.0
|
||||
expand_margin_top = 0.0
|
||||
expand_margin_bottom = 0.0
|
||||
shadow_color = Color( 0, 0, 0, 0.6 )
|
||||
shadow_size = 0
|
||||
anti_aliasing = true
|
||||
anti_aliasing_size = 1
|
||||
|
||||
[node name="SS14Window" type="Panel" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 100.0
|
||||
margin_top = 38.0
|
||||
margin_right = 361.0
|
||||
margin_bottom = 406.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
|
||||
[node name="Contents" type="Container" parent="." index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = 40.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -12.0
|
||||
rect_min_size = Vector2( 50, 50 )
|
||||
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
|
||||
_sections_unfolded = [ "Anchor", "Margin", "Mouse", "Rect" ]
|
||||
|
||||
[node name="VSplitContainer" type="VSplitContainer" 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 = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
split_offset = 0
|
||||
collapsed = false
|
||||
dragger_visibility = 0
|
||||
_sections_unfolded = [ "Anchor", "Grow Direction", "Hint", "Margin", "Rect" ]
|
||||
|
||||
[node name="Information" type="Label" parent="Contents/VSplitContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 241.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 = "Items: 0 Volume: 0/0 Stuff"
|
||||
align = 1
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "Anchor", "Margin" ]
|
||||
|
||||
[node name="ListScrollContainer" type="ScrollContainer" parent="Contents/VSplitContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 26.0
|
||||
margin_right = 241.0
|
||||
margin_bottom = 316.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = true
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
scroll_horizontal_enabled = true
|
||||
scroll_horizontal = 0
|
||||
scroll_vertical_enabled = true
|
||||
scroll_vertical = 0
|
||||
_sections_unfolded = [ "Anchor", "Focus", "Grow Direction", "Hint", "Margin", "Material", "Mouse", "Pause", "Rect", "Scroll", "Size Flags", "Theme", "Visibility" ]
|
||||
|
||||
[node name="EntityList" type="VBoxContainer" parent="Contents/VSplitContainer/ListScrollContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 241.0
|
||||
margin_bottom = 176.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
alignment = 1
|
||||
_sections_unfolded = [ "Anchor", "Focus", "Hint", "Margin", "Mouse", "Rect", "Size Flags", "Theme", "custom_constants" ]
|
||||
|
||||
[node name="Header" type="Panel" parent="." index="1"]
|
||||
|
||||
editor/display_folded = true
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.0
|
||||
margin_bottom = 25.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
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
_sections_unfolded = [ "Margin", "Mouse", "custom_styles" ]
|
||||
|
||||
[node name="Header Text" type="Label" parent="Header" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -25.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 = "Storage Item"
|
||||
align = 1
|
||||
valign = 1
|
||||
clip_text = true
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "Margin", "Mouse" ]
|
||||
|
||||
[node name="CloseButton" type="TextureButton" parent="Header" index="1"]
|
||||
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -25.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 = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
texture_normal = ExtResource( 1 )
|
||||
expand = true
|
||||
stretch_mode = 5
|
||||
_sections_unfolded = [ "Margin", "Textures" ]
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Engine/Scenes/SpriteMirror/SpriteView.tscn" type="PackedScene" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=1]
|
||||
|
||||
content_margin_left = -1.0
|
||||
content_margin_right = -1.0
|
||||
content_margin_top = -1.0
|
||||
content_margin_bottom = -1.0
|
||||
|
||||
[node name="StorageEntity" type="PanelContainer"]
|
||||
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 = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
_sections_unfolded = [ "Focus", "Hint", "Material", "Mouse", "Rect", "Size Flags", "Theme", "Visibility", "custom_styles" ]
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.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 = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Grow Direction", "Size Flags" ]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.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
|
||||
_sections_unfolded = [ "Anchor", "Grow Direction", "Hint", "Margin", "Mouse", "Rect", "Size Flags", "Theme", "custom_constants" ]
|
||||
|
||||
[node name="SpriteView" parent="HBoxContainer" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 32.0
|
||||
margin_bottom = 600.0
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
_sections_unfolded = [ "Rect" ]
|
||||
|
||||
[node name="Name" type="Label" parent="HBoxContainer"]
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 36.0
|
||||
margin_top = 293.0
|
||||
margin_right = 95.0
|
||||
margin_bottom = 307.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 = "Backpack"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "Anchor" ]
|
||||
|
||||
[node name="Control" type="Control" parent="HBoxContainer"]
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 99.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
_sections_unfolded = [ "Mouse", "Size Flags" ]
|
||||
|
||||
[node name="Size" type="Label" parent="HBoxContainer/Control"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -38.0
|
||||
margin_top = -7.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = 7.0
|
||||
grow_horizontal = 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 = "Size 6"
|
||||
align = 2
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "Margin", "Mouse" ]
|
||||
|
||||
Reference in New Issue
Block a user