mlpcardgame/Classes/Utils/Resources.gd

14 lines
487 B
GDScript3
Raw Permalink Normal View History

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