use cs package from backup packages

This commit is contained in:
Evil Factory
2022-04-29 14:00:53 -03:00
parent be76cd5f35
commit af47136bbd
6 changed files with 18 additions and 7 deletions
@@ -3228,7 +3228,7 @@ namespace Barotrauma
})); }));
commands.Add(new Command("cl_cs", "cs_cl: runs a string on the client", (string[] args) => commands.Add(new Command("cl_cs", "cs_cl: runs a string on the client", (string[] args) =>
{ {
if (LuaCsSetup.GetPackage("CsForBarotrauma", false) == null) { return; } if (LuaCsSetup.GetPackage("CsForBarotrauma", false, true) == null) { return; }
if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands)) if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands))
{ {
@@ -20,7 +20,7 @@ namespace Barotrauma
if (clientVersion == workshopVersion) { return; } if (clientVersion == workshopVersion) { return; }
string additional = LuaCsSetup.GetPackage("CsForBarotrauma", false) == null ? "" : "Cs"; string additional = LuaCsSetup.GetPackage("CsForBarotrauma", false, true) == null ? "" : "Cs";
var msg = new GUIMessageBox($"Lua{additional} Update", $"Your Lua{additional} client version is different from the version found in the Lua{additional}ForBarotrauma workshop files. Do you want to update?\n\n Client Version: {clientVersion}\n Workshop Version: {workshopVersion}", var msg = new GUIMessageBox($"Lua{additional} Update", $"Your Lua{additional} client version is different from the version found in the Lua{additional}ForBarotrauma workshop files. Do you want to update?\n\n Client Version: {clientVersion}\n Workshop Version: {workshopVersion}",
new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") }); new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") });
@@ -384,7 +384,7 @@ namespace Barotrauma
} }
}; };
#endif #endif
string additional = LuaCsSetup.GetPackage("CsForBarotrauma", false) == null ? "" : "Cs"; string additional = LuaCsSetup.GetPackage("CsForBarotrauma", false, true) == null ? "" : "Cs";
new GUIButton(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(20, 50) }, new GUIButton(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(20, 50) },
$"Remove Client-Side Lua{additional}", style: "MainMenuGUIButton", color: GUIStyle.Red) $"Remove Client-Side Lua{additional}", style: "MainMenuGUIButton", color: GUIStyle.Red)
@@ -1247,7 +1247,7 @@ namespace Barotrauma
})); }));
commands.Add(new Command("cs", "cs: runs a string", (string[] args) => commands.Add(new Command("cs", "cs: runs a string", (string[] args) =>
{ {
if(LuaCsSetup.GetPackage("CsForBarotrauma", false) == null) { return; } if(LuaCsSetup.GetPackage("CsForBarotrauma", false, true) == null) { return; }
GameMain.LuaCs.CsScript.Run(string.Join(" ", args)); GameMain.LuaCs.CsScript.Run(string.Join(" ", args));
GameMain.LuaCs.RecreateCsScript(); GameMain.LuaCs.RecreateCsScript();
@@ -36,7 +36,7 @@ namespace Barotrauma
? (Core as ContentPackage).ToEnumerable().CollectionConcat(Regular) ? (Core as ContentPackage).ToEnumerable().CollectionConcat(Regular)
: Enumerable.Empty<ContentPackage>(); : Enumerable.Empty<ContentPackage>();
private static class BackupPackages public static class BackupPackages
{ {
public static CorePackage? Core; public static CorePackage? Core;
public static ImmutableArray<RegularPackage>? Regular; public static ImmutableArray<RegularPackage>? Regular;
@@ -84,7 +84,7 @@ namespace Barotrauma
} }
public static ContentPackage GetPackage(Identifier name, bool fallbackToAll = true) public static ContentPackage GetPackage(Identifier name, bool fallbackToAll = true, bool useBackup = false)
{ {
foreach (ContentPackage package in ContentPackageManager.EnabledPackages.All) foreach (ContentPackage package in ContentPackageManager.EnabledPackages.All)
{ {
@@ -113,6 +113,17 @@ namespace Barotrauma
} }
} }
if (useBackup)
{
foreach (ContentPackage package in ContentPackageManager.EnabledPackages.BackupPackages.Regular)
{
if (package.NameMatches(name))
{
return package;
}
}
}
return null; return null;
} }
@@ -435,7 +446,7 @@ namespace Barotrauma
lua.Globals["CLIENT"] = IsClient; lua.Globals["CLIENT"] = IsClient;
if (GetPackage("CsForBarotrauma", false) != null) if (GetPackage("CsForBarotrauma", false, true) != null)
{ {
PrintMessage("Cs! Version " + AssemblyInfo.GitRevision); PrintMessage("Cs! Version " + AssemblyInfo.GitRevision);