14 lines
485 B
GDScript3
14 lines
485 B
GDScript3
|
class_name Resources
|
||
|
|
||
|
static func get_card(cardid: String, cbObj: Object, cbFn: String):
|
||
|
# Check if we have the cards pack
|
||
|
var file := File.new()
|
||
|
var fname := "res://Cards/" + cardid + ".webp"
|
||
|
if file.file_exists(fname):
|
||
|
file.open(fname, File.READ)
|
||
|
var flen := file.get_len()
|
||
|
var buf := file.get_buffer(flen)
|
||
|
cbObj.call(cbFn, HTTPRequest.RESULT_SUCCESS, 200, [], buf)
|
||
|
return
|
||
|
# Otherwise, fetch it and cache it
|
||
|
Remote.fetch(Remote.IMGURL + cardid + ".webp", cbObj, cbFn)
|