Make setting for crash handler.

This commit is contained in:
Ottermandias 2024-03-28 19:32:10 +01:00
parent a31bdb66c8
commit b04cb343dd
3 changed files with 59 additions and 42 deletions

View file

@ -33,12 +33,12 @@ public class Configuration : IPluginConfiguration, ISavable
public string ModDirectory { get; set; } = string.Empty; public string ModDirectory { get; set; } = string.Empty;
public string ExportDirectory { get; set; } = string.Empty; public string ExportDirectory { get; set; } = string.Empty;
public bool UseCrashHandler { get; set; } = true; public bool? UseCrashHandler { get; set; } = null;
public bool OpenWindowAtStart { get; set; } = false; public bool OpenWindowAtStart { get; set; } = false;
public bool HideUiInGPose { get; set; } = false; public bool HideUiInGPose { get; set; } = false;
public bool HideUiInCutscenes { get; set; } = true; public bool HideUiInCutscenes { get; set; } = true;
public bool HideUiWhenUiHidden { get; set; } = false; public bool HideUiWhenUiHidden { get; set; } = false;
public bool UseDalamudUiTextureRedirection { get; set; } = true; public bool UseDalamudUiTextureRedirection { get; set; } = true;
public bool UseCharacterCollectionInMainWindow { get; set; } = true; public bool UseCharacterCollectionInMainWindow { get; set; } = true;
public bool UseCharacterCollectionsInCards { get; set; } = true; public bool UseCharacterCollectionsInCards { get; set; } = true;
@ -48,9 +48,9 @@ public class Configuration : IPluginConfiguration, ISavable
public bool UseNoModsInInspect { get; set; } = false; public bool UseNoModsInInspect { get; set; } = false;
public bool HideChangedItemFilters { get; set; } = false; public bool HideChangedItemFilters { get; set; } = false;
public bool ReplaceNonAsciiOnImport { get; set; } = false; public bool ReplaceNonAsciiOnImport { get; set; } = false;
public bool HidePrioritiesInSelector { get; set; } = false; public bool HidePrioritiesInSelector { get; set; } = false;
public bool HideRedrawBar { get; set; } = false; public bool HideRedrawBar { get; set; } = false;
public int OptionGroupCollapsibleMin { get; set; } = 5; public int OptionGroupCollapsibleMin { get; set; } = 5;
public Vector2 MinimumSize = new(Constants.MinimumSizeX, Constants.MinimumSizeY); public Vector2 MinimumSize = new(Constants.MinimumSizeX, Constants.MinimumSizeY);

View file

