fix(m88): carry the header title and price on readable inks

This commit is contained in:
2026-09-18 13:31:48 +08:00
parent 0edba4a78e
commit 4d3a9b4540
2 changed files with 35 additions and 15 deletions
@@ -10,6 +10,7 @@ extends "res://presentation/page_view.gd"
const InitialCompanyArt = preload("res://entry/initial_company_art.gd")
const PageChrome = preload("res://ui/shared/page_chrome.gd")
const MarketChrome = preload("res://ui/shared/market_chrome.gd")
const RECRUIT_REVIEW_STATIC_MASTER = preload("res://assets/entry/shp_002_recruit_review/recruit-review-static-master.png")
@@ -56,7 +57,7 @@ func _render_view(data: Dictionary) -> void:
# Measured on the static master (PIL scan, 1280x720): top line y=44-46,
# left line x=44-46, right line x=1233-1236 (inner edge 1232). The insets keep
# 5-6px of breathing inside the inner edge, so the right edge stays <=1228.
var face_x := maxi(52, int(size.x * 0.021) + 26)
var face_x := maxi(64, int(size.x * 0.021) + 38)
var face_y := maxi(52, int(size.y * 0.048) + 18)
header_safe.add_theme_constant_override("margin_left", face_x)
header_safe.add_theme_constant_override("margin_right", face_x)
@@ -68,11 +69,15 @@ func _render_view(data: Dictionary) -> void:
var heading := VBoxContainer.new()
heading.size_flags_horizontal = Control.SIZE_EXPAND_FILL
header.add_child(heading)
heading.add_child(make_label(localize("招募详情", "RECRUIT REVIEW", data), scaled(20), Color("#f5ead0")))
# M88: the headline also sits over sky/cloud in the frame interior; the cream
# ink measured under 2:1 there, so the shared deep ink carries it.
heading.add_child(make_label(localize("招募详情", "RECRUIT REVIEW", data), scaled(20), PageChrome.INK))
# M88: the name sits on the frame interior, where the cream ink measured
# 1.03:1; the shared deep ink keeps the subtitle readable (>=4.5:1).
heading.add_child(make_label(String(facts.get("name", _fallback_offer_name(offer))), scaled(11), PageChrome.INK))
var price := make_label(localize("%d 金币", "%d COIN", data) % int(hire_state.get("price", offer.get("list_price", 0))), scaled(15), Color("#f0ca75"))
# M88: gold on the dark panel measured 3.1:1; the shared light paper token
# keeps the price emphatic and readable on that carrier.
var price := make_label(localize("%d 金币", "%d COIN", data) % int(hire_state.get("price", offer.get("list_price", 0))), scaled(15), MarketChrome.PAPER_LIGHT)
price.name = "RecruitReviewPrice"
price.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
header.add_child(price)
+27 -12
View File
@@ -95,27 +95,42 @@ func _capture(locale: String, text_scale: float) -> void:
failures.append("price right edge %.0f exceeds %.0f" % [price.get_global_rect().end.x, PRICE_RIGHT_MAX])
if InkCheck.ink_rect(title).position.y < TITLE_TOP_MIN:
failures.append("title ink top %.1f is above %.0f" % [InkCheck.ink_rect(title).position.y, TITLE_TOP_MIN])
var ratio := _name_contrast(view, name_label)
if ratio < CONTRAST_MIN:
failures.append("name contrast %.2f:1 below %.1f:1" % [ratio, CONTRAST_MIN])
var ratios := PackedStringArray()
for pair in [["title", title], ["name", name_label], ["price", price]]:
var ratio: float = _contrast_for(view, pair[1])
ratios.append("%s=%.2f:1" % [String(pair[0]), ratio])
if ratio < CONTRAST_MIN:
failures.append("%s contrast %.2f:1 below %.1f:1" % [String(pair[0]), ratio, CONTRAST_MIN])
print("ABG_M88_SHP002_CONTRAST %s ts%.1f %s" % [locale, text_scale, " ".join(ratios)])
sub.queue_free()
await process_frame
func _name_contrast(view: Control, name_label: Label) -> float:
func _contrast_for(view: Control, label: Label) -> float:
# Carrier = the pixels immediately around the glyph band (inside the label rect,
# outside the ink), median luminance. A P95 over the ink rect would sample the
# bright glyphs themselves for gold text and report a false 1:1.
var image := view.get_viewport().get_texture().get_image()
var ink: Rect2 = InkCheck.ink_rect(name_label)
var name_ink: Color = name_label.get_theme_color("font_color")
var rect := label.get_global_rect()
var samples: Array = []
for x in range(int(ink.position.x), maxi(int(ink.position.x) + 1, int(ink.end.x)), 2):
for y in range(int(ink.position.y), maxi(int(ink.position.y) + 1, int(ink.end.y)), 2):
samples.append(image.get_pixel(clampi(x, 0, image.get_width() - 1), clampi(y, 0, image.get_height() - 1)))
var y_top := clampi(int(rect.position.y) + 2, 0, image.get_height() - 1)
var y_bottom := clampi(int(rect.end.y) - 2, 0, image.get_height() - 1)
for x in range(clampi(int(rect.position.x) + 2, 0, image.get_width() - 1),
clampi(int(rect.end.x) - 2, 1, image.get_width())):
samples.append(image.get_pixel(x, y_top))
samples.append(image.get_pixel(x, y_bottom))
var x_left := clampi(int(rect.position.x) + 2, 0, image.get_width() - 1)
var x_right := clampi(int(rect.end.x) - 2, 0, image.get_width() - 1)
for y in range(y_top, maxi(y_top + 1, y_bottom)):
samples.append(image.get_pixel(x_left, y))
samples.append(image.get_pixel(x_right, y))
if samples.is_empty():
return 0.0
samples.sort_custom(func(a, b): return _luminance(a) < _luminance(b))
var carrier: Color = samples[mini(samples.size() - 1, int(float(samples.size() - 1) * 0.95))]
var lighter := maxf(_luminance(name_ink), _luminance(carrier))
var darker := minf(_luminance(name_ink), _luminance(carrier))
var carrier: Color = samples[samples.size() / 2]
var ink: Color = label.get_theme_color("font_color")
var lighter := maxf(_luminance(ink), _luminance(carrier))
var darker := minf(_luminance(ink), _luminance(carrier))
return (lighter + 0.05) / (darker + 0.05)