aboutsummaryrefslogtreecommitdiff
path: root/client/system/render_tool.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/system/render_tool.gd')
-rw-r--r--client/system/render_tool.gd67
1 files changed, 67 insertions, 0 deletions
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)