online multiplayer chess game (note server currently down)
Diffstat (limited to 'ui/menus/lobby/PGNEntry.gd')
| -rw-r--r-- | ui/menus/lobby/PGNEntry.gd | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/ui/menus/lobby/PGNEntry.gd b/ui/menus/lobby/PGNEntry.gd index 5f76aa2..7361911 100644 --- a/ui/menus/lobby/PGNEntry.gd +++ b/ui/menus/lobby/PGNEntry.gd @@ -1,19 +1,26 @@ extends LineEdit +onready var checkmark: Label = $"../Checkmark" + signal pgn_selected(m_array) -func _text_entered(new_text: String): +func text_changed(new_text: String) -> void: + if !new_text: + checkmark.text = "" + return var status = validate_pgn(new_text) if status: emit_signal("pgn_selected", status) + checkmark.text = "" else: - text = "invalid pgn" + checkmark.text = "" func validate_pgn(p: String): var parsed = Pgn.parse(p) - if parsed == null: - return false - else: - return parsed.moves # TODO: simulate the pgn and such nonsense + if parsed != null: + var c = Chess.new() + if c.load_pgn(text) == OK and !c.game_over(): + return parsed.moves + return false |