improved card size
parent
c2cbeba20c
commit
681471259b
|
|
@ -1,68 +1,101 @@
|
||||||
[gd_scene format=3 uid="uid://cgl06rqop270h"]
|
[gd_scene format=3 uid="uid://bbhpa50ef6702"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dw5y2tp34fxys" path="res://scripts/perk_card.gd" id="1_t8gqh"]
|
[ext_resource type="Script" uid="uid://dw5y2tp34fxys" path="res://scripts/perk_card.gd" id="1_t8gqh"]
|
||||||
[ext_resource type="Texture2D" uid="uid://duo145bmwho8d" path="res://assets/UI assets pack 2/UI books & more.png" id="2_nlhlf"]
|
[ext_resource type="Texture2D" uid="uid://duo145bmwho8d" path="res://assets/UI assets pack 2/UI books & more.png" id="2_nlhlf"]
|
||||||
[ext_resource type="FontFile" uid="uid://cq0jx2aapggkg" path="res://assets/fonts/slkscrb.ttf" id="3_n4umd"]
|
[ext_resource type="FontFile" uid="uid://cq0jx2aapggkg" path="res://assets/fonts/slkscrb.ttf" id="3_n4umd"]
|
||||||
[ext_resource type="FontFile" uid="uid://brooj0hba7650" path="res://assets/fonts/slkscr.ttf" id="4_40ty6"]
|
[ext_resource type="FontFile" uid="uid://brooj0hba7650" path="res://assets/fonts/slkscr.ttf" id="4_40ty6"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cdktimg5axaxj" path="res://assets/Fire Pixel Bullet 16x16/All_Fire_Bullet_Pixel_16x16_01.png" id="4_nlhlf"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fgk3h"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fgk3h"]
|
||||||
atlas = ExtResource("2_nlhlf")
|
atlas = ExtResource("2_nlhlf")
|
||||||
region = Rect2(561, 17, 46, 62)
|
region = Rect2(561, 17, 46, 62)
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_qag4p"]
|
[sub_resource type="LabelSettings" id="LabelSettings_qag4p"]
|
||||||
line_spacing = 0.0
|
line_spacing = 5.0
|
||||||
font = ExtResource("3_n4umd")
|
font = ExtResource("3_n4umd")
|
||||||
font_size = 5
|
font_size = 12
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_n4umd"]
|
||||||
|
atlas = ExtResource("4_nlhlf")
|
||||||
|
region = Rect2(258, 241, 25, 14)
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_ni87r"]
|
[sub_resource type="LabelSettings" id="LabelSettings_ni87r"]
|
||||||
font = ExtResource("4_40ty6")
|
font = ExtResource("4_40ty6")
|
||||||
font_size = 3
|
font_size = 11
|
||||||
|
|
||||||
[node name="PerkCard" type="Control" unique_id=1471811151]
|
[node name="PerkCard" type="Control" unique_id=1471811151]
|
||||||
|
custom_minimum_size = Vector2(200, 300)
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
script = ExtResource("1_t8gqh")
|
script = ExtResource("1_t8gqh")
|
||||||
|
|
||||||
[node name="Card" type="TextureRect" parent="." unique_id=1832247473]
|
[node name="Card" type="TextureRect" parent="." unique_id=1832247473]
|
||||||
texture_filter = 1
|
texture_filter = 1
|
||||||
|
custom_minimum_size = Vector2(200, 300)
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
texture = SubResource("AtlasTexture_fgk3h")
|
texture = SubResource("AtlasTexture_fgk3h")
|
||||||
|
|
||||||
[node name="Description" type="Label" parent="Card" unique_id=2006873472]
|
[node name="Name" type="Label" parent="Card" unique_id=2006873472]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
offset_left = -20.5
|
offset_left = -50.5
|
||||||
offset_top = 7.0
|
offset_top = 43.0
|
||||||
offset_right = 20.5
|
offset_right = 50.5
|
||||||
offset_bottom = 23.0
|
offset_bottom = 92.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
text = "AOE
|
text = "Zweizeilige
|
||||||
-Feuerball"
|
Überschrift
|
||||||
|
"
|
||||||
label_settings = SubResource("LabelSettings_qag4p")
|
label_settings = SubResource("LabelSettings_qag4p")
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="Name" type="Label" parent="Card" unique_id=859816848]
|
[node name="TextureRect" type="TextureRect" parent="Card/Name" unique_id=2128840891]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 7
|
anchors_preset = 7
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_left = -20.0
|
offset_left = -24.5
|
||||||
offset_top = -36.0
|
offset_top = -10.0
|
||||||
offset_right = 20.0
|
offset_right = 24.5
|
||||||
|
offset_bottom = 19.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
text = "Das ist ein test"
|
texture = SubResource("AtlasTexture_n4umd")
|
||||||
|
|
||||||
|
[node name="Description" type="Label" parent="Card" unique_id=859816848]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 7
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -65.0
|
||||||
|
offset_top = -176.0
|
||||||
|
offset_right = 69.0
|
||||||
|
offset_bottom = -43.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
text = "Text in Zeile Eins
|
||||||
|
Text in Zeile Eins
|
||||||
|
Text in Zeile Eins
|
||||||
|
Text in Zeile Eins
|
||||||
|
Text in Zeile Zwei
|
||||||
|
Text in Zeile Drei
|
||||||
|
Text in Zeile Vier
|
||||||
|
Text in Zeile Fünf"
|
||||||
label_settings = SubResource("LabelSettings_ni87r")
|
label_settings = SubResource("LabelSettings_ni87r")
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
autowrap_mode = 2
|
autowrap_mode = 2
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="." unique_id=1274377333]
|
[node name="Button" type="Button" parent="." unique_id=1274377333]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_right = 46.0
|
offset_right = 200.0
|
||||||
offset_bottom = 62.0
|
offset_bottom = 300.0
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -2427,6 +2427,7 @@ grow_horizontal = 2
|
||||||
script = ExtResource("16_rysoc")
|
script = ExtResource("16_rysoc")
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/LevelUpManager" unique_id=957625333]
|
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/LevelUpManager" unique_id=957625333]
|
||||||
|
custom_minimum_size = Vector2(1000, 400)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
|
@ -2439,6 +2440,7 @@ offset_right = 20.0
|
||||||
offset_bottom = 390.0
|
offset_bottom = 390.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
theme_override_constants/separation = 50
|
||||||
alignment = 1
|
alignment = 1
|
||||||
|
|
||||||
[node name="PerkEffects" type="Node2D" parent="." unique_id=2027136639]
|
[node name="PerkEffects" type="Node2D" parent="." unique_id=2027136639]
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@ class_name Perk
|
||||||
|
|
||||||
@export var name: String
|
@export var name: String
|
||||||
@export var description: String
|
@export var description: String
|
||||||
|
@export var icon: Texture2D = null
|
||||||
var effect: Callable
|
var effect: Callable
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ extends Control
|
||||||
|
|
||||||
@onready var perk_effects = get_node("/root/Game/PerkEffects")
|
@onready var perk_effects = get_node("/root/Game/PerkEffects")
|
||||||
var perks
|
var perks
|
||||||
|
@onready var perkCard = preload("res://scenes/PerkCard.tscn")
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
perks = perk_effects.available_perks
|
perks = perk_effects.available_perks
|
||||||
|
|
@ -22,12 +23,10 @@ func show_perks():
|
||||||
shuffled.shuffle()
|
shuffled.shuffle()
|
||||||
var chosen = shuffled.slice(0, 3)
|
var chosen = shuffled.slice(0, 3)
|
||||||
for x in chosen:
|
for x in chosen:
|
||||||
var button = Button.new()
|
var card = perkCard.instantiate()
|
||||||
button.text = x.name + "\n" + x.description
|
$HBoxContainer.add_child(card)
|
||||||
button.custom_minimum_size = Vector2(200, 500)
|
card.setup(x, func(): select_perk(x))
|
||||||
button.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
|
||||||
button.pressed.connect(func(): select_perk(x))
|
|
||||||
$HBoxContainer.add_child(button)
|
|
||||||
|
|
||||||
func select_perk(perk):
|
func select_perk(perk):
|
||||||
perk.effect.call()
|
perk.effect.call()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,40 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
@export var icon: Texture2D
|
@export var icon: Texture2D
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
var on_select: Callable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func setup(perk: Perk, select: Callable):
|
||||||
|
$Button.modulate.a = 0
|
||||||
|
$Card/Name.text = perk.name
|
||||||
|
$Card/Description.text = perk.description
|
||||||
|
if perk.icon != null:
|
||||||
|
$Card/Name/TextureRect.texture = perk.icon
|
||||||
|
animate_in()
|
||||||
|
on_select = select
|
||||||
|
$Button.pressed.connect(_on_button_pressed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_button_pressed() -> void:
|
||||||
|
await animate_out()
|
||||||
|
on_select.call()
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
func animate_in():
|
||||||
|
await get_tree().process_frame
|
||||||
|
var start_y = global_position.y + 500
|
||||||
|
var end_y = global_position.y
|
||||||
|
global_position.y = start_y
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD)
|
||||||
|
|
||||||
|
func animate_out():
|
||||||
|
var start_y = global_position.y
|
||||||
|
var end_y = global_position.y - 500
|
||||||
|
global_position.y = start_y
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_QUAD)
|
||||||
|
await tween.finished
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue