Show next camp preview in results
This commit is contained in:
@@ -3222,8 +3222,7 @@ func _update_result_panel() -> void:
|
||||
_rebuild_result_choices()
|
||||
if result_restart_button != null:
|
||||
result_restart_button.visible = true
|
||||
if next_battle_button != null:
|
||||
next_battle_button.visible = not str(battle_result_summary.get("next_scenario_id", "")).is_empty() and bool(battle_result_summary.get("choice_applied", true)) and bool(battle_result_summary.get("saved", false))
|
||||
_update_result_next_button_visibility()
|
||||
result_label.text = "Victory\n%s\n%s" % [
|
||||
state.objectives.get("victory", ""),
|
||||
_format_battle_result_summary()
|
||||
@@ -5656,6 +5655,12 @@ func _on_post_battle_choice_pressed(choice: Dictionary) -> void:
|
||||
_play_ui_cancel()
|
||||
_on_log_added("Could not save campaign choice.")
|
||||
_rebuild_result_choices()
|
||||
_update_result_next_button_visibility()
|
||||
if result_label != null and state.battle_status == BattleState.STATUS_VICTORY:
|
||||
result_label.text = "Victory\n%s\n%s" % [
|
||||
state.objectives.get("victory", ""),
|
||||
_format_battle_result_summary()
|
||||
]
|
||||
_update_hud()
|
||||
|
||||
|
||||
@@ -5701,6 +5706,9 @@ func _format_battle_result_summary() -> String:
|
||||
]
|
||||
if not already_next.is_empty():
|
||||
replay_lines.append("Next\n %s" % already_next)
|
||||
var replay_preview := _format_next_camp_preview_text(str(battle_result_summary.get("next_scenario_id", "")))
|
||||
if not replay_preview.is_empty():
|
||||
replay_lines.append("Next Camp\n %s" % replay_preview)
|
||||
return _join_strings(replay_lines, "\n")
|
||||
|
||||
var items: Array = battle_result_summary.get("items", [])
|
||||
@@ -5745,9 +5753,70 @@ func _format_battle_result_summary() -> String:
|
||||
sections.append("Choice\n Select a campaign response.")
|
||||
elif not str(battle_result_summary.get("choice_label", "")).is_empty():
|
||||
sections.append("Choice\n %s" % str(battle_result_summary.get("choice_label", "")))
|
||||
var next_preview := _format_next_camp_preview_text(str(battle_result_summary.get("next_scenario_id", "")))
|
||||
if not next_preview.is_empty() and bool(battle_result_summary.get("saved", false)):
|
||||
sections.append("Next Camp\n %s" % next_preview)
|
||||
return _join_strings(sections, "\n")
|
||||
|
||||
|
||||
func _update_result_next_button_visibility() -> void:
|
||||
if next_battle_button == null:
|
||||
return
|
||||
next_battle_button.visible = (
|
||||
not str(battle_result_summary.get("next_scenario_id", "")).is_empty()
|
||||
and bool(battle_result_summary.get("choice_applied", true))
|
||||
and bool(battle_result_summary.get("saved", false))
|
||||
)
|
||||
|
||||
|
||||
func _format_next_camp_preview_text(next_scenario_id: String) -> String:
|
||||
var scenario_id := next_scenario_id.strip_edges()
|
||||
if scenario_id.is_empty():
|
||||
return ""
|
||||
var scenario_path := campaign_state.get_scenario_path(scenario_id)
|
||||
if scenario_path.is_empty():
|
||||
return ""
|
||||
var preview_state := BattleStateScript.new()
|
||||
if not preview_state.load_battle(
|
||||
scenario_path,
|
||||
campaign_state.get_roster_overrides(),
|
||||
campaign_state.get_inventory_snapshot(),
|
||||
campaign_state.get_flags_snapshot(),
|
||||
campaign_state.get_joined_officers_snapshot()
|
||||
):
|
||||
return ""
|
||||
var parts := []
|
||||
var briefing := preview_state.get_briefing()
|
||||
var location := str(briefing.get("location", "")).strip_edges()
|
||||
if not location.is_empty():
|
||||
parts.append(location)
|
||||
var talk_count := _briefing_camp_conversation_count(briefing)
|
||||
if talk_count > 0:
|
||||
parts.append("Talk %d" % talk_count)
|
||||
var shop_count := preview_state.get_shop_item_ids().size()
|
||||
if shop_count > 0:
|
||||
parts.append("Shop %d goods" % shop_count)
|
||||
if preview_state.has_deployment_roster():
|
||||
parts.append("Deploy %d/%d" % [
|
||||
preview_state.get_deployed_player_count(),
|
||||
preview_state.get_deployment_max_units()
|
||||
])
|
||||
var formation_count := preview_state.get_formation_cells().size()
|
||||
if formation_count > 0:
|
||||
parts.append("Formation %d tiles" % formation_count)
|
||||
return _join_strings(parts, " | ")
|
||||
|
||||
|
||||
func _briefing_camp_conversation_count(briefing: Dictionary) -> int:
|
||||
var conversations = briefing.get("camp_conversations", [])
|
||||
if typeof(conversations) == TYPE_ARRAY and not conversations.is_empty():
|
||||
return conversations.size()
|
||||
var lines = briefing.get("camp_dialogue", [])
|
||||
if typeof(lines) == TYPE_ARRAY and not lines.is_empty():
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
func _format_progression_events(events) -> String:
|
||||
if typeof(events) != TYPE_ARRAY:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user