~swashberry/godot-license-dialog

e273b929786a4c6a8518bfb5c255a358129fed57 — swashberry 2 months ago d934605
do not read copyright file if path is blank.

If the `copyright_file` variable is left blank, the `LicenseDialog` will
not attempt to read any copyright file and will not populate the
`ComponentList` tree with project component information.

Projects will no longer push warnings if the `copyright_file` variable
is left as a blank string, which is now default.  However, the warnings
will still occur if the user specifies a file path which does not exist,
or if the project finds a copyright file which is not formatted
properly.

In order to make this change work, the `onready` keywords have been
removed from the `project_name` and `copyright_file` variable
declarations.
2 files changed, 17 insertions(+), 15 deletions(-)

M license_dialog.gd
M sample_project/sample_main_node.tscn
M license_dialog.gd => license_dialog.gd +16 -15
@@ 16,8 16,8 @@ export(String) var project_name = "" setget set_project_name, \
		get_project_name

# The path to a file containing licensing information for the game.
export(String, FILE, "*.txt") var copyright_file = \
		"res://COPYRIGHT.txt" setget set_copyright_file, get_copyright_file
export(String, FILE, "*.txt") var copyright_file =  "" \
		setget set_copyright_file, get_copyright_file


# These variables act as shortcuts to nodes within the LicenseDialog which we


@@ 60,19 60,20 @@ func _ready():

	# Populate the game components & licensing information from the copyright
	# file.
	_read_copyright_file()

	if project_components.size() == 0:
		push_warning( "Couldn't read any copyright data for this game!" )
	else:
		# Create a subtree for the project components list.
		project_components_tree = _component_list.create_item( root )
		project_components_tree.set_text( 0, game_name )
		project_components_tree.set_selectable( 0, false )
		for component in project_components:
			var component_item = _component_list.create_item(
					project_components_tree )
			component_item.set_text( 0, component )
	if copyright_file != "":
		_read_copyright_file()

		if project_components.size() == 0:
			push_warning( "Couldn't read any copyright data for this game!" )
		else:
			# Create a subtree for the project components list.
			project_components_tree = _component_list.create_item( root )
			project_components_tree.set_text( 0, game_name )
			project_components_tree.set_selectable( 0, false )
			for component in project_components:
				var component_item = _component_list.create_item(
						project_components_tree )
				component_item.set_text( 0, component )

	# Create a subtree for the Godot Engine components list.
	_godot_components_tree = _component_list.create_item( root )

M sample_project/sample_main_node.tscn => sample_project/sample_main_node.tscn +1 -0
@@ 7,6 7,7 @@
script = ExtResource( 1 )

[node name="LicenseDialog" parent="." instance=ExtResource( 2 )]
copyright_file = "res://COPYRIGHT.txt"

[node name="Label" type="Label" parent="."]
margin_left = 129.934