Replace control-list composition with scene + entity focus on three pages: Skyport training seats use real 96px hero frames; World node tokens become 80px landmarks with compact chapter underlines; Settlement becomes a single spoils plaque with one emphasized exit. Restore authored scene colour on Skyport/World and keep settlement darkening. Rebind authority callbacks to rebuilt world tokens so real ScreenTouch keeps routing. Presentation only: no CH numeric, battle, economy, save, route, locale-key or touch-target key changes. No new art or assets.
189 lines
6.7 KiB
GDScript
189 lines
6.7 KiB
GDScript
class_name UiPageSettlement
|
|
extends Control
|
|
|
|
## U1 Settlement page shell: a dedicated full-screen chapter card, not the
|
|
## generic gold dialog. Victory and defeat are different layouts. Rewards and
|
|
## numbers are runtime text; no outcome is baked into an image.
|
|
|
|
var locale: String = "zh_CN"
|
|
var reduced_motion: bool = false
|
|
var current_state: String = "victory"
|
|
var tap_targets: Dictionary = {}
|
|
var _card: PanelContainer = null
|
|
var _body: VBoxContainer = null
|
|
var _reward_number: Label = null
|
|
var _secondary: Button = null
|
|
var _runtime: Dictionary = {}
|
|
|
|
|
|
func build(p_locale: String, p_reduced: bool) -> void:
|
|
locale = p_locale
|
|
reduced_motion = p_reduced
|
|
tap_targets.clear()
|
|
_clear_children()
|
|
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
size_flags_vertical = Control.SIZE_EXPAND_FILL
|
|
mouse_filter = Control.MOUSE_FILTER_STOP # flow page intercepts lower input
|
|
|
|
# The page's only material surface is a centred spoils plaque, not a
|
|
# full-screen card. The modal dim behind it is the one allowed whole-screen
|
|
# darkening in the game; no second surface is introduced here.
|
|
var center := CenterContainer.new()
|
|
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
center.offset_bottom = -96 # keep the plaque clear of the docked CTA
|
|
center.mouse_filter = Control.MOUSE_FILTER_PASS
|
|
add_child(center)
|
|
|
|
_card = UiTheme.make_surface_panel(0.92)
|
|
_card.custom_minimum_size = Vector2(320, 372)
|
|
_card.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
center.add_child(_card)
|
|
|
|
_body = VBoxContainer.new()
|
|
_body.add_theme_constant_override("separation", 10)
|
|
_body.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
var margin := MarginContainer.new()
|
|
margin.add_theme_constant_override("margin_left", 16)
|
|
margin.add_theme_constant_override("margin_right", 16)
|
|
margin.add_theme_constant_override("margin_top", 12)
|
|
margin.add_theme_constant_override("margin_bottom", 12)
|
|
margin.add_child(_body)
|
|
_card.add_child(margin)
|
|
|
|
_set_state_content(current_state)
|
|
|
|
|
|
func title_key() -> String:
|
|
return "shell.victory.title" if current_state == "victory" else "shell.defeat.title"
|
|
|
|
|
|
func cta_label() -> String:
|
|
return UiText.t("modal.victory.next" if current_state == "victory" else "modal.defeat.retry", locale)
|
|
|
|
|
|
func cta_icon() -> String:
|
|
return "res://assets/icons/icon_flag.png"
|
|
|
|
|
|
func cta_enabled() -> bool:
|
|
return true
|
|
|
|
|
|
func state() -> String:
|
|
return "settlement_%s" % current_state
|
|
|
|
|
|
func set_state(value: String) -> void:
|
|
if value == "victory" or value == "defeat":
|
|
current_state = value
|
|
if _body != null:
|
|
_set_state_content(current_state)
|
|
|
|
|
|
## U2 additive hook. Default U1 content is unchanged when no runtime data is
|
|
## supplied; game_root passes authoritative reward, context and outcome text.
|
|
func set_runtime(data: Dictionary) -> void:
|
|
_runtime = data.duplicate()
|
|
if _body != null:
|
|
_set_state_content(current_state)
|
|
|
|
|
|
func card() -> Control:
|
|
return _card
|
|
|
|
|
|
func set_actions_visible(value: bool) -> void:
|
|
if _secondary != null:
|
|
_secondary.visible = value
|
|
if value:
|
|
tap_targets["settlement_secondary"] = _secondary
|
|
else:
|
|
tap_targets.erase("settlement_secondary")
|
|
|
|
|
|
func _set_state_content(value: String) -> void:
|
|
for child in _body.get_children():
|
|
_body.remove_child(child)
|
|
child.free()
|
|
tap_targets.clear()
|
|
|
|
# Ribbon: real loot/allies art at playable size (the page's L2 focus), not
|
|
# another text band. Chest + companion frame both come from existing assets.
|
|
var ribbon := HBoxContainer.new()
|
|
ribbon.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
ribbon.add_theme_constant_override("separation", 10)
|
|
ribbon.add_child(UiTheme.make_icon("res://assets/icons/icon_chest.png", 64))
|
|
var ally_id := str(_runtime.get("ally", "H04"))
|
|
if value != "victory":
|
|
ally_id = "H01"
|
|
ribbon.add_child(UiTheme.make_hero_portrait(
|
|
"res://assets/%s_idle_anim.png" % ally_id, 64))
|
|
_body.add_child(ribbon)
|
|
|
|
var emblem := UiTheme.make_label(
|
|
UiText.t("shell.victory.title" if value == "victory" else "shell.defeat.title", locale),
|
|
22, UiTheme.COLOR_BORDER if value == "victory" else UiTheme.COLOR_DANGER)
|
|
emblem.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
_body.add_child(emblem)
|
|
|
|
var cause_text := str(_runtime.get("cause",
|
|
UiText.tf("shell.victory.cleared", {"region": UiText.t("content.region.R1", locale), "index": 1}, locale) if value == "victory"
|
|
else UiText.t("modal.defeat.reason", locale)))
|
|
var cause := UiTheme.make_label(cause_text, 13, UiTheme.COLOR_TEXT)
|
|
cause.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
cause.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
_body.add_child(cause)
|
|
|
|
var time_text := str(_runtime.get("time", "00:47"))
|
|
if not time_text.is_empty():
|
|
_body.add_child(UiTheme.make_chip(time_text, UiTheme.COLOR_TEXT_DIM, 12))
|
|
|
|
if value == "victory":
|
|
var reward_row := HBoxContainer.new()
|
|
reward_row.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
reward_row.add_child(UiTheme.make_icon("res://assets/icons/icon_gold.png", 32))
|
|
_reward_number = UiTheme.make_label("0", 36, UiTheme.COLOR_BORDER)
|
|
reward_row.add_child(_reward_number)
|
|
reward_row.add_child(UiTheme.make_label(UiText.t("modal.victory.reward", locale), 12, UiTheme.COLOR_TEXT_DIM))
|
|
_body.add_child(reward_row)
|
|
_roll_reward()
|
|
if bool(_runtime.get("ally_visible", true)):
|
|
var ally_name := str(_runtime.get("ally", "H04"))
|
|
var ally := UiTheme.make_chip(UiText.tf("shell.victory.new_hero", {"name": ally_name}, locale))
|
|
_body.add_child(ally)
|
|
else:
|
|
# Failure gives a readable reason and a concrete improvement suggestion.
|
|
var hint := UiTheme.make_label(
|
|
str(_runtime.get("reason", UiText.t("shell.defeat.body", locale))), 12, UiTheme.COLOR_TEXT)
|
|
hint.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
hint.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
_body.add_child(hint)
|
|
var suggestion := UiTheme.make_chip(UiText.t("shell.victory.continue", locale))
|
|
_body.add_child(suggestion)
|
|
|
|
var fallback_return := UiText.t("modal.victory.return" if value == "victory" else "modal.defeat.return", locale)
|
|
# Quiet single exit. game_root suppresses this when its docked/primary
|
|
# action is present, so the two never become two solid actions at once.
|
|
var secondary := UiTheme.make_dialog_action(
|
|
str(_runtime.get("return_label", fallback_return)), false)
|
|
secondary.custom_minimum_size = Vector2(0, 48)
|
|
_body.add_child(secondary)
|
|
_secondary = secondary
|
|
tap_targets["settlement_secondary"] = secondary
|
|
|
|
|
|
func _roll_reward() -> void:
|
|
if _reward_number == null:
|
|
return
|
|
var amount := str(_runtime.get("reward_gold", 120))
|
|
# Static terminal value for deterministic capture; the pop roll is owned by
|
|
# the settlement timing milestone, not by this UI shell slice.
|
|
_reward_number.text = amount
|
|
|
|
|
|
func _clear_children() -> void:
|
|
for child in get_children():
|
|
remove_child(child)
|
|
child.free()
|