Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions entities/game/debug_tool/scenes/DebugPanel.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[gd_scene format=3 uid="uid://laeqw1xjwd1b"]

[ext_resource type="Script" uid="uid://be2gfsbg286u5" path="res://entities/game/debug_tool/scripts/DebugPanel.gd" id="1_8hepm"]

[node name="DebugPanel" type="Control" unique_id=190453148]
physics_interpolation_mode = 0
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
script = ExtResource("1_8hepm")
metadata/_custom_type_script = "uid://be2gfsbg286u5"

[node name="CenterContainer" type="CenterContainer" parent="." unique_id=257169691]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -40.0
offset_right = 40.0
grow_vertical = 0
mouse_filter = 2

[node name="ButtonHook" type="PanelContainer" parent="CenterContainer" unique_id=1406501716]
unique_name_in_owner = true
layout_mode = 2
7 changes: 7 additions & 0 deletions entities/game/debug_tool/scripts/DebugFunctionality.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class_name DebugFunctionality extends Resource

func get_display_name() -> String:
return ""

func execute_function(_memory_game: MemoryGame) -> void:
pass
1 change: 1 addition & 0 deletions entities/game/debug_tool/scripts/DebugFunctionality.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://c1wsjd5pkvtiq
29 changes: 29 additions & 0 deletions entities/game/debug_tool/scripts/DebugPanel.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class_name DebugPanel extends Control

@export var memory_game: MemoryGame
@export var debug_functions: Array[DebugFunctionality]

@onready var button_root: Control = get_node("%ButtonHook")

func _init() -> void:
visible = false
GlobalGameManagerAccess.game_manager.debug_mode.connect(toggle_visibility)
toggle_visibility(GlobalGameManagerAccess.game_manager.is_debug)

func _ready() -> void:
if not OS.is_debug_build():
queue_free()
return
if memory_game == null:
queue_free()
_create_buttons()

func _create_buttons() -> void:
for function: DebugFunctionality in debug_functions:
var child: Button = Button.new()
child.text = function.get_display_name()
child.pressed.connect(function.execute_function.bind(memory_game))
button_root.add_child(child)

func toggle_visibility(new_state: bool) -> void:
visible = new_state
1 change: 1 addition & 0 deletions entities/game/debug_tool/scripts/DebugPanel.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://be2gfsbg286u5
7 changes: 7 additions & 0 deletions entities/game/debug_tool/scripts/FinishGameFunction.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class_name FinishGame extends DebugFunctionality

func get_display_name() -> String:
return "Finish Game"

func execute_function(memory_game: MemoryGame) -> void:
memory_game.show_game_end_screen()
1 change: 1 addition & 0 deletions entities/game/debug_tool/scripts/FinishGameFunction.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://ce067cc441ff1
2 changes: 2 additions & 0 deletions entities/game/finish_game/scenes/FinishGame.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ script = ExtResource("6_f0a12")
finish_game_node = NodePath("../../../../../..")

[connection signal="finish_game_ui_loaded" from="." to="PanelContainer/MarginContainer/VBoxContainer2/BodyContainer/PanelContainer/VBoxContainer2/Player List" method="build_player_statistic"]
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer2/Footer/Buttons/OkButton" to="." method="hide"]
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer2/Footer/Buttons/ReplayGame" to="." method="hide"]
9 changes: 4 additions & 5 deletions entities/game/finish_game/scripts/ReplayGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ extends ClickableButton

func _ready() -> void:
await get_tree().physics_frame
if finish_game_node.played_deck == null:
if finish_game_node.played_deck == null or was_multiplayer_game():
queue_free()

func _pressed() -> void:
get_tree().paused = false
if multiplayer.multiplayer_peer != null:
multiplayer.multiplayer_peer.close()
GlobalGameManagerAccess.get_game_manager().play_network_game(finish_game_node.manager.get_players(), finish_game_node.played_deck, get_screen_position())
return
GlobalGameManagerAccess.get_game_manager().play_game_with_position(finish_game_node.manager.get_players(), finish_game_node.played_deck, get_screen_position())

