Fix title menu button fit

This commit is contained in:
2026-06-20 11:17:19 +09:00
parent 0062bb719c
commit c1e4c69eff
2 changed files with 50 additions and 6 deletions

View File

@@ -161,6 +161,7 @@ const TITLE_STORY_PREVIEW_CARD_SIZE := Vector2(148, 90)
const TITLE_STORY_PREVIEW_IMAGE_FRAME_SIZE := Vector2(140, 74)
const TITLE_STORY_PREVIEW_IMAGE_SIZE := Vector2(132, 66)
const TITLE_STORY_PREVIEW_LABEL_SIZE := Vector2(140, 16)
const TITLE_MENU_ICON_MAX_WIDTH := 42
const OPENING_STORY_BEAT_CARD_SIZE := Vector2(136, 74)
const OPENING_STORY_BEAT_IMAGE_FRAME_SIZE := Vector2(126, 46)
const OPENING_STORY_BEAT_IMAGE_SIZE := Vector2(124, 38)
@@ -1266,8 +1267,9 @@ func _configure_title_menu_button(button: Button, node_name: String, icon_kind:
button.text = label
button.tooltip_text = tooltip
button.custom_minimum_size = minimum_size
button.icon = _make_toolbar_icon(icon_kind)
button.icon = _make_title_menu_icon(icon_kind)
button.expand_icon = false
button.add_theme_constant_override("icon_max_width", TITLE_MENU_ICON_MAX_WIDTH)
button.icon_alignment = HORIZONTAL_ALIGNMENT_LEFT
button.vertical_icon_alignment = VERTICAL_ALIGNMENT_CENTER
button.alignment = HORIZONTAL_ALIGNMENT_CENTER
@@ -2045,6 +2047,25 @@ func _make_toolbar_icon(kind: String) -> Texture2D:
return ImageTexture.create_from_image(image)
func _make_title_menu_icon(kind: String) -> Texture2D:
return _make_resized_icon_texture(_make_toolbar_icon(kind), TITLE_MENU_ICON_MAX_WIDTH)
func _make_resized_icon_texture(texture: Texture2D, max_width: int) -> Texture2D:
if texture == null or max_width <= 0:
return texture
var width := texture.get_width()
var height := texture.get_height()
if width <= max_width:
return texture
var image: Image = texture.get_image()
if image == null:
return texture
var resized_height: int = maxi(1, int(round(float(height) * float(max_width) / float(width))))
image.resize(max_width, resized_height, Image.INTERPOLATE_LANCZOS)
return ImageTexture.create_from_image(image)
func _load_toolbar_icon_texture(kind: String) -> Texture2D:
var normalized_kind := kind.strip_edges().to_lower()
if normalized_kind.is_empty():
@@ -4333,9 +4354,9 @@ func _create_hud() -> void:
var title_portrait_shadow := ColorRect.new()
title_portrait_shadow.name = "TitlePortraitLacquerField"
title_portrait_shadow.position = Vector2(646, 34)
title_portrait_shadow.size = Vector2(512, 628)
title_portrait_shadow.color = Color(0.045, 0.018, 0.010, 0.56)
title_portrait_shadow.position = Vector2(686, 72)
title_portrait_shadow.size = Vector2(420, 556)
title_portrait_shadow.color = Color(0.10, 0.060, 0.035, 0.10)
title_portrait_shadow.mouse_filter = Control.MOUSE_FILTER_IGNORE
title_screen_root.add_child(title_portrait_shadow)