From 81deaf81c800900e30046cb927be1c9d91ae61b8 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 4 Sep 2025 23:47:24 +0200 Subject: reorganize client gui files --- client/gui/components/message/item/item_message.gd | 71 ++++++++++++++++++++++ .../components/message/item/item_message.gd.uid | 1 + .../gui/components/message/item/item_message.tscn | 48 +++++++++++++++ client/gui/components/message/item/item_render.gd | 41 +++++++++++++ .../gui/components/message/item/item_render.gd.uid | 1 + .../gui/components/message/item/item_render.tscn | 23 +++++++ 6 files changed, 185 insertions(+) create mode 100644 client/gui/components/message/item/item_message.gd create mode 100644 client/gui/components/message/item/item_message.gd.uid create mode 100644 client/gui/components/message/item/item_message.tscn create mode 100644 client/gui/components/message/item/item_render.gd create mode 100644 client/gui/components/message/item/item_render.gd.uid create mode 100644 client/gui/components/message/item/item_render.tscn (limited to 'client/gui/components/message/item') diff --git a/client/gui/components/message/item/item_message.gd b/client/gui/components/message/item/item_message.gd new file mode 100644 index 00000000..e643c291 --- /dev/null +++ b/client/gui/components/message/item/item_message.gd @@ -0,0 +1,71 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2025 Hurry Curry! contributors +# +# 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 . +# +class_name ItemMessage +extends Control + +const PRINTED_MAT := preload("res://gui/resources/materials/printed_material.tres") + +@export var enable_rotation := true +@export var enable_grayscale := false + +var timeout_remaining := 0. +var timeout_initial := 0. + +@onready var item_render: ItemRender = $VBoxContainer/SubViewportContainer/SubViewport/ItemRender +@onready var progress: ProgressBar = $VBoxContainer/ProgressBar +@onready var sub_viewport: SubViewport = $VBoxContainer/SubViewportContainer/SubViewport +@onready var sub_viewport_container: SubViewportContainer = $VBoxContainer/SubViewportContainer +@onready var v_box_container: VBoxContainer = $VBoxContainer + +func _ready() -> void: + Global.configure_viewport_aa(sub_viewport, Global.get_setting("graphics.aa")) + + if enable_grayscale: + sub_viewport_container.material = PRINTED_MAT + +func set_subviewport_size(sub_viewport_size: Vector2): + sub_viewport.size = sub_viewport_size + progress.custom_minimum_size.y = sub_viewport_size.x - sub_viewport_size.y + v_box_container.size.y = 0 + +func set_round_corner_radius_progress(radius: int): + var style_bg: StyleBoxFlat = progress.get_theme_stylebox("background") + var style_fill: StyleBoxFlat = progress.get_theme_stylebox("fill") + + style_bg.corner_radius_bottom_left = radius + style_bg.corner_radius_bottom_right = radius + style_fill.corner_radius_bottom_left = radius + style_fill.corner_radius_bottom_right = radius + +func set_item(item_name: String, timeout_initial_: float, timeout_remaining_: float): + item_render.set_item(item_name, enable_rotation) + + timeout_remaining = timeout_remaining_ + timeout_initial = timeout_initial_ + progress.max_value = timeout_initial + progress.value = timeout_remaining + +func remove_item(): + item_render.remove_item() + +func _process(delta): + if item_render.item != null and !Global.game_paused: + timeout_remaining -= delta + progress.value = timeout_remaining + var x: float = timeout_remaining / timeout_initial + var progress_style: StyleBoxFlat = progress.get_theme_stylebox("fill") + progress_style.bg_color = Color(min((1-x) * 2, 1), min(x * 2, 1), 0.) + progress.add_theme_stylebox_override("fill", progress_style) diff --git a/client/gui/components/message/item/item_message.gd.uid b/client/gui/components/message/item/item_message.gd.uid new file mode 100644 index 00000000..d2600c43 --- /dev/null +++ b/client/gui/components/message/item/item_message.gd.uid @@ -0,0 +1 @@ +uid://boheclidwdafn diff --git a/client/gui/components/message/item/item_message.tscn b/client/gui/components/message/item/item_message.tscn new file mode 100644 index 00000000..59e0ebf9 --- /dev/null +++ b/client/gui/components/message/item/item_message.tscn @@ -0,0 +1,48 @@ +[gd_scene load_steps=6 format=3 uid="uid://fkqh36s4vl3p"] + +[ext_resource type="Script" uid="uid://boheclidwdafn" path="res://gui/components/message/item/item_message.gd" id="1_76lg0"] +[ext_resource type="PackedScene" uid="uid://cem5xcld6vn51" path="res://gui/components/message/item/item_render.tscn" id="1_sju7l"] +[ext_resource type="StyleBox" uid="uid://brw8uogdgx2gf" path="res://gui/resources/style/item_bubble_progress_style.tres" id="3_ipe76"] +[ext_resource type="StyleBox" uid="uid://cu0his4018e7h" path="res://gui/resources/style/item_bubble_progress_style_background.tres" id="3_t61n3"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dpele"] +bg_color = Color(1, 1, 1, 1) +corner_radius_top_left = 30 +corner_radius_top_right = 30 +corner_radius_bottom_right = 30 +corner_radius_bottom_left = 30 + +[node name="ItemMessage" type="PanelContainer"] +auto_translate_mode = 2 +clip_children = 2 +offset_right = 256.0 +offset_bottom = 256.0 +size_flags_vertical = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_dpele") +script = ExtResource("1_76lg0") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 +size_flags_vertical = 0 +theme_override_constants/separation = 0 + +[node name="SubViewportContainer" type="SubViewportContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="SubViewport" type="SubViewport" parent="VBoxContainer/SubViewportContainer"] +own_world_3d = true +transparent_bg = true +handle_input_locally = false +size = Vector2i(256, 224) +render_target_update_mode = 4 + +[node name="ItemRender" parent="VBoxContainer/SubViewportContainer/SubViewport" instance=ExtResource("1_sju7l")] + +[node name="ProgressBar" type="ProgressBar" parent="VBoxContainer"] +custom_minimum_size = Vector2(0, 32) +layout_mode = 2 +theme_override_styles/background = ExtResource("3_t61n3") +theme_override_styles/fill = ExtResource("3_ipe76") +step = 0.0 +value = 100.0 +show_percentage = false diff --git a/client/gui/components/message/item/item_render.gd b/client/gui/components/message/item/item_render.gd new file mode 100644 index 00000000..71a5eb7c --- /dev/null +++ b/client/gui/components/message/item/item_render.gd @@ -0,0 +1,41 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2025 Hurry Curry! contributors +# +# 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 . +# +extends Node3D +class_name ItemRender + +var item: Item +var do_rotate: bool + +var base := Node3D.new() + +func _ready() -> void: + add_child(base) + +func set_item(item_name: String, enable_rotation := true): + if item != null: + remove_item() + + item = ItemFactory.produce(item_name, base) + do_rotate = enable_rotation + base.add_child(item) + +func remove_item(): + if item != null: + item.queue_free() + +func _process(delta: float): + if do_rotate: + base.rotation.y += delta * TAU * .025 diff --git a/client/gui/components/message/item/item_render.gd.uid b/client/gui/components/message/item/item_render.gd.uid new file mode 100644 index 00000000..745b21ce --- /dev/null +++ b/client/gui/components/message/item/item_render.gd.uid @@ -0,0 +1 @@ +uid://bt7773og3p557 diff --git a/client/gui/components/message/item/item_render.tscn b/client/gui/components/message/item/item_render.tscn new file mode 100644 index 00000000..3d993b7a --- /dev/null +++ b/client/gui/components/message/item/item_render.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=3 format=3 uid="uid://cem5xcld6vn51"] + +[ext_resource type="Script" uid="uid://bt7773og3p557" path="res://gui/components/message/item/item_render.gd" id="1_jfi7o"] + +[sub_resource type="Environment" id="Environment_iyxrx"] +ambient_light_source = 2 +ambient_light_color = Color(1, 1, 1, 1) +ambient_light_energy = 0.5 + +[node name="ItemRender" type="Node3D"] +script = ExtResource("1_jfi7o") + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.939693, 0.34202, 0, -0.34202, 0.939693, 0, 0.5, 1) +projection = 1 +size = 0.6 + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.173648, 0.984808, 0, -0.984808, 0.173648, 0, 0, 0) +light_energy = 0.5 + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_iyxrx") -- cgit v1.2.3-70-g09d2