diff options
author | nokoe <nokoe@mailbox.org> | 2024-07-14 14:22:03 +0200 |
---|---|---|
committer | nokoe <nokoe@mailbox.org> | 2024-07-14 14:22:03 +0200 |
commit | a44e6c9acab5b341814977a8fe0a0416c357618d (patch) | |
tree | c4ddb751611e803d000b2887a20a99e2ffd897dd /client/menu | |
parent | f18092fefe7f113548fe444a250df825f1b21255 (diff) | |
download | hurrycurry-a44e6c9acab5b341814977a8fe0a0416c357618d.tar hurrycurry-a44e6c9acab5b341814977a8fe0a0416c357618d.tar.bz2 hurrycurry-a44e6c9acab5b341814977a8fe0a0416c357618d.tar.zst |
hairstyle preview in print quality
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/grayscale.gdshader | 25 | ||||
-rw-r--r-- | client/menu/hairstyle_preview.gd | 25 | ||||
-rw-r--r-- | client/menu/hairstyle_preview.tscn | 55 | ||||
-rw-r--r-- | client/menu/setup.gd | 25 | ||||
-rw-r--r-- | client/menu/setup.tscn | 57 |
5 files changed, 123 insertions, 64 deletions
diff --git a/client/menu/grayscale.gdshader b/client/menu/grayscale.gdshader new file mode 100644 index 00000000..7c11b777 --- /dev/null +++ b/client/menu/grayscale.gdshader @@ -0,0 +1,25 @@ +/* + Hurry Curry! - a game about cooking + Copyright 2024 nokoe + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, version 3 of the License only. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +*/ +shader_type canvas_item; + +void fragment() { + float brightness = 0.2126 * COLOR.r + 0.7152 * COLOR.g + 0.0722 * COLOR.b; + brightness = (brightness - .5) * 2.; + COLOR.rgb = vec3(brightness); + COLOR.a *= 1. - brightness; +} diff --git a/client/menu/hairstyle_preview.gd b/client/menu/hairstyle_preview.gd new file mode 100644 index 00000000..324f7de1 --- /dev/null +++ b/client/menu/hairstyle_preview.gd @@ -0,0 +1,25 @@ +# Hurry Curry! - a game about cooking +# Copyright 2024 nokoe +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +class_name HairstylePreview +extends VBoxContainer + +signal selected(character: int) + +func setup(character: int, group: ButtonGroup): + $HairViewport/Node3D/Character.select_hairstyle(character) + $Select.button_group = group + $Select.text = tr("Hairstyle %d") % (character + 1) + $Select.pressed.connect(func(): selected.emit(character)) diff --git a/client/menu/hairstyle_preview.tscn b/client/menu/hairstyle_preview.tscn new file mode 100644 index 00000000..46bb9c74 --- /dev/null +++ b/client/menu/hairstyle_preview.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=7 format=3 uid="uid://dfon56nwd2tgn"] + +[ext_resource type="Script" path="res://menu/hairstyle_preview.gd" id="1_0qdmv"] +[ext_resource type="Shader" path="res://menu/grayscale.gdshader" id="1_sf0gc"] +[ext_resource type="PackedScene" uid="uid://b3hhir2fvnunu" path="res://player/character/character.tscn" id="2_jtitc"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_entrs"] +shader = ExtResource("1_sf0gc") + +[sub_resource type="ViewportTexture" id="ViewportTexture_giuq2"] +viewport_path = NodePath("HairViewport") + +[sub_resource type="ButtonGroup" id="ButtonGroup_c5p7t"] + +[node name="HairstylePreview" type="VBoxContainer"] +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("1_0qdmv") + +[node name="Preview" type="TextureRect" parent="."] +material = SubResource("ShaderMaterial_entrs") +layout_mode = 2 +texture = SubResource("ViewportTexture_giuq2") + +[node name="Select" type="CheckBox" parent="."] +layout_mode = 2 +button_group = SubResource("ButtonGroup_c5p7t") +text = "Hairstyle 1" + +[node name="HairViewport" type="SubViewport" parent="."] +own_world_3d = true +transparent_bg = true +msaa_3d = 1 +size = Vector2i(128, 128) + +[node name="Node3D" type="Node3D" parent="HairViewport"] + +[node name="Camera3D" type="Camera3D" parent="HairViewport/Node3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 1.5) +fov = 25.5 + +[node name="Character" parent="HairViewport/Node3D" instance=ExtResource("2_jtitc")] + +[node name="SpotLight3D" type="SpotLight3D" parent="HairViewport/Node3D"] +transform = Transform3D(0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, 0.866025, -2, 0, 2) + +[node name="SpotLight3D2" type="SpotLight3D" parent="HairViewport/Node3D"] +transform = Transform3D(0.876399, 0, 0.481585, 0, 1, 0, -0.481585, 0, 0.876399, 2, 0.499189, 2) +light_color = Color(0.857819, 0.80038, 0.775519, 1) +light_energy = 4.11 + +[node name="SpotLight3D3" type="SpotLight3D" parent="HairViewport/Node3D"] +transform = Transform3D(-0.965926, 0, -0.258819, -0.129409, 0.866025, 0.482963, 0.224144, 0.5, -0.836516, -1, 2, -2) +light_color = Color(0.540595, 0.865144, 1, 1) +light_energy = 8.2 diff --git a/client/menu/setup.gd b/client/menu/setup.gd index 279c54ff..7a56a14d 100644 --- a/client/menu/setup.gd +++ b/client/menu/setup.gd @@ -1,6 +1,7 @@ # Hurry Curry! - a game about cooking # Copyright 2024 metamuffin # Copyright 2024 tpart +# Copyright 2024 nokoe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -22,22 +23,28 @@ var character := -1 @onready var anim: AnimationPlayer = $AnimationPlayer @onready var username: LineEdit = $ScrollContainer/Control/TextureRect/PaperMargin/Contents/NameEntry/LineEdit -@onready var character_opts: Container = $ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/UniformEntry -@onready var character_model: Character = $ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport/Node3D/Character -@onready var sign: AudioStreamPlayer = $Sign +@onready var sign_sound: AudioStreamPlayer = $Sign @onready var sign_button: Button = $ScrollContainer/Control/TextureRect/PaperMargin/Contents/Signatures/EmployeeMargin/Sign/Signature @onready var scroll: ScrollContainer = $ScrollContainer +@onready var select_uniform: HBoxContainer = $ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform func _ready(): anim.play("paper_slide") - for i in character_opts.get_children().size(): - var box: CheckBox = character_opts.get_child(i) - box.pressed.connect(_character_selected.bind(i)) + var button_group := ButtonGroup.new() + for i in range(3): + var preview: HairstylePreview = preload("res://menu/hairstyle_preview.tscn").instantiate() + select_uniform.add_child(preview) + preview.setup(i, button_group) + preview.selected.connect(_character_selected) + if i < 2: + var spacer = Control.new() + spacer.size_flags_vertical = Control.SIZE_EXPAND + spacer.custom_minimum_size.x = 50 + select_uniform.add_child(spacer) super() func _character_selected(idx: int): character = idx - character_model.select_hairstyle(character) func _process(delta): var s = Input.get_axis("rotate_up", "rotate_down") @@ -49,8 +56,8 @@ func _on_sign_pressed(): sign_button.disabled = true - sign.play() - await sign.finished + sign_sound.play() + await sign_sound.finished anim.play_backwards("paper_slide") await anim.animation_finished diff --git a/client/menu/setup.tscn b/client/menu/setup.tscn index a78e666b..5ef6a260 100644 --- a/client/menu/setup.tscn +++ b/client/menu/setup.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=18 format=3 uid="uid://ddl3efikvqp66"] +[gd_scene load_steps=15 format=3 uid="uid://ddl3efikvqp66"] [ext_resource type="Script" path="res://menu/setup.gd" id="1_mo46n"] [ext_resource type="Theme" uid="uid://ci2qajdoa1an1" path="res://menu/theme/paper.tres" id="1_yq0aa"] [ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/font-sansita-swashed.woff2" id="3_2vg4d"] -[ext_resource type="PackedScene" uid="uid://b3hhir2fvnunu" path="res://player/character/character.tscn" id="3_871k7"] [ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://menu/scene_transition.tscn" id="4_u444t"] [ext_resource type="AudioStream" uid="uid://do7ii5hx71p0m" path="res://menu/sounds/page.ogg" id="5_xac6d"] [ext_resource type="AudioStream" uid="uid://5b3noxjmasmu" path="res://menu/sounds/sign.ogg" id="6_wf0gh"] @@ -60,11 +59,6 @@ corner_radius_top_right = 10 corner_radius_bottom_right = 10 corner_radius_bottom_left = 10 -[sub_resource type="ButtonGroup" id="ButtonGroup_8p5im"] - -[sub_resource type="ViewportTexture" id="ViewportTexture_euy7w"] -viewport_path = NodePath("ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport") - [sub_resource type="FontVariation" id="FontVariation_2cc7p"] base_font = ExtResource("3_2vg4d") @@ -231,54 +225,7 @@ scroll_active = false [node name="SelectUniform" type="HBoxContainer" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents"] layout_mode = 2 - -[node name="UniformEntry" type="VBoxContainer" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform"] -layout_mode = 2 - -[node name="Style1" type="CheckBox" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/UniformEntry"] -layout_mode = 2 -button_group = SubResource("ButtonGroup_8p5im") -text = "Hairstyle 1" - -[node name="Style2" type="CheckBox" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/UniformEntry"] -layout_mode = 2 -button_group = SubResource("ButtonGroup_8p5im") -text = "Hairstyle 2" - -[node name="Style3" type="CheckBox" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/UniformEntry"] -layout_mode = 2 -button_group = SubResource("ButtonGroup_8p5im") -text = "Hairstyle 3" - -[node name="Preview" type="TextureRect" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform"] -layout_mode = 2 -texture = SubResource("ViewportTexture_euy7w") - -[node name="HairViewport" type="SubViewport" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform"] -transparent_bg = true -msaa_3d = 1 -size = Vector2i(300, 128) - -[node name="Node3D" type="Node3D" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport"] - -[node name="Camera3D" type="Camera3D" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport/Node3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 1.5) -fov = 25.5 - -[node name="Character" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport/Node3D" instance=ExtResource("3_871k7")] - -[node name="SpotLight3D" type="SpotLight3D" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport/Node3D"] -transform = Transform3D(0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, 0.866025, -2, 0, 2) - -[node name="SpotLight3D2" type="SpotLight3D" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport/Node3D"] -transform = Transform3D(0.876399, 0, 0.481585, 0, 1, 0, -0.481585, 0, 0.876399, 2, 0.499189, 2) -light_color = Color(0.857819, 0.80038, 0.775519, 1) -light_energy = 4.11 - -[node name="SpotLight3D3" type="SpotLight3D" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/SelectUniform/HairViewport/Node3D"] -transform = Transform3D(-0.965926, 0, -0.258819, -0.129409, 0.866025, 0.482963, 0.224144, 0.5, -0.836516, -1, 2, -2) -light_color = Color(0.540595, 0.865144, 1, 1) -light_energy = 8.2 +alignment = 1 [node name="Duties" type="RichTextLabel" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents"] layout_mode = 2 |