From b92ea9a2aa445a4710e55cc6eb669f315050377c Mon Sep 17 00:00:00 2001 From: moneyl <8206401+Moneyl@users.noreply.github.com> Date: Fri, 24 May 2019 10:57:13 -0400 Subject: [PATCH] Remove GUI dependence on tscn files (#812) * Remove unused options menu tscn * Move SS14Window to pure C# * Move SpriteView to pure C# * Move EntitySpawnWindow and EntitySpawnItem to pure C# * Removes using statements accidentally added by resharper * Set EntitySpawnWindow default size to normal value Note that in construction menu and storage menu this had to be done in the object initializer and didn't work if it was set in the Initialize function for the respective menus. For whatever reason setting it in the EntitySpawnWindow.Initialize works fine. --- Resources/Scenes/OptionsMenu/OptionsMenu.tscn | 115 --------- .../Scenes/Placement/EntitySpawnItem.tscn | 115 --------- .../Scenes/Placement/EntitySpawnPanel.tscn | 222 ------------------ Resources/Scenes/SS14Window/SS14Window.tscn | 53 ----- Resources/Scenes/SpriteMirror/SpriteView.tscn | 17 -- .../UserInterface/Controls/SpriteView.cs | 1 - .../CustomControls/EntitySpawnWindow.cs | 133 +++++++++-- .../CustomControls/SS14Window.cs | 65 +++-- 8 files changed, 163 insertions(+), 558 deletions(-) delete mode 100644 Resources/Scenes/OptionsMenu/OptionsMenu.tscn delete mode 100644 Resources/Scenes/Placement/EntitySpawnItem.tscn delete mode 100644 Resources/Scenes/Placement/EntitySpawnPanel.tscn delete mode 100644 Resources/Scenes/SS14Window/SS14Window.tscn delete mode 100644 Resources/Scenes/SpriteMirror/SpriteView.tscn diff --git a/Resources/Scenes/OptionsMenu/OptionsMenu.tscn b/Resources/Scenes/OptionsMenu/OptionsMenu.tscn deleted file mode 100644 index fd714a86f11..00000000000 --- a/Resources/Scenes/OptionsMenu/OptionsMenu.tscn +++ /dev/null @@ -1,115 +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" instance=ExtResource( 1 )] - -margin_left = 370.0 -margin_top = 112.0 -margin_right = 519.0 -margin_bottom = 239.0 -mouse_default_cursor_shape = 0 - -[node name="Contents" parent="." index="0"] - -mouse_default_cursor_shape = 0 - -[node name="VBoxContainer" 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 ) -mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 - -[node name="VSyncCheckBox" type="CheckBox" parent="Contents/VBoxContainer" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 129.0 -margin_bottom = 24.0 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -custom_colors/font_color = Color( 1, 1, 1, 1 ) -toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null -text = "VSync" -flat = false -align = 0 -_sections_unfolded = [ "custom_colors" ] - -[node name="FullscreenCheckBox" type="CheckBox" parent="Contents/VBoxContainer" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 28.0 -margin_right = 129.0 -margin_bottom = 52.0 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null -text = "FullScreen" -flat = false -align = 0 - -[node name="ApplyButton" type="Button" parent="Contents/VBoxContainer" index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 56.0 -margin_right = 129.0 -margin_bottom = 76.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -disabled = true -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null -text = "Apply Changes" -flat = false -align = 1 -_sections_unfolded = [ "Margin" ] - -[node name="Header" parent="." index="1"] - -mouse_default_cursor_shape = 0 - -[node name="Header Text" parent="Header" index="0"] - -mouse_default_cursor_shape = 0 -text = "Options Menu" - -[node name="CloseButton" parent="Header" index="1"] - -focus_mode = 2 -mouse_default_cursor_shape = 0 - - diff --git a/Resources/Scenes/Placement/EntitySpawnItem.tscn b/Resources/Scenes/Placement/EntitySpawnItem.tscn deleted file mode 100644 index 0874ee8ad3c..00000000000 --- a/Resources/Scenes/Placement/EntitySpawnItem.tscn +++ /dev/null @@ -1,115 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[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="EntitySpawnItem" type="PanelContainer"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 102.0 -margin_bottom = 32.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 1 -custom_styles/panel = SubResource( 1 ) -_sections_unfolded = [ "Grow Direction", "Mouse", "Rect", "Size Flags", "custom_styles" ] - -[node name="Button" type="Button" parent="." index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 102.0 -margin_bottom = 32.0 -rect_pivot_offset = Vector2( 0, 0 ) -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 = [ "Size Flags" ] - -[node name="HBoxContainer" type="HBoxContainer" parent="." index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 102.0 -margin_bottom = 32.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -_sections_unfolded = [ "Grow Direction", "Mouse", "Size Flags" ] - -[node name="TextureWrap" type="Control" parent="HBoxContainer" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 32.0 -margin_bottom = 32.0 -rect_min_size = Vector2( 32, 32 ) -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -rect_clip_content = true -_sections_unfolded = [ "Mouse", "Rect" ] - -[node name="TextureRect" type="TextureRect" parent="HBoxContainer/TextureWrap" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 4 -size_flags_vertical = 4 -_sections_unfolded = [ "Focus", "Grow Direction", "Hint", "Margin", "Mouse", "Rect", "Size Flags", "Theme" ] - -[node name="Label" type="Label" parent="HBoxContainer" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 36.0 -margin_top = 9.0 -margin_right = 95.0 -margin_bottom = 23.0 -rect_pivot_offset = Vector2( 0, 0 ) -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 = [ "Mouse" ] - - diff --git a/Resources/Scenes/Placement/EntitySpawnPanel.tscn b/Resources/Scenes/Placement/EntitySpawnPanel.tscn deleted file mode 100644 index 88ac628bc18..00000000000 --- a/Resources/Scenes/Placement/EntitySpawnPanel.tscn +++ /dev/null @@ -1,222 +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" instance=ExtResource( 1 )] - -margin_right = 532.0 -margin_bottom = 398.0 -_sections_unfolded = [ "Margin" ] - -[node name="Contents" parent="." index="0"] - -mouse_filter = 1 - -[node name="HSplitContainer" type="HSplitContainer" 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 ) -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 = [ "Mouse" ] - -[node name="PrototypeListScrollContainer" type="ScrollContainer" parent="Contents/HSplitContainer" index="0"] - -editor/display_folded = true -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 200.0 -margin_bottom = 310.0 -rect_min_size = Vector2( 200, 0 ) -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = true -mouse_filter = 1 -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", "Grow Direction", "Margin", "Mouse", "Rect", "Scroll", "Size Flags" ] - -[node name="PrototypeList" type="VBoxContainer" parent="Contents/HSplitContainer/PrototypeListScrollContainer" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 200.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 1 -custom_constants/separation = 2 -alignment = 0 -_sections_unfolded = [ "Focus", "Hint", "Mouse", "Rect", "Size Flags", "custom_constants" ] - -[node name="Options" type="VBoxContainer" parent="Contents/HSplitContainer" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 212.0 -margin_right = 412.0 -margin_bottom = 310.0 -rect_min_size = Vector2( 200, 0 ) -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 0 -_sections_unfolded = [ "Hint", "Margin", "Mouse", "Rect" ] - -[node name="SearchBar" type="LineEdit" parent="Contents/HSplitContainer/Options" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 200.0 -margin_bottom = 24.0 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 1 -size_flags_horizontal = 1 -size_flags_vertical = 1 -focus_mode = 2 -context_menu_enabled = true -placeholder_text = "Search Entities" -placeholder_alpha = 0.6 -caret_blink = false -caret_blink_speed = 0.65 -caret_position = 0 -_sections_unfolded = [ "Placeholder" ] - -[node name="Buttons!" type="HBoxContainer" parent="Contents/HSplitContainer/Options" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 28.0 -margin_right = 200.0 -margin_bottom = 48.0 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -alignment = 1 -_sections_unfolded = [ "Mouse" ] - -[node name="ClearButton" type="Button" parent="Contents/HSplitContainer/Options/Buttons!" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 98.0 -margin_bottom = 20.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 1 -disabled = true -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null -text = "Clear Search" -flat = false -align = 1 -_sections_unfolded = [ "Grow Direction", "Rect", "Size Flags" ] - -[node name="EraseButton" type="Button" parent="Contents/HSplitContainer/Options/Buttons!" index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_left = 102.0 -margin_right = 200.0 -margin_bottom = 20.0 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 3 -size_flags_vertical = 1 -toggle_mode = true -enabled_focus_mode = 2 -shortcut = null -group = null -text = "Erase Mode" -flat = false -align = 1 - -[node name="OverridePlacementText" type="Label" parent="Contents/HSplitContainer/Options" index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 52.0 -margin_right = 200.0 -margin_bottom = 66.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 -text = "Override Placement:" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 - -[node name="OverrideMenu" type="OptionButton" parent="Contents/HSplitContainer/Options" index="3"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 70.0 -margin_right = 200.0 -margin_bottom = 90.0 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -toggle_mode = false -action_mode = 0 -enabled_focus_mode = 2 -shortcut = null -group = null -flat = false -align = 0 -selected = -1 -items = [ ] - -[node name="Header Text" parent="Header" index="0"] - -text = "Entity Spawn Panel" - - diff --git a/Resources/Scenes/SS14Window/SS14Window.tscn b/Resources/Scenes/SS14Window/SS14Window.tscn deleted file mode 100644 index 288cf74bb76..00000000000 --- a/Resources/Scenes/SS14Window/SS14Window.tscn +++ /dev/null @@ -1,53 +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] - -bg_color = Color( 0.234375, 0.234375, 0.234375, 1 ) - -[node name="SS14Window" type="Panel"] -margin_left = 100.0 -margin_top = 38.0 -margin_right = 878.0 -margin_bottom = 519.0 - -[node name="Contents" type="MarginContainer" parent="."] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 0.0 -margin_top = 30.0 -margin_right = 0.0 -margin_bottom = 0.0 -rect_min_size = Vector2( 50, 50 ) -rect_clip_content = true -mouse_filter = 2 -custom_constants/margin_right = 10 -custom_constants/margin_left = 10 -custom_constants/margin_bottom = 10 -custom_constants/margin_top = 10 - -[node name="Header" type="Panel" parent="."] -anchor_right = 1.0 -margin_bottom = 25.0 -mouse_filter = 2 -custom_styles/panel = SubResource( 1 ) - -[node name="Header Text" type="Label" parent="Header"] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_right = -25.0 -text = "Exemplary Window Title Here" -align = 1 -valign = 1 -clip_text = true - -[node name="CloseButton" type="TextureButton" parent="Header"] -anchor_left = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = -25.0 -texture_normal = ExtResource( 1 ) -expand = true -stretch_mode = 5 - diff --git a/Resources/Scenes/SpriteMirror/SpriteView.tscn b/Resources/Scenes/SpriteMirror/SpriteView.tscn deleted file mode 100644 index 9404c948ebe..00000000000 --- a/Resources/Scenes/SpriteMirror/SpriteView.tscn +++ /dev/null @@ -1,17 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://SpriteView.cs" type="Script" id=1] - -[node name="SpriteView" type="Control"] -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 = 1 -size_flags_vertical = 1 -script = ExtResource( 1 ) - diff --git a/Robust.Client/UserInterface/Controls/SpriteView.cs b/Robust.Client/UserInterface/Controls/SpriteView.cs index b2d13f820cd..c3ec2489fb0 100644 --- a/Robust.Client/UserInterface/Controls/SpriteView.cs +++ b/Robust.Client/UserInterface/Controls/SpriteView.cs @@ -10,7 +10,6 @@ namespace Robust.Client.UserInterface.Controls { - [ControlWrap("res://Engine/Scenes/SpriteMirror/SpriteView.tscn")] public class SpriteView : Control { ISpriteProxy Mirror; diff --git a/Robust.Client/UserInterface/CustomControls/EntitySpawnWindow.cs b/Robust.Client/UserInterface/CustomControls/EntitySpawnWindow.cs index ccc835c0b55..667079879ae 100644 --- a/Robust.Client/UserInterface/CustomControls/EntitySpawnWindow.cs +++ b/Robust.Client/UserInterface/CustomControls/EntitySpawnWindow.cs @@ -15,14 +15,12 @@ namespace Robust.Client.UserInterface.CustomControls { public sealed class EntitySpawnWindow : SS14Window { - protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Placement/EntitySpawnPanel.tscn"); - private readonly IPlacementManager placementManager; private readonly IPrototypeManager prototypeManager; private readonly IResourceCache resourceCache; private Control HSplitContainer; - private Control PrototypeList; + private VBoxContainer PrototypeList; private LineEdit SearchBar; private OptionButton OverrideMenu; private Button ClearButton; @@ -63,27 +61,85 @@ protected override void Initialize() { base.Initialize(); - // Get all the controls. - HSplitContainer = Contents.GetChild("HSplitContainer"); - PrototypeList = HSplitContainer.GetChild("PrototypeListScrollContainer").GetChild("PrototypeList"); - var options = HSplitContainer.GetChild("Options"); - SearchBar = options.GetChild("SearchBar"); + Title = "Entity Spawn Panel"; + + HSplitContainer = new HSplitContainer + { + Name = "HSplitContainer", + MouseFilter = MouseFilterMode.Pass + }; + + // Left side + var prototypeListScroll = new ScrollContainer("PrototypeListScrollContainer") + { + CustomMinimumSize = new Vector2(200.0f, 0.0f), + RectClipContent = true, + SizeFlagsHorizontal = SizeFlags.FillExpand, + HScrollEnabled = true, + VScrollEnabled = true + }; + PrototypeList = new VBoxContainer("PrototypeList") + { + MouseFilter = MouseFilterMode.Ignore, + SizeFlagsHorizontal = SizeFlags.FillExpand, + SeparationOverride = new int?(2), + Align = BoxContainer.AlignMode.Begin + }; + prototypeListScroll.AddChild(PrototypeList); + HSplitContainer.AddChild(prototypeListScroll); + + // Right side + var options = new VBoxContainer("Options") + { + CustomMinimumSize = new Vector2(200.0f, 0.0f), MouseFilter = MouseFilterMode.Ignore + }; + + SearchBar = new LineEdit("SearchBar") {MouseFilter = MouseFilterMode.Stop, PlaceHolder = "Search Entities"}; SearchBar.OnTextChanged += OnSearchBarTextChanged; + options.AddChild(SearchBar); - OverrideMenu = options.GetChild("OverrideMenu"); - OverrideMenu.OnItemSelected += OnOverrideMenuItemSelected; + var buttons = new HBoxContainer("Buttons!") + { + MouseFilter = MouseFilterMode.Ignore + }; + ClearButton = new Button("ClearButton") + { + SizeFlagsHorizontal = SizeFlags.FillExpand, + Disabled = true, + ToggleMode = false, + Text = "Clear Search", + }; + ClearButton.OnPressed += OnClearButtonPressed; + EraseButton = new Button("EraseButton") + { + SizeFlagsHorizontal = SizeFlags.FillExpand, + ToggleMode = true, + Text = "Erase Mode" + }; + EraseButton.OnToggled += OnEraseButtonToggled; + buttons.AddChild(ClearButton); + buttons.AddChild(EraseButton); + options.AddChild(buttons); + var overridePlacementText = new Label("OverridePlacementText") + { + MouseFilter = MouseFilterMode.Ignore, + SizeFlagsVertical = SizeFlags.ShrinkCenter, + Text = "Override Placement:" + }; + OverrideMenu = new OptionButton("OverrideMenu") {ToggleMode = false};//, TextAlign = Button.AlignMode.Left}; + OverrideMenu.OnItemSelected += OnOverrideMenuItemSelected; for (var i = 0; i < initOpts.Length; i++) { OverrideMenu.AddItem(initOpts[i], i); } - var buttons = options.GetChild("Buttons!"); - ClearButton = buttons.GetChild