feat: 完成资源加载功能
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
print(OS.get_user_data_dir())
|
|
||||||
|
|
||||||
func create_file(file_path: String) -> void:
|
func create_file(file_path: String) -> void:
|
||||||
var base_dir = file_path.get_base_dir()
|
var base_dir = file_path.get_base_dir()
|
||||||
if !DirAccess.dir_exists_absolute(base_dir):
|
if !DirAccess.dir_exists_absolute(base_dir):
|
||||||
@@ -22,8 +19,8 @@ func download_file(server_path: String, local_path: String) -> void:
|
|||||||
func download_defs(type: String, origin: String) -> void:
|
func download_defs(type: String, origin: String) -> void:
|
||||||
var list_file = FileAccess.open("user://download/source/%ss/list.json" % [type], FileAccess.READ)
|
var list_file = FileAccess.open("user://download/source/%ss/list.json" % [type], FileAccess.READ)
|
||||||
var list_text = list_file.get_as_text()
|
var list_text = list_file.get_as_text()
|
||||||
print(list_text)
|
|
||||||
var list = JSON.parse_string(list_text)
|
var list = JSON.parse_string(list_text)
|
||||||
|
list_file.close()
|
||||||
if !list:
|
if !list:
|
||||||
return
|
return
|
||||||
for k in list:
|
for k in list:
|
||||||
@@ -33,8 +30,8 @@ func download_defs(type: String, origin: String) -> void:
|
|||||||
func download_assets(origin: String) -> void:
|
func download_assets(origin: String) -> void:
|
||||||
var list_file = FileAccess.open("user://download/source/assets/list.json", FileAccess.READ)
|
var list_file = FileAccess.open("user://download/source/assets/list.json", FileAccess.READ)
|
||||||
var list_text = list_file.get_as_text()
|
var list_text = list_file.get_as_text()
|
||||||
print(list_text)
|
|
||||||
var list = JSON.parse_string(list_text)
|
var list = JSON.parse_string(list_text)
|
||||||
|
list_file.close()
|
||||||
if !list:
|
if !list:
|
||||||
return
|
return
|
||||||
for k in list["pics"]:
|
for k in list["pics"]:
|
||||||
@@ -72,4 +69,20 @@ func download_from_origin() -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
func load_resource():
|
func load_resource():
|
||||||
pass
|
var card_file = FileAccess.open("user://download/source/cards/list.json", FileAccess.READ)
|
||||||
|
GameManager.card_list = JSON.parse_string(card_file.get_as_text())
|
||||||
|
card_file.close()
|
||||||
|
|
||||||
|
var reaction_file = FileAccess.open("user://download/source/reactions/list.json", FileAccess.READ)
|
||||||
|
GameManager.reaction_list = JSON.parse_string(reaction_file.get_as_text())
|
||||||
|
reaction_file.close()
|
||||||
|
|
||||||
|
var matter_file = FileAccess.open("user://download/source/matters/list.json", FileAccess.READ)
|
||||||
|
GameManager.matter_list = JSON.parse_string(matter_file.get_as_text())
|
||||||
|
matter_file.close()
|
||||||
|
|
||||||
|
var asset_file = FileAccess.open("user://download/source/assets/list.json", FileAccess.READ)
|
||||||
|
var asset_list = JSON.parse_string(asset_file.get_as_text())
|
||||||
|
GameManager.pic_list = asset_list["pics"]
|
||||||
|
GameManager.sound_list = asset_list["sounds"]
|
||||||
|
asset_file.close()
|
||||||
|
|||||||
@@ -3,3 +3,10 @@ extends Node
|
|||||||
var data_origin: String = ""
|
var data_origin: String = ""
|
||||||
var ip_begin: String = "192.168."
|
var ip_begin: String = "192.168."
|
||||||
var username: String = ""
|
var username: String = ""
|
||||||
|
|
||||||
|
var card_list: Dictionary = {}
|
||||||
|
var matter_list: Dictionary = {}
|
||||||
|
var reaction_list: Dictionary = {}
|
||||||
|
var match_list: Dictionary = {}
|
||||||
|
var pic_list: Dictionary = {}
|
||||||
|
var sound_list: Dictionary = {}
|
||||||
Reference in New Issue
Block a user