Add direct-connect multiplayer foundation
This commit is contained in:
parent
9e9850dd20
commit
24f8263175
36 changed files with 2633 additions and 45 deletions
|
|
@ -16,6 +16,7 @@ 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 NetworkSessionType = preload("res://network/network_session.gd")
|
||||
const FishingShopType = preload("res://ui/fishing_shop.gd")
|
||||
const SettingsPanelType = preload("res://ui/settings_panel.gd")
|
||||
const PlayerFishingUpgradesType = preload(
|
||||
|
|
@ -100,6 +101,7 @@ func setup(
|
|||
shop_interaction: ShopInteractionType,
|
||||
item_effects: PlayerItemEffectsType,
|
||||
cooler_capacity: PlayerCoolerCapacityType,
|
||||
network_session: NetworkSessionType,
|
||||
) -> void:
|
||||
_fishing_spot = fishing_spot
|
||||
_item_effects = item_effects
|
||||
|
|
@ -121,7 +123,8 @@ func setup(
|
|||
bag,
|
||||
hotbar,
|
||||
item_catalog,
|
||||
cooler_capacity
|
||||
cooler_capacity,
|
||||
network_session
|
||||
)
|
||||
_hotbar_ui.setup(hotbar, bag, item_catalog, fishing_spot)
|
||||
_fishing_shop.setup(
|
||||
|
|
|
|||
175
ui/network/join_game_page.gd
Normal file
175
ui/network/join_game_page.gd
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
class_name JoinGamePage
|
||||
extends Control
|
||||
|
||||
signal join_requested(endpoint: String)
|
||||
signal back_requested
|
||||
|
||||
@onready var _address: LineEdit = %Address
|
||||
@onready var _join_button: BubbleButton = %JoinButton
|
||||
@onready var _cancel_button: BubbleButton = %CancelButton
|
||||
@onready var _back_button: BubbleButton = %BackButton
|
||||
@onready var _open_close_button: BubbleButton = %OpenCloseButton
|
||||
@onready var _status: Label = %Status
|
||||
@onready var _session_summary: Label = %SessionSummary
|
||||
|
||||
var _network_session: NetworkSession
|
||||
var _saved_servers: SavedServerStore
|
||||
var _gameplay_context: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_join_button.pressed.connect(_on_join_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(_on_address_submitted)
|
||||
hide()
|
||||
|
||||
|
||||
func setup(
|
||||
network_session: NetworkSession,
|
||||
saved_servers: SavedServerStore,
|
||||
gameplay_context: bool,
|
||||
) -> void:
|
||||
_network_session = network_session
|
||||
_saved_servers = saved_servers
|
||||
_gameplay_context = gameplay_context
|
||||
if not _network_session.state_changed.is_connected(_on_state_changed):
|
||||
_network_session.state_changed.connect(_on_state_changed)
|
||||
if not _network_session.status_message_changed.is_connected(
|
||||
_on_status_message_changed
|
||||
):
|
||||
_network_session.status_message_changed.connect(
|
||||
_on_status_message_changed
|
||||
)
|
||||
if not _network_session.connection_error.is_connected(
|
||||
_on_connection_error
|
||||
):
|
||||
_network_session.connection_error.connect(_on_connection_error)
|
||||
if not _network_session.peer_count_changed.is_connected(
|
||||
_on_peer_count_changed
|
||||
):
|
||||
_network_session.peer_count_changed.connect(_on_peer_count_changed)
|
||||
_refresh()
|
||||
|
||||
|
||||
func open_page(preserved_endpoint: String = "") -> void:
|
||||
if not preserved_endpoint.is_empty():
|
||||
_address.text = preserved_endpoint
|
||||
elif _address.text.is_empty():
|
||||
_address.text = "127.0.0.1:7777"
|
||||
show()
|
||||
_refresh()
|
||||
_address.grab_focus()
|
||||
_address.select_all()
|
||||
|
||||
|
||||
func close_page() -> void:
|
||||
hide()
|
||||
get_viewport().gui_release_focus()
|
||||
|
||||
|
||||
func get_endpoint_text() -> String:
|
||||
return _address.text
|
||||
|
||||
|
||||
func set_status(message: String) -> void:
|
||||
_status.text = message
|
||||
|
||||
|
||||
func _on_join_pressed() -> void:
|
||||
_request_join()
|
||||
|
||||
|
||||
func _on_address_submitted(_value: String) -> void:
|
||||
_request_join()
|
||||
|
||||
|
||||
func _request_join() -> void:
|
||||
if _network_session.state in [
|
||||
NetworkSession.State.CONNECTION_FAILED,
|
||||
NetworkSession.State.SERVER_LOST,
|
||||
]:
|
||||
_network_session.reset_failure()
|
||||
var endpoint: ConnectionEndpoint = EndpointParser.parse(_address.text)
|
||||
if not endpoint.is_valid():
|
||||
_status.text = endpoint.error_message
|
||||
return
|
||||
_address.text = endpoint.normalized_display
|
||||
join_requested.emit(endpoint.normalized_display)
|
||||
|
||||
|
||||
func _on_cancel_pressed() -> void:
|
||||
if _network_session != null:
|
||||
_network_session.cancel_connection()
|
||||
_refresh()
|
||||
|
||||
|
||||
func _on_back_pressed() -> void:
|
||||
if (
|
||||
_network_session != null
|
||||
and _network_session.state in [
|
||||
NetworkSession.State.CONNECTING,
|
||||
NetworkSession.State.AUTHENTICATING,
|
||||
]
|
||||
):
|
||||
_network_session.cancel_connection()
|
||||
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()
|
||||
|
||||
|
||||
func _on_status_message_changed(message: String) -> void:
|
||||
_status.text = message
|
||||
_refresh()
|
||||
|
||||
|
||||
func _on_connection_error(message: String) -> void:
|
||||
_status.text = message
|
||||
_refresh()
|
||||
|
||||
|
||||
func _on_peer_count_changed(player_count: int, max_players: int) -> void:
|
||||
_session_summary.text = "%d / %d players" % [
|
||||
player_count,
|
||||
max_players,
|
||||
]
|
||||
|
||||
|
||||
func _refresh() -> void:
|
||||
if not is_node_ready() or _network_session == null:
|
||||
return
|
||||
var connecting: bool = _network_session.state in [
|
||||
NetworkSession.State.CONNECTING,
|
||||
NetworkSession.State.AUTHENTICATING,
|
||||
]
|
||||
_address.editable = not connecting
|
||||
_join_button.disabled = connecting
|
||||
_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
|
||||
)
|
||||
if _session_summary.visible:
|
||||
_session_summary.text = "%d / %d players" % [
|
||||
_network_session.get_player_count(),
|
||||
_network_session.get_session_max_players(),
|
||||
]
|
||||
1
ui/network/join_game_page.gd.uid
Normal file
1
ui/network/join_game_page.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dch42c44t4rj5
|
||||
145
ui/network/join_game_page.tscn
Normal file
145
ui/network/join_game_page.tscn
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
[gd_scene load_steps=5 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/network/join_game_page.gd" id="1_script"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"]
|
||||
[ext_resource type="PackedScene" path="res://ui/components/bubble_menu/bubble_button.tscn" id="3_bubble"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBox_paper"]
|
||||
bg_color = Color(0.93, 0.885, 0.73, 1)
|
||||
shadow_color = Color(0.02, 0.075, 0.11, 0.42)
|
||||
shadow_size = 10
|
||||
shadow_offset = Vector2(7, 8)
|
||||
corner_radius_top_left = 54
|
||||
corner_radius_top_right = 46
|
||||
corner_radius_bottom_right = 58
|
||||
corner_radius_bottom_left = 48
|
||||
|
||||
[node name="JoinGamePage" type="Control"]
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_theme")
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Paper" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 340.0
|
||||
offset_top = 132.0
|
||||
offset_right = 940.0
|
||||
offset_bottom = 570.0
|
||||
theme_override_styles/panel = SubResource("StyleBox_paper")
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="Paper"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 70
|
||||
theme_override_constants/margin_top = 52
|
||||
theme_override_constants/margin_right = 70
|
||||
theme_override_constants/margin_bottom = 52
|
||||
|
||||
[node name="Layout" type="VBoxContainer" parent="Paper/Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 18
|
||||
alignment = 1
|
||||
|
||||
[node name="Title" type="Label" parent="Paper/Margin/Layout"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.035, 0.145, 0.22, 1)
|
||||
theme_override_font_sizes/font_size = 34
|
||||
text = "join game"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Hint" type="Label" parent="Paper/Margin/Layout"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.035, 0.145, 0.22, 1)
|
||||
theme_override_font_sizes/font_size = 17
|
||||
text = "hostname or IP address • optional port"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Address" type="LineEdit" parent="Paper/Margin/Layout"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 52)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.035, 0.145, 0.22, 1)
|
||||
theme_override_font_sizes/font_size = 22
|
||||
placeholder_text = "example.net:7777"
|
||||
alignment = 1
|
||||
max_length = 300
|
||||
|
||||
[node name="Status" type="Label" parent="Paper/Margin/Layout"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 42)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.035, 0.145, 0.22, 1)
|
||||
theme_override_font_sizes/font_size = 17
|
||||
text = "Direct UDP connection • default port 7777"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="SessionSummary" type="Label" parent="Paper/Margin/Layout"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.035, 0.145, 0.22, 1)
|
||||
theme_override_font_sizes/font_size = 17
|
||||
text = "1 / 8 players"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Actions" type="HBoxContainer" parent="Paper/Margin/Layout"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
alignment = 1
|
||||
|
||||
[node name="JoinButton" parent="Paper/Margin/Layout/Actions" instance=ExtResource("3_bubble")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(112, 106)
|
||||
layout_mode = 2
|
||||
text = "join"
|
||||
neutral_size = Vector2(112, 106)
|
||||
minimum_font_size = 18
|
||||
maximum_font_size = 24
|
||||
horizontal_amplitude = 0.0
|
||||
vertical_amplitude = 0.0
|
||||
deformation_amplitude = 0.0
|
||||
|
||||
[node name="OpenCloseButton" parent="Paper/Margin/Layout/Actions" instance=ExtResource("3_bubble")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(112, 106)
|
||||
layout_mode = 2
|
||||
text = "open\ngame"
|
||||
neutral_size = Vector2(112, 106)
|
||||
minimum_font_size = 17
|
||||
maximum_font_size = 22
|
||||
horizontal_amplitude = 0.0
|
||||
vertical_amplitude = 0.0
|
||||
deformation_amplitude = 0.0
|
||||
|
||||
[node name="CancelButton" parent="Paper/Margin/Layout/Actions" instance=ExtResource("3_bubble")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(98, 94)
|
||||
layout_mode = 2
|
||||
text = "cancel"
|
||||
neutral_size = Vector2(98, 94)
|
||||
minimum_font_size = 16
|
||||
maximum_font_size = 20
|
||||
horizontal_amplitude = 0.0
|
||||
vertical_amplitude = 0.0
|
||||
deformation_amplitude = 0.0
|
||||
|
||||
[node name="BackButton" parent="Paper/Margin/Layout/Actions" instance=ExtResource("3_bubble")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(98, 94)
|
||||
layout_mode = 2
|
||||
text = "back"
|
||||
neutral_size = Vector2(98, 94)
|
||||
minimum_font_size = 16
|
||||
maximum_font_size = 20
|
||||
horizontal_amplitude = 0.0
|
||||
vertical_amplitude = 0.0
|
||||
deformation_amplitude = 0.0
|
||||
|
|
@ -19,17 +19,22 @@ const BubbleConfirmationPageType = preload(
|
|||
"res://ui/components/bubble_menu/bubble_confirmation_page.gd"
|
||||
)
|
||||
const FishingSpotType = preload("res://fishing/fishing_spot.gd")
|
||||
const NetworkSessionType = preload("res://network/network_session.gd")
|
||||
const SavedServerStoreType = preload("res://network/saved_server_store.gd")
|
||||
const JoinGamePageType = preload("res://ui/network/join_game_page.gd")
|
||||
|
||||
signal return_to_title_requested
|
||||
signal reset_progress_requested
|
||||
signal quit_requested
|
||||
signal menu_visibility_changed(is_open: bool)
|
||||
signal join_game_requested(endpoint: String)
|
||||
|
||||
enum ConfirmationAction {
|
||||
NONE,
|
||||
RETURN_TO_TITLE,
|
||||
RESET_PROGRESS,
|
||||
QUIT_ANYWAY,
|
||||
JOIN_ANOTHER,
|
||||
}
|
||||
|
||||
enum CloseReason {
|
||||
|
|
@ -54,11 +59,14 @@ enum CloseReason {
|
|||
)
|
||||
@onready var _feedback: Label = %FeedbackLabel
|
||||
@onready var _save_button: BubbleButton = %SaveButton
|
||||
@onready var _join_game_page: JoinGamePageType = %JoinGamePage
|
||||
|
||||
var _player: PlayerType
|
||||
var _save_manager: SaveManagerType
|
||||
var _settings_manager: SettingsManagerType
|
||||
var _fishing_spot: FishingSpotType
|
||||
var _network_session: NetworkSessionType
|
||||
var _saved_servers: SavedServerStoreType
|
||||
var _prior_movement_enabled: bool = true
|
||||
var _prior_camera_enabled: bool = true
|
||||
var _prior_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_VISIBLE
|
||||
|
|
@ -71,12 +79,14 @@ var _root_transition_generation: int = 0
|
|||
var _closing_menu: bool = false
|
||||
var _backdrop_fade: Tween
|
||||
var _backdrop_fade_generation: int = 0
|
||||
var _pending_join_endpoint: String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
%ResumeButton.pressed.connect(resume)
|
||||
_save_button.pressed.connect(_save_now)
|
||||
%SettingsButton.pressed.connect(_open_settings)
|
||||
%JoinGameButton.pressed.connect(_open_join_game)
|
||||
%ReturnToTitleButton.pressed.connect(_confirm_return_to_title)
|
||||
%ResetProgressButton.pressed.connect(_confirm_reset_progress)
|
||||
%QuitButton.pressed.connect(_request_quit)
|
||||
|
|
@ -87,6 +97,8 @@ func _ready() -> void:
|
|||
_settings_panel.navigation_transition_started.connect(
|
||||
_emit_transition_flurry
|
||||
)
|
||||
_join_game_page.join_requested.connect(_on_join_game_requested)
|
||||
_join_game_page.back_requested.connect(_close_join_game)
|
||||
_dim_background.color.a = 0.0
|
||||
_confirmation_page.hide_page()
|
||||
resized.connect(_update_responsive_pause_stage)
|
||||
|
|
@ -98,11 +110,16 @@ func setup(
|
|||
save_manager: SaveManagerType,
|
||||
settings_manager: SettingsManagerType,
|
||||
fishing_spot: FishingSpotType,
|
||||
network_session: NetworkSessionType,
|
||||
saved_servers: SavedServerStoreType,
|
||||
) -> void:
|
||||
_player = player
|
||||
_save_manager = save_manager
|
||||
_settings_manager = settings_manager
|
||||
_fishing_spot = fishing_spot
|
||||
_network_session = network_session
|
||||
_saved_servers = saved_servers
|
||||
_join_game_page.setup(network_session, saved_servers, true)
|
||||
if not _fishing_spot.bite_activated.is_connected(_on_bite_activated):
|
||||
_fishing_spot.bite_activated.connect(_on_bite_activated)
|
||||
|
||||
|
|
@ -121,6 +138,7 @@ func open_menu() -> void:
|
|||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
_feedback.text = ""
|
||||
_settings_panel.hide()
|
||||
_join_game_page.close_page()
|
||||
_confirmation_page.hide_page()
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
_action_in_progress = false
|
||||
|
|
@ -169,6 +187,8 @@ func handle_escape() -> bool:
|
|||
return true
|
||||
if _confirmation_page.visible:
|
||||
_close_confirmation()
|
||||
elif _join_game_page.visible:
|
||||
_close_join_game()
|
||||
elif _settings_panel.visible:
|
||||
_settings_panel.handle_back()
|
||||
else:
|
||||
|
|
@ -203,6 +223,47 @@ func _open_settings() -> void:
|
|||
_begin_root_exit(_finish_open_settings)
|
||||
|
||||
|
||||
func _open_join_game() -> void:
|
||||
if (
|
||||
_action_in_progress
|
||||
or _root_transition_active
|
||||
or _confirmation_action != ConfirmationAction.NONE
|
||||
):
|
||||
return
|
||||
_begin_root_exit(_finish_open_join_game)
|
||||
|
||||
|
||||
func _finish_open_join_game() -> void:
|
||||
_join_game_page.open_page()
|
||||
|
||||
|
||||
func _close_join_game() -> void:
|
||||
_join_game_page.close_page()
|
||||
_begin_root_entry(true)
|
||||
|
||||
|
||||
func _on_join_game_requested(endpoint: String) -> void:
|
||||
if _action_in_progress or _root_transition_active:
|
||||
return
|
||||
_pending_join_endpoint = endpoint
|
||||
_open_confirmation(
|
||||
ConfirmationAction.JOIN_ANOTHER,
|
||||
"join another game?",
|
||||
(
|
||||
"your progression will be saved first. "
|
||||
+ "current players will be disconnected if you are hosting."
|
||||
),
|
||||
"save and join",
|
||||
false
|
||||
)
|
||||
|
||||
|
||||
func report_network_error(message: String) -> void:
|
||||
_feedback.text = message
|
||||
if _join_game_page.visible:
|
||||
_join_game_page.set_status(message)
|
||||
|
||||
|
||||
func _finish_open_settings() -> void:
|
||||
_settings_panel.open_panel(
|
||||
_settings_manager,
|
||||
|
|
@ -347,6 +408,10 @@ func _finish_confirmation_accept(action: ConfirmationAction) -> void:
|
|||
reset_progress_requested.emit()
|
||||
ConfirmationAction.QUIT_ANYWAY:
|
||||
quit_requested.emit()
|
||||
ConfirmationAction.JOIN_ANOTHER:
|
||||
_join_game_page.close_page()
|
||||
join_game_requested.emit(_pending_join_endpoint)
|
||||
_pending_join_endpoint = ""
|
||||
_:
|
||||
_action_in_progress = false
|
||||
_begin_root_entry(false)
|
||||
|
|
@ -421,6 +486,7 @@ func _finish_close(reason: CloseReason, restore_controls: bool) -> void:
|
|||
_dim_background.color.a = 0.0
|
||||
_dim_background.hide()
|
||||
_settings_panel.hide()
|
||||
_join_game_page.close_page()
|
||||
_root_page.hide_page()
|
||||
_confirmation_page.hide_page()
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=10 format=3]
|
||||
[gd_scene load_steps=11 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/pause_menu.gd" id="1_script"]
|
||||
[ext_resource type="PackedScene" path="res://ui/settings_panel.tscn" id="2_settings"]
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
[ext_resource type="Resource" path="res://ui/components/bubble_menu/bubble_menu_profile.tres" id="7_profile"]
|
||||
[ext_resource type="Script" path="res://ui/components/bubble_menu/bubble_transition_flurry.gd" id="8_flurry"]
|
||||
[ext_resource type="PackedScene" path="res://ui/components/bubble_menu/bubble_confirmation_page.tscn" id="9_confirmation"]
|
||||
[ext_resource type="PackedScene" path="res://ui/network/join_game_page.tscn" id="10_join_page"]
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -76,8 +77,8 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
script = ExtResource("4_page")
|
||||
page_id = &"pause"
|
||||
bubble_paths = Array[NodePath]([NodePath("BubbleCluster/ResumeButton"), NodePath("BubbleCluster/SaveButton"), NodePath("BubbleCluster/SettingsButton"), NodePath("BubbleCluster/ReturnToTitleButton"), NodePath("BubbleCluster/ResetProgressButton"), NodePath("BubbleCluster/QuitButton")])
|
||||
focus_paths = Array[NodePath]([NodePath("BubbleCluster/ResumeButton"), NodePath("BubbleCluster/SaveButton"), NodePath("BubbleCluster/SettingsButton"), NodePath("BubbleCluster/ReturnToTitleButton"), NodePath("BubbleCluster/ResetProgressButton"), NodePath("BubbleCluster/QuitButton")])
|
||||
bubble_paths = Array[NodePath]([NodePath("BubbleCluster/ResumeButton"), NodePath("BubbleCluster/SaveButton"), NodePath("BubbleCluster/JoinGameButton"), NodePath("BubbleCluster/SettingsButton"), NodePath("BubbleCluster/ReturnToTitleButton"), NodePath("BubbleCluster/ResetProgressButton"), NodePath("BubbleCluster/QuitButton")])
|
||||
focus_paths = Array[NodePath]([NodePath("BubbleCluster/ResumeButton"), NodePath("BubbleCluster/SaveButton"), NodePath("BubbleCluster/JoinGameButton"), NodePath("BubbleCluster/SettingsButton"), NodePath("BubbleCluster/ReturnToTitleButton"), NodePath("BubbleCluster/ResetProgressButton"), NodePath("BubbleCluster/QuitButton")])
|
||||
initial_focus_path = NodePath("BubbleCluster/ResumeButton")
|
||||
back_focus_path = NodePath("BubbleCluster/ResumeButton")
|
||||
maximum_layout_size = Vector2(720, 520)
|
||||
|
|
@ -134,6 +135,19 @@ minimum_font_size = 16
|
|||
maximum_font_size = 23
|
||||
motion_phase = 2.05
|
||||
|
||||
[node name="JoinGameButton" parent="ResponsivePauseStage/PausePresentationScaleRoot/RootPage/BubbleCluster" instance=ExtResource("5_bubble")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 0)
|
||||
text = "join\ngame"
|
||||
accessibility_name = "join game"
|
||||
neutral_size = Vector2(126, 120)
|
||||
desktop_anchor = Vector2(105, 320)
|
||||
compact_anchor = Vector2(105, 320)
|
||||
compact_minimum_size = Vector2(96, 92)
|
||||
minimum_font_size = 15
|
||||
maximum_font_size = 21
|
||||
motion_phase = 2.55
|
||||
|
||||
[node name="ReturnToTitleButton" parent="ResponsivePauseStage/PausePresentationScaleRoot/RootPage/BubbleCluster" instance=ExtResource("5_bubble")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 0)
|
||||
|
|
@ -209,3 +223,13 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="JoinGamePage" parent="ResponsivePauseStage/PausePresentationScaleRoot" instance=ExtResource("10_join_page")]
|
||||
unique_name_in_owner = true
|
||||
z_index = 4
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ const FishDataType = preload("res://fish/fish_data.gd")
|
|||
const FishBuyerProfileType = preload("res://economy/fish_buyer_profile.gd")
|
||||
const FishSaleResultType = preload("res://economy/fish_sale_result.gd")
|
||||
const FishSaleServiceType = preload("res://economy/fish_sale_service.gd")
|
||||
const NetworkSessionType = preload("res://network/network_session.gd")
|
||||
const FishInventoryType = preload("res://inventory/fish_inventory.gd")
|
||||
const FishPoolType = preload("res://fish/fish_pool.gd")
|
||||
const FishingSpotType = preload("res://fishing/fishing_spot.gd")
|
||||
|
|
@ -225,6 +226,7 @@ var _inventory: FishInventoryType
|
|||
var _collection_log: CollectionLogType
|
||||
var _wallet: PlayerWalletType
|
||||
var _sale_service: FishSaleServiceType
|
||||
var _network_session: NetworkSessionType
|
||||
var _default_buyer: FishBuyerProfileType
|
||||
var _catalog: FishPoolType
|
||||
var _fishing_spot: FishingSpotType
|
||||
|
|
@ -353,6 +355,7 @@ func setup(
|
|||
hotbar: PlayerHotbarType,
|
||||
item_catalog: ItemCatalogType,
|
||||
cooler_capacity: PlayerCoolerCapacityType,
|
||||
network_session: NetworkSessionType,
|
||||
) -> void:
|
||||
_player = player
|
||||
_inventory = inventory
|
||||
|
|
@ -366,6 +369,7 @@ func setup(
|
|||
_hotbar = hotbar
|
||||
_item_catalog = item_catalog
|
||||
_cooler_capacity = cooler_capacity
|
||||
_network_session = network_session
|
||||
_fish_selection.clear()
|
||||
if not _inventory.catches_changed.is_connected(_on_inventory_changed):
|
||||
_inventory.catches_changed.connect(_on_inventory_changed)
|
||||
|
|
@ -2337,6 +2341,23 @@ func _update_sale_summary() -> void:
|
|||
_sale_unavailable.text = ""
|
||||
_sale_unavailable.visible = false
|
||||
return
|
||||
if not _can_use_shared_world_actions():
|
||||
_selection_summary.text = (
|
||||
"1 fish selected"
|
||||
if selected_count == 1
|
||||
else "%d fish selected" % selected_count
|
||||
)
|
||||
_selection_status.set_content("selected", str(selected_count))
|
||||
_offer_status.set_content("pelican offer", "host only")
|
||||
_sell_button.disabled = true
|
||||
_sell_bubble.disabled = true
|
||||
_sell_bubble.persistent_mark = false
|
||||
_sell_bubble.refresh_ink_state()
|
||||
_sale_unavailable.text = (
|
||||
"Selling in joined games is coming in a later multiplayer phase."
|
||||
)
|
||||
_sale_unavailable.visible = true
|
||||
return
|
||||
var preview: FishSaleResultType = (
|
||||
_sale_service.preview_batch(selected_ids, _default_buyer)
|
||||
if _sale_service != null
|
||||
|
|
@ -2407,6 +2428,11 @@ func _on_favorite_pressed() -> void:
|
|||
|
||||
|
||||
func _on_sell_pressed() -> void:
|
||||
if not _can_use_shared_world_actions():
|
||||
_transaction_feedback.text = (
|
||||
"Selling in joined games is coming in a later multiplayer phase."
|
||||
)
|
||||
return
|
||||
var selected_ids: Array[StringName] = _fish_selection.get_selected_ids()
|
||||
if (
|
||||
_inventory == null
|
||||
|
|
@ -2455,6 +2481,7 @@ func _on_sell_pressed() -> void:
|
|||
func _on_confirm_sale_pressed() -> void:
|
||||
if (
|
||||
_sale_in_progress
|
||||
or not _can_use_shared_world_actions()
|
||||
or _sale_service == null
|
||||
or _confirmation_catch_ids.is_empty()
|
||||
or _confirmation_buyer == null
|
||||
|
|
@ -2484,6 +2511,13 @@ func _on_confirm_sale_pressed() -> void:
|
|||
_inventory_tab.grab_focus()
|
||||
|
||||
|
||||
func _can_use_shared_world_actions() -> bool:
|
||||
return (
|
||||
_network_session == null
|
||||
or _network_session.can_use_host_gameplay()
|
||||
)
|
||||
|
||||
|
||||
func _close_sale_confirmation() -> void:
|
||||
var was_visible: bool = _sale_confirmation.visible
|
||||
_confirmation_catch_ids.clear()
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ const BubbleClusterType = preload(
|
|||
const TitleConfirmationBubblePageType = preload(
|
||||
"res://ui/title_confirmation_bubble_page.gd"
|
||||
)
|
||||
const NetworkSessionType = preload("res://network/network_session.gd")
|
||||
const SavedServerStoreType = preload("res://network/saved_server_store.gd")
|
||||
const JoinGamePageType = preload("res://ui/network/join_game_page.gd")
|
||||
const DECORATIVE_FISH_TEXTURES: Array[Texture2D] = [
|
||||
preload("res://fish/species/bass/fish_bass_striped.png"),
|
||||
preload("res://fish/species/bluegill/fish_bluegill.png"),
|
||||
|
|
@ -84,8 +87,10 @@ const HOST_PRESENTATION_OUT_DURATION: float = 1.70
|
|||
const HOST_PRESENTATION_IN_DURATION: float = 1.85
|
||||
const HOST_CLUSTER_SAFE_MARGIN: float = 24.0
|
||||
|
||||
signal gameplay_requested
|
||||
signal new_game_requested
|
||||
signal continue_game_requested
|
||||
signal quit_requested
|
||||
signal join_game_requested(endpoint: String)
|
||||
|
||||
enum ConfirmationAction {
|
||||
NONE,
|
||||
|
|
@ -98,6 +103,7 @@ enum ConfirmationAction {
|
|||
@onready var _settings_button: BubbleButtonType = %SettingsButton
|
||||
@onready var _delete_button: BubbleButtonType = %DeleteSaveButton
|
||||
@onready var _quit_button: BubbleButtonType = %QuitButton
|
||||
@onready var _join_game_button: BubbleButtonType = %JoinGameButton
|
||||
@onready var _new_game_label: Label = %NewGameLabel
|
||||
@onready var _delete_save_label: Label = %DeleteSaveLabel
|
||||
@onready var _feedback_label: Label = %FeedbackLabel
|
||||
|
|
@ -129,6 +135,7 @@ enum ConfirmationAction {
|
|||
@onready var _bubble_field: BubbleClusterType = %BubbleField
|
||||
@onready var _start_prompt_center: CenterContainer = %StartPromptCenter
|
||||
@onready var _start_prompt_label: Label = %StartPromptLabel
|
||||
@onready var _join_game_page: JoinGamePageType = %JoinGamePage
|
||||
|
||||
var _save_manager: SaveManagerType
|
||||
var _settings_manager: SettingsManagerType
|
||||
|
|
@ -188,6 +195,7 @@ func _ready() -> void:
|
|||
_on_continue_stats_focus_changed.bind(false)
|
||||
)
|
||||
_new_game_button.pressed.connect(_on_new_game_pressed)
|
||||
_join_game_button.pressed.connect(_open_join_game)
|
||||
_settings_button.pressed.connect(_open_settings)
|
||||
_delete_button.pressed.connect(_on_delete_pressed)
|
||||
%QuitButton.pressed.connect(_on_quit_pressed)
|
||||
|
|
@ -221,9 +229,14 @@ func _ready() -> void:
|
|||
func setup(
|
||||
save_manager: SaveManagerType,
|
||||
settings_manager: SettingsManagerType,
|
||||
network_session: NetworkSessionType,
|
||||
saved_servers: SavedServerStoreType,
|
||||
) -> void:
|
||||
_save_manager = save_manager
|
||||
_settings_manager = settings_manager
|
||||
_join_game_page.setup(network_session, saved_servers, false)
|
||||
_join_game_page.join_requested.connect(join_game_requested.emit)
|
||||
_join_game_page.back_requested.connect(_close_join_game)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
_refresh_save_inspection()
|
||||
show()
|
||||
|
|
@ -239,12 +252,45 @@ func reopen() -> void:
|
|||
_prepare_awaiting_start_input()
|
||||
_reset_confirmation()
|
||||
_settings_panel.hide()
|
||||
_join_game_page.close_page()
|
||||
_refresh_save_inspection()
|
||||
show()
|
||||
_start_decorative_presentation()
|
||||
_start_entry_prompt_animation()
|
||||
|
||||
|
||||
func open_join_game_page(endpoint: String = "") -> void:
|
||||
_cancel_title_entry_transition()
|
||||
_awaiting_start_input = false
|
||||
_start_prompt_center.hide()
|
||||
_presentation_center.hide()
|
||||
_settings_panel.hide()
|
||||
_confirmation_page.hide_page()
|
||||
_join_game_page.open_page(endpoint)
|
||||
|
||||
|
||||
func report_network_error(message: String) -> void:
|
||||
_join_game_page.set_status(message)
|
||||
if not _join_game_page.visible:
|
||||
_feedback_label.text = message
|
||||
_feedback_label.show()
|
||||
_feedback_label.modulate.a = 1.0
|
||||
|
||||
|
||||
func _open_join_game() -> void:
|
||||
if _action_in_progress or _is_confirmation_active():
|
||||
return
|
||||
open_join_game_page()
|
||||
|
||||
|
||||
func _close_join_game() -> void:
|
||||
_join_game_page.close_page()
|
||||
_presentation_center.show()
|
||||
_button_center.show()
|
||||
_start_prompt_center.hide()
|
||||
_focus_initial_button()
|
||||
|
||||
|
||||
func is_awaiting_start_input() -> bool:
|
||||
return _awaiting_start_input
|
||||
|
||||
|
|
@ -347,6 +393,7 @@ func _get_title_buttons() -> Array[BubbleButton]:
|
|||
return [
|
||||
_continue_button,
|
||||
_new_game_button,
|
||||
_join_game_button,
|
||||
_settings_button,
|
||||
_delete_button,
|
||||
_quit_button,
|
||||
|
|
@ -438,6 +485,11 @@ func _process(delta: float) -> void:
|
|||
func _input(event: InputEvent) -> void:
|
||||
if not visible:
|
||||
return
|
||||
if _join_game_page.visible:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
_close_join_game()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if (
|
||||
_title_settings_transition_active
|
||||
or _title_entry_transition_active
|
||||
|
|
@ -851,12 +903,7 @@ func _on_continue_pressed() -> void:
|
|||
return
|
||||
_hide_continue_stats_context()
|
||||
_action_in_progress = true
|
||||
if _save_manager.load_player_data():
|
||||
_feedback_label.text = "save loaded."
|
||||
gameplay_requested.emit()
|
||||
else:
|
||||
_refresh_save_inspection()
|
||||
_feedback_label.text = "failed to load save. the original was preserved."
|
||||
continue_game_requested.emit()
|
||||
_action_in_progress = false
|
||||
|
||||
|
||||
|
|
@ -870,8 +917,7 @@ func _on_new_game_pressed() -> void:
|
|||
return
|
||||
_hide_continue_stats_context()
|
||||
if _inspection.status == SaveInspectionType.Status.MISSING:
|
||||
if _save_manager.initialize_new_game():
|
||||
gameplay_requested.emit()
|
||||
new_game_requested.emit()
|
||||
return
|
||||
if _inspection.status == SaveInspectionType.Status.UNSUPPORTED_VERSION:
|
||||
_feedback_label.text = (
|
||||
|
|
@ -917,6 +963,14 @@ func _on_confirmation_accepted() -> void:
|
|||
var action: ConfirmationAction = _confirmation_action
|
||||
_confirmation_page.lock_interaction()
|
||||
_action_in_progress = true
|
||||
if action == ConfirmationAction.NEW_GAME:
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
_confirmation_transition_generation += 1
|
||||
_cancel_confirmation_transition()
|
||||
_confirmation_page.hide_page()
|
||||
new_game_requested.emit()
|
||||
_action_in_progress = false
|
||||
return
|
||||
if not _save_manager.delete_progression_save():
|
||||
_feedback_label.text = "failed to delete saved progression."
|
||||
_action_in_progress = false
|
||||
|
|
@ -925,15 +979,8 @@ func _on_confirmation_accepted() -> void:
|
|||
return
|
||||
_save_manager.initialize_new_game()
|
||||
_refresh_save_inspection()
|
||||
if action == ConfirmationAction.NEW_GAME:
|
||||
_confirmation_action = ConfirmationAction.NONE
|
||||
_confirmation_transition_generation += 1
|
||||
_cancel_confirmation_transition()
|
||||
_confirmation_page.hide_page()
|
||||
gameplay_requested.emit()
|
||||
else:
|
||||
_feedback_label.text = "saved progression deleted."
|
||||
_begin_confirmation_return()
|
||||
_feedback_label.text = "saved progression deleted."
|
||||
_begin_confirmation_return()
|
||||
_action_in_progress = false
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=13 format=3]
|
||||
[gd_scene load_steps=14 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/title_screen.gd" id="1_script"]
|
||||
[ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"]
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
[ext_resource type="Script" path="res://ui/components/bubble_menu/bubble_cluster.gd" id="8_bubble_cluster"]
|
||||
[ext_resource type="Resource" path="res://ui/components/bubble_menu/bubble_menu_profile.tres" id="9_bubble_profile"]
|
||||
[ext_resource type="PackedScene" path="res://ui/title_confirmation_bubble_page.tscn" id="10_confirmation_page"]
|
||||
[ext_resource type="PackedScene" path="res://ui/network/join_game_page.tscn" id="11_join_page"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_title_water"]
|
||||
shader = ExtResource("4_water_shader")
|
||||
|
|
@ -314,6 +315,28 @@ motion_period = 4.9
|
|||
motion_phase = 2.5
|
||||
deformation_period = 6.3
|
||||
|
||||
[node name="JoinGameButton" type="Button" parent="ResponsiveTitleStage/TitlePresentationScaleRoot/Center/MainContent/ButtonCenter/BubbleLayoutSlot/BubbleMotionRoot/BubbleField"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 126.0
|
||||
offset_top = 224.0
|
||||
offset_right = 248.0
|
||||
offset_bottom = 342.0
|
||||
text = "join\ngame"
|
||||
script = ExtResource("7_bubble_button")
|
||||
profile = ExtResource("9_bubble_profile")
|
||||
neutral_size = Vector2(122, 118)
|
||||
desktop_anchor = Vector2(187, 268)
|
||||
compact_anchor = Vector2(187, 268)
|
||||
compact_minimum_size = Vector2(82, 80)
|
||||
minimum_font_size = 15
|
||||
maximum_font_size = 22
|
||||
horizontal_amplitude = 1.7
|
||||
vertical_amplitude = 3.8
|
||||
motion_period = 5.2
|
||||
motion_phase = 3.1
|
||||
deformation_amplitude = 0.015
|
||||
deformation_period = 5.7
|
||||
|
||||
[node name="DeleteSaveButton" type="Button" parent="ResponsiveTitleStage/TitlePresentationScaleRoot/Center/MainContent/ButtonCenter/BubbleLayoutSlot/BubbleMotionRoot/BubbleField"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = -11.0
|
||||
|
|
@ -407,3 +430,13 @@ offset_right = 360.0
|
|||
offset_bottom = 300.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="JoinGamePage" parent="ResponsiveTitleStage/TitlePresentationScaleRoot" instance=ExtResource("11_join_page")]
|
||||
unique_name_in_owner = true
|
||||
z_index = 220
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue