mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
android settings
This commit is contained in:
parent
b1888a010b
commit
61ebeace19
1 changed files with 26 additions and 2 deletions
|
|
@ -194,6 +194,19 @@ class Settings {
|
|||
public static var settingsDir = ".";
|
||||
#end
|
||||
#end
|
||||
#if android
|
||||
@:hlNative("Java_io_heaps_android_HeapsActivity")
|
||||
static function saveAndroid(name:String, data:String) {}
|
||||
#end
|
||||
|
||||
#if android
|
||||
@:hlNative("Java_io_heaps_android_HeapsActivity")
|
||||
static function loadAndroid(name:String):hl.Bytes {
|
||||
var i = 4;
|
||||
return hl.Bytes.fromValue("null", i);
|
||||
}
|
||||
#end
|
||||
|
||||
public static function applySettings() {
|
||||
#if hl
|
||||
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
|
||||
|
|
@ -290,7 +303,9 @@ class Settings {
|
|||
FileSystem.createDirectory(settingsDir);
|
||||
}
|
||||
File.saveContent(Path.join([settingsDir, "settings.json"]), json);
|
||||
Console.log("Saved settings to " + Path.join([settingsDir, "settings.json"]));
|
||||
#end
|
||||
#if android
|
||||
saveAndroid('settings', json);
|
||||
#end
|
||||
#if js
|
||||
var localStorage = js.Browser.getLocalStorage();
|
||||
|
|
@ -312,11 +327,20 @@ class Settings {
|
|||
settingsExists = localStorage.getItem("MBHaxeSettings") != null;
|
||||
}
|
||||
#end
|
||||
#if android
|
||||
settingsExists = true;
|
||||
var rawJson = @:privateAccess String.fromUTF8(loadAndroid('settings'));
|
||||
if (rawJson == null || rawJson == "")
|
||||
settingsExists = false;
|
||||
#end
|
||||
|
||||
if (settingsExists) {
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
var json = Json.parse(File.getContent(Path.join([settingsDir, "settings.json"])));
|
||||
#end
|
||||
#if android
|
||||
var json = Json.parse(rawJson);
|
||||
#end
|
||||
#if js
|
||||
var json = Json.parse(localStorage.getItem("MBHaxeSettings"));
|
||||
#end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue