Skip to content

Commit 3f5494f

Browse files
authored
Variable store (#5)
* Add files via upload * Add files via upload * Update README.md * Update Example.pck * Update README.md
1 parent ef6bc3a commit 3f5494f

14 files changed

Lines changed: 446 additions & 1 deletion

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[preset.0]
2+
3+
name="Windows Desktop"
4+
platform="Windows Desktop"
5+
runnable=true
6+
custom_features=""
7+
export_filter="all_resources"
8+
include_filter="*.json"
9+
exclude_filter=""
10+
export_path="../../../../Desktop/VariableStore.exe"
11+
script_export_mode=1
12+
script_encryption_key=""
13+
14+
[preset.0.options]
15+
16+
custom_template/debug=""
17+
custom_template/release=""
18+
binary_format/64_bits=true
19+
binary_format/embed_pck=false
20+
texture_format/bptc=false
21+
texture_format/s3tc=true
22+
texture_format/etc=false
23+
texture_format/etc2=false
24+
texture_format/no_bptc_fallbacks=true
25+
codesign/enable=false
26+
codesign/identity=""
27+
codesign/password=""
28+
codesign/timestamp=true
29+
codesign/timestamp_server_url=""
30+
codesign/digest_algorithm=1
31+
codesign/description=""
32+
codesign/custom_options=PoolStringArray( )
33+
application/icon=""
34+
application/file_version=""
35+
application/product_version=""
36+
application/company_name=""
37+
application/product_name=""
38+
application/file_description=""
39+
application/copyright=""
40+
application/trademarks=""

Code/VariableStore/project.godot

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=4
10+
11+
[application]
12+
13+
config/name="VariableStore"
14+
15+
[physics]
16+
17+
common/enable_pause_aware_picking=true
18+
19+
[rendering]
20+
21+
quality/driver/driver_name="GLES2"
22+
vram_compression/import_etc=true
23+
vram_compression/import_etc2=false
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
extends Node
2+
3+
### Usage:
4+
### Change the "store_link" and "download_file" variables from the (store.gd)
5+
### Don't touch anything else
6+
7+
8+
var global :Node #Needed for reference to "Global" node of Pixelorama (Used most of the time)
9+
10+
var extension_container :VBoxContainer
11+
var store :Button
12+
# This script acts as a setup for the extension
13+
func _enter_tree() -> void:
14+
global = get_node_or_null("/root/Global")
15+
if global:
16+
extension_container = global.control.find_node("Extensions")
17+
if extension_container:
18+
store = preload("res://src/Extensions/VariableStore/Store/Store.tscn").instance()
19+
store.get_child(0).extension_container = extension_container
20+
var parent = extension_container.get_node("HBoxContainer")
21+
parent.add_child(store)
22+
23+
func _exit_tree() -> void:
24+
store.queue_free()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gd_scene load_steps=2 format=2]
2+
3+
[ext_resource path="res://src/Extensions/VariableStore/Main.gd" type="Script" id=1]
4+
5+
[node name="Main" type="Node"]
6+
script = ExtResource( 1 )
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
extends Panel
2+
3+
### Usage:
4+
### Change the "store_link" and "download_file" variables from the (store.gd)
5+
### Don't touch anything else
6+
7+
onready var ext_name = $HBoxContainer/VBoxContainer/Name
8+
onready var ext_discription = $HBoxContainer/VBoxContainer/Description
9+
onready var ext_picture = $HBoxContainer/Picture
10+
11+
var extension_container :VBoxContainer
12+
var thumbnail := ""
13+
var download_link := ""
14+
var download_path := ""
15+
16+
onready var download_request = $DownloadRequest
17+
18+
func set_info(info: Array, extension_path: String) -> void:
19+
ext_name.text = info[0]
20+
ext_discription.text = info[1]
21+
thumbnail = info[2]
22+
download_link = info[3]
23+
var dir := Directory.new()
24+
dir.make_dir_recursive(str(extension_path,"Download/"))
25+
download_path = str(extension_path,"Download/",info[0],".pck")
26+
27+
$RequestDelay.wait_time = randf() * 2 #to prevent sending bulk requests
28+
$RequestDelay.start()
29+
30+
31+
func _on_RequestDelay_timeout() -> void:
32+
$RequestDelay.queue_free()
33+
var _error = $ImageRequest.request(thumbnail) #image
34+
35+
36+
func _on_ImageRequest_request_completed(_result, _response_code, _headers, body: PoolByteArray) -> void:
37+
# Update the recieved image
38+
$ImageRequest.queue_free()
39+
var image = Image.new()
40+
var _error = image.load_jpg_from_buffer(body)
41+
if _error != OK:
42+
var _err1 = image.load_png_from_buffer(body)
43+
if _err1 != OK:
44+
var _err2 = image.load_webp_from_buffer(body)
45+
if _err2 != OK:
46+
var _err3 = image.load_tga_from_buffer(body)
47+
if _err3 != OK:
48+
var _err4 = image.load_bmp_from_buffer(body)
49+
var texture = ImageTexture.new()
50+
texture.create_from_image(image)
51+
ext_picture.texture = texture
52+
53+
54+
func _on_Button_pressed() -> void:
55+
# Download File
56+
$HBoxContainer/VBoxContainer/Button.disabled = true
57+
download_request.download_file = download_path
58+
download_request.request(download_link)
59+
60+
61+
func _on_DownloadRequest_request_completed(result: int, _response_code, _headers, _body) -> void:
62+
if result == HTTPRequest.RESULT_SUCCESS:
63+
# Add extension
64+
extension_container.install_extension(download_path)
65+
var dir := Directory.new()
66+
dir.remove(download_path)
67+
announce_done(true)
68+
else:
69+
$Error.dialog_text = str("Unable to Download extension...\nHttp Code (",result,")").c_unescape()
70+
$Error.popup_centered()
71+
announce_done(false)
72+
73+
74+
func announce_done(success: bool):
75+
$HBoxContainer/VBoxContainer/Button.disabled = false
76+
if success:
77+
$HBoxContainer/VBoxContainer/Done.visible = true
78+
$DoneDelay.start()
79+
80+
81+
func _on_DoneDelay_timeout() -> void:
82+
$HBoxContainer/VBoxContainer/Done.visible = false
83+
84+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://src/Extensions/VariableStore/Store/Entry/Entry.gd" type="Script" id=1]
4+
[ext_resource path="res://src/Extensions/VariableStore/Store/Entry/PlaceHolder.png" type="Texture" id=2]
5+
6+
[node name="Entry" type="Panel"]
7+
margin_right = 399.0
8+
margin_bottom = 100.0
9+
rect_min_size = Vector2( 0, 100 )
10+
size_flags_horizontal = 3
11+
script = ExtResource( 1 )
12+
13+
[node name="HBoxContainer" type="HBoxContainer" parent="."]
14+
anchor_right = 1.0
15+
anchor_bottom = 1.0
16+
17+
[node name="Picture" type="TextureRect" parent="HBoxContainer"]
18+
margin_right = 100.0
19+
margin_bottom = 100.0
20+
rect_min_size = Vector2( 100, 0 )
21+
texture = ExtResource( 2 )
22+
expand = true
23+
stretch_mode = 6
24+
25+
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
26+
margin_left = 104.0
27+
margin_right = 399.0
28+
margin_bottom = 100.0
29+
size_flags_horizontal = 3
30+
31+
[node name="Name" type="Label" parent="HBoxContainer/VBoxContainer"]
32+
margin_right = 295.0
33+
margin_bottom = 14.0
34+
text = "Extension Name..."
35+
36+
[node name="Description" type="RichTextLabel" parent="HBoxContainer/VBoxContainer"]
37+
margin_top = 18.0
38+
margin_right = 295.0
39+
margin_bottom = 76.0
40+
size_flags_vertical = 3
41+
42+
[node name="Done" type="Label" parent="HBoxContainer/VBoxContainer"]
43+
visible = false
44+
margin_top = 62.0
45+
margin_right = 295.0
46+
margin_bottom = 76.0
47+
text = "Done!!!"
48+
align = 1
49+
50+
[node name="Button" type="Button" parent="HBoxContainer/VBoxContainer"]
51+
margin_top = 80.0
52+
margin_right = 295.0
53+
margin_bottom = 100.0
54+
text = "Download"
55+
56+
[node name="RequestDelay" type="Timer" parent="."]
57+
one_shot = true
58+
autostart = true
59+
60+
[node name="ImageRequest" type="HTTPRequest" parent="."]
61+
62+
[node name="DownloadRequest" type="HTTPRequest" parent="."]
63+
64+
[node name="DoneDelay" type="Timer" parent="."]
65+
wait_time = 2.0
66+
67+
[node name="Error" type="AcceptDialog" parent="."]
68+
margin_right = 242.0
69+
margin_bottom = 84.0
70+
71+
[node name="Text" type="Label" parent="Error"]
72+
anchor_right = 1.0
73+
anchor_bottom = 1.0
74+
margin_left = 8.0
75+
margin_top = 8.0
76+
margin_right = -8.0
77+
margin_bottom = -36.0
78+
align = 1
79+
valign = 1
80+
81+
[connection signal="pressed" from="HBoxContainer/VBoxContainer/Button" to="." method="_on_Button_pressed"]
82+
[connection signal="timeout" from="RequestDelay" to="." method="_on_RequestDelay_timeout"]
83+
[connection signal="request_completed" from="ImageRequest" to="." method="_on_ImageRequest_request_completed"]
84+
[connection signal="request_completed" from="DownloadRequest" to="." method="_on_DownloadRequest_request_completed"]
85+
[connection signal="timeout" from="DoneDelay" to="." method="_on_DoneDelay_timeout"]
1.04 KB
Loading
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/PlaceHolder.png-9ac8ce407c63c0424579abf0f82b6144.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://src/Extensions/VariableStore/Store/Entry/PlaceHolder.png"
13+
dest_files=[ "res://.import/PlaceHolder.png-9ac8ce407c63c0424579abf0f82b6144.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
process/normal_map_invert_y=false
32+
stream=false
33+
size_limit=0
34+
detect_3d=true
35+
svg/scale=1.0
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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

Comments
 (0)