dev: 函数统一间隔两行
This commit is contained in:
@@ -9,6 +9,7 @@ func create_file(file_path: String) -> void:
|
||||
var file: FileAccess = FileAccess.open(file_path, FileAccess.WRITE)
|
||||
file.close()
|
||||
|
||||
|
||||
func download_file(server_path: String, local_path: String) -> void:
|
||||
var http: HTTPRequest = HTTPRequest.new()
|
||||
add_child(http)
|
||||
@@ -19,6 +20,7 @@ func download_file(server_path: String, local_path: String) -> void:
|
||||
http.request(server_path)
|
||||
await http.request_completed
|
||||
|
||||
|
||||
func get_uuid() -> void:
|
||||
var index_file: FileAccess = FileAccess.open("user://download/sources/temp/index.json", FileAccess.READ)
|
||||
var index_text: String = index_file.get_as_text()
|
||||
@@ -26,6 +28,7 @@ func get_uuid() -> void:
|
||||
index_file.close()
|
||||
uuid = content["uuid"]
|
||||
|
||||
|
||||
func download_defs(type: String, origin: String) -> void:
|
||||
var list_file: FileAccess = FileAccess.open("user://download/sources/%s/%ss/list.json" % [uuid, type], FileAccess.READ)
|
||||
var list_text: String = list_file.get_as_text()
|
||||
@@ -37,6 +40,7 @@ func download_defs(type: String, origin: String) -> void:
|
||||
var filename = list[k]
|
||||
await download_file("%s%s/id/%s" % [origin, type, k], "user://download/sources/%s/%ss/%s.json" % [uuid, type, filename])
|
||||
|
||||
|
||||
func download_assets(origin: String) -> void:
|
||||
var list_file: FileAccess = FileAccess.open("user://download/sources/%s/assets/list.json" % [uuid], FileAccess.READ)
|
||||
var list_text: String = list_file.get_as_text()
|
||||
@@ -51,6 +55,7 @@ func download_assets(origin: String) -> void:
|
||||
var filename = list["sounds"][k]
|
||||
await download_file("%sasset/sound/%s" % [origin, k], "user://download/sources/%s/assets/sounds/%s" % [uuid, filename])
|
||||
|
||||
|
||||
func download_from_origin() -> int:
|
||||
var origin: String = GameManager.data_origin
|
||||
var http: HTTPRequest = HTTPRequest.new()
|
||||
@@ -88,6 +93,7 @@ func download_from_origin() -> int:
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
func load_resource():
|
||||
var card_file: FileAccess = FileAccess.open("user://download/sources/%s/cards/list.json" % [uuid], FileAccess.READ)
|
||||
GameManager.card_list = JSON.parse_string(card_file.get_as_text())
|
||||
@@ -107,6 +113,7 @@ func load_resource():
|
||||
GameManager.sound_list = asset_list["sounds"]
|
||||
asset_file.close()
|
||||
|
||||
|
||||
func get_sources():
|
||||
if !DirAccess.dir_exists_absolute("user://download/sources/"):
|
||||
DirAccess.make_dir_recursive_absolute("user://download/sources/")
|
||||
|
||||
Reference in New Issue
Block a user