|
|
@@ -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,11 +81,11 @@ namespace GCMM |
|
|
|
await CheckModUpdatesAsync(); |
|
|
|
Process.Start(command); |
|
|
|
} |
|
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT) |
|
|
|
Process.Start(new ProcessStartInfo(GamePath("\\" + GetExe())) |
|
|
|
{ |
|
|
|
WorkingDirectory = GamePath("\\") //Mods are only loaded if the working directory is correct |
|
|
|
}); |
|
|
|
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 |
|
|
|
}); |
|
|
|
EndWork(false); |
|
|
|
tcs.SetResult(null); |
|
|
|
}; |
|
|
@@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |