Compare commits

...
11 Commits
Author SHA1 Message Date
Admin dded4e0c8f Merge branch 'dev_UI' into dev 2026-09-10 00:28:58 +08:00
Admin ae605c5e48 DiscipleManager 与 TimeSystem 随 MainGame 场景挂载,打通弟子增删信号到 UI
生命周期重构:
- TimeSystem 退出 Autoload,改挂 MainGame.tscn 子节点,补 class_name;
  HUD 对时间系统的引用由全局名改为 %TimeSystem(unique_name_in_owner)
- DiscipleManager 挂 MainGame.tscn(原无效 Autoload 注册已删),
  进游戏随场景创建、返回主菜单随树销毁,杜绝弟子数据跨轮回残留

信号闭环:
- 场景连接 disciple_added / disciple_removed 到 MainGame 回调,
  回调转调 Manager.add_disciple_card / remove_disciple_card(卡按 id 同步增删)
- MainGame._ready 按 NEW_GAME 触发 spawn_initial_roster(),
  父节点 _ready 时序最晚,保证卡片连接先于首批信号就绪
- 恢复误删的 sign_return_mainmenu 场景连接(返回主菜单建组存档链路)

注意:MainGame._process 内含临时删除测试(1000 帧后删 id=2 弟子),
演示移除链路用,后续版本应移除
2026-09-10 00:27:54 +08:00
Admin c1fb348f07 管理面板弟子卡支持 id 存取与按 id 删除
- DiscipleInformation 新增 disciple_id 字段,set_info 时写入对应 Disciple 的 id
- Manager 废弃 test_disciple_table 手动建卡,新增 add_disciple_card:
  Disciple 对象 → 信息字典(含 id/name/realm_name/五行)→ 实例化卡片
- 新增 remove_disciple_card(id):遍历 HFlowContainer 按 disciple_id
  匹配摘除并销毁(供 disciple_removed 信号驱动)
2026-09-10 00:27:44 +08:00
Admin 050c8116ad 修复初始编队生成:对入参建可写副本再补发 id
- Disciple.create 强制要求 data 含 id,且 INITIAL_ROSTER 为 const 常量:
  原实现先 create 后补 id 导致 5 人全部创建失败
- 改为 duplicate() 副本上写入 _master_id 发号,避免污染常量
- INITIAL_ROSTER 补手写 id 占位字段(实际以发号器为准)
2026-09-10 00:27:40 +08:00
Admin f38bcfd210 修复 Disciple 模型:放宽 _init 字典形参、显式化小境界上限类型推断
- _init 形参由 Dictionary[String, Variant] 放宽为 Dictionary:
  duplicate() 产物为普通字典,运行时类型校验导致 create() 失败