func was_multiplayer_game() -> bool:
return not multiplayer.multiplayer_peer is OfflineMultiplayerPeer
16 changes: 14 additions & 2 deletions entities/game/memory_game/scenes/MemoryGame.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
[ext_resource type="Texture2D" uid="uid://vk4fpd7xo01j" path="res://assets/sprites/Axuree/wood_medium.png" id="23_a3528"]
[ext_resource type="Script" uid="uid://btm576yjkyt4j" path="res://entities/game/memory_game/scripts/CardSpawner.gd" id="26_a3528"]
[ext_resource type="Script" uid="uid://drr3p4wba2ys3" path="res://entities/game/memory_game/scripts/systems/NetworkHandler.gd" id="29_kihnp"]
[ext_resource type="PackedScene" uid="uid://laeqw1xjwd1b" path="res://entities/game/debug_tool/scenes/DebugPanel.tscn" id="33_j82c0"]
[ext_resource type="Script" uid="uid://c1wsjd5pkvtiq" path="res://entities/game/debug_tool/scripts/DebugFunctionality.gd" id="34_4hsit"]
[ext_resource type="Script" uid="uid://ce067cc441ff1" path="res://entities/game/debug_tool/scripts/FinishGameFunction.gd" id="35_imof5"]
[ext_resource type="Script" uid="uid://p5xd1ppjr4ph" path="res://entities/game/memory_game/scripts/systems/TutorialStateSystem.gd" id="40_1resq"]

[sub_resource type="Resource" id="Resource_kihnp"]
Expand Down Expand Up @@ -60,6 +63,10 @@ script = ExtResource("17_tgl34")
button_action_name = "zoom_in"
metadata/_custom_type_script = "uid://cgdnmg4wop2a6"

[sub_resource type="Resource" id="Resource_8rpam"]
script = ExtResource("35_imof5")
metadata/_custom_type_script = "uid://ce067cc441ff1"

[node name="MemoryGame" type="Node2D" unique_id=648295195 node_paths=PackedStringArray("game_nodes_to_show", "card_target_node")]
process_mode = 1
script = ExtResource("1_13jq5")
Expand Down Expand Up @@ -211,8 +218,13 @@ grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2

[node name="DebugPanel" parent="UI" unique_id=190453148 node_paths=PackedStringArray("memory_game") instance=ExtResource("33_j82c0")]
memory_game = NodePath("../..")
debug_functions = Array[ExtResource("34_4hsit")]([SubResource("Resource_8rpam")])

[connection signal="game_paused" from="." to="Systems/PlayerInputSystem" method="game_paused"]
[connection signal="game_paused" from="." to="World/Camera2D" method="game_paused"]
[connection signal="game_was_finished" from="." to="World/Camera2D" method="queue_free"]
[connection signal="load_game" from="." to="Systems/CardSpawnerSystem" method="place_cards_from_deck"]
[connection signal="request_popup" from="." to="Systems/PopupSystem" method="add_and_show_popup"]
[connection signal="force_close_popup" from="Systems/GameStateSystem" to="Systems/PopupSystem" method="force_close_popup_with_id"]
Expand All @@ -222,20 +234,20 @@ mouse_filter = 2
[connection signal="state_changed" from="Systems/GameStateSystem" to="Systems/PlayerSystem" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="Systems/AiAgentSystem" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="Systems/PlayerInputSystem" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="Systems/NetworkHandlerSystem" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="World/Background" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="World/Cards" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="World/Camera2D" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="UI/PlayersOverlay" method="game_state_changed"]
[connection signal="state_changed" from="Systems/GameStateSystem" to="Systems/NetworkHandlerSystem" method="game_state_changed"]
[connection signal="tutorial_requested" from="Systems/TutorialStateSystem" to="Systems/PopupSystem" method="add_and_show_popup"]
[connection signal="player_added" from="Systems/PlayerSystem" to="UI/PlayersOverlay" method="add_player"]
[connection signal="player_changed" from="Systems/PlayerSystem" to="UI/PlayersOverlay" method="player_changed"]
[connection signal="player_resource_changed" from="Systems/PlayerSystem" to="Systems/TutorialStateSystem" method="player_changed"]
[connection signal="player_resource_changed" from="Systems/PlayerSystem" to="Systems/AiAgentSystem" method="player_changed"]
[connection signal="player_resource_changed" from="Systems/PlayerSystem" to="Systems/PlayerInputSystem" method="player_changed"]
[connection signal="player_resource_changed" from="Systems/PlayerSystem" to="Systems/NetworkHandlerSystem" method="player_changed"]
[connection signal="player_resource_changed" from="Systems/PlayerSystem" to="World/Cards" method="player_changed"]
[connection signal="player_resource_changed" from="Systems/PlayerSystem" to="World/Camera2D" method="player_changed"]
[connection signal="player_resource_changed" from="Systems/PlayerSystem" to="Systems/NetworkHandlerSystem" method="player_changed"]
[connection signal="player_score_changed" from="Systems/PlayerSystem" to="UI/PlayersOverlay" method="player_scored"]
[connection signal="card_movement" from="Systems/PlayerInputSystem" to="World/Cards" method="parse_movement"]
[connection signal="confirm_current_card" from="Systems/PlayerInputSystem" to="World/Cards" method="confirm_current_card"]
Expand Down
1 change: 0 additions & 1 deletion entities/game/memory_game/scripts/CardSpawner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func place_cards_from_deck(deck_to_use: MemoryDeckResource) -> void:
_place_thread.start(_add_cards_to_field_async.bind(cards, _card_target_node))

