diff options
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/character.gd | 32 | ||||
-rw-r--r-- | client/menu/character.tscn | 70 | ||||
-rw-r--r-- | client/menu/hairstyle_preview.gd | 13 | ||||
-rw-r--r-- | client/menu/setup.gd | 9 |
4 files changed, 100 insertions, 24 deletions
diff --git a/client/menu/character.gd b/client/menu/character.gd index fb224dd7..f40aeffb 100644 --- a/client/menu/character.gd +++ b/client/menu/character.gd @@ -25,7 +25,7 @@ extends Menu func _ready(): super() $VBoxContainer/top_panel/a/username.text = Global.get_profile("username") - character.set_style(Global.get_profile("character")) + character.set_style(Global.get_profile("character_style"), "chef") init_map() func init_map(): @@ -73,9 +73,31 @@ func _on_back_pressed(): replace_menu("res://menu/main.tscn") func _on_character_back_pressed(): - Global.set_profile("character", max(Global.get_profile("character") - 1, 0)) - character.set_style(Global.get_profile("character")) + modify_style(func m(current_style: Dictionary): + current_style.color = G.rem_euclid(current_style.color - 1, character.NUM_COLORS)) func _on_character_forward_pressed(): - Global.set_profile("character", max(Global.get_profile("character") + 1, 0)) - character.set_style(Global.get_profile("character")) + modify_style(func m(current_style: Dictionary): + current_style.color = G.rem_euclid(current_style.color + 1, character.NUM_COLORS)) + +func _on_headwear_back_pressed() -> void: + modify_style(func m(current_style: Dictionary): + current_style.headwear = G.rem_euclid(current_style.headwear - 1, character.NUM_HEADWEARS)) + +func _on_headwear_forward_pressed() -> void: + modify_style(func m(current_style: Dictionary): + current_style.headwear = G.rem_euclid(current_style.headwear + 1, character.NUM_HEADWEARS)) + +func _on_hairstyle_back_pressed() -> void: + modify_style(func m(current_style: Dictionary): + current_style.hairstyle = G.rem_euclid(current_style.hairstyle - 1, character.NUM_HAIRS)) + +func _on_hairstyle_forward_pressed() -> void: + modify_style(func m(current_style: Dictionary): + current_style.hairstyle = G.rem_euclid(current_style.hairstyle + 1, character.NUM_HAIRS)) + +func modify_style(modifier: Callable): + var current_style: Dictionary = Global.get_profile("character_style") + modifier.call(current_style) + Global.set_profile("character_style", current_style) + character.set_style(Global.get_profile("character_style"), "chef") diff --git a/client/menu/character.tscn b/client/menu/character.tscn index e5ec1292..f640e7cc 100644 --- a/client/menu/character.tscn +++ b/client/menu/character.tscn @@ -101,11 +101,11 @@ theme_override_constants/margin_bottom = 50 layout_mode = 2 alignment = 1 -[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Spacer/VBoxContainer"] +[node name="Headware" type="HBoxContainer" parent="VBoxContainer/Spacer/VBoxContainer"] layout_mode = 2 alignment = 1 -[node name="Back" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/HBoxContainer"] +[node name="Back" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/Headware"] layout_mode = 2 focus_neighbor_right = NodePath("../Forward") texture_normal = ExtResource("5_kvd7k") @@ -114,11 +114,61 @@ texture_hover = ExtResource("6_soj8g") texture_focused = ExtResource("6_u31hl") flip_h = true -[node name="Spacer" type="Control" parent="VBoxContainer/Spacer/VBoxContainer/HBoxContainer"] +[node name="Spacer" type="Control" parent="VBoxContainer/Spacer/VBoxContainer/Headware"] layout_mode = 2 size_flags_horizontal = 3 -[node name="Forward" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/HBoxContainer"] +[node name="Forward" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/Headware"] +layout_mode = 2 +focus_neighbor_left = NodePath("../Back") +texture_normal = ExtResource("5_kvd7k") +texture_pressed = ExtResource("5_xpff8") +texture_hover = ExtResource("6_soj8g") +texture_focused = ExtResource("6_u31hl") + +[node name="Hairstyle" type="HBoxContainer" parent="VBoxContainer/Spacer/VBoxContainer"] +layout_mode = 2 +alignment = 1 + +[node name="Back" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/Hairstyle"] +layout_mode = 2 +focus_neighbor_right = NodePath("../Forward") +texture_normal = ExtResource("5_kvd7k") +texture_pressed = ExtResource("5_xpff8") +texture_hover = ExtResource("6_soj8g") +texture_focused = ExtResource("6_u31hl") +flip_h = true + +[node name="Spacer" type="Control" parent="VBoxContainer/Spacer/VBoxContainer/Hairstyle"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Forward" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/Hairstyle"] +layout_mode = 2 +focus_neighbor_left = NodePath("../Back") +texture_normal = ExtResource("5_kvd7k") +texture_pressed = ExtResource("5_xpff8") +texture_hover = ExtResource("6_soj8g") +texture_focused = ExtResource("6_u31hl") + +[node name="Character" type="HBoxContainer" parent="VBoxContainer/Spacer/VBoxContainer"] +layout_mode = 2 +alignment = 1 + +[node name="Back" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/Character"] +layout_mode = 2 +focus_neighbor_right = NodePath("../Forward") +texture_normal = ExtResource("5_kvd7k") +texture_pressed = ExtResource("5_xpff8") +texture_hover = ExtResource("6_soj8g") +texture_focused = ExtResource("6_u31hl") +flip_h = true + +[node name="Spacer" type="Control" parent="VBoxContainer/Spacer/VBoxContainer/Character"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Forward" type="TextureButton" parent="VBoxContainer/Spacer/VBoxContainer/Character"] layout_mode = 2 focus_neighbor_left = NodePath("../Back") texture_normal = ExtResource("5_kvd7k") @@ -150,10 +200,10 @@ text = "c.menu.back" visible = false layout_mode = 1 -[connection signal="focus_entered" from="VBoxContainer/Spacer/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_focus_entered"] -[connection signal="focus_exited" from="VBoxContainer/Spacer/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_focus_exited"] -[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/HBoxContainer/Back" to="." method="_on_character_back_pressed"] -[connection signal="focus_entered" from="VBoxContainer/Spacer/VBoxContainer/HBoxContainer/Forward" to="." method="_on_forward_focus_entered"] -[connection signal="focus_exited" from="VBoxContainer/Spacer/VBoxContainer/HBoxContainer/Forward" to="." method="_on_forward_focus_exited"] -[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/HBoxContainer/Forward" to="." method="_on_character_forward_pressed"] +[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Headware/Back" to="." method="_on_headwear_back_pressed"] +[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Headware/Forward" to="." method="_on_headwear_forward_pressed"] +[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Hairstyle/Back" to="." method="_on_hairstyle_back_pressed"] +[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Hairstyle/Forward" to="." method="_on_hairstyle_forward_pressed"] +[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Character/Back" to="." method="_on_character_back_pressed"] +[connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Character/Forward" to="." method="_on_character_forward_pressed"] [connection signal="pressed" from="VBoxContainer/bottom_panel/back" to="." method="_on_back_pressed"] diff --git a/client/menu/hairstyle_preview.gd b/client/menu/hairstyle_preview.gd index 08b6aab9..415f5c21 100644 --- a/client/menu/hairstyle_preview.gd +++ b/client/menu/hairstyle_preview.gd @@ -1,4 +1,5 @@ # Hurry Curry! - a game about cooking +# Copyright 2025 tpart # Copyright 2024 nokoe # # This program is free software: you can redistribute it and/or modify @@ -16,10 +17,12 @@ class_name HairstylePreview extends VBoxContainer -signal selected(character: int) +signal selected(character_style: Dictionary) -func setup(character: int, group: ButtonGroup): - $HairViewport/Node3D/Character.set_style(character) +func setup(hairstyle: int, group: ButtonGroup): + var character_style = Global.default_profile.character_style + character_style.hairstyle = hairstyle + $HairViewport/Node3D/Character.set_style(character_style, "chef") $Select.button_group = group - $Select.text = tr("c.setup.uniform.value").format([character + 1]) - $Select.pressed.connect(func(): selected.emit(character)) + $Select.text = tr("c.setup.uniform.value").format([hairstyle + 1]) + $Select.pressed.connect(func(): selected.emit(character_style)) diff --git a/client/menu/setup.gd b/client/menu/setup.gd index 21fbc526..f38f0bf7 100644 --- a/client/menu/setup.gd +++ b/client/menu/setup.gd @@ -19,7 +19,7 @@ extends Menu const SCROLL_SPEED := 500. -var character := -1 +var character_style = null # : Dictionary? @onready var anim: AnimationPlayer = $AnimationPlayer @onready var username: LineEdit = $ScrollContainer/Control/TextureRect/PaperMargin/Contents/NameEntry/LineEdit @@ -48,8 +48,8 @@ func _ready(): super() -func _character_selected(idx: int): - character = idx +func _character_selected(style: Dictionary): + character_style = style func _process(delta): var s = Input.get_axis("rotate_up", "rotate_down") @@ -58,7 +58,7 @@ func _process(delta): func check(): if username.text == "": return tr("c.error.empty_username") - if character == -1: return tr("c.error.select_hairstyle") + if character_style == null: return tr("c.error.select_hairstyle") return null func _on_sign_pressed(): @@ -79,6 +79,7 @@ func _on_sign_pressed(): await anim.animation_finished Global.set_profile("username", username.text) + Global.set_profile("character_style", character_style) if skip_tutorial.button_pressed: for k in Global.profile["hints"].keys(): Global.set_hint(k, true) |