2019-06-11 23:50:33 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
signal loaded()
|
|
|
|
|
2019-06-29 13:25:13 +00:00
|
|
|
onready var roomList := $RoomScroll/RoomList
|
2019-07-06 15:13:14 +00:00
|
|
|
onready var gametypeDropdown := $CreateRoomDialog/DialogElements/RoomRow1/GameType/Dropdown
|
|
|
|
onready var gametypeMenu: PopupMenu = gametypeDropdown.get_popup()
|
|
|
|
|
|
|
|
onready var draftOptions := $CreateRoomDialog/DialogElements/DraftRows
|
|
|
|
|
|
|
|
onready var drafttypeDropdown := $CreateRoomDialog/DialogElements/DraftRows/DraftRow1/DraftType/Dropdown
|
|
|
|
onready var drafttypeMenu: PopupMenu = drafttypeDropdown.get_popup()
|
|
|
|
|
|
|
|
onready var draftRowBlock := $CreateRoomDialog/DialogElements/DraftRows/DraftRowBlock
|
|
|
|
|
|
|
|
onready var draftblockDropdown := $CreateRoomDialog/DialogElements/DraftRows/DraftRowBlock/DraftBlock/Dropdown
|
|
|
|
onready var draftblockMenu: PopupMenu = draftblockDropdown.get_popup()
|
|
|
|
|
|
|
|
onready var draftRowCube := $CreateRoomDialog/DialogElements/DraftRows/DraftCubeURL
|
2019-06-29 13:25:13 +00:00
|
|
|
|
|
|
|
var RoomItem := preload("res://Scenes/Lobby/RoomEntry.tscn")
|
|
|
|
|
2019-07-06 15:13:14 +00:00
|
|
|
var playerName := ""
|
|
|
|
|
|
|
|
const GAMETYPE_DRAFT = 0
|
|
|
|
|
|
|
|
const DRAFTTYPE_BLOCK = 0
|
|
|
|
const DRAFTTYPE_CUBE = 1
|
|
|
|
const DRAFTTYPE_I8P = 2
|
|
|
|
|
|
|
|
const DRAFTBLOCK_PR = 0
|
|
|
|
const DRAFTBLOCK_EO = 1
|
|
|
|
const DRAFTBLOCK_DE = 2
|
|
|
|
|
2019-06-11 23:50:33 +00:00
|
|
|
func _ready():
|
2019-06-29 09:46:33 +00:00
|
|
|
# Load bgm
|
2019-07-06 00:15:43 +00:00
|
|
|
BGM.set_volume(BGM.LOW)
|
2019-06-29 09:46:33 +00:00
|
|
|
BGM.load_music("lobby")
|
2019-06-29 13:25:13 +00:00
|
|
|
emit_signal("loaded")
|
2019-07-03 20:15:12 +00:00
|
|
|
Server.get_rooms(self, "_room_list")
|
2019-06-29 13:25:13 +00:00
|
|
|
add_room("test", "Unnamed room")
|
2019-07-03 20:15:12 +00:00
|
|
|
$ChooseNameDialog.popup_centered()
|
2019-07-06 15:13:14 +00:00
|
|
|
|
|
|
|
# Add options to room creation dialog
|
|
|
|
gametypeMenu.add_item("Draft", GAMETYPE_DRAFT)
|
|
|
|
|
|
|
|
drafttypeMenu.add_item("Booster draft (block)", DRAFTTYPE_BLOCK)
|
|
|
|
drafttypeMenu.add_item("Cube draft (classic)", DRAFTTYPE_CUBE)
|
|
|
|
drafttypeMenu.add_item("Cube draft (I8Pages' style)", DRAFTTYPE_I8P)
|
|
|
|
|
|
|
|
draftblockMenu.add_item("Premiere block", DRAFTBLOCK_PR)
|
|
|
|
draftblockMenu.add_item("Odyssey block", DRAFTBLOCK_EO)
|
|
|
|
draftblockMenu.add_item("Defenders block", DRAFTBLOCK_DE)
|
2019-06-29 13:25:13 +00:00
|
|
|
|
|
|
|
func add_room(id: String, name: String):
|
|
|
|
var item := RoomItem.instance()
|
|
|
|
item.roomName = name
|
|
|
|
item.connect("clicked", self, "_room_clicked", [id])
|
|
|
|
roomList.add_child(item)
|
2019-07-06 00:15:43 +00:00
|
|
|
|
2019-07-03 20:15:12 +00:00
|
|
|
func _room_list(result, obj):
|
|
|
|
if result != OK:
|
|
|
|
# Handle error
|
|
|
|
breakpoint
|
|
|
|
print(obj)
|
|
|
|
|
2019-06-29 13:25:13 +00:00
|
|
|
func _room_clicked(id: String):
|
2019-07-03 20:15:12 +00:00
|
|
|
print(id)
|
|
|
|
|
|
|
|
func _create_room():
|
2019-07-06 15:13:14 +00:00
|
|
|
$CreateRoomDialog.popup_centered()
|
|
|
|
gametypeDropdown.select(GAMETYPE_DRAFT)
|
|
|
|
|
|
|
|
func _name_changed(new_text):
|
|
|
|
var name := $ChooseNameDialog/Name
|
|
|
|
$ChooseNameDialog/Confirm.visible = name.text.length() > 0
|
|
|
|
|
|
|
|
func _name_chosen(new_text):
|
|
|
|
var name := $ChooseNameDialog/Name
|
|
|
|
playerName = name.text
|
|
|
|
$ChooseNameDialog.visible = false
|
|
|
|
|
|
|
|
|
|
|
|
func _toggle_spectators(button_pressed):
|
|
|
|
$CreateRoomDialog/DialogElements/RoomRow2/MaxSpec/Spinner.editable = button_pressed
|
|
|
|
|
|
|
|
|
|
|
|
func _game_type_selected(ID):
|
|
|
|
# Hide all options
|
|
|
|
draftOptions.visible = false
|
|
|
|
|
|
|
|
# Enable options for chosen game type
|
|
|
|
match ID:
|
|
|
|
GAMETYPE_DRAFT:
|
|
|
|
draftOptions.visible = true
|
|
|
|
|
|
|
|
|
|
|
|
func _draft_type_selected(ID):
|
|
|
|
# Hide all options
|
|
|
|
draftRowCube.visible = false
|
|
|
|
draftRowBlock.visible = false
|
|
|
|
|
|
|
|
print(ID)
|
|
|
|
# Enable options for chosen game type
|
|
|
|
match ID:
|
|
|
|
DRAFTTYPE_BLOCK:
|
|
|
|
draftRowBlock.visible = true
|
|
|
|
DRAFTTYPE_CUBE:
|
|
|
|
draftRowCube.visible = true
|
|
|
|
DRAFTTYPE_I8P:
|
|
|
|
draftRowCube.visible = true
|