Removed chatbox dependence on tscn file
This turned out to be much simpler than how I was initially making it. The important thing to note is that without setting the margin and anchor values for the chatbox itself (not it's children) it won't show up on the screen.
This commit is contained in:
@@ -11,8 +11,6 @@ namespace Content.Client.Chat
|
|||||||
{
|
{
|
||||||
public class ChatBox : PanelContainer
|
public class ChatBox : PanelContainer
|
||||||
{
|
{
|
||||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/ChatBox/ChatBox.tscn");
|
|
||||||
|
|
||||||
public delegate void TextSubmitHandler(ChatBox chatBox, string text);
|
public delegate void TextSubmitHandler(ChatBox chatBox, string text);
|
||||||
|
|
||||||
private const int MaxLinePixelLength = 500;
|
private const int MaxLinePixelLength = 500;
|
||||||
@@ -43,19 +41,28 @@ namespace Content.Client.Chat
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
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;
|
||||||
|
|
||||||
|
VBoxContainer VBox = new VBoxContainer("VBoxContainer");
|
||||||
|
|
||||||
|
contents = new OutputPanel();
|
||||||
|
contents.SizeFlagsVertical = SizeFlags.FillExpand;
|
||||||
|
VBox.AddChild(contents);
|
||||||
|
|
||||||
|
Input = new LineEdit("Input");
|
||||||
Input.OnKeyDown += InputKeyDown;
|
Input.OnKeyDown += InputKeyDown;
|
||||||
Input.OnTextEntered += Input_OnTextEntered;
|
Input.OnTextEntered += Input_OnTextEntered;
|
||||||
GetChild<Control>("VBoxContainer/Contents").Dispose();
|
VBox.AddChild(Input);
|
||||||
|
|
||||||
contents = new OutputPanel
|
AddChild(VBox);
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
};
|
|
||||||
GetChild("VBoxContainer").AddChild(contents);
|
|
||||||
contents.SetPositionInParent(0);
|
|
||||||
|
|
||||||
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Gray.WithAlpha(0.5f)};
|
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.Gray.WithAlpha(0.5f) };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MouseDown(GUIMouseButtonEventArgs e)
|
protected override void MouseDown(GUIMouseButtonEventArgs e)
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://Engine/Fonts/CALIBRI.TTF" type="DynamicFontData" id=1]
|
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=3]
|
|
||||||
|
|
||||||
content_margin_left = -1.0
|
|
||||||
content_margin_right = -1.0
|
|
||||||
content_margin_top = -1.0
|
|
||||||
content_margin_bottom = -1.0
|
|
||||||
bg_color = Color( 0.501961, 0.501961, 0.501961, 0.501961 )
|
|
||||||
draw_center = true
|
|
||||||
border_width_left = 1
|
|
||||||
border_width_top = 1
|
|
||||||
border_width_right = 1
|
|
||||||
border_width_bottom = 1
|
|
||||||
border_color = Color( 0, 0, 0, 0.501961 )
|
|
||||||
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 = 1.0
|
|
||||||
expand_margin_right = 1.0
|
|
||||||
expand_margin_top = 1.0
|
|
||||||
expand_margin_bottom = 1.0
|
|
||||||
shadow_color = Color( 0, 0, 0, 0.6 )
|
|
||||||
shadow_size = 0
|
|
||||||
anti_aliasing = true
|
|
||||||
anti_aliasing_size = 1
|
|
||||||
_sections_unfolded = [ "Anti Aliasing", "Border Width", "Corner Radius", "Expand Margin", "Shadow" ]
|
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
|
||||||
|
|
||||||
size = 16
|
|
||||||
use_mipmaps = false
|
|
||||||
use_filter = false
|
|
||||||
font_data = ExtResource( 1 )
|
|
||||||
_sections_unfolded = [ "Extra Spacing", "Font/fallback", "Settings" ]
|
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=2]
|
|
||||||
|
|
||||||
content_margin_left = 2.0
|
|
||||||
content_margin_right = -1.0
|
|
||||||
content_margin_top = -1.0
|
|
||||||
content_margin_bottom = -1.0
|
|
||||||
bg_color = Color( 0.0234375, 0.0234375, 0.0234375, 0.501961 )
|
|
||||||
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 = 1
|
|
||||||
corner_radius_top_right = 1
|
|
||||||
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
|
|
||||||
_sections_unfolded = [ "Content Margin", "Corner Radius", "Expand Margin" ]
|
|
||||||
|
|
||||||
[node name="ChatBox" type="PanelContainer" index="0"]
|
|
||||||
|
|
||||||
anchor_left = 1.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = -475.0
|
|
||||||
margin_top = 10.0
|
|
||||||
margin_right = -10.0
|
|
||||||
margin_bottom = 185.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
|
|
||||||
custom_styles/panel = SubResource( 3 )
|
|
||||||
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Rect", "custom_styles" ]
|
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="." index="0"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 1.0
|
|
||||||
margin_top = 1.0
|
|
||||||
margin_right = 464.0
|
|
||||||
margin_bottom = 174.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="Contents" type="RichTextLabel" parent="VBoxContainer" index="0"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_right = 463.0
|
|
||||||
margin_bottom = 153.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = true
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 3
|
|
||||||
custom_fonts/normal_font = SubResource( 1 )
|
|
||||||
bbcode_enabled = false
|
|
||||||
bbcode_text = ""
|
|
||||||
visible_characters = -1
|
|
||||||
percent_visible = 1.0
|
|
||||||
meta_underlined = true
|
|
||||||
tab_size = 4
|
|
||||||
text = ""
|
|
||||||
scroll_active = true
|
|
||||||
scroll_following = false
|
|
||||||
selection_enabled = false
|
|
||||||
override_selected_font_color = false
|
|
||||||
_sections_unfolded = [ "BBCode", "Size Flags", "custom_fonts" ]
|
|
||||||
|
|
||||||
[node name="Input" type="LineEdit" parent="VBoxContainer" index="1"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_top = 157.0
|
|
||||||
margin_right = 463.0
|
|
||||||
margin_bottom = 173.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
focus_mode = 2
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 1
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
custom_styles/normal = SubResource( 2 )
|
|
||||||
custom_fonts/font = SubResource( 1 )
|
|
||||||
focus_mode = 2
|
|
||||||
context_menu_enabled = true
|
|
||||||
placeholder_alpha = 0.6
|
|
||||||
caret_blink = true
|
|
||||||
caret_blink_speed = 0.5
|
|
||||||
caret_position = 0
|
|
||||||
_sections_unfolded = [ "Margin", "custom_colors", "custom_constants", "custom_fonts", "custom_styles" ]
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user