Add fishing shop and persistent upgrades

This commit is contained in:
Alexander Sellite 2026-07-25 21:24:01 -04:00
parent 49e7faaf84
commit 6386c5e3e3
27 changed files with 1662 additions and 38 deletions

496
ui/fishing_shop.gd Normal file
View file

@ -0,0 +1,496 @@
class_name FishingShop
extends Control
const INPUT_OWNER: StringName = &"fishing_shop"
const MAIN_SHOP_BUYER_ID: StringName = &"main_fishing_shop"
const FishBuyerProfileType = preload("res://economy/fish_buyer_profile.gd")
const FishCatchType = preload("res://fish/fish_catch.gd")
const FishInventoryType = preload("res://inventory/fish_inventory.gd")
const FishSaleResultType = preload("res://economy/fish_sale_result.gd")
const FishSaleServiceType = preload("res://economy/fish_sale_service.gd")
const PlayerWalletType = preload("res://economy/player_wallet.gd")
const FishingSpotType = preload("res://fishing/fishing_spot.gd")
const PlayerFishingUpgradesType = preload(
"res://progression/player_fishing_upgrades.gd"
)
const PlayerType = preload("res://player/player.gd")
const ShopInteractionType = preload(
"res://world/fishing_shop_interaction.gd"
)
signal menu_visibility_changed(is_open: bool)
enum CloseReason {
USER,
RANGE_EXIT,
WATER_RECOVERY,
SESSION_END,
TEARDOWN,
}
@onready var _wallet_label: Label = %WalletLabel
@onready var _fish_list: ItemList = %FishList
@onready var _fish_empty: Label = %FishEmpty
@onready var _fish_texture: TextureRect = %FishTexture
@onready var _fish_name: Label = %FishName
@onready var _fish_details: Label = %FishDetails
@onready var _sell_button: Button = %SellButton
@onready var _feedback: Label = %Feedback
@onready var _reel_level: Label = %ReelLevel
@onready var _reel_effect: Label = %ReelEffect
@onready var _reel_cost: Label = %ReelCost
@onready var _reel_purchase: Button = %ReelPurchase
@onready var _barrier_level: Label = %BarrierLevel
@onready var _barrier_effect: Label = %BarrierEffect
@onready var _barrier_cost: Label = %BarrierCost
@onready var _barrier_purchase: Button = %BarrierPurchase
@onready var _confirmation: PanelContainer = %SaleConfirmation
@onready var _confirmation_text: Label = %ConfirmationText
@onready var _confirm_sale: Button = %ConfirmSale
@onready var _cancel_sale: Button = %CancelSale
var _player: PlayerType
var _inventory: FishInventoryType
var _wallet: PlayerWalletType
var _sale_service: FishSaleServiceType
var _buyer: FishBuyerProfileType
var _upgrades: PlayerFishingUpgradesType
var _fishing_spot: FishingSpotType
var _interaction: ShopInteractionType
var _selected_catch_id: StringName
var _confirmation_catch_id: StringName
var _prior_movement_enabled: bool = true
var _prior_camera_enabled: bool = true
var _prior_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_VISIBLE
var _snapshot_stored: bool = false
var _mouse_snapshot_stored: bool = false
var _generation: int = 0
var _transaction_in_progress: bool = false
var _closing: bool = false
func _ready() -> void:
%CloseButton.pressed.connect(close_shop)
_fish_list.item_selected.connect(_on_fish_selected)
_sell_button.pressed.connect(_open_sale_confirmation)
_confirm_sale.pressed.connect(_on_confirm_sale)
_cancel_sale.pressed.connect(_close_sale_confirmation)
_reel_purchase.pressed.connect(_purchase_reel_speed)
_barrier_purchase.pressed.connect(_purchase_barrier_power)
func setup(
player: PlayerType,
inventory: FishInventoryType,
wallet: PlayerWalletType,
sale_service: FishSaleServiceType,
buyer: FishBuyerProfileType,
upgrades: PlayerFishingUpgradesType,
fishing_spot: FishingSpotType,
interaction: ShopInteractionType,
) -> void:
_player = player
_inventory = inventory
_wallet = wallet
_sale_service = sale_service
_buyer = buyer
_upgrades = upgrades
_fishing_spot = fishing_spot
_interaction = interaction
if not _inventory.catches_changed.is_connected(_on_inventory_changed):
_inventory.catches_changed.connect(_on_inventory_changed)
if not _wallet.balance_changed.is_connected(_on_wallet_changed):
_wallet.balance_changed.connect(_on_wallet_changed)
if not _upgrades.upgrades_changed.is_connected(_on_upgrades_changed):
_upgrades.upgrades_changed.connect(_on_upgrades_changed)
_refresh_all()
func open_shop() -> bool:
if (
visible
or _player == null
or _interaction == null
or not _interaction.is_local_player_in_range()
or _fishing_spot == null
or not _fishing_spot.can_open_fishing_shop()
or _buyer == null
or not _buyer.is_valid()
or _buyer.id != MAIN_SHOP_BUYER_ID
):
return false
_generation += 1
_closing = false
_transaction_in_progress = false
_prior_movement_enabled = _player.is_movement_enabled()
_prior_camera_enabled = _player.is_camera_input_enabled()
_prior_mouse_mode = Input.mouse_mode
_snapshot_stored = true
_mouse_snapshot_stored = true
_player.set_movement_enabled(false)
_player.set_camera_input_enabled(false)
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, true)
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
_feedback.text = ""
_close_sale_confirmation()
show()
_refresh_all()
%CloseButton.grab_focus()
menu_visibility_changed.emit(true)
return true
func consume_escape() -> bool:
if not visible:
return false
if _confirmation.visible:
_close_sale_confirmation()
else:
close_shop()
return true
func close_shop(
reason: CloseReason = CloseReason.USER,
restore_controls: bool = true,
) -> void:
if not visible:
return
_closing = true
_generation += 1
_transaction_in_progress = false
_close_sale_confirmation()
_selected_catch_id = StringName()
hide()
get_viewport().gui_release_focus()
if _fishing_spot != null and is_instance_valid(_fishing_spot):
_fishing_spot.set_local_menu_input_suppressed(INPUT_OWNER, false)
if (
restore_controls
and _snapshot_stored
and _fishing_spot != null
and _fishing_spot.is_ready_for_shop_transaction()
):
_player.set_movement_enabled(_prior_movement_enabled)
_player.set_camera_input_enabled(_prior_camera_enabled)
_snapshot_stored = false
_apply_mouse_close_policy(reason)
_closing = false
menu_visibility_changed.emit(false)
func close_for_range_exit() -> void:
close_shop(CloseReason.RANGE_EXIT)
func close_for_water_recovery() -> void:
# Recovery emits its starting signal immediately before it captures the
# player's current control state. Restore our local snapshot synchronously
# so recovery captures the pre-shop state, then becomes the new authority
# before another frame can process gameplay input.
close_shop(CloseReason.WATER_RECOVERY, true)
func close_for_session_end() -> void:
close_shop(CloseReason.SESSION_END, false)
func _exit_tree() -> void:
if visible:
close_shop(CloseReason.TEARDOWN, false)
func _refresh_all() -> void:
if not is_node_ready():
return
_refresh_wallet()
_refresh_fish_list()
_refresh_selected_fish()
_refresh_upgrades()
func _refresh_wallet() -> void:
_wallet_label.text = (
"Wallet: $%d" % _wallet.get_balance()
if _wallet != null
else "Wallet: $0"
)
func _refresh_fish_list() -> void:
_fish_list.clear()
var catches: Array[FishCatchType] = (
_inventory.get_all_catches() if _inventory != null else []
)
catches.sort_custom(
func(a: FishCatchType, b: FishCatchType) -> bool:
return a.catch_sequence > b.catch_sequence
)
var selected_index: int = -1
for fish_catch: FishCatchType in catches:
if fish_catch == null or not fish_catch.is_valid():
continue
var marker: String = "" if fish_catch.is_favorited else ""
var index: int = _fish_list.add_item(
"%s%s%.2f lb"
% [marker, fish_catch.fish.display_name, fish_catch.weight_lb],
fish_catch.fish.display_texture
)
_fish_list.set_item_metadata(index, String(fish_catch.catch_id))
_fish_list.set_item_tooltip(
index,
"%s%s"
% [
fish_catch.fish.get_rarity_name(),
"Favorited" if fish_catch.is_favorited else "Available",
]
)
if fish_catch.catch_id == _selected_catch_id:
selected_index = index
_fish_empty.visible = _fish_list.item_count == 0
if selected_index >= 0:
_fish_list.select(selected_index)
elif not _selected_catch_id.is_empty():
_selected_catch_id = StringName()
func _refresh_selected_fish() -> void:
var fish_catch: FishCatchType = _get_selected_catch()
_fish_texture.texture = (
fish_catch.fish.display_texture if fish_catch != null else null
)
_fish_name.text = (
fish_catch.fish.display_name if fish_catch != null else "Select a fish"
)
if fish_catch == null:
_fish_details.text = "Choose one individual fish from your Cooler."
_sell_button.disabled = true
return
var offer: int = _buyer.get_offer(fish_catch.sale_value)
_fish_details.text = (
"%.2f lb • %s\nBase value: $%d\nMain-shop offer: $%d%s"
% [
fish_catch.weight_lb,
fish_catch.fish.get_rarity_name(),
fish_catch.sale_value,
offer,
"\nFavorited fish cannot be sold."
if fish_catch.is_favorited
else "",
]
)
_sell_button.disabled = (
fish_catch.is_favorited
or _transaction_in_progress
or _closing
)
func _refresh_upgrades() -> void:
if _upgrades == null:
return
var reel_level: int = _upgrades.get_reel_speed_level()
var reel_cost: int = _upgrades.get_next_reel_speed_cost()
_reel_level.text = "Level %d" % reel_level
_reel_purchase.disabled = (
reel_cost < 0
or _transaction_in_progress
or _closing
or not _upgrades.can_purchase_reel_speed(_wallet)
)
if reel_cost < 0:
_reel_effect.text = "%.2f×" % _upgrades.get_reel_speed_multiplier()
_reel_cost.text = "MAX"
else:
_reel_effect.text = (
"%.2f×%.2f×"
% [
_upgrades.get_reel_speed_multiplier(),
1.0 + float(reel_level + 1) * 0.10,
]
)
_reel_cost.text = "$%d" % reel_cost
_reel_purchase.text = "MAX" if reel_cost < 0 else "Purchase"
var barrier_level: int = _upgrades.get_barrier_power_level()
var barrier_cost: int = _upgrades.get_next_barrier_power_cost()
_barrier_level.text = "Level %d" % barrier_level
_barrier_purchase.disabled = (
barrier_cost < 0
or _transaction_in_progress
or _closing
or not _upgrades.can_purchase_barrier_power(_wallet)
)
if barrier_cost < 0:
_barrier_effect.text = "%d damage" % _upgrades.get_barrier_damage()
_barrier_cost.text = "MAX"
else:
_barrier_effect.text = (
"%d damage → %d damage"
% [
_upgrades.get_barrier_damage(),
barrier_level + 2,
]
)
_barrier_cost.text = "$%d" % barrier_cost
_barrier_purchase.text = "MAX" if barrier_cost < 0 else "Purchase"
func _on_fish_selected(index: int) -> void:
if index < 0 or index >= _fish_list.item_count:
return
_selected_catch_id = StringName(str(_fish_list.get_item_metadata(index)))
_feedback.text = ""
_refresh_selected_fish()
func _open_sale_confirmation() -> void:
var fish_catch: FishCatchType = _get_selected_catch()
if not _is_transaction_context_valid() or fish_catch == null:
_feedback.text = "This fish is no longer available."
_refresh_all()
return
if fish_catch.is_favorited:
_feedback.text = "Favorited fish cannot be sold."
return
_confirmation_catch_id = fish_catch.catch_id
var offer: int = _buyer.get_offer(fish_catch.sale_value)
_confirmation_text.text = (
"Sell this %.2f lb %s to the Fishing Shop for $%d?"
% [fish_catch.weight_lb, fish_catch.fish.display_name, offer]
)
_confirmation.show()
_cancel_sale.grab_focus()
func _close_sale_confirmation() -> void:
_confirmation_catch_id = StringName()
_confirmation.hide()
func _on_confirm_sale() -> void:
if _transaction_in_progress:
return
var transaction_generation: int = _generation
var catch_id: StringName = _confirmation_catch_id
_close_sale_confirmation()
if (
catch_id.is_empty()
or not _is_transaction_context_valid()
or transaction_generation != _generation
or _buyer.id != MAIN_SHOP_BUYER_ID
):
_feedback.text = "Unable to complete sale."
return
_transaction_in_progress = true
var result: FishSaleResultType = _sale_service.sell(catch_id, _buyer)
_transaction_in_progress = false
if (
transaction_generation != _generation
or not visible
):
return
if result.is_success():
_feedback.text = "Fish sold for $%d." % result.payout
_selected_catch_id = StringName()
else:
_feedback.text = result.get_message()
_refresh_all()
func _purchase_reel_speed() -> void:
_purchase_upgrade(true)
func _purchase_barrier_power() -> void:
_purchase_upgrade(false)
func _purchase_upgrade(is_reel_speed: bool) -> void:
if _transaction_in_progress or not _is_transaction_context_valid():
_feedback.text = "Unable to complete purchase."
return
var cost: int = (
_upgrades.get_next_reel_speed_cost()
if is_reel_speed
else _upgrades.get_next_barrier_power_cost()
)
if cost < 0:
_feedback.text = "Maximum level reached."
return
if not _wallet.can_afford(cost):
_feedback.text = "Not enough money."
return
var transaction_generation: int = _generation
_transaction_in_progress = true
var purchased: bool = (
_upgrades.purchase_reel_speed(_wallet)
if is_reel_speed
else _upgrades.purchase_barrier_power(_wallet)
)
_transaction_in_progress = false
if transaction_generation != _generation or not visible:
return
_feedback.text = (
"Upgrade purchased."
if purchased
else "Unable to complete purchase."
)
_refresh_all()
func _get_selected_catch() -> FishCatchType:
if _inventory == null or _selected_catch_id.is_empty():
return null
return _inventory.get_catch_by_id(_selected_catch_id)
func _is_transaction_context_valid() -> bool:
return (
visible
and not _closing
and _interaction != null
and _interaction.is_local_player_in_range()
and _fishing_spot != null
and _fishing_spot.is_ready_for_shop_transaction()
and _buyer != null
and _buyer.is_valid()
and _buyer.id == MAIN_SHOP_BUYER_ID
)
func _on_inventory_changed() -> void:
_refresh_fish_list()
if (
not _confirmation_catch_id.is_empty()
and _inventory.get_catch_by_id(_confirmation_catch_id) == null
):
_close_sale_confirmation()
_feedback.text = "This fish is no longer available."
_refresh_selected_fish()
func _on_wallet_changed(_balance: int, _delta: int) -> void:
_refresh_wallet()
_refresh_upgrades()
func _on_upgrades_changed(
_reel_speed_level: int,
_barrier_power_level: int,
) -> void:
_refresh_upgrades()
func _apply_mouse_close_policy(reason: CloseReason) -> void:
if not _mouse_snapshot_stored:
return
match reason:
CloseReason.USER, CloseReason.RANGE_EXIT:
Input.mouse_mode = _prior_mouse_mode
CloseReason.WATER_RECOVERY:
Input.mouse_mode = _prior_mouse_mode
CloseReason.SESSION_END:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
CloseReason.TEARDOWN:
pass
_mouse_snapshot_stored = false

