mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
feat(UI): 更新字体资源并优化物品显示逻辑
替换原有字体文件为OTF格式,添加粗体字体支持 在物品显示组件中添加字体颜色变化功能,根据资源是否足够显示不同颜色 优化Feed类的资源消耗计算逻辑,增加countOf方法提高可读性
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://ccuucmpdsjgb3"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://ccuucmpdsjgb3"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Statemachine/DamageLabel.gd" id="1_0q15u"]
|
||||
[ext_resource type="FontFile" uid="uid://v3frxpuvtj5o" path="res://resources/fonts/syht-bold.ttf" id="2_p1o7i"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_valp2"]
|
||||
font = ExtResource("2_p1o7i")
|
||||
font_size = 25
|
||||
outline_size = 6
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bbm8l3hr4ihar"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://bbm8l3hr4ihar"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Statemachine/ItemShow.gd" id="1_2dhsb"]
|
||||
[ext_resource type="Texture2D" uid="uid://bks8jmctleina" path="res://resources/items/baseball.svg" id="1_hyowb"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_3yjwr"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6sxrr"]
|
||||
length = 0.001
|
||||
tracks/0/type = "bezier"
|
||||
@@ -110,6 +112,7 @@ layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 8
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_3yjwr")
|
||||
|
||||
[node name="animator" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ project/assembly_name="ChickenVSBear"
|
||||
[gui]
|
||||
|
||||
theme/custom="res://themes/main.tres"
|
||||
theme/custom_font="res://resources/fonts/syht.ttf"
|
||||
theme/custom_font="res://resources/fonts/syht.otf"
|
||||
|
||||
[input]
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://v3frxpuvtj5o"
|
||||
path="res://.godot/imported/syht.ttf-4e5237bd9d733edbe0924500cb0652ef.fontdata"
|
||||
path="res://.godot/imported/syht-bold.ttf-d2f3da15c712d5ae8c3980a92666acf1.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/fonts/syht.ttf"
|
||||
dest_files=["res://.godot/imported/syht.ttf-4e5237bd9d733edbe0924500cb0652ef.fontdata"]
|
||||
source_file="res://resources/fonts/syht-bold.ttf"
|
||||
dest_files=["res://.godot/imported/syht-bold.ttf-d2f3da15c712d5ae8c3980a92666acf1.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://cidql48uspujd"
|
||||
path="res://.godot/imported/syht.otf-6c719d9824cc1519958ce5c1d54778a5.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/fonts/syht.otf"
|
||||
dest_files=["res://.godot/imported/syht.otf-6c719d9824cc1519958ce5c1d54778a5.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
@@ -5,12 +5,14 @@ class_name ItemShow
|
||||
@export var type: ItemStore.ItemType = ItemStore.ItemType.BASEBALL
|
||||
@export var count: int = 0
|
||||
@export var autoFree: bool = false
|
||||
@export var enough: bool = true
|
||||
|
||||
@onready var avatarTexture: TextureRect = $"%avatar"
|
||||
@onready var countLabel: Label = $"%count"
|
||||
@onready var animator: AnimationPlayer = $"%animator"
|
||||
|
||||
func _ready():
|
||||
countLabel.label_settings = countLabel.label_settings.duplicate()
|
||||
if autoFree:
|
||||
animator.play("show")
|
||||
await animator.animation_finished
|
||||
@@ -21,6 +23,10 @@ func _ready():
|
||||
func _physics_process(_delta):
|
||||
avatarTexture.texture = ItemStore.getTexture(type)
|
||||
countLabel.text = str(count)
|
||||
if enough:
|
||||
countLabel.label_settings.font_color = Color.WHITE
|
||||
else:
|
||||
countLabel.label_settings.font_color = Color.RED
|
||||
|
||||
static func generate(itemType: ItemStore.ItemType, itemCount: int = 1, isAutoFree: bool = false):
|
||||
var item = ComponentManager.getUIComponent("ItemShow").instantiate()
|
||||
|
||||
@@ -29,20 +29,18 @@ func _ready():
|
||||
rebuildInfo()
|
||||
|
||||
func allHad(entity: EntityBase) -> bool:
|
||||
var allHave = true
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i] * multipiler()
|
||||
var count = countOf(i)
|
||||
if entity.inventory[item] < count:
|
||||
allHave = false
|
||||
break
|
||||
return allHave
|
||||
return false
|
||||
return true
|
||||
func apply(entity: EntityBase):
|
||||
var allHave = allHad(entity)
|
||||
if allHave:
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i] * multipiler()
|
||||
var count = countOf(i)
|
||||
entity.inventory[item] -= count
|
||||
for i in range(min(fields.size(), fieldValues.size())):
|
||||
var field = fields[i]
|
||||
@@ -66,6 +64,8 @@ func apply(entity: EntityBase):
|
||||
hide()
|
||||
selected.emit(allHave)
|
||||
return allHave
|
||||
func countOf(index: int) -> int:
|
||||
return ceil(costCounts[index] * multipiler())
|
||||
func multipiler() -> float:
|
||||
if is_instance_valid(UIState.player):
|
||||
return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION)
|
||||
@@ -106,6 +106,7 @@ func rebuildInfo():
|
||||
var cost = costs[i]
|
||||
var count = costCounts[i]
|
||||
var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate()
|
||||
costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= countOf(i)
|
||||
costShow.type = cost
|
||||
costShow.count = int(count * multipiler())
|
||||
costsBox.add_child(costShow)
|
||||
|
||||
Reference in New Issue
Block a user