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

View File

@@ -3228,7 +3228,7 @@ namespace Barotrauma
}));
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))
{

View File

@@ -20,7 +20,7 @@ namespace Barotrauma
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}",
new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") });

View File

@@ -384,7 +384,7 @@ namespace Barotrauma
}
};
#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) },
$"Remove Client-Side Lua{additional}", style: "MainMenuGUIButton", color: GUIStyle.Red)

View File

@@ -1247,7 +1247,7 @@ namespace Barotrauma
}));
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.RecreateCsScript();

View File

@@ -36,7 +36,7 @@ namespace Barotrauma
? (Core as ContentPackage).ToEnumerable().CollectionConcat(Regular)
: Enumerable.Empty<ContentPackage>();
private static class BackupPackages
public static class BackupPackages
{
public static CorePackage? Core;
public static ImmutableArray<RegularPackage>? Regular;

View File

@@ -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)
{
@@ -113,6 +113,17 @@ namespace Barotrauma
}
}
if (useBackup)
{
foreach (ContentPackage package in ContentPackageManager.EnabledPackages.BackupPackages.Regular)
{
if (package.NameMatches(name))
{
return package;
}
}
}
return null;
}
@@ -435,7 +446,7 @@ namespace Barotrauma
lua.Globals["CLIENT"] = IsClient;
if (GetPackage("CsForBarotrauma", false) != null)
if (GetPackage("CsForBarotrauma", false, true) != null)
{
PrintMessage("Cs! Version " + AssemblyInfo.GitRevision);