diff --git a/components/Abstracts/FeedCardBase.tscn b/components/Abstracts/FeedCardBase.tscn index 8d1c9a3..63ce357 100644 --- a/components/Abstracts/FeedCardBase.tscn +++ b/components/Abstracts/FeedCardBase.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://bykwevnv7keeh"] +[gd_scene load_steps=6 format=3 uid="uid://bykwevnv7keeh"] [ext_resource type="Script" path="res://scripts/Structs/Feed.gd" id="1_2ea75"] [ext_resource type="Theme" uid="uid://dhvs6urgf6jr5" path="res://themes/main.tres" id="2_lvrpo"] -[ext_resource type="Texture2D" uid="uid://bxqax0anr5a45" path="res://resources/feeds/donut.svg" id="3_q17fm"] +[ext_resource type="Texture2D" uid="uid://dwwpkn4q07ja2" path="res://icon.svg" id="3_v6s0y"] +[ext_resource type="PackedScene" uid="uid://bt370a1djjg5p" path="res://components/UI/FeedName.tscn" id="4_aewpy"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2ewr"] content_margin_left = 30.0 @@ -47,18 +48,14 @@ custom_minimum_size = Vector2(75, 75) layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 0 -texture = ExtResource("3_q17fm") +texture = ExtResource("3_v6s0y") expand_mode = 1 stretch_mode = 5 -[node name="name" type="RichTextLabel" parent="container/info"] +[node name="name" parent="container/info" instance=ExtResource("4_aewpy")] unique_name_in_owner = true layout_mode = 2 -size_flags_horizontal = 4 -bbcode_enabled = true -text = "[b]未命名饲料[/b]" -fit_content = true -autowrap_mode = 0 +quality = 1 [node name="fields" type="VBoxContainer" parent="container"] unique_name_in_owner = true diff --git a/components/UI/FeedName.tscn b/components/UI/FeedName.tscn new file mode 100644 index 0000000..27cdc88 --- /dev/null +++ b/components/UI/FeedName.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=2 format=3 uid="uid://bt370a1djjg5p"] + +[ext_resource type="Script" path="res://scripts/Statemachine/FeedName.gd" id="1_wfxme"] + +[node name="FeedName" type="CenterContainer"] +offset_right = 107.0 +offset_bottom = 19.0 +script = ExtResource("1_wfxme") +quality = 0 +colorStore = { +0: Color(0.5, 0.5, 0.5, 1), +1: Color(1, 1, 1, 1), +2: Color(0, 0.609284, 1, 1), +3: Color(0.561523, 0, 1, 1), +4: Color(1, 0.866475, 0, 1) +} + +[node name="label" type="RichTextLabel" parent="."] +unique_name_in_owner = true +layout_mode = 2 +bbcode_enabled = true +text = "[b][color=#808080]未命名饲料[/color][/b]" +fit_content = true +autowrap_mode = 0 diff --git a/scripts/Statemachine/FeedName.gd b/scripts/Statemachine/FeedName.gd new file mode 100644 index 0000000..d0ee107 --- /dev/null +++ b/scripts/Statemachine/FeedName.gd @@ -0,0 +1,42 @@ +@tool +extends CenterContainer +class_name FeedName + +enum Quality { + WASTE, + COMMON, + RARE, + EPIC, + LEGENDARY, +} + +@export var displayName: String = "未命名饲料" +@export var quality: Quality = Quality.COMMON +@export var qualityColorMap = { + Quality.WASTE: Color(), + Quality.COMMON: Color(), + Quality.RARE: Color(), + Quality.EPIC: Color(), + Quality.LEGENDARY: Color() +} +@export var qualityNameMap = { + Quality.WASTE: "常见", + Quality.COMMON: "普通", + Quality.RARE: "稀有", + Quality.EPIC: "史诗", + Quality.LEGENDARY: "传说" +} +@export var qualityRandomWeight = { + Quality.WASTE: 5, + Quality.COMMON: 50, + Quality.RARE: 10, + Quality.EPIC: 5, + Quality.LEGENDARY: 1 +} + +@onready var label: RichTextLabel = $"%label" + +func _physics_process(_delta): + label.text = "[b][color=%s]%s[/color][/b]" % ["#" + color().to_html(false), displayName] +func color(): + return qualityColorMap[quality] as Color diff --git a/scripts/Structs/Feed.gd b/scripts/Structs/Feed.gd index a748f42..99f8acc 100644 --- a/scripts/Structs/Feed.gd +++ b/scripts/Structs/Feed.gd @@ -6,13 +6,14 @@ signal selected(applied: bool) @export var avatarTexture: Texture2D = preload("res://icon.svg") @export var displayName: String = "未命名饲料" +@export var quality: FeedName.Quality = FeedName.Quality.COMMON @export var fields: Array[FieldStore.Entity] = [] @export var fieldValues: Array[float] = [] @export var costs: Array[ItemStore.ItemType] = [] @export var costCounts: Array[int] = [] @onready var avatarRect: TextureRect = $"%avatar" -@onready var nameLabel: RichTextLabel = $"%name" +@onready var nameLabel: FeedName = $"%name" @onready var fieldsBox: VBoxContainer = $"%fields" @onready var costsBox: GridContainer = $"%costs" @onready var selectButton: Button = $"%selectBtn" @@ -23,7 +24,8 @@ func _ready(): apply(UIState.player) ) avatarRect.texture = avatarTexture - nameLabel.text = "[b]" + displayName + "[/b]" + nameLabel.displayName = displayName + nameLabel.quality = quality for i in fieldsBox.get_children(): i.queue_free() var noField = true