2019-05-31 22:44:21 +00:00
|
|
|
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
|
2019-07-03 20:15:12 +00:00
|
|
|
Remote.fetch(Remote.ImageURL + cardid + ".webp", cbObj, cbFn)
|