Compare commits

..

3 commits

Author SHA1 Message Date
91e55a1709 Start work on lobby items 2019-06-29 15:25:13 +02:00
a304697c80 Add players in draft screen 2019-06-29 15:02:11 +02:00
d4fff245bc Add cards to proper categories, fix problem colors 2019-06-29 14:06:55 +02:00
15 changed files with 265 additions and 56 deletions

Binary file not shown.

42
Classes/CardInfo.gd Normal file
View file

@ -0,0 +1,42 @@
extends Object
class_name CardInfo
var id := "unknown"
var name := "Unknown card"
var subname := "--"
var colors := []
var keywords := []
var traits := []
var requirements := {}
var cost := 0
var power := 0
var type := "None"
var text := "This card does not exist, if you see it it's because something failed loading"
var rarity := "UR"
var bonus := 0
var opponentPower := 0
func _init(cardEntry: Dictionary):
if not cardEntry.empty():
id = cardEntry.ID
name = cardEntry.Name
subname = cardEntry.Subname
colors = cardEntry.Element
keywords = cardEntry.Keywords
traits = cardEntry.Traits
type = cardEntry.Type
text = cardEntry.Text
rarity = cardEntry.Rarity
if cardEntry.has("Power"):
power = cardEntry.Power
if cardEntry.has("Cost"):
cost = cardEntry.Cost
if cardEntry.has("ProblemBonus"):
bonus = cardEntry.ProblemBonus
if cardEntry.has("Requirement"):
requirements = cardEntry.Requirement
elif cardEntry.has("ProblemRequirement"):
requirements = cardEntry.ProblemRequirement
if cardEntry.has("ProblemOpponentPower"):
opponentPower = cardEntry.ProblemOpponentPower

View file

@ -36,12 +36,12 @@ scroll_horizontal_enabled = false
[node name="PickedCardList" parent="PickedCardListScroll" instance=ExtResource( 3 )] [node name="PickedCardList" parent="PickedCardListScroll" instance=ExtResource( 3 )]
[node name="VBoxContainer" type="VBoxContainer" parent="."] [node name="PlayerList" type="VBoxContainer" parent="."]
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = 20.0 margin_left = 20.0
margin_top = 20.0 margin_top = 20.0
margin_right = 220.0 margin_right = 220.0
margin_bottom = 20.0 margin_bottom = -20.0
[node name="Cards" type="GridContainer" parent="."] [node name="Cards" type="GridContainer" parent="."]
anchor_left = 0.5 anchor_left = 0.5

View file

@ -0,0 +1,23 @@
extends Panel
export var isBot: bool = false
export var playerName: String = "Nobody"
export var pickedColor: Color
export var pickingColor: Color
onready var playerIcon := $PlayerIcon
onready var playerNameLabel := $PlayerName
func _ready():
if isBot:
var atl := (playerIcon.texture as AtlasTexture).duplicate()
atl.region.position.x = 0
playerIcon.texture = atl
playerNameLabel.text = playerName
func set_picked(picked: bool):
if picked:
playerNameLabel.add_color_override("font_color", pickedColor)
else:
playerNameLabel.add_color_override("font_color", pickingColor)

View file

@ -0,0 +1,43 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Scenes/Draft/PlayerItem.gd" type="Script" id=1]
[ext_resource path="res://UIAssets/Draft/playericons.png" type="Texture" id=2]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Bold.ttf" type="DynamicFontData" id=3]
[sub_resource type="AtlasTexture" id=1]
flags = 13
atlas = ExtResource( 2 )
region = Rect2( 64, 0, 64, 64 )
[sub_resource type="DynamicFont" id=2]
size = 12
extra_spacing_top = 2
font_data = ExtResource( 3 )
[node name="PlayerItem" type="Panel"]
margin_right = 150.0
margin_bottom = 23.0
rect_min_size = Vector2( 150, 23 )
size_flags_horizontal = 3
script = ExtResource( 1 )
pickedColor = Color( 0.380392, 0.984314, 0.372549, 1 )
pickingColor = Color( 1, 0.243137, 0.278431, 1 )
[node name="PlayerIcon" type="TextureRect" parent="."]
anchor_bottom = 1.0
margin_top = 2.0
margin_right = 30.0
margin_bottom = -2.0
texture = SubResource( 1 )
expand = true
stretch_mode = 6
[node name="PlayerName" type="Label" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 30.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 2 )
text = "Nobody"
valign = 1

View file

