Skip to content

Commit bcbaefb

Browse files
authored
Release ver 0.2
1 parent 2b7a37c commit bcbaefb

File tree

7 files changed

+164
-89
lines changed

7 files changed

+164
-89
lines changed

Code/VariableStore/project.godot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ config_version=4
1111
[application]
1212

1313
config/name="VariableStore"
14+
run/main_scene="res://src/Extensions/VariableStore/Store/Store.tscn"
1415

1516
[physics]
1617

Code/VariableStore/src/Extensions/VariableStore/Main.gd

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
extends Node
22

3-
### Usage:
4-
### Change the "store_link" and "download_file" variables from the (store.gd)
3+
#### Usage:
4+
### Change the "EXTENSION_NAME" and "STORE_LINK" to your choice
5+
### and the version number is set from "extension.json" (version MUST be a float)
56
### Don't touch anything else
7+
const STORE_LINK: String = "https://raw.githubusercontent.com/Variable-ind/Pixelorama-Extensions/master/store_info.txt"
8+
const EXTENSION_NAME: String = "VariableStore" # Should be the same as the extension name in extension.json
9+
### Principle/Setup:
10+
# 1) Make a file in the repository and store all the extensions inside it in
11+
# the form of
12+
# ["Name", "Information", "Image", "Download Link"]
13+
# -> Name : The EXACT case-sensitive name of the extension
14+
# -> Information : The extension information (can be anything)
15+
# -> Image : The image link (taken from anywhere on the internet)
16+
# -> Download link : The link is taken by clicking on extension in github
17+
# and clicking "Copy Link" on the "Download" button located
18+
# right next to "Delete this file" button on the next page
19+
#
20+
# 2) After the list is made save by clicking "Commit new file". Open the file and click the "Raw"
21+
# button which is located right next to "Blame" button. When the raw mode is opened copy the link
22+
# from the search bar. This link is your new "STORE_LINK".
23+
#
24+
# 3) Now just export this as a regular .pck extension (Remember to replace wherever "VariableStore"
25+
# is written to your own choice name)and you are now good to go
26+
# (You dont have to touch the extension ever again)!!.
27+
#
28+
# 4) Just update the list on github as new extensions come along.
29+
# The extensions that are not on the list will not be available for download
630

731

832
var global :Node #Needed for reference to "Global" node of Pixelorama (Used most of the time)
@@ -15,10 +39,14 @@ func _enter_tree() -> void:
1539
if global:
1640
extension_container = global.control.find_node("Extensions")
1741
if extension_container:
18-
store = preload("res://src/Extensions/VariableStore/Store/Store.tscn").instance()
42+
store = load("res://src/Extensions/%s/Store/Store.tscn" % EXTENSION_NAME).instance()
1943
store.get_child(0).extension_container = extension_container
44+
store.get_child(0).store_name = EXTENSION_NAME
45+
store.get_child(0).store_link = STORE_LINK
46+
store.text = "Open %s" % EXTENSION_NAME
2047
var parent = extension_container.get_node("HBoxContainer")
2148
parent.add_child(store)
2249

50+
2351
func _exit_tree() -> void:
2452
store.queue_free()

Code/VariableStore/src/Extensions/VariableStore/Store/Entry/Entry.gd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
extends Panel
22

33
### Usage:
4-
### Change the "store_link" and "download_file" variables from the (store.gd)
4+
### Change the "EXTENSION_NAME" and "STORE_LINK" from the (Main.gd)
55
### Don't touch anything else
66

7-
onready var ext_name = $HBoxContainer/VBoxContainer/Name
8-
onready var ext_discription = $HBoxContainer/VBoxContainer/Description
9-
onready var ext_picture = $HBoxContainer/Picture
7+
onready var ext_name = $Panel/HBoxContainer/VBoxContainer/Name
8+
onready var ext_discription = $Panel/HBoxContainer/VBoxContainer/Description
9+
onready var ext_picture = $Panel/HBoxContainer/Picture
1010

1111
var extension_container :VBoxContainer
1212
var thumbnail := ""
@@ -21,7 +21,7 @@ func set_info(info: Array, extension_path: String) -> void:
2121
thumbnail = info[2]
2222
download_link = info[3]
2323
var dir := Directory.new()
24-
dir.make_dir_recursive(str(extension_path,"Download/"))
24+
var _error = dir.make_dir_recursive(str(extension_path,"Download/"))
2525
download_path = str(extension_path,"Download/",info[0],".pck")
2626

2727
$RequestDelay.wait_time = randf() * 2 #to prevent sending bulk requests
@@ -53,7 +53,7 @@ func _on_ImageRequest_request_completed(_result, _response_code, _headers, body:
5353

5454
func _on_Button_pressed() -> void:
5555
# Download File
56-
$HBoxContainer/VBoxContainer/Button.disabled = true
56+
$Panel/HBoxContainer/VBoxContainer/Button.disabled = true
5757
download_request.download_file = download_path
5858
download_request.request(download_link)
5959

@@ -62,23 +62,23 @@ func _on_DownloadRequest_request_completed(result: int, _response_code, _headers
6262
if result == HTTPRequest.RESULT_SUCCESS:
6363
# Add extension
6464
extension_container.install_extension(download_path)
65-
var dir := Directory.new()
66-
dir.remove(download_path)
6765
announce_done(true)
6866
else:
6967
$Error.dialog_text = str("Unable to Download extension...\nHttp Code (",result,")").c_unescape()
7068
$Error.popup_centered()
7169
announce_done(false)
70+
var dir := Directory.new()
71+
var _error = dir.remove(download_path)
7272

7373

7474
func announce_done(success: bool):
75-
$HBoxContainer/VBoxContainer/Button.disabled = false
75+
$Panel/HBoxContainer/VBoxContainer/Button.disabled = false
7676
if success:
77-
$HBoxContainer/VBoxContainer/Done.visible = true
77+
$Panel/HBoxContainer/VBoxContainer/Done.visible = true
7878
$DoneDelay.start()
7979

8080

8181
func _on_DoneDelay_timeout() -> void:
82-
$HBoxContainer/VBoxContainer/Done.visible = false
82+
$Panel/HBoxContainer/VBoxContainer/Done.visible = false
8383

8484

Code/VariableStore/src/Extensions/VariableStore/Store/Entry/Entry.tscn

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,73 @@
44
[ext_resource path="res://src/Extensions/VariableStore/Store/Entry/PlaceHolder.png" type="Texture" id=2]
55

66
[node name="Entry" type="Panel"]
7+
self_modulate = Color( 0.411765, 0.411765, 0.411765, 1 )
78
margin_right = 399.0
8-
margin_bottom = 100.0
9-
rect_min_size = Vector2( 0, 100 )
9+
margin_bottom = 140.0
10+
rect_min_size = Vector2( 0, 140 )
1011
size_flags_horizontal = 3
1112
script = ExtResource( 1 )
1213

13-
[node name="HBoxContainer" type="HBoxContainer" parent="."]
14+
[node name="Panel" type="Panel" parent="."]
15+
self_modulate = Color( 0.701961, 0.701961, 0.701961, 1 )
16+
anchor_right = 1.0
17+
anchor_bottom = 1.0
18+
margin_left = 3.0
19+
margin_top = 4.0
20+
margin_right = -3.0
21+
margin_bottom = -4.0
22+
mouse_filter = 1
23+
__meta__ = {
24+
"_editor_description_": ""
25+
}
26+
27+
[node name="HBoxContainer" type="HBoxContainer" parent="Panel"]
1428
anchor_right = 1.0
1529
anchor_bottom = 1.0
30+
margin_right = -6.0
31+
margin_bottom = -8.0
1632

17-
[node name="Picture" type="TextureRect" parent="HBoxContainer"]
33+
[node name="Picture" type="TextureRect" parent="Panel/HBoxContainer"]
1834
margin_right = 100.0
19-
margin_bottom = 100.0
35+
margin_bottom = 124.0
2036
rect_min_size = Vector2( 100, 0 )
2137
texture = ExtResource( 2 )
2238
expand = true
2339
stretch_mode = 6
2440

25-
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
41+
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/HBoxContainer"]
2642
margin_left = 104.0
27-
margin_right = 399.0
28-
margin_bottom = 100.0
43+
margin_right = 387.0
44+
margin_bottom = 124.0
2945
size_flags_horizontal = 3
3046

31-
[node name="Name" type="Label" parent="HBoxContainer/VBoxContainer"]
32-
margin_right = 295.0
47+
[node name="Name" type="Label" parent="Panel/HBoxContainer/VBoxContainer"]
48+
margin_right = 283.0
3349
margin_bottom = 14.0
3450
text = "Extension Name..."
3551

36-
[node name="Description" type="RichTextLabel" parent="HBoxContainer/VBoxContainer"]
52+
[node name="Description" type="TextEdit" parent="Panel/HBoxContainer/VBoxContainer"]
3753
margin_top = 18.0
38-
margin_right = 295.0
39-
margin_bottom = 76.0
54+
margin_right = 283.0
55+
margin_bottom = 100.0
4056
size_flags_vertical = 3
57+
text = "DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription"
58+
readonly = true
59+
wrap_enabled = true
4160

42-
[node name="Done" type="Label" parent="HBoxContainer/VBoxContainer"]
61+
[node name="Done" type="Label" parent="Panel/HBoxContainer/VBoxContainer"]
4362
visible = false
44-
margin_top = 62.0
45-
margin_right = 295.0
46-
margin_bottom = 76.0
63+
self_modulate = Color( 0.337255, 1, 0, 1 )
64+
margin_top = 46.0
65+
margin_right = 283.0
66+
margin_bottom = 60.0
4767
text = "Done!!!"
4868
align = 1
4969

50-
[node name="Button" type="Button" parent="HBoxContainer/VBoxContainer"]
51-
margin_top = 80.0
52-
margin_right = 295.0
53-
margin_bottom = 100.0
70+
[node name="Button" type="Button" parent="Panel/HBoxContainer/VBoxContainer"]
71+
margin_top = 104.0
72+
margin_right = 283.0
73+
margin_bottom = 124.0
5474
text = "Download"
5575

5676
[node name="RequestDelay" type="Timer" parent="."]
@@ -78,7 +98,7 @@ margin_bottom = -36.0
7898
align = 1
7999
valign = 1
80100

81-
[connection signal="pressed" from="HBoxContainer/VBoxContainer/Button" to="." method="_on_Button_pressed"]
101+
[connection signal="pressed" from="Panel/HBoxContainer/VBoxContainer/Button" to="." method="_on_Button_pressed"]
82102
[connection signal="timeout" from="RequestDelay" to="." method="_on_RequestDelay_timeout"]
83103
[connection signal="request_completed" from="ImageRequest" to="." method="_on_ImageRequest_request_completed"]
84104
[connection signal="request_completed" from="DownloadRequest" to="." method="_on_DownloadRequest_request_completed"]
Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,20 @@
11
extends 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+
57
var extension_container :VBoxContainer
68
var 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
1514
var 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
3918
onready var content = $Panel/ScrollContainer/Content
4019

4120

@@ -44,16 +23,17 @@ func _on_StoreButton_pressed() -> void:
4423

4524

4625
func _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

10380
func 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

Comments
 (0)