From 97322b565fb6359ea855a5327e3a6d339e55b27d Mon Sep 17 00:00:00 2001 From: CactiChameleon9 Date: Sat, 16 Jul 2022 10:33:31 +0100 Subject: [PATCH] Implement a basic color changing card --- UI/Card.gd | 25 +++++++++++++++++++++++++ UI/Card.tscn | 16 ++++++++++++++++ UI/CardStyle.tres | 7 +++++++ UI/CardView.tscn | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 UI/Card.gd create mode 100644 UI/Card.tscn create mode 100644 UI/CardStyle.tres create mode 100644 UI/CardView.tscn diff --git a/UI/Card.gd b/UI/Card.gd new file mode 100644 index 0000000..b12d4df --- /dev/null +++ b/UI/Card.gd @@ -0,0 +1,25 @@ +tool +extends Control + + +enum TYPE { + DAMAGE = 0 + UTILITY = 1 + SPECIAL = 2 + EFFECT = 3 +} + +const TYPE_COLORS = [ + Color("#db4758"), # DAMAGE + Color("#3cc361"), # UTILITY + Color("#ddd55c"), # SPECIAL + Color("#bc5ec6"), # EFFECT +] + +export (TYPE) var type + + +func _ready(): + var card_style = $PanelContainer.get('custom_styles/panel').duplicate(true) + card_style.set_bg_color(TYPE_COLORS[type]) + $PanelContainer.set('custom_styles/panel', card_style) diff --git a/UI/Card.tscn b/UI/Card.tscn new file mode 100644 index 0000000..72fffbe --- /dev/null +++ b/UI/Card.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://UI/Card.gd" type="Script" id=1] +[ext_resource path="res://UI/CardStyle.tres" type="StyleBox" id=2] + +[node name="Card" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource( 1 ) + +[node name="PanelContainer" type="PanelContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +custom_styles/panel = ExtResource( 2 ) diff --git a/UI/CardStyle.tres b/UI/CardStyle.tres new file mode 100644 index 0000000..d919b32 --- /dev/null +++ b/UI/CardStyle.tres @@ -0,0 +1,7 @@ +[gd_resource type="StyleBoxFlat" format=2] + +[resource] +corner_radius_top_left = 20 +corner_radius_top_right = 20 +corner_radius_bottom_right = 20 +corner_radius_bottom_left = 20 diff --git a/UI/CardView.tscn b/UI/CardView.tscn new file mode 100644 index 0000000..74b8833 --- /dev/null +++ b/UI/CardView.tscn @@ -0,0 +1,35 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://UI/Card.tscn" type="PackedScene" id=1] + +[node name="CardView" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="HBox" type="HBoxContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +custom_constants/separation = 50 + +[node name="Card1" parent="HBox" instance=ExtResource( 1 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 308.0 +margin_bottom = 600.0 +type = 1 + +[node name="Card2" parent="HBox" instance=ExtResource( 1 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 358.0 +margin_right = 666.0 +margin_bottom = 600.0 +type = 2 + +[node name="Card3" parent="HBox" instance=ExtResource( 1 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 716.0 +margin_right = 1024.0 +margin_bottom = 600.0 +type = 3