mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-03-04 11:01:01 +00:00
android settings
This commit is contained in:
parent
6368ba56f8
commit
becf9186fa
1 changed files with 28 additions and 4 deletions
|
|
@ -157,11 +157,23 @@ class Settings {
|
|||
public static var isTouch:Option<Bool> = Option.None;
|
||||
|
||||
#if hl
|
||||
#if MACOS_BUNDLE
|
||||
#if MACOS_BUNDLE
|
||||
public static var settingsDir = Path.join([Sys.getEnv("HOME"), "Library", "Application Support", "MBHaxe-MBP"]);
|
||||
#else
|
||||
#else
|
||||
public static var settingsDir = ".";
|
||||
#end
|
||||
#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() {
|
||||
|
|
@ -260,6 +272,9 @@ class Settings {
|
|||
}
|
||||
File.saveContent(Path.join([settingsDir, "settings.json"]), json);
|
||||
#end
|
||||
#if android
|
||||
saveAndroid('settings', json);
|
||||
#end
|
||||
#if js
|
||||
var localStorage = js.Browser.getLocalStorage();
|
||||
if (localStorage != null) {
|
||||
|
|
@ -279,11 +294,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