From bfc8058aefa734d4f2c187064b70008bf520e9b6 Mon Sep 17 00:00:00 2001 From: Mathias Baumgartinger~ Date: Tue, 2 Jan 2024 18:09:51 +0100 Subject: [PATCH] feat: add min and max to GameObjectClusterCollection and corresponding popupconfiguration refs: #333, #334, #177fedd7 --- .../GameObjectCollections/GameObjectClusterCollection.gd | 4 +++- GameSystem/GameObjectCollections/GameObjectCollection.gd | 4 ++-- GameSystem/GameObjectConfiguration.gd | 6 +++++- UI/LabTable/LabTable.gd | 8 +++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/GameSystem/GameObjectCollections/GameObjectClusterCollection.gd b/GameSystem/GameObjectCollections/GameObjectClusterCollection.gd index 0126daf43..0826d7631 100644 --- a/GameSystem/GameObjectCollections/GameObjectClusterCollection.gd +++ b/GameSystem/GameObjectCollections/GameObjectClusterCollection.gd @@ -10,7 +10,9 @@ var feature_layer var location_layer var instance_goc -var cluster_size = 8 +var cluster_size := 8 +var min_cluster_size := 1 +var max_cluster_size := 20 var search_radius = 4000.0 var location_feature_instances = {} var used_locations = {} diff --git a/GameSystem/GameObjectCollections/GameObjectCollection.gd b/GameSystem/GameObjectCollections/GameObjectCollection.gd index 5f1dcd7f6..152694e06 100644 --- a/GameSystem/GameObjectCollections/GameObjectCollection.gd +++ b/GameSystem/GameObjectCollections/GameObjectCollection.gd @@ -22,11 +22,11 @@ func _init(initial_name): name = initial_name -func get_game_object(id): +func get_game_object(id) -> GameObject: return game_objects[id] -func get_all_game_objects(): +func get_all_game_objects() -> Array[GameObject]: return game_objects.values() diff --git a/GameSystem/GameObjectConfiguration.gd b/GameSystem/GameObjectConfiguration.gd index 6fd0f2800..6ec48dcc4 100644 --- a/GameSystem/GameObjectConfiguration.gd +++ b/GameSystem/GameObjectConfiguration.gd @@ -15,7 +15,7 @@ func _ready(): canceled.connect(_on_any_button.bind(false)) -func add_configuration_option(option_name, reference): +func add_configuration_option(option_name, reference, min=null, max=null): var vbox = VBoxContainer.new() vbox.name = option_name var label = Label.new() @@ -24,6 +24,10 @@ func add_configuration_option(option_name, reference): slider.min_value = 1 slider.tick_count = 10 slider.step = 1 + if min != null: + slider.min_value = float(min) + if max != null: + slider.max_value = float(max) name_to_ref_ui[option_name] = {"ref": reference, "ui": slider} diff --git a/UI/LabTable/LabTable.gd b/UI/LabTable/LabTable.gd index 9de5e2518..f1ace035a 100644 --- a/UI/LabTable/LabTable.gd +++ b/UI/LabTable/LabTable.gd @@ -109,8 +109,14 @@ func set_workshop_mode(active: bool): if is_any_change_allowed or collection is GameObjectClusterCollection: var goc_popup: ConfirmationDialog = goc_configuration_popup.instantiate() add_child(goc_popup) + if "cluster_size" in collection: - goc_popup.add_configuration_option("cluster_size", collection) + goc_popup.add_configuration_option( + "cluster_size", + collection, + collection.min_cluster_size, + collection.max_cluster_size) + for attribute: GameObjectAttribute in collection.attributes.values(): if attribute.allow_change: goc_popup.add_configuration_option(attribute.name, attribute)