This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Scenes/UI.gd

46 lines
959 B
GDScript3
Raw Normal View History

2020-07-06 22:00:39 +00:00
extends Control
2020-07-20 09:15:39 +00:00
class_name GameUI
2020-07-10 11:31:16 +00:00
enum ServerMenuItem {
2020-07-20 09:15:39 +00:00
ServerInfo
}
enum PopupName {
SpaceMap,
EnergyUsage
2020-07-10 11:31:16 +00:00
}
2020-07-21 17:47:33 +00:00
onready var logs = $Logs
2020-07-22 13:57:33 +00:00
onready var scene = $"/root/scene"
2020-07-22 15:34:04 +00:00
const CHAT_RADIUS = 32*10
2020-07-21 17:47:33 +00:00
2020-07-10 11:31:16 +00:00
func _ready() -> void:
# Add options to menu buttons
var serverMenu = $Menu/Margins/Grid/Server.get_popup()
serverMenu.connect("id_pressed", self, "_server_option_chosen")
2020-07-20 09:15:39 +00:00
serverMenu.add_item("Server info", ServerMenuItem.ServerInfo)
2020-07-10 11:31:16 +00:00
func _server_option_chosen(id) -> void:
match id:
2020-07-20 09:15:39 +00:00
ServerMenuItem.ServerInfo:
2020-07-10 11:31:16 +00:00
$ServerInfoPopup.popup_centered()
2020-07-20 09:15:39 +00:00
func open_popup(map_name) -> void:
match map_name:
PopupName.SpaceMap:
$MapPopup.popup_centered_ratio()
PopupName.EnergyUsage:
pass
2020-07-20 09:15:39 +00:00
func close_popup(map_name) -> void:
match map_name:
PopupName.SpaceMap:
$MapPopup.visible = false
PopupName.EnergyUsage:
pass
2020-07-22 13:57:33 +00:00
func _send_chat(text):
scene.rpc("broadcast_zone", text + "\n", scene.world.player.global_position, CHAT_RADIUS)