Add visual crests to battle unit list
This commit is contained in:
@@ -183,7 +183,10 @@ const PREP_MENU_BUTTON_SIZE := Vector2(48, 38)
|
||||
const BATTLE_UNIT_LIST_PANEL_SIZE := Vector2(420, 360)
|
||||
const BATTLE_UNIT_LIST_ROW_SIZE := Vector2(372, 58)
|
||||
const BATTLE_UNIT_LIST_ICON_SIZE := Vector2(46, 46)
|
||||
const BATTLE_UNIT_LIST_CLASS_CREST_PANEL_SIZE := Vector2(22, 22)
|
||||
const BATTLE_UNIT_LIST_CLASS_CREST_ICON_SIZE := Vector2(17, 17)
|
||||
const BATTLE_UNIT_LIST_BADGE_SIZE := Vector2(72, 22)
|
||||
const BATTLE_UNIT_LIST_BADGE_ICON_SIZE := Vector2(15, 15)
|
||||
const SETTINGS_PANEL_SIZE := Vector2(420, 330)
|
||||
const LOCAL_COMMAND_BUTTON_SIZE := Vector2(92, 38)
|
||||
const LOCAL_COMMAND_CANCEL_BUTTON_SIZE := Vector2(196, 30)
|
||||
@@ -2590,9 +2593,26 @@ func _create_hud() -> void:
|
||||
battle_unit_header_row.add_theme_constant_override("separation", 8)
|
||||
battle_unit_column.add_child(battle_unit_header_row)
|
||||
|
||||
var battle_unit_header_tooltip := "군세\n전장에 있는 아군과 적군의 상태를 봅니다."
|
||||
var battle_unit_header_seal := _make_seal_tile("군", 26)
|
||||
battle_unit_header_seal.name = "BattleUnitListHeaderSeal"
|
||||
battle_unit_header_seal.tooltip_text = battle_unit_header_tooltip
|
||||
battle_unit_header_row.add_child(battle_unit_header_seal)
|
||||
|
||||
var battle_unit_header_icon := TextureRect.new()
|
||||
battle_unit_header_icon.name = "BattleUnitListHeaderIcon"
|
||||
battle_unit_header_icon.custom_minimum_size = Vector2(24, 24)
|
||||
battle_unit_header_icon.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
battle_unit_header_icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
battle_unit_header_icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
battle_unit_header_icon.texture = _make_toolbar_icon("unit_list")
|
||||
battle_unit_header_icon.tooltip_text = battle_unit_header_tooltip
|
||||
battle_unit_header_row.add_child(battle_unit_header_icon)
|
||||
|
||||
battle_unit_list_title_label = Label.new()
|
||||
battle_unit_list_title_label.text = "군세"
|
||||
battle_unit_list_title_label.custom_minimum_size = Vector2(232, 28)
|
||||
battle_unit_list_title_label.tooltip_text = battle_unit_header_tooltip
|
||||
battle_unit_list_title_label.custom_minimum_size = Vector2(174, 28)
|
||||
battle_unit_list_title_label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_apply_label_style(battle_unit_list_title_label, UI_OLD_BRONZE, 16)
|
||||
battle_unit_header_row.add_child(battle_unit_list_title_label)
|
||||
@@ -12403,11 +12423,17 @@ func _make_battle_unit_list_row(unit: Dictionary) -> HBoxContainer:
|
||||
badge_row.tooltip_text = tooltip_text
|
||||
column.add_child(badge_row)
|
||||
|
||||
for badge_text in _format_battle_unit_list_row_badges(unit):
|
||||
var badge_texts := _format_battle_unit_list_row_badges(unit)
|
||||
for badge_index in range(badge_texts.size()):
|
||||
var badge_text = badge_texts[badge_index]
|
||||
var text := str(badge_text).strip_edges()
|
||||
if text.is_empty():
|
||||
continue
|
||||
badge_row.add_child(_make_battle_unit_list_badge(text, tooltip_text))
|
||||
badge_row.add_child(_make_battle_unit_list_badge(
|
||||
text,
|
||||
tooltip_text,
|
||||
_battle_unit_list_badge_icon(unit, badge_index, text)
|
||||
))
|
||||
return row
|
||||
|
||||
|
||||
@@ -12443,6 +12469,30 @@ func _make_battle_unit_list_icon(unit: Dictionary, tooltip_text: String) -> Pane
|
||||
initials_label.tooltip_text = tooltip_text
|
||||
_apply_label_style(initials_label, UI_PARCHMENT_TEXT, 14)
|
||||
stack.add_child(initials_label)
|
||||
|
||||
var class_icon := _load_unit_class_icon_texture(unit)
|
||||
if class_icon != null:
|
||||
var crest_panel := PanelContainer.new()
|
||||
crest_panel.name = "BattleUnitListClassCrest"
|
||||
crest_panel.position = Vector2(
|
||||
BATTLE_UNIT_LIST_ICON_SIZE.x - BATTLE_UNIT_LIST_CLASS_CREST_PANEL_SIZE.x + 1.0,
|
||||
BATTLE_UNIT_LIST_ICON_SIZE.y - BATTLE_UNIT_LIST_CLASS_CREST_PANEL_SIZE.y + 1.0
|
||||
)
|
||||
crest_panel.size = BATTLE_UNIT_LIST_CLASS_CREST_PANEL_SIZE
|
||||
crest_panel.custom_minimum_size = BATTLE_UNIT_LIST_CLASS_CREST_PANEL_SIZE
|
||||
crest_panel.tooltip_text = "%s\n%s" % [_unit_class_display_name(unit), tooltip_text]
|
||||
_apply_panel_style(crest_panel, "caption")
|
||||
|
||||
var crest_icon := TextureRect.new()
|
||||
crest_icon.name = "BattleUnitListClassIcon"
|
||||
crest_icon.custom_minimum_size = BATTLE_UNIT_LIST_CLASS_CREST_ICON_SIZE
|
||||
crest_icon.size = BATTLE_UNIT_LIST_CLASS_CREST_ICON_SIZE
|
||||
crest_icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
crest_icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
crest_icon.texture = class_icon
|
||||
crest_icon.tooltip_text = crest_panel.tooltip_text
|
||||
crest_panel.add_child(crest_icon)
|
||||
stack.add_child(crest_panel)
|
||||
return panel
|
||||
|
||||
|
||||
@@ -12462,23 +12512,81 @@ func _format_battle_unit_list_row_badges(unit: Dictionary) -> Array:
|
||||
]
|
||||
|
||||
|
||||
func _make_battle_unit_list_badge(text: String, tooltip_text: String) -> PanelContainer:
|
||||
func _make_battle_unit_list_badge(text: String, tooltip_text: String, icon_texture: Texture2D = null) -> PanelContainer:
|
||||
var panel := PanelContainer.new()
|
||||
panel.custom_minimum_size = BATTLE_UNIT_LIST_BADGE_SIZE
|
||||
panel.tooltip_text = tooltip_text
|
||||
_apply_panel_style(panel, "caption")
|
||||
if icon_texture != null:
|
||||
panel.set_meta("battle_unit_list_badge_icon", true)
|
||||
|
||||
var row := HBoxContainer.new()
|
||||
row.custom_minimum_size = Vector2(BATTLE_UNIT_LIST_BADGE_SIZE.x - 8.0, BATTLE_UNIT_LIST_BADGE_SIZE.y - 4.0)
|
||||
row.add_theme_constant_override("separation", 3)
|
||||
row.tooltip_text = tooltip_text
|
||||
panel.add_child(row)
|
||||
|
||||
if icon_texture != null:
|
||||
var icon := TextureRect.new()
|
||||
icon.name = "BattleUnitListBadgeIcon"
|
||||
icon.custom_minimum_size = BATTLE_UNIT_LIST_BADGE_ICON_SIZE
|
||||
icon.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
icon.texture = icon_texture
|
||||
icon.tooltip_text = tooltip_text
|
||||
row.add_child(icon)
|
||||
|
||||
var label := Label.new()
|
||||
label.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.custom_minimum_size = Vector2(44, BATTLE_UNIT_LIST_BADGE_SIZE.y - 4.0)
|
||||
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT if icon_texture != null else HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
label.text = text
|
||||
label.tooltip_text = tooltip_text
|
||||
_apply_label_style(label, UI_PARCHMENT_TEXT, 10)
|
||||
panel.add_child(label)
|
||||
row.add_child(label)
|
||||
return panel
|
||||
|
||||
|
||||
func _battle_unit_list_badge_icon(unit: Dictionary, badge_index: int, badge_text: String) -> Texture2D:
|
||||
match badge_index:
|
||||
0:
|
||||
return _load_unit_class_icon_texture(unit)
|
||||
1:
|
||||
return _make_toolbar_icon("status")
|
||||
2:
|
||||
return _make_toolbar_icon(_battle_unit_action_icon_kind(unit))
|
||||
3:
|
||||
return _make_toolbar_icon(_battle_zone_icon_kind(badge_text))
|
||||
_:
|
||||
return null
|
||||
|
||||
|
||||
func _battle_unit_action_icon_kind(unit: Dictionary) -> String:
|
||||
if not bool(unit.get("alive", true)):
|
||||
return "cancel"
|
||||
if str(unit.get("team", "")) == BattleState.TEAM_ENEMY:
|
||||
return "threat"
|
||||
if not bool(unit.get("controllable", true)):
|
||||
return "formation"
|
||||
if bool(unit.get("acted", false)):
|
||||
return "wait"
|
||||
return "move"
|
||||
|
||||
|
||||
func _battle_zone_icon_kind(zone_text: String) -> String:
|
||||
match zone_text:
|
||||
"성채":
|
||||
return "objective"
|
||||
"마을":
|
||||
return "shop"
|
||||
"위치 미상":
|
||||
return "status"
|
||||
_:
|
||||
return "terrain"
|
||||
|
||||
|
||||
func _format_battle_unit_list_row_tooltip(unit: Dictionary) -> String:
|
||||
var hint := "클릭하면 위치로 이동합니다."
|
||||
if str(unit.get("team", "")) == BattleState.TEAM_PLAYER and _can_select(unit) and _can_select_from_battle_unit_list():
|
||||
|
||||
Reference in New Issue
Block a user