1
ui/fishing_shop.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://6yu6krq6yk8f

348
ui/fishing_shop.tscn Normal file
View file

@ -0,0 +1,348 @@
[gd_scene load_steps=6 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"]
[ext_resource type="Texture2D" path="res://items/icons/placeholder/reel_speed_upgrade.svg" id="3_reel"]
[ext_resource type="Texture2D" path="res://items/icons/placeholder/barrier_power_upgrade.svg" id="4_barrier"]
[ext_resource type="Texture2D" path="res://items/icons/placeholder/fish_coin.svg" id="5_coin"]
[node name="FishingShop" type="Control"]
unique_name_in_owner = true
visible = false
z_index = 80
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme = ExtResource("2_theme")
script = ExtResource("1_script")
[node name="Dimmer" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 0
color = Color(0.015, 0.02, 0.03, 0.64)
[node name="ShopPanel" type="PanelContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -450.0
offset_top = -260.0
offset_right = 450.0
offset_bottom = 260.0
grow_horizontal = 2
grow_vertical = 2
[node name="Margin" type="MarginContainer" parent="ShopPanel"]
layout_mode = 2
theme_override_constants/margin_left = 16
theme_override_constants/margin_top = 14
theme_override_constants/margin_right = 16
theme_override_constants/margin_bottom = 14
[node name="Layout" type="VBoxContainer" parent="ShopPanel/Margin"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="Header" type="HBoxContainer" parent="ShopPanel/Margin/Layout"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="Title" type="Label" parent="ShopPanel/Margin/Layout/Header"]
layout_mode = 2
size_flags_horizontal = 3
text = "Fishing Shop"
theme_override_font_sizes/font_size = 24
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)
layout_mode = 2
texture = ExtResource("5_coin")
expand_mode = 1
stretch_mode = 5
texture_filter = 1
[node name="WalletLabel" type="Label" parent="ShopPanel/Margin/Layout/Header"]
unique_name_in_owner = true
layout_mode = 2
text = "Wallet: $0"
[node name="CloseButton" type="Button" parent="ShopPanel/Margin/Layout/Header"]
unique_name_in_owner = true
layout_mode = 2
text = "Close"
custom_minimum_size = Vector2(72, 30)
[node name="Feedback" type="Label" parent="ShopPanel/Margin/Layout"]
unique_name_in_owner = true
layout_mode = 2
text = ""
horizontal_alignment = 1
theme_override_colors/font_color = Color(1, 0.82, 0.4, 1)
[node name="Body" type="HBoxContainer" parent="ShopPanel/Margin/Layout"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 12
[node name="FishSales" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body"]
custom_minimum_size = Vector2(500, 0)
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 6
[node name="SalesTitle" type="Label" parent="ShopPanel/Margin/Layout/Body/FishSales"]
layout_mode = 2
text = "Sell individual Cooler fish • Full base value"
theme_override_font_sizes/font_size = 17
[node name="SalesBody" type="HSplitContainer" parent="ShopPanel/Margin/Layout/Body/FishSales"]
layout_mode = 2
size_flags_vertical = 3
split_offset = 265
theme_override_constants/separation = 8
[node name="ListPanel" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody"]
custom_minimum_size = Vector2(250, 0)
layout_mode = 2
[node name="ListMargin" type="MarginContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/ListPanel"]
layout_mode = 2
theme_override_constants/margin_left = 7
theme_override_constants/margin_top = 7
theme_override_constants/margin_right = 7
theme_override_constants/margin_bottom = 7
[node name="ListStack" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/ListPanel/ListMargin"]
layout_mode = 2
[node name="FishEmpty" type="Label" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/ListPanel/ListMargin/ListStack"]
unique_name_in_owner = true
layout_mode = 2
text = "Your Cooler is empty."
horizontal_alignment = 1
[node name="FishList" type="ItemList" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/ListPanel/ListMargin/ListStack"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
fixed_icon_size = Vector2i(48, 36)
icon_mode = 1
same_column_width = true
[node name="FishDetail" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody"]
custom_minimum_size = Vector2(220, 0)
layout_mode = 2
[node name="DetailMargin" type="MarginContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail"]
layout_mode = 2
theme_override_constants/margin_left = 9
theme_override_constants/margin_top = 9
theme_override_constants/margin_right = 9
theme_override_constants/margin_bottom = 9
[node name="DetailStack" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail/DetailMargin"]
layout_mode = 2
theme_override_constants/separation = 6
[node name="FishTexture" type="TextureRect" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail/DetailMargin/DetailStack"]
unique_name_in_owner = true
custom_minimum_size = Vector2(190, 100)
layout_mode = 2
expand_mode = 1
stretch_mode = 5
texture_filter = 1
[node name="FishName" type="Label" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail/DetailMargin/DetailStack"]
unique_name_in_owner = true
layout_mode = 2
text = "Select a fish"
horizontal_alignment = 1
theme_override_font_sizes/font_size = 19
[node name="FishDetails" type="Label" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail/DetailMargin/DetailStack"]
unique_name_in_owner = true
layout_mode = 2
text = "Choose one individual fish from your Cooler."
horizontal_alignment = 1
autowrap_mode = 2
[node name="SellButton" type="Button" parent="ShopPanel/Margin/Layout/Body/FishSales/SalesBody/FishDetail/DetailMargin/DetailStack"]
unique_name_in_owner = true
layout_mode = 2
disabled = true
text = "Sell Selected"
[node name="Upgrades" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body"]
custom_minimum_size = Vector2(310, 0)
layout_mode = 2
theme_override_constants/separation = 8
[node name="UpgradeTitle" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades"]
layout_mode = 2
text = "Fishing Upgrades"
theme_override_font_sizes/font_size = 17
[node name="ReelCard" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades"]
layout_mode = 2
[node name="Margin" type="MarginContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard"]
layout_mode = 2
theme_override_constants/margin_left = 9
theme_override_constants/margin_top = 9
theme_override_constants/margin_right = 9
theme_override_constants/margin_bottom = 9
[node name="Row" type="HBoxContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin"]
layout_mode = 2
theme_override_constants/separation = 9
[node name="Icon" type="TextureRect" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row"]
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
texture = ExtResource("3_reel")
expand_mode = 1
stretch_mode = 5
texture_filter = 1
[node name="Data" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Name" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row/Data"]
layout_mode = 2
text = "Reel Speed"
theme_override_font_sizes/font_size = 17
[node name="ReelLevel" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row/Data"]
unique_name_in_owner = true
layout_mode = 2
text = "Level 0"
[node name="ReelEffect" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row/Data"]
unique_name_in_owner = true
layout_mode = 2
text = "1.00× → 1.10×"
[node name="ReelCost" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row/Data"]
unique_name_in_owner = true
layout_mode = 2
text = "$50"
[node name="ReelPurchase" type="Button" parent="ShopPanel/Margin/Layout/Body/Upgrades/ReelCard/Margin/Row"]
unique_name_in_owner = true
layout_mode = 2
text = "Purchase"
[node name="BarrierCard" type="PanelContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades"]
layout_mode = 2
[node name="Margin" type="MarginContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard"]
layout_mode = 2
theme_override_constants/margin_left = 9
theme_override_constants/margin_top = 9
theme_override_constants/margin_right = 9
theme_override_constants/margin_bottom = 9
[node name="Row" type="HBoxContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin"]
layout_mode = 2
theme_override_constants/separation = 9
[node name="Icon" type="TextureRect" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row"]
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
texture = ExtResource("4_barrier")
expand_mode = 1
stretch_mode = 5
texture_filter = 1
[node name="Data" type="VBoxContainer" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Name" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row/Data"]
layout_mode = 2
text = "Barrier Power"
theme_override_font_sizes/font_size = 17
[node name="BarrierLevel" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row/Data"]
unique_name_in_owner = true
layout_mode = 2
text = "Level 0"
[node name="BarrierEffect" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row/Data"]
unique_name_in_owner = true
layout_mode = 2
text = "1 damage → 2 damage"
[node name="BarrierCost" type="Label" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row/Data"]
unique_name_in_owner = true
layout_mode = 2
text = "$100"
[node name="BarrierPurchase" type="Button" parent="ShopPanel/Margin/Layout/Body/Upgrades/BarrierCard/Margin/Row"]
unique_name_in_owner = true
layout_mode = 2
text = "Purchase"
[node name="SaleConfirmation" type="PanelContainer" parent="."]
unique_name_in_owner = true
visible = false
z_index = 10
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -220.0
offset_top = -90.0
offset_right = 220.0
offset_bottom = 90.0
grow_horizontal = 2
grow_vertical = 2
[node name="Margin" type="MarginContainer" parent="SaleConfirmation"]
layout_mode = 2
theme_override_constants/margin_left = 18
theme_override_constants/margin_top = 16
theme_override_constants/margin_right = 18
theme_override_constants/margin_bottom = 16
[node name="Stack" type="VBoxContainer" parent="SaleConfirmation/Margin"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="ConfirmationText" type="Label" parent="SaleConfirmation/Margin/Stack"]
unique_name_in_owner = true
layout_mode = 2
autowrap_mode = 2
horizontal_alignment = 1
[node name="Buttons" type="HBoxContainer" parent="SaleConfirmation/Margin/Stack"]
layout_mode = 2
alignment = 1
theme_override_constants/separation = 8
[node name="ConfirmSale" type="Button" parent="SaleConfirmation/Margin/Stack/Buttons"]
unique_name_in_owner = true
layout_mode = 2
text = "Sell Fish"
theme_type_variation = &"DangerButton"
[node name="CancelSale" type="Button" parent="SaleConfirmation/Margin/Stack/Buttons"]
unique_name_in_owner = true
layout_mode = 2
text = "Cancel"

View file

@ -16,6 +16,13 @@ const PlayerHotbarType = preload("res://inventory/player_hotbar.gd")
const HotbarUIType = preload("res://ui/hotbar.gd")
const TitleScreenType = preload("res://ui/title_screen.gd")
const PauseMenuType = preload("res://ui/pause_menu.gd")
const FishingShopType = preload("res://ui/fishing_shop.gd")
const PlayerFishingUpgradesType = preload(
"res://progression/player_fishing_upgrades.gd"
)
const ShopInteractionType = preload(
"res://world/fishing_shop_interaction.gd"
)
@onready var _status_label: Label = %StatusLabel
@onready var _catch_track: Control = %CatchTrack
@ -31,11 +38,15 @@ const PauseMenuType = preload("res://ui/pause_menu.gd")
@onready var _title_screen: TitleScreenType = %TitleScreen
@onready var _pause_menu: PauseMenuType = %PauseMenu
@onready var _hotbar_ui: HotbarUIType = %Hotbar
@onready var _fishing_shop: FishingShopType = %FishingShop
@onready var _shop_prompt: PanelContainer = %ShopPrompt
var _showcase_active: bool = false
var _player_menu_open: bool = false
var _gameplay_ui_enabled: bool = false
var _fishing_spot: FishingSpotType
var _system_menu_open: bool = false
var _shop_open: bool = false
func setup(
@ -50,6 +61,9 @@ func setup(
bag: PlayerBagType,
hotbar: PlayerHotbarType,
item_catalog: ItemCatalogType,
main_shop_buyer: FishBuyerProfileType,
fishing_upgrades: PlayerFishingUpgradesType,
shop_interaction: ShopInteractionType,
) -> void:
_fishing_spot = fishing_spot
fishing_spot.status_changed.connect(_on_fishing_status_changed)
@ -72,6 +86,17 @@ func setup(
item_catalog
)
_hotbar_ui.setup(hotbar, bag, item_catalog, fishing_spot)
_fishing_shop.setup(
player,
inventory,
wallet,
sale_service,
main_shop_buyer,
fishing_upgrades,
fishing_spot,
shop_interaction
)
_fishing_shop.menu_visibility_changed.connect(_on_shop_visibility_changed)
func close_player_menu() -> void:
@ -102,7 +127,9 @@ func set_gameplay_ui_enabled(enabled: bool) -> void:
_gameplay_ui_enabled = enabled
if not enabled:
close_player_menu_for_session_end()
_fishing_shop.close_for_session_end()
_fishing_panel.visible = false
_shop_prompt.hide()
_hotbar_ui.hide()
_hotbar_ui.set_gameplay_input_enabled(false)
else:
@ -112,11 +139,33 @@ func set_gameplay_ui_enabled(enabled: bool) -> void:
func set_system_menu_open(is_open: bool) -> void:
_hotbar_ui.visible = _gameplay_ui_enabled and not is_open
_system_menu_open = is_open
_hotbar_ui.visible = (
_gameplay_ui_enabled and not is_open and not _shop_open
)
_hotbar_ui.set_gameplay_input_enabled(
_gameplay_ui_enabled and not is_open and not _player_menu_open
_gameplay_ui_enabled
and not is_open
and not _player_menu_open
and not _shop_open
)
_hotbar_ui.set_drag_enabled(_player_menu_open and not is_open)
if is_open:
_shop_prompt.hide()
func get_fishing_shop() -> FishingShopType:
return _fishing_shop
func set_shop_prompt_visible(is_visible: bool) -> void:
_shop_prompt.visible = (
is_visible
and _gameplay_ui_enabled
and not _system_menu_open
and not _player_menu_open
and not _shop_open
)
func get_screen_fade() -> ScreenFade:
@ -299,3 +348,20 @@ func _on_player_menu_visibility_changed(is_open: bool) -> void:
)
_hotbar_ui.set_drag_enabled(is_open)
_refresh_fishing_panel_visibility()
if is_open:
_shop_prompt.hide()
func _on_shop_visibility_changed(is_open: bool) -> void:
_shop_open = is_open
_hotbar_ui.visible = (
_gameplay_ui_enabled and not is_open and not _system_menu_open
)
_hotbar_ui.set_gameplay_input_enabled(
_gameplay_ui_enabled
and not is_open
and not _system_menu_open
and not _player_menu_open
)
if is_open:
_shop_prompt.hide()

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3]
[gd_scene load_steps=13 format=3]
[ext_resource type="Script" path="res://ui/game_ui.gd" id="1_ui"]
[ext_resource type="PackedScene" path="res://ui/player_menu.tscn" id="2_menu"]
@ -7,6 +7,7 @@
[ext_resource type="PackedScene" path="res://ui/title_screen.tscn" id="5_title"]
[ext_resource type="PackedScene" path="res://ui/pause_menu.tscn" id="6_pause"]
[ext_resource type="PackedScene" path="res://ui/hotbar.tscn" id="7_hotbar"]
[ext_resource type="PackedScene" path="res://ui/fishing_shop.tscn" id="8_shop"]
[sub_resource type="StyleBoxFlat" id="StyleBox_chase_background"]
bg_color = Color(0.055, 0.105, 0.125, 1)
@ -133,6 +134,39 @@ unique_name_in_owner = true
[node name="Hotbar" parent="." instance=ExtResource("7_hotbar")]
unique_name_in_owner = true
[node name="ShopPrompt" type="PanelContainer" parent="."]
unique_name_in_owner = true
visible = false
z_index = 55
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -150.0
offset_top = -284.0
offset_right = 150.0
offset_bottom = -246.0
grow_horizontal = 2
grow_vertical = 0
mouse_filter = 2
theme = ExtResource("3_theme")
[node name="Margin" type="MarginContainer" parent="ShopPrompt"]
layout_mode = 2
theme_override_constants/margin_left = 12
theme_override_constants/margin_top = 7
theme_override_constants/margin_right = 12
theme_override_constants/margin_bottom = 7
[node name="Label" type="Label" parent="ShopPrompt/Margin"]
layout_mode = 2
text = "Press E to open Fishing Shop"
horizontal_alignment = 1
[node name="FishingShop" parent="." instance=ExtResource("8_shop")]
unique_name_in_owner = true
[node name="ScreenFade" type="ColorRect" parent="."]
unique_name_in_owner = true
visible = false