Replaced ENUM values with Ints to workaround Godot bug
parent
a54eb54293
commit
edda7abc6f
|
@ -4,17 +4,19 @@ extends Control
|
||||||
|
|
||||||
enum ChatState {INACTIVE, TYPING_ALL, TYPING_TEAM}
|
enum ChatState {INACTIVE, TYPING_ALL, TYPING_TEAM}
|
||||||
|
|
||||||
|
enum GameFocus {MENU, GAME, CHAT, AWAY} # copied from Main.gd TODO: delete this
|
||||||
|
|
||||||
var state = ChatState.INACTIVE :
|
var state = ChatState.INACTIVE :
|
||||||
set(new_state):
|
set(new_state):
|
||||||
state = new_state
|
state = new_state
|
||||||
match new_state:
|
match new_state:
|
||||||
ChatState.INACTIVE:
|
0: #ChatState.INACTIVE:
|
||||||
$VBoxContainer/Typing.hide()
|
$VBoxContainer/Typing.hide()
|
||||||
$VBoxContainer/Typing/LineEdit.release_focus()
|
$VBoxContainer/Typing/LineEdit.release_focus()
|
||||||
ChatState.TYPING_ALL:
|
1: #ChatState.TYPING_ALL:
|
||||||
$VBoxContainer/Typing.show()
|
$VBoxContainer/Typing.show()
|
||||||
$VBoxContainer/Typing/LineEdit.grab_focus()
|
$VBoxContainer/Typing/LineEdit.grab_focus()
|
||||||
ChatState.TYPING_TEAM:
|
2: #ChatState.TYPING_TEAM:
|
||||||
$VBoxContainer/Typing.show()
|
$VBoxContainer/Typing.show()
|
||||||
$VBoxContainer/Typing/LineEdit.grab_focus()
|
$VBoxContainer/Typing/LineEdit.grab_focus()
|
||||||
|
|
||||||
|
@ -24,19 +26,19 @@ func _ready():
|
||||||
|
|
||||||
func _input(event) -> void:
|
func _input(event) -> void:
|
||||||
if Input.is_action_just_pressed("say_all"):
|
if Input.is_action_just_pressed("say_all"):
|
||||||
main.focus = main.GameFocus.CHAT
|
main.focus = 1 #main.GameFocus.CHAT
|
||||||
state = ChatState.TYPING_ALL
|
state = 1 #ChatState.TYPING_ALL
|
||||||
|
|
||||||
if Input.is_action_just_pressed("say_team"):
|
if Input.is_action_just_pressed("say_team"):
|
||||||
main.focus = main.GameFocus.CHAT
|
main.focus = 1 #main.GameFocus.CHAT
|
||||||
state = ChatState.TYPING_TEAM
|
state = 2 #ChatState.TYPING_TEAM
|
||||||
|
|
||||||
if Input.is_action_just_pressed("UI_Accept") and state != ChatState.INACTIVE:
|
if Input.is_action_just_pressed("UI_Accept") and state != 0: #ChatState.INACTIVE:
|
||||||
$VBoxContainer/ChatHistory.text.append($VBoxContainer/Typing/LineEdit.text)
|
$VBoxContainer/ChatHistory.text.append($VBoxContainer/Typing/LineEdit.text)
|
||||||
$VBoxContainer/Typing/LineEdit.text.clear()
|
$VBoxContainer/Typing/LineEdit.text.clear()
|
||||||
state = ChatState.INACTIVE
|
state = 0 #ChatState.INACTIVE
|
||||||
main.focus = main.GameFocus.GAME
|
main.focus = 0 #main.GameFocus.GAME
|
||||||
|
|
||||||
func _unhandled_input(event) -> void:
|
func _unhandled_input(event) -> void:
|
||||||
if state != ChatState.INACTIVE:
|
if state != 0: #ChatState.INACTIVE:
|
||||||
get_tree().set_input_as_handled()
|
get_tree().get_root().set_input_as_handled()
|
||||||
|
|
Reference in New Issue