mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 13:11:42 +00:00
preserve previews
This commit is contained in:
parent
2283afe20d
commit
ba69caffd2
1 changed files with 9 additions and 1 deletions
|
|
@ -51,6 +51,7 @@ class Mission {
|
||||||
#else
|
#else
|
||||||
static var _previewRequest:Int;
|
static var _previewRequest:Int;
|
||||||
#end
|
#end
|
||||||
|
static var _previewCache:Map<Mission, h2d.Tile> = [];
|
||||||
|
|
||||||
public function new() {}
|
public function new() {}
|
||||||
|
|
||||||
|
|
@ -171,9 +172,16 @@ class Mission {
|
||||||
if (_previewRequest != null #if sys && !_previewRequest.fulfilled #end) {
|
if (_previewRequest != null #if sys && !_previewRequest.fulfilled #end) {
|
||||||
Http.cancel(_previewRequest); // Cancel the previous request to save dequeing
|
Http.cancel(_previewRequest); // Cancel the previous request to save dequeing
|
||||||
}
|
}
|
||||||
|
if (_previewCache.exists(this)) {
|
||||||
|
var t = _previewCache.get(this);
|
||||||
|
onLoaded(t);
|
||||||
|
return t.getTexture().name;
|
||||||
|
}
|
||||||
_previewRequest = Marbleland.getMissionImage(this.id, (im) -> {
|
_previewRequest = Marbleland.getMissionImage(this.id, (im) -> {
|
||||||
if (im != null) {
|
if (im != null) {
|
||||||
onLoaded(im.toTile());
|
var t = im.toTile();
|
||||||
|
_previewCache.set(this, t);
|
||||||
|
onLoaded(t);
|
||||||
} else {
|
} else {
|
||||||
Console.error("Preview image not found for " + this.path);
|
Console.error("Preview image not found for " + this.path);
|
||||||
var img = new BitmapData(1, 1);
|
var img = new BitmapData(1, 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue