aboutsummaryrefslogtreecommitdiff
path: root/client/system
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-09-27 00:55:20 +0200
committermetamuffin <metamuffin@disroot.org>2025-09-27 00:55:23 +0200
commit9a5eb8ddf73fecc0ef5907983e136a1018937621 (patch)
tree3c692f6e7702c59abffa19c7b5c1da868b0f0c7b /client/system
parent2ff484a85dec4abed71071ba509ac5cd307ff2f9 (diff)
downloadhurrycurry-9a5eb8ddf73fecc0ef5907983e136a1018937621.tar
hurrycurry-9a5eb8ddf73fecc0ef5907983e136a1018937621.tar.bz2
hurrycurry-9a5eb8ddf73fecc0ef5907983e136a1018937621.tar.zst
Add client cli tool to render tiles/items to PNG
Diffstat (limited to 'client/system')
-rw-r--r--client/system/cli.gd4
-rw-r--r--client/system/render_tool.gd67
-rw-r--r--client/system/render_tool.gd.uid1
-rw-r--r--client/system/render_tool.tscn48
4 files changed, 120 insertions, 0 deletions
diff --git a/client/system/cli.gd b/client/system/cli.gd
index 7a312127..d503d536 100644
--- a/client/system/cli.gd
+++ b/client/system/cli.gd
@@ -29,6 +29,10 @@ static var OPTIONS := [
Option.new("h", "help", Mode.FLAG, "Show help"),
Option.new("s", "setting", Mode.MULTI_OPTION, "Per-launch setting override"),
Option.new("c", "join-command", Mode.OPTION, "Message to send right after initial joining"),
+ Option.new(null, "render-items", Mode.OPTION, "Render items from text file to images"),
+ Option.new(null, "render-tiles", Mode.OPTION, "Render tiles from text file to images"),
+ Option.new(null, "render-resolution", Mode.OPTION, "Resolution for rendering items or tiles"),
+ Option.new(null, "render-output", Mode.OPTION, "Output directory for rendering items or tiles"),
Option.new(null, "connect_address", Mode.POSITIONAL, "Connect to a server directly without menu interaction")
]
diff --git a/client/system/render_tool.gd b/client/system/render_tool.gd
new file mode 100644
index 00000000..3037f9bb
--- /dev/null
+++ b/client/system/render_tool.gd
@@ -0,0 +1,67 @@
+# 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
+
+enum Mode {
+ ITEMS,
+ TILES
+}
+
+@onready var camera = $SubViewportContainer/SubViewport/Node3D/Camera3D
+@onready var base = $SubViewportContainer/SubViewport/Node3D
+
+var current_object: Node3D = null
+var mode: Mode
+
+func _ready():
+ super()
+
+ var input_file: String
+ if Cli.opts.has("render-items"):
+ mode = Mode.ITEMS
+ input_file = Cli.opts["render-items"]
+ elif Cli.opts.has("render-tiles"):
+ mode = Mode.TILES
+ input_file = Cli.opts["render-tiles"]
+ else:
+ push_error("cannot open render_tool menu without corresponding cli options")
+ return
+
+ var file = FileAccess.open(input_file, FileAccess.READ)
+ var object_name_list = file.get_as_text().strip_edges().split("\n")
+ var resolution = Vector2i.ONE * int(Cli.opts.get("render-resolution", "256"))
+ $SubViewportContainer/SubViewport.size = resolution
+
+ for object_name in object_name_list:
+ setup_object(object_name)
+ await RenderingServer.frame_post_draw
+ var path = Cli.opts.get("render-output", ".").path_join(object_name + ".png")
+ $SubViewportContainer/SubViewport.get_texture().get_image().save_png(path)
+
+ exit()
+
+func setup_object(object_name: String):
+ if current_object: base.remove_child(current_object)
+ match mode:
+ Mode.ITEMS:
+ current_object = ItemFactory.produce(object_name, base)
+ Mode.TILES:
+ var tf = TileFactory.new()
+ current_object = tf.produce(object_name, Vector2i(0, 0), [null, null, null, null])
+ current_object.rotation_degrees.y = 45.
+ current_object.translate(Vector3(-0.5, 0.0, -0.5))
+ camera.size = 2.
+ base.add_child(current_object)
diff --git a/client/system/render_tool.gd.uid b/client/system/render_tool.gd.uid
new file mode 100644
index 00000000..daf5d5b8
--- /dev/null
+++ b/client/system/render_tool.gd.uid
@@ -0,0 +1 @@
+uid://byw3ney1w3bww
diff --git a/client/system/render_tool.tscn b/client/system/render_tool.tscn
new file mode 100644
index 00000000..5a1a208f
--- /dev/null
+++ b/client/system/render_tool.tscn
@@ -0,0 +1,48 @@
+[gd_scene load_steps=4 format=3 uid="uid://xppn2tnr0hcx"]
+
+[ext_resource type="Script" uid="uid://byw3ney1w3bww" path="res://system/render_tool.gd" id="1_gmn7h"]
+
+[sub_resource type="BoxMesh" id="BoxMesh_pcjn7"]
+
+[sub_resource type="Environment" id="Environment_vdkpo"]
+background_mode = 1
+background_color = Color(0, 0, 0, 0)
+ambient_light_source = 2
+ambient_light_color = Color(1, 1, 1, 1)
+
+[node name="ItemExport" 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_gmn7h")
+
+[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
+layout_mode = 0
+offset_right = 512.0
+offset_bottom = 512.0
+
+[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
+transparent_bg = true
+handle_input_locally = false
+render_target_update_mode = 4
+
+[node name="Node3D" type="Node3D" parent="SubViewportContainer/SubViewport"]
+
+[node name="DebugPlaceholder" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/Node3D"]
+visible = false
+mesh = SubResource("BoxMesh_pcjn7")
+skeleton = NodePath("../../../..")
+
+[node name="WorldEnvironment" type="WorldEnvironment" parent="SubViewportContainer/SubViewport/Node3D"]
+environment = SubResource("Environment_vdkpo")
+
+[node name="Camera3D" type="Camera3D" parent="SubViewportContainer/SubViewport/Node3D"]
+transform = Transform3D(1, 0, 0, 0, 0.8660254, 0.5, 0, -0.5, 0.8660254, 0, 2, 3)
+projection = 1
+far = 30.0
+
+[node name="DirectionalLight3D" type="DirectionalLight3D" parent="SubViewportContainer/SubViewport/Node3D"]
+transform = Transform3D(0.7071067, 0.49999997, -0.4999999, 0, 0.70710677, 0.7071067, 0.7071067, -0.49999997, 0.4999999, 0, 0, 0)