mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 04:31:40 +00:00
android build fixes
This commit is contained in:
parent
d7fa0869d7
commit
d86af0b31a
6 changed files with 58 additions and 4 deletions
10
compile-android.hxml
Normal file
10
compile-android.hxml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-cp src
|
||||
-lib heaps
|
||||
-lib hlsdl
|
||||
-lib zyheaps
|
||||
-hl marblegame.hl
|
||||
-D android
|
||||
-D windowSize=1280x720
|
||||
-D keep-inline-positions
|
||||
--main Main
|
||||
-debug
|
||||
|
|
@ -71,18 +71,26 @@ class Mission {
|
|||
if (!this.isClaMission) {
|
||||
var basename = haxe.io.Path.withoutExtension(this.path);
|
||||
if (ResourceLoader.fileSystem.exists(basename + ".png")) {
|
||||
#if (!android)
|
||||
imgFileEntry = ResourceLoader.fileSystem.get(basename + ".png");
|
||||
imgFileEntry.load(() -> {
|
||||
#end
|
||||
var ret = ResourceLoader.getResource(basename + ".png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
onLoaded(ret);
|
||||
#if (!android)
|
||||
});
|
||||
#end
|
||||
}
|
||||
if (ResourceLoader.fileSystem.exists(basename + ".jpg")) {
|
||||
#if (!android)
|
||||
imgFileEntry = ResourceLoader.fileSystem.get(basename + ".jpg");
|
||||
imgFileEntry.load(() -> {
|
||||
#end
|
||||
var ret = ResourceLoader.getResource(basename + ".jpg", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
onLoaded(ret);
|
||||
#if (!android)
|
||||
});
|
||||
#end
|
||||
}
|
||||
var img = new BitmapData(1, 1);
|
||||
img.setPixel(0, 0, 0);
|
||||
|
|
@ -94,6 +102,27 @@ class Mission {
|
|||
}
|
||||
}
|
||||
|
||||
public function getPreviewImageSync() {
|
||||
if (!this.isClaMission) {
|
||||
var basename = haxe.io.Path.withoutExtension(this.path);
|
||||
if (ResourceLoader.fileSystem.exists(basename + ".png")) {
|
||||
var ret = ResourceLoader.getResource(basename + ".png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return ret;
|
||||
}
|
||||
if (ResourceLoader.fileSystem.exists(basename + ".jpg")) {
|
||||
var ret = ResourceLoader.getResource(basename + ".jpg", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return ret;
|
||||
}
|
||||
var img = new BitmapData(1, 1);
|
||||
img.setPixel(0, 0, 0);
|
||||
return Tile.fromBitmap(img);
|
||||
} else {
|
||||
var img = new BitmapData(1, 1);
|
||||
img.setPixel(0, 0, 0);
|
||||
return Tile.fromBitmap(img);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDifPath(rawElementPath:String) {
|
||||
if (StringTools.contains(rawElementPath, "$usermods")) {
|
||||
rawElementPath = rawElementPath.split("@").slice(1).map(x -> {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class ResourceLoader {
|
|||
fileSystem = mfileSystem;
|
||||
onLoadedFunc();
|
||||
}, scene2d);
|
||||
#if js
|
||||
loader = mloader;
|
||||
fileSystem = mfileSystem;
|
||||
var loadg = new h2d.Text(hxd.res.DefaultFont.get());
|
||||
|
|
@ -94,7 +95,10 @@ class ResourceLoader {
|
|||
fwd();
|
||||
});
|
||||
worker.run();
|
||||
// preloader.start();
|
||||
#end
|
||||
#if android
|
||||
preloader.start();
|
||||
#end
|
||||
#end
|
||||
#if (hl && !android)
|
||||
onLoadedFunc();
|
||||
|
|
@ -204,7 +208,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function load(path:String) {
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
if (!StringTools.startsWith(path, "data/"))
|
||||
path = "data/" + path;
|
||||
#end
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@ class ResourceLoaderWorker {
|
|||
}
|
||||
|
||||
public function addTaskParallel(task:(() -> Void)->Void) {
|
||||
#if (!android)
|
||||
paralleltasks.push(task);
|
||||
#else
|
||||
tasks.push(task);
|
||||
#end
|
||||
}
|
||||
|
||||
public function run() {
|
||||
|
|
@ -54,6 +58,10 @@ class ResourceLoaderWorker {
|
|||
}
|
||||
|
||||
public function loadFile(path:String) {
|
||||
#if (!android)
|
||||
paralleltasks.push(fwd -> ResourceLoader.load(path).entry.load(fwd));
|
||||
#else
|
||||
tasks.push(fwd -> ResourceLoader.load(path).entry.load(fwd));
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ class ManifestEntry extends FileEntry {
|
|||
private var bytes:Bytes;
|
||||
private var readPos:Int;
|
||||
private var loaded:Bool;
|
||||
private var loadPromise:js.lib.Promise<Void>;
|
||||
#end
|
||||
|
||||
public function new(fs:ManifestFileSystem, name:String, relPath:String, file:String, ?originalFile:String) {
|
||||
|
|
|
|||
|
|
@ -518,7 +518,11 @@ class PlayMissionGui extends GuiImage {
|
|||
pmDescriptionOther.text.text = descText2;
|
||||
pmDescriptionOther.text.loadImage = (name) -> goldBadge;
|
||||
|
||||
#if android
|
||||
pmPreview.bmp.tile = currentMission.getPreviewImageSync();
|
||||
#else
|
||||
pmPreview.bmp.tile = tmpprevtile;
|
||||
#end
|
||||
#if js
|
||||
switch (previewTimeoutHandle) {
|
||||
case None:
|
||||
|
|
@ -536,7 +540,7 @@ class PlayMissionGui extends GuiImage {
|
|||
}, 75));
|
||||
}
|
||||
#end
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
currentMission.getPreviewImage(prevImg -> {
|
||||
pmPreview.bmp.tile = prevImg;
|
||||
}); // Shit be sync
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue