From 78c13e68040241f0fb76592e3664de2bc24cc981 Mon Sep 17 00:00:00 2001 From: nokoe Date: Tue, 1 Oct 2024 14:29:11 +0200 Subject: more universal popups --- client/menu/popup.gd | 31 +++++++++++++++++++++++++ client/menu/popup.tscn | 44 ++++++++++++++++++++++++++++++++++++ client/menu/rating/rating.tscn | 2 +- client/menu/setup.gd | 7 +++++- client/menu/warning_popup.gd | 8 ------- client/menu/warning_popup.tscn | 51 ------------------------------------------ 6 files changed, 82 insertions(+), 61 deletions(-) create mode 100644 client/menu/popup.gd create mode 100644 client/menu/popup.tscn delete mode 100644 client/menu/warning_popup.gd delete mode 100644 client/menu/warning_popup.tscn (limited to 'client/menu') diff --git a/client/menu/popup.gd b/client/menu/popup.gd new file mode 100644 index 00000000..5b3a60ac --- /dev/null +++ b/client/menu/popup.gd @@ -0,0 +1,31 @@ +# 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 . +# +extends Menu +class_name MenuPopup + +@onready var message := $CenterContainer/Panel/MarginContainer/VBoxContainer/Message +@onready var button_container := $CenterContainer/Panel/MarginContainer/VBoxContainer/HBoxContainer + +class Data: + var buttons: Array[Button] + var text: String + +func _ready(): + var setup: Data = self.data + for i in setup.buttons: + button_container.add_child(i) + i.pressed.connect(exit) + message.text = setup.text diff --git a/client/menu/popup.tscn b/client/menu/popup.tscn new file mode 100644 index 00000000..85db4897 --- /dev/null +++ b/client/menu/popup.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=4 format=3 uid="uid://lwtym0pbc17g"] + +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_m0d0r"] +[ext_resource type="Script" path="res://menu/popup.gd" id="2_1h10j"] +[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/dark_blur_material.tres" id="3_iouvy"] + +[node name="Popup" 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_m0d0r") +script = ExtResource("2_1h10j") +support_anim = false + +[node name="CenterContainer" type="CenterContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Panel" type="PanelContainer" parent="CenterContainer"] +material = ExtResource("3_iouvy") +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="CenterContainer/Panel"] +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/Panel/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 16 + +[node name="Message" type="Label" parent="CenterContainer/Panel/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "You must fill out all requested fields." +horizontal_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/Panel/MarginContainer/VBoxContainer"] +layout_mode = 2 +alignment = 1 diff --git a/client/menu/rating/rating.tscn b/client/menu/rating/rating.tscn index 69edba88..780cf261 100644 --- a/client/menu/rating/rating.tscn +++ b/client/menu/rating/rating.tscn @@ -120,7 +120,7 @@ alignment = 1 [node name="Close" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer"] layout_mode = 2 -text = "c.menu.rating.accept" +text = "c.menu.accept" [node name="StarTimer" type="Timer" parent="."] wait_time = 0.5 diff --git a/client/menu/setup.gd b/client/menu/setup.gd index fbf0bfce..580902da 100644 --- a/client/menu/setup.gd +++ b/client/menu/setup.gd @@ -60,7 +60,12 @@ func check(): func _on_sign_pressed(): if check() != null: # TODO show error message - await submenu("res://menu/warning_popup.tscn", check()) + var data := MenuPopup.Data.new() + data.text = check() + var accept_button := Button.new() + accept_button.text = tr("c.menu.accept") + data.buttons = [accept_button] + await submenu("res://menu/popup.tscn", data) return sign_button.disabled = true diff --git a/client/menu/warning_popup.gd b/client/menu/warning_popup.gd deleted file mode 100644 index fd23a30a..00000000 --- a/client/menu/warning_popup.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Menu -class_name WarningPopup - -func _ready(): - $CenterContainer/Panel/MarginContainer/VBoxContainer/Message.text = self.data - -func _on_accept_pressed(): - exit() diff --git a/client/menu/warning_popup.tscn b/client/menu/warning_popup.tscn deleted file mode 100644 index 4fd2fbba..00000000 --- a/client/menu/warning_popup.tscn +++ /dev/null @@ -1,51 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://0v2olkwpm150"] - -[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_yk5xc"] -[ext_resource type="Script" path="res://menu/warning_popup.gd" id="2_2vobb"] -[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/dark_blur_material.tres" id="3_5wavk"] - -[node name="WarningPopup" 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_yk5xc") -script = ExtResource("2_2vobb") -support_anim = false - -[node name="CenterContainer" type="CenterContainer" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="Panel" type="PanelContainer" parent="CenterContainer"] -material = ExtResource("3_5wavk") -layout_mode = 2 - -[node name="MarginContainer" type="MarginContainer" parent="CenterContainer/Panel"] -layout_mode = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/Panel/MarginContainer"] -layout_mode = 2 -theme_override_constants/separation = 16 - -[node name="Message" type="Label" parent="CenterContainer/Panel/MarginContainer/VBoxContainer"] -layout_mode = 2 -text = "You must fill out all requested fields." -horizontal_alignment = 1 - -[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/Panel/MarginContainer/VBoxContainer"] -layout_mode = 2 -alignment = 1 - -[node name="Accept" type="Button" parent="CenterContainer/Panel/MarginContainer/VBoxContainer/HBoxContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 16 -text = "Accept" - -[connection signal="pressed" from="CenterContainer/Panel/MarginContainer/VBoxContainer/HBoxContainer/Accept" to="." method="_on_accept_pressed"] -- cgit v1.2.3-70-g09d2