mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-03-06 20:11:10 +00:00
Use macOS Dirs
This commit is contained in:
parent
d86af0b31a
commit
fb32db9685
2 changed files with 12 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ import src.ResourceLoaderWorker;
|
|||
|
||||
class ResourceLoader {
|
||||
#if (hl && !android)
|
||||
public static var fileSystem:FileSystem = new LocalFileSystem(".", null);
|
||||
public static var fileSystem:FileSystem = new LocalFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "Resources"])), null);
|
||||
#end
|
||||
#if (js || android)
|
||||
public static var fileSystem:FileSystem = null;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import hxd.Window;
|
|||
import haxe.DynamicAccess;
|
||||
#if hl
|
||||
import sys.io.File;
|
||||
import sys.FileSystem;
|
||||
import haxe.io.Path;
|
||||
#end
|
||||
import src.ResourceLoader;
|
||||
import haxe.Json;
|
||||
|
|
@ -114,6 +116,8 @@ class Settings {
|
|||
|
||||
public static var isTouch:Option<Bool> = Option.None;
|
||||
|
||||
public static var settingsDir = Path.join([Sys.getEnv("HOME"), "Library", "Application Support", "MBHaxe-MBG"]);
|
||||
|
||||
public static function applySettings() {
|
||||
#if hl
|
||||
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
|
||||
|
|
@ -171,7 +175,10 @@ class Settings {
|
|||
#end
|
||||
var json = Json.stringify(outputData);
|
||||
#if (hl && !android)
|
||||
File.saveContent("settings.json", json);
|
||||
if (!FileSystem.exists(settingsDir)) {
|
||||
FileSystem.createDirectory(settingsDir);
|
||||
}
|
||||
File.saveContent(Path.join([settingsDir, "settings.json"]), json);
|
||||
#end
|
||||
#if js
|
||||
var localStorage = js.Browser.getLocalStorage();
|
||||
|
|
@ -184,7 +191,7 @@ class Settings {
|
|||
public static function load() {
|
||||
var settingsExists = false;
|
||||
#if hl
|
||||
settingsExists = ResourceLoader.fileSystem.exists("settings.json");
|
||||
settingsExists = FileSystem.exists(Path.join([settingsDir, "settings.json"]));
|
||||
#end
|
||||
#if js
|
||||
var localStorage = js.Browser.getLocalStorage();
|
||||
|
|
@ -195,7 +202,8 @@ class Settings {
|
|||
|
||||
if (settingsExists) {
|
||||
#if hl
|
||||
var json = Json.parse(ResourceLoader.fileSystem.get("settings.json").getText());
|
||||
var json =
|
||||
Json.parse(File.getContent(Path.join([settingsDir, "settings.json"])));
|
||||
#end
|
||||
#if js
|
||||
var json = Json.parse(localStorage.getItem("MBHaxeSettings"));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue