added dialogue close command
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"help": " [command] - Shows help or help for a specific command\n",
|
||||
"consoleclear": " - Clears the console\n",
|
||||
"speed": " <multiplier number> - Multiplies the player speed by the given value\n",
|
||||
"noclip": " - Toggles the player collision and lets you walk through walls and world barriers\n",
|
||||
"stickycamera": " - Toggles the camera mode. Stickycamera follows the player without limits and extra animation\n",
|
||||
"playername": " <new name> - Renames the player\n",
|
||||
"reload": " - Reloads the current level (for softlocks or other issues)\n",
|
||||
"visiblecollision": " - Toggles if collision shapes hitboxes and hitmarkers are visible. Use 'reload' to see changes!\n"
|
||||
"help": " [command] - Shows help or help for a specific command",
|
||||
"consoleclear": " - Clears the console",
|
||||
"speed": " <multiplier number> - Multiplies the player speed by the given value",
|
||||
"noclip": " - Toggles the player collision and lets you walk through walls and world barriers",
|
||||
"stickycamera": " - Toggles the camera mode. Stickycamera follows the player without limits and extra animation",
|
||||
"playername": " <new name> - Renames the player",
|
||||
"closedialogue": "Closes the current dialogue box",
|
||||
"reload": " - Reloads the current level (for softlocks or other issues)",
|
||||
"visiblecollision": " - Toggles if collision shapes hitboxes and hitmarkers are visible. Use 'reload' to see changes!"
|
||||
}
|
@@ -3,7 +3,7 @@ using Godot.Collections;
|
||||
|
||||
public partial class console : PopupPanel
|
||||
{
|
||||
private RichTextLabel textblock;
|
||||
private static RichTextLabel textblock;
|
||||
private LineEdit line;
|
||||
private Dictionary commandDict;
|
||||
private string error = "Not found! :(\n";
|
||||
@@ -31,7 +31,7 @@ public partial class console : PopupPanel
|
||||
private void OnLineEditTextSubmitted(string command)
|
||||
{
|
||||
line.Clear();
|
||||
if (command.Length != 0) textblock.AddText(player_variables.PlayerName + " > " + command + "\n");
|
||||
if (command.Length != 0) Print(player_variables.PlayerName + " > " + command + "\n");
|
||||
Variant args;
|
||||
if (command.Split(' ').Length == 2 && commandDict.ContainsKey(command.Split(' ')[0].ToLower()))
|
||||
{
|
||||
@@ -51,18 +51,21 @@ public partial class console : PopupPanel
|
||||
{
|
||||
Call(command.ToLower());
|
||||
}
|
||||
else if (command.Length != 0) textblock.AddText(error);
|
||||
else if (command.Length != 0) Print(error);
|
||||
}
|
||||
public static void Print(string text)
|
||||
{
|
||||
textblock.AddText(text + "\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void help()
|
||||
{
|
||||
textblock.AddText("==================================== Help ====================================\n");
|
||||
Print("==================================== 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]);
|
||||
Print((i + 1) + ". " + Json.ParseString(commandDict.Keys.ToString()).AsStringArray()[i]);
|
||||
Print(Json.ParseString(commandDict.Values.ToString()).AsStringArray()[i]);
|
||||
}
|
||||
}
|
||||
private void help(string key) //Optional parameters aren't optional in Call()/Callv() so i use overloads instead
|
||||
@@ -70,12 +73,12 @@ public partial class console : PopupPanel
|
||||
key = key.ToLower();
|
||||
if (key.Length != 0 && commandDict.ContainsKey(key))
|
||||
{
|
||||
textblock.AddText(key);
|
||||
textblock.AddText(commandDict[key].ToString());
|
||||
Print(key);
|
||||
Print(commandDict[key].ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
textblock.AddText(error);
|
||||
Print(error);
|
||||
help("help");
|
||||
};
|
||||
}
|
||||
@@ -83,39 +86,44 @@ public partial class console : PopupPanel
|
||||
private void speed(float multiplier)
|
||||
{
|
||||
player.speed = Mathf.Clamp(multiplier, 0.01f, 15f);
|
||||
textblock.AddText("Set player speed to " + Mathf.Clamp(multiplier, 0.01f, 15f) + "\n");
|
||||
Print("Set player speed to " + Mathf.Clamp(multiplier, 0.01f, 15f));
|
||||
}
|
||||
private void noclip()
|
||||
{
|
||||
try { textblock.AddText(player.CollisionToggle()); }
|
||||
try { Print(player.CollisionToggle()); }
|
||||
catch
|
||||
{
|
||||
textblock.AddText("Player is not accessable\n");
|
||||
Print("Player is not accessable");
|
||||
help("noclip");
|
||||
}
|
||||
}
|
||||
private void stickycamera()
|
||||
{
|
||||
try { textblock.AddText(player.CheatCam()); }
|
||||
try { Print(player.CheatCam()); }
|
||||
catch
|
||||
{
|
||||
textblock.AddText("Player is not accessable\n");
|
||||
Print("Player is not accessable");
|
||||
help("stickycamera");
|
||||
}
|
||||
}
|
||||
private void playername(string name)
|
||||
{
|
||||
player_variables.PlayerName = name;
|
||||
textblock.AddText("Your new name is now: " + player_variables.PlayerName + "\n");
|
||||
Print("Your new name is now: " + player_variables.PlayerName);
|
||||
}
|
||||
private void closedialogue()
|
||||
{
|
||||
dialog_bubble.forceClose = true;
|
||||
Print("Dialogue got closed!");
|
||||
}
|
||||
private void reload()
|
||||
{
|
||||
GetTree().ReloadCurrentScene();
|
||||
textblock.AddText("Level got reloaded!\n");
|
||||
Print("Level got reloaded!");
|
||||
}
|
||||
private void visiblecollision()
|
||||
{
|
||||
GetTree().DebugCollisionsHint = !GetTree().DebugCollisionsHint;
|
||||
textblock.AddText("Visible collision shapes and hitmarker now set to: " + GetTree().DebugCollisionsHint + "\nUse 'reload' to see changes!\n");
|
||||
Print("Visible collision shapes and hitmarker now set to: " + GetTree().DebugCollisionsHint + "\nUse 'reload' to see changes!");
|
||||
}
|
||||
}
|
@@ -10,6 +10,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
public Timer typewriterTimer;
|
||||
public string title;
|
||||
public Area2D triggerArea;
|
||||
public static bool forceClose;
|
||||
/*TODO:
|
||||
- Dont repeat the same randomized dialogue after you get asked do you need something "else"
|
||||
- add tree support (example: "story" key)
|
||||
@@ -24,6 +25,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
}
|
||||
public void GetDialog(string file, Area2D actor)
|
||||
{
|
||||
console.Print("Loaded dialogue from: " + file + "\nClose dialogue with 'closedialogue'");
|
||||
triggerArea = actor;
|
||||
title = actor.Get("title").AsString();
|
||||
bool introducedVillager = actor.Get("introducedVillager").AsBool();
|
||||
@@ -69,7 +71,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
{
|
||||
if (Input.IsActionJustPressed("ui_cancel")) richText.VisibleCharacters = richText.Text.Length;
|
||||
|
||||
if (Input.IsActionJustPressed("ui_accept") && GetNode<PanelContainer>("box/panel_container").Visible == false
|
||||
if (Input.IsActionJustPressed("ui_accept") && GetNode<console>("/root/Console").Visible == false && GetNode<PanelContainer>("box/panel_container").Visible == false
|
||||
&& richText.VisibleCharacters == -1 | Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length <= richText.VisibleCharacters)
|
||||
{
|
||||
if (dlgPointer < dlgLines.AsGodotArray().Count)
|
||||
@@ -89,7 +91,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
}
|
||||
dlgPointer++;
|
||||
}
|
||||
if (dlgPointer > dlgLines.AsGodotArray().Count)
|
||||
if (dlgPointer > dlgLines.AsGodotArray().Count || forceClose)
|
||||
CloseDialog();
|
||||
}
|
||||
public void UpdateDialog()
|
||||
@@ -127,7 +129,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
if (GetNode<PanelContainer>("box/panel_container").Visible == true
|
||||
&& GetNode("box/panel_container/margin_container").GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton() != null)
|
||||
{
|
||||
GetNode<AudioStreamPlayer>("answerbtn_audio_stream").Play();
|
||||
GetNode<AudioStreamPlayer>("answerbtn_audio_stream").Play(); //BUG: dialogue box breaks while game console is open.
|
||||
var answer = dlgLines.AsGodotArray()[dlgPointer - 1].AsGodotDictionary()[GetNode<Button>(GetNode("box/panel_container/margin_container")
|
||||
.GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton().GetPath()).Text];
|
||||
GetNode<PanelContainer>("box/panel_container").Visible = false;
|
||||
@@ -151,6 +153,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseDialog()
|
||||
{
|
||||
Visible = false;
|
||||
@@ -159,5 +162,6 @@ public partial class dialog_bubble : CanvasLayer
|
||||
GetNode<Label>("box/name_label").Text = "???";
|
||||
richText.Text = "";
|
||||
if (GetParent().Name == "player") player.allowMovement = true;
|
||||
forceClose = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user