mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
Add HarmonyOS Sans font and implement QuickUI for text handling
- Imported HarmonyOS Sans Regular font with appropriate settings for rendering and fallback. - Created QuickUI script to facilitate the creation of small text labels with optional centering. - Added new theme resources for big bold text and small text, defining font sizes for RichTextLabel and Label respectively.
This commit is contained in:
@@ -56,7 +56,7 @@ static func generate(
|
||||
var instance: BulletBase = bullet.instantiate()
|
||||
instance.launcher = launchBy
|
||||
instance.position = spawnPosition
|
||||
instance.rotation = spawnRotation + randf_range(-launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT), launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT))
|
||||
instance.rotation = spawnRotation + deg_to_rad(randf_range(-launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT), launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT)))
|
||||
if addToWorld:
|
||||
WorldManager.rootNode.add_child(instance)
|
||||
return instance
|
||||
|
||||
@@ -16,6 +16,10 @@ var fields = {
|
||||
@export var isBoss: bool = false
|
||||
@export var displayName: String = "未知实体"
|
||||
@export var sprintMultiplier: float = 7
|
||||
@export var inventory = {
|
||||
ItemStore.ItemType.BASEBALL: 0,
|
||||
ItemStore.ItemType.BASKETBALL: 0
|
||||
}
|
||||
|
||||
@onready var animatree: AnimationTree = $"%animatree"
|
||||
@onready var texture: AnimatedSprite2D = $"%texture"
|
||||
|
||||
+25
-4
@@ -2,7 +2,7 @@
|
||||
extends PanelContainer
|
||||
class_name Feed
|
||||
|
||||
@export var avatarTexture: Texture2D = null
|
||||
@export var avatarTexture: Texture2D = preload("res://icon.svg")
|
||||
@export var displayName: String = "未命名饲料"
|
||||
@export var fields: Array[FieldStore.Entity] = []
|
||||
@export var fieldValues: Array[float] = []
|
||||
@@ -10,22 +10,26 @@ class_name Feed
|
||||
@export var costCounts: Array[int] = []
|
||||
|
||||
@onready var avatarRect: TextureRect = $"%avatar"
|
||||
@onready var nameLabel: Label = $"%name"
|
||||
@onready var nameLabel: RichTextLabel = $"%name"
|
||||
@onready var fieldsBox: VBoxContainer = $"%fields"
|
||||
@onready var costsBox: GridContainer = $"%costs"
|
||||
|
||||
func _ready():
|
||||
func _process(_delta):
|
||||
avatarRect.texture = avatarTexture
|
||||
nameLabel.text = displayName
|
||||
nameLabel.text = "[b]" + displayName + "[/b]"
|
||||
for i in fieldsBox.get_children():
|
||||
i.queue_free()
|
||||
var noField = true
|
||||
for i in range(min(fields.size(), fieldValues.size())):
|
||||
noField = false
|
||||
var field = fields[i]
|
||||
var value = fieldValues[i]
|
||||
var fieldShow: FieldShow = preload("res://components/UI/FieldShow.tscn").instantiate()
|
||||
fieldShow.field = field
|
||||
fieldShow.value = value
|
||||
fieldsBox.add_child(fieldShow)
|
||||
if noField:
|
||||
fieldsBox.add_child(QuickUI.smallText("无词条"))
|
||||
for i in costsBox.get_children():
|
||||
i.queue_free()
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
@@ -35,3 +39,20 @@ func _ready():
|
||||
costShow.type = cost
|
||||
costShow.count = count
|
||||
costsBox.add_child(costShow)
|
||||
func apply(entity: EntityBase):
|
||||
var allHave = true
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i]
|
||||
if entity.inventory[item] < count:
|
||||
allHave = false
|
||||
break
|
||||
if allHave:
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i]
|
||||
entity.inventory[item] -= count
|
||||
for i in range(min(fields.size(), fieldValues.size())):
|
||||
var field = fields[i]
|
||||
var value = fieldValues[i]
|
||||
entity.fields[field] += value
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class_name QuickUI
|
||||
|
||||
static func smallText(text: String, center: bool = true):
|
||||
var label = Label.new()
|
||||
label.text = text
|
||||
label.theme = preload("res://themes/smallText.tres")
|
||||
if center:
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
return label
|
||||
Reference in New Issue
Block a user