diff options
| author | Sophia Pearson <codergal89@gmail.com> | 2022-09-04 13:29:53 +0200 |
|---|---|---|
| committer | Sophia Pearson <codergal89@gmail.com> | 2022-09-04 13:29:53 +0200 |
| commit | 645d1083fecf707a56b07c1fd52df4015885d9ce (patch) | |
| tree | 3415e9ccd9e3c3dfbb382d08583816b0d2836f3d | |
| parent | 6503e483766d3a4e1907ecd9b69e7db4e86e7cb6 (diff) | |
| download | texty-645d1083fecf707a56b07c1fd52df4015885d9ce.tar.xz texty-645d1083fecf707a56b07c1fd52df4015885d9ce.zip | |
game: add StatusLine behavior
| -rw-r--r-- | Assets/Themes/Default.tres | 1 | ||||
| -rw-r--r-- | Scenes/Game.tscn | 35 | ||||
| -rw-r--r-- | Scenes/Texty.tscn | 4 | ||||
| -rw-r--r-- | Scripts/Game.cs | 34 | ||||
| -rw-r--r-- | Scripts/Game/StatusLine.cs | 30 | ||||
| -rw-r--r-- | Scripts/Texty.cs | 30 |
6 files changed, 54 insertions, 80 deletions
diff --git a/Assets/Themes/Default.tres b/Assets/Themes/Default.tres index 6faea67..32fc4b7 100644 --- a/Assets/Themes/Default.tres +++ b/Assets/Themes/Default.tres @@ -18,6 +18,7 @@ [resource] InvertedLabel/colors/font_color = Color( 0, 0, 0, 1 ) InvertedPanelContainer/styles/panel = ExtResource( 1 ) +InvertedRichTextLabel/colors/default_color = Color( 0, 0, 0, 1 ) Label/colors/font_color = Color( 1, 1, 1, 1 ) Label/styles/normal = SubResource( 3 ) LineEdit/colors/cursor_color = Color( 0, 0, 0, 1 ) diff --git a/Scenes/Game.tscn b/Scenes/Game.tscn index c5c22e0..772fed0 100644 --- a/Scenes/Game.tscn +++ b/Scenes/Game.tscn @@ -1,4 +1,6 @@ -[gd_scene format=2] +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Scripts/Game/StatusLine.cs" type="Script" id=1] [node name="Game" type="VBoxContainer"] anchor_right = 1.0 @@ -7,48 +9,53 @@ custom_constants/separation = 0 [node name="StatusLine" type="PanelContainer" parent="."] margin_right = 640.0 -margin_bottom = 29.0 +margin_bottom = 31.0 theme_type_variation = "InvertedPanelContainer" +script = ExtResource( 1 ) +Title = "Adventure Title" [node name="Container" type="HBoxContainer" parent="StatusLine"] margin_left = 8.0 margin_top = 2.0 margin_right = 632.0 -margin_bottom = 27.0 +margin_bottom = 29.0 size_flags_horizontal = 3 -[node name="Title" type="Label" parent="StatusLine/Container"] +[node name="TitleLabel" type="RichTextLabel" parent="StatusLine/Container"] +unique_name_in_owner = true margin_right = 624.0 -margin_bottom = 25.0 +margin_bottom = 27.0 size_flags_horizontal = 3 size_flags_vertical = 6 -theme_type_variation = "InvertedLabel" -text = "Adventure Title" -max_lines_visible = 1 +theme_type_variation = "InvertedRichTextLabel" +bbcode_enabled = true +fit_content_height = true +scroll_active = false [node name="Output" type="PanelContainer" parent="."] -margin_top = 29.0 +margin_top = 31.0 margin_right = 640.0 margin_bottom = 451.0 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="Container" type="ScrollContainer" parent="Output"] +[node name="ScrollContainer" type="ScrollContainer" parent="Output"] margin_left = 8.0 margin_top = 2.0 margin_right = 632.0 -margin_bottom = 420.0 +margin_bottom = 418.0 mouse_filter = 1 size_flags_horizontal = 3 size_flags_vertical = 3 scroll_horizontal_enabled = false -[node name="Lines" type="VBoxContainer" parent="Output/Container"] +[node name="LineContainer" type="VBoxContainer" parent="Output/ScrollContainer"] +unique_name_in_owner = true margin_right = 624.0 margin_bottom = 27.0 size_flags_horizontal = 3 -[node name="RichTextLabel" type="RichTextLabel" parent="Output/Container/Lines"] +[node name="RichTextLabel" type="RichTextLabel" parent="Output/ScrollContainer/LineContainer"] margin_right = 624.0 margin_bottom = 27.0 text = "This is where the output goes" @@ -68,12 +75,14 @@ margin_right = 632.0 margin_bottom = 27.0 [node name="Prompt" type="Label" parent="Input/Container"] +unique_name_in_owner = true margin_right = 20.0 margin_bottom = 25.0 theme_type_variation = "InvertedLabel" text = "?>" [node name="Text" type="LineEdit" parent="Input/Container"] +unique_name_in_owner = true margin_left = 28.0 margin_right = 624.0 margin_bottom = 25.0 diff --git a/Scenes/Texty.tscn b/Scenes/Texty.tscn index a7bdbf9..25892fa 100644 --- a/Scenes/Texty.tscn +++ b/Scenes/Texty.tscn @@ -1,11 +1,9 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://Assets/Shaders/crt_shader.tres" type="Material" id=1] [ext_resource path="res://Scenes/Game.tscn" type="PackedScene" id=2] -[ext_resource path="res://Scripts/Texty.cs" type="Script" id=3] [node name="Texty" type="Node"] -script = ExtResource( 3 ) [node name="Terminal" type="CanvasLayer" parent="."] diff --git a/Scripts/Game.cs b/Scripts/Game.cs deleted file mode 100644 index 07dab9a..0000000 --- a/Scripts/Game.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics; -using Godot; - -namespace Texty.Scripts -{ - public abstract class Game : MarginContainer - { - public CommandParser CommandParser; - public VBoxContainer LayoutContainer; - public OutputContainer OutputContainer; - - [Export(PropertyHint.File, "*.tscn")] public PackedScene OutputRowScene; - - public override void _Ready() - { - Debug.Assert(OutputRowScene != null, $"The {nameof(OutputRowScene)} was not set!"); - - CommandParser = GetNode<CommandParser>(nameof(CommandParser)); - LayoutContainer = GetNode<VBoxContainer>(nameof(LayoutContainer)); - OutputContainer = LayoutContainer.GetNode<OutputContainer>(nameof(OutputContainer)); - } - - public void OnInputSubmitted(string text) - { - var newRow = OutputRowScene.Instance<OutputRow>(); - newRow.InputText = text; - - var command = CommandParser.TryParse(text); - newRow.OutputText = command == null ? "Please rephrase your command" : "THE OUTPUT SHOULD GO HERE!"; - - OutputContainer.Add(newRow); - } - } -}
\ No newline at end of file diff --git a/Scripts/Game/StatusLine.cs b/Scripts/Game/StatusLine.cs new file mode 100644 index 0000000..4a3fb23 --- /dev/null +++ b/Scripts/Game/StatusLine.cs @@ -0,0 +1,30 @@ +using Godot; + +namespace Texty.Scripts.Game +{ + public class StatusLine : PanelContainer + { + private string _titleText = "Title Text"; + + [Export] + public string Title + { + get => _titleText; + set + { + if (TitleLabel != null) + TitleLabel.Text = value; + _titleText = value; + } + } + + public RichTextLabel TitleLabel; + + public override void _Ready() + { + TitleLabel = GetNode<RichTextLabel>($"%{nameof(TitleLabel)}"); + TitleLabel.Text = _titleText; + } + } +} + diff --git a/Scripts/Texty.cs b/Scripts/Texty.cs deleted file mode 100644 index 0101183..0000000 --- a/Scripts/Texty.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Godot; - -namespace Texty.Scripts -{ - public class Texty : Node - { - - public Game Game; - public StartMenu StartMenu; - - public override void _Ready() - { - Game = GetNode<Game>(nameof(Game)); - StartMenu = GetNode<StartMenu>(nameof(StartMenu)); - } - - public void OnQuitGame() - { - GetTree().Notification(MainLoop.NotificationWmQuitRequest); - } - - public void OnStartGame() - { - StartMenu.Visible = false; - Game.Visible = true; - } - - } -} - |
