Some Linux support, fix list color after update
This commit is contained in:
parent
407724fb0d
commit
cbd6170757
5 changed files with 28 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
|
@ -22,6 +22,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -16,21 +16,21 @@ namespace GCMM
|
|||
public async Task InstallMod(ModInfo mod)
|
||||
{
|
||||
if (mod.DownloadURL == null) return;
|
||||
if (!File.Exists(Settings.Default.GamePath + @"\Gamecraft.exe"))
|
||||
if (!File.Exists(GamePath(@"\Gamecraft.exe")))
|
||||
{
|
||||
MessageBox.Show("Gamecraft not found. Set the correct path in Settings.");
|
||||
return;
|
||||
}
|
||||
var tmp = Directory.CreateDirectory("temp");
|
||||
var plugins = Directory.CreateDirectory(Settings.Default.GamePath + @"\Plugins");
|
||||
string tmppath = tmp.FullName + "\\" + mod.Name;
|
||||
var plugins = Directory.CreateDirectory(GamePath(@"\Plugins"));
|
||||
string tmppath = tmp.FullName + Path.DirectorySeparatorChar + mod.Name;
|
||||
using (var client = GetClient())
|
||||
{
|
||||
await client.DownloadFileTaskAsync(mod.DownloadURL, tmppath);
|
||||
string disposition = client.ResponseHeaders["Content-Disposition"];
|
||||
string filename = disposition.Substring(disposition.IndexOf("filename=") + 10).Replace("\"", "");
|
||||
if (filename.EndsWith(".dll"))
|
||||
File.Move(tmppath, plugins.FullName + "\\" + mod.Name + ".dll"); //Force mod name to make uninstalls & identifying easier
|
||||
File.Move(tmppath, plugins.FullName + Path.DirectorySeparatorChar + mod.Name + ".dll"); //Force mod name to make uninstalls & identifying easier
|
||||
else if (filename.EndsWith(".zip"))
|
||||
{
|
||||
bool pluginOnly = true;
|
||||
|
@ -120,7 +120,7 @@ namespace GCMM
|
|||
{
|
||||
LoadFileList(mod);
|
||||
if (mod.ModFiles.Count == 0) //A single DLL
|
||||
File.Delete(Settings.Default.GamePath + @"\Plugins\" + mod.Name + ".dll");
|
||||
File.Delete(GamePath(@"\Plugins\" + mod.Name + ".dll"));
|
||||
else //A ZIP
|
||||
{
|
||||
foreach (string file in mod.ModFiles)
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace GCMM
|
|||
|
||||
public void GetInstalledMods()
|
||||
{
|
||||
foreach (var modPath in Directory.GetFiles(Settings.Default.GamePath + @"\Plugins", "*.dll"))
|
||||
foreach (var modPath in Directory.GetFiles(GamePath(@"\Plugins"), "*.dll"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -122,6 +122,8 @@ namespace GCMM
|
|||
}
|
||||
if (mod.LatestVersion != null && mod.Version != null && mod.Version < mod.LatestVersion)
|
||||
item.ForeColor = Color.Blue;
|
||||
else
|
||||
item.ForeColor = modlist.ForeColor;
|
||||
}
|
||||
|
||||
public void RemoveModFromList(ModInfo mod)
|
||||
|
|
|
@ -17,24 +17,25 @@ namespace GCMM
|
|||
{
|
||||
public bool? CheckIfPatched()
|
||||
{
|
||||
if (!File.Exists(Settings.Default.GamePath + @"\IPA.exe"))
|
||||
if (!File.Exists(GamePath(@"\IPA.exe")))
|
||||
{
|
||||
status.Text = "Status: Patcher missing\nClicking Play will install it";
|
||||
return null;
|
||||
}
|
||||
string nopatch = "Status: Unpatched" + (unpatched.Checked ? "" : "\nClicking Play patches it");
|
||||
if (!Directory.Exists(Settings.Default.GamePath + @"\IPA\Backups\Gamecraft"))
|
||||
string backups = GamePath(@"\IPA\Backups\Gamecraft");
|
||||
if (!Directory.Exists(backups))
|
||||
{
|
||||
status.Text = nopatch;
|
||||
return false;
|
||||
}
|
||||
string backup = Directory.EnumerateDirectories(Settings.Default.GamePath + @"\IPA\Backups\Gamecraft").OrderByDescending(s => s).FirstOrDefault();
|
||||
string backup = Directory.EnumerateDirectories(backups).OrderByDescending(s => s).FirstOrDefault();
|
||||
if (backup == null)
|
||||
{
|
||||
status.Text = nopatch;
|
||||
return false;
|
||||
}
|
||||
if (File.GetLastWriteTime(Settings.Default.GamePath + @"\Gamecraft_Data\Managed\Assembly-CSharp.dll")
|
||||
if (File.GetLastWriteTime(GamePath(@"\Gamecraft_Data\Managed\Assembly-CSharp.dll"))
|
||||
> //If the file was updated at least 2 minutes after patching
|
||||
Directory.GetLastWriteTime(backup).AddMinutes(2))
|
||||
{
|
||||
|
@ -75,8 +76,8 @@ namespace GCMM
|
|||
return;
|
||||
}
|
||||
if (!status.Value ^ unpatched.Checked)
|
||||
{
|
||||
var psi = new ProcessStartInfo(Settings.Default.GamePath + @"\IPA.exe", "Gamecraft.exe "
|
||||
{ //TODO: Wine
|
||||
var psi = new ProcessStartInfo(GamePath(@"\IPA.exe"), "Gamecraft.exe "
|
||||
+ (unpatched.Checked ? "--revert " : "") + "--nowait")
|
||||
{
|
||||
UseShellExecute = false,
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace GCMM
|
|||
}
|
||||
|
||||
public string GetGameFolder()
|
||||
{
|
||||
{ //TODO
|
||||
string libs;
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
libs = @"C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf";
|
||||
|
@ -59,7 +59,7 @@ namespace GCMM
|
|||
var ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Gamecraft executable|Gamecraft.exe";
|
||||
ofd.Title = "Game location";
|
||||
ofd.InitialDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\";
|
||||
ofd.InitialDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\"; //TODO
|
||||
ofd.CheckFileExists = true;
|
||||
ofd.ShowDialog();
|
||||
if (string.IsNullOrWhiteSpace(ofd.FileName))
|
||||
|
@ -77,7 +77,10 @@ namespace GCMM
|
|||
return;
|
||||
}
|
||||
if ((CheckIfPatched() ?? false) || unpatched.Checked)
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
Process.Start("steam://run/1078000/");
|
||||
else
|
||||
Process.Start("xdg-open", "steam://run/1078000/");
|
||||
};
|
||||
if (InvokeRequired)
|
||||
Invoke(act);
|
||||
|
@ -121,5 +124,10 @@ namespace GCMM
|
|||
if (desc)
|
||||
modlist_SelectedIndexChanged(modlist, null);
|
||||
}
|
||||
|
||||
public string GamePath(string path)
|
||||
{
|
||||
return (Settings.Default.GamePath + path).Replace('\\', Path.DirectorySeparatorChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue