Skip to content

Commit

Permalink
Update paths to use .modloader folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora-yx committed Feb 14, 2025
1 parent 0881f31 commit f1f1b26
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
4 changes: 2 additions & 2 deletions SA-Mod-Manager/Controls/SA2/GameConfig.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public GameConfig(ref object gameSettings, ref bool suppressEvent_)
InitializeComponent();
suppressEvent = suppressEvent_;
GameProfile = (GameSettings)gameSettings;
if (App.CurrentGame?.modDirectory != null && Directory.Exists(App.CurrentGame.modDirectory))
if (App.CurrentGame?.modDirectory != null && Directory.Exists(App.CurrentGame.modLoaderDirectory))
{
string pathDest = Path.Combine(App.CurrentGame.modDirectory, "Patches.json");
string pathDest = Path.Combine(App.CurrentGame.modLoaderDirectory, "Patches.json");
if (File.Exists(pathDest))
patchesPath = pathDest;
SetPatches();
Expand Down
4 changes: 2 additions & 2 deletions SA-Mod-Manager/Controls/SADX/GameConfig.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public GameConfig(ref object gameSettings, ref bool suppressEvent_)
suppressEvent = suppressEvent_;
GameProfile = (GameSettings)gameSettings;
UpdateAppLauncherBtn();
if (Directory.Exists(App.CurrentGame.modDirectory))
if (Directory.Exists(App.CurrentGame.modLoaderDirectory))
{

string pathDest = Path.Combine(App.CurrentGame.modDirectory, "Patches.json");
string pathDest = Path.Combine(App.CurrentGame.modLoaderDirectory, "Patches.json");
if (File.Exists(pathDest))
patchesPath = pathDest;

Expand Down
26 changes: 15 additions & 11 deletions SA-Mod-Manager/GamesInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public string modDirectory
}
}

public string modLoaderDirectory
{
get
{
return Path.Combine(gameDirectory, "mods", ".modloader");
}
}

/// <summary>
/// Profiles Directory where Manager, Game Profiles, and other settings are stored.
/// </summary>
Expand Down Expand Up @@ -123,9 +131,9 @@ public static async Task InstallDLL_Loader(Game game, bool isupdate = false)
return;


Util.CreateSafeDirectory(game.modDirectory);
Util.CreateSafeDirectory(game.modLoaderDirectory);

string loaderPath = Path.Combine(game.modDirectory, game.loader.name + ".dll");
string loaderPath = Path.Combine(game.modLoaderDirectory, game.loader.name + ".dll");

