Refine shop, online sessions, and player feedback
This commit is contained in:
parent
2ffcbf51ac
commit
c038eeadea
47 changed files with 1208 additions and 189 deletions
|
|
@ -26,8 +26,13 @@ const ShopInteractionType = preload(
|
|||
)
|
||||
const UtilityPageStyleType = preload("res://ui/utility_page_style.gd")
|
||||
const OrganizerTabType = preload("res://ui/components/organizer_tab.gd")
|
||||
const UIMotionType = preload("res://ui/ui_motion.gd")
|
||||
const FALLBACK_SUPPLY_ICON: Texture2D = preload(
|
||||
"res://ui/icons/pictograms/x_light.png"
|
||||
)
|
||||
|
||||
signal menu_visibility_changed(is_open: bool)
|
||||
signal menu_exit_started
|
||||
signal sell_fish_requested
|
||||
signal shop_cooler_return_requested
|
||||
signal shop_cooler_confirmation_cancel_requested
|
||||
|
|
@ -46,6 +51,7 @@ enum ShopSection {
|
|||
SNACKS,
|
||||
EQUIPMENT,
|
||||
ART_SUPPLIES,
|
||||
SELL_FISH,
|
||||
}
|
||||
|
||||
const SHOP_SECTION_LABELS: Array[String] = [
|
||||
|
|
@ -54,15 +60,23 @@ const SHOP_SECTION_LABELS: Array[String] = [
|
|||
"Snacks",
|
||||
"Equipment",
|
||||
"Art Supplies",
|
||||
"Sell Fish",
|
||||
]
|
||||
const SUPPLY_ICON_GRID_COLUMNS: int = 9
|
||||
const SUPPLY_ICON_TILE_SIZE := Vector2(72.0, 72.0)
|
||||
const SUPPLY_ICON_HOST_SIZE := Vector2(72.0, 84.0)
|
||||
const SUPPLY_ICON_GRID_SEPARATION: int = 8
|
||||
const SUPPLY_PRICE_COLOR := Color("c3dfe6")
|
||||
const SUPPLY_PRICE_FONT_SIZE: int = 15
|
||||
const SUPPLY_PRICE_Y: float = 60.0
|
||||
const SUPPLY_PRICE_HEIGHT: float = 24.0
|
||||
const SUPPLY_PRICE_HORIZONTAL_PADDING: float = 12.0
|
||||
|
||||
@onready var _wallet_label: Label = %WalletLabel
|
||||
@onready var _shop_panel: PanelContainer = %ShopPanel
|
||||
@onready var _shop_cooler_page: Control = %ShopCoolerPage
|
||||
@onready var _shop_cooler_mount: Control = %ShopCoolerMount
|
||||
@onready var _back_to_shop_button: Button = %BackToShopButton
|
||||
@onready var _buy_mode_button: Button = %BuyModeButton
|
||||
@onready var _sell_mode_button: Button = %SellModeButton
|
||||
@onready var _shop_body: HBoxContainer = $ShopPanel/Margin/Layout/Body
|
||||
@onready var _feedback: Label = %Feedback
|
||||
@onready var _shop_tab_bar: HBoxContainer = %ShopTabBar
|
||||
@onready var _upgrades_content: VBoxContainer = %Upgrades
|
||||
|
|
@ -100,6 +114,8 @@ var _snapshot_stored: bool = false
|
|||
var _mouse_snapshot_stored: bool = false
|
||||
var _transaction_in_progress: bool = false
|
||||
var _closing: bool = false
|
||||
var _close_generation: int = 0
|
||||
var _close_tween: Tween
|
||||
var _cooler_page_active: bool = false
|
||||
var _cooler_modal_open: bool = false
|
||||
var _shop_section: ShopSection = ShopSection.UPGRADES
|
||||
|
|
@ -111,46 +127,57 @@ func _ready() -> void:
|
|||
_apply_shop_styles()
|
||||
_build_shop_tabs()
|
||||
%CloseButton.pressed.connect(close_shop)
|
||||
_buy_mode_button.pressed.connect(_focus_buy_page)
|
||||
_sell_mode_button.pressed.connect(_request_shop_cooler)
|
||||
_back_to_shop_button.pressed.connect(shop_cooler_return_requested.emit)
|
||||
_reel_purchase.pressed.connect(_purchase_reel_speed)
|
||||
_barrier_purchase.pressed.connect(_purchase_barrier_power)
|
||||
_cooler_purchase.pressed.connect(_purchase_cooler_capacity)
|
||||
|
||||
|
||||
func _request_shop_cooler() -> void:
|
||||
func _request_shop_cooler() -> bool:
|
||||
if _transaction_in_progress:
|
||||
_feedback.text = "Finish the current transaction first."
|
||||
return
|
||||
return false
|
||||
if not _is_transaction_context_valid():
|
||||
_feedback.text = "The fishing shop is no longer available."
|
||||
return
|
||||
return false
|
||||
sell_fish_requested.emit()
|
||||
return _cooler_page_active
|
||||
|
||||
|
||||
func _focus_buy_page() -> void:
|
||||
func _focus_shop_section() -> void:
|
||||
_feedback.text = ""
|
||||
if _shop_section == ShopSection.UPGRADES:
|
||||
_reel_purchase.grab_focus()
|
||||
return
|
||||
for child: Node in _supplies_list.get_children():
|
||||
if _shop_section == ShopSection.SELL_FISH:
|
||||
_shop_tabs[int(ShopSection.SELL_FISH)].grab_focus()
|
||||
return
|
||||
for child: Node in _supplies_list.find_children(
|
||||
"*", "Button", true, false
|
||||
):
|
||||
var stock_button := child as Button
|
||||
if stock_button != null and not stock_button.disabled:
|
||||
stock_button.grab_focus()
|
||||
return
|
||||
_buy_mode_button.grab_focus()
|
||||
var section_index: int = int(_shop_section)
|
||||
if section_index >= 0 and section_index < _shop_tabs.size():
|
||||
_shop_tabs[section_index].grab_focus()
|
||||
|
||||
|
||||
func _build_shop_tabs() -> void:
|
||||
_shop_tab_bar.custom_minimum_size.y = 44.0
|
||||
_shop_tab_bar.show()
|
||||
for section_index: int in range(ShopSection.size()):
|
||||
if section_index == ShopSection.SELL_FISH:
|
||||
var tab_group_spacer := Control.new()
|
||||
tab_group_spacer.name = "SellTabSpacer"
|
||||
tab_group_spacer.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
tab_group_spacer.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_shop_tab_bar.add_child(tab_group_spacer)
|
||||
var tab: OrganizerTab = OrganizerTabType.new()
|
||||
tab.text = SHOP_SECTION_LABELS[section_index]
|
||||
tab.palette_index = section_index
|
||||
tab.custom_minimum_size = Vector2(132.0, 42.0)
|
||||
tab.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
tab.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
tab.focus_mode = Control.FOCUS_ALL
|
||||
tab.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
tab.pressed.connect(_select_shop_section.bind(section_index, true))
|
||||
|
|
@ -161,15 +188,38 @@ func _build_shop_tabs() -> void:
|
|||
|
||||
|
||||
func _select_shop_section(section_index: int, focus_content: bool) -> void:
|
||||
if _closing:
|
||||
return
|
||||
if section_index == int(_shop_section):
|
||||
_update_shop_tab_selection()
|
||||
if focus_content:
|
||||
_focus_shop_section()
|
||||
return
|
||||
if section_index == ShopSection.SELL_FISH:
|
||||
if not _request_shop_cooler():
|
||||
_update_shop_tab_selection()
|
||||
return
|
||||
_shop_section = ShopSection.SELL_FISH
|
||||
_update_shop_tab_selection()
|
||||
return
|
||||
if _cooler_page_active:
|
||||
shop_cooler_return_requested.emit()
|
||||
_shop_section = section_index as ShopSection
|
||||
var showing_upgrades: bool = _shop_section == ShopSection.UPGRADES
|
||||
_upgrades_content.visible = showing_upgrades
|
||||
_supplies_content.visible = not showing_upgrades
|
||||
for tab_index: int in range(_shop_tabs.size()):
|
||||
_shop_tabs[tab_index].set_selected(tab_index == section_index, true)
|
||||
_update_shop_tab_selection()
|
||||
_refresh_supplies()
|
||||
if focus_content and visible:
|
||||
_focus_buy_page()
|
||||
_focus_shop_section()
|
||||
|
||||
|
||||
func _update_shop_tab_selection() -> void:
|
||||
for tab_index: int in range(_shop_tabs.size()):
|
||||
_shop_tabs[tab_index].set_selected(
|
||||
tab_index == int(_shop_section),
|
||||
true,
|
||||
)
|
||||
|
||||
|
||||
func _apply_shop_styles() -> void:
|
||||
|
|
@ -193,20 +243,11 @@ func _apply_shop_styles() -> void:
|
|||
)
|
||||
for button: BaseButton in [
|
||||
%CloseButton,
|
||||
_buy_mode_button,
|
||||
_sell_mode_button,
|
||||
_reel_purchase,
|
||||
_barrier_purchase,
|
||||
_cooler_purchase,
|
||||
_back_to_shop_button,
|
||||
]:
|
||||
UtilityPageStyleType.apply_ocean_button(button)
|
||||
_buy_mode_button.add_theme_stylebox_override(
|
||||
"normal",
|
||||
UtilityPageStyleType.ocean_button_style(
|
||||
UtilityPageStyleType.OCEAN_SELECTED
|
||||
),
|
||||
)
|
||||
_feedback.add_theme_color_override(
|
||||
"font_color", UtilityPageStyleType.OCEAN_TEXT_SECONDARY
|
||||
)
|
||||
|
|
@ -276,7 +317,10 @@ func open_shop() -> bool:
|
|||
or _buyer.id != MAIN_SHOP_BUYER_ID
|
||||
):
|
||||
return false
|
||||
_cancel_close_tween()
|
||||
_close_generation += 1
|
||||
_closing = false
|
||||
modulate.a = 1.0
|
||||
_transaction_in_progress = (
|
||||
_network_shop != null
|
||||
and _network_shop.is_local_purchase_pending()
|
||||
|
|
@ -296,7 +340,7 @@ func open_shop() -> bool:
|
|||
_shop_tab_bar.show()
|
||||
_select_shop_section(ShopSection.UPGRADES, false)
|
||||
_refresh_all()
|
||||
_buy_mode_button.grab_focus()
|
||||
_reel_purchase.grab_focus()
|
||||
menu_visibility_changed.emit(true)
|
||||
return true
|
||||
|
||||
|
|
@ -304,11 +348,13 @@ func open_shop() -> bool:
|
|||
func consume_escape() -> bool:
|
||||
if not visible:
|
||||
return false
|
||||
if _closing:
|
||||
return true
|
||||
if _cooler_page_active:
|
||||
if _cooler_modal_open:
|
||||
shop_cooler_confirmation_cancel_requested.emit()
|
||||
else:
|
||||
shop_cooler_return_requested.emit()
|
||||
_select_shop_section(ShopSection.UPGRADES, true)
|
||||
return true
|
||||
close_shop()
|
||||
return true
|
||||
|
|
@ -319,11 +365,11 @@ func get_shop_cooler_mount() -> Control:
|
|||
|
||||
|
||||
func activate_shop_cooler_page() -> void:
|
||||
_shop_tab_bar.hide()
|
||||
_cooler_page_active = true
|
||||
_shop_panel.hide()
|
||||
_shop_panel.show()
|
||||
_shop_body.hide()
|
||||
_feedback.hide()
|
||||
_shop_cooler_page.show()
|
||||
_back_to_shop_button.disabled = false
|
||||
|
||||
|
||||
func deactivate_shop_cooler_page() -> void:
|
||||
|
|
@ -331,16 +377,18 @@ func deactivate_shop_cooler_page() -> void:
|
|||
_shop_tab_bar.show()
|
||||
_cooler_page_active = false
|
||||
_cooler_modal_open = false
|
||||
_back_to_shop_button.disabled = false
|
||||
for tab: OrganizerTab in _shop_tabs:
|
||||
tab.disabled = false
|
||||
_shop_cooler_page.hide()
|
||||
_shop_panel.show()
|
||||
if visible:
|
||||
_buy_mode_button.grab_focus()
|
||||
_shop_body.show()
|
||||
_feedback.show()
|
||||
|
||||
|
||||
func set_shop_cooler_modal_open(is_open: bool) -> void:
|
||||
_cooler_modal_open = is_open
|
||||
_back_to_shop_button.disabled = is_open
|
||||
for tab: OrganizerTab in _shop_tabs:
|
||||
tab.disabled = is_open
|
||||
|
||||
|
||||
func close_shop(
|
||||
|
|
@ -349,12 +397,47 @@ func close_shop(
|
|||
) -> void:
|
||||
if not visible:
|
||||
return
|
||||
if _closing:
|
||||
if reason in [
|
||||
CloseReason.WATER_RECOVERY,
|
||||
CloseReason.SESSION_END,
|
||||
CloseReason.TEARDOWN,
|
||||
]:
|
||||
_finish_close(reason, restore_controls, _close_generation)
|
||||
return
|
||||
_closing = true
|
||||
_transaction_in_progress = false
|
||||
hide()
|
||||
var current_viewport: Viewport = get_viewport()
|
||||
if current_viewport != null:
|
||||
current_viewport.gui_release_focus()
|
||||
menu_exit_started.emit()
|
||||
_close_generation += 1
|
||||
var generation: int = _close_generation
|
||||
if reason in [CloseReason.USER, CloseReason.RANGE_EXIT]:
|
||||
_close_tween = create_tween()
|
||||
_close_tween.tween_property(
|
||||
self,
|
||||
"modulate:a",
|
||||
0.0,
|
||||
UIMotionType.PLAYER_MENU_EXIT_DURATION,
|
||||
).set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
_close_tween.finished.connect(
|
||||
_finish_close.bind(reason, restore_controls, generation)
|
||||
)
|
||||
return
|
||||
_finish_close(reason, restore_controls, generation)
|
||||
|
||||
|
||||
func _finish_close(
|
||||
reason: CloseReason,
|
||||
restore_controls: bool,
|
||||
generation: int,
|
||||
) -> void:
|
||||
if generation != _close_generation or not visible:
|
||||
return
|
||||
_cancel_close_tween()
|
||||
hide()
|
||||
modulate.a = 1.0
|
||||
if _fishing_spot != null and is_instance_valid(_fishing_spot):
|
||||
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, false)
|
||||
if (
|
||||
|
|
@ -372,6 +455,13 @@ func close_shop(
|
|||
deactivate_shop_cooler_page()
|
||||
|
||||
|
||||
func _cancel_close_tween() -> void:
|
||||
if _close_tween == null:
|
||||
return
|
||||
_close_tween.kill()
|
||||
_close_tween = null
|
||||
|
||||
|
||||
func close_for_range_exit() -> void:
|
||||
close_shop(CloseReason.RANGE_EXIT)
|
||||
|
||||
|
|
@ -404,9 +494,9 @@ func _refresh_all() -> void:
|
|||
|
||||
func _refresh_wallet() -> void:
|
||||
_wallet_label.text = (
|
||||
"wallet: $%d" % _wallet.get_balance()
|
||||
str(_wallet.get_balance())
|
||||
if _wallet != null
|
||||
else "wallet: $0"
|
||||
else "0"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -475,7 +565,7 @@ func _refresh_supplies() -> void:
|
|||
for child: Node in _supplies_list.get_children():
|
||||
_supplies_list.remove_child(child)
|
||||
child.queue_free()
|
||||
if _shop_section == ShopSection.UPGRADES:
|
||||
if _shop_section in [ShopSection.UPGRADES, ShopSection.SELL_FISH]:
|
||||
return
|
||||
_stock_title.text = SHOP_SECTION_LABELS[int(_shop_section)]
|
||||
var stock_item_ids: Array[StringName] = (
|
||||
|
|
@ -493,6 +583,9 @@ func _refresh_supplies() -> void:
|
|||
grouped_item_ids.append(item_id)
|
||||
stock_item_ids = grouped_item_ids
|
||||
var current_stock_group: StringName = StringName()
|
||||
var current_stock_grid: GridContainer
|
||||
if _shop_section in [ShopSection.SNACKS, ShopSection.EQUIPMENT]:
|
||||
current_stock_grid = _add_stock_icon_grid()
|
||||
for item_id: StringName in stock_item_ids:
|
||||
var item: ItemDataType = _item_catalog.get_item_by_id(item_id)
|
||||
if item == null or not _item_belongs_in_current_section(item):
|
||||
|
|
@ -503,10 +596,11 @@ func _refresh_supplies() -> void:
|
|||
)
|
||||
if stock_group != current_stock_group:
|
||||
_add_stock_section(str(stock_group))
|
||||
current_stock_grid = _add_stock_icon_grid()
|
||||
current_stock_group = stock_group
|
||||
var button := Button.new()
|
||||
button.custom_minimum_size = Vector2(195, 54)
|
||||
button.icon = item.icon
|
||||
button.icon = item.icon if item.icon != null else FALLBACK_SUPPLY_ICON
|
||||
button.expand_icon = true
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
var owned: int = _bag.get_quantity(item_id)
|
||||
|
|
@ -520,6 +614,9 @@ func _refresh_supplies() -> void:
|
|||
var total_cost: int = FishingShopStockType.get_purchase_cost(
|
||||
item_id, quantity, bait_unlocked
|
||||
)
|
||||
var use_icon_tile: bool = (
|
||||
current_stock_grid != null
|
||||
)
|
||||
button.text = "%s\n$%d • owned %d" % [
|
||||
item.display_name,
|
||||
FishingShopStockType.get_price(item_id),
|
||||
|
|
@ -527,8 +624,8 @@ func _refresh_supplies() -> void:
|
|||
]
|
||||
var item_tooltip_text: String = item.description
|
||||
if bait_topoff:
|
||||
if item.icon != null:
|
||||
button.custom_minimum_size = Vector2(72, 72)
|
||||
if use_icon_tile:
|
||||
button.custom_minimum_size = SUPPLY_ICON_TILE_SIZE
|
||||
button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
button.text = ""
|
||||
|
|
@ -560,6 +657,17 @@ func _refresh_supplies() -> void:
|
|||
item.description,
|
||||
]
|
||||
)
|
||||
elif use_icon_tile:
|
||||
button.custom_minimum_size = SUPPLY_ICON_TILE_SIZE
|
||||
button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
button.text = ""
|
||||
item_tooltip_text = "%s\n$%d • owned %d\n%s" % [
|
||||
item.display_name,
|
||||
FishingShopStockType.get_price(item_id),
|
||||
owned,
|
||||
item.description,
|
||||
]
|
||||
button.disabled = (
|
||||
_transaction_in_progress
|
||||
or _closing
|
||||
|
|
@ -577,19 +685,30 @@ func _refresh_supplies() -> void:
|
|||
)
|
||||
UtilityPageStyleType.apply_ocean_button(button)
|
||||
button.pressed.connect(_purchase_supply.bind(item_id))
|
||||
_supplies_list.add_child(button)
|
||||
if current_stock_grid != null:
|
||||
_add_supply_icon_tile(
|
||||
current_stock_grid,
|
||||
button,
|
||||
FishingShopStockType.get_price(item_id),
|
||||
)
|
||||
else:
|
||||
_supplies_list.add_child(button)
|
||||
if _shop_section == ShopSection.ART_SUPPLIES:
|
||||
_add_stock_section("art kit")
|
||||
_add_art_kit_button()
|
||||
var art_kit_grid := _add_stock_icon_grid()
|
||||
_add_art_kit_button(art_kit_grid)
|
||||
_add_stock_section("markers")
|
||||
var marker_grid := _add_stock_icon_grid()
|
||||
for product_id: StringName in ArtShopStockType.MARKER_PRODUCTS:
|
||||
_add_art_upgrade_button(product_id)
|
||||
_add_art_upgrade_button(product_id, marker_grid)
|
||||
_add_stock_section("brushes")
|
||||
var brush_grid := _add_stock_icon_grid()
|
||||
for product_id: StringName in ArtShopStockType.BRUSH_PRODUCTS:
|
||||
_add_art_upgrade_button(product_id)
|
||||
_add_art_upgrade_button(product_id, brush_grid)
|
||||
_add_stock_section("grids")
|
||||
var canvas_grid := _add_stock_icon_grid()
|
||||
for product_id: StringName in ArtShopStockType.GRID_PRODUCTS:
|
||||
_add_art_upgrade_button(product_id)
|
||||
_add_art_upgrade_button(product_id, canvas_grid)
|
||||
|
||||
|
||||
func _item_belongs_in_current_section(item: ItemDataType) -> bool:
|
||||
|
|
@ -613,7 +732,21 @@ func _add_stock_section(title: String) -> void:
|
|||
_supplies_list.add_child(label)
|
||||
|
||||
|
||||
func _add_art_kit_button() -> void:
|
||||
func _add_stock_icon_grid() -> GridContainer:
|
||||
var grid := GridContainer.new()
|
||||
grid.columns = SUPPLY_ICON_GRID_COLUMNS
|
||||
grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
grid.add_theme_constant_override(
|
||||
"h_separation", SUPPLY_ICON_GRID_SEPARATION
|
||||
)
|
||||
grid.add_theme_constant_override(
|
||||
"v_separation", SUPPLY_ICON_GRID_SEPARATION
|
||||
)
|
||||
_supplies_list.add_child(grid)
|
||||
return grid
|
||||
|
||||
|
||||
func _add_art_kit_button(parent: GridContainer) -> void:
|
||||
var item: ItemDataType = _item_catalog.get_item_by_id(
|
||||
ArtShopStockType.ART_KIT_ITEM_ID
|
||||
)
|
||||
|
|
@ -626,10 +759,19 @@ func _add_art_kit_button() -> void:
|
|||
ArtShopStockType.ART_KIT_PRICE,
|
||||
"owned" if owned else "not owned",
|
||||
],
|
||||
item.description,
|
||||
"%s\n$%d • %s\n%s" % [
|
||||
item.display_name,
|
||||
ArtShopStockType.ART_KIT_PRICE,
|
||||
"owned" if owned else "not owned",
|
||||
item.description,
|
||||
],
|
||||
)
|
||||
_configure_supply_icon_tile(button, item.icon)
|
||||
_add_supply_icon_tile(
|
||||
parent,
|
||||
button,
|
||||
ArtShopStockType.ART_KIT_PRICE,
|
||||
)
|
||||
button.icon = item.icon
|
||||
button.expand_icon = true
|
||||
button.disabled = (
|
||||
owned
|
||||
or _transaction_in_progress
|
||||
|
|
@ -642,7 +784,10 @@ func _add_art_kit_button() -> void:
|
|||
button.pressed.connect(_purchase_art_kit)
|
||||
|
||||
|
||||
func _add_art_upgrade_button(product_id: StringName) -> void:
|
||||
func _add_art_upgrade_button(
|
||||
product_id: StringName,
|
||||
parent: GridContainer,
|
||||
) -> void:
|
||||
var kit_owned: bool = (
|
||||
_bag.get_quantity(ArtShopStockType.ART_KIT_ITEM_ID) > 0
|
||||
)
|
||||
|
|
@ -653,7 +798,18 @@ func _add_art_upgrade_button(product_id: StringName) -> void:
|
|||
ArtShopStockType.UPGRADE_PRICE,
|
||||
"unlocked" if unlocked else "locked",
|
||||
],
|
||||
ArtShopStockType.get_description(product_id),
|
||||
"%s\n$%d • %s\n%s" % [
|
||||
ArtShopStockType.get_display_name(product_id),
|
||||
ArtShopStockType.UPGRADE_PRICE,
|
||||
"unlocked" if unlocked else "locked",
|
||||
ArtShopStockType.get_description(product_id),
|
||||
],
|
||||
)
|
||||
_configure_supply_icon_tile(button, FALLBACK_SUPPLY_ICON)
|
||||
_add_supply_icon_tile(
|
||||
parent,
|
||||
button,
|
||||
ArtShopStockType.UPGRADE_PRICE,
|
||||
)
|
||||
button.disabled = (
|
||||
not kit_owned
|
||||
|
|
@ -667,17 +823,92 @@ func _add_art_upgrade_button(product_id: StringName) -> void:
|
|||
button.pressed.connect(_purchase_art_upgrade.bind(product_id))
|
||||
|
||||
|
||||
func _make_stock_button(button_text: String, tooltip: String) -> Button:
|
||||
func _make_stock_button(
|
||||
button_text: String,
|
||||
tooltip: String,
|
||||
) -> Button:
|
||||
var button := Button.new()
|
||||
button.custom_minimum_size = Vector2(195, 54)
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
button.text = button_text
|
||||
button.tooltip_text = tooltip
|
||||
UtilityPageStyleType.apply_ocean_button(button)
|
||||
_supplies_list.add_child(button)
|
||||
return button
|
||||
|
||||
|
||||
func _configure_supply_icon_tile(
|
||||
button: Button,
|
||||
icon: Texture2D,
|
||||
) -> void:
|
||||
button.custom_minimum_size = SUPPLY_ICON_TILE_SIZE
|
||||
button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
button.icon = icon if icon != null else FALLBACK_SUPPLY_ICON
|
||||
button.expand_icon = true
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
button.text = ""
|
||||
|
||||
|
||||
func _add_supply_icon_tile(
|
||||
parent: GridContainer,
|
||||
button: Button,
|
||||
price: int,
|
||||
) -> void:
|
||||
var tile_host := Control.new()
|
||||
tile_host.custom_minimum_size = SUPPLY_ICON_HOST_SIZE
|
||||
tile_host.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
parent.add_child(tile_host)
|
||||
button.position = Vector2.ZERO
|
||||
button.size = SUPPLY_ICON_TILE_SIZE
|
||||
tile_host.add_child(button)
|
||||
var price_text := "$%d" % price
|
||||
var price_text_width: float = UtilityPageStyleType.TuffyFont.get_string_size(
|
||||
price_text,
|
||||
HORIZONTAL_ALIGNMENT_LEFT,
|
||||
-1.0,
|
||||
SUPPLY_PRICE_FONT_SIZE,
|
||||
).x
|
||||
var price_width: float = minf(
|
||||
SUPPLY_ICON_TILE_SIZE.x,
|
||||
ceilf(price_text_width + SUPPLY_PRICE_HORIZONTAL_PADDING),
|
||||
)
|
||||
var price_bubble := PanelContainer.new()
|
||||
price_bubble.name = "PriceBubble"
|
||||
price_bubble.position = Vector2(
|
||||
(SUPPLY_ICON_TILE_SIZE.x - price_width) * 0.5,
|
||||
SUPPLY_PRICE_Y,
|
||||
)
|
||||
price_bubble.size = Vector2(price_width, SUPPLY_PRICE_HEIGHT)
|
||||
price_bubble.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
price_bubble.z_index = 2
|
||||
var price_style := UtilityPageStyleType.rounded_style(
|
||||
UtilityPageStyleType.OCEAN_FIELD,
|
||||
12,
|
||||
)
|
||||
price_style.content_margin_left = 6.0
|
||||
price_style.content_margin_right = 6.0
|
||||
price_style.content_margin_top = 0.0
|
||||
price_style.content_margin_bottom = 0.0
|
||||
price_bubble.add_theme_stylebox_override("panel", price_style)
|
||||
tile_host.add_child(price_bubble)
|
||||
var price_label := Label.new()
|
||||
price_label.name = "Price"
|
||||
price_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
price_label.text = price_text
|
||||
price_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
price_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
price_label.add_theme_font_override(
|
||||
"font", UtilityPageStyleType.TuffyFont
|
||||
)
|
||||
price_label.add_theme_font_size_override(
|
||||
"font_size", SUPPLY_PRICE_FONT_SIZE
|
||||
)
|
||||
price_label.add_theme_color_override(
|
||||
"font_color", SUPPLY_PRICE_COLOR
|
||||
)
|
||||
price_label.add_theme_constant_override("outline_size", 0)
|
||||
price_bubble.add_child(price_label)
|
||||
|
||||
|
||||
func _refresh_cooler_capacity() -> void:
|
||||
if _cooler_capacity == null:
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue