Fix lib bug, check game exe more, preview support
Fixed the game folder method returning the library file Checking the game's exe when starting Added support for the preview branch of the game Added support for preview versions of mods
This commit is contained in:
parent
cbd6170757
commit
b4d64c50d0
5 changed files with 54 additions and 18 deletions
|
@ -54,7 +54,7 @@ If you encounter an issue while the game is patched, report it to us. If you thi
|
||||||
modlist.Items.Clear();
|
modlist.Items.Clear();
|
||||||
UpdateButton(installbtn, false);
|
UpdateButton(installbtn, false);
|
||||||
modinfobox.Text = defaultInfo;
|
modinfobox.Text = defaultInfo;
|
||||||
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath))
|
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath) || GetExe() == null)
|
||||||
{
|
{
|
||||||
Settings.Default.GamePath = GetGameFolder();
|
Settings.Default.GamePath = GetGameFolder();
|
||||||
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath))
|
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath))
|
||||||
|
@ -114,9 +114,9 @@ If you encounter an issue while the game is patched, report it to us. If you thi
|
||||||
if(up)
|
if(up)
|
||||||
{
|
{
|
||||||
modinfobox.Select(0, "New version available!".Length);
|
modinfobox.Select(0, "New version available!".Length);
|
||||||
modinfobox.SelectionColor = Color.Aqua;
|
//modinfobox.SelectionColor = Color.Aqua;
|
||||||
modinfobox.DeselectAll();
|
//modinfobox.DeselectAll();
|
||||||
modinfobox.SelectionColor = modinfobox.ForeColor;
|
//modinfobox.SelectionColor = modinfobox.ForeColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -170,7 +170,7 @@ If you encounter an issue while the game is patched, report it to us. If you thi
|
||||||
{
|
{
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
{
|
{
|
||||||
Process.Start("explorer.exe", "/select,"+Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"Low\Freejam\Gamecraft\Player.log");
|
Process.Start("explorer.exe", $@"/select,{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}Low\Freejam\{GetExe().Replace(".exe", "")}\Player.log");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace GCMM
|
||||||
public async Task InstallMod(ModInfo mod)
|
public async Task InstallMod(ModInfo mod)
|
||||||
{
|
{
|
||||||
if (mod.DownloadURL == null) return;
|
if (mod.DownloadURL == null) return;
|
||||||
if (!File.Exists(GamePath(@"\Gamecraft.exe")))
|
if (GetExe() == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Gamecraft not found. Set the correct path in Settings.");
|
MessageBox.Show("Gamecraft not found. Set the correct path in Settings.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace GCMM
|
||||||
|
|
||||||
public async void GetAvailableMods()
|
public async void GetAvailableMods()
|
||||||
{
|
{
|
||||||
|
bool preview = GetExe()?.Contains("Preview") ?? false;
|
||||||
using (var client = GetClient())
|
using (var client = GetClient())
|
||||||
{
|
{
|
||||||
string str = await client.DownloadStringTaskAsync("https://exmods.org/mods/modlist.tsv");
|
string str = await client.DownloadStringTaskAsync("https://exmods.org/mods/modlist.tsv");
|
||||||
|
@ -48,21 +49,39 @@ namespace GCMM
|
||||||
Author = sp[0].Trim(),
|
Author = sp[0].Trim(),
|
||||||
Name = sp[1].Trim()
|
Name = sp[1].Trim()
|
||||||
};
|
};
|
||||||
if (await FetchModInfo(mod)) //If it's actually a mod
|
if (await FetchModInfo(mod, preview)) //If it's actually a mod
|
||||||
AddUpdateModInList(mod);
|
AddUpdateModInList(mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> FetchModInfo(ModInfo mod)
|
public async Task<bool> FetchModInfo(ModInfo mod, bool preview)
|
||||||
{
|
{
|
||||||
string repoURL = "/api/v1/repos/" + mod.Author + "/" + mod.Name + "/releases";
|
string repoURL = "/api/v1/repos/" + mod.Author + "/" + mod.Name + "/releases";
|
||||||
using (var client = GetClient())
|
using (var client = GetClient())
|
||||||
{
|
{
|
||||||
var arr = JArray.Parse(await client.DownloadStringTaskAsync(repoURL));
|
var arr = JArray.Parse(await client.DownloadStringTaskAsync(repoURL));
|
||||||
var release = arr.FirstOrDefault(rel => !(bool)rel["prerelease"] && !(bool)rel["draft"]);
|
var release = arr.FirstOrDefault(rel =>
|
||||||
|
{
|
||||||
|
if ((bool) rel["prerelease"] || (bool) rel["draft"])
|
||||||
|
return false;
|
||||||
|
var vs = rel["tag_name"].ToString();
|
||||||
|
int ind = vs.IndexOf('-');
|
||||||
|
if (ind != -1)
|
||||||
|
{
|
||||||
|
if (vs.Substring(ind + 1).Equals("preview", StringComparison.InvariantCultureIgnoreCase)
|
||||||
|
&& !preview)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
if (release == null)
|
if (release == null)
|
||||||
return false;
|
return false;
|
||||||
|
var verstr = release["tag_name"].ToString().Replace("v", "");
|
||||||
|
int index = verstr.IndexOf('-');
|
||||||
|
if (index != -1)
|
||||||
|
verstr = verstr.Substring(0, index);
|
||||||
|
|
||||||
JToken asset;
|
JToken asset;
|
||||||
if (release["assets"].Count() == 1)
|
if (release["assets"].Count() == 1)
|
||||||
asset = release["assets"].First;
|
asset = release["assets"].First;
|
||||||
|
@ -72,9 +91,11 @@ namespace GCMM
|
||||||
string name = token["name"].ToString();
|
string name = token["name"].ToString();
|
||||||
return name == mod.Name + ".dll" || name == mod.Name + ".zip";
|
return name == mod.Name + ".dll" || name == mod.Name + ".zip";
|
||||||
});
|
});
|
||||||
|
|
||||||
mod.DownloadURL = asset?["browser_download_url"]?.ToString();
|
mod.DownloadURL = asset?["browser_download_url"]?.ToString();
|
||||||
mod.LastUpdated = (DateTime)release["published_at"];
|
mod.LastUpdated = (DateTime)release["published_at"];
|
||||||
var ver = release["tag_name"].ToString().Replace("v", "").Split('.').Select(str => int.Parse(str)).ToArray();
|
|
||||||
|
var ver = verstr.Split('.').Select(str => int.Parse(str)).ToArray();
|
||||||
int getver(byte i) => ver.Length > i ? ver[i] : 0; //By default it sets values not present to -1, but we need them to be 0
|
int getver(byte i) => ver.Length > i ? ver[i] : 0; //By default it sets values not present to -1, but we need them to be 0
|
||||||
mod.LatestVersion = new Version(getver(0), getver(1), getver(2), getver(3));
|
mod.LatestVersion = new Version(getver(0), getver(1), getver(2), getver(3));
|
||||||
mod.UpdateDetails = release["name"] + "\n\n" + release["body"].ToString();
|
mod.UpdateDetails = release["name"] + "\n\n" + release["body"].ToString();
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace GCMM
|
||||||
}
|
}
|
||||||
if (!status.Value ^ unpatched.Checked)
|
if (!status.Value ^ unpatched.Checked)
|
||||||
{ //TODO: Wine
|
{ //TODO: Wine
|
||||||
var psi = new ProcessStartInfo(GamePath(@"\IPA.exe"), "Gamecraft.exe "
|
var psi = new ProcessStartInfo(GamePath(@"\IPA.exe"), GetExe() + " "
|
||||||
+ (unpatched.Checked ? "--revert " : "") + "--nowait")
|
+ (unpatched.Checked ? "--revert " : "") + "--nowait")
|
||||||
{
|
{
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
|
|
|
@ -46,18 +46,18 @@ namespace GCMM
|
||||||
continue;
|
continue;
|
||||||
string library = match.Groups[1].Value.Replace("\\\\", "\\");
|
string library = match.Groups[1].Value.Replace("\\\\", "\\");
|
||||||
library += @"\steamapps\common\";
|
library += @"\steamapps\common\";
|
||||||
if (File.Exists(library + @"Gamecraft\Gamecraft.exe"))
|
if (GetExe(library + "Gamecraft") != null)
|
||||||
return library + "Gamecraft";
|
return library + "Gamecraft";
|
||||||
if (File.Exists(library + @"RobocraftX\Gamecraft.exe"))
|
if (GetExe(library + "RobocraftX") != null)
|
||||||
return library + "RobocraftX";
|
return library + "RobocraftX";
|
||||||
}
|
}
|
||||||
return libs;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SelectGameFolder()
|
public string SelectGameFolder()
|
||||||
{
|
{
|
||||||
var ofd = new OpenFileDialog();
|
var ofd = new OpenFileDialog();
|
||||||
ofd.Filter = "Gamecraft executable|Gamecraft.exe";
|
ofd.Filter = "Gamecraft executable|Gamecraft.exe|Gamecraft Preview executable|GamecraftPreview.exe";
|
||||||
ofd.Title = "Game location";
|
ofd.Title = "Game location";
|
||||||
ofd.InitialDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\"; //TODO
|
ofd.InitialDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\"; //TODO
|
||||||
ofd.CheckFileExists = true;
|
ofd.CheckFileExists = true;
|
||||||
|
@ -125,9 +125,24 @@ namespace GCMM
|
||||||
modlist_SelectedIndexChanged(modlist, null);
|
modlist_SelectedIndexChanged(modlist, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GamePath(string path)
|
/// <summary>
|
||||||
|
/// Path must start with \
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="gamepath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GamePath(string path, string gamepath = null)
|
||||||
{
|
{
|
||||||
return (Settings.Default.GamePath + path).Replace('\\', Path.DirectorySeparatorChar);
|
return ((gamepath ?? Settings.Default.GamePath) + path).Replace('\\', Path.DirectorySeparatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetExe(string path = null)
|
||||||
|
{
|
||||||
|
if (File.Exists(GamePath("\\Gamecraft.exe", path)))
|
||||||
|
return "Gamecraft.exe";
|
||||||
|
if (File.Exists(GamePath("\\GamecraftPreview.exe", path)))
|
||||||
|
return "GamecraftPreview.exe";
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue