Add chat format
This commit is contained in:
parent
6ddb52c27c
commit
f57e1c433b
4 changed files with 25 additions and 12 deletions
|
@ -13,6 +13,7 @@ onready var physics = world.get_world_2d().direct_space_state
|
|||
var writing = false
|
||||
|
||||
func _ready() -> void:
|
||||
$"/root/Music/BGM".stop()
|
||||
randomize()
|
||||
if netgame.hosting:
|
||||
world.load_map(netgame.get_current_map())
|
||||
|
|
24
Scenes/UI.gd
24
Scenes/UI.gd
|
@ -13,8 +13,11 @@ enum PopupName {
|
|||
|
||||
onready var logs = $Logs
|
||||
onready var scene = $"/root/scene"
|
||||
onready var netgame = $"/root/Multiplayer"
|
||||
|
||||
const WHISPER_RADIUS = 32*3
|
||||
const CHAT_RADIUS = 32*10
|
||||
const SHOUT_RADIUS = 32*14
|
||||
|
||||
func _ready() -> void:
|
||||
# Add options to menu buttons
|
||||
|
@ -27,19 +30,28 @@ func _server_option_chosen(id) -> void:
|
|||
ServerMenuItem.ServerInfo:
|
||||
$ServerInfoPopup.popup_centered()
|
||||
|
||||
func open_popup(map_name) -> void:
|
||||
match map_name:
|
||||
func open_popup(popup_name) -> void:
|
||||
match popup_name:
|
||||
PopupName.SpaceMap:
|
||||
$MapPopup.popup_centered_ratio()
|
||||
PopupName.EnergyUsage:
|
||||
pass
|
||||
|
||||
func close_popup(map_name) -> void:
|
||||
match map_name:
|
||||
func close_popup(popup_name) -> void:
|
||||
match popup_name:
|
||||
PopupName.SpaceMap:
|
||||
$MapPopup.visible = false
|
||||
PopupName.EnergyUsage:
|
||||
pass
|
||||
|
||||
func _send_chat(text):
|
||||
scene.rpc("broadcast_zone", text + "\n", scene.world.player.global_position, CHAT_RADIUS)
|
||||
const say_format = "%s says \"%s\"\n"
|
||||
const shout_format = "%s shouts \"[b]%s[/b]\"\n"
|
||||
const whisper_format = "[i]%s whispers \"%s\"[/i]\n"
|
||||
func _send_chat(text: String) -> void:
|
||||
var escaped_text = text.replace("[", "[\u8203") # Hacky way to escape BBCode
|
||||
if text.ends_with("!!"):
|
||||
scene.rpc("broadcast_zone", shout_format % [netgame.player_name, escaped_text], scene.world.player.global_position, SHOUT_RADIUS)
|
||||
elif text.begins_with("#"):
|
||||
scene.rpc("broadcast_zone", whisper_format % [netgame.player_name, escaped_text.substr(1)], scene.world.player.global_position, WHISPER_RADIUS)
|
||||
else:
|
||||
scene.rpc("broadcast_zone", say_format % [netgame.player_name, escaped_text], scene.world.player.global_position, CHAT_RADIUS)
|
||||
|
|
|
@ -11,5 +11,5 @@ dest_files=[ "res://.import/neutral-bi-beep.ogg-b80d5dd9b7ca71aa0d191c8ef7940dc5
|
|||
|
||||
[params]
|
||||
|
||||
loop=true
|
||||
loop=false
|
||||
loop_offset=0
|
||||
|
|
|
@ -11,11 +11,11 @@ dest_files=[ "res://.import/radio-message.wav-ce2c91f356066e01259b32b652b758a3.s
|
|||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/8_bit=true
|
||||
force/mono=true
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/trim=true
|
||||
edit/normalize=true
|
||||
edit/loop=false
|
||||
compress/mode=0
|
||||
compress/mode=1
|
||||
|
|
Reference in a new issue