Finalized input map, started implementing chat - broken by Enum Godot bugs

pull/50/head
unfa 2021-06-04 00:38:30 +02:00
parent 9927ab2d6f
commit a54eb54293
4 changed files with 153 additions and 9 deletions

42
Game/Assets/HUD/Chat.gd Normal file
View File

@ -0,0 +1,42 @@
extends Control
@onready var main = get_tree().get_root().get_node("Main")
enum ChatState {INACTIVE, TYPING_ALL, TYPING_TEAM}
var state = ChatState.INACTIVE :
set(new_state):
state = new_state
match new_state:
ChatState.INACTIVE:
$VBoxContainer/Typing.hide()
$VBoxContainer/Typing/LineEdit.release_focus()
ChatState.TYPING_ALL:
$VBoxContainer/Typing.show()
$VBoxContainer/Typing/LineEdit.grab_focus()
ChatState.TYPING_TEAM:
$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"):
main.focus = main.GameFocus.CHAT
state = ChatState.TYPING_ALL
if Input.is_action_just_pressed("say_team"):
main.focus = main.GameFocus.CHAT
state = ChatState.TYPING_TEAM
if Input.is_action_just_pressed("UI_Accept") and state != ChatState.INACTIVE:
$VBoxContainer/ChatHistory.text.append($VBoxContainer/Typing/LineEdit.text)
$VBoxContainer/Typing/LineEdit.text.clear()
state = ChatState.INACTIVE
main.focus = main.GameFocus.GAME
func _unhandled_input(event) -> void:
if state != ChatState.INACTIVE:
get_tree().set_input_as_handled()

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Assets/HUD/Vignette.png" type="Texture2D" id=1]
[ext_resource path="res://Assets/HUD/Crosshair.png" type="Texture2D" id=2]
[ext_resource path="res://Assets/SFX/UI_Confirm_Kill.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/SFX/UI_Confirm_Hit.wav" type="AudioStream" id=4]
[ext_resource path="res://Assets/HUD/Crosshair.gd" type="Script" id=5]
[ext_resource path="res://Assets/HUD/Chat.gd" type="Script" id=6]
[sub_resource type="Animation" id=1]
resource_name = "Default"
@ -140,3 +141,80 @@ script = null
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Chat" type="Control" parent="."]
offset_left = 24.0
offset_top = 24.0
offset_right = 324.0
offset_bottom = 474.0
script = ExtResource( 6 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="Chat"]
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -500.0
offset_right = 300.0
offset_bottom = 37.0
alignment = 2
script = null
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ChatHistory" type="RichTextLabel" parent="Chat/VBoxContainer"]
offset_top = 422.0
offset_right = 300.0
offset_bottom = 537.0
text = "text
text
text
text
text"
fit_content_height = true
scroll_active = false
scroll_following = true
custom_effects = [ ]
structured_text_bidi_override_options = [ ]
script = null
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Typing" type="HBoxContainer" parent="Chat/VBoxContainer"]
visible = false
offset_top = 504.0
offset_right = 300.0
offset_bottom = 537.0
script = null
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Chat/VBoxContainer/Typing"]
offset_top = 3.0
offset_right = 34.0
offset_bottom = 29.0
text = "say: "
structured_text_bidi_override_options = [ ]
script = null
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LineEdit" type="LineEdit" parent="Chat/VBoxContainer/Typing"]
offset_left = 38.0
offset_right = 108.0
offset_bottom = 33.0
context_menu_enabled = false
virtual_keyboard_enabled = false
shortcut_keys_enabled = false
selecting_enabled = false
structured_text_bidi_override_options = [ ]
caret_blink = true
script = null
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -3,7 +3,9 @@ extends Node
enum GameFocus {MENU, GAME, CHAT, AWAY}
@onready var gui = $GUI
@onready var hud = $HUD
@onready var player = $Level/Player
@onready var chat = hud.get_node("Chat")
var focus = GameFocus.MENU

View File

@ -68,31 +68,53 @@ move_special={
}
weapon_previous={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":4,"pressed":false,"double_click":false,"script":null)
]
}
weapon_next={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"double_click":false,"script":null)
]
}
weapon_reload={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":82,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
weapon_swap={
weapon_last={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":81,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
weapon_1={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":49,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
weapon_2={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":50,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
weapon_3={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":51,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
say_all={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":89,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
say_team={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":84,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
say_send={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":16777221,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}
[rendering]