Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XDG support #29

Merged
merged 1 commit into from Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Celeste.Mod.mm/Mod/Everest/Everest.Content.cs
Expand Up @@ -192,7 +192,7 @@ public static class Content {
Celeste.Instance.Content = new EverestContentManager(Celeste.Instance.Content);

Directory.CreateDirectory(PathContentOrig = Path.Combine(PathGame, Celeste.Instance.Content.RootDirectory));
Directory.CreateDirectory(PathDUMP = Path.Combine(PathGame, "ModDUMP"));
Directory.CreateDirectory(PathDUMP = Path.Combine(PathEverest, "ModDUMP"));

if (_DumpAll)
DumpAll();
Expand All @@ -203,7 +203,7 @@ public static class Content {
Crawl(new AssemblyModContent(typeof(Everest).Assembly) {
Name = "Everest"
});
Crawl(new MapBinsInModsModContent(Path.Combine(PathGame, "Mods")));
Crawl(new MapBinsInModsModContent(Path.Combine(PathEverest, "Mods")));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Celeste.Mod.mm/Mod/Everest/Everest.Loader.cs
Expand Up @@ -37,7 +37,7 @@ public static class Loader {
internal static int DelayedLock;

internal static void LoadAuto() {
Directory.CreateDirectory(PathMods = Path.Combine(PathGame, "Mods"));
Directory.CreateDirectory(PathMods = Path.Combine(PathEverest, "Mods"));
Directory.CreateDirectory(PathCache = Path.Combine(PathMods, "Cache"));

PathBlacklist = Path.Combine(PathMods, "blacklist.txt");
Expand Down
19 changes: 18 additions & 1 deletion Celeste.Mod.mm/Mod/Everest/Everest.cs
Expand Up @@ -80,6 +80,14 @@ public static partial class Everest {
/// The path to the Everest /ModSettings directory.
/// </summary>
public static string PathSettings { get; internal set; }
/// <summary>
/// Whether XDG paths should be used.
/// </summary>
public static bool XDGPaths { get; internal set; }
/// <summary>
/// Path to Everest base location. Defaults to the game directory.
/// </summary>
public static string PathEverest { get; internal set; }

private static bool _SavingSettings;

Expand Down Expand Up @@ -146,7 +154,16 @@ public static partial class Everest {
}

PathGame = Path.GetDirectoryName(typeof(Celeste).Assembly.Location);
PathSettings = Path.Combine(PathGame, "ModSettings");
if (!File.Exists(Path.Combine(PathGame, "EverestXDGFlag"))) {
XDGPaths = false;
PathEverest = PathGame;
} else {
XDGPaths = true;
var dataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Directory.CreateDirectory(PathEverest = Path.Combine(dataDir, "Everest"));
Directory.CreateDirectory(Path.Combine(dataDir, "Everest", "Mods")); // Make sure it exists before content gets initialized
}
PathSettings = Path.Combine(PathEverest, "ModSettings");
Directory.CreateDirectory(PathSettings);

// Before even initializing anything else, make sure to prepare any static flags.
Expand Down
14 changes: 3 additions & 11 deletions default.nix
@@ -1,13 +1,6 @@
{ pkgs ? import <nixpkgs> {}, fetchNuGet ? pkgs.fetchNuGet, buildDotnetPackage ? pkgs.buildDotnetPackage }:

let
HookedMethod = fetchNuGet {
baseName = "HookedMethod";
version = "0.3.3-beta";
sha256 = "5abc349e55d57777fed6fc5d65cda4cc97aa8cb1dc87927dea7d4182f3fa57df";
outputFiles = [ "*" ];
};

Cecil = fetchNuGet {
baseName = "Mono.Cecil";
version = "0.10.0";
Expand All @@ -18,7 +11,7 @@ let
ValueTuple = fetchNuGet {
baseName = "System.ValueTuple";
version = "4.4.0";
sha256 = "0442bk4nk7ncd37qn1p5nbz297093vfcz5p0xl97q1gvcb7fyfsf";
sha256 = "1wydfgszs00yxga57sam66vzv9fshk2pw7gim57saplsnkfliaif";
outputFiles = ["*"];
};

Expand All @@ -30,7 +23,7 @@ in buildDotnetPackage rec {
src = ./.;

xBuildFiles = [ "Celeste.Mod.mm/Celeste.Mod.mm.csproj" "MiniInstaller/MiniInstaller.csproj" ];
outputFiles = [ "Celeste.Mod.mm/bin/Release/*" /* vim syntax bug workaround */ "MiniInstaller/bin/Release/*" /* vim syntax bug workaround */ ];
outputFiles = [ "Celeste.Mod.mm/bin/Release/*" "MiniInstaller/bin/Release/*" ];

patchPhase = ''
# $(SolutionDir) does not work for some reason
Expand All @@ -40,8 +33,7 @@ in buildDotnetPackage rec {

preBuild = ''
# Fake nuget restore, not very elegant but it works.
mkdir -p packages
ln -sn ${HookedMethod}/lib/dotnet/HookedMethod packages/HookedMethod.${HookedMethod.version}
mkdir -p packages
ln -sn ${Cecil}/lib/dotnet/Mono.Cecil packages/Mono.Cecil.${Cecil.version}
ln -sn ${ValueTuple}/lib/dotnet/System.ValueTuple packages/System.ValueTuple.${ValueTuple.version}
'';
Expand Down