Remove autopatching altogether and detect launcher path
This commit is contained in:
parent
8676e232da
commit
adfe43f1a3
5 changed files with 26 additions and 85 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net461</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>false</SignAssembly>
|
||||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
<Company>ExMods</Company>
|
<Company>ExMods</Company>
|
||||||
<Description>A mod manager for Techblox. It automatically downloads and runs GCIPA and allows the user to install mods.</Description>
|
<Description>A mod manager for Techblox. It automatically downloads and runs GCIPA and allows the user to install mods.</Description>
|
||||||
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
|
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
|
||||||
|
<LangVersion>8</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
@ -32,6 +33,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
|
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -77,13 +77,6 @@ You may also want to verify the game's files in the launcher.
|
||||||
status.Text = resources.GetString("Status_Game_not_found");
|
status.Text = resources.GetString("Status_Game_not_found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Configuration.AutoPatch == AutoPatchingState.Unspecified)
|
|
||||||
{
|
|
||||||
Configuration.AutoPatch = AutoPatchingState.Disabled;
|
|
||||||
if (DialogUtils.ShowYesNoQuestion(resources.GetString("Change_launch_settings_question"),
|
|
||||||
resources.GetString("Change_launch_settings_title")))
|
|
||||||
EnableDisableAutoPatchingWithDialog(true);
|
|
||||||
}
|
|
||||||
DeleteEmptyPluginsDir(out bool pexists, out bool dexists);
|
DeleteEmptyPluginsDir(out bool pexists, out bool dexists);
|
||||||
if (!pexists && dexists)
|
if (!pexists && dexists)
|
||||||
unpatched.Checked = true; //It will call the event but that won't do anything
|
unpatched.Checked = true; //It will call the event but that won't do anything
|
||||||
|
@ -262,7 +255,7 @@ You may also want to verify the game's files in the launcher.
|
||||||
private async Task RefreshEverything(bool evenMods)
|
private async Task RefreshEverything(bool evenMods)
|
||||||
{
|
{
|
||||||
CheckIfPatched(); //Set from placeholder
|
CheckIfPatched(); //Set from placeholder
|
||||||
lastGameUpdateTime = await GetLastGameUpdateTime();
|
lastGameUpdateTime = GetGameVersionAsDate();
|
||||||
var mods = GetInstalledMods();
|
var mods = GetInstalledMods();
|
||||||
if (evenMods)
|
if (evenMods)
|
||||||
await GetAvailableMods();
|
await GetAvailableMods();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -7,6 +6,8 @@ using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using Application = UnityEngine.Application;
|
||||||
|
|
||||||
namespace GCMM
|
namespace GCMM
|
||||||
{
|
{
|
||||||
|
@ -28,50 +29,19 @@ namespace GCMM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool EnableDisableAutoPatching(bool enable)
|
|
||||||
{
|
|
||||||
foreach (string file in Directory.EnumerateFiles(GamePath("")))
|
|
||||||
File.Copy(file, Path.GetFileName(file), true);
|
|
||||||
var toSymLink = new List<string> {GamePath("\\MonoBleedingEdge")};
|
|
||||||
Directory.CreateDirectory("TechbloxPreview_Data");
|
|
||||||
toSymLink.AddRange(Directory.EnumerateDirectories(GamePath("\\TechbloxPreview_Data"))
|
|
||||||
.Except(new[] {"Managed"}));
|
|
||||||
foreach (string file in Directory.EnumerateFiles(GamePath("\\TechbloxPreview_Data")))
|
|
||||||
File.Copy(file, "TechbloxPreview_Data\\" + Path.GetFileName(file), true);
|
|
||||||
Directory.CreateDirectory("TechbloxPreview_Data\\Managed");
|
|
||||||
foreach (string file in Directory.EnumerateFiles(GamePath("\\TechbloxPreview_Data\\Managed")))
|
|
||||||
File.Copy(file, "TechbloxPreview_Data\\Managed\\" + Path.GetFileName(file), true);
|
|
||||||
return toSymLink.Select(targetName => (sourceName: targetName.Replace(GamePath("\\"), ""), targetName))
|
|
||||||
.Where(tuple => !Directory.Exists(tuple.sourceName))
|
|
||||||
.All(tuple => SymLinks.CreateFolderSymbolicLink(tuple.sourceName, tuple.targetName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EnableDisableAutoPatchingWithDialog(bool enable)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (EnableDisableAutoPatching(enable))
|
|
||||||
{
|
|
||||||
DialogUtils.ShowInfo(resources.GetString("Change_launch_settings_done"),
|
|
||||||
resources.GetString("Change_launch_settings_title"));
|
|
||||||
Configuration.AutoPatch = enable ? AutoPatchingState.Enabled : AutoPatchingState.Disabled;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
DialogUtils.ShowError(resources.GetString("Change_launch_settings_error"),
|
|
||||||
resources.GetString("Change_launch_settings_title"));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
DialogUtils.ShowError(resources.GetString("Change_launch_settings_error") + "\n\n" + e,
|
|
||||||
resources.GetString("Change_launch_settings_title"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetGameFolder()
|
public string GetGameFolder()
|
||||||
{
|
{
|
||||||
string launcherConfig =
|
using var key =
|
||||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
Registry.LocalMachine.OpenSubKey(
|
||||||
"Techblox Launcher", "launcher_settings.ini");
|
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Techblox Launcher") ??
|
||||||
|
Registry.LocalMachine.OpenSubKey(
|
||||||
|
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Techblox Launcher");
|
||||||
|
string launcherPath = key?.GetValue("DisplayIcon") is string launcherExecutable
|
||||||
|
? Directory.GetParent(launcherExecutable)?.FullName
|
||||||
|
: null;
|
||||||
|
launcherPath ??= Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||||
|
"Techblox Launcher");
|
||||||
|
string launcherConfig = Path.Combine(launcherPath, "launcher_settings.ini");
|
||||||
if (!File.Exists(launcherConfig)) return null;
|
if (!File.Exists(launcherConfig)) return null;
|
||||||
string path = File.ReadLines(launcherConfig)
|
string path = File.ReadLines(launcherConfig)
|
||||||
.FirstOrDefault(line => line.StartsWith("133062..GAME_PATH="))
|
.FirstOrDefault(line => line.StartsWith("133062..GAME_PATH="))
|
||||||
|
@ -111,11 +81,11 @@ namespace GCMM
|
||||||
await CheckModUpdatesAsync();
|
await CheckModUpdatesAsync();
|
||||||
Process.Start(command);
|
Process.Start(command);
|
||||||
}
|
}
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
Process.Start(new ProcessStartInfo(GamePath("\\" + GetExe()))
|
Process.Start(new ProcessStartInfo(GamePath("\\" + GetExe()))
|
||||||
{
|
{
|
||||||
WorkingDirectory = GamePath("\\") //Mods are only loaded if the working directory is correct
|
WorkingDirectory = GamePath("\\") //Mods are only loaded if the working directory is correct
|
||||||
});
|
});
|
||||||
EndWork(false);
|
EndWork(false);
|
||||||
tcs.SetResult(null);
|
tcs.SetResult(null);
|
||||||
};
|
};
|
||||||
|
@ -224,19 +194,9 @@ namespace GCMM
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DateTime> GetLastGameUpdateTime()
|
public DateTime GetGameVersionAsDate()
|
||||||
{
|
{
|
||||||
/*using (var client = GetClient())
|
return Convert.ToDateTime(Application.version);
|
||||||
{
|
|
||||||
string html = await client.DownloadStringTaskAsync("https://api.steamcmd.net/v1/info/1078000");
|
|
||||||
var regex = new Regex("<i>timeupdated:</i>[^<]*<b>([^<]*)</b>");
|
|
||||||
var match = regex.Match(html);
|
|
||||||
if (!match.Success)
|
|
||||||
return default;
|
|
||||||
return new DateTime(1970, 1, 1).AddSeconds(long.Parse(match.Groups[1].Value));
|
|
||||||
}*/
|
|
||||||
//return new DateTime(2020, 12, 28);
|
|
||||||
return default;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@ namespace GCMM
|
||||||
private void savebtn_Click(object sender, EventArgs e)
|
private void savebtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
mainForm.Configuration.GamePath = gamelocation.Text;
|
mainForm.Configuration.GamePath = gamelocation.Text;
|
||||||
if (autopatching.Checked != autopatchingEnabled)
|
|
||||||
mainForm.EnableDisableAutoPatchingWithDialog(autopatching.Checked);
|
|
||||||
mainForm.Configuration.Save();
|
mainForm.Configuration.Save();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace GCMM
|
|
||||||
{
|
|
||||||
public class SymLinks
|
|
||||||
{
|
|
||||||
public static bool CreateFolderSymbolicLink(string source, string target)
|
|
||||||
{
|
|
||||||
var proc = Process.Start(new ProcessStartInfo("cmd.exe", $"/c mklink /J \"{source}\" \"{target}\""));
|
|
||||||
proc?.WaitForExit();
|
|
||||||
return proc?.ExitCode == 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue