Skip to content

Commit 799fa4f

Browse files
committed
Change default save path on mac/linux/windows
1 parent 6e74824 commit 799fa4f

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/Murder/Game.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,6 @@ private void SetTargetFps(int fps, float fixedUpdateFactor)
876876
/// </summary>
877877
protected virtual void ExitGame()
878878
{
879-
_game?.OnExit();
880-
881-
Microsoft.Xna.Framework.Media.MediaPlayer.Stop();
882879
base.Exit();
883880
}
884881

@@ -895,6 +892,7 @@ protected virtual void OnClose(object? sender, EventArgs e)
895892
{
896893
// right before the game itself closes.
897894
Haptics.ClearAll();
895+
_game?.OnClose();
898896
}
899897
}
900898
}

src/Murder/IMurderGame.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void OnSceneTransition() { }
5454
/// <summary>
5555
/// Called once the game exits.
5656
/// </summary>
57-
public void OnExit() { }
57+
public void OnClose() { }
5858

5959
/// <summary>
6060
/// Creates save data for the game.

src/Murder/Utilities/Serialization/FileHelper.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,32 @@ public static string GetSaveBasePath(string gameName)
7979
{
8080
_osVersion ??= SDL2.SDL.SDL_GetPlatform();
8181

82-
if (_osVersion.Equals("Windows") || _osVersion.Equals("Mac OS X") ||
83-
_osVersion.Equals("Linux") || _osVersion.Equals("FreeBSD") ||
84-
_osVersion.Equals("OpenBSD") || _osVersion.Equals("NetBSD"))
82+
if (_osVersion.Equals("Windows"))
8583
{
8684
return Path.Join(Environment.GetFolderPath(
8785
Environment.SpecialFolder.LocalApplicationData), gameName);
8886
}
8987

88+
if (_osVersion.Equals("Mac OS X"))
89+
{
90+
return Path.Join(Environment.GetFolderPath(
91+
Environment.SpecialFolder.ApplicationData), gameName);
92+
}
93+
94+
if (_osVersion.Equals("Linux") || _osVersion.Equals("FreeBSD") ||
95+
_osVersion.Equals("OpenBSD") || _osVersion.Equals("NetBSD"))
96+
{
97+
if (Environment.GetEnvironmentVariable("XDG_DATA_HOME") is string dataPath)
98+
{
99+
return Path.Join(dataPath, gameName);
100+
}
101+
102+
if (Environment.GetEnvironmentVariable("HOME") is string homePath)
103+
{
104+
return Path.Join(homePath, ".local", "share", gameName);
105+
}
106+
}
107+
90108
return SDL2.SDL.SDL_GetPrefPath(null, gameName);
91109
}
92110

0 commit comments

Comments
 (0)