~swashberry/godot-license-dialog

d934605f5a8a1e908b9bc0c16f491bd287178b41 — swashberry 2 months ago b28da00
remove _label_text variable.

The more I think about it, the more having a whole separate variable and
functions which modify the text of a label seemed wasteful and
unnecessary.  This commit removes that variable and repurposes the
`set_label_text` function as a shortcut.

Because this variable is no longer being used to modify the text of the
label, the script for the `LicenseDialog` no longer needs to update
editor properties, so the `tool` keyword has been removed.
2 files changed, 4 insertions(+), 23 deletions(-)

M license_dialog.gd
M license_dialog.tscn
M license_dialog.gd => license_dialog.gd +3 -21
@@ 1,4 1,3 @@
tool
extends WindowDialog
# A dialog which displays a human-readable list of attribution notices.



@@ 13,20 12,13 @@ enum { _FILE, _COPYRIGHT, _COMMENT, _LICENSE }

# The name of the project which will be used.  If left blank, this value will be
# replaced with the name of the Godot Engine project.
export(String) onready var project_name = "" setget set_project_name, \
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") onready var copyright_file = \
export(String, FILE, "*.txt") var copyright_file = \
		"res://COPYRIGHT.txt" setget set_copyright_file, get_copyright_file

# The text for the label which appears above the components list.  The text
# "GAME_NAME" will be replaced with the contents of `project_name`.
export(String, MULTILINE) onready var label_text = "Clicking one of the " + \
		"buttons below will display licensing information for individual " + \
		"components of GAME_NAME and the engine it is built on, the Godot " + \
		"Engine." setget set_label_text, get_label_text


# These variables act as shortcuts to nodes within the LicenseDialog which we
# will be accessing frequently.  The reason we do this is that it's cheaper to


@@ 63,9 55,6 @@ func _ready():
	if game_name == "":
		game_name = ProjectSettings.get_setting( "application/config/name" )

	var parsed_text = label_text.replace( "GAME_NAME", game_name )
	_info_label.set_text( parsed_text )

	# Create the root for the component list tree.
	var root = _component_list.create_item()



@@ 141,14 130,7 @@ func get_copyright_file() -> String:


func set_label_text( text: String ):
	label_text = text


func get_label_text( replace_name: bool = false ) -> String:
	if replace_name:
		return label_text
	else:
		return label_text.replace( "GAME_NAME", project_name )
	_info_label.text = text


func _on_ComponentList_item_selected():

M license_dialog.tscn => license_dialog.tscn +1 -2
@@ 12,14 12,13 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
label_text = "Clicking one of the buttons below will display licensing information for individual components of  and the engine it is built on, the Godot Engine."

[node name="Label" type="Label" parent="."]
anchor_left = 0.01
anchor_top = 0.01
anchor_right = 0.99
anchor_bottom = 0.1
text = "Clicking one of the buttons below will display licensing information for individual components of Godot Unofficial License Dialog (GUiLD) and the engine it is built on, the Godot Engine."
text = "Clicking one of the buttons below will display licensing information for individual components of this project and the engine it is built on, the Godot Engine."
autowrap = true
__meta__ = {
"_edit_use_anchors_": false