|
|
@@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Drawing; |
|
|
|
using System.IO; |
|
|
@@ -29,39 +30,41 @@ namespace GCMM |
|
|
|
|
|
|
|
private bool EnableDisableAutoPatching(bool enable) |
|
|
|
{ |
|
|
|
string launcherConfig = |
|
|
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), |
|
|
|
"Techblox Launcher", "launcher_settings.ini"); |
|
|
|
bool gamePathSet = false; |
|
|
|
if (File.Exists(launcherConfig)) |
|
|
|
{ |
|
|
|
string[] lines = File.ReadLines(launcherConfig).Select(line => |
|
|
|
{ |
|
|
|
if (line.StartsWith("133062..GAME_PATH=") && line.Contains('/')) |
|
|
|
{ |
|
|
|
gamePathSet = true; |
|
|
|
return $"{line.Replace("/TBMM/", "/")}{(enable ? "TBMM/" : "")}"; |
|
|
|
} |
|
|
|
|
|
|
|
return line; |
|
|
|
}).ToArray(); //Need to close the file |
|
|
|
File.WriteAllLines(launcherConfig, lines); |
|
|
|
} |
|
|
|
|
|
|
|
return gamePathSet; |
|
|
|
} //TODO: Setting the game path might not be a good idea because of updates... |
|
|
|
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) |
|
|
|
{ |
|
|
|
if (EnableDisableAutoPatching(enable)) |
|
|
|
try |
|
|
|
{ |
|
|
|
DialogUtils.ShowInfo(resources.GetString("Change_launch_settings_done"), |
|
|
|
resources.GetString("Change_launch_settings_title")); |
|
|
|
Configuration.AutoPatch = enable ? AutoPatchingState.Enabled : AutoPatchingState.Disabled; |
|
|
|
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")); |
|
|
|
} |
|
|
|
else |
|
|
|
DialogUtils.ShowError(resources.GetString("Change_launch_settings_error"), |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
DialogUtils.ShowError(resources.GetString("Change_launch_settings_error") + "\n\n" + e, |
|
|
|
resources.GetString("Change_launch_settings_title")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public string GetGameFolder() |
|
|
@@ -72,7 +75,8 @@ namespace GCMM |
|
|
|
if (!File.Exists(launcherConfig)) return null; |
|
|
|
string path = File.ReadLines(launcherConfig) |
|
|
|
.FirstOrDefault(line => line.StartsWith("133062..GAME_PATH=")) |
|
|
|
?.Substring("133062..GAME_PATH=".Length).Replace("/TBMM/", "/") + "StandaloneWindows64"; |
|
|
|
?.Substring("133062..GAME_PATH=".Length).Replace("/TBMM/", "/"); |
|
|
|
if (path != null) path = (path + "StandaloneWindows64").Replace('/', Path.DirectorySeparatorChar); |
|
|
|
if (path != null && GetExe(path) != null) return path; |
|
|
|
return null; |
|
|
|
} |
|
|
|