@ -3,46 +3,6 @@ extends Node
var loadedSets := {} var loadedSets := {}
var loadedCards := {} var loadedCards := {}
class CardInfo:
var id := "unknown"
var name := "Unknown card"
var subname := "--"
var colors := []
var keywords := []
var traits := []
var requirements := {}
var cost := 0
var power := 0
var type := "None"
var text := "This card does not exist, if you see it it's because something failed loading"
var rarity := "UR"
var bonus := 0
var opponentPower := 0
func _init(cardEntry: Dictionary):
if not cardEntry.empty():
id = cardEntry.ID
name = cardEntry.Name
subname = cardEntry.Subname
colors = cardEntry.Element
keywords = cardEntry.Keywords
traits = cardEntry.Traits
type = cardEntry.Type
text = cardEntry.Text
rarity = cardEntry.Rarity
if cardEntry.has("Power"):
power = cardEntry.Power
if cardEntry.has("Cost"):
cost = cardEntry.Cost
if cardEntry.has("ProblemBonus"):
bonus = cardEntry.ProblemBonus
if cardEntry.has("Requirement"):
requirements = cardEntry.Requirement
elif cardEntry.has("ProblemRequirement"):
requirements = cardEntry.ProblemRequirement
if cardEntry.has("ProblemOpponentPower"):
opponentPower = cardEntry.ProblemOpponentPower
func _ready(): func _ready():
# Search for sets in MLPData # Search for sets in MLPData
var dir := Directory.new() var dir := Directory.new()

View file

@ -2,8 +2,23 @@ extends Control
signal loaded() signal loaded()
onready var roomList := $RoomScroll/RoomList
var RoomItem := preload("res://Scenes/Lobby/RoomEntry.tscn")
func _ready(): func _ready():
# Load bgm # Load bgm
BGM.load_music("lobby") BGM.load_music("lobby")
emit_signal("loaded") emit_signal("loaded")
add_room("test", "Unnamed room")
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)
func _room_clicked(id: String):
print(id)

View file

