mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
make replay work in android
This commit is contained in:
parent
913f3d475d
commit
a8103f8a36
3 changed files with 31 additions and 1 deletions
|
|
@ -454,8 +454,12 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
if (!this.isWatching) {
|
||||
this.replay.clear();
|
||||
} else
|
||||
} else {
|
||||
this.replay.rewind();
|
||||
if (Util.isTouchDevice()) {
|
||||
MarbleGame.instance.touchInput.hideControls(@:privateAccess this.playGui.playGuiCtrl);
|
||||
}
|
||||
}
|
||||
|
||||
this.rewindManager.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -336,6 +336,7 @@ class Settings {
|
|||
#end
|
||||
#if android
|
||||
settingsDir = @:privateAccess String.fromUTF8(get_storage_path());
|
||||
trace('Storage path is ${settingsDir}');
|
||||
#end
|
||||
#if js
|
||||
var localStorage = js.Browser.getLocalStorage();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package gui;
|
||||
|
||||
import hxd.fs.BytesFileSystem.BytesFileEntry;
|
||||
import src.Marbleland;
|
||||
import src.Mission;
|
||||
import hxd.BitmapData;
|
||||
|
|
@ -49,6 +50,7 @@ class ReplayCenterGui extends GuiImage {
|
|||
var replayList = [];
|
||||
sys.FileSystem.createDirectory(haxe.io.Path.join([Settings.settingsDir, "data", "replays"]));
|
||||
var replayPath = haxe.io.Path.join([Settings.settingsDir, "data", "replays",]);
|
||||
#if (sys && !android)
|
||||
var replayFiles = ResourceLoader.fileSystem.dir(replayPath);
|
||||
for (replayFile in replayFiles) {
|
||||
if (replayFile.extension == "mbr") {
|
||||
|
|
@ -57,6 +59,23 @@ class ReplayCenterGui extends GuiImage {
|
|||
replayList.push(replayF);
|
||||
}
|
||||
}
|
||||
#end
|
||||
// #if android
|
||||
var replayFiles = sys.FileSystem.readDirectory(replayPath);
|
||||
for (replayFile in replayFiles) {
|
||||
var extension = haxe.io.Path.extension(replayFile);
|
||||
trace('Replay file: ${replayFile}}');
|
||||
if (extension == "mbr") {
|
||||
var replayF = new Replay(null);
|
||||
var fullpath = haxe.io.Path.join([Settings.settingsDir, "data", "replays", replayFile]);
|
||||
trace('Replay file path: ${fullpath}}');
|
||||
var replayBytes = sys.io.File.getBytes(fullpath);
|
||||
var fe = new BytesFileEntry(fullpath, replayBytes);
|
||||
if (replayF.readHeader(replayBytes, fe))
|
||||
replayList.push(replayF);
|
||||
}
|
||||
}
|
||||
// #end
|
||||
|
||||
var playButton = new GuiButton(loadButtonImages('data/ui/replay/play', true));
|
||||
playButton.position = new Vector(323, 386);
|
||||
|
|
@ -68,6 +87,9 @@ class ReplayCenterGui extends GuiImage {
|
|||
var repmis = repl.mission;
|
||||
if (!StringTools.contains(repmis, "data/"))
|
||||
repmis = "data/" + repmis;
|
||||
#if android
|
||||
repmis = StringTools.replace(repmis, "data/", "");
|
||||
#end
|
||||
var mi = repl.customId == 0 ? MissionList.missions.get(repmis) : Marbleland.missions.get(repl.customId);
|
||||
if (mi.isClaMission) {
|
||||
mi.download(() -> {
|
||||
|
|
@ -135,6 +157,9 @@ class ReplayCenterGui extends GuiImage {
|
|||
var repmis = thisReplay.mission;
|
||||
if (!StringTools.contains(repmis, "data/"))
|
||||
repmis = "data/" + repmis;
|
||||
#if android
|
||||
repmis = StringTools.replace(repmis, "data/", "");
|
||||
#end
|
||||
if (MissionList.missions == null)
|
||||
MissionList.buildMissionList();
|
||||
var m = thisReplay.customId == 0 ? MissionList.missions.get(repmis) : Marbleland.missions.get(thisReplay.customId);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue