Skip to content

Documentation: Add example of polymorphism/inheritance #29

Description

@hrothwell

Found that inheritance / polymorphism could be done, but not clear in README:

func save():
	save_dialog.show()
	
	save_dialog.file_selected.connect(func(path: String):
		var file = FileAccess.open(path, FileAccess.WRITE)
		file.store_line(ForgeJSONGD.class_to_json_string(my_abstract_resource_implementation, true)), # save the file type 
		ConnectFlags.CONNECT_ONE_SHOT)

func open():
	open_dialog.show()
	
	open_dialog.file_selected.connect(func(path: String):
		var previously_saved: AbstractResource = ForgeJSONGD.json_file_to_class(null, path) # null commented in scripts to use the saved type
		do_something(previously_saved), # this carries the previous implementation's type correctly
		ConnectFlags.CONNECT_ONE_SHOT)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions