Skip to content

Commit

Permalink
Update choice event script.
Browse files Browse the repository at this point in the history
- Added a method to set default values for properties
See godotengine/godot#30440 (comment)
  • Loading branch information
AnidemDex committed Nov 27, 2021
1 parent fd18ce3 commit d9715aa
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions addons/textalog/events/dialog/choice.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ func remove_option(option_name:String) -> void:


func _set_option(option_name:String, value) -> void:
if (value == null) or not (value is Timeline):
value = Timeline.new()

options[option_name] = value
emit_changed()
property_list_changed_notify()
Expand Down Expand Up @@ -53,7 +50,7 @@ func _on_option_selected(option) -> void:
var curr_tmln:Timeline = event_manager.timeline
var curr_queue := curr_tmln._event_queue.duplicate()

var timeline:Timeline = options[option] as Timeline
var timeline:Timeline = options[option] as Timeline
var events:Array = timeline.get_events()
events.invert()

Expand Down Expand Up @@ -82,6 +79,21 @@ func _execute() -> void:
_options_manager.connect("option_selected", self, "_on_option_selected", [], CONNECT_ONESHOT)


func property_can_revert(property):
if property.begins_with("options/"):
property = property.replace("options/", "")
if options.has(property):
return true
return false


func property_get_revert(property):
if property.begins_with("options/"):
property = property.replace("options/", "")
if options.has(property):
return Timeline.new()


func _get_property_list() -> Array:
var p := []

Expand All @@ -99,7 +111,6 @@ func _get_property_list() -> Array:
"type":TYPE_OBJECT,
"usage":PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_SCRIPT_VARIABLE,
"hint":PROPERTY_HINT_RESOURCE_TYPE,
"hint_string":"Timeline"
}
)

Expand Down

0 comments on commit d9715aa

Please sign in to comment.