Add players in draft screen

This commit is contained in:
Hamcha 2019-06-29 15:02:11 +02:00
parent d4fff245bc
commit a304697c80
8 changed files with 118 additions and 2 deletions

Binary file not shown.

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

@ -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,9 +46,18 @@ 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
const yEdge = 10 const yEdge = 10

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

@ -77,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"