Refine TAB menu presentation and standardize UI fonts
This commit is contained in:
parent
78b91c350b
commit
59bdb07fc5
19 changed files with 393 additions and 435 deletions
|
|
@ -1,40 +1,31 @@
|
|||
class_name InterfaceFontController
|
||||
extends Node
|
||||
|
||||
signal font_mode_changed(use_readable_font: bool)
|
||||
|
||||
const READABLE_FONT_PATH: String = "res://ui/fonts/Tuffy_Bold.otf"
|
||||
const STANDARD_FONT: Font = preload("res://ui/fonts/Tuffy_Bold.otf")
|
||||
|
||||
var _game_theme: Theme = preload("res://ui/game_theme.tres")
|
||||
var _game_font: Font = preload("res://ui/fonts/seattle_avenue.otf")
|
||||
var _readable_font: Font
|
||||
var _utility_theme: Theme
|
||||
var _use_readable_font: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if ResourceLoader.exists(READABLE_FONT_PATH):
|
||||
_readable_font = load(READABLE_FONT_PATH) as Font
|
||||
if _readable_font == null:
|
||||
push_error("Readable interface font resource is unavailable.")
|
||||
else:
|
||||
_readable_font.fallbacks = [_game_font]
|
||||
enforce_standard_font()
|
||||
_utility_theme = _game_theme.duplicate(true)
|
||||
_utility_theme.default_font = readable_font()
|
||||
_utility_theme.default_font = STANDARD_FONT
|
||||
|
||||
|
||||
func set_readable_font_enabled(enabled: bool) -> void:
|
||||
_use_readable_font = enabled
|
||||
_game_theme.default_font = (
|
||||
_readable_font
|
||||
if enabled and _readable_font != null
|
||||
else _game_font
|
||||
)
|
||||
font_mode_changed.emit(_use_readable_font)
|
||||
func enforce_standard_font() -> void:
|
||||
_game_theme.default_font = STANDARD_FONT
|
||||
if _utility_theme != null:
|
||||
_utility_theme.default_font = STANDARD_FONT
|
||||
|
||||
|
||||
func set_readable_font_enabled(_enabled: bool) -> void:
|
||||
# Compatibility seam for callers compiled against the old setting.
|
||||
enforce_standard_font()
|
||||
|
||||
|
||||
func is_readable_font_enabled() -> bool:
|
||||
return _use_readable_font
|
||||
return true
|
||||
|
||||
|
||||
func apply_utility_theme(themed_node: Node) -> void:
|
||||
|
|
@ -42,9 +33,7 @@ func apply_utility_theme(themed_node: Node) -> void:
|
|||
return
|
||||
if _utility_theme == null:
|
||||
_utility_theme = _game_theme.duplicate(true)
|
||||
_utility_theme.default_font = (
|
||||
_readable_font if _readable_font != null else _game_font
|
||||
)
|
||||
_utility_theme.default_font = STANDARD_FONT
|
||||
if themed_node is Control:
|
||||
(themed_node as Control).theme = _utility_theme
|
||||
elif themed_node is Window:
|
||||
|
|
@ -52,4 +41,4 @@ func apply_utility_theme(themed_node: Node) -> void:
|
|||
|
||||
|
||||
func readable_font() -> Font:
|
||||
return _readable_font if _readable_font != null else _game_font
|
||||
return STANDARD_FONT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue