refactor(m52): extract guild contract board

This commit is contained in:
2026-09-11 10:40:47 +08:00
parent 63c8211436
commit a7a2d1d7df
2 changed files with 51 additions and 0 deletions
+8
View File
@@ -13,6 +13,7 @@ const GUILD_DESK_WORLD = preload("res://assets/entry/guild_desk_v001/world.png")
const M52_GUILD_BACKGROUND = preload("res://assets/backgrounds/m52_guild_background.png")
const M52_Q_GUILD_BACKGROUND = preload("res://assets/backgrounds/m52_q_guild_background.png")
const M52_GUILD_RESOURCE_STATUS = preload("res://ui/m52/guild_resource_status.gd")
const M52_GUILD_CONTRACT_BOARD = preload("res://ui/m52/guild_contract_board.gd")
const M52_GUILD_HEADER = preload("res://ui/m52/guild_header.gd")
const GUILD_DESK_CONTRACT_BOARD = preload("res://assets/entry/guild_desk_v001/contract-board.png")
const GUILD_DESK_TOP_LEFT = preload("res://assets/entry/guild_desk_v001/top_rail/left.png")
@@ -250,6 +251,13 @@ func _build_overlay(data: Dictionary) -> void:
notice.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
notice.mouse_filter = Control.MOUSE_FILTER_IGNORE
kiosk_copy_area.add_child(notice)
for legacy_copy in [kiosk_text, contract_reason, market_reason, notice]:
legacy_copy.visible = false
var contract_board := M52_GUILD_CONTRACT_BOARD.new().configure(kiosk_title, contract_copy, market_copy, String(page_data.get("notice", "")))
contract_board.name = "GuildContractBoardContent"
contract_board.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
contract_board.mouse_filter = Control.MOUSE_FILTER_IGNORE
kiosk_copy_area.add_child(contract_board)
var equipment_state: Dictionary = Dictionary(destinations.get("equipment", {}))
var party_state: Dictionary = Dictionary(destinations.get("party", {}))
+43
View File
@@ -0,0 +1,43 @@
class_name ABGM52GuildContractBoard
extends Control
const UIFactory = preload("res://ui/shared/ui_factory.gd")
var title_text := "委托板"
var contract_text := ""
var market_text := ""
var notice_text := ""
func configure(next_title: String, next_contract: String, next_market: String, next_notice: String) -> ABGM52GuildContractBoard:
title_text = next_title
contract_text = next_contract
market_text = next_market
notice_text = next_notice
return self
func _ready() -> void:
clip_contents = true
_add_copy("GuildKioskText", title_text, Rect2(0.03, 0.04, 0.94, 0.20), 13)
_add_copy("GuildContractReason", contract_text, Rect2(0.04, 0.31, 0.92, 0.24), 9)
_add_copy("GuildMarketReason", market_text, Rect2(0.04, 0.58, 0.92, 0.28), 9)
_add_copy("GuildNotice", notice_text, Rect2(0.03, 0.86, 0.94, 0.13), 8)
func _add_copy(node_name: String, value: String, area: Rect2, design_size: int) -> void:
var label := UIFactory.label(value, "body", 1.0, Color("#4b3724"))
label.name = node_name
label.anchor_left = area.position.x
label.anchor_top = area.position.y
label.anchor_right = area.end.x
label.anchor_bottom = area.end.y
label.offset_left = 0.0
label.offset_top = 0.0
label.offset_right = 0.0
label.offset_bottom = 0.0
label.add_theme_font_size_override("font_size", design_size)
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(label)