mlpcardgame/Classes/Utils/Resources.gd

14 lines
No EOL
487 B
GDScript

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.ImageURL + cardid + ".webp", cbObj, cbFn)