7 static partial class LuaCsInstaller
9 public static void Uninstall()
11 if (!File.Exists(
"Temp/Original/Barotrauma.dll"))
13 new GUIMessageBox(
"Error",
"Error: Temp/Original/Barotrauma.dll not found, Github version? Use Steam validate files instead.");
18 var msg =
new GUIMessageBox(
"Confirm",
"Are you sure you want to remove Client-Side LuaCs?",
new LocalizedString[2] { TextManager.Get(
"Yes"), TextManager.Get(
"Cancel") });
20 msg.Buttons[0].OnClicked = (GUIButton button,
object obj) =>
24 string[] filesToRemove =
new string[]
26 "Barotrauma.dll",
"Barotrauma.deps.json",
"Barotrauma.pdb",
"BarotraumaCore.dll",
"BarotraumaCore.pdb",
27 "System.Reflection.Metadata.dll",
"System.Collections.Immutable.dll",
28 "System.Runtime.CompilerServices.Unsafe.dll"
32 CreateMissingDirectory();
34 foreach (
string file
in filesToRemove)
36 File.Move(file,
"Temp/ToDelete/" + file,
true);
37 File.Move(
"Temp/Original/" + file, file,
true);
42 new GUIMessageBox(
"Error", $
"{e} {e.InnerException} \nTry verifying files instead.");
46 new GUIMessageBox(
"Restart",
"Restart your game to apply the changes. If the mod continues to stay active after the restart, try verifying games instead.");
51 msg.Buttons[1].OnClicked = (GUIButton button,
object obj) =>
58 public static void CheckUpdate()
60 if (!File.Exists(LuaCsSetup.VersionFile)) {
return; }
62 ContentPackage luaPackage = LuaCsSetup.GetPackage(LuaCsSetup.LuaForBarotraumaId);
64 if (luaPackage ==
null) {
return; }
66 string luaCsPath = Path.GetDirectoryName(luaPackage.Path);
67 string clientVersion = File.ReadAllText(LuaCsSetup.VersionFile);
68 string workshopVersion = luaPackage.ModVersion;
70 if (clientVersion == workshopVersion || File.Exists(
"debugsomething")) {
return; }
72 var msg =
new GUIMessageBox($
"LuaCs Update", $
"Your LuaCs client version is different from the version found in the LuaCsForBarotrauma workshop files. Do you want to update?\n\n Client Version: {clientVersion}\n Workshop Version: {workshopVersion}",
73 new LocalizedString[2] { TextManager.Get(
"Yes"), TextManager.Get(
"Cancel") });
75 msg.Buttons[0].OnClicked = (GUIButton button,
object obj) =>
77 string[] filesToUpdate = trackingFiles.Concat(Directory.EnumerateFiles(luaCsPath,
"*.dll", SearchOption.AllDirectories)
78 .Where(s => s.Contains(
"mscordaccore_amd64_amd64")).Select(s => Path.GetFileName(s))).ToArray();
82 CreateMissingDirectory();
84 foreach (
string file
in filesToUpdate)
88 File.Move(file,
"Temp/Old/" + file,
true);
89 File.Copy(Path.Combine(luaCsPath,
"Binary", file), file,
true);
93 DebugConsole.ThrowError($
"Failed to update file {e}");
98 File.WriteAllText(LuaCsSetup.VersionFile, workshopVersion);
102 new GUIMessageBox(
"Failed", $
"Failed to update, error: {e}");
108 new GUIMessageBox(
"Restart", $
"LuaCs updated! Restart your game to apply the changes.");
114 msg.Buttons[1].OnClicked = (GUIButton button,
object obj) =>