mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 20:51:38 +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 {
|
class ResourceLoader {
|
||||||
#if (hl && !android)
|
#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
|
#end
|
||||||
#if (js || android)
|
#if (js || android)
|
||||||
public static var fileSystem:FileSystem = null;
|
public static var fileSystem:FileSystem = null;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import hxd.Window;
|
||||||
import haxe.DynamicAccess;
|
import haxe.DynamicAccess;
|
||||||
#if hl
|
#if hl
|
||||||
import sys.io.File;
|
import sys.io.File;
|
||||||
|
import sys.FileSystem;
|
||||||
|
import haxe.io.Path;
|
||||||
#end
|
#end
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
import haxe.Json;
|
import haxe.Json;
|
||||||
|
|
@ -114,6 +116,8 @@ class Settings {
|
||||||
|
|
||||||
public static var isTouch:Option<Bool> = Option.None;
|
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() {
|
public static function applySettings() {
|
||||||
#if hl
|
#if hl
|
||||||
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
|
Window.getInstance().resize(optionsSettings.screenWidth, optionsSettings.screenHeight);
|
||||||
|
|
@ -171,7 +175,10 @@ class Settings {
|
||||||
#end
|
#end
|
||||||
var json = Json.stringify(outputData);
|
var json = Json.stringify(outputData);
|
||||||
#if (hl && !android)
|
#if (hl && !android)
|
||||||
File.saveContent("settings.json", json);
|
if (!FileSystem.exists(settingsDir)) {
|
||||||
|
FileSystem.createDirectory(settingsDir);
|
||||||
|
}
|
||||||
|
File.saveContent(Path.join([settingsDir, "settings.json"]), json);
|
||||||
#end
|
#end
|
||||||
#if js
|
#if js
|
||||||
var localStorage = js.Browser.getLocalStorage();
|
var localStorage = js.Browser.getLocalStorage();
|
||||||
|
|
@ -184,7 +191,7 @@ class Settings {
|
||||||
public static function load() {
|
public static function load() {
|
||||||
var settingsExists = false;
|
var settingsExists = false;
|
||||||
#if hl
|
#if hl
|
||||||
settingsExists = ResourceLoader.fileSystem.exists("settings.json");
|
settingsExists = FileSystem.exists(Path.join([settingsDir, "settings.json"]));
|
||||||
#end
|
#end
|
||||||
#if js
|
#if js
|
||||||
var localStorage = js.Browser.getLocalStorage();
|
var localStorage = js.Browser.getLocalStorage();
|
||||||
|
|
@ -195,7 +202,8 @@ class Settings {
|
||||||
|
|
||||||
if (settingsExists) {
|
if (settingsExists) {
|
||||||
#if hl
|
#if hl
|
||||||
var json = Json.parse(ResourceLoader.fileSystem.get("settings.json").getText());
|
var json =
|
||||||
|
Json.parse(File.getContent(Path.join([settingsDir, "settings.json"])));
|
||||||
#end
|
#end
|
||||||
#if js
|
#if js
|
||||||
var json = Json.parse(localStorage.getItem("MBHaxeSettings"));
|
var json = Json.parse(localStorage.getItem("MBHaxeSettings"));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue