Use generated toolbar icons
This commit is contained in:
@@ -28,6 +28,7 @@ const BGM_MENU_PATH := "res://audio/bgm/menu_theme_placeholder.wav"
|
||||
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 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"
|
||||
const OPENING_PROLOGUE_XIAHOU_DUN_PATH := "res://art/story/opening/xiahou_dun_joins.png"
|
||||
@@ -976,7 +977,7 @@ func _configure_hud_command_button(button: Button, icon_kind: String = "") -> vo
|
||||
if not icon_kind.is_empty():
|
||||
button.text = ""
|
||||
button.icon = _make_toolbar_icon(icon_kind)
|
||||
button.expand_icon = false
|
||||
button.expand_icon = true
|
||||
button.set_meta("icon_only", true)
|
||||
button.set_meta("command_icon", icon_kind)
|
||||
|
||||
@@ -1022,7 +1023,7 @@ func _configure_local_command_button(button: Button, icon_kind: String, label: S
|
||||
button.custom_minimum_size = minimum_size
|
||||
button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
button.icon = _make_toolbar_icon(icon_kind)
|
||||
button.expand_icon = false
|
||||
button.expand_icon = true
|
||||
button.add_theme_font_size_override("font_size", 1)
|
||||
button.set_meta("icon_only", true)
|
||||
button.set_meta("command_icon", icon_kind)
|
||||
@@ -1332,6 +1333,9 @@ func _set_control_tree_tooltip(node: Node, tooltip: String) -> void:
|
||||
|
||||
|
||||
func _make_toolbar_icon(kind: String) -> Texture2D:
|
||||
var generated_icon := _load_toolbar_icon_texture(kind)
|
||||
if generated_icon != null:
|
||||
return generated_icon
|
||||
var image := Image.create(32, 32, false, Image.FORMAT_RGBA8)
|
||||
image.fill(Color(0, 0, 0, 0))
|
||||
var ink := Color(0.82, 0.84, 0.78, 1.0)
|
||||
@@ -1524,6 +1528,13 @@ func _make_toolbar_icon(kind: String) -> Texture2D:
|
||||
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():
|
||||
return null
|
||||
return _load_art_texture(TOOLBAR_ICON_PATH_TEMPLATE % normalized_kind)
|
||||
|
||||
|
||||
func _icon_rect(image: Image, rect: Rect2i, color: Color) -> void:
|
||||
for y in range(maxi(0, rect.position.y), mini(image.get_height(), rect.position.y + rect.size.y)):
|
||||
for x in range(maxi(0, rect.position.x), mini(image.get_width(), rect.position.x + rect.size.x)):
|
||||
|
||||
Reference in New Issue
Block a user