fix: route market surfaces through shared UI
This commit is contained in:
@@ -8,13 +8,8 @@ extends "res://presentation/page_view.gd"
|
||||
## as a copied MarketPageController snapshot.
|
||||
|
||||
const InitialCompanyArt = preload("res://entry/initial_company_art.gd")
|
||||
const UIIcon = preload("res://ui/shared/ui_icon.gd")
|
||||
const MARKET_STATIC_MASTER = preload("res://assets/entry/shp_001_market/market-static-master.png")
|
||||
const M50_MARKET_BACKGROUND = preload("res://assets/ui_m50/market_background.png")
|
||||
const M50_BUTTON_FRAME = preload("res://assets/ui_m50/button.png")
|
||||
const M50_COMMISSION_BOARD = preload("res://assets/ui_m50/commission_board.png")
|
||||
const M50_RECRUIT_CARD = preload("res://assets/ui_m50/recruit_card.png")
|
||||
const M50_SEALS = preload("res://assets/ui_m50/seals.png")
|
||||
|
||||
const USE_M50_RESPONSIVE_SLICE := true
|
||||
|
||||
@@ -593,14 +588,14 @@ func _render_m50_responsive_slice(data: Dictionary) -> void:
|
||||
coin.name = "MarketCoinStatus"
|
||||
coin.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
top.add_child(coin)
|
||||
var settings := _m50_button("MarketSettings", "", "icon", Vector2(52, 48), "settings")
|
||||
var settings := UIFactory.command_button("MarketSettings", "", "icon", "settings", "flat", "content", Vector2(52, 48))
|
||||
settings.tooltip_text = _tr("打开设置", "Open settings", data)
|
||||
settings.pressed.connect(func(): emit_intent("settings", {}), CONNECT_DEFERRED)
|
||||
top.add_child(settings)
|
||||
|
||||
var body := HBoxContainer.new()
|
||||
body.name = "M50MarketBody"
|
||||
body.add_theme_constant_override("separation", 14)
|
||||
body.add_theme_constant_override("separation", 8 if size.x < 820.0 else 14)
|
||||
body.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
page.add_child(body)
|
||||
|
||||
@@ -639,8 +634,10 @@ func _render_m50_responsive_slice(data: Dictionary) -> void:
|
||||
offer_list.add_child(empty)
|
||||
|
||||
var selected: Dictionary = Dictionary(data.get("selected_offer", {}))
|
||||
var board := _m50_ninepatch("MarketContextSurface", M50_COMMISSION_BOARD, Rect2(16, 37, 566, 515), Vector4(68, 68, 68, 68))
|
||||
board.custom_minimum_size = Vector2(286, 0)
|
||||
var board := Panel.new()
|
||||
board.name = "MarketContextSurface"
|
||||
board.add_theme_stylebox_override("panel", Tokens.surface_style("context"))
|
||||
board.custom_minimum_size = Vector2(260 if size.x < 820.0 else 286, 0)
|
||||
board.size_flags_horizontal = Control.SIZE_EXPAND
|
||||
board.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
body.add_child(board)
|
||||
@@ -672,7 +669,7 @@ func _render_m50_responsive_slice(data: Dictionary) -> void:
|
||||
detail.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
detail.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
board_content.add_child(detail)
|
||||
var review := _m50_button("MarketReviewRecruit", _tr("查看详情", "REVIEW DETAILS"), "primary", Vector2(0, 52), "inspect")
|
||||
var review := UIFactory.command_button("MarketReviewRecruit", _tr("查看详情", "REVIEW DETAILS"), "primary", "inspect", "flat", "content", Vector2(0, 52))
|
||||
review.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
review.disabled = selected_offer_id.is_empty() or selected_kind != "recruit"
|
||||
if review.disabled:
|
||||
@@ -690,7 +687,7 @@ func _render_m50_responsive_slice(data: Dictionary) -> void:
|
||||
footer.add_theme_constant_override("separation", 10)
|
||||
footer.custom_minimum_size.y = 52
|
||||
page.add_child(footer)
|
||||
var back := _m50_button("MarketBackGuild", _tr("返回公会", "BACK TO GUILD"), "utility", Vector2(170, 48), "back")
|
||||
var back := UIFactory.command_button("MarketBackGuild", _tr("返回公会", "BACK TO GUILD"), "utility", "back", "flat", "content", Vector2(128, 48))
|
||||
back.pressed.connect(func(): emit_intent("back", {}), CONNECT_DEFERRED)
|
||||
footer.add_child(back)
|
||||
var footer_hint := UIFactory.label(_tr("准备 → 编队 → 风险 → 出发", "PREPARE → FORM → RISK → DEPART"), "micro", 1.0, Tokens.COLOR_GOLD_LIGHT)
|
||||
@@ -699,7 +696,7 @@ func _render_m50_responsive_slice(data: Dictionary) -> void:
|
||||
footer.add_child(footer_hint)
|
||||
var return_command_facts: Dictionary = Dictionary(Dictionary(data.get("commands", {})).get("return_contract", {}))
|
||||
var return_enabled := bool(return_command_facts.get("enabled", false))
|
||||
var return_contract := _m50_button("MarketReturnContract", _tr("返回委托", "RETURN CONTRACT"), "danger", Vector2(190, 48), "risk")
|
||||
var return_contract := UIFactory.command_button("MarketReturnContract", _tr("返回委托", "RETURN CONTRACT"), "danger", "risk", "flat", "content", Vector2(148, 48))
|
||||
return_contract.disabled = not return_enabled
|
||||
if return_contract.disabled:
|
||||
return_contract.self_modulate = Color(0.58, 0.62, 0.64, 1.0)
|
||||
@@ -711,8 +708,7 @@ func _render_m50_responsive_slice(data: Dictionary) -> void:
|
||||
# Category commands stay available to keyboard/touch contracts but remain
|
||||
# secondary to the recruit decision in this first responsive slice.
|
||||
for category in ["equipment", "battle"]:
|
||||
var category_button := Button.new()
|
||||
category_button.name = "MarketCategory%s" % category.capitalize()
|
||||
var category_button := UIFactory.command_button("MarketCategory%s" % category.capitalize(), "", "secondary", "generic", "flat", "content")
|
||||
category_button.visible = false
|
||||
category_button.pressed.connect(func(): emit_intent("category", {"category": category}), CONNECT_DEFERRED)
|
||||
add_child(category_button)
|
||||
@@ -721,20 +717,10 @@ func _render_m50_responsive_slice(data: Dictionary) -> void:
|
||||
func _m50_recruit_card(index: int, offer: Dictionary, selected_kind: String, selected_offer_id: String, data: Dictionary) -> Button:
|
||||
var offer_id := String(offer.get("source_offer_id", ""))
|
||||
var presentation := _offer_presentation(offer)
|
||||
var card := Button.new()
|
||||
card.name = "MarketOffer%s" % offer_id
|
||||
card.flat = true
|
||||
card.focus_mode = Control.FOCUS_ALL
|
||||
card.custom_minimum_size = Vector2(146, 0)
|
||||
var card := UIFactory.command_button("MarketOffer%s" % offer_id, "", "secondary", "generic", "flat", "content", Vector2(146, 48))
|
||||
card.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
card.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
card.tooltip_text = _tr("检查 %s", "Inspect %s", data) % String(presentation.get("recruit_name", _fallback_recruit_name(offer)))
|
||||
for style_name in ["normal", "hover", "pressed", "disabled", "focus", "hover_pressed"]:
|
||||
card.add_theme_stylebox_override(style_name, StyleBoxEmpty.new())
|
||||
var frame := _m50_ninepatch("Frame", M50_RECRUIT_CARD, Rect2(109, 15, 382, 551), Vector4(54, 54, 54, 54))
|
||||
frame.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
frame.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
card.add_child(frame)
|
||||
var portrait := TextureRect.new()
|
||||
portrait.name = "Portrait"
|
||||
portrait.texture = InitialCompanyArt.texture_for(offer)
|
||||
@@ -787,11 +773,8 @@ func _m50_recruit_card(index: int, offer: Dictionary, selected_kind: String, sel
|
||||
card.add_child(price)
|
||||
var selected := selected_kind == "recruit" and selected_offer_id == offer_id
|
||||
card.set_meta("selected", selected)
|
||||
UIFactory.refresh_command_button(card, false, selected)
|
||||
card.pressed.connect(func(): emit_intent("select_offer", {"kind": "recruit", "offer_id": offer_id}), CONNECT_DEFERRED)
|
||||
card.mouse_entered.connect(func(): frame.modulate = Color(1.12, 1.08, 0.94, 1.0))
|
||||
card.mouse_exited.connect(func(): frame.modulate = Color(1.0, 1.0, 1.0, 1.0))
|
||||
if selected:
|
||||
frame.modulate = Color(1.10, 1.18, 1.22, 1.0)
|
||||
if not bool(presentation.get("reduced_motion", false)):
|
||||
var tween := portrait.create_tween().set_loops()
|
||||
tween.set_pause_mode(Tween.TWEEN_PAUSE_PROCESS)
|
||||
@@ -800,59 +783,6 @@ func _m50_recruit_card(index: int, offer: Dictionary, selected_kind: String, sel
|
||||
return card
|
||||
|
||||
|
||||
func _m50_ninepatch(node_name: String, texture: Texture2D, region: Rect2, margins: Vector4) -> NinePatchRect:
|
||||
var patch := NinePatchRect.new()
|
||||
patch.name = node_name
|
||||
patch.texture = texture
|
||||
patch.region_rect = region
|
||||
patch.patch_margin_left = margins.x
|
||||
patch.patch_margin_top = margins.y
|
||||
patch.patch_margin_right = margins.z
|
||||
patch.patch_margin_bottom = margins.w
|
||||
patch.axis_stretch_horizontal = NinePatchRect.AXIS_STRETCH_MODE_TILE_FIT
|
||||
patch.axis_stretch_vertical = NinePatchRect.AXIS_STRETCH_MODE_TILE_FIT
|
||||
patch.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
|
||||
patch.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
return patch
|
||||
|
||||
|
||||
func _m50_button(node_name: String, text_value: String, variant: String, minimum_size: Vector2, icon_kind: String) -> Button:
|
||||
var button := Button.new()
|
||||
button.name = node_name
|
||||
button.flat = true
|
||||
button.focus_mode = Control.FOCUS_ALL
|
||||
button.custom_minimum_size = Vector2(maxf(48.0, minimum_size.x), maxf(48.0, minimum_size.y))
|
||||
button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
for style_name in ["normal", "hover", "pressed", "disabled", "focus", "hover_pressed"]:
|
||||
button.add_theme_stylebox_override(style_name, StyleBoxEmpty.new())
|
||||
var frame := _m50_ninepatch("Frame", M50_BUTTON_FRAME, Rect2(10, 164, 583, 245), Vector4(78, 54, 78, 54))
|
||||
frame.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
button.add_child(frame)
|
||||
if not text_value.is_empty():
|
||||
var label := UIFactory.label(text_value, "label", 1.0, Tokens.COLOR_INK if variant == "primary" else Tokens.COLOR_IVORY)
|
||||
label.name = "ButtonLabel"
|
||||
label.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
label.offset_left = 16.0
|
||||
label.offset_right = -16.0
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
button.add_child(label)
|
||||
if Tokens.icon_kind_supported(icon_kind):
|
||||
var icon := UIIcon.new().configure(icon_kind, "dark")
|
||||
icon.name = "CommandIcon"
|
||||
icon.set_anchors_and_offsets_preset(Control.PRESET_CENTER_LEFT)
|
||||
icon.position = Vector2(14, 0)
|
||||
icon.size = Vector2(28, 28)
|
||||
icon.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
button.add_child(icon)
|
||||
button.mouse_entered.connect(func(): frame.modulate = Color(1.12, 1.08, 0.94, 1.0))
|
||||
button.mouse_exited.connect(func(): frame.modulate = Color(1.0, 1.0, 1.0, 1.0))
|
||||
button.pressed.connect(func(): frame.modulate = Color(0.92, 0.96, 1.04, 1.0))
|
||||
return button
|
||||
|
||||
|
||||
func _market_mode_button(overlay: Control, category: String, area: Rect2, count: int, selected_category: String, data: Dictionary) -> Button:
|
||||
var selected := selected_category == category
|
||||
var title: String = String({
|
||||
|
||||
@@ -12,7 +12,7 @@ func run_test() -> void:
|
||||
for fixture in [{"width": 760, "height": 360}, {"width": 844, "height": 390}, {"width": 1280, "height": 720}]:
|
||||
await _check_fixture(int(fixture.width), int(fixture.height))
|
||||
if failures.is_empty():
|
||||
print("ABG_M50_RESPONSIVE_UI_OK fixtures=760x360,844x390,1280x720 ninepatch=button,board,card fixed_text=true intents=preserved")
|
||||
print("ABG_M50_RESPONSIVE_UI_OK fixtures=760x360,844x390,1280x720 shared_surface=board,card shared_commands=true fixed_text=true intents=preserved")
|
||||
quit(0)
|
||||
else:
|
||||
for failure in failures:
|
||||
@@ -31,7 +31,7 @@ func _check_fixture(width: int, height: int) -> void:
|
||||
host.add_child(view)
|
||||
view.render(_fixture_data())
|
||||
await process_frame
|
||||
var board := view.find_child("MarketContextSurface", true, false) as NinePatchRect
|
||||
var board := view.find_child("MarketContextSurface", true, false) as Control
|
||||
var first_card := view.find_child("MarketOfferR-001", true, false) as Button
|
||||
var review := view.find_child("MarketReviewRecruit", true, false) as Button
|
||||
expect(board != null, "%dx%d board NinePatch exists" % [width, height])
|
||||
@@ -39,8 +39,7 @@ func _check_fixture(width: int, height: int) -> void:
|
||||
expect(review != null and review.size.y >= 48.0, "%dx%d primary button keeps minimum height" % [width, height])
|
||||
if board != null:
|
||||
expect(board.size.x >= 260.0, "%dx%d board expands horizontally" % [width, height])
|
||||
var margins := [board.patch_margin_left, board.patch_margin_top, board.patch_margin_right, board.patch_margin_bottom]
|
||||
expect(margins[0] > 0.0 and margins[2] > 0.0, "%dx%d board preserves side margins" % [width, height])
|
||||
expect(board is Panel or board is NinePatchRect, "%dx%d board uses a shared surface" % [width, height])
|
||||
var name_label := first_card.get_node_or_null("Name") as Label if first_card != null else null
|
||||
expect(name_label != null and name_label.get_theme_font_size("font_size") == 14, "%dx%d card text stays fixed at 14px" % [width, height])
|
||||
host.queue_free()
|
||||
|
||||
Reference in New Issue
Block a user