Fix custom saves on Linux

pull/9/head
Miepee 4 years ago
parent 2ade37c70a
commit 5063a64d18

@ -32,32 +32,44 @@ public partial class ModPacker : Form
private void CustomSaveDataButton_Click(object sender, EventArgs e) private void CustomSaveDataButton_Click(object sender, EventArgs e)
{ {
bool wasSuccessful = false; bool wasSuccessful = false;
// TODO: make sure that the validation works on other platforms too
var winSaveRegex = new Regex(@"C:\\Users\\.*\\AppData\\Local\\"); //this is to ensure, that the save directory is valid. so far, this is only important for windows var winSaveRegex = new Regex(@"C:\\Users\\.*\\AppData\\Local\\"); //this is to ensure, that the save directory is valid. so far, this is only important for windows
var linSaveRegex = new Regex(@"$/\.config"); // Linux users can set their home directory wherever they want to, for each individual application var linSaveRegex = new Regex($@"{Environment.GetEnvironmentVariable("HOME")}/\.config/.*"); // GMS hardcodes save into ~/.config on linux
//TODO: var macSaveRegex
var dialog = new SelectFolderDialog(); //TODO: var macSaveRegex = ????
// TODO: .config on linux
dialog.Directory = Environment.GetEnvironmentVariable("LocalAppData"); var dialog = new SelectFolderDialog();
string initialDir = "";
if (OS.IsWindows)
initialDir = Environment.GetEnvironmentVariable("LocalAppData");
else if (OS.IsLinux)
initialDir = Environment.GetEnvironmentVariable("HOME") + "/.config";
else if (OS.IsMac)
initialDir = ""; //TODO!
dialog.Directory = initialDir;
while (!wasSuccessful) while (!wasSuccessful)
{ {
if (dialog.ShowDialog(this) == DialogResult.Ok) if (dialog.ShowDialog(this) == DialogResult.Ok)
{ {
Match match; Match match = Match.Empty;
if (OS.IsWindows)
match = winSaveRegex.Match(dialog.Directory); match = winSaveRegex.Match(dialog.Directory);
else if (OS.IsLinux)
match = linSaveRegex.Match(dialog.Directory);
else if (OS.IsMac)
match = winSaveRegex.Match(dialog.Directory); //TODO!
if (match.Success == false) if (match.Success == false)
{ MessageBox.Show("Invalid Save Directory! Please consult the GameMaker: Studio 1.4 documentation for valid save directories!");
// TODO: different error messages
MessageBox.Show("Invalid Save Directory! Please choose one in %LocalAppData%");
}
else else
{ {
//TODO: needs to be OS specific //TODO: figure out mac
wasSuccessful = true; wasSuccessful = true;
saveFilePath = dialog.Directory.Replace(match.Value, "%localappdata%/"); saveFilePath = dialog.Directory.Replace(match.Value, "%localappdata%/");
if (OS.IsWindows)
{
saveFilePath = saveFilePath.Replace("\\", "/"); // if we don't do this, custom save locations are going to fail on Linux saveFilePath = saveFilePath.Replace("\\", "/"); // if we don't do this, custom save locations are going to fail on Linux
}
// if someone has a custom save path inside of am2r and creates these whithin game maker, they will always be lower case // if someone has a custom save path inside of am2r and creates these whithin game maker, they will always be lower case
// we need to adjust them here to lowercase as well, as otherwise launcher gets problems on nix systems // we need to adjust them here to lowercase as well, as otherwise launcher gets problems on nix systems
const string vanillaPrefix = "%localappdata%/AM2R/"; const string vanillaPrefix = "%localappdata%/AM2R/";

@ -19,8 +19,7 @@ public static class Core
public static readonly string Version = "2.0.3"; public static readonly string Version = "2.0.3";
private const string originalMD5 = "f2b84fe5ba64cb64e284be1066ca08ee"; private const string originalMD5 = "f2b84fe5ba64cb64e284be1066ca08ee";
private static readonly string[] DATAFILES_BLACKLIST = { "data.win", "AM2R.exe", "D3DX9_43.dll", "game.unx", "game.ios" }; private static readonly string[] DATAFILES_BLACKLIST = { "data.win", "AM2R.exe", "D3DX9_43.dll", "game.unx", "game.ios" };
// todo: dont do this, cwd is unreliable private static readonly string localPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
private static readonly string localPath = Directory.GetCurrentDirectory();
// TODO: go over thhis and clean // TODO: go over thhis and clean
public static (bool, string) CreateModPack(ModProfileXML profile, string originalZipPath, string modZipPath, string apkPath, string output) public static (bool, string) CreateModPack(ModProfileXML profile, string originalZipPath, string modZipPath, string apkPath, string output)

Loading…
Cancel
Save