Skip to content

Commit

Permalink
feat: add min and max to GameObjectClusterCollection and correspondin…
Browse files Browse the repository at this point in the history
…g popupconfiguration

refs: #333, #334, #177fedd7
  • Loading branch information
Mathias Baumgartinger~ committed Jan 2, 2024
1 parent 91993ac commit bfc8058
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
4 changes: 2 additions & 2 deletions GameSystem/GameObjectCollections/GameObjectCollection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
6 changes: 5 additions & 1 deletion GameSystem/GameObjectConfiguration.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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}

Expand Down
8 changes: 7 additions & 1 deletion UI/LabTable/LabTable.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bfc8058

Please sign in to comment.