refactor(m52): extract guild header module

This commit is contained in:
2026-09-11 07:55:29 +08:00
parent cbcbfc35eb
commit 8caa64f724
2 changed files with 44 additions and 23 deletions
+5 -23
View File
@@ -12,6 +12,7 @@ const InitialCompanyArt = preload("res://entry/initial_company_art.gd")
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_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")
const GUILD_DESK_TOP_CENTER = preload("res://assets/entry/guild_desk_v001/top_rail/center.png")
@@ -122,29 +123,10 @@ func _build_overlay(data: Dictionary) -> void:
var returned_contract := bool(contract_data.get("returned", false))
var has_contract := bool(contract_data.get("present", false))
var title_plate := _overlay_plate(
overlay,
"GuildTitlePlate",
Rect2(0.090, 0.026, 0.137, 0.076),
Color("#f3dfae"),
Color("#9d7839"),
2,
14
)
var title := make_label(localize("公会大厅", "GUILD HALL", page_data), _guild_text_size(11), Color("#23323a"))
title.name = "GuildAnchorTitle"
_set_normalized_rect(title, Rect2(0.07, 0.04, 0.86, 0.54))
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
title.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
title.mouse_filter = Control.MOUSE_FILTER_IGNORE
title_plate.add_child(title)
var status := make_label(localize("持续远征团", "PERSISTENT COMPANY", page_data), _guild_text_size(6), Color("#5e513a"))
status.name = "GuildAnchorStatus"
_set_normalized_rect(status, Rect2(0.07, 0.57, 0.86, 0.34))
status.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
status.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
status.mouse_filter = Control.MOUSE_FILTER_IGNORE
title_plate.add_child(status)
var header := M52_GUILD_HEADER.new().configure(localize("公会大厅", "GUILD HALL", page_data), localize("持续远征团", "PERSISTENT COMPANY", page_data))
header.name = "GuildTitlePlate"
_set_normalized_rect(header, Rect2(0.075, 0.026, 0.215, 0.120))
overlay.add_child(header)
var pressure_copy := "0"
var coin_copy := "--"
+39
View File
@@ -0,0 +1,39 @@
class_name ABGM52GuildHeader
extends Control
const UIFactory = preload("res://ui/shared/ui_factory.gd")
var title_text := "公会大厅"
var subtitle_text := "持续远征团"
func configure(next_title: String, next_subtitle: String) -> ABGM52GuildHeader:
title_text = next_title
subtitle_text = next_subtitle
return self
func _ready() -> void:
clip_contents = true
var title := UIFactory.label(title_text, "title", 1.0, Color("#23323a"))
title.name = "GuildAnchorTitle"
title.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
title.anchor_left = 0.08
title.anchor_top = 0.08
title.anchor_right = 0.92
title.anchor_bottom = 0.58
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
title.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
title.clip_text = true
title.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
add_child(title)
var subtitle := UIFactory.label(subtitle_text, "micro", 1.0, Color("#5e513a"))
subtitle.name = "GuildAnchorStatus"
subtitle.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
subtitle.anchor_left = 0.12
subtitle.anchor_top = 0.58
subtitle.anchor_right = 0.88
subtitle.anchor_bottom = 0.96
subtitle.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
subtitle.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
subtitle.clip_text = true
subtitle.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
add_child(subtitle)