diff options
Diffstat (limited to 'client/menu/document')
-rw-r--r-- | client/menu/document/document.gd | 152 | ||||
-rw-r--r-- | client/menu/document/document.gd.uid | 1 | ||||
-rw-r--r-- | client/menu/document/document.tscn | 28 |
3 files changed, 0 insertions, 181 deletions
diff --git a/client/menu/document/document.gd b/client/menu/document/document.gd deleted file mode 100644 index c7042852..00000000 --- a/client/menu/document/document.gd +++ /dev/null @@ -1,152 +0,0 @@ -# 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 <https://www.gnu.org/licenses/>. -# -extends Menu - -const MARGIN: int = 75 - -var labels := {} - -func _ready(): - super() - $ScrollContainer/VBoxContainer.add_child(build_document(data)) - -func build_document(element: Dictionary, bullet: bool = false) -> Control: - var node: Control - match element["t"]: - "document": - node = VBoxContainer.new() - node.name = "Document" - for e in element["es"]: - node.add_child(build_document(e)) - "page": - node = PanelContainer.new() - node.name = "Page" - node.add_theme_stylebox_override("panel", preload("res://menu/theme/style/paper_panel_style.tres")) - node.set_custom_minimum_size(Vector2(800, 1131.371)) - var margin := MarginContainer.new() - margin.add_theme_constant_override("margin_bottom", MARGIN) - margin.add_theme_constant_override("margin_top", MARGIN) - margin.add_theme_constant_override("margin_left", MARGIN) - margin.add_theme_constant_override("margin_right", MARGIN) - var vbox := VBoxContainer.new() - if element["background"]: - margin.add_child(background(element["background"])) - margin.add_child(vbox) - for e in element["es"]: - vbox.add_child(build_document(e, bullet)) - node.add_child(margin) - "label": - var label_id = element["id"] - node = build_document(element["e"], bullet) - labels[label_id] = node - "list": - node = VBoxContainer.new() - node.name = "List" - for e in element["es"]: - node.add_child(build_document(e, true)) - "table": - node = VBoxContainer.new() - node.name = "Rows" - node.size_flags_horizontal = Control.SIZE_EXPAND_FILL - for r in range(element["es"].size()): - var row = HBoxContainer.new() - node.add_child(row) - row.size_flags_horizontal = Control.SIZE_EXPAND_FILL - row.name = "Row%d" % r - for c in element["es"][r]: - var e = build_document(c, bullet) - e.size_flags_horizontal = Control.SIZE_EXPAND_FILL - row.add_child(e) - "par": - node = VBoxContainer.new() - node.name = "Paragraph" - for e in element["es"]: - node.add_child(build_document(e, bullet)) - "ref": - # TODO: Support clicking - node = build_document(element["e"], bullet) - "conditional": - # Ignore all conditionals for now, since they are only revelant for typst version - node = Control.new() - "text": - node = text_node(element, bullet) - _: - node = Control.new() - push_error("Error building document: Unknown type \"%s\"" % element["t"]) - return node - -func text_node(element: Dictionary, bullet: bool) -> Control: - var node: Control - var label := Label.new() - # we need a hbox container for rtl - if bullet: - node = HBoxContainer.new() - var bullet_label := Label.new() - bullet_label.text = "•" - if element.get("size"): - bullet_label.add_theme_font_size_override("font_size", element["size"]) - # TODO: Ignore font color for now. Will be removed in the future. - # if element.get("color"): - # bullet_label.add_theme_color_override("font_color", Color(element["color"])) - bullet_label.add_theme_color_override("font_color", Color.BLACK) - label.add_theme_color_override("font_color", Color.BLACK) - node.add_child(bullet_label) - label.size_flags_horizontal = Control.SIZE_EXPAND_FILL - node.add_child(label) - else: - node = label - label.name = "Text" - label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART - label.text = Global.get_message_str(element["s"]) - if element.get("font"): - match element["font"]: - "Great Vibes": - node.add_theme_font_override("font", preload("res://menu/theme/fonts/font-sansita-swashed.woff2")) - if element.get("size"): - node.add_theme_font_size_override("font_size", element["size"]) - # TODO: Ignore font color for now. Will be removed in the future. - # if element.get("color"): - # label.add_theme_color_override("font_color", Color(element["color"])) - label.add_theme_color_override("font_color", Color.BLACK) - return node - -func background(background_name: String) -> SubViewportContainer: - var item_name: String - match background_name: - "cover": item_name = "plate:plate,plate,plate,dirt" - "toc": item_name = "tomato" - "tomato_soup": item_name = "plate:tomato-soup" - "burger": item_name = "plate:sliced-bun,sliced-tomato,sliced-lettuce" - "mochi": item_name = "plate:strawberry-mochi" - "curry": item_name = "plate:curry,cooked-rice" - "icecream": item_name = "plate:strawberry-icecream" - "drinks": item_name = "glass:strawberry-shake" - var n: item_name = n - var scene: ItemRender = preload("res://menu/communicate/item/item_render.tscn").instantiate() - scene.set_item(item_name, false) - var vc := SubViewportContainer.new() - var viewport := SubViewport.new() - viewport.add_child(scene) - viewport.own_world_3d = true - viewport.transparent_bg = true - vc.size_flags_horizontal = Control.SIZE_SHRINK_CENTER - vc.size_flags_vertical = Control.SIZE_SHRINK_END - #vc.material = preload("res://menu/theme/materials/printed_material.tres") - vc.add_child(viewport) - return vc - -func _menu_open(): pass -func _menu_exit(): pass diff --git a/client/menu/document/document.gd.uid b/client/menu/document/document.gd.uid deleted file mode 100644 index c84b53b1..00000000 --- a/client/menu/document/document.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c83p4k0nredmd diff --git a/client/menu/document/document.tscn b/client/menu/document/document.tscn deleted file mode 100644 index ce39dcbc..00000000 --- a/client/menu/document/document.tscn +++ /dev/null @@ -1,28 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://bdggwo8un3mys"] - -[ext_resource type="Script" uid="uid://c83p4k0nredmd" path="res://menu/document/document.gd" id="1_gyisx"] -[ext_resource type="Script" uid="uid://bd7bylb2t2m0" path="res://menu/auto_setup/scroll_container_custom.gd" id="2_0d0p0"] - -[node name="Document" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_gyisx") -support_anim = false - -[node name="ScrollContainer" type="ScrollContainer" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("2_0d0p0") - -[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] -layout_mode = 2 -size_flags_horizontal = 6 -size_flags_vertical = 4 |