Add generated UI panel frames

This commit is contained in:
2026-06-20 03:13:34 +09:00
parent 4cda39f440
commit 5decb837fd
8 changed files with 160 additions and 7 deletions

View File

@@ -29,6 +29,7 @@ const BGM_BATTLE_PATH := "res://audio/bgm/battle_loop_placeholder.wav"
const TITLE_BACKGROUND_PATH := "res://art/backgrounds/title_war_camp_dawn.png"
const TITLE_PORTRAIT_PATH := "res://art/portraits/cao_cao.png"
const TOOLBAR_ICON_PATH_TEMPLATE := "res://art/ui/icons/toolbar_%s.png"
const PANEL_TEXTURE_PATH_TEMPLATE := "res://art/ui/panels/panel_%s.png"
const TERRAIN_TEXTURE_PATH_TEMPLATE := "res://art/terrain/terrain_%s.png"
const OPENING_PROLOGUE_REBELLION_PATH := "res://art/story/opening/yellow_turban_rebellion.png"
const OPENING_PROLOGUE_RESOLVE_PATH := "res://art/story/opening/cao_cao_resolves.png"
@@ -692,6 +693,46 @@ func _make_panel_style(fill: Color, border: Color, border_width: int, radius: in
return style
func _make_panel_texture_style(variant: String, content_margin: int) -> StyleBoxTexture:
var spec := _panel_texture_spec(variant)
if spec.is_empty():
return null
var texture_key := str(spec.get("texture", ""))
var texture := _load_art_texture(PANEL_TEXTURE_PATH_TEMPLATE % texture_key)
if texture == null:
return null
var slice_margin := int(spec.get("slice_margin", 88))
var style := StyleBoxTexture.new()
style.texture = texture
style.draw_center = true
style.texture_margin_left = slice_margin
style.texture_margin_right = slice_margin
style.texture_margin_top = slice_margin
style.texture_margin_bottom = slice_margin
var resolved_margin: int = maxi(content_margin, int(spec.get("content_margin", content_margin)))
style.content_margin_left = resolved_margin
style.content_margin_right = resolved_margin
style.content_margin_top = resolved_margin
style.content_margin_bottom = resolved_margin
return style
func _panel_texture_spec(variant: String) -> Dictionary:
match variant:
"paper", "edict", "notice_edict", "speech_scroll":
return {"texture": "paper_scroll", "slice_margin": 108, "content_margin": 22}
"silk_map", "bamboo_slips", "hud_info", "target_hint", "caption", "edict_compact":
return {"texture": "hud_jade", "slice_margin": 46, "content_margin": 9}
"dialogue", "compact", "result_tablet":
return {"texture": "lacquer", "slice_margin": 96, "content_margin": 14}
"command_seal", "notice", "result_defeat_tablet":
return {"texture": "command_seal", "slice_margin": 72, "content_margin": 12}
"result_victory_tablet":
return {"texture": "hud_jade", "slice_margin": 92, "content_margin": 22}
_:
return {}
func _age_panel_style(style: StyleBoxFlat, variant: String, border_width: int) -> void:
if style == null:
return
@@ -872,7 +913,13 @@ func _apply_panel_style(panel: PanelContainer, variant: String) -> void:
pass
var style := _make_panel_style(fill, border, border_width, radius, margin, shadow_size)
_age_panel_style(style, variant, border_width)
var texture_style := _make_panel_texture_style(variant, margin)
if texture_style != null:
panel.add_theme_stylebox_override("panel", texture_style)
panel.set_meta("generated_panel_texture", true)
return
panel.add_theme_stylebox_override("panel", style)
panel.set_meta("generated_panel_texture", false)
func _make_button_style(fill: Color, border: Color, border_width: int) -> StyleBoxFlat: