mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 20:51:38 +00:00
Use macOS directories
This commit is contained in:
parent
a1e67dd7e9
commit
deee285e71
2 changed files with 13 additions and 4 deletions
|
|
@ -22,7 +22,7 @@ import src.Settings;
|
||||||
|
|
||||||
class ResourceLoader {
|
class ResourceLoader {
|
||||||
#if (hl && !android)
|
#if (hl && !android)
|
||||||
public static var fileSystem:FileSystem = new TorqueFileSystem(".", null);
|
public static var fileSystem:FileSystem = new TorqueFileSystem(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;
|
||||||
|
|
@ -154,6 +156,9 @@ 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-MBP"]);
|
||||||
|
|
||||||
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);
|
||||||
|
|
@ -245,7 +250,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();
|
||||||
|
|
@ -258,7 +266,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();
|
||||||
|
|
@ -269,7 +277,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