optional specific help key

This commit is contained in:
2023-02-23 16:20:56 +01:00
parent fb6f079895
commit cc25674987
2 changed files with 15 additions and 13 deletions

View File

@@ -3,10 +3,10 @@ using Godot.Collections;
public partial class console : PopupPanel
{
public RichTextLabel textblock;
public LineEdit line;
public Dictionary commandDict;
public string error = "Not found! :(\n";
private RichTextLabel textblock;
private LineEdit line;
private Dictionary commandDict;
private string error = "Not found! :(\n";
//functions with capital letters can't be used inside the console
public override void _Ready()
@@ -20,11 +20,12 @@ public partial class console : PopupPanel
{
if (Input.IsActionJustPressed("console"))
{
Visible = !Visible;
line.GrabFocus();
player.allowMovement = !Visible;
}
/*if (OS.ReadStringFromStdIn() != "") //not tested yet
OnLineEditTextSubmitted(OS.ReadStringFromStdIn());*/
}
private void OnPopupHide() => player.allowMovement = true;
private void OnLineEditTextSubmitted(string command)
@@ -55,23 +56,24 @@ public partial class console : PopupPanel
private void help(/*string key = ""*/) //bug: optional parameters aren't optional in Call()
private void help()
{
/*if (key.Length == 0)
{*/
textblock.AddText("==================================== Help ====================================\n");
for (int i = 0; i < commandDict.Count; i++)
{
textblock.AddText((i + 1) + ". " + Json.ParseString(commandDict.Keys.ToString()).AsStringArray()[i]);
textblock.AddText(Json.ParseString(commandDict.Values.ToString()).AsStringArray()[i]);
}
/*}
else if (commandDict.ContainsKey(key))
}
private void help(string key) //Optional parameters aren't optional in Call()/Callv() so i use overloads instead
{
key = key.ToLower();
if (key.Length != 0 && commandDict.ContainsKey(key))
{
textblock.AddText(key);
textblock.AddText(commandDict[key].ToString());
}
else textblock.AddText(error);*/
else textblock.AddText(error);
}
private void consoleclear() => textblock.Clear();
private void speed(float multiplier)
@@ -102,4 +104,4 @@ public partial class console : PopupPanel
GetTree().DebugCollisionsHint = !GetTree().DebugCollisionsHint;
textblock.AddText("Visible collision shapes and hitmarker now set to: " + GetTree().DebugCollisionsHint + "\nUse 'reload' to see changes!\n");
}
}
}