diff --git a/UI/popup/dialogue.gd b/UI/popup/dialogue.gd index bda4349..7be4566 100644 --- a/UI/popup/dialogue.gd +++ b/UI/popup/dialogue.gd @@ -84,6 +84,7 @@ func _advance_dialogue_or_finish() -> void: else: # All dialogues in this page's queue are finished print(node_name + ": Dialogue queue for this page finished. Calling go_next().") + self.hide() go_next() # This will eventually call _close_dialogue and hide the page # Renamed to reflect it shows a single line diff --git a/UI/popup/task_development/main_plan/main_plan.gd b/UI/popup/task_development/main_plan/main_plan.gd index 54ed7d7..383988b 100644 --- a/UI/popup/task_development/main_plan/main_plan.gd +++ b/UI/popup/task_development/main_plan/main_plan.gd @@ -4,6 +4,9 @@ extends UIPage # 继承自我们之前创建的 UIPage @onready var gameplay_page_path: Control = $gameplay @onready var theme_page_path: Control = $theme @onready var strategy_page_path: Control = $strategy +@onready var notice_path: Control = $notice +@onready var dialogue_secretary: Control = $dialogue_secretary + # Part_2: 预算 @onready var budget_button: Button = $BG/Part_2/HBoxContainer/Button @@ -34,6 +37,11 @@ func _ready(): func _on_page_activated(): super._on_page_activated() # 调用父类的激活逻辑 + if GameState.get_value("is_on_task"): + self.show() + go_to_child_page(dialogue_secretary) + return + print(name + " 页面已激活") # 当从其它页面退回到当前页面的时候,money恢复show_up起始值 if get_main_data("original_money") > GameState.get_value("money"): @@ -179,8 +187,7 @@ func _on_strategy_select_button_pressed(): func _on_confirm_button_pressed(): # 导航到下一个页面或结束工作流 if GameState.get_value("money") < get_main_data("预算"): - next_ui_node_path = "../notice_1" - go_next() + go_to_child_page(notice_path) return else: next_ui_node_path = "../product_focus" diff --git a/UI/popup/task_development/main_plan/main_plan.tscn b/UI/popup/task_development/main_plan/main_plan.tscn index 832030d..3370067 100644 --- a/UI/popup/task_development/main_plan/main_plan.tscn +++ b/UI/popup/task_development/main_plan/main_plan.tscn @@ -107,6 +107,7 @@ offset_bottom = 18.0 grow_horizontal = 2 grow_vertical = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("4_fdt2j") theme_override_font_sizes/font_size = 27 text = "新项目" vertical_alignment = 1 @@ -139,6 +140,7 @@ grow_vertical = 2 [node name="Label" type="Label" parent="BG/Part_2/HBoxContainer"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("4_fdt2j") theme_override_font_sizes/font_size = 24 text = "预算" horizontal_alignment = 1 @@ -492,6 +494,7 @@ grow_vertical = 2 theme = ExtResource("5_edtgu") theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_colors/font_focus_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("4_fdt2j") theme_override_font_sizes/font_size = 23 theme_override_styles/focus = SubResource("StyleBoxEmpty_6xfhm") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_k3c3w") diff --git a/UI/popup/task_development/npc_select_1/npc_select_1.gd b/UI/popup/task_development/npc_select_1/npc_select_1.gd index 046e334..b1dd53b 100644 --- a/UI/popup/task_development/npc_select_1/npc_select_1.gd +++ b/UI/popup/task_development/npc_select_1/npc_select_1.gd @@ -22,6 +22,8 @@ var _power_bar_segments: Array[ColorRect] = [] # 用于存储体力条的各个 @onready var next_button: Button = $BG/Title/next/Button @onready var confirm_button: Button = $BG/Confirm +@onready var notice_path: Control = $notice + @export var Suitable_position:Array = [] # --- 内部状态 --- @@ -199,7 +201,6 @@ func _display_current_npc() -> void: # print(str(self.name) + ": NPC icon name is empty for key '%s'. Using default." % npc_key) npc_icon_rect.texture = ResourceLoader.load(DEFAULT_NPC_ICON_PATH) - # 更新能力值 (确保转换为整数显示) stat_design_label.text = str(int(npc_info.get("design", 0.0))) stat_code_label.text = str(int(npc_info.get("code", 0.0))) @@ -253,15 +254,34 @@ func _on_confirm_pressed() -> void: if current_npc_index != -1 and current_npc_index < enabled_npc_keys.size(): var selected_npc_key = enabled_npc_keys[current_npc_index] + # 从 cost_label 获取费用文本并转换为整数 + var cost_string = cost_label.text + var current_npc_cost: int + + # 进行转换,并处理可能的转换失败 (尽管在此逻辑下,cost_label.text 应该总是数字) + if cost_string.is_valid_int(): + current_npc_cost = cost_string.to_int() + else: + printerr(str(self.name) + ": Error converting cost_label.text ('" + cost_string + "') to integer.") + # 可以选择在这里弹出一个错误提示给用户,或者阻止后续操作 + # 例如,可以简单地返回,或者显示一个通知 + go_to_child_page(notice_path) # 假设 notice_path 可以显示一个通用错误 + return + # 导航到下一个页面或结束工作流 next_ui_node_path = temp_next_ui_node_path - if GameState.get_value("money") < int(cost_label.text): - next_ui_node_path = "../notice_2" - go_next() - return + + # 将 GameState 中的 money 与当前NPC的 cost 进行比较 + if GameState.get_value("money") < current_npc_cost: + # 如果钱不够,跳转到提示页面 (例如,显示“资金不足”) + # 您可能需要一个特定的提示页面或消息来指明是费用不足 + # GameState.set_value("notice_msg","资金不足以支付该负责人费用:" + str(current_npc_cost)) # 示例:设置特定提示信息 + go_to_child_page(notice_path) else: - var new_money = GameState.get_value("money")-get_main_data("预算") - GameState.set_value("money",new_money) - #GameState.set_value("dialogue_npc",selected_npc_key) + # 如果钱足够,则扣除费用 + var new_money = GameState.get_value("money") - current_npc_cost + GameState.set_value("money", new_money) + + # 设置选中的NPC为关键环节负责人 set_main_data("关键环节负责人", selected_npc_key) - go_next() + go_next() # 进入下一个UI流程 diff --git a/UI/popup/task_development/task_development_start.tscn b/UI/popup/task_development/task_development_start.tscn index 2c140aa..a6c2bc9 100644 --- a/UI/popup/task_development/task_development_start.tscn +++ b/UI/popup/task_development/task_development_start.tscn @@ -60,6 +60,18 @@ layout_mode = 1 next_ui_node_path = NodePath("..") parent_page_node_path = NodePath("..") +[node name="notice" parent="main_plan" instance=ExtResource("10_5pged")] +visible = false +layout_mode = 1 +notice_text = "资金不足" +parent_page_node_path = NodePath("..") + +[node name="dialogue_secretary" parent="main_plan" instance=ExtResource("8_6il88")] +visible = false +layout_mode = 1 +dialogues = ["目前正在进行其它项目"] +parent_page_node_path = NodePath("..") + [node name="product_focus" parent="." instance=ExtResource("7_l1sf4")] visible = false layout_mode = 1 @@ -80,21 +92,13 @@ Suitable_position = ["项目总监", "策划", "美术设计师"] next_ui_node_path = NodePath("../dialogue_npc") back_ui_node_path = NodePath("../main_plan") +[node name="notice" parent="npc_select_1" instance=ExtResource("10_5pged")] +visible = false +layout_mode = 1 +notice_text = "资金不足" +parent_page_node_path = NodePath("..") + [node name="dialogue_npc" parent="." instance=ExtResource("8_6il88")] visible = false layout_mode = 1 dialogues = ["感谢给我这个机会,我会尽力!"] - -[node name="notice_1" parent="." instance=ExtResource("10_5pged")] -visible = false -layout_mode = 1 -notice_text = "资金不足" -next_ui_node_path = NodePath("../main_plan") -back_ui_node_path = NodePath("../main_plan") - -[node name="notice_2" parent="." instance=ExtResource("10_5pged")] -visible = false -layout_mode = 1 -notice_text = "资金不足" -next_ui_node_path = NodePath("../npc_select_1") -back_ui_node_path = NodePath("../npc_select_1") diff --git a/UI/ui_framework.gd b/UI/ui_framework.gd index 3d93b66..31f1da3 100644 --- a/UI/ui_framework.gd +++ b/UI/ui_framework.gd @@ -38,7 +38,7 @@ func show_up(): else: printerr("Main: Initial page not found or not a UIPage: ", initial_page_path) else: - self.visible = false + self.show() func start_new_workflow(start_page: UIPage, initial_data: Dictionary = {}): print("Main: Starting new workflow with page: ", start_page.name, " and data: ", initial_data) @@ -145,6 +145,7 @@ func _on_page_workflow_end_requested(is_confirm_and_trigger_action: bool): current_active_page = null GameState.set_value(gamestate_data_key,shared_workflow_data) + GameState.set_value("is_on_task",true) GameState.resume_game() - self.visible = false + self.hide() print("Main: UI Workflow finished and Main hidden.")