Add ancient serif UI font

This commit is contained in:
2026-06-19 03:29:37 +09:00
parent ce0ca3177f
commit 27c9de787a
5 changed files with 176 additions and 5 deletions

View File

@@ -32,6 +32,8 @@ const SFX_SKILL_CAST_PATH := "res://audio/sfx/skill_cast_01.wav"
const SFX_SLASH_PATH := "res://audio/sfx/slash_01.wav"
const SFX_UI_CLICK_PATH := "res://audio/sfx/ui_click_01.wav"
const SFX_VICTORY_STING_PATH := "res://audio/sfx/victory_sting_01.wav"
const UI_FONT_REGULAR_PATH := "res://art/ui/fonts/GowunBatang-Regular.ttf"
const UI_FONT_BOLD_PATH := "res://art/ui/fonts/GowunBatang-Bold.ttf"
const BGM_VOLUME_DB := -14.0
const SFX_VOLUME_DB := -4.0
const UI_SFX_VOLUME_DB := -8.0
@@ -118,6 +120,7 @@ var mission_title_label: Label
var mission_detail_label: Label
var objective_notice_panel: PanelContainer
var objective_notice_label: Label
var ui_root_control: Control
var hud_unit_portrait_panel: PanelContainer
var hud_unit_portrait_texture: TextureRect
var hud_unit_portrait_label: Label
@@ -236,6 +239,8 @@ var unit_motion_by_unit: Dictionary = {}
var unit_action_motion_by_unit: Dictionary = {}
var battle_background_path := ""
var battle_background_texture: Texture2D
var ui_regular_font: Font
var ui_bold_font: Font
func _ready() -> void:
@@ -431,6 +436,60 @@ func _make_button_style(fill: Color, border: Color, border_width: int) -> StyleB
return style
func _ui_font(bold: bool = false) -> Font:
if bold:
if ui_bold_font == null:
ui_bold_font = _load_ui_font(UI_FONT_BOLD_PATH)
return ui_bold_font
if ui_regular_font == null:
ui_regular_font = _load_ui_font(UI_FONT_REGULAR_PATH)
return ui_regular_font
func _load_ui_font(font_path: String) -> Font:
if font_path.is_empty():
return null
if ResourceLoader.exists(font_path):
var resource := ResourceLoader.load(font_path)
if resource is Font:
return resource as Font
var font := FontFile.new()
if font.load_dynamic_font(font_path) != OK:
return null
return font
func _make_ui_theme() -> Theme:
var theme := Theme.new()
var regular := _ui_font(false)
if regular != null:
theme.default_font = regular
theme.set_font("normal_font", "RichTextLabel", regular)
theme.set_font("italics_font", "RichTextLabel", regular)
theme.set_font("mono_font", "RichTextLabel", regular)
var bold := _ui_font(true)
if bold != null:
theme.set_font("bold_font", "RichTextLabel", bold)
theme.set_font("bold_italics_font", "RichTextLabel", bold)
return theme
func _draw_ui_font(bold: bool = false) -> Font:
var font := _ui_font(bold)
if font != null:
return font
return ThemeDB.fallback_font
func _apply_control_font(control: Control, bold: bool = false) -> void:
if control == null:
return
var font := _ui_font(bold)
if font == null:
return
control.add_theme_font_override("font", font)
func _apply_button_style(button: Button, important: bool = false) -> void:
if button == null:
return
@@ -447,6 +506,7 @@ func _apply_button_style(button: Button, important: bool = false) -> void:
button.add_theme_color_override("font_pressed_color", UI_PARCHMENT_TEXT)
button.add_theme_color_override("font_focus_color", UI_PARCHMENT_TEXT)
button.add_theme_color_override("font_disabled_color", UI_DISABLED_TEXT)
_apply_control_font(button, important)
func _apply_label_style(label: Label, font_color: Color, font_size: int = 0) -> void:
@@ -455,6 +515,7 @@ func _apply_label_style(label: Label, font_color: Color, font_size: int = 0) ->
label.add_theme_color_override("font_color", font_color)
if font_size > 0:
label.add_theme_font_size_override("font_size", font_size)
_apply_control_font(label, font_size >= 16)
func _make_separator(width: float = 0.0, height: float = 2.0) -> ColorRect:
@@ -545,6 +606,8 @@ func _create_hud() -> void:
add_child(layer)
var root := Control.new()
ui_root_control = root
root.theme = _make_ui_theme()
root.set_anchors_preset(Control.PRESET_FULL_RECT)
root.mouse_filter = Control.MOUSE_FILTER_IGNORE
layer.add_child(root)
@@ -2199,7 +2262,7 @@ func _draw_overlays() -> void:
func _draw_units() -> void:
var font := ThemeDB.fallback_font
var font := _draw_ui_font()
for unit in state.units:
if not unit.get("alive", false) or not unit.get("deployed", true):
continue
@@ -2243,7 +2306,7 @@ func _draw_units() -> void:
func _draw_target_selection_markers() -> void:
if not _is_targeting_mode():
return
var font := ThemeDB.fallback_font
var font := _draw_ui_font(true)
for marker in _target_selection_marker_entries():
var cell: Vector2i = marker.get("cell", Vector2i(-1, -1))
if not state.is_inside(cell):
@@ -2391,7 +2454,7 @@ func _draw_unit_class_badge(rect: Rect2, unit: Dictionary, team_color: Color) ->
var badge_rect := Rect2(rect.position + Vector2(5, 5), Vector2(28, 13))
draw_rect(badge_rect, Color(0.02, 0.022, 0.026, 0.82))
draw_rect(badge_rect, team_color.lightened(0.18), false, 1.2)
var font := ThemeDB.fallback_font
var font := _draw_ui_font(true)
draw_string(font, badge_rect.position + Vector2(1, 11), _unit_class_abbrev(unit), HORIZONTAL_ALIGNMENT_CENTER, badge_rect.size.x - 2, 8, Color.WHITE)
@@ -2741,7 +2804,7 @@ func _draw_action_impact_cue(cue: String, start: Vector2, end: Vector2, progress
func _draw_floating_texts() -> void:
if floating_texts.is_empty():
return
var font := ThemeDB.fallback_font
var font := _draw_ui_font(true)
for popup in floating_texts:
var duration: float = maxf(0.01, float(popup.get("duration", FLOATING_TEXT_LIFETIME)))
var age := float(popup.get("age", 0.0))
@@ -2808,7 +2871,7 @@ func _draw_target_preview_badge() -> void:
var kind := str(badge.get("kind", ""))
var color := _target_preview_badge_color(kind)
var background := Color(0.025, 0.028, 0.034, 0.88)
var font := ThemeDB.fallback_font
var font := _draw_ui_font(true)
var text := str(badge.get("text", ""))
draw_rect(badge_rect, background)