Skip to content

Commit

Permalink
feat: apply ConfirmationDialog when adding a new gameobjectcluster
Browse files Browse the repository at this point in the history
refs: #333, #334, #177fedd7
  • Loading branch information
Mathias Baumgartinger~ committed Jan 2, 2024
1 parent 54740ad commit cf2328c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions UI/LabTable/LabTable.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extends Control
var current_goc_name = "Wind Farms"

var geo_transform
var goc_configuration_popup = preload("res://GameSystem/GameObjectConfiguration.tscn")

signal game_object_created(cursor_position)
signal game_object_failed(cursor_position)
Expand Down Expand Up @@ -100,6 +101,24 @@ func set_workshop_mode(active: bool):
vector_local.z = -vector_local.z

var collection = GameSystem.current_game_mode.game_object_collections[current_goc_name]

# Let user configure the GoC via a popup if any change is allowed
var is_any_change_allowed = collection.attributes.values().any(
func(attrib): return attrib.allow_change)

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)
for attribute: GameObjectAttribute in collection.attributes.values():
if attribute.allow_change:
goc_popup.add_configuration_option(attribute.name, attribute)

goc_popup.popup_on_parent(Rect2(event.global_position, goc_popup.size))
var success = await goc_popup.closed
if not success: return

var new_game_object = GameSystem.create_new_game_object(collection, vector_local)

if new_game_object:
Expand Down

0 comments on commit cf2328c

Please sign in to comment.