mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 20:51:38 +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) {
|
if (!this.isWatching) {
|
||||||
this.replay.clear();
|
this.replay.clear();
|
||||||
} else
|
} else {
|
||||||
this.replay.rewind();
|
this.replay.rewind();
|
||||||
|
if (Util.isTouchDevice()) {
|
||||||
|
MarbleGame.instance.touchInput.hideControls(@:privateAccess this.playGui.playGuiCtrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.rewindManager.clear();
|
this.rewindManager.clear();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,7 @@ class Settings {
|
||||||
#end
|
#end
|
||||||
#if android
|
#if android
|
||||||
settingsDir = @:privateAccess String.fromUTF8(get_storage_path());
|
settingsDir = @:privateAccess String.fromUTF8(get_storage_path());
|
||||||
|
trace('Storage path is ${settingsDir}');
|
||||||
#end
|
#end
|
||||||
#if js
|
#if js
|
||||||
var localStorage = js.Browser.getLocalStorage();
|
var localStorage = js.Browser.getLocalStorage();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import hxd.fs.BytesFileSystem.BytesFileEntry;
|
||||||
import src.Marbleland;
|
import src.Marbleland;
|
||||||
import src.Mission;
|
import src.Mission;
|
||||||
import hxd.BitmapData;
|
import hxd.BitmapData;
|
||||||
|
|
@ -49,6 +50,7 @@ class ReplayCenterGui extends GuiImage {
|
||||||
var replayList = [];
|
var replayList = [];
|
||||||
sys.FileSystem.createDirectory(haxe.io.Path.join([Settings.settingsDir, "data", "replays"]));
|
sys.FileSystem.createDirectory(haxe.io.Path.join([Settings.settingsDir, "data", "replays"]));
|
||||||
var replayPath = 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);
|
var replayFiles = ResourceLoader.fileSystem.dir(replayPath);
|
||||||
for (replayFile in replayFiles) {
|
for (replayFile in replayFiles) {
|
||||||
if (replayFile.extension == "mbr") {
|
if (replayFile.extension == "mbr") {
|
||||||
|
|
@ -57,6 +59,23 @@ class ReplayCenterGui extends GuiImage {
|
||||||
replayList.push(replayF);
|
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));
|
var playButton = new GuiButton(loadButtonImages('data/ui/replay/play', true));
|
||||||
playButton.position = new Vector(323, 386);
|
playButton.position = new Vector(323, 386);
|
||||||
|
|
@ -68,6 +87,9 @@ class ReplayCenterGui extends GuiImage {
|
||||||
var repmis = repl.mission;
|
var repmis = repl.mission;
|
||||||
if (!StringTools.contains(repmis, "data/"))
|
if (!StringTools.contains(repmis, "data/"))
|
||||||
repmis = "data/" + repmis;
|
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);
|
var mi = repl.customId == 0 ? MissionList.missions.get(repmis) : Marbleland.missions.get(repl.customId);
|
||||||
if (mi.isClaMission) {
|
if (mi.isClaMission) {
|
||||||
mi.download(() -> {
|
mi.download(() -> {
|
||||||
|
|
@ -135,6 +157,9 @@ class ReplayCenterGui extends GuiImage {
|
||||||
var repmis = thisReplay.mission;
|
var repmis = thisReplay.mission;
|
||||||
if (!StringTools.contains(repmis, "data/"))
|
if (!StringTools.contains(repmis, "data/"))
|
||||||
repmis = "data/" + repmis;
|
repmis = "data/" + repmis;
|
||||||
|
#if android
|
||||||
|
repmis = StringTools.replace(repmis, "data/", "");
|
||||||
|
#end
|
||||||
if (MissionList.missions == null)
|
if (MissionList.missions == null)
|
||||||
MissionList.buildMissionList();
|
MissionList.buildMissionList();
|
||||||
var m = thisReplay.customId == 0 ? MissionList.missions.get(repmis) : Marbleland.missions.get(thisReplay.customId);
|
var m = thisReplay.customId == 0 ? MissionList.missions.get(repmis) : Marbleland.missions.get(thisReplay.customId);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue