Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
deflinhec committed Jan 7, 2021
2 parents 93f507d + d3d2df6 commit 85e6c7a
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/.gutconfig.json export-ignore
/test/ export-ignore
/datas/ export-ignore
/demo/ export-ignore
/screenshots/ export-ignore
/addons/gut/ export-ignore
/icon.png export-ignore
/icon.png.import export-ignore
/main.tscn export-ignore
/project.godot export-ignore
/default_env.tres export-ignore
/LICENSE export-ignore
Expand Down
2 changes: 1 addition & 1 deletion addons/google_sheet/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="GodotGoogleSheet"
description=""
author="Deflinhec"
version="1.0.0"
version="1.0.1"
script="plugin.gd"
13 changes: 11 additions & 2 deletions addons/google_sheet/src/gsheet.gd
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ func _wait(_caller):
return
_sem.wait()

func _notification(what):
if what == NOTIFICATION_PREDELETE:
if use_thread and _thread.is_active():
_thread.wait_to_finish()


func _init(new_host: Host = null):
host = new_host if new_host else host
connect("allset", self, "_on_allset")
if not use_thread:
return
_mutex = Mutex.new()
Expand All @@ -90,11 +96,11 @@ func start():
if not _queue.empty():
if not use_thread:
call_deferred("_thread_func", 0)
else:
elif not _thread.is_active():
_ternimate = false
_thread.start(self, "_thread_func", 0)
else:
call_deferred("emit_signal", "allset")
connect("allset", self, "_on_allset")


func _on_allset():
Expand All @@ -109,6 +115,7 @@ func download() -> void:
_requesting = true
_post("download")
_unlock("download")
start()


# 下載請求,取得下載檔案大小
Expand Down Expand Up @@ -205,6 +212,8 @@ func _is_ternimate() -> bool:
func _thread_func(_u):
while not _is_ternimate():
_load_process()
if _is_ternimate():
break
_http_process()


Expand Down
48 changes: 48 additions & 0 deletions demo/main.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
extends CanvasLayer

var GSheet = preload("res://addons/google_sheet/src/gsheet.gd")

var gsheet = GSheet.new()

var datas: Dictionary = {}

func _ready():
gsheet.connect("allset", self, "_on_allset")
gsheet.connect("complete", self, "_on_complete")
gsheet.connect("total_bytes_changed", self, "_on_total_bytes_changed")
gsheet.connect("downloaded_bytes_changed", self, "_on_downloaded_bytes_changed")
gsheet.connect("total_files_changed", self, "_on_total_files_changed")
gsheet.connect("loaded_files_changed", self, "_on_loaded_files_changed")
gsheet.queue("res://datas/test.json",
"1-DGS8kSiBrPOxvyM1ISCxtdqWt-I7u1Vmcp-XksQ1M4", 1)
gsheet.start()


func _on_total_bytes_changed(bytes: int):
$Status.set_text("Downloading...")
$ProgressBar.max_value = bytes


func _on_downloaded_bytes_changed(bytes: int):
$ProgressBar.value = bytes


func _on_total_files_changed(count: int):
$Status.set_text("Loading...")
$ProgressBar.max_value = count


func _on_loaded_files_changed(count: int):
$ProgressBar.value = count


func _on_complete(path: String, data: Dictionary):
datas[path] = data


func _on_allset():
$Status.set_text("All set")


func _on_Button_pressed():
gsheet.download()
48 changes: 48 additions & 0 deletions demo/main.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://demo/main.gd" type="Script" id=1]

[node name="CanvasLayer" type="CanvasLayer"]
script = ExtResource( 1 )

[node name="ProgressBar" type="ProgressBar" parent="."]
anchor_left = 0.444
anchor_top = 0.488
anchor_right = 0.556
anchor_bottom = 0.512
margin_left = 0.343964
margin_top = 0.199982
margin_right = -0.344055
margin_bottom = -0.200012
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Button" type="Button" parent="."]
anchor_left = 0.445
anchor_top = 0.528
anchor_right = 0.555
anchor_bottom = 0.562
margin_left = 0.319977
margin_top = 0.200012
margin_right = -0.320007
margin_bottom = -0.200012
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Status" type="Label" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -40.0
margin_top = -28.6667
margin_right = 40.0
margin_bottom = -14.6667
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
3 changes: 0 additions & 3 deletions main.tscn

This file was deleted.

2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _global_script_class_icons={
[application]

config/name="GodotGoogleSheet"
run/main_scene="res://test/test.tscn"
run/main_scene="res://demo/main.tscn"
config/icon="res://icon.png"

[editor_plugins]
Expand Down

0 comments on commit 85e6c7a

Please sign in to comment.