mirror of
https://github.com/Steffo99/nanogolf.git
synced 2024-11-25 01:24:18 +00:00
done
This commit is contained in:
parent
14fbad5261
commit
3acbd84bc3
5 changed files with 143 additions and 2 deletions
4
scenes/hole_score.tscn
Normal file
4
scenes/hole_score.tscn
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[gd_scene format=3 uid="uid://c4o6rtunoqywm"]
|
||||||
|
|
||||||
|
[node name="HoleScore" type="Label"]
|
||||||
|
text = "5"
|
|
@ -19,6 +19,10 @@ var lobby_menu_instance: LobbyMenu = null
|
||||||
const game_hud_scene: PackedScene = preload("res://scenes/game_hud.tscn")
|
const game_hud_scene: PackedScene = preload("res://scenes/game_hud.tscn")
|
||||||
var game_hud_instance: GameHUD = null
|
var game_hud_instance: GameHUD = null
|
||||||
|
|
||||||
|
const results_menu_scene: PackedScene = preload("res://scenes/results_menu.tscn")
|
||||||
|
var results_menu_instance: ResultsMenu = null
|
||||||
|
|
||||||
|
|
||||||
func init_main_menu() -> void:
|
func init_main_menu() -> void:
|
||||||
main_menu_instance = main_menu_scene.instantiate()
|
main_menu_instance = main_menu_scene.instantiate()
|
||||||
main_menu_instance.hosting_confirmed.connect(_on_hosting_confirmed)
|
main_menu_instance.hosting_confirmed.connect(_on_hosting_confirmed)
|
||||||
|
@ -130,6 +134,17 @@ func deinit_game_hud() -> void:
|
||||||
game_hud_instance.queue_free()
|
game_hud_instance.queue_free()
|
||||||
game_hud_instance = null
|
game_hud_instance = null
|
||||||
|
|
||||||
|
func init_results_menu() -> void:
|
||||||
|
results_menu_instance = results_menu_scene.instantiate()
|
||||||
|
results_menu_instance.player_dir = client_game_instance.player_dir
|
||||||
|
results_menu_instance.leave_confirmed.connect(_on_lost_connection)
|
||||||
|
interface_instance.add_child(results_menu_instance)
|
||||||
|
|
||||||
|
func deinit_results_menu() -> void:
|
||||||
|
results_menu_instance.queue_free()
|
||||||
|
results_menu_instance = null
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
init_main_menu()
|
init_main_menu()
|
||||||
|
|
||||||
|
@ -163,7 +178,7 @@ func _on_phase_changed(old: PhaseTracker.Phase, new: PhaseTracker.Phase) -> void
|
||||||
PhaseTracker.Phase.PLAYING:
|
PhaseTracker.Phase.PLAYING:
|
||||||
deinit_game_hud()
|
deinit_game_hud()
|
||||||
PhaseTracker.Phase.ENDED:
|
PhaseTracker.Phase.ENDED:
|
||||||
pass # TODO
|
deinit_results_menu()
|
||||||
# Then, initialize the new one
|
# Then, initialize the new one
|
||||||
match new:
|
match new:
|
||||||
PhaseTracker.Phase.LOBBY:
|
PhaseTracker.Phase.LOBBY:
|
||||||
|
@ -171,4 +186,4 @@ func _on_phase_changed(old: PhaseTracker.Phase, new: PhaseTracker.Phase) -> void
|
||||||
PhaseTracker.Phase.PLAYING:
|
PhaseTracker.Phase.PLAYING:
|
||||||
init_game_hud()
|
init_game_hud()
|
||||||
PhaseTracker.Phase.ENDED:
|
PhaseTracker.Phase.ENDED:
|
||||||
pass # TODO
|
init_results_menu()
|
||||||
|
|
|
@ -111,3 +111,4 @@ func play_putt_sound(putt_vector: Vector2):
|
||||||
var putt_impulse: float = putt_vector.length()
|
var putt_impulse: float = putt_vector.length()
|
||||||
sound.volume_db = putt_volume.sample(putt_impulse / putt_max_impulse)
|
sound.volume_db = putt_volume.sample(putt_impulse / putt_max_impulse)
|
||||||
sound.play()
|
sound.play()
|
||||||
|
|
||||||
|
|
61
scenes/results_menu.gd
Normal file
61
scenes/results_menu.gd
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
extends Control
|
||||||
|
class_name ResultsMenu
|
||||||
|
|
||||||
|
|
||||||
|
@export_category("References")
|
||||||
|
|
||||||
|
@export var results_grid: GridContainer
|
||||||
|
|
||||||
|
const label_scene: PackedScene = preload("res://scenes/player_label.tscn")
|
||||||
|
|
||||||
|
|
||||||
|
var player_dir: PlayerNodeDirectory = null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var max_hole_scores = 0
|
||||||
|
|
||||||
|
for playernode in player_dir.get_children():
|
||||||
|
var player: PlayerLabel = label_scene.instantiate()
|
||||||
|
player.set_player_name(playernode.player_name)
|
||||||
|
player.set_player_color(playernode.player_color)
|
||||||
|
player.set_possessed(playernode.get_multiplayer_authority())
|
||||||
|
results_grid.add_child(player)
|
||||||
|
|
||||||
|
max_hole_scores = max(max_hole_scores, len(playernode.hole_scores))
|
||||||
|
var total_score = 0
|
||||||
|
for hole_score in playernode.hole_scores:
|
||||||
|
var score: PlayerLabel = label_scene.instantiate()
|
||||||
|
if hole_score != -1:
|
||||||
|
score.text = "%d" % hole_score
|
||||||
|
else:
|
||||||
|
score.text = "-"
|
||||||
|
score.set_player_color(playernode.player_color)
|
||||||
|
score.set_possessed(playernode.get_multiplayer_authority())
|
||||||
|
score.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||||
|
score.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||||
|
results_grid.add_child(score)
|
||||||
|
if hole_score == -1 or total_score == -1:
|
||||||
|
total_score = -1
|
||||||
|
else:
|
||||||
|
total_score += hole_score
|
||||||
|
|
||||||
|
var total: PlayerLabel = label_scene.instantiate()
|
||||||
|
if total_score != -1:
|
||||||
|
total.text = "[%d]" % total_score
|
||||||
|
else:
|
||||||
|
total.text = "-"
|
||||||
|
total.set_player_color(playernode.player_color)
|
||||||
|
total.set_possessed(playernode.get_multiplayer_authority())
|
||||||
|
total.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||||
|
total.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||||
|
results_grid.add_child(total)
|
||||||
|
|
||||||
|
results_grid.columns = max_hole_scores + 2
|
||||||
|
|
||||||
|
|
||||||
|
signal leave_confirmed
|
||||||
|
|
||||||
|
func _on_leave_button_pressed() -> void:
|
||||||
|
leave_confirmed.emit()
|
60
scenes/results_menu.tscn
Normal file
60
scenes/results_menu.tscn
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cdieahvbjaqx6"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scenes/results_menu.gd" id="1_b1mjj"]
|
||||||
|
|
||||||
|
[node name="ResultsMenu" type="Control" node_paths=PackedStringArray("results_grid")]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_b1mjj")
|
||||||
|
results_grid = NodePath("Layout/ResultsList/Scrollable/PlayerResults")
|
||||||
|
|
||||||
|
[node name="Layout" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Title" type="RichTextLabel" parent="Layout"]
|
||||||
|
layout_mode = 2
|
||||||
|
bbcode_enabled = true
|
||||||
|
text = "[center][font_size=32px][b]Nanogolf[/b][/font_size]
|
||||||
|
Risultati[/center]"
|
||||||
|
fit_content = true
|
||||||
|
|
||||||
|
[node name="Padding" type="Control" parent="Layout"]
|
||||||
|
custom_minimum_size = Vector2(0, 16)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ResultsList" type="PanelContainer" parent="Layout"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Scrollable" type="ScrollContainer" parent="Layout/ResultsList"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="PlayerResults" type="GridContainer" parent="Layout/ResultsList/Scrollable"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 6
|
||||||
|
theme_override_constants/h_separation = 12
|
||||||
|
theme_override_constants/v_separation = 12
|
||||||
|
columns = 7
|
||||||
|
|
||||||
|
[node name="Padding2" type="Control" parent="Layout"]
|
||||||
|
custom_minimum_size = Vector2(0, 16)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="Layout"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="LeaveButton" type="Button" parent="Layout/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Esci"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Layout/HBoxContainer/LeaveButton" to="." method="_on_leave_button_pressed"]
|
Loading…
Reference in a new issue