Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Event Body toggle not showing up #1533

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions addons/dialogic/Editor/Events/EventBlock/event_block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var expanded := true
var body_was_build := false

# does the body have elements?
var has_body_content := false
var has_any_enabled_body_content := false

# list that stores visibility conditions
var field_list := []
Expand Down Expand Up @@ -137,8 +137,11 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
body_was_build = true

for p in resource.get_event_editor_info():
field_list.append({'node':null, 'location':p.location})
if p.has('condition'):
field_list[-1]['condition'] = p.condition

if !build_body and p.location == 1:
has_body_content = true
continue
elif !build_header and p.location == 0:
continue
Expand All @@ -149,6 +152,7 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:

### LINEBREAK
if p.name == "linebreak":
field_list.remove_at(field_list.size()-1)
if !current_body_container.get_child_count():
current_body_container.queue_free()
current_body_container = HFlowContainer.new()
Expand Down Expand Up @@ -249,7 +253,7 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:

### --------------------------------------------------------------------
### 3. FILL THE NEW NODE WITH INFORMATION AND LISTEN TO CHANGES
field_list.append({'node':editor_node})
field_list[-1]['node'] = editor_node
if "event_resource" in editor_node:
editor_node.event_resource = resource
if 'property_name' in editor_node:
Expand All @@ -275,40 +279,42 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void:
if p.has('condition'):
field_list[-1]['condition'] = p.condition
if left_label:
field_list.append({'node': left_label, 'condition':p.condition})
field_list.append({'node': left_label, 'condition':p.condition, 'location':p.location})
if right_label:
field_list.append({'node': right_label, 'condition':p.condition})
field_list.append({'node': right_label, 'condition':p.condition, 'location':p.location})

if build_body:
has_body_content = true
# has_body_content = true
if current_body_container.get_child_count() == 0:
has_body_content = false
# has_body_content = false
expanded = false
body_container.visible = false

recalculate_field_visibility()


func recalculate_field_visibility() -> void:
has_any_enabled_body_content = false
for p in field_list:
if !p.has('condition') or p.condition.is_empty():
p.node.show()
if p.node != null:
p.node.show()
if p.location == 1:
has_any_enabled_body_content = true
else:
var expr := Expression.new()
expr.parse(p.condition)
if expr.execute([], resource):
p.node.show()
if p.node != null:
p.node.show()
if p.location == 1:
has_any_enabled_body_content = true
else:
p.node.hide()
if p.node != null:
p.node.hide()
if expr.has_execute_failed():
printerr("[Dialogic] Failed executing visibility condition for '",p.get('property', 'unnamed'),"': " + expr.get_error_text())
%ExpandButton.visible = false
if body_content_container != null:
for node in body_content_container.get_children():
for sub_node in node.get_children():
if sub_node.visible:
%ExpandButton.visible = true
break
%ExpandButton.visible = has_any_enabled_body_content


func set_property(property_name:String, value:Variant) -> void:
Expand Down Expand Up @@ -392,7 +398,7 @@ func _on_EventNode_gui_input(event:InputEvent) -> void:
if event is InputEventMouseButton and event.is_pressed() and event.button_index == 1:
grab_focus() # Grab focus to avoid copy pasting text or events
if event.double_click:
if has_body_content:
if has_any_enabled_body_content:
_on_ExpandButton_toggled(!expanded)
# For opening the context menu
if event is InputEventMouseButton:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func _draw():
continue

if !event.resource is DialogicEndBranchEvent:
if event.has_body_content or event.resource.can_contain_events:
if event.has_any_enabled_body_content or event.resource.can_contain_events:
var icon_panel_height := 32*_scale
var rect_position :Vector2= event.get_node('%IconPanel').global_position+Vector2(0,1)*event.get_node('%IconPanel').size+Vector2(0,-4)
var color :Color= event.resource.event_color
Expand Down
6 changes: 3 additions & 3 deletions addons/dialogic/Events/Call Node/event_call_node.gd
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ func get_shortcode_parameters() -> Dictionary:
func build_event_editor():
add_header_edit('method', ValueType.SinglelineText, 'Call method')
add_header_edit('path', ValueType.SinglelineText, 'in object')
add_body_edit('wait', ValueType.Bool, 'wait for method to finsih:')
add_body_edit('wait', ValueType.Bool, 'Wait for method to finsih:')
add_body_edit('inline', ValueType.Bool, 'Use as inline Command:')
add_body_edit('inline_signal_argument', ValueType.SinglelineText, 'inline Signal Name', '', {}, 'inline == true')
add_body_edit('inline_signal_argument', ValueType.SinglelineText, 'Inline Signal Name', '', {}, 'inline == true')
add_body_edit('inline_single_use', ValueType.Bool, 'Single Use:', '', {}, 'inline == true')
add_body_line_break()
add_body_edit('arguments', ValueType.StringArray, 'arguments:')
add_body_edit('arguments', ValueType.StringArray, 'Arguments:')