From 44f9b025d5dccd300f9a17d68f259819f8b4e0c8 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Fri, 11 Aug 2023 20:15:41 -0400 Subject: [PATCH] Adding a generate button to the UI --- world.gd | 3 +++ world.tscn | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/world.gd b/world.gd index e818d71..b0934db 100644 --- a/world.gd +++ b/world.gd @@ -210,3 +210,6 @@ func _on_generation_submit_pressed() -> void: seed(world_seed) start_conway() + +func _on_world_seed_generate_pressed() -> void: + generation_seed.text = str(randi()) diff --git a/world.tscn b/world.tscn index 37aa22c..475d6b4 100644 --- a/world.tscn +++ b/world.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=4 format=3 uid="uid://d3twfk56sjf2m"] +[gd_scene load_steps=5 format=3 uid="uid://d3twfk56sjf2m"] [ext_resource type="Script" path="res://world.gd" id="1_wavft"] [ext_resource type="Texture2D" uid="uid://c2vm5pfsamed4" path="res://icon.svg" id="2_8r6bn"] [ext_resource type="PackedScene" uid="uid://cy6vsgu8o0rad" path="res://scenes/fps_counter/fps_counter.tscn" id="3_ves6s"] +[ext_resource type="Texture2D" uid="uid://b8gggrriib8n" path="res://assets/refresh.png" id="4_fcljs"] [node name="World" type="Node2D"] position = Vector2(-152, 0) @@ -95,6 +96,11 @@ custom_minimum_size = Vector2(200, 0) layout_mode = 2 placeholder_text = "Empty for Random" +[node name="Generate" type="Button" parent="UI/WorldGeneration/VBoxContainer/Seed"] +self_modulate = Color(0.501961, 0.501961, 0.501961, 1) +layout_mode = 2 +icon = ExtResource("4_fcljs") + [node name="WorldSize" type="HBoxContainer" parent="UI/WorldGeneration/VBoxContainer"] layout_mode = 2 theme_override_constants/separation = 6 @@ -161,4 +167,5 @@ layout_mode = 2 text = "Start" [connection signal="timeout" from="GenerationTimer" to="." method="_on_generation_timer_timeout"] +[connection signal="pressed" from="UI/WorldGeneration/VBoxContainer/Seed/Generate" to="." method="_on_world_seed_generate_pressed"] [connection signal="pressed" from="UI/WorldGeneration/VBoxContainer/Submit/Button" to="." method="_on_generation_submit_pressed"]