Dynamic buttons

On branch feat/godot
 Changes to be committed:
	modified:   tools/configurator/main.gd
	modified:   tools/configurator/main.tscn
	modified:   tools/configurator/res/pixel_ui_theme/RetroDECKTheme.tres
	modified:   tools/configurator/tk_about.gd
This commit is contained in:
Rekku 2024-08-19 12:47:46 +01:00
parent 971d93b158
commit ab4a7f1c0a
4 changed files with 74 additions and 66 deletions

View file

@ -27,7 +27,7 @@ var a_button_texture_alt: Texture2D = load("res://assets/icons/kenney_input-prom
var b_button_texture: Texture2D = load("res://assets/icons/kenney_input-prompts-pixel-16/Tiles/tile_0043.png")
var b_button_texture_alt: Texture2D = load("res://assets/icons/kenney_input-prompts-pixel-16/Tiles/tile_0048.png")
var app_data = AppData.new()
var app_data := AppData.new()
func _ready():
_get_nodes()
_connect_signals()

View file

@ -1060,47 +1060,55 @@ expand_mode = 1
stretch_mode = 4
[node name="GridContainer" type="GridContainer" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container"]
unique_name_in_owner = true
layout_mode = 2
columns = 3
[node name="website_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container/GridContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "TK_WEBSITE"
icon = ExtResource("21_1vm5n")
[node name="changelog_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container/GridContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "TK_CHANGELOG"
icon = ExtResource("21_1vm5n")
[node name="wiki_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container/GridContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "TK_WIKI"
icon = ExtResource("21_1vm5n")
[node name="credits_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container/GridContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "TK_CREDITS"
icon = ExtResource("21_1vm5n")
[node name="donate_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container/GridContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "TK_DONATE"
icon = ExtResource("21_1vm5n")
[node name="contactus_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container/GridContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "TK_CONTACTUS"
icon = ExtResource("21_1vm5n")
[node name="licenses_button" type="Button" parent="Background/MarginContainer/TabContainer/TK_ABOUT/ScrollContainer/about_container/GridContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "TK_LICENSES"
icon = ExtResource("21_1vm5n")

File diff suppressed because one or more lines are too long

View file

@ -1,33 +1,36 @@
extends MarginContainer
#var class_functions: ClassFunctions
var website_button: Button
var changelog_button: Button
var rd_web_button := Button.new()
var rd_changelog_button := Button.new()
var wiki_button: Button
var credits_button: Button
var donate_button: Button
var contactus_button: Button
var licenses_button: Button
var app_data = AppData.new()
var app_data := AppData.new()
var bArray :Array = [rd_web_button,rd_changelog_button]
func _ready():
#tk_about = class_functions.import_csv_data("res://tk_about.txt")
app_data = data_handler.app_data
_get_nodes()
_connect_signals()
for but in bArray:
%GridContainer.add_child(but)
for id in app_data.about_links:
var web_data: Link = app_data.about_links[id]
match id:
"rd_web":
%website_button.text = web_data.name
%website_button.tooltip_text = web_data.description
%website_button.editor_description = web_data.url
rd_web_button.text = web_data.name
rd_web_button.tooltip_text = web_data.description
rd_web_button.icon = ResourceLoader.load("res://assets/icons/pixelitos/128/internet-web-browser.png")
rd_web_button.editor_description = web_data.url
"rd_changelog":
%changelog_button.text = web_data.name
%changelog_button.tooltip_text = web_data.description
%changelog_button.editor_description = web_data.url
rd_changelog_button.text = web_data.name
rd_changelog_button.tooltip_text = web_data.description
rd_changelog_button.icon = ResourceLoader.load("res://assets/icons/pixelitos/128/internet-web-browser.png")
rd_changelog_button.editor_description = web_data.url
"rd_wiki":
%wiki_button.text = web_data.name
%wiki_button.tooltip_text = web_data.description
@ -50,18 +53,15 @@ func _ready():
%licenses_button.editor_description = web_data.url
func _get_nodes() -> void:
website_button = get_node("%website_button")
changelog_button = get_node("%changelog_button")
wiki_button = get_node("%wiki_button")
credits_button = get_node("%credits_button")
donate_button = get_node("%donate_button")
contactus_button = get_node("%contactus_button")
licenses_button = get_node("%licenses_button")
func _connect_signals() -> void:
website_button.pressed.connect(_about_button_pressed.bind("rd_web"))
changelog_button.pressed.connect(_about_button_pressed.bind("rd_changelog"))
rd_web_button.pressed.connect(_about_button_pressed.bind("rd_web"))
rd_changelog_button.pressed.connect(_about_button_pressed.bind("rd_changelog"))
wiki_button.pressed.connect(_about_button_pressed.bind("rd_wiki"))
credits_button.pressed.connect(_about_button_pressed.bind("rd_credits"))
donate_button.pressed.connect(_about_button_pressed.bind("rd_donate"))
@ -71,9 +71,9 @@ func _connect_signals() -> void:
func _about_button_pressed(id: String) -> void:
match id:
"rd_web":
OS.shell_open(%website_button.editor_description)
OS.shell_open(rd_web_button.editor_description)
"rd_changelog":
OS.shell_open(%changelog_button.editor_description)
OS.shell_open(rd_changelog_button.editor_description)
"rd_wiki":
OS.shell_open(%wiki_button.editor_description)
"rd_credits":