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
|
|
@ -7,7 +7,7 @@ const SPEECH_SECONDS: float = 6.0
|
|||
const DRAFT_SAVE_DELAY: float = 0.4
|
||||
const IDLE_ALPHA: float = 0.58
|
||||
const CHAT_SURFACE_COLOR := Color(0.025, 0.13, 0.19, 0.94)
|
||||
const PANEL_WIDTH: float = 270.0
|
||||
const PANEL_WIDTH: float = 290.0
|
||||
const COMPACT_HEIGHT: float = 250.0
|
||||
const BOTTOM_MARGIN: float = 12.0
|
||||
const EXPANDED_TOP_MARGIN: float = 94.0
|
||||
|
|
@ -31,9 +31,10 @@ const MOBILE_EXPANDED_WIDTH: float = 820.0
|
|||
const MOBILE_COMPACT_HEIGHT: float = 220.0
|
||||
const MOBILE_EXPANDED_HEIGHT: float = 390.0
|
||||
const MOBILE_EDGE_MARGIN: float = 12.0
|
||||
const CLOCK_SIZE := Vector2(116.0, 34.0)
|
||||
const CLOCK_SIZE := Vector2(174.0, 51.0)
|
||||
const CLOCK_FONT_SIZE: int = 27
|
||||
const CLOCK_EDGE_MARGIN: float = 10.0
|
||||
const WEATHER_ICON_SIZE := Vector2(34.0, 34.0)
|
||||
const WEATHER_ICON_SIZE := Vector2(51.0, 51.0)
|
||||
const WEATHER_ICON_GAP: float = 6.0
|
||||
const FISH_FINDER_EFFECT_ICON_SIZE := Vector2(18.0, 18.0)
|
||||
const FISH_FINDER_EFFECT_ICON: Texture2D = preload(
|
||||
|
|
@ -383,7 +384,7 @@ func _build_ui() -> void:
|
|||
_clock_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
_clock_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_clock_label.add_theme_font_override("font", UtilityPageStyle.TuffyFont)
|
||||
_clock_label.add_theme_font_size_override("font_size", 18)
|
||||
_clock_label.add_theme_font_size_override("font_size", CLOCK_FONT_SIZE)
|
||||
_clock_label.add_theme_color_override(
|
||||
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=7 format=3]
|
||||
[gd_scene load_steps=8 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/fishing_shop.gd" id="1_script"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"]
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
[ext_resource type="Texture2D" path="res://items/icons/shop/64_power_plus.png" id="4_barrier"]
|
||||
[ext_resource type="Texture2D" path="res://items/icons/placeholder/fish_coin.svg" id="5_coin"]
|
||||
[ext_resource type="Texture2D" path="res://items/icons/equipment/64_cooler_plus.png" id="6_cooler"]
|
||||
[ext_resource type="Texture2D" path="res://ui/icons/pictograms/x_light.png" id="7_close"]
|
||||
|
||||
[node name="FishingShop" type="Control"]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -34,7 +35,7 @@ mouse_filter = 0
|
|||
[node name="ShopCoolerPage" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
z_index = 90
|
||||
z_index = 102
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -53,18 +54,8 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="BackToShopButton" type="Button" parent="ShopCoolerPage"]
|
||||
unique_name_in_owner = true
|
||||
z_index = 110
|
||||
layout_mode = 0
|
||||
offset_left = 1052.0
|
||||
offset_top = 54.0
|
||||
offset_right = 1218.0
|
||||
offset_bottom = 104.0
|
||||
text = "back to shop"
|
||||
|
||||
[node name="ShopPanel" type="PanelContainer" parent="."]
|
||||
z_index = 2
|
||||
z_index = 101
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
|
|
@ -101,41 +92,39 @@ text = "fishing shop"
|
|||
theme_override_font_sizes/font_size = 32
|
||||
theme_override_colors/font_color = Color(0.208, 0.725, 0.78, 1)
|
||||
|
||||
[node name="CoinIcon" type="TextureRect" parent="ShopPanel/Margin/Layout/Header"]
|
||||
custom_minimum_size = Vector2(24, 24)
|
||||
[node name="BalanceDisplay" type="HBoxContainer" parent="ShopPanel/Margin/Layout/Header"]
|
||||
custom_minimum_size = Vector2(0, 48)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 6
|
||||
alignment = 1
|
||||
|
||||
[node name="CoinIcon" type="TextureRect" parent="ShopPanel/Margin/Layout/Header/BalanceDisplay"]
|
||||
custom_minimum_size = Vector2(26, 26)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
texture = ExtResource("5_coin")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
texture_filter = 1
|
||||
|
||||
[node name="WalletLabel" type="Label" parent="ShopPanel/Margin/Layout/Header"]
|
||||
[node name="WalletLabel" type="Label" parent="ShopPanel/Margin/Layout/Header/BalanceDisplay"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
layout_mode = 2
|
||||
text = "wallet: $0"
|
||||
size_flags_vertical = 4
|
||||
text = "0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="CloseButton" type="Button" parent="ShopPanel/Margin/Layout/Header"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(48, 48)
|
||||
layout_mode = 2
|
||||
text = "close"
|
||||
custom_minimum_size = Vector2(104, 48)
|
||||
|
||||
[node name="ModeTabs" type="HBoxContainer" parent="ShopPanel/Margin/Layout"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="BuyModeButton" type="Button" parent="ShopPanel/Margin/Layout/ModeTabs"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(180, 42)
|
||||
layout_mode = 2
|
||||
text = "buy gear & supplies"
|
||||
|
||||
[node name="SellModeButton" type="Button" parent="ShopPanel/Margin/Layout/ModeTabs"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(180, 42)
|
||||
layout_mode = 2
|
||||
text = "sell fish"
|
||||
tooltip_text = "Close shop"
|
||||
flat = true
|
||||
icon = ExtResource("7_close")
|
||||
expand_icon = true
|
||||
icon_max_width = 40
|
||||
|
||||
[node name="Feedback" type="Label" parent="ShopPanel/Margin/Layout"]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -146,10 +135,10 @@ theme_override_colors/font_color = Color(1, 0.82, 0.4, 1)
|
|||
|
||||
[node name="ShopTabBar" type="HBoxContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
z_index = 1
|
||||
offset_left = 298.0
|
||||
z_index = 100
|
||||
offset_left = 180.0
|
||||
offset_top = 26.0
|
||||
offset_right = 982.0
|
||||
offset_right = 1100.0
|
||||
offset_bottom = 70.0
|
||||
alignment = 1
|
||||
theme_override_constants/separation = 6
|
||||
|
|
|
|||
|
|
@ -144,6 +144,17 @@ corner_radius_top_right = 10
|
|||
corner_radius_bottom_right = 10
|
||||
corner_radius_bottom_left = 10
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="TooltipPanel"]
|
||||
content_margin_left = 12.0
|
||||
content_margin_top = 8.0
|
||||
content_margin_right = 12.0
|
||||
content_margin_bottom = 8.0
|
||||
bg_color = Color(0.031, 0.122, 0.169, 1)
|
||||
corner_radius_top_left = 10
|
||||
corner_radius_top_right = 10
|
||||
corner_radius_bottom_right = 10
|
||||
corner_radius_bottom_left = 10
|
||||
|
||||
[resource]
|
||||
default_font = ExtResource("1_font")
|
||||
default_font_size = 23
|
||||
|
|
@ -175,3 +186,6 @@ OptionButton/styles/hover = SubResource("ButtonHover")
|
|||
OptionButton/styles/normal = SubResource("ButtonNormal")
|
||||
OptionButton/styles/pressed = SubResource("ButtonPressed")
|
||||
PanelContainer/styles/panel = SubResource("Panel")
|
||||
TooltipLabel/colors/font_color = Color(0.765, 0.875, 0.902, 1)
|
||||
TooltipLabel/font_sizes/font_size = 18
|
||||
TooltipPanel/styles/panel = SubResource("TooltipPanel")
|
||||
|
|
|
|||
|
|
@ -402,6 +402,7 @@ func setup(
|
|||
network_shop_service,
|
||||
)
|
||||
_fishing_shop.menu_visibility_changed.connect(_on_shop_visibility_changed)
|
||||
_fishing_shop.menu_exit_started.connect(_on_shop_exit_started)
|
||||
_fishing_shop.sell_fish_requested.connect(_on_shop_sell_fish_requested)
|
||||
_fishing_shop.shop_cooler_return_requested.connect(
|
||||
_on_shop_cooler_return_requested
|
||||
|
|
@ -528,8 +529,11 @@ func _on_character_call_received(
|
|||
if _spawn_service == null:
|
||||
return
|
||||
var avatar: PlayerType = _spawn_service.get_avatar(peer_id)
|
||||
if avatar == null:
|
||||
return
|
||||
avatar.play_character_call_visual()
|
||||
var audio_path: String = VoiceProfilesType.call_audio_path(call_id)
|
||||
if avatar == null or not ResourceLoader.exists(audio_path, "AudioStream"):
|
||||
if not ResourceLoader.exists(audio_path, "AudioStream"):
|
||||
return
|
||||
var stream: AudioStream = load(audio_path) as AudioStream
|
||||
if stream == null:
|
||||
|
|
@ -2088,11 +2092,18 @@ func _on_player_menu_exit_started() -> void:
|
|||
player_menu_backdrop_visibility_changed.emit(false)
|
||||
|
||||
|
||||
func _on_shop_exit_started() -> void:
|
||||
if not _shop_open:
|
||||
return
|
||||
shop_backdrop_visibility_changed.emit(false)
|
||||
|
||||
|
||||
func _on_shop_visibility_changed(is_open: bool) -> void:
|
||||
_shop_open = is_open
|
||||
if is_open and _surface_drawing != null:
|
||||
_surface_drawing.deactivate()
|
||||
shop_backdrop_visibility_changed.emit(is_open)
|
||||
if is_open:
|
||||
shop_backdrop_visibility_changed.emit(true)
|
||||
if not is_open and _player_menu.is_shop_cooler_mounted():
|
||||
_player_menu.unmount_shop_cooler()
|
||||
_refresh_chat_availability()
|
||||
|
|
|
|||
27
ui/hotbar.gd
27
ui/hotbar.gd
|
|
@ -17,7 +17,7 @@ const FishingSpotType = preload("res://fishing/fishing_spot.gd")
|
|||
|
||||
const DESKTOP_REFERENCE_SIZE := Vector2(1280.0, 720.0)
|
||||
const COMPACT_REFERENCE_SIZE := Vector2(640.0, 480.0)
|
||||
const HOTBAR_PRESENTATION_SCALE: float = 1.00
|
||||
const HOTBAR_PRESENTATION_SCALE: float = 0.80
|
||||
const HOTBAR_CANONICAL_POSITION := Vector2.ZERO
|
||||
const HOTBAR_MENU_POSITION := Vector2(-136.0, -90.0)
|
||||
const HOTBAR_GAMEPLAY_Z_INDEX: int = 35
|
||||
|
|
@ -215,9 +215,7 @@ func set_player_menu_context(enabled: bool) -> void:
|
|||
return
|
||||
_player_menu_context = enabled
|
||||
z_index = HOTBAR_MENU_Z_INDEX if enabled else HOTBAR_GAMEPLAY_Z_INDEX
|
||||
_presentation_scale_root.position = (
|
||||
HOTBAR_MENU_POSITION if enabled else HOTBAR_CANONICAL_POSITION
|
||||
)
|
||||
_presentation_scale_root.position = _presentation_position()
|
||||
|
||||
|
||||
func set_presentation_visible(
|
||||
|
|
@ -363,11 +361,7 @@ func _apply_layout() -> void:
|
|||
_presentation_scale_root.scale = (
|
||||
Vector2.ONE * HOTBAR_PRESENTATION_SCALE
|
||||
)
|
||||
_presentation_scale_root.position = (
|
||||
HOTBAR_MENU_POSITION
|
||||
if _player_menu_context
|
||||
else HOTBAR_CANONICAL_POSITION
|
||||
)
|
||||
_presentation_scale_root.position = _presentation_position()
|
||||
var field_size := (
|
||||
Vector2(580.0, 82.0)
|
||||
if _compact_layout
|
||||
|
|
@ -382,6 +376,21 @@ func _apply_layout() -> void:
|
|||
slot.apply_layout(_compact_layout)
|
||||
|
||||
|
||||
func _presentation_position() -> Vector2:
|
||||
var scaled_size: Vector2 = (
|
||||
DESKTOP_REFERENCE_SIZE * HOTBAR_PRESENTATION_SCALE
|
||||
)
|
||||
var bottom_centered_offset := Vector2(
|
||||
(DESKTOP_REFERENCE_SIZE.x - scaled_size.x) * 0.5,
|
||||
DESKTOP_REFERENCE_SIZE.y - scaled_size.y,
|
||||
)
|
||||
return bottom_centered_offset + (
|
||||
HOTBAR_MENU_POSITION
|
||||
if _player_menu_context
|
||||
else HOTBAR_CANONICAL_POSITION
|
||||
)
|
||||
|
||||
|
||||
func _refresh() -> void:
|
||||
for slot: BubbleHotbarSlotType in _slots:
|
||||
slot.refresh()
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ const DIRECT_WORKFLOW_HELP: String = (
|
|||
@onready var _delete_button: Button = %DeleteButton
|
||||
@onready var _cancel_button: Button = %CancelButton
|
||||
@onready var _back_button: Button = %BackButton
|
||||
@onready var _open_close_button: Button = %OpenCloseButton
|
||||
@onready var _status: Label = %Status
|
||||
@onready var _session_summary: Label = %SessionSummary
|
||||
@onready var _delete_confirmation: BubbleConfirmationPage = (
|
||||
|
|
@ -75,7 +74,7 @@ func _ready() -> void:
|
|||
_discover_button, _direct_button, _saved_button, _recent_button,
|
||||
_refresh_button, _join_button,
|
||||
_save_button, _edit_button, _favorite_button, _delete_button,
|
||||
_cancel_button, _back_button, _open_close_button,
|
||||
_cancel_button, _back_button,
|
||||
]:
|
||||
UtilityPageStyle.apply_ocean_button(button)
|
||||
UtilityPageStyle.apply_ocean_line_edit(_address)
|
||||
|
|
@ -92,7 +91,6 @@ func _ready() -> void:
|
|||
_delete_button.pressed.connect(_on_delete_pressed)
|
||||
_cancel_button.pressed.connect(_on_cancel_pressed)
|
||||
_back_button.pressed.connect(_on_back_pressed)
|
||||
_open_close_button.pressed.connect(_on_open_close_pressed)
|
||||
_address.text_submitted.connect(func(_value: String) -> void:
|
||||
if _name_entry_active:
|
||||
_name_edit.grab_focus()
|
||||
|
|
@ -235,6 +233,9 @@ func _request_join() -> void:
|
|||
var endpoint_text: String = _address.text
|
||||
if _mode == Mode.DISCOVER:
|
||||
var room: Dictionary = _selected_discovery_room()
|
||||
if _discovery != null and _discovery.is_own_room(room):
|
||||
_set_status("You are already hosting this room.", true)
|
||||
return
|
||||
if _discovery_room_is_full(room):
|
||||
_set_status("That room is full.", true)
|
||||
return
|
||||
|
|
@ -441,12 +442,16 @@ func _refresh_entries() -> void:
|
|||
for room: Dictionary in _discovery_rooms:
|
||||
var player_count: int = int(room.get("current_players", 0))
|
||||
var maximum: int = int(room.get("max_players", 0))
|
||||
var own_room: bool = (
|
||||
_discovery != null and _discovery.is_own_room(room)
|
||||
)
|
||||
_server_list.add_item(
|
||||
"%s — %d / %d players%s" % [
|
||||
"%s — %d / %d players%s%s" % [
|
||||
str(room.get("room_name", "Public room")),
|
||||
player_count,
|
||||
maximum,
|
||||
" — full" if player_count >= maximum else "",
|
||||
" — your room" if own_room else "",
|
||||
]
|
||||
)
|
||||
return
|
||||
|
|
@ -517,6 +522,12 @@ func _refresh() -> void:
|
|||
and selected
|
||||
and _discovery_room_is_full(_selected_discovery_room())
|
||||
)
|
||||
or (
|
||||
discovery_mode
|
||||
and selected
|
||||
and _discovery != null
|
||||
and _discovery.is_own_room(_selected_discovery_room())
|
||||
)
|
||||
)
|
||||
_join_button.text = "join\nnow" if direct else "join"
|
||||
_refresh_button.visible = discovery_mode and not _name_entry_active
|
||||
|
|
@ -541,15 +552,6 @@ func _refresh() -> void:
|
|||
)
|
||||
_delete_button.text = "remove" if _mode == Mode.RECENT else "delete"
|
||||
_cancel_button.visible = connecting
|
||||
_open_close_button.visible = (
|
||||
_gameplay_context and _network_session.is_host()
|
||||
)
|
||||
if _open_close_button.visible:
|
||||
_open_close_button.text = (
|
||||
"close\ngame"
|
||||
if _network_session.is_open_host()
|
||||
else "open\ngame"
|
||||
)
|
||||
_session_summary.visible = (
|
||||
_gameplay_context
|
||||
and _network_session.state != NetworkSession.State.INACTIVE
|
||||
|
|
@ -647,7 +649,7 @@ func _format_entry_details(entry: SavedServerEntry) -> String:
|
|||
func _format_discovery_details(room: Dictionary) -> String:
|
||||
if room.is_empty():
|
||||
return "Select a public room."
|
||||
return "\n".join([
|
||||
var lines: Array[String] = [
|
||||
"Room: %s" % str(room.get("room_name", "Public room")),
|
||||
"Players: %d / %d" % [
|
||||
int(room.get("current_players", 0)),
|
||||
|
|
@ -657,7 +659,10 @@ func _format_discovery_details(room: Dictionary) -> String:
|
|||
_discovery.room_endpoint(room) if _discovery != null else "—"
|
||||
),
|
||||
"Direct UDP connection • ping is measured after joining",
|
||||
])
|
||||
]
|
||||
if _discovery != null and _discovery.is_own_room(room):
|
||||
lines.append("This is the room you are currently hosting.")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
func _selected_discovery_room() -> Dictionary:
|
||||
|
|
@ -785,13 +790,6 @@ func _on_back_pressed() -> void:
|
|||
back_requested.emit()
|
||||
|
||||
|
||||
func _on_open_close_pressed() -> void:
|
||||
if _network_session == null or not _network_session.is_host():
|
||||
return
|
||||
_network_session.set_host_open(not _network_session.is_open_host())
|
||||
_refresh()
|
||||
|
||||
|
||||
func _on_state_changed(_state: NetworkSession.State) -> void:
|
||||
_refresh()
|
||||
|
||||
|
|
|
|||
|
|
@ -308,13 +308,6 @@ custom_minimum_size = Vector2(82, 68)
|
|||
layout_mode = 2
|
||||
text = "delete"
|
||||
|
||||
[node name="OpenCloseButton" type="Button" parent="Paper/Margin/Layout/Actions"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(88, 72)
|
||||
layout_mode = 2
|
||||
text = "open\ngame"
|
||||
|
||||
[node name="CancelButton" type="Button" parent="Paper/Margin/Layout/Actions"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
class_name PlayersPage
|
||||
extends Control
|
||||
|
||||
const TOGGLE_STATE_COLOR := Color("c3dfe6")
|
||||
|
||||
var _service: NetworkPlayerListService
|
||||
var _discovery: DiscoveryClient
|
||||
var _count_label: Label
|
||||
|
|
@ -9,7 +11,10 @@ var _list: VBoxContainer
|
|||
var _status: Label
|
||||
var _host_settings_panel: PanelContainer
|
||||
var _room_name_edit: LineEdit
|
||||
var _discoverable_toggle: CheckButton
|
||||
var _online_toggle: Button
|
||||
var _online_state_label: Label
|
||||
var _discoverable_toggle: Button
|
||||
var _discoverable_state_label: Label
|
||||
var _host_discovery_status: Label
|
||||
var _current_tab := 0
|
||||
|
||||
|
|
@ -111,21 +116,26 @@ func _build_host_settings(root: VBoxContainer) -> void:
|
|||
_room_name_edit = LineEdit.new()
|
||||
_room_name_edit.custom_minimum_size = Vector2(300.0, 42.0)
|
||||
_room_name_edit.max_length = DiscoveryClient.MAX_ROOM_NAME_LENGTH
|
||||
_room_name_edit.placeholder_text = DiscoveryClient.DEFAULT_ROOM_NAME
|
||||
_room_name_edit.placeholder_text = "Player Name's Server"
|
||||
UtilityPageStyle.apply_ocean_line_edit(_room_name_edit)
|
||||
_room_name_edit.text_submitted.connect(
|
||||
func(_value: String) -> void: _commit_room_name()
|
||||
)
|
||||
_room_name_edit.focus_exited.connect(_commit_room_name)
|
||||
row.add_child(_room_name_edit)
|
||||
_discoverable_toggle = CheckButton.new()
|
||||
_discoverable_toggle.text = "list publicly"
|
||||
_discoverable_toggle.toggled.connect(_on_discoverable_toggled)
|
||||
UtilityPageStyle.apply_ocean_button(_discoverable_toggle)
|
||||
row.add_child(_discoverable_toggle)
|
||||
_online_toggle = _build_host_toggle("online", row)
|
||||
_online_state_label = _online_toggle.get_node("StateBadge/State") as Label
|
||||
_online_toggle.pressed.connect(_on_online_pressed)
|
||||
_discoverable_toggle = _build_host_toggle("discovery", row)
|
||||
_discoverable_state_label = (
|
||||
_discoverable_toggle.get_node("StateBadge/State") as Label
|
||||
)
|
||||
_discoverable_toggle.pressed.connect(_on_discoverable_pressed)
|
||||
_host_discovery_status = Label.new()
|
||||
_host_discovery_status.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
_host_discovery_status.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
_host_discovery_status.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_host_discovery_status.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
_host_discovery_status.add_theme_font_size_override("font_size", 14)
|
||||
_host_discovery_status.add_theme_color_override(
|
||||
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
|
||||
|
|
@ -133,6 +143,56 @@ func _build_host_settings(root: VBoxContainer) -> void:
|
|||
row.add_child(_host_discovery_status)
|
||||
|
||||
|
||||
func _build_host_toggle(label_text: String, row: HBoxContainer) -> Button:
|
||||
var button := Button.new()
|
||||
button.custom_minimum_size = Vector2(150.0, 46.0)
|
||||
button.text = label_text
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
button.clip_contents = false
|
||||
UtilityPageStyle.apply_ocean_button(button)
|
||||
row.add_child(button)
|
||||
var badge := PanelContainer.new()
|
||||
badge.name = "StateBadge"
|
||||
badge.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
badge.z_index = 2
|
||||
button.add_child(badge)
|
||||
badge.set_anchors_preset(Control.PRESET_CENTER_BOTTOM)
|
||||
badge.offset_left = -39.0
|
||||
badge.offset_top = -12.0
|
||||
badge.offset_right = 39.0
|
||||
badge.offset_bottom = 12.0
|
||||
var state_label := Label.new()
|
||||
state_label.name = "State"
|
||||
state_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
state_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
state_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
state_label.add_theme_font_override("font", UtilityPageStyle.TuffyFont)
|
||||
state_label.add_theme_font_size_override("font_size", 15)
|
||||
state_label.add_theme_color_override("font_color", TOGGLE_STATE_COLOR)
|
||||
badge.add_child(state_label)
|
||||
return button
|
||||
|
||||
|
||||
func _set_host_toggle_state(
|
||||
button: Button,
|
||||
state_label: Label,
|
||||
state_text: String,
|
||||
enabled: bool,
|
||||
) -> void:
|
||||
state_label.text = state_text
|
||||
var badge := state_label.get_parent() as PanelContainer
|
||||
badge.add_theme_stylebox_override(
|
||||
"panel",
|
||||
UtilityPageStyle.rounded_style(
|
||||
UtilityPageStyle.OCEAN_SELECTED
|
||||
if enabled
|
||||
else UtilityPageStyle.OCEAN_FIELD,
|
||||
12,
|
||||
),
|
||||
)
|
||||
button.queue_redraw()
|
||||
|
||||
|
||||
func _select_tab(index: int) -> void:
|
||||
if index == 2 and (_service == null or not _service.is_local_host()):
|
||||
return
|
||||
|
|
@ -172,17 +232,38 @@ func _refresh_host_settings() -> void:
|
|||
return
|
||||
if not _room_name_edit.has_focus():
|
||||
_room_name_edit.text = _discovery.get_room_name()
|
||||
_discoverable_toggle.set_pressed_no_signal(_discovery.is_discoverable())
|
||||
var is_open: bool = _service.is_open_host()
|
||||
var is_discoverable: bool = _discovery.is_discoverable()
|
||||
_set_host_toggle_state(
|
||||
_online_toggle,
|
||||
_online_state_label,
|
||||
"OPEN" if is_open else "CLOSED",
|
||||
is_open,
|
||||
)
|
||||
_set_host_toggle_state(
|
||||
_discoverable_toggle,
|
||||
_discoverable_state_label,
|
||||
"ON" if is_discoverable else "OFF",
|
||||
is_discoverable,
|
||||
)
|
||||
_online_toggle.disabled = not _service.is_local_host()
|
||||
_online_toggle.tooltip_text = (
|
||||
"Close this game to new connections."
|
||||
if is_open
|
||||
else "Open this game so other players can connect."
|
||||
)
|
||||
var can_publish: bool = (
|
||||
_service.is_local_host()
|
||||
and _discovery.is_configured()
|
||||
and _service.is_open_host()
|
||||
and is_open
|
||||
)
|
||||
_discoverable_toggle.disabled = not can_publish
|
||||
_discoverable_toggle.tooltip_text = (
|
||||
"Advertise this open game in the public room browser."
|
||||
"Stop advertising this game in the public room browser."
|
||||
if is_discoverable
|
||||
else "Advertise this open game in the public room browser."
|
||||
if can_publish
|
||||
else "Open the game before listing it publicly."
|
||||
else "Open the game before enabling discovery."
|
||||
if _discovery.is_configured()
|
||||
else "Room discovery is not configured in this build."
|
||||
)
|
||||
|
|
@ -201,13 +282,18 @@ func _commit_room_name() -> void:
|
|||
_room_name_edit.text = _discovery.get_room_name()
|
||||
|
||||
|
||||
func _on_discoverable_toggled(enabled: bool) -> void:
|
||||
func _on_online_pressed() -> void:
|
||||
if _service == null or not _service.is_local_host():
|
||||
return
|
||||
_service.set_host_open(not _service.is_open_host())
|
||||
_refresh_host_settings()
|
||||
|
||||
|
||||
func _on_discoverable_pressed() -> void:
|
||||
if _discovery == null:
|
||||
return
|
||||
if not _discovery.set_discoverable(enabled):
|
||||
_discoverable_toggle.set_pressed_no_signal(
|
||||
_discovery.is_discoverable()
|
||||
)
|
||||
_discovery.set_discoverable(not _discovery.is_discoverable())
|
||||
_refresh_host_settings()
|
||||
|
||||
|
||||
func _on_host_settings_changed(
|
||||
|
|
@ -216,15 +302,25 @@ func _on_host_settings_changed(
|
|||
) -> void:
|
||||
if _room_name_edit != null and not _room_name_edit.has_focus():
|
||||
_room_name_edit.text = room_name
|
||||
if _discoverable_toggle != null:
|
||||
_discoverable_toggle.set_pressed_no_signal(discoverable)
|
||||
if _discoverable_state_label != null:
|
||||
_set_host_toggle_state(
|
||||
_discoverable_toggle,
|
||||
_discoverable_state_label,
|
||||
"ON" if discoverable else "OFF",
|
||||
discoverable,
|
||||
)
|
||||
_refresh_host_settings()
|
||||
|
||||
|
||||
func _on_host_status_changed(message: String, is_error: bool) -> void:
|
||||
if _host_discovery_status == null:
|
||||
return
|
||||
_host_discovery_status.text = message
|
||||
var tooltip_only: bool = message in [
|
||||
"Open the game before listing it publicly.",
|
||||
"Open the game before enabling discovery.",
|
||||
]
|
||||
_host_discovery_status.text = "" if tooltip_only else message
|
||||
_host_discovery_status.visible = not _host_discovery_status.text.is_empty()
|
||||
_host_discovery_status.add_theme_color_override(
|
||||
"font_color",
|
||||
UtilityPageStyle.OCEAN_DANGER
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func _ready() -> void:
|
|||
mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
focus_mode = Control.FOCUS_NONE
|
||||
texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
|
||||
custom_minimum_size = Vector2(34.0, 34.0)
|
||||
custom_minimum_size = Vector2(51.0, 51.0)
|
||||
_update_tooltip()
|
||||
queue_redraw()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue