diff options
| author | Sophia Pearson <codergal89@gmail.com> | 2022-10-03 22:22:50 +0200 |
|---|---|---|
| committer | Sophia Pearson <codergal89@gmail.com> | 2022-10-04 22:18:18 +0200 |
| commit | e127ad39e742396030352240d829bc903b1d4464 (patch) | |
| tree | 10cc21d70bf13181aef7c8ad0344077ff63579a3 /Scripts/Terminal | |
| parent | ddbb045f6387a8ba23b1210b27a745516a387a52 (diff) | |
| download | texty-e127ad39e742396030352240d829bc903b1d4464.tar.xz texty-e127ad39e742396030352240d829bc903b1d4464.zip | |
godot: inital Godot 4 migration
Diffstat (limited to 'Scripts/Terminal')
| -rw-r--r-- | Scripts/Terminal/ButtonBlock.cs | 10 | ||||
| -rw-r--r-- | Scripts/Terminal/InputArea.cs | 10 | ||||
| -rw-r--r-- | Scripts/Terminal/MenuScreen.cs | 2 | ||||
| -rw-r--r-- | Scripts/Terminal/OutputArea.cs | 8 | ||||
| -rw-r--r-- | Scripts/Terminal/OutputBlock.cs | 6 | ||||
| -rw-r--r-- | Scripts/Terminal/StatusArea.cs | 4 |
6 files changed, 21 insertions, 19 deletions
diff --git a/Scripts/Terminal/ButtonBlock.cs b/Scripts/Terminal/ButtonBlock.cs index 769fdf8..ef25f8c 100644 --- a/Scripts/Terminal/ButtonBlock.cs +++ b/Scripts/Terminal/ButtonBlock.cs @@ -1,12 +1,10 @@ using System.Linq; using Godot; -using Godot.Collections; using Texty.Scripts.GodotExtensions; namespace Texty.Scripts.Terminal { - [Tool] - public abstract class ButtonBlock : MarginContainer + public partial class ButtonBlock : MarginContainer { private VBoxContainer Buttons => GetNodeOrNull<VBoxContainer>($"%{nameof(Buttons)}"); @@ -17,12 +15,14 @@ namespace Texty.Scripts.Terminal Buttons.GetChildren<Button>().FirstOrDefault()?.GrabFocus(); } - protected abstract void OnButtonPressed(int index); + protected virtual void OnButtonPressed(int index) + { + } private void ConnectButtons() { foreach (var (button, index) in Buttons.GetChildren<Button>().Select((button, index) => (button, index))) - button.Connect("pressed", this, nameof(OnButtonPressed), new Array(index)); + button.Pressed += () => OnButtonPressed(index); } } }
\ No newline at end of file diff --git a/Scripts/Terminal/InputArea.cs b/Scripts/Terminal/InputArea.cs index eb78d38..a32ad2c 100644 --- a/Scripts/Terminal/InputArea.cs +++ b/Scripts/Terminal/InputArea.cs @@ -1,15 +1,17 @@ -using System; using Godot; namespace Texty.Scripts.Terminal { - public abstract class InputArea : HBoxContainer + public partial class InputArea : HBoxContainer { protected Label PromptLabel => GetNodeOrNull<Label>($"%{nameof(PromptLabel)}"); protected LineEdit TextInput => GetNodeOrNull<LineEdit>($"%{nameof(TextInput)}"); public new bool HasFocus => TextInput?.HasFocus() ?? false; - - public abstract void OnTextEntered(string text); + + public virtual void OnTextEntered(string text) + { + + } } }
\ No newline at end of file diff --git a/Scripts/Terminal/MenuScreen.cs b/Scripts/Terminal/MenuScreen.cs index 5c3abfb..1259b31 100644 --- a/Scripts/Terminal/MenuScreen.cs +++ b/Scripts/Terminal/MenuScreen.cs @@ -3,7 +3,7 @@ using Godot; namespace Texty.Scripts.Terminal { [Tool] - public class MenuScreen : Control + public partial class MenuScreen : Control { private string _title = ""; private StatusArea TitleArea => GetNodeOrNull<StatusArea>($"%{nameof(TitleArea)}"); diff --git a/Scripts/Terminal/OutputArea.cs b/Scripts/Terminal/OutputArea.cs index 6de4ac1..e297c49 100644 --- a/Scripts/Terminal/OutputArea.cs +++ b/Scripts/Terminal/OutputArea.cs @@ -7,7 +7,7 @@ using Texty.Scripts.Game; namespace Texty.Scripts.Terminal { - public class OutputArea : ScrollContainer + public partial class OutputArea : ScrollContainer { [Export(PropertyHint.File, "*.tscn")] public PackedScene OutputBlockScene; public Array<string> TextBlocks => new Array<string>(BlockNodes.ToList().Select(block => block.Content)); @@ -22,7 +22,7 @@ namespace Texty.Scripts.Terminal public override void _Ready() { Debug.Assert(OutputBlockScene != null, "OutputBlockScene has not been configured!"); - Debug.Assert(OutputBlockScene.CanInstance(), "OutputBlockScene can not be instanced!"); + Debug.Assert(OutputBlockScene.CanInstantiate(), "OutputBlockScene can not be instanced!"); Clear(); } @@ -37,8 +37,8 @@ namespace Texty.Scripts.Terminal public void Push(string text) { - if (text.Empty()) return; - var block = OutputBlockScene.Instance<OutputBlock>(); + if (string.IsNullOrEmpty(text)) return; + var block = OutputBlockScene.Instantiate<OutputBlock>(); block.Content = text; LineContainer.AddChild(block); } diff --git a/Scripts/Terminal/OutputBlock.cs b/Scripts/Terminal/OutputBlock.cs index 08b2ab2..4512446 100644 --- a/Scripts/Terminal/OutputBlock.cs +++ b/Scripts/Terminal/OutputBlock.cs @@ -3,7 +3,7 @@ using Godot; namespace Texty.Scripts.Terminal { [Tool] - public class OutputBlock : MarginContainer + public partial class OutputBlock : MarginContainer { private string _content = ""; @@ -12,12 +12,12 @@ namespace Texty.Scripts.Terminal [Export(PropertyHint.MultilineText)] public string Content { - get => ContentLabel?.BbcodeText ?? ""; + get => ContentLabel?.Text ?? ""; set { _content = value; if (ContentLabel != null) - ContentLabel.BbcodeText = GodotSharp.Singleton.Tr(_content); + ContentLabel.Text = GodotSharp.Singleton.Tr(_content); } } diff --git a/Scripts/Terminal/StatusArea.cs b/Scripts/Terminal/StatusArea.cs index 35bc1c7..3099168 100644 --- a/Scripts/Terminal/StatusArea.cs +++ b/Scripts/Terminal/StatusArea.cs @@ -3,7 +3,7 @@ using Godot; namespace Texty.Scripts.Terminal { [Tool] - public class StatusArea : HBoxContainer + public partial class StatusArea : HBoxContainer { private string _titleText = ""; private RichTextLabel TitleLabel => GetNodeOrNull<RichTextLabel>($"%{nameof(TitleLabel)}"); @@ -16,7 +16,7 @@ namespace Texty.Scripts.Terminal { _titleText = value; if (TitleLabel != null) - TitleLabel.BbcodeText = GodotSharp.Singleton.Tr(value); + TitleLabel.Text = GodotSharp.Singleton.Tr(value); } } |
