mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Add readme button to extensions (if they posess one) (#1045)
This commit is contained in:
parent
bd42a0cba6
commit
50858be854
|
@ -1,9 +1,10 @@
|
|||
class_name ExtensionEntry
|
||||
extends Panel
|
||||
extends PanelContainer
|
||||
|
||||
var sha256 := ""
|
||||
var thumbnail := ""
|
||||
var download_link := ""
|
||||
var readme_link := ""
|
||||
var download_path := ""
|
||||
var tags := PackedStringArray()
|
||||
var is_update := false ## An update instead of download
|
||||
|
@ -18,6 +19,7 @@ var is_update := false ## An update instead of download
|
|||
@onready var thumbnail_request := %ImageRequest as HTTPRequest
|
||||
@onready var extension_downloader := %DownloadRequest as HTTPRequest
|
||||
@onready var down_button := %DownloadButton as Button
|
||||
@onready var readme_button := %ReadmeButton as Button
|
||||
@onready var progress_bar := %ProgressBar as ProgressBar
|
||||
@onready var done_label := %Done as Label
|
||||
@onready var alert_dialog := %Alert as AcceptDialog
|
||||
|
@ -38,6 +40,12 @@ func set_info(info: Dictionary, extension_path: String) -> void:
|
|||
if "description" in info.keys():
|
||||
ext_discription.text = info["description"]
|
||||
ext_discription.tooltip_text = ext_discription.text
|
||||
if "readme" in info.keys():
|
||||
readme_link = info["readme"]
|
||||
readme_link = readme_link.strip_edges()
|
||||
if readme_link != "":
|
||||
readme_button.visible = true
|
||||
readme_button.tooltip_text = readme_link
|
||||
if "thumbnail" in info.keys():
|
||||
thumbnail = info["thumbnail"]
|
||||
if "download_link" in info.keys():
|
||||
|
@ -69,6 +77,10 @@ func _on_ImageRequest_request_completed(
|
|||
small_picture.pressed.connect(enlarge_thumbnail.bind(texture))
|
||||
|
||||
|
||||
func _on_readme_button_pressed() -> void:
|
||||
OS.shell_open(readme_link)
|
||||
|
||||
|
||||
func _on_Download_pressed() -> void:
|
||||
down_button.disabled = true
|
||||
extension_downloader.download_file = download_path
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dnjpemuehkxsn"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dnjpemuehkxsn"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/UI/ExtensionExplorer/Entry/ExtensionEntry.gd" id="1_3no3v"]
|
||||
[ext_resource type="Texture2D" uid="uid://b47r0c6auaqk6" path="res://assets/graphics/icons/icon.png" id="2_qhsve"]
|
||||
[ext_resource type="Texture2D" uid="uid://3v78ojo0pkfg" path="res://assets/graphics/misc/external_link.svg" id="3_ujt8o"]
|
||||
|
||||
[node name="ExtensionEntry" type="Panel"]
|
||||
[node name="ExtensionEntry" type="PanelContainer"]
|
||||
self_modulate = Color(0.411765, 0.411765, 0.411765, 1)
|
||||
custom_minimum_size = Vector2(300, 150)
|
||||
offset_right = 284.0
|
||||
offset_right = 310.0
|
||||
offset_bottom = 150.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_3no3v")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
@ -67,11 +63,22 @@ layout_mode = 2
|
|||
[node name="ProgressTimer" type="Timer" parent="MarginContainer/HBoxContainer/VBoxContainer/ProgressBar"]
|
||||
wait_time = 0.1
|
||||
|
||||
[node name="DownloadButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DownloadButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Download"
|
||||
|
||||
[node name="ReadmeButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "README"
|
||||
icon = ExtResource("3_ujt8o")
|
||||
|
||||
[node name="RequestDelay" type="Timer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
one_shot = true
|
||||
|
@ -115,7 +122,8 @@ stretch_mode = 5
|
|||
|
||||
[connection signal="timeout" from="MarginContainer/HBoxContainer/VBoxContainer/Done/DoneDelay" to="." method="_on_DoneDelay_timeout"]
|
||||
[connection signal="timeout" from="MarginContainer/HBoxContainer/VBoxContainer/ProgressBar/ProgressTimer" to="." method="_on_ProgressTimer_timeout"]
|
||||
[connection signal="pressed" from="MarginContainer/HBoxContainer/VBoxContainer/DownloadButton" to="." method="_on_Download_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/DownloadButton" to="." method="_on_Download_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/HBoxContainer/VBoxContainer/HBoxContainer/ReadmeButton" to="." method="_on_readme_button_pressed"]
|
||||
[connection signal="timeout" from="RequestDelay" to="." method="_on_RequestDelay_timeout"]
|
||||
[connection signal="request_completed" from="ImageRequest" to="." method="_on_ImageRequest_request_completed"]
|
||||
[connection signal="request_completed" from="DownloadRequest" to="." method="_on_DownloadRequest_request_completed"]
|
||||
|
|
|
@ -200,6 +200,8 @@ func parse_extension_data(raw_data: Array) -> Dictionary:
|
|||
result["sha256"] = item[0]
|
||||
"description":
|
||||
result["description"] = item[0]
|
||||
"readme":
|
||||
result["readme"] = item[0]
|
||||
"thumbnail":
|
||||
result["thumbnail"] = item[0]
|
||||
"download_link":
|
||||
|
|
Loading…
Reference in a new issue