2021-06-04 00:38:30 +02:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
@onready var main = get_tree().get_root().get_node("Main")
|
|
|
|
|
|
|
|
enum ChatState {INACTIVE, TYPING_ALL, TYPING_TEAM}
|
|
|
|
|
2021-06-04 02:33:26 +02:00
|
|
|
enum GameFocus {MENU, GAME, CHAT, AWAY} # copied from Main.gd TODO: delete this
|
|
|
|
|
2021-06-04 00:38:30 +02:00
|
|
|
var state = ChatState.INACTIVE :
|
|
|
|
set(new_state):
|
|
|
|
state = new_state
|
|
|
|
match new_state:
|
2021-06-04 02:33:26 +02:00
|
|
|
0: #ChatState.INACTIVE:
|
2021-06-04 00:38:30 +02:00
|
|
|
$VBoxContainer/Typing.hide()
|
|
|
|
$VBoxContainer/Typing/LineEdit.release_focus()
|
2021-06-04 02:33:26 +02:00
|
|
|
1: #ChatState.TYPING_ALL:
|
2021-06-04 00:38:30 +02:00
|
|
|
$VBoxContainer/Typing.show()
|
|
|
|
$VBoxContainer/Typing/LineEdit.grab_focus()
|
2021-06-04 02:33:26 +02:00
|
|
|
2: #ChatState.TYPING_TEAM:
|
2021-06-04 00:38:30 +02:00
|
|
|
$VBoxContainer/Typing.show()
|
|
|
|
$VBoxContainer/Typing/LineEdit.grab_focus()
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
func _input(event) -> void:
|
|
|
|
if Input.is_action_just_pressed("say_all"):
|
2021-06-04 02:33:26 +02:00
|
|
|
main.focus = 1 #main.GameFocus.CHAT
|
|
|
|
state = 1 #ChatState.TYPING_ALL
|
2021-06-04 00:38:30 +02:00
|
|
|
|
|
|
|
if Input.is_action_just_pressed("say_team"):
|
2021-06-04 02:33:26 +02:00
|
|
|
main.focus = 1 #main.GameFocus.CHAT
|
|
|
|
state = 2 #ChatState.TYPING_TEAM
|
2021-06-04 00:38:30 +02:00
|
|
|
|
2021-06-04 02:33:26 +02:00
|
|
|
if Input.is_action_just_pressed("UI_Accept") and state != 0: #ChatState.INACTIVE:
|
2021-06-04 00:38:30 +02:00
|
|
|
$VBoxContainer/ChatHistory.text.append($VBoxContainer/Typing/LineEdit.text)
|
|
|
|
$VBoxContainer/Typing/LineEdit.text.clear()
|
2021-06-04 02:33:26 +02:00
|
|
|
state = 0 #ChatState.INACTIVE
|
|
|
|
main.focus = 0 #main.GameFocus.GAME
|
2021-06-04 00:38:30 +02:00
|
|
|
|
|
|
|
func _unhandled_input(event) -> void:
|
2021-06-04 02:33:26 +02:00
|
|
|
if state != 0: #ChatState.INACTIVE:
|
|
|
|
get_tree().get_root().set_input_as_handled()
|