|
| 1 | +extends WindowDialog |
| 2 | + |
| 3 | +var global :Node #Needed for reference to "Global" node of Pixelorama (Used most of the time) |
| 4 | +onready var http = $HTTPRequest |
| 5 | +var extension_container :VBoxContainer |
| 6 | +var extension_path: String = "" |
| 7 | + |
| 8 | +#### Usage: |
| 9 | +### Change the "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 | + |
| 14 | +### Principle/Setup: |
| 15 | +# 1) Make a file in the repository and store all the extensions inside it in |
| 16 | +# the form of |
| 17 | +# ["Name", "Information", "Image", "Download Link"] |
| 18 | +# -> Name : The EXACT case-sensitive name of the extension |
| 19 | +# -> Information : The extension information (can be anything) |
| 20 | +# -> Image : The image link (taken from anywhere on the internet) |
| 21 | +# -> Download link : The link is taken by clicking on extension in github |
| 22 | +# and clicking "Copy Link" on the "Download" button located |
| 23 | +# right next to "Delete this file" button on the next page |
| 24 | +# |
| 25 | +# 2) After the list is made save by clicking "Commit new file". Open the file and click the "Raw" |
| 26 | +# button which is located right next to "Blame" button. When the raw mode is opened copy the link |
| 27 | +# from the search bar. This link is your new "store_link" variable. |
| 28 | +# |
| 29 | +# 3) Now just export this as a regular .pck extension (Remember to replace wherever "VariableStore" |
| 30 | +# is written to your own choice name)and you are now good to go |
| 31 | +# (You dont have to touch the extension ever again)!!. |
| 32 | +# |
| 33 | +# 4) Just update the list on github as new extensions come along. |
| 34 | +# The extensions that are not on the list will not be available for download |
| 35 | + |
| 36 | + |
| 37 | +onready var content = $Panel/ScrollContainer/Content |
| 38 | + |
| 39 | + |
| 40 | +func _on_StoreButton_pressed() -> void: |
| 41 | + popup_centered() |
| 42 | + |
| 43 | + |
| 44 | +func _on_Store_about_to_show() -> void: |
| 45 | + #clear old entries |
| 46 | + for entry in content.get_children(): |
| 47 | + entry.queue_free() |
| 48 | + |
| 49 | + # Some Essential settings |
| 50 | + global = get_node_or_null("/root/Global") |
| 51 | + if global: |
| 52 | + extension_container = global.control.find_node("Extensions") |
| 53 | + if extension_container: |
| 54 | + extension_path = ProjectSettings.globalize_path(extension_container.EXTENSIONS_PATH) |
| 55 | + if !extension_path.ends_with("/"): |
| 56 | + extension_path += "/" |
| 57 | + else: |
| 58 | + return |
| 59 | + |
| 60 | + http.download_file = str(extension_path,download_file) |
| 61 | + var _error = http.request(store_link) |
| 62 | + |
| 63 | + |
| 64 | +func _on_HTTPRequest_request_completed(result: int, _response_code: int, _headers: PoolStringArray, _body: PoolByteArray) -> void: |
| 65 | + if result == HTTPRequest.RESULT_SUCCESS: |
| 66 | + var file = File.new() |
| 67 | + var _error = file.open(str(extension_path,download_file), File.READ) |
| 68 | + |
| 69 | + var dummy_number = 0 # I don't need the first line of file |
| 70 | + while not file.eof_reached(): |
| 71 | + var info = str2var(file.get_line()) |
| 72 | + if dummy_number > 0: |
| 73 | + if typeof(info) == TYPE_ARRAY: |
| 74 | + add_entry(info) |
| 75 | + dummy_number += 1 |
| 76 | + file.close() |
| 77 | + var dir := Directory.new() |
| 78 | + dir.remove(str(extension_path,download_file)) |
| 79 | + else: |
| 80 | + printerr("Unable to Get info from remote repository...") |
| 81 | + |
| 82 | + |
| 83 | +func add_entry(info: Array) -> void: |
| 84 | + var entry = preload("res://src/Extensions/VariableStore/Store/Entry/Entry.tscn").instance() |
| 85 | + entry.extension_container = extension_container |
| 86 | + content.add_child(entry) |
| 87 | + entry.set_info(info, extension_path) |
0 commit comments