try
{
Expand Down Expand Up @@ -178,8 +186,8 @@ public static async Task InstallDLL_Loader(Game game, bool isupdate = false)
var offline = new OfflineInstall(game.loader.name);
offline.Show();
await Task.Delay(700);
Util.ExtractEmbedded7z(game.loader.name + ".7z", game.modDirectory);
bool success = File.Exists(Path.Combine(game.modDirectory, game.loader.name + ".dll"));
Util.ExtractEmbedded7z(game.loader.name + ".7z", game.modLoaderDirectory);
bool success = File.Exists(Path.Combine(game.modLoaderDirectory, game.loader.name + ".dll"));
offline.CheckSuccess(success);

await Task.Delay(500);
Expand Down Expand Up @@ -250,10 +258,10 @@ public static async Task<bool> UpdateLoader(Game game, string dlLink, bool updat
{
string fileName = game.loader.name + ".7z";
Uri uri = new(dlLink);
string pathFinal = Path.Combine(game.modDirectory, fileName);
string pathFinal = Path.Combine(game.modLoaderDirectory, fileName);
var loaderInfo = new List<DownloadInfo>
{
new(game.loader.name, fileName, game.modDirectory, uri, update ? DownloadDialog.DLType.Update : DownloadDialog.DLType.Install)
new(game.loader.name, fileName, game.modLoaderDirectory, uri, update ? DownloadDialog.DLType.Update : DownloadDialog.DLType.Install)
};

var dl = new DownloadDialog(loaderInfo);
Expand Down Expand Up @@ -293,11 +301,7 @@ public static async Task<bool> UpdateLoader(Game game, string dlLink, bool updat
dl.StartDL();
if (success)
{
List<string> excludeFile = ["extlib"];
await Util.Extract(pathFinal, game.modDirectory, true);
string ExtLibPath = Path.GetFullPath(Path.Combine(game.modDirectory, "extlib"));
if (Directory.Exists(ExtLibPath))
Directory.Move(ExtLibPath, App.extLibPath);
await Util.Extract(pathFinal, App.CurrentGame.modLoaderDirectory, true);

if (update)
File.Copy(App.CurrentGame.loader.loaderdllpath, App.CurrentGame.loader.dataDllPath, true);
Expand Down
2 changes: 1 addition & 1 deletion SA-Mod-Manager/Management/ProfileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static string ProfilesDirectory
if (App.CurrentGame.modDirectory == null)
return string.Empty;
else
return Path.Combine(App.CurrentGame.modDirectory, ".modloader", "profiles");
return Path.Combine(App.CurrentGame.modLoaderDirectory, "profiles");
}
}

Expand Down
Binary file modified SA-Mod-Manager/Resources/SA2ModLoader.7z
Binary file not shown.
Binary file modified SA-Mod-Manager/Resources/SADXModLoader.7z
Binary file not shown.
18 changes: 10 additions & 8 deletions SA-Mod-Manager/UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private async void MainWindowManager_Loaded(object sender, RoutedEventArgs e)
Load();
SetBindings(); //theme is set here

if (string.IsNullOrEmpty(App.CurrentGame?.modDirectory) == false)
if (Util.IsStringValid(App.CurrentGame?.modDirectory))
{
var oneClick = new OneClickInstall(updatePath);
await oneClick.UriInit();
Expand Down Expand Up @@ -1451,19 +1451,21 @@ private void UpdateManagerInfo()
{

//App.CurrentGame.modDirectory = Path.Combine(App.CurrentGame.gameDirectory, "mods");
App.CurrentGame.loader.mlverPath = Path.Combine(App.CurrentGame.modDirectory, App.CurrentGame.loader.mlverfile);
App.CurrentGame.loader.mlverPath = Path.Combine(App.CurrentGame.modLoaderDirectory, App.CurrentGame.loader.mlverfile);
App.CurrentGame.loader.IniPath = Path.Combine(App.CurrentGame.gameDirectory, Path.Combine("mods", App.CurrentGame.defaultIniProfile));
App.CurrentGame.loader.dataDllOriginPath = Path.Combine(App.CurrentGame.gameDirectory, App.CurrentGame.loader.originPath.defaultDataDllOriginPath);
App.CurrentGame.loader.loaderdllpath = Path.Combine(App.CurrentGame.gameDirectory, Path.Combine(App.CurrentGame.modDirectory, App.CurrentGame.loader.name + ".dll"));
App.CurrentGame.loader.loaderdllpath = Path.Combine(App.CurrentGame.modLoaderDirectory, App.CurrentGame.loader.name + ".dll");

var dllPath = App.CurrentGame.loader.loaderdllpath;
App.CurrentGame.loader.dataDllPath = Path.Combine(App.CurrentGame.gameDirectory, App.CurrentGame.loader.originPath.defaultDataDllPath);

updatePath = Path.GetFullPath(Path.Combine(App.CurrentGame.modDirectory, ".updates"));
codelstpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modDirectory, "Codes.lst"));
codexmlpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modDirectory, "Codes.xml"));
codedatpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modDirectory, "Codes.dat"));
patchdatpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modDirectory, "Patches.dat"));
codelstpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modLoaderDirectory, "Codes.lst"));
codexmlpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modLoaderDirectory, "Codes.xml"));
codedatpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modLoaderDirectory, "Codes.dat"));
patchdatpath = Path.GetFullPath(Path.Combine(App.CurrentGame.modLoaderDirectory, "Patches.dat"));

App.extLibPath = Path.Combine(App.CurrentGame.modDirectory, ".modloader", "extlib");
App.extLibPath = Path.Combine(App.CurrentGame.modLoaderDirectory, "extlib");

Controls.SADX.GameConfig.UpdateD3D8Paths();

Expand Down
2 changes: 1 addition & 1 deletion SA-Mod-Manager/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ private static void UpdatePathsForPortableMode()
if (App.isLinux && Directory.Exists(App.extLibPath) == false) //force portable mode for new users on Linux since it tends to work better.
{
App.ConfigFolder = Path.Combine(App.StartDirectory, "SAManager");
App.extLibPath = Path.Combine(App.CurrentGame.modDirectory, ".modloader", "extlib");
App.extLibPath = Path.Combine(App.CurrentGame.modLoaderDirectory, "extlib");
App.crashFolder = Path.Combine(App.ConfigFolder, "CrashDump");
}
}
Expand Down

0 comments on commit f1f1b26

Please sign in to comment.