- SUB_MAX_BY_REALM 索引两处改用显式 int 声明,消除 Cannot infer 错误
- doc/弟子管理.md 补充修炼经验说明
2026-09-10 00:27:36 +08:00
Admin 2dbbe48f96 Merge branch 'dev' into dev_UI 2026-09-09 21:50:26 +08:00
Admin 0f0dc74e1e Merge branch 'dev' of ssh://git.devquest.cn:2222/chentianya/ImmortalSect into dev 2026-09-09 21:50:19 +08:00
Admin df82e61cf9 Merge branch 'dev' into dev_UI 2026-09-09 21:13:30 +08:00
Admin 8a793fa198 Merge branch 'dev_UI' into dev 2026-09-09 21:13:24 +08:00
Admin 4d1e4d8248 管理界面改为动态创建页签并注册各页面板 2026-09-09 21:08:50 +08:00
Admin 257aeccd2a 新增弟子/建筑/订单/炼丹/库房信息卡脚本与填充接口 2026-09-09 21:08:47 +08:00
29 changed files with 409 additions and 149 deletions
+6
View File
@@ -116,3 +116,9 @@ func load_from_dict(d) -> void
graph TD graph TD
A[分配属性总量,按正正态分布] --> B[随机分配5种属性,属性之和为1] --> C[分配灵气利用率] A[分配属性总量,按正正态分布] --> B[随机分配5种属性,属性之和为1] --> C[分配灵气利用率]
``` ```
## 修炼说明
每个小境界修炼需要的经验 = 基础经验值 * 属性总量
经验获取量 = 基础经验 * 灵气吸收效率
-1
View File
@@ -18,7 +18,6 @@ config/icon="res://icon.svg"
[autoload] [autoload]
GameState="*res://src/Core/GameState.gd" GameState="*res://src/Core/GameState.gd"
TimeSystem="*res://src/Core/TimeSystem.gd"
Settings="*res://src/Core/Settings.gd" Settings="*res://src/Core/Settings.gd"
SaveSystem="*res://src/Core/SaveSystem.gd" SaveSystem="*res://src/Core/SaveSystem.gd"
+13 -12
View File
@@ -1,6 +1,4 @@
# 初始版本不提供添加弟子的接口 # 初始版本不提供添加弟子的接口
class_name DiscipleManager class_name DiscipleManager
extends Node extends Node
@@ -14,6 +12,7 @@ const INITIAL_ROSTER := [
# 1 玄真(宗主):修士·炼气9层,五行全高,炼丹3级 # 1 玄真(宗主):修士·炼气9层,五行全高,炼丹3级
{ {
"name": "玄真", "name": "玄真",
"id" : 1,
"metal": 45, "wood": 38, "water": 22, "fire": 31, "earth": 19, "metal": 45, "wood": 38, "water": 22, "fire": 31, "earth": 19,
"efficiency": 85, "efficiency": 85,
"realm_level": 1, "sub_realm_level": 9, "realm_level": 1, "sub_realm_level": 9,
@@ -23,6 +22,7 @@ const INITIAL_ROSTER := [
# 2 凌霄:修士·炼气4层,金火旺 # 2 凌霄:修士·炼气4层,金火旺
{ {
"name": "凌霄", "name": "凌霄",
"id" : 2,
"metal": 62, "wood": 12, "water": 15, "fire": 44, "earth": 20, "metal": 62, "wood": 12, "water": 15, "fire": 44, "earth": 20,
"efficiency": 76, "efficiency": 76,
"realm_level": 1, "sub_realm_level": 4, "realm_level": 1, "sub_realm_level": 4,
@@ -32,6 +32,7 @@ const INITIAL_ROSTER := [
# 3 青禾:凡人带灵根(木47≥20 可修炼破境),药草天赋 # 3 青禾:凡人带灵根(木47≥20 可修炼破境),药草天赋
{ {
"name": "青禾", "name": "青禾",
"id" : 3,
"metal": 8, "wood": 47, "water": 25, "fire": 12, "earth": 10, "metal": 8, "wood": 47, "water": 25, "fire": 12, "earth": 10,
"efficiency": 68, "efficiency": 68,
"realm_level": 0, "sub_realm_level": 1, "realm_level": 0, "sub_realm_level": 1,
@@ -41,6 +42,7 @@ const INITIAL_ROSTER := [
# 4 阿福:凡人杂役(无灵根,五行均<20) # 4 阿福:凡人杂役(无灵根,五行均<20)
{ {
"name": "阿福", "name": "阿福",
"id" : 4,
"metal": 5, "wood": 12, "water": 8, "fire": 9, "earth": 10, "metal": 5, "wood": 12, "water": 8, "fire": 9, "earth": 10,
"efficiency": 41, "efficiency": 41,
"realm_level": 0, "sub_realm_level": 1, "realm_level": 0, "sub_realm_level": 1,
@@ -50,6 +52,7 @@ const INITIAL_ROSTER := [
# 5 阿禄:凡人杂役(无灵根) # 5 阿禄:凡人杂役(无灵根)
{ {
"name": "阿禄", "name": "阿禄",
"id" : 5,
"metal": 3, "wood": 6, "water": 5, "fire": 8, "earth": 15, "metal": 3, "wood": 6, "water": 5, "fire": 8, "earth": 15,
"efficiency": 35, "efficiency": 35,
"realm_level": 0, "sub_realm_level": 1, "realm_level": 0, "sub_realm_level": 1,
@@ -61,16 +64,16 @@ const INITIAL_ROSTER := [
var _disciples: Array[Disciple] = [] # 弟子列表 var _disciples: Array[Disciple] = [] # 弟子列表
var _master_id: int = 0 # 管理器的发号计数,id 的唯一来源 var _master_id: int = 0 # 管理器的发号计数,id 的唯一来源
# ---- 工厂 ---- func _enter_tree() -> void:
pass
# ---- 工厂 ----
# 初始编队(复用 _create_from_data # 初始编队(复用 _create_from_data
func spawn_initial_roster() -> Array[Disciple]: func spawn_initial_roster() -> void:
for data in INITIAL_ROSTER: for data in INITIAL_ROSTER:
var disciple = _create_from_data(data) var disciple = _create_from_data(data)
if disciple != null: if disciple != null:
add_disciple(disciple) add_disciple(disciple)
# _disciples.append(disciple)
# emit_signal("disciple_added", disciple)
else: else:
push_error("Failed to spawn disciple from data: %s" % data) push_error("Failed to spawn disciple from data: %s" % data)
pass pass
@@ -78,14 +81,14 @@ func spawn_initial_roster() -> Array[Disciple]:
# 补 id → Disciple.create() # 补 id → Disciple.create()
# 从数据字典创建 Disciple 实例,若失败返回 null # 从数据字典创建 Disciple 实例,若失败返回 null
func _create_from_data(data: Dictionary) -> Disciple: func _create_from_data(data: Dictionary) -> Disciple:
var disciple := Disciple.create(data) var copy := data.duplicate() # 可写副本(浅拷贝,顶层加键足够)
copy["id"] = _master_id
_master_id += 1
var disciple := Disciple.create(copy)
if disciple == null: if disciple == null:
push_error("Failed to create disciple from data: %s" % data) push_error("Failed to create disciple from data: %s" % data)
return null return null
disciple.id = _master_id
_master_id += 1
return disciple return disciple
pass
# ---- 仓储 ---- # ---- 仓储 ----
@@ -159,5 +162,3 @@ func to_dict():
func load_from_dict(): func load_from_dict():
pass pass
+1
View File
@@ -0,0 +1 @@
uid://bstiea1nx61b8
+22
View File
@@ -1,5 +1,17 @@
extends Node extends Node
var cnt := 0;
func _ready() -> void:
%DiscipleManager.spawn_initial_roster()
pass
func _process(delta: float) -> void:
if cnt >= 1000:
var d : Disciple= %DiscipleManager.get_disciple(2);
%DiscipleManager.remove_disciple(d);
else:
cnt = cnt + 1;
pass
func _on_top_bar_hud_sign_return_mainmenu() -> void: func _on_top_bar_hud_sign_return_mainmenu() -> void:
if GameState.mode == GameState.GameMode.NEW_GAME: if GameState.mode == GameState.GameMode.NEW_GAME:
@@ -8,3 +20,13 @@ func _on_top_bar_hud_sign_return_mainmenu() -> void:
SaveSystem.save(GameState.profile_id) # 进游戏立即存首档,防开局就丢 SaveSystem.save(GameState.profile_id) # 进游戏立即存首档,防开局就丢
get_tree().change_scene_to_file("res://src/UI/Panels/MainMenu/MainMenu.tscn") get_tree().change_scene_to_file("res://src/UI/Panels/MainMenu/MainMenu.tscn")
pass # Replace with function body. pass # Replace with function body.
func _on_disciple_manager_disciple_added(disciple: Disciple) -> void:
$PanelContainer/Manager.add_disciple_card(disciple)
pass # Replace with function body.
func _on_disciple_manager_disciple_removed(disciple: Disciple) -> void:
$PanelContainer/Manager.remove_disciple_card(disciple.id)
pass # Replace with function body.
+16 -2
View File
@@ -1,12 +1,14 @@
[gd_scene format=3 uid="uid://c1exffg84ojqx"] [gd_scene format=3 uid="uid://c1exffg84ojqx"]
[ext_resource type="Script" uid="uid://cr4by5k8vgkcq" path="res://src/Core/MainGame.gd" id="1_8bu23"] [ext_resource type="Script" uid="uid://cr4by5k8vgkcq" path="res://src/Core/MainGame.gd" id="1_2atgf"]
[ext_resource type="Script" uid="uid://bstiea1nx61b8" path="res://src/Character/DiscipleManager.gd" id="1_dl5bp"]
[ext_resource type="PackedScene" uid="uid://d3njijtx7ws1m" path="res://src/UI/HUD/MainSceneHud.tscn" id="2_8bu23"] [ext_resource type="PackedScene" uid="uid://d3njijtx7ws1m" path="res://src/UI/HUD/MainSceneHud.tscn" id="2_8bu23"]
[ext_resource type="StyleBox" uid="uid://e86yw57h4v2s" path="res://resources/manager_style_box_flat.tres" id="3_dl5bp"] [ext_resource type="StyleBox" uid="uid://e86yw57h4v2s" path="res://resources/manager_style_box_flat.tres" id="3_dl5bp"]
[ext_resource type="PackedScene" uid="uid://d1mbwdtarjqof" path="res://src/UI/Panels/Manager/Manager.tscn" id="4_58g0x"] [ext_resource type="PackedScene" uid="uid://d1mbwdtarjqof" path="res://src/UI/Panels/Manager/Manager.tscn" id="4_58g0x"]
[ext_resource type="Script" uid="uid://b8f8t2phmhq2e" path="res://src/Core/TimeSystem.gd" id="5_58g0x"]
[node name="MainGame" type="Node" unique_id=42551660] [node name="MainGame" type="Node" unique_id=42551660]
script = ExtResource("1_8bu23") script = ExtResource("1_2atgf")
[node name="MainHud" parent="." unique_id=836125968 instance=ExtResource("2_8bu23")] [node name="MainHud" parent="." unique_id=836125968 instance=ExtResource("2_8bu23")]
size_flags_horizontal = 3 size_flags_horizontal = 3
@@ -23,4 +25,16 @@ theme_override_styles/panel = ExtResource("3_dl5bp")
[node name="Manager" parent="PanelContainer" unique_id=360636457 instance=ExtResource("4_58g0x")] [node name="Manager" parent="PanelContainer" unique_id=360636457 instance=ExtResource("4_58g0x")]
layout_mode = 2 layout_mode = 2
[node name="DiscipleManager" type="Node" parent="." unique_id=1485476702]
unique_name_in_owner = true
script = ExtResource("1_dl5bp")
metadata/_custom_type_script = "uid://bstiea1nx61b8"
[node name="TimeSystem" type="Node" parent="." unique_id=1280036358]
unique_name_in_owner = true
script = ExtResource("5_58g0x")
metadata/_custom_type_script = "uid://b8f8t2phmhq2e"
[connection signal="disciple_added" from="DiscipleManager" to="." method="_on_disciple_manager_disciple_added"]
[connection signal="disciple_removed" from="DiscipleManager" to="." method="_on_disciple_manager_disciple_removed"]
[connection signal="sign_return_mainmenu" from="MainHud" to="." method="_on_top_bar_hud_sign_return_mainmenu"] [connection signal="sign_return_mainmenu" from="MainHud" to="." method="_on_top_bar_hud_sign_return_mainmenu"]
+1
View File
@@ -1,6 +1,7 @@
## 全局时间系统(Autoload 单例)。 ## 全局时间系统(Autoload 单例)。
## 负责游戏时间的推进与播报,仅在世界场景中运行。 ## 负责游戏时间的推进与播报,仅在世界场景中运行。
## 历法:12 月 × 30 日 = 360 日/年。 ## 历法:12 月 × 30 日 = 360 日/年。
class_name TimeSystem
extends Node extends Node
const MONTHS_PER_YEAR := 12 const MONTHS_PER_YEAR := 12
+3 -3
View File
@@ -137,7 +137,7 @@ var total_amount: int:
## 构造:按 data 覆盖属性,数值属性经 RANGES 夹取;缺键保留字段默认值。 ## 构造:按 data 覆盖属性,数值属性经 RANGES 夹取;缺键保留字段默认值。
## @param data: 键名与属性名一致,如 {"id": 1, "name": "玄真", "metal": 60} ## @param data: 键名与属性名一致,如 {"id": 1, "name": "玄真", "metal": 60}
func _init(data: Dictionary[String, Variant] = {}) -> void: func _init(data: Dictionary = {}) -> void:
if data.has("id"): if data.has("id"):
id = int(data["id"]) id = int(data["id"])
if data.has("name"): if data.has("name"):
@@ -187,12 +187,12 @@ func set_attr(key: String, value: int) -> bool:
if key == "realm_level": if key == "realm_level":
# 大境界变化后,小境界不得超过新境界的上限(如落入凡人则强制 1) # 大境界变化后,小境界不得超过新境界的上限(如落入凡人则强制 1)
set("realm_level", v) set("realm_level", v)
var max_sub := SUB_MAX_BY_REALM[v] var max_sub : int = SUB_MAX_BY_REALM[v]
if int(get("sub_realm_level")) > max_sub: if int(get("sub_realm_level")) > max_sub:
set("sub_realm_level", max_sub) set("sub_realm_level", max_sub)
elif key == "sub_realm_level": elif key == "sub_realm_level":
# 小境界写入时按当前大境界上限夹取(凡人上限 1 / 练气 13 / 其余 4) # 小境界写入时按当前大境界上限夹取(凡人上限 1 / 练气 13 / 其余 4)
var max_sub := SUB_MAX_BY_REALM[int(get("realm_level"))] var max_sub : int = SUB_MAX_BY_REALM[int(get("realm_level"))]
set("sub_realm_level", clampi(v, 1, max_sub)) set("sub_realm_level", clampi(v, 1, max_sub))
else: else:
set(key, v) set(key, v)
+3 -3
View File
@@ -6,8 +6,8 @@ extends Control
signal sign_return_mainmenu signal sign_return_mainmenu
func _ready() -> void: func _ready() -> void:
time_label.text = TimeSystem.get_date_text() time_label.text = %TimeSystem.get_date_text()
TimeSystem.month_passed.connect(_on_TimeMonthPassed) %TimeSystem.month_passed.connect(_on_TimeMonthPassed)
pass pass
func _on_ButtonEsc_ButtonUp() -> void: func _on_ButtonEsc_ButtonUp() -> void:
@@ -20,5 +20,5 @@ func _on_TimeMonthPassed(_year: int, _month: int) -> void:
func _on_button_continue_button_up() -> void: func _on_button_continue_button_up() -> void:
TimeSystem.advance_month() %TimeSystem.advance_month()
pass # Replace with function body. pass # Replace with function body.
@@ -0,0 +1,10 @@
extends Control
func _ready() -> void:
custom_minimum_size = Vector2(180, 240)
custom_maximum_size = Vector2(180, 240)
pass
func set_alchemy_info(info : Dictionary) -> bool:
$PanelContainer/HBoxContainer/HBoxContainer/Name.text = info['name']
return true;
@@ -0,0 +1 @@
uid://bictkemio85fb
@@ -2,6 +2,7 @@
[ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_62fqa"] [ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_62fqa"]
[ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="1_j02a5"] [ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="1_j02a5"]
[ext_resource type="Script" uid="uid://bictkemio85fb" path="res://src/UI/Panels/Manager/AlchemyPanel/AlchemyPanel.gd" id="1_kuh5g"]
[node name="AlchemyPanel" type="Control" unique_id=729180406] [node name="AlchemyPanel" type="Control" unique_id=729180406]
custom_minimum_size = Vector2(180, 240) custom_minimum_size = Vector2(180, 240)
@@ -12,6 +13,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_kuh5g")
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=1524260599] [node name="PanelContainer" type="PanelContainer" parent="." unique_id=1524260599]
layout_mode = 1 layout_mode = 1
@@ -0,0 +1,21 @@
extends Control
var disciple_id: int;
func _ready() -> void:
custom_maximum_size = Vector2(180, 320);
custom_minimum_size = Vector2(180, 240);
pass;
func set_info(info: Dictionary):
disciple_id = info['id'];
$VBoxContainer/HBoxContainer/Name.text = info['name'];
$VBoxContainer/HBoxContainer2/Level.text = info['level']
$VBoxContainer/HBoxContainer3/GridContainer/MetalVal.text = str(info['metal'])
$VBoxContainer/HBoxContainer3/GridContainer/WoodVal.text = str(info['wood'])
$VBoxContainer/HBoxContainer3/GridContainer/WaterVal.text = str(info['water'])
$VBoxContainer/HBoxContainer3/GridContainer/FireVal.text = str(info['fire'])
$VBoxContainer/HBoxContainer3/GridContainer/EarthVal.text = str(info['earth'])
#print(info)
pass
@@ -0,0 +1 @@
uid://cc7c76lgm5nrf
@@ -2,18 +2,20 @@
[ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="1_abpqa"] [ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="1_abpqa"]
[ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_po3i5"] [ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_po3i5"]
[ext_resource type="Script" uid="uid://cc7c76lgm5nrf" path="res://src/UI/Panels/Manager/DisciplePanel/DiscipleInformation.gd" id="2_6fig8"]
[node name="DiscipleInformationPanel" type="PanelContainer" unique_id=2024414593] [node name="DiscipleInformationPanel" type="PanelContainer" unique_id=2024414593]
custom_minimum_size = Vector2(180, 240) custom_minimum_size = Vector2(180, 240)
custom_maximum_size = Vector2(180, 240) custom_maximum_size = Vector2(180, 320)
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_styles/panel = ExtResource("1_po3i5") theme_override_styles/panel = ExtResource("1_po3i5")
script = ExtResource("2_6fig8")
metadata/discipleId = 0
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1066350214] [node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1066350214]
layout_mode = 2 layout_mode = 2
@@ -25,7 +27,6 @@ size_flags_vertical = 3
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer" unique_id=2078348112] [node name="Label" type="Label" parent="VBoxContainer/HBoxContainer" unique_id=2078348112]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1 size_flags_vertical = 1
text = "姓名" text = "姓名"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
@@ -44,7 +45,6 @@ size_flags_vertical = 3
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2" unique_id=233829191] [node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2" unique_id=233829191]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1 size_flags_vertical = 1
text = "境界" text = "境界"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
@@ -60,100 +60,98 @@ label_settings = ExtResource("1_abpqa")
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer" unique_id=1358402714] [node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer" unique_id=1358402714]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
size_flags_stretch_ratio = 5.0
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3" unique_id=1781987484] [node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3" unique_id=1781987484]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1 size_flags_vertical = 1
text = "属性" text = "属
性"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/HBoxContainer3" unique_id=251442021] [node name="GridContainer" type="GridContainer" parent="VBoxContainer/HBoxContainer3" unique_id=431356438]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
columns = 2
[node name="Metal" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer2" unique_id=395220991] [node name="Metal" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=395220991]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
text = "金" text = "金"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
vertical_alignment = 1 vertical_alignment = 1
[node name="Wood" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer2" unique_id=1852801128] [node name="MetalVal" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=334471189]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Wood" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=1852801128]
layout_mode = 2
size_flags_vertical = 3
text = "木" text = "木"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
vertical_alignment = 1 vertical_alignment = 1
[node name="Water" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer2" unique_id=1864946709] [node name="WoodVal" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=1099683329]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Water" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=1864946709]
layout_mode = 2
size_flags_vertical = 3
text = "水" text = "水"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
vertical_alignment = 1 vertical_alignment = 1
[node name="Fire" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer2" unique_id=1916838020] [node name="WaterVal" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=1520779703]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Fire" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=1916838020]
layout_mode = 2
size_flags_vertical = 3
text = "火" text = "火"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
vertical_alignment = 1 vertical_alignment = 1
[node name="Earth" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer2" unique_id=2106256122] [node name="FireVal" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=66098798]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Earth" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=2106256122]
layout_mode = 2
size_flags_vertical = 3
text = "土" text = "土"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
vertical_alignment = 1 vertical_alignment = 1
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer3" unique_id=565242402] [node name="EarthVal" type="Label" parent="VBoxContainer/HBoxContainer3/GridContainer" unique_id=170833691]
layout_mode = 2
size_flags_horizontal = 3
[node name="Metal" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer" unique_id=334471189]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
vertical_alignment = 1
[node name="Wood" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer" unique_id=1099683329]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
vertical_alignment = 1
[node name="Water" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer" unique_id=1520779703]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
vertical_alignment = 1
[node name="Fire" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer" unique_id=66098798]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
text = "1"
label_settings = ExtResource("1_abpqa")
vertical_alignment = 1
[node name="Earth" type="Label" parent="VBoxContainer/HBoxContainer3/VBoxContainer" unique_id=170833691]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
text = "1" text = "1"
label_settings = ExtResource("1_abpqa") label_settings = ExtResource("1_abpqa")
horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
@@ -0,0 +1,10 @@
extends Control
func _ready() -> void:
custom_minimum_size = Vector2(180, 320)
custom_minimum_size = Vector2(180, 240)
pass
func set_field_info(info: Dictionary) -> bool:
$PanelContainer/VBoxContainer/Name.text = info['name']
return true;
@@ -0,0 +1 @@
uid://lw0x0n7r063b
@@ -1,5 +1,6 @@
[gd_scene format=3 uid="uid://bk5w5of88aysu"] [gd_scene format=3 uid="uid://bk5w5of88aysu"]
[ext_resource type="Script" uid="uid://lw0x0n7r063b" path="res://src/UI/Panels/Manager/FieldPanel/FieldInformation.gd" id="1_p6bv6"]
[ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_rap8l"] [ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_rap8l"]
[ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="2_p6bv6"] [ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="2_p6bv6"]
@@ -12,6 +13,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_p6bv6")
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=900478219] [node name="PanelContainer" type="PanelContainer" parent="." unique_id=900478219]
layout_mode = 1 layout_mode = 1
@@ -27,14 +29,12 @@ layout_mode = 2
[node name="Name" type="Label" parent="PanelContainer/VBoxContainer" unique_id=909840161] [node name="Name" type="Label" parent="PanelContainer/VBoxContainer" unique_id=909840161]
layout_mode = 2 layout_mode = 2
text = "AAA"
label_settings = ExtResource("2_p6bv6") label_settings = ExtResource("2_p6bv6")
horizontal_alignment = 1 horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
[node name="Info" type="Label" parent="PanelContainer/VBoxContainer" unique_id=1950109494] [node name="Info" type="Label" parent="PanelContainer/VBoxContainer" unique_id=1950109494]
layout_mode = 2 layout_mode = 2
text = "BBB"
label_settings = ExtResource("2_p6bv6") label_settings = ExtResource("2_p6bv6")
[node name="GridContainer" type="GridContainer" parent="PanelContainer/VBoxContainer" unique_id=1107543260] [node name="GridContainer" type="GridContainer" parent="PanelContainer/VBoxContainer" unique_id=1107543260]
@@ -0,0 +1,39 @@
extends Control
## 测试数据:模拟 sect_data 里的嵌套资源(分类 → 子项)
var test_resources := [
{"name": "粮草", "items": [{"name": "", "quantity": 10}, {"name": "蔬菜", "quantity": 20}]},
{"name": "丹药", "items": [{"name": "聚气丹", "quantity": 5}]},
]
func _ready() -> void:
var tree: Tree = $ScrollContainer/Tree
tree.hide_root = true # 隐藏内部根,顶部就是"粮草/丹药"
tree.columns = 2
tree.item_selected.connect(_on_item_selected)
_refresh(tree)
pass
## 每次数据变化后全量重建(简单可靠)
func _refresh(tree: Tree) -> void:
tree.clear()
for category: Dictionary in test_resources:
var cat_item := tree.create_item() # 无父 = 顶级项(挂在隐藏根下)
cat_item.set_text(0, category["name"])
cat_item.set_metadata(0, {"type": "category"})
for sub: Dictionary in category["items"]:
var item := tree.create_item(cat_item) # 子项
item.set_text(0, sub["name"])
item.set_text(1, str(sub["quantity"]))
item.set_metadata(0, sub) # 存整条数据便于取用
## 动态新增一项后刷新
func _on_add_button() -> void: # 测试:手动调一次
test_resources[0]["items"].append({"name": "灵米", "quantity": 99})
_refresh($ScrollContainer/Tree)
func _on_item_selected() -> void:
var tree: Tree = $ScrollContainer/Tree
var selected := tree.get_selected()
if selected != null:
print(selected.get_text(0), "", selected.get_metadata(0))
@@ -0,0 +1 @@
uid://b55qsl2gyvt3e
@@ -1,5 +1,7 @@
[gd_scene format=3 uid="uid://dxij6vexu5m1q"] [gd_scene format=3 uid="uid://dxij6vexu5m1q"]
[ext_resource type="Script" uid="uid://b55qsl2gyvt3e" path="res://src/UI/Panels/Manager/InventoryPanel/InventoryPanel.gd" id="1_th4yu"]
[node name="InventoryPanel" type="Control" unique_id=735363118] [node name="InventoryPanel" type="Control" unique_id=735363118]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@@ -7,6 +9,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_th4yu")
[node name="ScrollContainer" type="ScrollContainer" parent="." unique_id=887058553] [node name="ScrollContainer" type="ScrollContainer" parent="." unique_id=887058553]
layout_mode = 1 layout_mode = 1
+131
View File
@@ -1,6 +1,137 @@
extends Control extends Control
var test_field_table : Array[Dictionary] = [] # 建筑
var test_order_table : Array[Dictionary] = [] # 订单
var test_alchemy_table : Array[Dictionary] = [] # 炼丹配方
var test_inventory : Array[Dictionary] = [] # 库存
var test_sub_inventory1 : Array[Dictionary] = [] # 库存
var test_sub_inventory2 : Array[Dictionary] = [] # 库存
var test_sub_inventory3 : Array[Dictionary] = [] # 库存
var sect_resources : Dictionary;
var disciple_info_scene := preload("res://src/UI/Panels/Manager/DisciplePanel/DiscipleInformationPanel.tscn")
var field_info_scene := preload("res://src/UI/Panels/Manager/FieldPanel/FieldInformationPanel.tscn")
var order_info_scene := preload("res://src/UI/Panels/Manager/OrderPanel/OrderInformationPanel.tscn")
var alchemy_info_scene := preload("res://src/UI/Panels/Manager/AlchemyPanel/AlchemyPanel.tscn")
func _ready() -> void: func _ready() -> void:
init_test_data();
var manager_panel_scene := load("res://src/UI/Panels/Manager/ManagerPanel.tscn") as PackedScene
var inventory_panel_scene := load("res://src/UI/Panels/Manager/InventoryPanel/InventoryPanel.tscn") as PackedScene
sect_resources["弟子"] = manager_panel_scene.instantiate();
sect_resources["弟子"].name = "弟子";
$TabContainer.add_child(sect_resources["弟子"]);
sect_resources["建筑"] = manager_panel_scene.instantiate();
sect_resources["建筑"].name = "建筑";
$TabContainer.add_child(sect_resources["建筑"]);
sect_resources["订单"] = manager_panel_scene.instantiate();
sect_resources["订单"].name = "订单";
$TabContainer.add_child(sect_resources["订单"]);
sect_resources["炼丹"] = manager_panel_scene.instantiate();
sect_resources["炼丹"].name = "炼丹";
$TabContainer.add_child(sect_resources["炼丹"]);
sect_resources["库房"] = inventory_panel_scene.instantiate();
sect_resources["库房"].name = "库房";
$TabContainer.add_child(sect_resources["库房"]);
for e in test_field_table:
var d := field_info_scene.instantiate()
d.set_field_info(e)
sect_resources["建筑"].add_info_card(d)
pass pass
for e in test_order_table:
var d := order_info_scene.instantiate()
d.set_order_info(e)
sect_resources['订单'].add_info_card(d)
pass
for e in test_alchemy_table:
var d := alchemy_info_scene.instantiate()
d.set_alchemy_info(e)
sect_resources['炼丹'].add_info_card(d)
pass
pass
func init_test_data() -> void:
test_field_table.append_array([
{"name": "灵田", "弟子": 0},
{"name": "灵田", "弟子": 1},
{"name": "灵药园", "弟子": 2},
{"name": "灵药园", "弟子": 3},
{"name": "灵药园", "弟子": 4},
{"name": "炼丹房", "弟子": 0}
])
test_order_table.append_array([
{"title": "炼制灵丹", "type": "炼丹", "level": 1, "reward": 100, "time": 10, "status": 0},
{"title": "炼制灵丹", "type": "炼丹", "level": 2, "reward": 200, "time": 20, "status": 0},
{"title": "炼制灵丹", "type": "炼丹", "level": 3, "reward": 300, "time": 30, "status": 0},
{"title": "炼制灵丹", "type": "炼丹", "level": 4, "reward": 400, "time": 40, "status": 0},
{"title": "炼制灵丹", "type": "炼丹", "level": 5, "reward": 500, "time": 50, "status": 0}
])
test_alchemy_table.append_array([
{"name": "灵丹", "herb_1": 0, "herb_2": 0, "herb_3": 0, "herb_4": 0, "herb_5": 0, "herb_6": 0, "herb_7": 0, "herb_8": 0, "herb_9": 0},
{"name": "灵丹", "herb_1": 0, "herb_2": 0, "herb_3": 0, "herb_4": 0, "herb_5": 0, "herb_6": 0, "herb_7": 0, "herb_8": 0, "herb_9": 0},
{"name": "灵丹", "herb_1": 0, "herb_2": 0, "herb_3": 0, "herb_4": 0, "herb_5": 0, "herb_6": 0, "herb_7": 0, "herb_8": 0, "herb_9": 0},
{"name": "灵丹", "herb_1": 0, "herb_2": 0, "herb_3": 0, "herb_4": 0, "herb_5": 0, "herb_6": 0, "herb_7": 0, "herb_8": 0, "herb_9": 0},
{"name": "灵丹", "herb_1": 0, "herb_2": 0, "herb_3": 0, "herb_4": 0, "herb_5": 0, "herb_6": 0, "herb_7": 0, "herb_8": 0, "herb_9": 0}
])
test_sub_inventory1.append_array([
{"name": "A", "type": "草药", "quantity": 10},
{"name": "B", "type": "草药", "quantity": 20},
{"name": "C", "type": "草药", "quantity": 30},
{"name": "D", "type": "草药", "quantity": 40},
{"name": "E", "type": "草药", "quantity": 50}
])
test_sub_inventory2.append_array([
{"name": "", "type": "粮食", "quantity": 10},
{"name": "蔬菜", "type": "粮食", "quantity": 20},
])
test_sub_inventory3.append_array([
{"name": "聚气丹", "type": "丹药", "quantity": 10},
{"name": "筑基丹", "type": "丹药", "quantity": 20},
])
test_inventory.append_array([{"草药": test_sub_inventory1}, {"粮食": test_sub_inventory2}, {"丹药": test_sub_inventory3}]);
pass
func add_disciple_card(d : Disciple) -> void:
var ds := disciple_info_scene.instantiate()
var info := {
"id": d.id,
"name": d.name,
"gender" : "x",
"level" : d.realm_name(),
"metal" : int(d.get_attr("metal")),
"wood" : int(d.get_attr("wood")),
"water" : int(d.get_attr("water")),
"fire" : int(d.get_attr("fire")),
"earth" : int(d.get_attr("earth"))
}
ds.set_info(info)
sect_resources["弟子"].add_info_card(ds)
pass
func remove_disciple_card(id: int) -> void:
var panel: Control = sect_resources["弟子"] # ManagerPanel 页
var flow: Node = panel.get_node("ScrollContainer/HFlowContainer")
for child in flow.get_children():
if child.disciple_id == id: # 指定项匹配
flow.remove_child(child) # 1. 先从树摘除
child.queue_free() # 2. 再排队销毁
return # 匹配唯一,删完即走
+1 -27
View File
@@ -1,8 +1,6 @@
[gd_scene format=3 uid="uid://d1mbwdtarjqof"] [gd_scene format=3 uid="uid://d1mbwdtarjqof"]
[ext_resource type="Script" uid="uid://qjqb0jaqxuu2" path="res://src/UI/Panels/Manager/Manager.gd" id="1_qdh6a"] [ext_resource type="Script" uid="uid://qjqb0jaqxuu2" path="res://src/UI/Panels/Manager/Manager.gd" id="1_qdh6a"]
[ext_resource type="PackedScene" uid="uid://cbqydw1lerumr" path="res://src/UI/Panels/Manager/ManagerPanel.tscn" id="2_ieenf"]
[ext_resource type="PackedScene" uid="uid://dxij6vexu5m1q" path="res://src/UI/Panels/Manager/InventoryPanel/InventoryPanel.tscn" id="3_k3wlu"]
[node name="Manager" type="Control" unique_id=360636457] [node name="Manager" type="Control" unique_id=360636457]
layout_mode = 3 layout_mode = 3
@@ -22,28 +20,4 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
current_tab = 4 tab_focus_mode = 1
[node name="ManagerPanel" parent="TabContainer" unique_id=1475562434 instance=ExtResource("2_ieenf")]
visible = false
layout_mode = 2
metadata/_tab_index = 0
[node name="ManagerPanel2" parent="TabContainer" unique_id=393118788 instance=ExtResource("2_ieenf")]
visible = false
layout_mode = 2
metadata/_tab_index = 1
[node name="ManagerPanel3" parent="TabContainer" unique_id=609733971 instance=ExtResource("2_ieenf")]
visible = false
layout_mode = 2
metadata/_tab_index = 2
[node name="ManagerPanel4" parent="TabContainer" unique_id=780944038 instance=ExtResource("2_ieenf")]
visible = false
layout_mode = 2
metadata/_tab_index = 3
[node name="InventoryPanel" parent="TabContainer" unique_id=735363118 instance=ExtResource("3_k3wlu")]
layout_mode = 2
metadata/_tab_index = 4
+5
View File
@@ -0,0 +1,5 @@
extends Control
func add_info_card(card : Control) -> bool:
$ScrollContainer/HFlowContainer.add_child(card)
return true;
@@ -0,0 +1 @@
uid://beiiusgimt3s1
+5
View File
@@ -1,5 +1,7 @@
[gd_scene format=3 uid="uid://cbqydw1lerumr"] [gd_scene format=3 uid="uid://cbqydw1lerumr"]
[ext_resource type="Script" uid="uid://beiiusgimt3s1" path="res://src/UI/Panels/Manager/ManagerPanel.gd" id="1_1bkxy"]
[node name="ManagerPanel" type="Control" unique_id=1475562434] [node name="ManagerPanel" type="Control" unique_id=1475562434]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@@ -7,6 +9,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_1bkxy")
[node name="ScrollContainer" type="ScrollContainer" parent="." unique_id=129376527] [node name="ScrollContainer" type="ScrollContainer" parent="." unique_id=129376527]
layout_mode = 1 layout_mode = 1
@@ -18,4 +21,6 @@ grow_vertical = 2
[node name="HFlowContainer" type="HFlowContainer" parent="ScrollContainer" unique_id=836450693] [node name="HFlowContainer" type="HFlowContainer" parent="ScrollContainer" unique_id=836450693]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 1 alignment = 1
@@ -0,0 +1,10 @@
extends Control
func _ready() -> void:
custom_minimum_size = Vector2(180, 240)
custom_maximum_size = Vector2(180, 240)
pass
func set_order_info(info : Dictionary) -> bool:
$PanelContainer/VBoxContainer/Title.text = info['title']
return true;
@@ -0,0 +1 @@
uid://cygiqebct7tk7
@@ -1,5 +1,6 @@
[gd_scene format=3 uid="uid://6ui4v8yhobr4"] [gd_scene format=3 uid="uid://6ui4v8yhobr4"]
[ext_resource type="Script" uid="uid://cygiqebct7tk7" path="res://src/UI/Panels/Manager/OrderPanel/OrderInformation.gd" id="1_0aqu5"]
[ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_87463"] [ext_resource type="StyleBox" uid="uid://kxc0y8146vlk" path="res://resources/manager_info_style_box_flat.tres" id="1_87463"]
[ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="2_sotk8"] [ext_resource type="LabelSettings" uid="uid://dur4uye3m0ffd" path="res://resources/manager_info_label_settings.tres" id="2_sotk8"]
@@ -12,6 +13,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_0aqu5")
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=1940446491] [node name="PanelContainer" type="PanelContainer" parent="." unique_id=1940446491]
layout_mode = 1 layout_mode = 1