123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- extends Reference
- var filePrexif = "user://colorTiles"
- var lat = 0
- var lon = 0
- # Called when the node enters the scene tree for the first time.
- func _ready():
- pass # Replace with function body.
- # this function essentially checks if the file exists and starts a download if not
- func open(latIN, lonIN):
- lat = latIN
- lon = lonIN
- var file = File.new()
- var err = file.open(getTexName(), File.READ)
- if err == 7:
- Downloader.download(getTexName(), "color")
- var dl = Downloader.Download.new()
- while not dl._file_name == getTexName():
- dl = yield(Messenger, "fileDownloaded")
- file.open(getTexName(), File.READ)
- Messenger.emit_signal("textureReady", Vector2(latIN, lonIN))
- return Vector2(latIN, lonIN)
- elif err != OK:
- print("error opening tex ", err)
- return false
- else:
- file.close()
- return Vector2(latIN, lonIN)
- func loadTexture():
- var texName = getTexName()
- print("opening texture "+texName)
- var image = Image.new()
- var err = image.load(texName)
- if err != OK:
- print("error opening tex ", err)
- var tex = ImageTexture.new()
- tex.create_from_image(image, 0)
- return tex
-
- func getTexName():
- return "%s/m-%s-%s.png" % [filePrexif, (int(lat)+90)%180, (int(lon)+180)%360]
- #return "res://tex/grid.png"
- # Called every frame. 'delta' is the elapsed time since the previous frame.
- #func _process(delta):
- # pass
|