feat: HUD 灵气浓度显示 + 字体大小配置化([ui] 节)
This commit is contained in:
@@ -24,3 +24,6 @@ base_speed=10 ; 基础修为/日
|
||||
qi_concentration=1.0 ; 宗门灵气浓度
|
||||
aptitude_speed=[0.6, 1.0, 1.5, 2.0] ; 资质倍率(下品/中品/上品/天骄)
|
||||
heavenly_bonus=1.5 ; 天灵根额外修炼速度倍率
|
||||
|
||||
[ui] ; UI 通用
|
||||
hud_font_size=28 ; HUD 字体大小
|
||||
|
||||
@@ -32,6 +32,10 @@ var aptitude_speed: Array[float] = [0.6, 1.0, 1.5, 2.0]
|
||||
## 天灵根额外修炼速度倍率。
|
||||
var heavenly_bonus := 1.5
|
||||
|
||||
# —— UI 通用(对应 cfg 的 [ui] 节)——
|
||||
## HUD 字体大小。
|
||||
var hud_font_size := 32
|
||||
|
||||
## 各难度资质权重表(键 = 难度档位,值 = 下品/中品/上品/天骄 权重)。
|
||||
var aptitude_weights_by_difficulty: Dictionary = {
|
||||
"normal": [45, 35, 15, 5],
|
||||
@@ -65,6 +69,8 @@ func _load_config() -> void:
|
||||
cultivation_base_speed = cfg.get_value("cultivation", "base_speed", cultivation_base_speed)
|
||||
qi_concentration = cfg.get_value("cultivation", "qi_concentration", qi_concentration)
|
||||
heavenly_bonus = cfg.get_value("cultivation", "heavenly_bonus", heavenly_bonus)
|
||||
# UI 通用
|
||||
hud_font_size = cfg.get_value("ui", "hud_font_size", hud_font_size)
|
||||
var apt_raw: Variant = cfg.get_value("cultivation", "aptitude_speed", [])
|
||||
if apt_raw is Array and apt_raw.size() == aptitude_speed.size():
|
||||
var arr: Array[float] = []
|
||||
|
||||
@@ -68,6 +68,21 @@ size_flags_vertical = 8
|
||||
size_flags_stretch_ratio = 2.0
|
||||
label_settings = SubResource("LabelSettings_bn2o5")
|
||||
|
||||
[node name="Label_Qi" type="Label" parent="HBoxContainer" unique_id=790000001]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 8
|
||||
text = "灵气"
|
||||
label_settings = SubResource("LabelSettings_bn2o5")
|
||||
|
||||
[node name="Value_Qi" type="Label" parent="HBoxContainer" unique_id=790000002]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 8
|
||||
size_flags_stretch_ratio = 2.0
|
||||
label_settings = SubResource("LabelSettings_bn2o5")
|
||||
|
||||
[node name="SpeedGroup" type="HBoxContainer" parent="HBoxContainer" unique_id=2144893126]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
@@ -10,6 +10,7 @@ signal sign_open_disciples
|
||||
@onready var time_label: Label = %Value_Time
|
||||
@onready var currency_label: Label = %Value_Currency
|
||||
@onready var reputation_label: Label = %Value_Reputation
|
||||
@onready var qi_label: Label = %Value_Qi
|
||||
@onready var pause_button: Button = %Button_Pause
|
||||
@onready var speed_buttons: Array[Button] = [%Button_Speed1, %Button_Speed5, %Button_Speed20]
|
||||
|
||||
@@ -25,7 +26,10 @@ func _ready() -> void:
|
||||
SectManager.reputation_changed.connect(_on_reputation_changed)
|
||||
currency_label.text = str(SectManager.spirit_stones)
|
||||
reputation_label.text = str(SectManager.reputation)
|
||||
# 灵气浓度:当前为配置固定值(D6 建筑系统接入后动态刷新)
|
||||
qi_label.text = "%d%%" % roundi(GameConfig.qi_concentration * 100)
|
||||
time_label.text = TimeSystem.get_date_text()
|
||||
_apply_hud_font()
|
||||
_update_speed_ui()
|
||||
|
||||
## 每日推进时刷新日期显示。
|
||||
@@ -61,6 +65,16 @@ func _on_speed_button_up(index: int) -> void:
|
||||
TimeSystem.set_speed_index(index)
|
||||
_update_speed_ui()
|
||||
|
||||
## 应用配置中的 HUD 字体大小(GameConfig.hud_font_size)。
|
||||
## 标签共用同一 LabelSettings 资源,改一处全生效;按钮逐个覆盖。
|
||||
func _apply_hud_font() -> void:
|
||||
var size := GameConfig.hud_font_size
|
||||
var settings: LabelSettings = $HBoxContainer/Label_Currency.label_settings
|
||||
if settings != null:
|
||||
settings.font_size = size
|
||||
for btn in $HBoxContainer.find_children("*", "Button", true, false):
|
||||
btn.add_theme_font_size_override("font_size", size)
|
||||
|
||||
## 刷新速度组 UI:暂停按钮文字与各档位按下状态。
|
||||
## 选中档位用 toggle 的 pressed 状态表达(原生高亮),暂停时禁用档位按钮。
|
||||
func _update_speed_ui() -> void:
|
||||
|
||||
Reference in New Issue
Block a user