From dc80e15129daa09e12d785a657a13763eb31d43f Mon Sep 17 00:00:00 2001 From: unfa Date: Sun, 26 Sep 2021 02:18:51 +0200 Subject: [PATCH] Added a different focus banner fro typing in chat. Fixed player name changes not being updated min-game --- Asset Sources/Effects/Busy.svg | 484 +++++++++++++++++++------- Game/Assets/Characters/Player.gd | 10 +- Game/Assets/Effects/Typing.png | 3 + Game/Assets/Effects/Typing.png.import | 35 ++ Game/Assets/HUD/Chat.gd | 27 +- Game/Assets/UI/ProfileMenu.gd | 5 + Game/Assets/UI/ProfileMenu.tscn | 1 + Game/Main.gd | 14 +- 8 files changed, 440 insertions(+), 139 deletions(-) create mode 100644 Game/Assets/Effects/Typing.png create mode 100644 Game/Assets/Effects/Typing.png.import diff --git a/Asset Sources/Effects/Busy.svg b/Asset Sources/Effects/Busy.svg index f235322..0e8dc9b 100644 --- a/Asset Sources/Effects/Busy.svg +++ b/Asset Sources/Effects/Busy.svg @@ -9,7 +9,7 @@ id="svg5" inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)" sodipodi:docname="Busy.svg" - inkscape:export-filename="/data/Projects/Games/Liblast/Game/Assets/Effects/Busy.png" + inkscape:export-filename="/data/Projects/Games/Liblast/Game/Assets/Effects/Typing.png" inkscape:export-xdpi="182.1837" inkscape:export-ydpi="182.1837" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" @@ -31,22 +31,39 @@ fit-margin-left="0" fit-margin-right="0" fit-margin-bottom="0" - inkscape:zoom="2.8284272" - inkscape:cx="76.013977" - inkscape:cy="126.92566" + inkscape:zoom="2.0000001" + inkscape:cx="20.499999" + inkscape:cy="76.499998" inkscape:window-width="1920" inkscape:window-height="1051" inkscape:window-x="1920" inkscape:window-y="0" inkscape:window-maximized="1" - inkscape:current-layer="layer1" /> + inkscape:current-layer="layer2" /> + id="defs2"> + + + + + transform="translate(-25.239306,-69.836283)" + style="display:none" + sodipodi:insensitive="true"> + Z + Z + - - + Z - Z + Z - Z + Z - - - - Z - Z - Z - - - - + style="font-weight:bold;stroke:#ffffff;stroke-width:3.44247;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers stroke fill">Z + + + + + + AFK + Lag + + + Chat + + + + + + + + + + + + + + + + + + + + + + Z + Z + + + %$^#! diff --git a/Game/Assets/Characters/Player.gd b/Game/Assets/Characters/Player.gd index 7f92cf6..a6937f6 100644 --- a/Game/Assets/Characters/Player.gd +++ b/Game/Assets/Characters/Player.gd @@ -9,6 +9,9 @@ extends CharacterBody3D @onready var crosshair = hud.get_node("Crosshair") @onready var vignette = hud.get_node("Vignette") +@onready var banner_busy = preload("res://Assets/Effects/Busy.png") +@onready var banner_chat = preload("res://Assets/Effects/Typing.png") + @onready var head = $Head @onready var camera = $Head/Camera @onready var tween = $Head/Camera/Tween @@ -117,11 +120,16 @@ var last_viewed_banner = null func view_banner(show:bool): focus_banner_show = show -@rpc(nosync, reliable, auth) func focus_banner(show:bool): +@rpc(nosync, reliable, auth) func focus_banner(show:bool, type:=0 ): if show: $FocusBanner.show() else: $FocusBanner.hide() + + match type: + 0: $FocusBanner.mesh.surface_get_material(0).set("albedo_texture", banner_busy) + 1: $FocusBanner.mesh.surface_get_material(0).set("albedo_texture", banner_chat) + @rpc(auth, nosync,unreliable) func update_movement(player_transform, head_rotation, lin_velocity, jetpack): global_transform = player_transform diff --git a/Game/Assets/Effects/Typing.png b/Game/Assets/Effects/Typing.png new file mode 100644 index 0000000..cb9ca8f --- /dev/null +++ b/Game/Assets/Effects/Typing.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7dfbd1955c1de3f811c516ae9cbae3e97b3174bab9b266667db60f3e4e2e775 +size 16132 diff --git a/Game/Assets/Effects/Typing.png.import b/Game/Assets/Effects/Typing.png.import new file mode 100644 index 0000000..436e536 --- /dev/null +++ b/Game/Assets/Effects/Typing.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture2D" +uid="uid://b1bf2ni3gggce" +path="res://.godot/imported/Typing.png-cfa6ed9a5a612bb50eac93e4420acb28.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Effects/Typing.png" +dest_files=["res://.godot/imported/Typing.png-cfa6ed9a5a612bb50eac93e4420acb28.stex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +compress/streamed=false +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/HDR_as_SRGB=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 diff --git a/Game/Assets/HUD/Chat.gd b/Game/Assets/HUD/Chat.gd index 4bce4e2..dece775 100644 --- a/Game/Assets/HUD/Chat.gd +++ b/Game/Assets/HUD/Chat.gd @@ -7,21 +7,20 @@ extends Control @onready var chat_label = $VBoxContainer/Typing/Label enum ChatState {INACTIVE, TYPING_ALL, TYPING_TEAM} -enum GameFocus {MENU, GAME, CHAT, AWAY} # copied from Main.gd TODO: delete this var state = ChatState.INACTIVE : set(new_state): state = new_state match new_state: - 0: #ChatState.INACTIVE: + ChatState.INACTIVE: chat_typing.hide() chat_editor.release_focus() - 1: #ChatState.TYPING_ALL: + ChatState.TYPING_ALL: chat_label.text = "all: " chat_typing.show() chat_editor.grab_focus() chat_editor.text = '' - 2: #ChatState.TYPING_TEAM: + ChatState.TYPING_TEAM: chat_label.text = "team: " chat_typing.show() chat_editor.grab_focus() @@ -34,25 +33,25 @@ func _ready(): func _input(_event) -> void: if state == ChatState.INACTIVE: if Input.is_action_just_pressed("say_all"): - main.focus = 2 #main.GameFocus.CHAT - state = 1 #ChatState.TYPING_ALL + main.focus = main.GameFocus.CHAT + state = ChatState.TYPING_ALL get_tree().get_root().set_input_as_handled() if Input.is_action_just_pressed("say_team"): - main.focus = 2 #main.GameFocus.CHAT - state = 2 #ChatState.TYPING_TEAM + main.focus = main.GameFocus.CHAT + state = ChatState.TYPING_TEAM get_tree().get_root().set_input_as_handled() elif Input.is_action_just_pressed("say_cancel"): - main.focus = 1 #main.GameFocus.GAME - state = 0 #ChatState.INACTIVE + main.focus = main.GameFocus.GAME + state = ChatState.INACTIVE func _unhandled_input(_event) -> void: - if state != 0: #ChatState.INACTIVE: + if state != ChatState.INACTIVE: get_tree().get_root().set_input_as_handled() # doesn't work over network due to missing RPC implementation in Godot 4 -@rpc func chat_message(sender_pid: int, recipient_team, message: String) -> void: +@rpc(sync, any, reliable) func chat_message(sender_pid: int, recipient_team, message: String) -> void: var sender_info = main.player_list.get(sender_pid) chat_history.append_text('\n' + '[b][color=' + sender_info.color.to_html() +']' + str(sender_info.name) + '[/color][/b] : [i]' + message + '[/i]') @@ -65,5 +64,5 @@ func _on_Editor_text_submitted(new_text): var new_message = [sender_id, 0, new_text] rpc(&'chat_message',sender_id, 0, new_text) chat_editor.text = '' - state = 0 #ChatState.INACTIVE - main.focus = 0 #main.GameFocus.GAME + state = ChatState.INACTIVE + main.focus = main.GameFocus.GAME diff --git a/Game/Assets/UI/ProfileMenu.gd b/Game/Assets/UI/ProfileMenu.gd index d0750ec..f81fef1 100644 --- a/Game/Assets/UI/ProfileMenu.gd +++ b/Game/Assets/UI/ProfileMenu.gd @@ -3,3 +3,8 @@ extends "res://Assets/UI/Menu.gd" func change_player_color(data): if Main: Main.change_player_color(data) + + +func change_player_name(data): + if Main: + Main.change_player_name(data) diff --git a/Game/Assets/UI/ProfileMenu.tscn b/Game/Assets/UI/ProfileMenu.tscn index 192429f..7d970c7 100644 --- a/Game/Assets/UI/ProfileMenu.tscn +++ b/Game/Assets/UI/ProfileMenu.tscn @@ -31,4 +31,5 @@ offset_top = 70.0 offset_right = 155.0 offset_bottom = 99.0 +[connection signal="data_changed" from="UsernameLineEdit" to="." method="change_player_name"] [connection signal="data_changed" from="PlayerColor" to="." method="change_player_color"] diff --git a/Game/Main.gd b/Game/Main.gd index 6709be0..614b279 100644 --- a/Game/Main.gd +++ b/Game/Main.gd @@ -146,7 +146,7 @@ var focus:GameFocus: hud.hide() if local_player: local_player.input_active = false - local_player.rpc(&"focus_banner", true) + local_player.rpc(&"focus_banner", true, 0) 1: # GAME Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) gui.hide() @@ -157,11 +157,11 @@ var focus:GameFocus: 2: # CHAT if local_player: local_player.input_active = false - local_player.rpc(&"focus_banner", true) + local_player.rpc(&"focus_banner", true, 1) 3: #AWAY if local_player: local_player.input_active = true - local_player.rpc(&"focus_banner", true) + local_player.rpc(&"focus_banner", true, 2) focus = new_focus @@ -442,9 +442,11 @@ func _ready() -> void: start_dedicated_server() func change_player_color(color): - _on_ColorPickerButton_color_changed(color) - -func _on_ColorPickerButton_color_changed(color): if get_tree().multiplayer.has_multiplayer_peer(): player_list.players[get_tree().multiplayer.get_unique_id()].color = color push_local_player_info() + +func change_player_name(player_name): + if get_tree().multiplayer.has_multiplayer_peer(): + player_list.players[get_tree().multiplayer.get_unique_id()].name = player_name + push_local_player_info()