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>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
|
@ -11,6 +11,7 @@
|
|||
<Company>ExMods</Company>
|
||||
<Description>A mod manager for Techblox. It automatically downloads and runs GCIPA and allows the user to install mods.</Description>
|
||||
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
|
||||
<LangVersion>8</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
@ -32,6 +33,9 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<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>
|
||||
|
|
|
@ -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");
|
||||
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);
|
||||
if (!pexists && dexists)
|
||||
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)
|
||||
{
|
||||
CheckIfPatched(); //Set from placeholder
|
||||
lastGameUpdateTime = await GetLastGameUpdateTime();
|
||||
lastGameUpdateTime = GetGameVersionAsDate();
|
||||
var mods = GetInstalledMods();
|
||||
if (evenMods)
|
||||
await GetAvailableMods();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
@ -7,6 +6,8 @@ using System.Linq;
|
|||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using Application = UnityEngine.Application;
|
||||
|
||||
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()
|
||||
{
|
||||
string launcherConfig =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"Techblox Launcher", "launcher_settings.ini");
|
||||
using var key =
|
||||
Registry.LocalMachine.OpenSubKey(
|
||||
@"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;
|
||||
string path = File.ReadLines(launcherConfig)
|
||||
.FirstOrDefault(line => line.StartsWith("133062..GAME_PATH="))
|
||||
|
@ -111,7 +81,7 @@ namespace GCMM
|
|||
await CheckModUpdatesAsync();
|
||||
Process.Start(command);
|
||||
}
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
Process.Start(new ProcessStartInfo(GamePath("\\" + GetExe()))
|
||||
{
|
||||
WorkingDirectory = GamePath("\\") //Mods are only loaded if the working directory is correct
|
||||
|
@ -224,19 +194,9 @@ namespace GCMM
|
|||
return false;
|
||||
}
|
||||
|
||||
public async Task<DateTime> GetLastGameUpdateTime()
|
||||
public DateTime GetGameVersionAsDate()
|
||||
{
|
||||
/*using (var client = GetClient())
|
||||
{
|
||||
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;
|
||||
return Convert.ToDateTime(Application.version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@ namespace GCMM
|
|||
private void savebtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
mainForm.Configuration.GamePath = gamelocation.Text;
|
||||
if (autopatching.Checked != autopatchingEnabled)
|
||||
mainForm.EnableDisableAutoPatchingWithDialog(autopatching.Checked);
|
||||
mainForm.Configuration.Save();
|
||||
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