More IPC work

Additional checks to make sure profile update event is not getting sent when editor and default profile is involved
Selected default profile can no longer be changed if profile set as default is enabled
Fixed "Limit to my creatures" not ignoring objects with IdentifierType != Owned
IPC test tab no longer initializes IPC if debug mode is disabled
Fixed incorrect warning priority in plugin state control
Some slight text changes
This commit is contained in:
RisaDev
2024-03-26 00:14:29 +03:00
parent da252a57cf
commit abb92e741e
7 changed files with 65 additions and 44 deletions

View File

@@ -8,6 +8,7 @@ using CustomizePlus.Configuration.Data;
using CustomizePlus.UI.Windows.MainWindow.Tabs.Templates;
using CustomizePlus.Core.Helpers;
using CustomizePlus.Api;
using CustomizePlus.Core.Data;
namespace CustomizePlus.UI.Windows.Controls;
@@ -20,10 +21,6 @@ public class PluginStateBlock
private readonly HookingService _hookingService;
private readonly CustomizePlusIpc _ipcService;
private static Vector4 normalColor = new Vector4(1, 1, 1, 1);
private static Vector4 warnColor = new Vector4(1, 0.5f, 0, 1);
private static Vector4 errorColor = new Vector4(1, 0, 0, 1);
public PluginStateBlock(
BoneEditorPanel boneEditorPanel,
PluginConfiguration configuration,
@@ -55,11 +52,6 @@ public class PluginStateBlock
severity = PluginStateSeverity.Error;
message = $"Fantasia+ detected. The plugin is disabled until Fantasia+ is disabled and the game is restarted.";
}
else if (_gameStateService.GameInPosingMode())
{
severity = PluginStateSeverity.Warning;
message = $"GPose active. Compatibility with posing tools is limited.";
}
else if (!_configuration.PluginEnabled)
{
severity = PluginStateSeverity.Warning;
@@ -80,7 +72,12 @@ public class PluginStateBlock
message = $"Editor is active.{(_boneEditorPanel.HasChanges ? " You have unsaved changes, finish template bone editing to open save/revert dialog." : "")}";
}
}
else if (_ipcService.IPCFailed) //this is low priority error
else if (_gameStateService.GameInPosingMode())
{
severity = PluginStateSeverity.Warning;
message = $"GPose active. Compatibility with posing tools is limited.";
}
else if (_ipcService.IPCFailed) //this is a low priority error
{
severity = PluginStateSeverity.Error;
message = $"Detected failure in IPC. Integrations with other plugins will not function.";
@@ -91,16 +88,16 @@ public class PluginStateBlock
ImGui.SetCursorPos(new Vector2(ImGui.GetWindowContentRegionMax().X - ImGui.CalcTextSize(message).X - 30, yPos - ImGuiHelpers.GlobalScale));
var icon = FontAwesomeIcon.InfoCircle;
var color = normalColor;
var color = Constants.Colors.Normal;
switch (severity)
{
case PluginStateSeverity.Warning:
icon = FontAwesomeIcon.ExclamationTriangle;
color = warnColor;
color = Constants.Colors.Warning;
break;
case PluginStateSeverity.Error:
icon = FontAwesomeIcon.ExclamationTriangle;
color = errorColor;
color = Constants.Colors.Error;
break;
}

View File

@@ -19,6 +19,7 @@ using System.Collections.Generic;
using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string VirtualPath, string CharacterName, bool IsEnabled);
using OtterGui.Log;
using CustomizePlus.Core.Extensions;
using CustomizePlus.Configuration.Data;
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Debug;
@@ -85,7 +86,8 @@ public class IPCTestTab //: IDisposable
ObjectManager objectManager,
GameObjectService gameObjectService,
ActorManager actorManager,
Logger logger)
Logger logger,
PluginConfiguration configuration)
{
_objectTable = objectTable;
_profileManager = profileManager;
@@ -95,7 +97,8 @@ public class IPCTestTab //: IDisposable
_actorManager = actorManager;
_logger = logger;
EzIPC.Init(this, "CustomizePlus");
if(configuration.DebuggingModeEnabled)
EzIPC.Init(this, "CustomizePlus"); //do not init EzIPC if debugging disabled so no debug event hook is created
if (_getApiVersionIpcFunc != null)
_apiVersion = _getApiVersionIpcFunc();

View File

@@ -12,6 +12,10 @@ using CustomizePlus.Configuration.Data;
using CustomizePlus.Profiles.Data;
using CustomizePlus.UI.Windows.Controls;
using CustomizePlus.Templates;
using CustomizePlus.Core.Helpers;
using System.Windows.Forms;
using CustomizePlus.Core.Data;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Profiles;
@@ -147,16 +151,28 @@ public class ProfilePanel
{
if (ImGui.Checkbox("##Enabled", ref enabled))
_manager.SetEnabled(_selector.Selected!, enabled);
ImGuiUtil.LabeledHelpMarker("Enabled",
"Whether the templates in this profile should be applied at all. Only one profile can be enabled for a character at the same time.");
}
ImGuiUtil.LabeledHelpMarker("Enabled",
"Whether the templates in this profile should be applied at all. Only one profile can be enabled for a character at the same time.");
ImGui.SameLine();
var isDefault = _manager.DefaultProfile == _selector.Selected;
if (ImGui.Checkbox("##DefaultProfile", ref isDefault))
_manager.SetDefaultProfile(isDefault ? _selector.Selected! : null);
ImGuiUtil.LabeledHelpMarker("Default profile (Players and Retainers only)",
"Whether the templates in this profile are applied to all players and retainers without a specific profile. Only one profile can be default at the same time.");
var isDefaultEnabled = _manager.DefaultProfile?.Enabled ?? false;
using (ImRaii.Disabled(isDefaultEnabled))
{
if (ImGui.Checkbox("##DefaultProfile", ref isDefault))
_manager.SetDefaultProfile(isDefault ? _selector.Selected! : null);
ImGuiUtil.LabeledHelpMarker("Default profile (Players and Retainers only)",
"Whether the templates in this profile are applied to all players and retainers without a specific profile. Only one profile can be default at the same time.");
}
if(isDefaultEnabled)
{
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Text, Constants.Colors.Warning);
ImGuiUtil.PrintIcon(FontAwesomeIcon.ExclamationTriangle);
ImGui.PopStyleColor();
ImGuiUtil.HoverTooltip("Can only be changed while the default profile is disabled.");
}
}
}
@@ -224,7 +240,7 @@ public class ProfilePanel
if (ImGui.Checkbox("##LimitLookupToOwnedObjects", ref enabled))
_manager.SetLimitLookupToOwned(_selector.Selected!, enabled);
ImGuiUtil.LabeledHelpMarker("Limit to my creatures",
"When enabled limits the character search to only your own summons, mounts and minions.\nUseful when there is possibility there will be another character with that name owned by another player.\n* For battle chocobo use \"Chocobo\" as character name.\n** If you are changing root scale for mount and want to keep your scale make sure your own scale is set to anything other than default value.");
"When enabled limits the character search to only your own summons, mounts and minions.\nUseful when there is possibility there will be another character with that name owned by another player.\n* For battle chocobo use \"Chocobo\" as character name.");
}
}
}

View File

@@ -197,7 +197,7 @@ public class SettingsTab
{
var isChecked = _configuration.DebuggingModeEnabled;
if (CtrlHelper.CheckboxWithTextAndHelp("##debugmode", "Debug mode",
"Enables debug mode", ref isChecked))
"Enables debug mode. Requires plugin restart for all features to become properly initialized.", ref isChecked))
{
_configuration.DebuggingModeEnabled = isChecked;
_configuration.Save();