Remove all uses of the Cs Package now that we don't need it anymore
LuaCs Settings no longer uses LuaCsConfig Cs Package is no longer is used for enabling CSharp Scripting (except for dedicated server, to not make those people confused) Added popups for when you have CSharp mods enabled but don't have CSharp enabled when going to singleplayer/multiplayer
This commit is contained in:
@@ -10,17 +10,22 @@ using System.Diagnostics;
|
||||
using MoonSharp.VsCodeDebugger;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class LuaCsSetupConfig
|
||||
{
|
||||
public bool FirstTimeCsWarning = true;
|
||||
public bool ForceCsScripting = false;
|
||||
public bool EnableCsScripting = false;
|
||||
public bool TreatForcedModsAsNormal = true;
|
||||
public bool PreferToUseWorkshopLuaSetup = false;
|
||||
public bool DisableErrorGUIOverlay = false;
|
||||
public bool HideUserNames = true;
|
||||
public bool HideUserNames
|
||||
{
|
||||
get { return LuaCsLogger.HideUserNames; }
|
||||
set { LuaCsLogger.HideUserNames = value; }
|
||||
}
|
||||
|
||||
public LuaCsSetupConfig() { }
|
||||
}
|
||||
@@ -96,7 +101,11 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetPackage(CsForBarotraumaId, false, true) != null || Config.ForceCsScripting;
|
||||
#if SERVER
|
||||
if (GetPackage(CsForBarotraumaId, false, false) != null && GameMain.Server.ServerPeer is LidgrenServerPeer) { return true; }
|
||||
#endif
|
||||
|
||||
return Config.EnableCsScripting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,19 +120,7 @@ namespace Barotrauma
|
||||
Networking = new LuaCsNetworking();
|
||||
DebugServer = new MoonSharpVsCodeDebugServer();
|
||||
|
||||
if (File.Exists(configFileName))
|
||||
{
|
||||
using (var file = File.Open(configFileName, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
Config = LuaCsConfig.Load<LuaCsSetupConfig>(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Config = new LuaCsSetupConfig();
|
||||
}
|
||||
|
||||
UpdateConfigVars();
|
||||
ReadSettings();
|
||||
}
|
||||
|
||||
[Obsolete("Use AssemblyManager::GetTypesByName()")]
|
||||
@@ -164,20 +161,41 @@ namespace Barotrauma
|
||||
|
||||
public void DetachDebugger() => DebugServer.Detach(Lua);
|
||||
|
||||
public void UpdateConfigVars()
|
||||
public void ReadSettings()
|
||||
{
|
||||
LuaCsLogger.HideUserNames = Config.HideUserNames;
|
||||
Config = new LuaCsSetupConfig();
|
||||
|
||||
if (File.Exists(configFileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var file = File.Open(configFileName, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
XDocument document = XDocument.Load(file);
|
||||
Config.EnableCsScripting = bool.Parse(document.Root.Element("ForceCsScripting").Value);
|
||||
Config.TreatForcedModsAsNormal = bool.Parse(document.Root.Element("TreatForcedModsAsNormal").Value);
|
||||
Config.PreferToUseWorkshopLuaSetup = bool.Parse(document.Root.Element("PreferToUseWorkshopLuaSetup").Value);
|
||||
Config.DisableErrorGUIOverlay = bool.Parse(document.Root.Element("DisableErrorGUIOverlay").Value);
|
||||
Config.HideUserNames = bool.Parse(document.Root.Element("HideUserNames").Value);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LuaCsLogger.HandleException(e, LuaCsMessageOrigin.LuaCs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateConfig()
|
||||
public void WriteSettings()
|
||||
{
|
||||
FileStream file;
|
||||
if (!File.Exists(configFileName)) { file = File.Create(configFileName); }
|
||||
else { file = File.Open(configFileName, FileMode.Truncate, FileAccess.Write); }
|
||||
LuaCsConfig.Save(file, Config);
|
||||
file.Close();
|
||||
|
||||
UpdateConfigVars();
|
||||
XDocument document = new XDocument();
|
||||
document.Add(new XElement("LuaCsSetupConfig"));
|
||||
document.Root.Add(new XElement("ForceCsScripting", Config.EnableCsScripting));
|
||||
document.Root.Add(new XElement("TreatForcedModsAsNormal", Config.TreatForcedModsAsNormal));
|
||||
document.Root.Add(new XElement("PreferToUseWorkshopLuaSetup", Config.PreferToUseWorkshopLuaSetup));
|
||||
document.Root.Add(new XElement("DisableErrorGUIOverlay", Config.DisableErrorGUIOverlay));
|
||||
document.Root.Add(new XElement("HideUserNames", Config.HideUserNames));
|
||||
document.Save(configFileName);
|
||||
}
|
||||
|
||||
public static ContentPackage GetPackage(ContentPackageId id, bool fallbackToAll = true, bool useBackup = false)
|
||||
@@ -393,9 +411,6 @@ namespace Barotrauma
|
||||
UserData.RegisterType<LuaUserData>();
|
||||
UserData.RegisterType<LuaCsPerformanceCounter>();
|
||||
UserData.RegisterType<IUserDataDescriptor>();
|
||||
UserData.RegisterType<CsPackageManager>();
|
||||
UserData.RegisterType<AssemblyManager>();
|
||||
UserData.RegisterType<IAssemblyPlugin>();
|
||||
|
||||
UserData.RegisterExtensionType(typeof(MathUtils));
|
||||
UserData.RegisterExtensionType(typeof(XMLExtensions));
|
||||
@@ -438,13 +453,9 @@ namespace Barotrauma
|
||||
{
|
||||
LuaCsLogger.LogMessage("Cs! Version " + AssemblyInfo.GitRevision);
|
||||
|
||||
if (Config.FirstTimeCsWarning)
|
||||
{
|
||||
Config.FirstTimeCsWarning = false;
|
||||
UpdateConfig();
|
||||
|
||||
DebugConsole.AddWarning("Cs package active! Cs mods are NOT sandboxed, use it at your own risk!");
|
||||
}
|
||||
UserData.RegisterType<CsPackageManager>();
|
||||
UserData.RegisterType<AssemblyManager>();
|
||||
UserData.RegisterType<IAssemblyPlugin>();
|
||||
|
||||
Lua.Globals["PluginPackageManager"] = PluginPackageManager;
|
||||
Lua.Globals["AssemblyManager"] = AssemblyManager;
|
||||
|
||||
Reference in New Issue
Block a user