11extends WindowDialog
22
3- var global :Node # Needed for reference to "Global" node of Pixelorama (Used most of the time)
4- onready var http = $ HTTPRequest
3+ ## # Usage:
4+ ## # Change the "EXTENSION_NAME" and "STORE_LINK" from the (Main.gd)
5+ ## # Don't touch anything else
6+
57var extension_container :VBoxContainer
68var extension_path : String = ""
79
8- ## ## Usage:
9- ## # Change the "store_version", "store_link" and "download_file" variables to your choice
10- ## # Don't touch anything else
11- var download_file : String = "variable_info.txt" # File can be of any name you want
12- var store_link : String = "https://raw.githubusercontent.com/Variable-ind/Pixelorama-Extensions/master/store_info.txt"
13- var store_version : float = 0.1
14-
10+ var store_link :String
11+ var store_name :String
12+ var download_file :String
13+ var store_version :float
1514var new_version_available := false
16- ## # Principle/Setup:
17- # 1) Make a file in the repository and store all the extensions inside it in
18- # the form of
19- # ["Name", "Information", "Image", "Download Link"]
20- # -> Name : The EXACT case-sensitive name of the extension
21- # -> Information : The extension information (can be anything)
22- # -> Image : The image link (taken from anywhere on the internet)
23- # -> Download link : The link is taken by clicking on extension in github
24- # and clicking "Copy Link" on the "Download" button located
25- # right next to "Delete this file" button on the next page
26- #
27- # 2) After the list is made save by clicking "Commit new file". Open the file and click the "Raw"
28- # button which is located right next to "Blame" button. When the raw mode is opened copy the link
29- # from the search bar. This link is your new "store_link" variable.
30- #
31- # 3) Now just export this as a regular .pck extension (Remember to replace wherever "VariableStore"
32- # is written to your own choice name)and you are now good to go
33- # (You dont have to touch the extension ever again)!!.
34- #
35- # 4) Just update the list on github as new extensions come along.
36- # The extensions that are not on the list will not be available for download
3715
3816
17+ onready var http = $ HTTPRequest
3918onready var content = $ Panel/ScrollContainer/Content
4019
4120
@@ -44,16 +23,17 @@ func _on_StoreButton_pressed() -> void:
4423
4524
4625func _on_Store_about_to_show () -> void :
47- # Display Version
48- if ! window_title .ends_with (str (" (" , store_version , ")" )):
49- window_title += str (" (" , store_version , ")" )
26+ # Basic setup
27+ download_file = str (store_name ,".txt" )
28+ store_version = get_store_version_info ()
29+ window_title = str (store_name , " (" , store_version , ")" )
5030
5131 # Clear old entries
5232 for entry in content .get_children ():
5333 entry .queue_free ()
5434
5535 # Some Essential settings
56- global = get_node_or_null ("/root/Global" )
36+ var global : Node = get_node_or_null ("/root/Global" )
5737 if global :
5838 extension_container = global .control .find_node ("Extensions" )
5939 if extension_container :
@@ -73,35 +53,63 @@ func _on_HTTPRequest_request_completed(result: int, _response_code: int, _header
7353 var _error = file .open (str (extension_path ,download_file ), File .READ )
7454 var version :float
7555
76- var dummy_number = 1
7756 while not file .eof_reached ():
7857 var info = str2var (file .get_line ())
7958 if typeof (info ) == TYPE_REAL :
8059 # check version
8160 version = info
82- if version > store_version :
61+ if version > store_version and ! new_version_available :
8362 new_version_available = true
8463 elif typeof (info ) == TYPE_ARRAY :
85- if dummy_number >= 3 :
86- if new_version_available :
87- if dummy_number == 3 :
88- var label := Label .new ()
89- label .text = str ("Version " , version , " is Available" )
90- content .add_child (label )
91- add_entry (info ) # Announce update
92- else :
93- if dummy_number > 3 : # The first 3 lines of file are Store-related and are excluded
94- add_entry (info )
95- dummy_number += 1
64+ if new_version_available :
65+ var label := Label .new ()
66+ label .text = str ("Version " , version , " is Available" )
67+ content .add_child (label )
68+ add_entry (info ) # Announce update
69+ break
70+ else :
71+ if info [0 ] != store_name :
72+ add_entry (info )
9673 file .close ()
9774 var dir := Directory .new ()
98- dir .remove (str (extension_path ,download_file ))
75+ _error = dir .remove (str (extension_path , download_file ))
9976 else :
10077 printerr ("Unable to Get info from remote repository..." )
10178
10279
10380func add_entry (info : Array ) -> void :
104- var entry = preload ("res://src/Extensions/VariableStore /Store/Entry/Entry.tscn" ).instance ()
81+ var entry = load ("res://src/Extensions/%s /Store/Entry/Entry.tscn" % store_name ).instance ()
10582 entry .extension_container = extension_container
10683 content .add_child (entry )
10784 entry .set_info (info , extension_path )
85+
86+
87+ func error_getting_info ():
88+ $ Error/Text .text = str ($ Error/Text .text % store_name )
89+ $ Error .popup_centered ()
90+
91+
92+ func get_store_version_info () -> float :
93+ var store_config_file_path : String = "res://src/Extensions/%s /extension.json" % store_name
94+ var store_config_file := File .new ()
95+ var err := store_config_file .open (store_config_file_path , File .READ )
96+ if err != OK :
97+ printerr ("Error loading config file: " , err )
98+ store_config_file .close ()
99+ return float (0 )
100+
101+ var info_json = parse_json (store_config_file .get_as_text ())
102+ store_config_file .close ()
103+
104+ if ! info_json :
105+ printerr ("No JSON data found." )
106+ return float (0 )
107+
108+ if info_json .has ("version" ):
109+ var version = str2var (info_json ["version" ])
110+ if typeof (version ) == TYPE_REAL :
111+ return version
112+ else :
113+ return version
114+ else :
115+ return float (0 )
0 commit comments