diff options
-rw-r--r-- | client/game.gd | 2 | ||||
-rw-r--r-- | client/menu/game.gd | 5 | ||||
-rw-r--r-- | client/menu/overlay.tscn | 21 | ||||
-rw-r--r-- | client/menu/rating/desaturate.gdshader | 7 | ||||
-rw-r--r-- | client/menu/rating/rating.gd | 37 | ||||
-rw-r--r-- | client/menu/rating/rating.tscn | 147 | ||||
-rw-r--r-- | client/menu/theme/paper_texture.tres | 14 | ||||
-rw-r--r-- | client/multiplayer.gd | 12 | ||||
-rw-r--r-- | client/project.godot | 2 |
9 files changed, 229 insertions, 18 deletions
diff --git a/client/game.gd b/client/game.gd index 5c52b11e..4ac28d2b 100644 --- a/client/game.gd +++ b/client/game.gd @@ -113,6 +113,8 @@ func _ready(): ) mp.movement_sync.connect(func(): + if not players.has(player_id): + return var player_instance: ControllablePlayer = players[player_id] player_instance.position_ = last_position ) diff --git a/client/menu/game.gd b/client/menu/game.gd index be501d2c..06f9fbae 100644 --- a/client/menu/game.gd +++ b/client/menu/game.gd @@ -16,12 +16,14 @@ # extends Menu +@onready var game: Game = $Game @onready var debug_label = $Debug @onready var overlay = $Overlay @onready var popup_message: PopupMessage = $PopupMessage func _ready(): get_tree().get_root().connect("go_back_requested", open_ingame_menu) + game.mp.show_rating.connect(show_rating) super() func _input(_event): @@ -38,3 +40,6 @@ func open_ingame_menu(): if popup != null: return Sound.play_click() submenu("res://menu/ingame.tscn") + +func show_rating(stars: int, score: int): + submenu("res://menu/rating/rating.tscn", [stars, score]) diff --git a/client/menu/overlay.tscn b/client/menu/overlay.tscn index 69a8df8e..e28013db 100644 --- a/client/menu/overlay.tscn +++ b/client/menu/overlay.tscn @@ -1,27 +1,14 @@ -[gd_scene load_steps=8 format=3 uid="uid://bpikve6wlsjfl"] +[gd_scene load_steps=6 format=3 uid="uid://bpikve6wlsjfl"] [ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_4kujw"] [ext_resource type="Script" path="res://menu/overlay.gd" id="2_kbjds"] +[ext_resource type="Texture2D" uid="uid://chxkwohi56cxx" path="res://menu/theme/paper_texture.tres" id="3_oum5g"] [ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/font-sansita-swashed.woff2" id="3_u54fv"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_04ujj"] bg_color = Color(0, 0, 0, 0) -[sub_resource type="Gradient" id="Gradient_pkrjd"] -colors = PackedColorArray(0.917969, 0.866454, 0.770122, 1, 0.832031, 0.781817, 0.666307, 1) - -[sub_resource type="FastNoiseLite" id="FastNoiseLite_k7p6k"] -noise_type = 0 -frequency = 0.0084 -domain_warp_enabled = true -domain_warp_frequency = -1.465 - -[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_jq3d3"] -color_ramp = SubResource("Gradient_pkrjd") -noise = SubResource("FastNoiseLite_k7p6k") - [node name="Overlay" type="PanelContainer"] -visible = false anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -54,7 +41,7 @@ offset_bottom = 185.0 grow_horizontal = 2 grow_vertical = 2 rotation = 0.0610865 -texture = SubResource("NoiseTexture2D_jq3d3") +texture = ExtResource("3_oum5g") [node name="Margin" type="MarginContainer" parent="Score/Paper"] layout_mode = 1 @@ -163,7 +150,7 @@ offset_bottom = 393.0 grow_horizontal = 2 grow_vertical = 2 rotation = 0.0610865 -texture = SubResource("NoiseTexture2D_jq3d3") +texture = ExtResource("3_oum5g") [node name="Line" type="HBoxContainer" parent="Time/Paper"] layout_mode = 0 diff --git a/client/menu/rating/desaturate.gdshader b/client/menu/rating/desaturate.gdshader new file mode 100644 index 00000000..e6861560 --- /dev/null +++ b/client/menu/rating/desaturate.gdshader @@ -0,0 +1,7 @@ +shader_type canvas_item; + +uniform float t : hint_range(0.0, 1.0); + +void fragment() { + COLOR.rgb = mix(vec3(pow((COLOR.r+COLOR.g+COLOR.b)/3.,3.)),COLOR.rgb,t); +} diff --git a/client/menu/rating/rating.gd b/client/menu/rating/rating.gd new file mode 100644 index 00000000..faa0ba59 --- /dev/null +++ b/client/menu/rating/rating.gd @@ -0,0 +1,37 @@ +extends Menu + +const PARTICLE_AMOUNTS = [0, 6, 32, 128] + +@onready var title: Label = $MarginContainer/PanelContainer/VBoxContainer/Text/Title +@onready var subtitle: Label = $MarginContainer/PanelContainer/VBoxContainer/Text/Subtitle +@onready var stars = $MarginContainer/PanelContainer/VBoxContainer/Stars.get_children() +@onready var star_timer = $StarTimer +@onready var particles = $MarginContainer/PanelContainer/Particles + +func _ready(): + super() + show_rating(data[0], data[1]) + +func show_rating(stars_: int, points: int): + match stars_: + 0: title.text = tr("Poor service") + 1: title.text = tr("Acceptable service") + 2: title.text = tr("Good service") + 3: title.text = tr("Excellent service") + + subtitle.text = tr("You collected %s points") % points + + for i in range(0, stars_): + var star: TextureRect = stars[i] + star_timer.start() + await star_timer.timeout + star.material.set_shader_parameter("t", 1) + star.get_node("Sound").play() + + particles.amount = PARTICLE_AMOUNTS[stars_] + + if stars_ > 0: + particles.emitting = true + +func _on_close_pressed(): + exit() diff --git a/client/menu/rating/rating.tscn b/client/menu/rating/rating.tscn new file mode 100644 index 00000000..8dbe50dd --- /dev/null +++ b/client/menu/rating/rating.tscn @@ -0,0 +1,147 @@ +[gd_scene load_steps=12 format=3 uid="uid://buu3cdpigs8qq"] + +[ext_resource type="Texture2D" uid="uid://b10goh4dsa3b0" path="res://player/star.webp" id="1_7qv7r"] +[ext_resource type="Shader" path="res://menu/rating/desaturate.gdshader" id="1_pddsm"] +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_uwajf"] +[ext_resource type="Script" path="res://menu/rating/rating.gd" id="2_cq0se"] +[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/dark_blur_material.tres" id="4_hdurb"] +[ext_resource type="AudioStream" uid="uid://camy77x26mmpv" path="res://menu/sounds/success.ogg" id="5_tutpj"] + +[sub_resource type="Curve" id="Curve_dqga7"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.0954774, 1), 0.262418, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Gradient" id="Gradient_majwe"] +offsets = PackedFloat32Array(0, 0.0584795, 1) +colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_oi7xd"] +shader = ExtResource("1_pddsm") +shader_parameter/t = 0.0 + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_ney6s"] +shader = ExtResource("1_pddsm") +shader_parameter/t = 0.0 + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_27tx1"] +shader = ExtResource("1_pddsm") +shader_parameter/t = 0.0 + +[node name="Rating" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_uwajf") +script = ExtResource("2_cq0se") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 128 +theme_override_constants/margin_top = 64 +theme_override_constants/margin_right = 128 +theme_override_constants/margin_bottom = 64 + +[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"] +material = ExtResource("4_hdurb") +layout_mode = 2 + +[node name="Particles" type="CPUParticles2D" parent="MarginContainer/PanelContainer"] +position = Vector2(544, 292) +emitting = false +amount = 32 +texture = ExtResource("1_7qv7r") +emission_shape = 3 +emission_rect_extents = Vector2(512, 256) +direction = Vector2(0, -1) +initial_velocity_min = 256.0 +initial_velocity_max = 256.0 +angular_velocity_min = -30.0 +angular_velocity_max = 30.0 +angle_min = -20.0 +angle_max = 20.0 +scale_amount_min = 0.1 +scale_amount_max = 0.2 +scale_amount_curve = SubResource("Curve_dqga7") +color_ramp = SubResource("Gradient_majwe") + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"] +layout_mode = 2 +theme_override_constants/separation = 64 +alignment = 1 + +[node name="Text" type="VBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Title" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Text"] +layout_mode = 2 +theme_override_font_sizes/font_size = 48 +text = "Title here" +horizontal_alignment = 1 + +[node name="Subtitle" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Text"] +layout_mode = 2 +theme_override_font_sizes/font_size = 24 +text = "Subtitle here" +horizontal_alignment = 1 + +[node name="Stars" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer"] +layout_mode = 2 +alignment = 1 + +[node name="Star1" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/Stars"] +material = SubResource("ShaderMaterial_oi7xd") +custom_minimum_size = Vector2(128, 128) +layout_mode = 2 +texture = ExtResource("1_7qv7r") +expand_mode = 1 +stretch_mode = 5 + +[node name="Sound" type="AudioStreamPlayer" parent="MarginContainer/PanelContainer/VBoxContainer/Stars/Star1"] +stream = ExtResource("5_tutpj") +pitch_scale = 1.5 + +[node name="Star2" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/Stars"] +material = SubResource("ShaderMaterial_ney6s") +custom_minimum_size = Vector2(128, 128) +layout_mode = 2 +texture = ExtResource("1_7qv7r") +expand_mode = 1 +stretch_mode = 5 + +[node name="Sound" type="AudioStreamPlayer" parent="MarginContainer/PanelContainer/VBoxContainer/Stars/Star2"] +stream = ExtResource("5_tutpj") +pitch_scale = 1.65 + +[node name="Star3" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/Stars"] +material = SubResource("ShaderMaterial_27tx1") +custom_minimum_size = Vector2(128, 128) +layout_mode = 2 +texture = ExtResource("1_7qv7r") +expand_mode = 1 +stretch_mode = 5 + +[node name="Sound" type="AudioStreamPlayer" parent="MarginContainer/PanelContainer/VBoxContainer/Stars/Star3"] +stream = ExtResource("5_tutpj") +pitch_scale = 1.9 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer"] +layout_mode = 2 +alignment = 1 + +[node name="Close" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Accept" + +[node name="StarTimer" type="Timer" parent="."] +wait_time = 0.5 +one_shot = true + +[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/Close" to="." method="_on_close_pressed"] diff --git a/client/menu/theme/paper_texture.tres b/client/menu/theme/paper_texture.tres new file mode 100644 index 00000000..2c681244 --- /dev/null +++ b/client/menu/theme/paper_texture.tres @@ -0,0 +1,14 @@ +[gd_resource type="NoiseTexture2D" load_steps=3 format=3 uid="uid://chxkwohi56cxx"] + +[sub_resource type="Gradient" id="Gradient_pkrjd"] +colors = PackedColorArray(0.917969, 0.866454, 0.770122, 1, 0.832031, 0.781817, 0.666307, 1) + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_k7p6k"] +noise_type = 0 +frequency = 0.0084 +domain_warp_enabled = true +domain_warp_frequency = -1.465 + +[resource] +color_ramp = SubResource("Gradient_pkrjd") +noise = SubResource("FastNoiseLite_k7p6k") diff --git a/client/multiplayer.gd b/client/multiplayer.gd index c301c401..132c6705 100644 --- a/client/multiplayer.gd +++ b/client/multiplayer.gd @@ -54,6 +54,8 @@ signal hide_score() signal server_message(text: String) signal replay_start() signal connection_closed(reason: String) +signal show_rating(stars: int, points: int) +signal show_book() # TODO: Connect this const VERSION_MAJOR: int = 2 const VERSION_MINOR: int = 0 @@ -253,6 +255,16 @@ func handle_packet(bytes: PackedByteArray): score.emit(demands_failed, demands_completed, points, time_remaining) else: hide_score.emit() + "menu": + var menu: String = decoded["menu"] + match menu: + "book": + show_book.emit() + "score": + var data: Dictionary = decoded["data"] + var stars = data["stars"] + var points = data["points"] + show_rating.emit(stars, points) "server_message": var text = decoded["text"] server_message.emit(text) diff --git a/client/project.godot b/client/project.godot index 8ef3527c..714b859c 100644 --- a/client/project.godot +++ b/client/project.godot @@ -185,7 +185,7 @@ zoom_out_discrete={ [internationalization] locale/translations=PackedStringArray("res://po/de.po", "res://po/fr.po", "res://po/es.po", "res://po/ja.po") -locale/translations_pot_files=PackedStringArray("res://global.gd", "res://menu/overlay.tscn", "res://menu/setup.tscn", "res://menu/character.tscn", "res://menu/error.tscn", "res://menu/ingame.tscn", "res://menu/lobby.tscn", "res://menu/main.tscn", "res://menu/settings.tscn", "res://menu/ingame.gd", "res://menu/lobby.gd", "res://menu/popup_message.gd", "res://multiplayer.gd", "res://menu/hairstyle_preview.gd", "res://menu/credits.tscn", "res://menu/credits.gd") +locale/translations_pot_files=PackedStringArray("res://global.gd", "res://menu/overlay.tscn", "res://menu/setup.tscn", "res://menu/character.tscn", "res://menu/error.tscn", "res://menu/ingame.tscn", "res://menu/lobby.tscn", "res://menu/main.tscn", "res://menu/settings.tscn", "res://menu/ingame.gd", "res://menu/lobby.gd", "res://menu/popup_message.gd", "res://multiplayer.gd", "res://menu/hairstyle_preview.gd", "res://menu/credits.tscn", "res://menu/credits.gd", "res://menu/rating/rating.gd") [rendering] |