@ -36,7 +36,7 @@ public sealed class CrashHandlerService : IDisposable, IService
_config = config; _config = config;
_validityChecker = validityChecker; _validityChecker = validityChecker;
if (!_config.UseCrashHandler) if (_config.UseCrashHandler ?? false)
return; return;
OpenEventWriter(); OpenEventWriter();
@ -84,7 +84,7 @@ public sealed class CrashHandlerService : IDisposable, IService
public void Enable() public void Enable()
{ {
if (_config.UseCrashHandler) if (_config.UseCrashHandler ?? false)
return; return;
_config.UseCrashHandler = true; _config.UseCrashHandler = true;
@ -97,7 +97,7 @@ public sealed class CrashHandlerService : IDisposable, IService
public void Disable() public void Disable()
{ {
if (!_config.UseCrashHandler) if (!(_config.UseCrashHandler ?? false))
return; return;
_config.UseCrashHandler = false; _config.UseCrashHandler = false;

View file

@ -43,6 +43,7 @@ public class SettingsTab : ITab
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly IDataManager _gameData; private readonly IDataManager _gameData;
private readonly PredefinedTagManager _predefinedTagManager; private readonly PredefinedTagManager _predefinedTagManager;
private readonly CrashHandlerService _crashService;
private int _minimumX = int.MaxValue; private int _minimumX = int.MaxValue;
private int _minimumY = int.MaxValue; private int _minimumY = int.MaxValue;
@ -53,7 +54,7 @@ public class SettingsTab : ITab
Penumbra penumbra, FileDialogService fileDialog, ModManager modManager, ModFileSystemSelector selector, Penumbra penumbra, FileDialogService fileDialog, ModManager modManager, ModFileSystemSelector selector,
CharacterUtility characterUtility, ResidentResourceManager residentResources, ModExportManager modExportManager, HttpApi httpApi, CharacterUtility characterUtility, ResidentResourceManager residentResources, ModExportManager modExportManager, HttpApi httpApi,
DalamudSubstitutionProvider dalamudSubstitutionProvider, FileCompactor compactor, DalamudConfigService dalamudConfig, DalamudSubstitutionProvider dalamudSubstitutionProvider, FileCompactor compactor, DalamudConfigService dalamudConfig,
IDataManager gameData, PredefinedTagManager predefinedTagConfig) IDataManager gameData, PredefinedTagManager predefinedTagConfig, CrashHandlerService crashService)
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_config = config; _config = config;
@ -74,6 +75,7 @@ public class SettingsTab : ITab
if (_compactor.CanCompact) if (_compactor.CanCompact)
_compactor.Enabled = _config.UseFileSystemCompression; _compactor.Enabled = _config.UseFileSystemCompression;
_predefinedTagManager = predefinedTagConfig; _predefinedTagManager = predefinedTagConfig;
_crashService = crashService;
} }
public void DrawHeader() public void DrawHeader()
@ -228,35 +230,35 @@ public class SettingsTab : ITab
_newModDirectory = _config.ModDirectory; _newModDirectory = _config.ModDirectory;
bool save, selected; bool save, selected;
using (ImRaii.Group()) using (ImRaii.Group())
{ {
ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton3); ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton3);
using (ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale, !_modManager.Valid)) using (ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale, !_modManager.Valid))
{ {
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.RegexWarningBorder) using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.RegexWarningBorder)
.Push(ImGuiCol.TextDisabled, Colors.RegexWarningBorder, !_modManager.Valid); .Push(ImGuiCol.TextDisabled, Colors.RegexWarningBorder, !_modManager.Valid);
save = ImGui.InputTextWithHint("##rootDirectory", "Enter Root Directory here (MANDATORY)...", ref _newModDirectory, save = ImGui.InputTextWithHint("##rootDirectory", "Enter Root Directory here (MANDATORY)...", ref _newModDirectory,
RootDirectoryMaxLength, ImGuiInputTextFlags.EnterReturnsTrue); RootDirectoryMaxLength, ImGuiInputTextFlags.EnterReturnsTrue);
} }
selected = ImGui.IsItemActive(); selected = ImGui.IsItemActive();
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(UiHelpers.ScaleX3, 0)); using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(UiHelpers.ScaleX3, 0));
ImGui.SameLine(); ImGui.SameLine();
DrawDirectoryPickerButton(); DrawDirectoryPickerButton();
style.Pop(); style.Pop();
ImGui.SameLine(); ImGui.SameLine();
const string tt = "This is where Penumbra will store your extracted mod files.\n" const string tt = "This is where Penumbra will store your extracted mod files.\n"
+ "TTMP files are not copied, just extracted.\n" + "TTMP files are not copied, just extracted.\n"
+ "This directory needs to be accessible and you need write access here.\n" + "This directory needs to be accessible and you need write access here.\n"
+ "It is recommended that this directory is placed on a fast hard drive, preferably an SSD.\n" + "It is recommended that this directory is placed on a fast hard drive, preferably an SSD.\n"
+ "It should also be placed near the root of a logical drive - the shorter the total path to this folder, the better.\n" + "It should also be placed near the root of a logical drive - the shorter the total path to this folder, the better.\n"
+ "Definitely do not place it in your Dalamud directory or any sub-directory thereof."; + "Definitely do not place it in your Dalamud directory or any sub-directory thereof.";
ImGuiComponents.HelpMarker(tt); ImGuiComponents.HelpMarker(tt);
_tutorial.OpenTutorial(BasicTutorialSteps.GeneralTooltips); _tutorial.OpenTutorial(BasicTutorialSteps.GeneralTooltips);
ImGui.SameLine(); ImGui.SameLine();
ImGui.TextUnformatted("Root Directory"); ImGui.TextUnformatted("Root Directory");
ImGuiUtil.HoverTooltip(tt); ImGuiUtil.HoverTooltip(tt);
} }
_tutorial.OpenTutorial(BasicTutorialSteps.ModDirectory); _tutorial.OpenTutorial(BasicTutorialSteps.ModDirectory);
@ -704,6 +706,7 @@ public class SettingsTab : ITab
if (!header) if (!header)
return; return;
DrawCrashHandler();
DrawMinimumDimensionConfig(); DrawMinimumDimensionConfig();
Checkbox("Auto Deduplicate on Import", Checkbox("Auto Deduplicate on Import",
"Automatically deduplicate mod files on import. This will make mod file sizes smaller, but deletes (binary identical) files.", "Automatically deduplicate mod files on import. This will make mod file sizes smaller, but deletes (binary identical) files.",
@ -721,6 +724,20 @@ public class SettingsTab : ITab
ImGui.NewLine(); ImGui.NewLine();
} }
private void DrawCrashHandler()
{
Checkbox("Enable Penumbra Crash Logging (Experimental)",
"Enables Penumbra to launch a secondary process that records some game activity which may or may not help diagnosing Penumbra-related game crashes.",
_config.UseCrashHandler ?? false,
v =>
{
if (v)
_crashService.Enable();
else
_crashService.Disable();
});
}
private void DrawCompressionBox() private void DrawCompressionBox()
{ {
if (!_compactor.CanCompact) if (!_compactor.CanCompact)