Add room creation dialog (WIP)

This commit is contained in:
Hamcha 2019-07-06 17:13:14 +02:00
parent ed1099616f
commit 4c984e5b04
8 changed files with 436 additions and 18 deletions

View file

@ -1,3 +1,5 @@
# Credits for third party assets
Some assets come from fellow MLP fans and artists:
- [**Ninja Applejack** by Yetioner](https://www.deviantart.com/yetioner/art/Ninja-Applejack-663088882)
@ -5,6 +7,7 @@ Some assets come from fellow MLP fans and artists:
- [**Pinkie: 'Tall ceilings' (S05E03)** by DJDavid98](https://www.deviantart.com/djdavid98/art/Pinkie-Tall-ceilings-S05E03-532855027)
- [**excited Rainbow Dash** by CloudyGlow](https://www.deviantart.com/cloudyglow/art/excited-Rainbow-Dash-730032632)
- [**Rarity Falling in joy** by Yetioner](https://www.deviantart.com/yetioner/art/Rarity-Falling-in-joy-600727887)
- [**Mane 6 on a Friendship Retreat** by CloudyGlow](https://www.deviantart.com/cloudyglow/art/Mane-6-on-a-Friendship-Retreat-675732746)
The following Sound effects from Freesound were used:

View file

@ -1,15 +1,25 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://Scenes/Scripts/Lobby.gd" type="Script" id=1]
[ext_resource path="res://MLPAssets/Background/menubg.webp" type="Texture" id=2]
[ext_resource path="res://UIAssets/Fonts/Catamaran.tres" type="DynamicFont" id=3]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Light.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://UIAssets/UITheme.tres" type="Theme" id=3]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Bold.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://UIAssets/Fonts/UIDialogLabel.tres" type="DynamicFont" id=5]
[ext_resource path="res://UIAssets/Fonts/Catamaran.tres" type="DynamicFont" id=6]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Light.ttf" type="DynamicFontData" id=7]
[sub_resource type="DynamicFont" id=1]
[sub_resource type="DynamicFont" id=4]
size = 30
font_data = ExtResource( 4 )
[sub_resource type="DynamicFont" id=2]
font_data = ExtResource( 7 )
[sub_resource type="DynamicFont" id=3]
size = 20
use_mipmaps = true
use_filter = true
font_data = ExtResource( 4 )
font_data = ExtResource( 7 )
[node name="Lobby" type="Control"]
anchor_right = 1.0
@ -50,13 +60,283 @@ margin_bottom = 90.0
text = "Create room"
[node name="CreateRoomDialog" type="PopupDialog" parent="."]
margin_left = 317.0
margin_top = 178.0
margin_right = 983.0
margin_bottom = 587.0
visible = true
margin_left = 377.0
margin_top = 109.0
margin_right = 967.0
margin_bottom = 647.0
theme = ExtResource( 3 )
[node name="DialogElements" type="VBoxContainer" parent="CreateRoomDialog"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = 10.0
margin_right = -10.0
margin_bottom = -10.0
theme = ExtResource( 3 )
[node name="Title" type="Label" parent="CreateRoomDialog/DialogElements"]
margin_right = 570.0
margin_bottom = 50.0
theme = ExtResource( 3 )
custom_fonts/font = SubResource( 4 )
text = "Create new room"
align = 1
valign = 1
[node name="RoomRow1" type="HBoxContainer" parent="CreateRoomDialog/DialogElements"]
margin_top = 54.0
margin_right = 570.0
margin_bottom = 134.0
theme = ExtResource( 3 )
custom_constants/separation = 20
alignment = 1
[node name="GameType" type="VBoxContainer" parent="CreateRoomDialog/DialogElements/RoomRow1"]
margin_left = 25.0
margin_right = 225.0
margin_bottom = 80.0
rect_min_size = Vector2( 200, 0 )
theme = ExtResource( 3 )
alignment = 2
[node name="NameLabel" type="Label" parent="CreateRoomDialog/DialogElements/RoomRow1/GameType"]
margin_top = 4.0
margin_right = 200.0
margin_bottom = 37.0
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Game Type"
align = 1
valign = 1
[node name="Dropdown" type="OptionButton" parent="CreateRoomDialog/DialogElements/RoomRow1/GameType"]
margin_top = 41.0
margin_right = 200.0
margin_bottom = 80.0
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
shortcut_in_tooltip = false
[node name="RoomName" type="VBoxContainer" parent="CreateRoomDialog/DialogElements/RoomRow1"]
margin_left = 245.0
margin_right = 545.0
margin_bottom = 80.0
rect_min_size = Vector2( 200, 0 )
theme = ExtResource( 3 )
alignment = 2
[node name="NameLabel" type="Label" parent="CreateRoomDialog/DialogElements/RoomRow1/RoomName"]
margin_right = 300.0
margin_bottom = 33.0
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Room Name"
align = 1
valign = 1
[node name="LineEdit" type="LineEdit" parent="CreateRoomDialog/DialogElements/RoomRow1/RoomName"]
margin_top = 37.0
margin_right = 300.0
margin_bottom = 80.0
rect_min_size = Vector2( 300, 0 )
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
placeholder_text = "Room name"
[node name="RoomRow2" type="HBoxContainer" parent="CreateRoomDialog/DialogElements"]
editor/display_folded = true
margin_top = 138.0
margin_right = 570.0
margin_bottom = 226.0
theme = ExtResource( 3 )
custom_constants/separation = 20
alignment = 1
[node name="MaxPlayers" type="VBoxContainer" parent="CreateRoomDialog/DialogElements/RoomRow2"]
margin_left = 75.0
margin_right = 275.0
margin_bottom = 88.0
rect_min_size = Vector2( 200, 0 )
theme = ExtResource( 3 )
alignment = 2
[node name="NameLabel" type="Label" parent="CreateRoomDialog/DialogElements/RoomRow2/MaxPlayers"]
margin_top = 8.0
margin_right = 200.0
margin_bottom = 41.0
theme = ExtResource( 3 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Max # of players"
align = 1
valign = 1
[node name="Spinner" type="SpinBox" parent="CreateRoomDialog/DialogElements/RoomRow2/MaxPlayers"]
margin_top = 45.0
margin_right = 200.0
margin_bottom = 88.0
theme = ExtResource( 3 )
max_value = 20.0
value = 8.0
align = 1
[node name="MaxSpec" type="VBoxContainer" parent="CreateRoomDialog/DialogElements/RoomRow2"]
margin_left = 295.0
margin_right = 495.0
margin_bottom = 88.0
rect_min_size = Vector2( 200, 0 )
theme = ExtResource( 3 )
alignment = 2
[node name="NameLabel" type="CheckBox" parent="CreateRoomDialog/DialogElements/RoomRow2/MaxSpec"]
margin_right = 200.0
margin_bottom = 41.0
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Max # of spectators"
align = 1
[node name="Spinner" type="SpinBox" parent="CreateRoomDialog/DialogElements/RoomRow2/MaxSpec"]
margin_top = 45.0
margin_right = 200.0
margin_bottom = 88.0
theme = ExtResource( 3 )
max_value = 20.0
align = 1
editable = false
[node name="DraftRows" type="VBoxContainer" parent="CreateRoomDialog/DialogElements"]
margin_top = 230.0
margin_right = 570.0
margin_bottom = 440.0
[node name="DraftOptions" type="Label" parent="CreateRoomDialog/DialogElements/DraftRows"]
margin_right = 570.0
margin_bottom = 50.0
theme = ExtResource( 3 )
custom_fonts/font = SubResource( 4 )
text = "Draft options"
align = 1
valign = 1
[node name="DraftRow1" type="HBoxContainer" parent="CreateRoomDialog/DialogElements/DraftRows"]
margin_top = 54.0
margin_right = 570.0
margin_bottom = 130.0
theme = ExtResource( 3 )
custom_constants/separation = 20
alignment = 1
[node name="DraftType" type="VBoxContainer" parent="CreateRoomDialog/DialogElements/DraftRows/DraftRow1"]
margin_left = 85.0
margin_right = 485.0
margin_bottom = 76.0
rect_min_size = Vector2( 200, 0 )
theme = ExtResource( 3 )
alignment = 2
[node name="NameLabel" type="Label" parent="CreateRoomDialog/DialogElements/DraftRows/DraftRow1/DraftType"]
margin_right = 400.0
margin_bottom = 33.0
theme = ExtResource( 3 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Draft type"
align = 1
valign = 1
[node name="Dropdown" type="OptionButton" parent="CreateRoomDialog/DialogElements/DraftRows/DraftRow1/DraftType"]
margin_top = 37.0
margin_right = 400.0
margin_bottom = 76.0
rect_min_size = Vector2( 400, 0 )
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
shortcut_in_tooltip = false
[node name="DraftRowBlock" type="HBoxContainer" parent="CreateRoomDialog/DialogElements/DraftRows"]
margin_top = 134.0
margin_right = 570.0
margin_bottom = 210.0
theme = ExtResource( 3 )
custom_constants/separation = 20
alignment = 1
[node name="DraftBlock" type="VBoxContainer" parent="CreateRoomDialog/DialogElements/DraftRows/DraftRowBlock"]
margin_left = 85.0
margin_right = 485.0
margin_bottom = 76.0
rect_min_size = Vector2( 200, 0 )
theme = ExtResource( 3 )
alignment = 2
[node name="NameLabel" type="Label" parent="CreateRoomDialog/DialogElements/DraftRows/DraftRowBlock/DraftBlock"]
margin_right = 400.0
margin_bottom = 33.0
theme = ExtResource( 3 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Block"
align = 1
valign = 1
[node name="Dropdown" type="OptionButton" parent="CreateRoomDialog/DialogElements/DraftRows/DraftRowBlock/DraftBlock"]
margin_top = 37.0
margin_right = 400.0
margin_bottom = 76.0
rect_min_size = Vector2( 400, 0 )
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
shortcut_in_tooltip = false
[node name="DraftCubeURL" type="HBoxContainer" parent="CreateRoomDialog/DialogElements/DraftRows"]
visible = false
margin_top = 134.0
margin_right = 570.0
margin_bottom = 214.0
theme = ExtResource( 3 )
custom_constants/separation = 20
alignment = 1
[node name="CubeURL" type="VBoxContainer" parent="CreateRoomDialog/DialogElements/DraftRows/DraftCubeURL"]
margin_left = 85.0
margin_right = 485.0
margin_bottom = 80.0
rect_min_size = Vector2( 200, 0 )
theme = ExtResource( 3 )
alignment = 2
[node name="NameLabel" type="Label" parent="CreateRoomDialog/DialogElements/DraftRows/DraftCubeURL/CubeURL"]
margin_right = 400.0
margin_bottom = 33.0
theme = ExtResource( 3 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Cube URL"
align = 1
valign = 1
[node name="LineEdit" type="LineEdit" parent="CreateRoomDialog/DialogElements/DraftRows/DraftCubeURL/CubeURL"]
margin_top = 37.0
margin_right = 400.0
margin_bottom = 80.0
rect_min_size = Vector2( 400, 0 )
theme = ExtResource( 3 )
custom_fonts/font = ExtResource( 5 )
placeholder_text = "URL to cube file"
[node name="Button" type="Button" parent="CreateRoomDialog"]
anchor_top = 1.0
anchor_bottom = 1.0
margin_left = 28.0
margin_top = -70.0
margin_right = 558.0
margin_bottom = -28.0
theme = ExtResource( 3 )
text = "Create room"
[node name="ChooseNameDialog" type="PopupDialog" parent="."]
visible = true
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
@ -66,25 +346,44 @@ margin_bottom = 200.0
rect_min_size = Vector2( 400, 200 )
popup_exclusive = true
[node name="Label" type="Label" parent="ChooseNameDialog"]
[node name="Prompt" type="Label" parent="ChooseNameDialog"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 394.0
margin_bottom = 13.0
rect_scale = Vector2( 0.5, 0.5 )
custom_fonts/font = ExtResource( 3 )
custom_fonts/font = ExtResource( 6 )
text = "Choose a name"
align = 1
valign = 1
[node name="LineEdit" type="LineEdit" parent="ChooseNameDialog"]
[node name="Confirm" type="Label" parent="ChooseNameDialog"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 13.4599
margin_top = 159.388
margin_right = -14.5401
margin_bottom = -13.6124
custom_fonts/font = SubResource( 2 )
custom_colors/font_color = Color( 0.666667, 0.666667, 0.666667, 1 )
text = "Press return to confirm"
align = 1
valign = 1
[node name="Name" type="LineEdit" parent="ChooseNameDialog"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 90.825
margin_top = 100.0
margin_right = -90.0
margin_bottom = -60.0
custom_fonts/font = SubResource( 1 )
custom_fonts/font = SubResource( 3 )
align = 1
placeholder_text = "Player name"
[connection signal="pressed" from="NewRoom" to="." method="_create_room"]
[connection signal="item_selected" from="CreateRoomDialog/DialogElements/RoomRow1/GameType/Dropdown" to="." method="_game_type_selected"]
[connection signal="toggled" from="CreateRoomDialog/DialogElements/RoomRow2/MaxSpec/NameLabel" to="." method="_toggle_spectators"]
[connection signal="item_selected" from="CreateRoomDialog/DialogElements/DraftRows/DraftRow1/DraftType/Dropdown" to="." method="_draft_type_selected"]
[connection signal="text_changed" from="ChooseNameDialog/Name" to="." method="_name_changed"]
[connection signal="text_entered" from="ChooseNameDialog/Name" to="." method="_name_chosen"]

View file

@ -3,9 +3,35 @@ extends Control
signal loaded()
onready var roomList := $RoomScroll/RoomList
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
var RoomItem := preload("res://Scenes/Lobby/RoomEntry.tscn")
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
func _ready():
# Load bgm
BGM.set_volume(BGM.LOW)
@ -14,6 +40,17 @@ func _ready():
Server.get_rooms(self, "_room_list")
add_room("test", "Unnamed room")
$ChooseNameDialog.popup_centered()
# 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)
func add_room(id: String, name: String):
var item := RoomItem.instance()
@ -31,4 +68,44 @@ func _room_clicked(id: String):
print(id)
func _create_room():
$CreateRoomDialog.popup_centered_ratio(0.75)
$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

View file

@ -11,4 +11,7 @@ func _anim_finished(anim_name):
# Load bgm
BGM.set_volume(BGM.HIGH)
BGM.load_music("title")
pass
pass
func _go_to_lobby():
Loader.load_scene("res://Scenes/Lobby.tscn")

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://Scenes/Scripts/TitleScreen.gd" type="Script" id=1]
[ext_resource path="res://UIAssets/mane6start.png" type="Texture" id=2]
[ext_resource path="res://UIAssets/Sounds/Swoosh.wav" type="AudioStream" id=3]
[ext_resource path="res://UIAssets/Sounds/TWRise.wav" type="AudioStream" id=4]
[ext_resource path="res://UIAssets/Effects/FlashCenter.shader" type="Shader" id=5]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Bold.ttf" type="DynamicFontData" id=6]
[sub_resource type="Animation" id=1]
resource_name = "FadeIn"
@ -278,6 +279,10 @@ tracks/2/keys = {
shader = ExtResource( 5 )
shader_param/effect_strength = 0.0
[sub_resource type="DynamicFont" id=4]
size = 40
font_data = ExtResource( 6 )
[node name="TitleScreen" type="Control"]
anchor_left = 0.5
anchor_top = 0.5
@ -361,6 +366,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
[node name="Title" type="Control" parent="."]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
@ -370,4 +376,13 @@ modulate = Color( 1, 1, 1, 0 )
material = SubResource( 3 )
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Button" type="Button" parent="Title"]
margin_left = 466.998
margin_top = 363.297
margin_right = 818.998
margin_bottom = 452.297
custom_fonts/font = SubResource( 4 )
text = "Multiplayer lobby"
[connection signal="animation_finished" from="Intro/AnimationPlayer" to="." method="_anim_finished"]
[connection signal="pressed" from="Title/Button" to="." method="_go_to_lobby"]

View file

@ -0,0 +1,7 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Light.ttf" type="DynamicFontData" id=1]
[resource]
size = 20
font_data = ExtResource( 1 )

15
UIAssets/UITheme.tres Normal file
View file

@ -0,0 +1,15 @@
[gd_resource type="Theme" load_steps=2 format=2]
[ext_resource path="res://UIAssets/Fonts/UIDialogLabel.tres" type="DynamicFont" id=1]
[resource]
default_font = ExtResource( 1 )
Label/colors/font_color = Color( 1, 1, 1, 1 )
Label/colors/font_color_shadow = Color( 0, 0, 0, 0 )
Label/colors/font_outline_modulate = Color( 1, 1, 1, 1 )
Label/constants/line_spacing = 3
Label/constants/shadow_as_outline = 0
Label/constants/shadow_offset_x = 1
Label/constants/shadow_offset_y = 1
Label/fonts/font = null
Label/styles/normal = null

View file

@ -78,7 +78,6 @@ gdscript/warnings/unsafe_call_argument=true
window/size/width=1280
window/size/height=800
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/stretch/aspect="expand"