await card_placing_done
_place_thread = null

for card: CardTemplate in cards:
card.visible = true
Expand Down
1 change: 0 additions & 1 deletion entities/game/memory_game/scripts/MemoryGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var game_menu: GamePauseMenu = null

var ending_round: bool = false

var message_banner: PackedScene = preload("res://entities/game/bottom_message_banner/scenes/BottomMessageBanner.tscn")
var auto_close_popup: PackedScene = preload("res://entities/game/auto_close_popup/scenes/AutoClosePopup.tscn")
var last_message_banner_id: int = -1

Expand Down
40 changes: 28 additions & 12 deletions shared/global_entities/game_manager/scripts/GameManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,13 @@ func translate_built_in_decks() -> void:
translated_build_in_decks.append(new_deck)

func close_game_with_position(transition_start_position: Vector2) -> void:
var nodes: Array[Node] = get_children()
var previous_children: Array[Node] = _get_active_children()
var animation_scene: AnimationScene = await ScreenTransitionManager.transit_screen_with_position(main_menu_template, transition_start_position)
await animation_scene.animation_done
for node: Node in nodes:
if node == null or node.is_queued_for_deletion():
continue
if node.name == "GlobalFixedNode" or node.is_in_group("static"):
for child: Node in previous_children:
if child == null or child.is_queued_for_deletion():
continue
node.queue_free()

child.queue_free()

func close_game() -> void:
close_game_with_position(Vector2.ZERO)
Expand Down Expand Up @@ -243,6 +240,7 @@ func _rpc_load_game(game_data: Dictionary) -> void:

func load_game(card_deck: Resource, players: Array[PlayerResource], click_position: Vector2) -> void:
var current_player_id: int = 0
var active_nodes: Array[Node] = _get_active_children()
for player: PlayerResource in players:
player.id = current_player_id
current_player_id = current_player_id + 1
Expand All @@ -256,12 +254,20 @@ func load_game(card_deck: Resource, players: Array[PlayerResource], click_positi
)


var old_camera: Camera2D = get_viewport().get_camera_2d()
var loading_screen: LoadingScreen = loading_screen_template.instantiate() as LoadingScreen
loading_screen.add_to_group("game_initialize_scene")
loading_screen.set_follow_up_node(game_scene_node)

await ScreenTransitionManager.transit_screen_by_node_with_position(loading_screen, click_position, false)
if old_camera != null and not old_camera.is_queued_for_deletion():
old_camera.zoom = Vector2.ONE
old_camera.queue_free()
add_child(game_scene_node)
for node: Node in active_nodes:
if node == null or node.is_queued_for_deletion():
continue
node.queue_free()


func get_available_decks() -> Array[MemoryDeckResource]:
Expand All @@ -273,10 +279,13 @@ func get_available_decks() -> Array[MemoryDeckResource]:
return return_array

func clear_all_nodes() -> void:
for child: Node in get_children():
if child.name == "GlobalFixedNode" or child.is_in_group("static"):
continue
remove_child(child)
for child: Node in get_children():
if child == null or child.is_queued_for_deletion():
continue
if child.name == "GlobalFixedNode" or child.is_in_group("static"):
continue
remove_child(child)
child.queue_free()

func loading_data_done() -> void:
if initial_menu_shown:
Expand All @@ -290,4 +299,11 @@ func loading_data_done() -> void:
current_loading_node.call("destroy")
return
current_loading_node.queue_free()
#open_menu(main_menu_template)

func _get_active_children() -> Array[Node]:
var children: Array[Node] = []
for child: Node in get_children():
if child == null or child.is_queued_for_deletion():
continue
children.append(child)
return children
Loading