mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 04:13:40 +01:00
feat: Allow /xldev to disable Safe Mode (#2166)
- Adds new menu item to /xldev to disable Safe Mode, allowing users to load plugins again. - Safe mode cannot be re-enabled once disabled. - Add new ModuleLog.Create<T> for eventual ILogger magic - Make safe mode writable - Remove redundant check in CheckPolicy
This commit is contained in:
parent
da8be03124
commit
a656fefb2b
4 changed files with 38 additions and 13 deletions
|
|
@ -1012,6 +1012,11 @@ internal class DalamudInterface : IInternalDisposableService
|
||||||
pluginManager.LoadBannedPlugins = !pluginManager.LoadBannedPlugins;
|
pluginManager.LoadBannedPlugins = !pluginManager.LoadBannedPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pluginManager.SafeMode && ImGui.MenuItem("Disable Safe Mode"))
|
||||||
|
{
|
||||||
|
pluginManager.SafeMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.MenuItem("API Level:" + PluginManager.DalamudApiLevel, false);
|
ImGui.MenuItem("API Level:" + PluginManager.DalamudApiLevel, false);
|
||||||
ImGui.MenuItem("Loaded plugins:" + pluginManager.InstalledPlugins.Count(), false);
|
ImGui.MenuItem("Loaded plugins:" + pluginManager.InstalledPlugins.Count(), false);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Core;
|
using Serilog.Core;
|
||||||
|
using Serilog.Core.Enrichers;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace Dalamud.Logging.Internal;
|
namespace Dalamud.Logging.Internal;
|
||||||
|
|
@ -27,6 +28,28 @@ public class ModuleLog
|
||||||
this.moduleLogger = Log.ForContext("Dalamud.ModuleName", this.moduleName);
|
this.moduleLogger = Log.ForContext("Dalamud.ModuleName", this.moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ModuleLog"/> class.
|
||||||
|
/// This class will properly attach SourceContext and other attributes per Serilog standards.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type">The type of the class this logger is for.</param>
|
||||||
|
public ModuleLog(Type type)
|
||||||
|
{
|
||||||
|
this.moduleName = type.Name;
|
||||||
|
this.moduleLogger = Log.ForContext(
|
||||||
|
[
|
||||||
|
new PropertyEnricher(Constants.SourceContextPropertyName, type.FullName),
|
||||||
|
new PropertyEnricher("Dalamud.ModuleName", this.moduleName)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to create a new <see cref="ModuleLog"/> instance based on a type.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The class to create this ModuleLog for.</typeparam>
|
||||||
|
/// <returns>Returns a ModuleLog with name set.</returns>
|
||||||
|
internal static ModuleLog Create<T>() => new(typeof(T));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Log a templated verbose message to the in-game debug log.
|
/// Log a templated verbose message to the in-game debug log.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ internal class PluginManager : IInternalDisposableService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int PluginWaitBeforeFreeDefault = 1000; // upped from 500ms, seems more stable
|
public const int PluginWaitBeforeFreeDefault = 1000; // upped from 500ms, seems more stable
|
||||||
|
|
||||||
private static readonly ModuleLog Log = new("PLUGINM");
|
private static readonly ModuleLog Log = ModuleLog.Create<PluginManager>();
|
||||||
|
|
||||||
private readonly object pluginListLock = new();
|
private readonly object pluginListLock = new();
|
||||||
private readonly DirectoryInfo pluginDirectory;
|
private readonly DirectoryInfo pluginDirectory;
|
||||||
|
|
@ -243,9 +243,9 @@ internal class PluginManager : IInternalDisposableService
|
||||||
public bool ReposReady { get; private set; }
|
public bool ReposReady { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the plugin manager started in safe mode.
|
/// Gets or sets a value indicating whether the plugin manager started in safe mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SafeMode { get; init; }
|
public bool SafeMode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="PluginConfigurations"/> object used when initializing plugins.
|
/// Gets the <see cref="PluginConfigurations"/> object used when initializing plugins.
|
||||||
|
|
|
||||||
|
|
@ -510,9 +510,6 @@ internal class LocalPlugin : IAsyncDisposable
|
||||||
var startInfo = Service<Dalamud>.Get().StartInfo;
|
var startInfo = Service<Dalamud>.Get().StartInfo;
|
||||||
var manager = Service<PluginManager>.Get();
|
var manager = Service<PluginManager>.Get();
|
||||||
|
|
||||||
if (startInfo.NoLoadPlugins)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (startInfo.NoLoadThirdPartyPlugins && this.manifest.IsThirdParty)
|
if (startInfo.NoLoadThirdPartyPlugins && this.manifest.IsThirdParty)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue