Fix narrow en_US bottom nav fourth label clipping

This commit is contained in:
2026-11-30 10:04:54 +08:00
parent 15401f8172
commit 733a93f632
+26 -3
View File
@@ -29,6 +29,7 @@ var _dock: PrimaryCTADock
var _nav: PanelContainer
var _nav_buttons: Array = []
var _nav_specs: Array = []
var _nav_icons: Array = []
var _pages: Dictionary = {}
@@ -107,13 +108,30 @@ func _build_nav() -> void:
{"id": PAGE_SETTLEMENT, "icon": "res://assets/icons/icon_chest.png", "key": "modal.victory.title"},
{"id": "more", "icon": "res://assets/icons/icon_click_gear.png", "key": "shell.side.title"},
]
for spec in _nav_specs:
for i in _nav_specs.size():
var spec: Dictionary = _nav_specs[i]
var button := UiTheme.make_menu_button(
str(spec["icon"]), UiText.t(str(spec["key"]), locale), "secondary", 11, true, true)
str(spec["icon"]), UiText.t(_nav_text_key(i), locale), "secondary", 11, true, true)
button.custom_minimum_size = Vector2(0, 48)
button.pressed.connect(_on_nav.bind(str(spec["id"])))
row.add_child(button)
_nav_buttons.append(button)
_nav_icons.append(button.icon)
func _nav_narrow_en() -> bool:
# Same narrow en_US text-fit gate already used by game_root.gd. No locale
# table or wider-layout presentation is changed.
return locale.begins_with("en") and get_viewport_rect().size.x <= 400.0
func _nav_text_key(index: int) -> String:
# "shell.side.title" ("Company Affairs") overflows a <=400px viewport and
# clips the fourth tab. Reuse the existing short key; every other tab,
# locale and viewport keeps its exact authored key.
if index == 3 and _nav_narrow_en():
return "hud.nav.company"
return str(_nav_specs[index]["key"])
func _rebuild_pages() -> void:
@@ -178,7 +196,12 @@ func _refresh() -> void:
if crystal != null:
crystal.text = "12"
for i in _nav_buttons.size():
(_nav_buttons[i] as Button).text = UiText.t(str(_nav_specs[i]["key"]), locale)
var button := _nav_buttons[i] as Button
button.text = UiText.t(_nav_text_key(i), locale)
# The nav row sizes to content, so the gear icon still pushes the short
# label off-screen at 360/390. Suppress only that icon here; the tab
# count/order, underline selected style and press routing stay intact.
button.icon = null if i == 3 and _nav_narrow_en() else (_nav_icons[i] as Texture2D)
_dock.set_label(page.cta_label())
_dock.set_icon(page.cta_icon())
_dock.set_enabled(page.cta_enabled())