@ -1,15 +1,14 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://Scenes/Lobby.gd" type="Script" id=1] [ext_resource path="res://Scenes/Lobby.gd" type="Script" id=1]
[ext_resource path="res://MLPAssets/Background/menubg.webp" type="Texture" id=2] [ext_resource path="res://MLPAssets/Background/menubg.webp" type="Texture" id=2]
[ext_resource path="res://Scenes/Lobby/RoomEntry.tscn" type="PackedScene" id=3]
[node name="Lobby" type="Control"] [node name="Lobby" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="TextureRect" type="TextureRect" parent="."] [node name="Background" type="TextureRect" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = -1.29236 margin_left = -1.29236
@ -18,20 +17,17 @@ texture = ExtResource( 2 )
expand = true expand = true
stretch_mode = 7 stretch_mode = 7
[node name="ScrollContainer" type="ScrollContainer" parent="."] [node name="RoomScroll" type="ScrollContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = 30.0 margin_left = 30.0
margin_top = 100.0 margin_top = 100.0
margin_right = -30.0 margin_right = -30.0
margin_bottom = -300.0 margin_bottom = -300.0
scroll_horizontal_enabled = false
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] [node name="RoomList" type="VBoxContainer" parent="RoomScroll"]
margin_right = 1220.0 margin_right = 1220.0
margin_bottom = 400.0 margin_bottom = 400.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
[node name="Control" parent="ScrollContainer/VBoxContainer" instance=ExtResource( 3 )]
anchor_right = 0.0
margin_right = 1220.0

24
Scenes/Lobby/RoomEntry.gd Normal file
View file

@ -0,0 +1,24 @@
extends Panel
signal clicked()
export var roomName: String = "Unnamed room"
onready var roomNameLabel := $RoomName
func _ready():
roomNameLabel.text = roomName
func _gui_input(event: InputEvent):
# Left double click
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
accept_event()
if event.doubleclick:
emit_signal("clicked")
else:
#TODO Fade in
pass
func _mouse_exited():
#TODO if faded in, fade out
pass

View file

@ -1,4 +1,14 @@
[gd_scene format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://Scenes/Lobby/RoomEntry.gd" type="Script" id=1]
[ext_resource path="res://UIAssets/Fonts/Catamaran-Bold.ttf" type="DynamicFontData" id=2]
[sub_resource type="DynamicFont" id=1]
size = 26
use_mipmaps = true
use_filter = true
extra_spacing_top = 2
font_data = ExtResource( 2 )
[node name="RoomEntry" type="Panel"] [node name="RoomEntry" type="Panel"]
anchor_right = 1.0 anchor_right = 1.0
@ -6,3 +16,14 @@ margin_right = -280.0
margin_bottom = 50.0 margin_bottom = 50.0
rect_min_size = Vector2( 0, 50 ) rect_min_size = Vector2( 0, 50 )
size_flags_horizontal = 3 size_flags_horizontal = 3
script = ExtResource( 1 )
[node name="RoomName" type="Label" parent="."]
margin_left = 20.0
margin_right = 411.0
margin_bottom = 50.0
custom_fonts/font = SubResource( 1 )
text = "Unnamed Room"
valign = 1
[connection signal="gui_input" from="." to="." method="_gui_input"]
[connection signal="mouse_exited" from="RoomName" to="." method="_mouse_exited"]

View file

@ -1,8 +1,12 @@
extends Control extends Control
onready var CardList = $PickedCardListScroll/PickedCardList onready var CardList = $PickedCardListScroll/PickedCardList
onready var PlayerList = $PlayerList
var players = {}
var CardUI := preload("res://Scenes/DeckBuilder/UICard.tscn") var CardUI := preload("res://Scenes/DeckBuilder/UICard.tscn")
var PlayerItem := preload("res://Scenes/Draft/PlayerItem.tscn")
func _ready(): func _ready():
add_card("pr1") add_card("pr1")
@ -17,6 +21,8 @@ func _ready():
add_card("pr10") add_card("pr10")
add_card("pr20") add_card("pr20")
add_card("pr30") add_card("pr30")
add_player("Player 1", false)
add_player("Bot 1", true)
func add_card(cardID: String): func add_card(cardID: String):
var card := CardUI.instance() var card := CardUI.instance()
@ -40,8 +46,17 @@ func _card_unselected():
func _card_picked(cardID: String): func _card_picked(cardID: String):
CardList.add_card(cardID) CardList.add_card(cardID)
players["Player 1"].set_picked(true)
$CardZoom.fadeout() $CardZoom.fadeout()
#clear_cards() clear_cards()
func add_player(playerName: String, isBot: bool):
var item := PlayerItem.instance()
item.playerName = playerName
item.isBot = isBot
players[playerName] = item
$PlayerList.add_child(item)
item.set_picked(false)
const yMargin = 5 const yMargin = 5
const xEdge = 200 const xEdge = 200

View file

@ -30,8 +30,36 @@ func add_card(cardID: String):
item.cardSubname = data.subname item.cardSubname = data.subname
item.showCost = has_cost(data.type) item.showCost = has_cost(data.type)
item.cardCost = data.cost item.cardCost = data.cost
if data.type == "Problem":
item.color = to_color_ids(data.requirements.keys())
else:
item.color = to_color_ids(data.colors) item.color = to_color_ids(data.colors)
blocks["entry"].add_child(item) var cat := get_card_group(data)
add_to_card_group(cat, item)
func get_card_group(item: CardInfo) -> String:
match item.type:
"Friend":
# Entry if req is 0, friend otherwise
if item.requirements.size() < 1:
return "entry"
return "friend"
"Event":
#TODO some events are entry (color-fixing)
return "event"
"Resource":
#TODO some resources are entry (color-fixing)
return "resource"
"Troublemaker":
return "troublemaker"
"Problem":
return "problem"
"Mane Character":
return "mane"
func add_to_card_group(cat: String, item: Node):
blocks[cat].add_child(item)
labels[cat].visible = true
var colorTable = { var colorTable = {
"Loyalty": "blue", "Loyalty": "blue",
@ -45,6 +73,7 @@ var colorTable = {
func to_color_ids(ogcolors: Array) -> String: func to_color_ids(ogcolors: Array) -> String:
var newcol := [] var newcol := []
for ogcol in ogcolors: for ogcol in ogcolors:
ogcol = (ogcol as String).trim_prefix("Not ")
if colorTable.has(ogcol): if colorTable.has(ogcol):
newcol.push_back(colorTable[ogcol]) newcol.push_back(colorTable[ogcol])
match newcol.size(): match newcol.size():

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/playericons.png-eeeb153289558a7b4ae89e3caa9a0b44.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://UIAssets/Draft/playericons.png"
dest_files=[ "res://.import/playericons.png-eeeb153289558a7b4ae89e3caa9a0b44.stex" ]
[params]
compress/mode=1
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=true
flags/anisotropic=true
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -19,6 +19,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://Scenes/Board/Card.gd" "path": "res://Scenes/Board/Card.gd"
}, { }, {
"base": "Object",
"class": "CardInfo",
"language": "GDScript",
"path": "res://Classes/CardInfo.gd"
}, {
"base": "Reference", "base": "Reference",
"class": "Resources", "class": "Resources",
"language": "GDScript", "language": "GDScript",
@ -37,6 +42,7 @@ _global_script_classes=[ {
_global_script_class_icons={ _global_script_class_icons={
"Board": "", "Board": "",
"Card": "", "Card": "",
"CardInfo": "",
"Resources": "", "Resources": "",
"ScatterCard": "", "ScatterCard": "",
"Stack": "" "Stack": ""
@ -71,6 +77,7 @@ gdscript/warnings/unsafe_call_argument=true
window/size/width=1280 window/size/width=1280
window/size/height=800 window/size/height=800
window/dpi/allow_hidpi=true
window/stretch/mode="2d" window/stretch/mode="2d"
window/stretch/aspect="expand" window/stretch/aspect="expand"