mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-28 05:31:37 +00:00
make work on js
This commit is contained in:
parent
266a29afc4
commit
ce1bcf9c2c
6 changed files with 31 additions and 8 deletions
|
|
@ -907,7 +907,7 @@ class DtsObject extends GameObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isInstanced) {
|
if (!this.isInstanced && !this.isTSStatic) {
|
||||||
for (i in 0...this.materials.length) {
|
for (i in 0...this.materials.length) {
|
||||||
var info = this.materialInfos.get(this.materials[i]);
|
var info = this.materialInfos.get(this.materials[i]);
|
||||||
if (info == null)
|
if (info == null)
|
||||||
|
|
|
||||||
14
src/Http.hx
14
src/Http.hx
|
|
@ -1,7 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
import src.Console;
|
import src.Console;
|
||||||
import sys.thread.FixedThreadPool;
|
|
||||||
|
|
||||||
typedef HttpRequest = {
|
typedef HttpRequest = {
|
||||||
var url:String;
|
var url:String;
|
||||||
|
|
@ -55,6 +54,7 @@ class Http {
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
// Returns HTTPRequest on sys, Int on js
|
||||||
public static function get(url:String, callback:haxe.io.Bytes->Void, errCallback:String->Void) {
|
public static function get(url:String, callback:haxe.io.Bytes->Void, errCallback:String->Void) {
|
||||||
var req = {
|
var req = {
|
||||||
url: url,
|
url: url,
|
||||||
|
|
@ -67,7 +67,9 @@ class Http {
|
||||||
requests.add(req);
|
requests.add(req);
|
||||||
return req;
|
return req;
|
||||||
#else
|
#else
|
||||||
js.Browser.window.fetch(url).then(r -> r.arrayBuffer().then(b -> callback(haxe.io.Bytes.ofData(b))), e -> errCallback(e.toString()));
|
return js.Browser.window.setTimeout(() -> {
|
||||||
|
js.Browser.window.fetch(url).then(r -> r.arrayBuffer().then(b -> callback(haxe.io.Bytes.ofData(b))), e -> errCallback(e.toString()));
|
||||||
|
}, 75);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,11 +82,15 @@ class Http {
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if sys
|
||||||
public static function cancel(req:HttpRequest) {
|
public static function cancel(req:HttpRequest) {
|
||||||
#if sys
|
|
||||||
cancellationMutex.acquire();
|
cancellationMutex.acquire();
|
||||||
req.cancelled = true;
|
req.cancelled = true;
|
||||||
cancellationMutex.release();
|
cancellationMutex.release();
|
||||||
#end
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
public static function cancel(req:Int) {
|
||||||
|
js.Browser.window.clearTimeout(req);
|
||||||
|
}
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1021,7 +1021,7 @@ class MarbleWorld extends Scheduler {
|
||||||
this.addDtsObject(tsShape, () -> {
|
this.addDtsObject(tsShape, () -> {
|
||||||
tsShape.setTransform(mat);
|
tsShape.setTransform(mat);
|
||||||
onFinish();
|
onFinish();
|
||||||
});
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addParticleEmitterNode(element:MissionElementParticleEmitterNode) {
|
public function addParticleEmitterNode(element:MissionElementParticleEmitterNode) {
|
||||||
|
|
@ -1053,7 +1053,7 @@ class MarbleWorld extends Scheduler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addDtsObject(obj:DtsObject, onFinish:Void->Void) {
|
public function addDtsObject(obj:DtsObject, onFinish:Void->Void, isTsStatic:Bool = false) {
|
||||||
function parseIfl(path:String, onFinish:Array<String>->Void) {
|
function parseIfl(path:String, onFinish:Array<String>->Void) {
|
||||||
ResourceLoader.load(path).entry.load(() -> {
|
ResourceLoader.load(path).entry.load(() -> {
|
||||||
var text = ResourceLoader.getFileEntry(path).entry.getText();
|
var text = ResourceLoader.getFileEntry(path).entry.getText();
|
||||||
|
|
@ -1116,6 +1116,8 @@ class MarbleWorld extends Scheduler {
|
||||||
|
|
||||||
for (texPath in texToLoad) {
|
for (texPath in texToLoad) {
|
||||||
if (haxe.io.Path.extension(texPath) == "ifl") {
|
if (haxe.io.Path.extension(texPath) == "ifl") {
|
||||||
|
if (isTsStatic)
|
||||||
|
obj.useInstancing = false;
|
||||||
worker.addTask(fwd -> {
|
worker.addTask(fwd -> {
|
||||||
parseIfl(texPath, keyframes -> {
|
parseIfl(texPath, keyframes -> {
|
||||||
var innerWorker = new ResourceLoaderWorker(() -> {
|
var innerWorker = new ResourceLoaderWorker(() -> {
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,19 @@ class Marbleland {
|
||||||
switch (game) {
|
switch (game) {
|
||||||
case 'gold':
|
case 'gold':
|
||||||
goldMissions.sort((x, y) -> x.title > y.title ? 1 : (x.title < y.title ? -1 : 0));
|
goldMissions.sort((x, y) -> x.title > y.title ? 1 : (x.title < y.title ? -1 : 0));
|
||||||
|
for (i in 0...goldMissions.length - 1) {
|
||||||
|
@:privateAccess goldMissions[i].next = goldMissions[i + 1];
|
||||||
|
}
|
||||||
case 'platinum':
|
case 'platinum':
|
||||||
platinumMissions.sort((x, y) -> x.title > y.title ? 1 : (x.title < y.title ? -1 : 0));
|
platinumMissions.sort((x, y) -> x.title > y.title ? 1 : (x.title < y.title ? -1 : 0));
|
||||||
|
for (i in 0...platinumMissions.length - 1) {
|
||||||
|
@:privateAccess platinumMissions[i].next = platinumMissions[i + 1];
|
||||||
|
}
|
||||||
case 'ultra':
|
case 'ultra':
|
||||||
ultraMissions.sort((x, y) -> x.title > y.title ? 1 : (x.title < y.title ? -1 : 0));
|
ultraMissions.sort((x, y) -> x.title > y.title ? 1 : (x.title < y.title ? -1 : 0));
|
||||||
|
for (i in 0...ultraMissions.length - 1) {
|
||||||
|
@:privateAccess ultraMissions[i].next = ultraMissions[i + 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,11 @@ class Mission {
|
||||||
|
|
||||||
var imgFileEntry:hxd.fs.FileEntry;
|
var imgFileEntry:hxd.fs.FileEntry;
|
||||||
|
|
||||||
|
#if sys
|
||||||
static var _previewRequest:HttpRequest;
|
static var _previewRequest:HttpRequest;
|
||||||
|
#else
|
||||||
|
static var _previewRequest:Int;
|
||||||
|
#end
|
||||||
|
|
||||||
public function new() {}
|
public function new() {}
|
||||||
|
|
||||||
|
|
@ -164,7 +168,7 @@ class Mission {
|
||||||
onLoaded(Tile.fromBitmap(img));
|
onLoaded(Tile.fromBitmap(img));
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (_previewRequest != null && !_previewRequest.fulfilled) {
|
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
|
||||||
}
|
}
|
||||||
_previewRequest = Marbleland.getMissionImage(this.id, (im) -> {
|
_previewRequest = Marbleland.getMissionImage(this.id, (im) -> {
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,9 @@ class ResourceLoader {
|
||||||
zipFilesystem.clear(); // We are only allowed to load one zip
|
zipFilesystem.clear(); // We are only allowed to load one zip
|
||||||
for (entry in entries) {
|
for (entry in entries) {
|
||||||
var fname = entry.fileName.toLowerCase();
|
var fname = entry.fileName.toLowerCase();
|
||||||
|
#if sys
|
||||||
fname = "data/" + fname;
|
fname = "data/" + fname;
|
||||||
|
#end
|
||||||
if (exists(fname))
|
if (exists(fname))
|
||||||
continue;
|
continue;
|
||||||
Console.log("Loaded zip entry: " + fname);
|
Console.log("Loaded zip entry: " + fname);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue