oh fuck im gonna have to learn to clean up previous commits
This commit is contained in:
71
UI/CardSelectionBox/card_selection_box.gd
Normal file
71
UI/CardSelectionBox/card_selection_box.gd
Normal file
@@ -0,0 +1,71 @@
|
||||
class_name CardSelectionBox
|
||||
extends Control
|
||||
|
||||
@export var icon: TextureRect
|
||||
@export var tags: VBoxContainer
|
||||
@export var cost_label: Label
|
||||
@export var lifetime_label: Label
|
||||
@export var unselected_style_box: StyleBoxFlat
|
||||
@export var selected_style_box: StyleBoxFlat
|
||||
|
||||
|
||||
func set_card(card: Card) -> void:
|
||||
icon.texture = card.icon
|
||||
cost_label.text = str(card.rarity + 1)
|
||||
lifetime_label.text = str(card.duration)
|
||||
for i: int in tags.get_child_count():
|
||||
tags.get_child(i).queue_free()
|
||||
for tag: Data.CardTags in card.tags:
|
||||
var tag_icon: TextureRect = icon.duplicate()
|
||||
if tag == Data.CardTags.DAMAGE:
|
||||
tag_icon.texture = load("res://Assets/Textures/damage_icon.png")
|
||||
if tag == Data.CardTags.UTILITY:
|
||||
tag_icon.texture = load("res://Assets/Textures/utility_icon.png")
|
||||
if tag == Data.CardTags.TARGETS_FLYING:
|
||||
tag_icon.modulate = Color.FIREBRICK
|
||||
tag_icon.texture = load("res://Assets/Textures/flight_icon.png")
|
||||
tags.add_child(tag_icon)
|
||||
|
||||
|
||||
func set_key(slot: int) -> void:
|
||||
match(slot):
|
||||
0:
|
||||
$Label.text = parse_action_tag("#Select 1st Card#")
|
||||
1:
|
||||
$Label.text = parse_action_tag("#Select 2nd Card#")
|
||||
2:
|
||||
$Label.text = parse_action_tag("#Select 3rd Card#")
|
||||
3:
|
||||
$Label.text = parse_action_tag("#Select 4th Card#")
|
||||
44:
|
||||
$Label.text = parse_action_tag("#Select 5th Card#")
|
||||
|
||||
|
||||
func parse_action_tag(text: String) -> String:
|
||||
var string_array: PackedStringArray = text.split("#")
|
||||
var output: Array[String] = []
|
||||
if string_array.size() > 1:
|
||||
for i: int in InputMap.action_get_events(string_array[1]).size():
|
||||
var event: InputEvent = InputMap.action_get_events(string_array[1])[i]
|
||||
if InputMap.action_get_events(string_array[1]).size() > 1:
|
||||
var last: bool = true if i == InputMap.action_get_events(string_array[1]).size() - 1 else false
|
||||
var first: bool = true if i == 0 else false
|
||||
if last:
|
||||
output.append(" or ")
|
||||
elif !first:
|
||||
output.append(", ")
|
||||
if event is InputEventKey:
|
||||
output.append("[img=top,50]%s[/img]" % KeyIconMap.keys[str(event.physical_keycode)])
|
||||
if event is InputEventMouseButton:
|
||||
output.append("[img=top,50]%s[/img]" % KeyIconMap.mouse_buttons[str(event.button_index)])
|
||||
string_array[1] = "".join(output)
|
||||
text = "".join(string_array)
|
||||
return text
|
||||
|
||||
|
||||
func select() -> void:
|
||||
$PanelContainer.add_theme_stylebox_override("panel", selected_style_box)
|
||||
|
||||
|
||||
func deselect() -> void:
|
||||
$PanelContainer.add_theme_stylebox_override("panel", unselected_style_box)
|
||||
1
UI/CardSelectionBox/card_selection_box.gd.uid
Normal file
1
UI/CardSelectionBox/card_selection_box.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://87h0a76hdx4b
|
||||
78
UI/CardSelectionBox/card_selection_box.tscn
Normal file
78
UI/CardSelectionBox/card_selection_box.tscn
Normal file
@@ -0,0 +1,78 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://gdd1xupf4oxx"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b165eh481oodf" path="res://Assets/Textures/damage_icon.png" id="1_k8442"]
|
||||
[ext_resource type="Script" uid="uid://87h0a76hdx4b" path="res://UI/CardSelectionBox/card_selection_box.gd" id="1_m0g3h"]
|
||||
[ext_resource type="StyleBox" uid="uid://c4ye5r2xdsocm" path="res://UI/CardSelectionBox/unselected_style_box.tres" id="2_0817q"]
|
||||
[ext_resource type="StyleBox" uid="uid://csbgndc6vfayf" path="res://UI/CardSelectionBox/selected_style_box.tres" id="2_ek0dh"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpcyxdpog3w85" path="res://Assets/Textures/assault_icon.png" id="2_m0g3h"]
|
||||
|
||||
[node name="Control" type="Control" node_paths=PackedStringArray("icon", "tags", "cost_label", "lifetime_label")]
|
||||
custom_minimum_size = Vector2(170, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_m0g3h")
|
||||
icon = NodePath("PanelContainer/HBoxContainer/Icon")
|
||||
tags = NodePath("PanelContainer/HBoxContainer/MarginContainer/Tags")
|
||||
cost_label = NodePath("PanelContainer/HBoxContainer/Stats/Cost")
|
||||
lifetime_label = NodePath("PanelContainer/HBoxContainer/Stats/Lifetime")
|
||||
unselected_style_box = ExtResource("2_0817q")
|
||||
selected_style_box = ExtResource("2_ek0dh")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 2
|
||||
offset_right = 152.0
|
||||
offset_bottom = 124.0
|
||||
theme_override_styles/panel = ExtResource("2_ek0dh")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="Tags" type="VBoxContainer" parent="PanelContainer/HBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Icon2" type="TextureRect" parent="PanelContainer/HBoxContainer/MarginContainer/Tags"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
texture = ExtResource("1_k8442")
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
texture = ExtResource("2_m0g3h")
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Stats" type="VBoxContainer" parent="PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Cost" type="Label" parent="PanelContainer/HBoxContainer/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 7
|
||||
text = "3"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Lifetime" type="Label" parent="PanelContainer/HBoxContainer/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 7
|
||||
text = "6"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Label" type="RichTextLabel" parent="."]
|
||||
layout_mode = 1
|
||||
offset_left = -25.0
|
||||
offset_top = 100.0
|
||||
offset_right = 25.0
|
||||
offset_bottom = 150.0
|
||||
bbcode_enabled = true
|
||||
text = "[img=top,50]/home/lexi/godot/multiplayer_tower_defense/UI/Keybinding/XeluController&KeyPrompts/Keyboard & Mouse/Light/1_Key_Light.png[/img]"
|
||||
fit_content = true
|
||||
vertical_alignment = 2
|
||||
8
UI/CardSelectionBox/selected_style_box.tres
Normal file
8
UI/CardSelectionBox/selected_style_box.tres
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="StyleBoxFlat" format=3 uid="uid://csbgndc6vfayf"]
|
||||
|
||||
[resource]
|
||||
content_margin_left = 8.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 8.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0.430763, 0.633388, 0.725502, 1)
|
||||
6
UI/CardSelectionBox/unselected_style_box.tres
Normal file
6
UI/CardSelectionBox/unselected_style_box.tres
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_resource type="StyleBoxFlat" format=3 uid="uid://c4ye5r2xdsocm"]
|
||||
|
||||
[resource]
|
||||
content_margin_left = 8.0
|
||||
content_margin_right = 8.0
|
||||
bg_color = Color(0.292, 0.292, 0.292, 0.89)
|
||||
Reference in New Issue
Block a user