Compact prebattle shop rows
This commit is contained in:
@@ -11535,6 +11535,7 @@ func _rebuild_shop_buy_list() -> void:
|
||||
var remaining := stock_limit - purchased if stock_limit >= 0 else -1
|
||||
var buy_button := Button.new()
|
||||
var detail_text := _format_shop_buy_item_detail_text(normalized_id, item, price, owned, stock_limit, remaining)
|
||||
var visible_badges := _format_shop_buy_visible_badges(item, price, owned, stock_limit, remaining)
|
||||
buy_button.text = _format_shop_buy_action_text(normalized_id, item, price)
|
||||
buy_button.custom_minimum_size = Vector2(500, 32)
|
||||
buy_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
@@ -11542,7 +11543,7 @@ func _rebuild_shop_buy_list() -> void:
|
||||
buy_button.disabled = campaign_state.gold < price or (stock_limit >= 0 and remaining <= 0)
|
||||
_apply_button_style(buy_button)
|
||||
buy_button.pressed.connect(_on_shop_item_pressed.bind(normalized_id))
|
||||
_add_shop_item_row(normalized_id, item, buy_button, detail_text)
|
||||
_add_shop_item_row(normalized_id, item, buy_button, detail_text, visible_badges)
|
||||
|
||||
|
||||
func _rebuild_shop_sell_list() -> void:
|
||||
@@ -11562,13 +11563,14 @@ func _rebuild_shop_sell_list() -> void:
|
||||
var owned := int(inventory.get(normalized_id, 0))
|
||||
var sell_button := Button.new()
|
||||
var detail_text := _format_shop_sell_item_detail_text(normalized_id, item, sale_price, owned)
|
||||
var visible_badges := _format_shop_sell_visible_badges(item, owned)
|
||||
sell_button.text = _format_shop_sell_action_text(normalized_id, item, sale_price)
|
||||
sell_button.custom_minimum_size = Vector2(500, 32)
|
||||
sell_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
sell_button.tooltip_text = _format_shop_item_tooltip_text(_format_shop_sell_item_button_text(normalized_id, item, sale_price, owned), detail_text)
|
||||
_apply_button_style(sell_button)
|
||||
sell_button.pressed.connect(_on_shop_sell_item_pressed.bind(normalized_id))
|
||||
_add_shop_item_row(normalized_id, item, sell_button, detail_text)
|
||||
_add_shop_item_row(normalized_id, item, sell_button, detail_text, visible_badges)
|
||||
|
||||
|
||||
func _clear_shop_list() -> void:
|
||||
@@ -11629,42 +11631,55 @@ func _make_initials_badge(label_text: String, badge_size: Vector2, font_size: in
|
||||
return panel
|
||||
|
||||
|
||||
func _add_shop_item_row(item_id: String, item: Dictionary, action_button: Button, detail_text: String) -> void:
|
||||
func _add_shop_item_row(item_id: String, item: Dictionary, action_button: Button, detail_text: String, visible_badges: Array) -> void:
|
||||
var tooltip_text := action_button.tooltip_text
|
||||
if tooltip_text.is_empty():
|
||||
tooltip_text = detail_text
|
||||
var row := HBoxContainer.new()
|
||||
row.custom_minimum_size = Vector2(580, 58)
|
||||
row.custom_minimum_size = Vector2(580, 64)
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
row.tooltip_text = tooltip_text
|
||||
shop_list.add_child(row)
|
||||
|
||||
row.add_child(_make_shop_item_icon_panel(item_id, item))
|
||||
row.add_child(_make_shop_item_icon_panel(item_id, item, tooltip_text))
|
||||
|
||||
var column := VBoxContainer.new()
|
||||
column.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
column.add_theme_constant_override("separation", 3)
|
||||
column.tooltip_text = tooltip_text
|
||||
row.add_child(column)
|
||||
|
||||
column.add_child(action_button)
|
||||
|
||||
var detail_label := Label.new()
|
||||
detail_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
detail_label.custom_minimum_size = Vector2(500, 20)
|
||||
detail_label.text = detail_text
|
||||
_apply_label_style(detail_label, UI_AGED_INK)
|
||||
column.add_child(detail_label)
|
||||
var badge_row := HBoxContainer.new()
|
||||
badge_row.custom_minimum_size = Vector2(500, 24)
|
||||
badge_row.add_theme_constant_override("separation", 5)
|
||||
badge_row.tooltip_text = tooltip_text
|
||||
column.add_child(badge_row)
|
||||
|
||||
for badge_text in visible_badges:
|
||||
var text := str(badge_text).strip_edges()
|
||||
if text.is_empty():
|
||||
continue
|
||||
badge_row.add_child(_make_shop_item_info_badge(text, tooltip_text))
|
||||
|
||||
|
||||
func _make_shop_item_icon_panel(item_id: String, item: Dictionary) -> PanelContainer:
|
||||
func _make_shop_item_icon_panel(item_id: String, item: Dictionary, tooltip_text: String = "") -> PanelContainer:
|
||||
var icon_panel := PanelContainer.new()
|
||||
icon_panel.custom_minimum_size = SHOP_ITEM_ICON_SIZE
|
||||
icon_panel.tooltip_text = tooltip_text
|
||||
_apply_panel_style(icon_panel, "portrait")
|
||||
|
||||
var stack := Control.new()
|
||||
stack.custom_minimum_size = SHOP_ITEM_ICON_SIZE
|
||||
stack.tooltip_text = tooltip_text
|
||||
icon_panel.add_child(stack)
|
||||
|
||||
var icon_rect := TextureRect.new()
|
||||
icon_rect.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
icon_rect.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
icon_rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
icon_rect.tooltip_text = tooltip_text
|
||||
stack.add_child(icon_rect)
|
||||
|
||||
var initials_label := Label.new()
|
||||
@@ -11672,6 +11687,7 @@ func _make_shop_item_icon_panel(item_id: String, item: Dictionary) -> PanelConta
|
||||
initials_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
initials_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
initials_label.add_theme_font_size_override("font_size", 16)
|
||||
initials_label.tooltip_text = tooltip_text
|
||||
_apply_label_style(initials_label, UI_PARCHMENT_TEXT)
|
||||
stack.add_child(initials_label)
|
||||
|
||||
@@ -11685,11 +11701,52 @@ func _make_shop_item_icon_panel(item_id: String, item: Dictionary) -> PanelConta
|
||||
|
||||
|
||||
func _format_shop_buy_action_text(item_id: String, _item: Dictionary, price: int) -> String:
|
||||
return "매입 %s %d냥" % [_item_display_name(item_id), price]
|
||||
return "%s %d냥" % [_item_display_name(item_id), price]
|
||||
|
||||
|
||||
func _format_shop_sell_action_text(item_id: String, _item: Dictionary, sale_price: int) -> String:
|
||||
return "매각 %s %d냥" % [_item_display_name(item_id), sale_price]
|
||||
return "%s %d냥" % [_item_display_name(item_id), sale_price]
|
||||
|
||||
|
||||
func _format_shop_buy_visible_badges(item: Dictionary, price: int, owned: int, stock_limit: int = -1, remaining: int = -1) -> Array:
|
||||
var badges := _shop_item_common_visible_badges(item, owned)
|
||||
if stock_limit >= 0:
|
||||
badges.append("잔량 %d/%d" % [max(0, remaining), stock_limit])
|
||||
if stock_limit >= 0 and remaining <= 0:
|
||||
badges.append("매진")
|
||||
elif campaign_state.gold < price:
|
||||
badges.append("부족 %d냥" % (price - campaign_state.gold))
|
||||
return badges
|
||||
|
||||
|
||||
func _format_shop_sell_visible_badges(item: Dictionary, owned: int) -> Array:
|
||||
var badges := _shop_item_common_visible_badges(item, owned)
|
||||
badges.append("반값")
|
||||
return badges
|
||||
|
||||
|
||||
func _shop_item_common_visible_badges(item: Dictionary, owned: int) -> Array:
|
||||
return [
|
||||
_item_kind_text(str(item.get("kind", "item"))),
|
||||
"보유 %d" % owned
|
||||
]
|
||||
|
||||
|
||||
func _make_shop_item_info_badge(text: String, tooltip_text: String) -> PanelContainer:
|
||||
var panel := PanelContainer.new()
|
||||
panel.custom_minimum_size = Vector2(92, 24)
|
||||
panel.tooltip_text = tooltip_text
|
||||
_apply_panel_style(panel, "caption")
|
||||
|
||||
var label := Label.new()
|
||||
label.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
label.text = text
|
||||
label.tooltip_text = tooltip_text
|
||||
_apply_label_style(label, UI_PARCHMENT_TEXT, 11)
|
||||
panel.add_child(label)
|
||||
return panel
|
||||
|
||||
|
||||
func _format_shop_buy_item_detail_text(_item_id: String, item: Dictionary, price: int, owned: int, stock_limit: int = -1, remaining: int = -1) -> String:
|
||||
|
||||
Reference in New Issue
Block a user