konami code
This commit is contained in:
@@ -127,6 +127,11 @@ console={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194334,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194334,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
cheat_start={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[internationalization]
|
[internationalization]
|
||||||
|
|
||||||
|
@@ -3,6 +3,9 @@ using Godot.Collections;
|
|||||||
|
|
||||||
public partial class console : PopupPanel
|
public partial class console : PopupPanel
|
||||||
{
|
{
|
||||||
|
private string[] gamepadCheatcode = { "ui_up", "ui_up", "ui_down", "ui_down", "ui_left", "ui_right", "ui_left", "ui_right", "ui_cancel", "ui_accept", "cheat_start" };
|
||||||
|
private int gpCcIndexer = 0;
|
||||||
|
private InputEvent inputEvent;
|
||||||
private static RichTextLabel textblock;
|
private static RichTextLabel textblock;
|
||||||
private LineEdit line;
|
private LineEdit line;
|
||||||
private Dictionary commandDict;
|
private Dictionary commandDict;
|
||||||
@@ -16,17 +19,35 @@ public partial class console : PopupPanel
|
|||||||
line = GetNode<LineEdit>("v_box_container/line_edit");
|
line = GetNode<LineEdit>("v_box_container/line_edit");
|
||||||
commandDict = Json.ParseString(FileAccess.GetFileAsString("res://src/scene-scripts/console/commands.json").ToString()).AsGodotDictionary();
|
commandDict = Json.ParseString(FileAccess.GetFileAsString("res://src/scene-scripts/console/commands.json").ToString()).AsGodotDictionary();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("console"))
|
//Cheatcode
|
||||||
|
if (Input.IsActionJustPressed(gamepadCheatcode[gpCcIndexer]))
|
||||||
{
|
{
|
||||||
Visible = !Visible;
|
gpCcIndexer++;
|
||||||
player.allowMovement = !Visible;
|
GetNode<Timer>("cheatcode_timer").Start();
|
||||||
line.GrabFocus();
|
if (gpCcIndexer == gamepadCheatcode.Length)
|
||||||
|
{
|
||||||
|
gpCcIndexer = 0;
|
||||||
|
ToggleVisible();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (Input.IsActionJustPressed("ui_cancel"))
|
||||||
|
|
||||||
|
//Normal keyboard hotkey
|
||||||
|
if (Input.IsActionJustPressed("console"))
|
||||||
|
ToggleVisible();
|
||||||
|
//OS console
|
||||||
/*if (OS.ReadStringFromStdIn() != "") //not tested yet
|
/*if (OS.ReadStringFromStdIn() != "") //not tested yet
|
||||||
OnLineEditTextSubmitted(OS.ReadStringFromStdIn());*/
|
OnLineEditTextSubmitted(OS.ReadStringFromStdIn());*/
|
||||||
}
|
}
|
||||||
|
private void ToggleVisible()
|
||||||
|
{
|
||||||
|
Visible = !Visible;
|
||||||
|
player.allowMovement = !Visible;
|
||||||
|
line.GrabFocus();
|
||||||
|
}
|
||||||
private void OnPopupHide() { if (dialog_bubble.isTalking == false) player.allowMovement = true; }
|
private void OnPopupHide() { if (dialog_bubble.isTalking == false) player.allowMovement = true; }
|
||||||
private void OnLineEditTextSubmitted(string command)
|
private void OnLineEditTextSubmitted(string command)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user