Add ability to apply profiles on character selection (lobby) screen

This commit is contained in:
RisaDev
2024-04-15 23:45:48 +03:00
parent 237c7d5c6a
commit bf74d3774c
6 changed files with 63 additions and 3 deletions

View File

@@ -97,6 +97,7 @@ public class PluginConfiguration : IPluginConfiguration, ISavable
public bool ApplyInTryOn { get; set; } = true;
public bool ApplyInCards { get; set; } = true;
public bool ApplyInInspect { get; set; } = true;
public bool ApplyInLobby { get; set; } = true;
}
public ProfileApplicationSettingsEntries ProfileApplicationSettings { get; set; } = new();

View File

@@ -10,6 +10,10 @@ using DalamudGameObject = Dalamud.Game.ClientState.Objects.Types.GameObject;
using ECommons.Configuration;
using System;
using CustomizePlus.Configuration.Data;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using Penumbra.GameData;
using Penumbra.String;
using Dalamud.Logging;
namespace CustomizePlus.Game.Services;
@@ -92,7 +96,6 @@ public class GameObjectService
return _objectTable.CreateObjectReference(actor);
}
/// <summary>
/// Get "true" actor for special actors.
/// This should be used everywhere where resolving proper actor is crucial for proper profile application

View File

@@ -27,6 +27,7 @@ using Penumbra.GameData.Enums;
using Penumbra.GameData.Interop;
using System.Runtime.Serialization;
using CustomizePlus.Game.Services;
using ObjectManager = CustomizePlus.GameData.Services.ObjectManager;
namespace CustomizePlus.Profiles;
@@ -42,6 +43,7 @@ public class ProfileManager : IDisposable
private readonly PluginConfiguration _configuration;
private readonly ActorManager _actorManager;
private readonly GameObjectService _gameObjectService;
private readonly ObjectManager _objectManager;
private readonly ProfileChanged _event;
private readonly TemplateChanged _templateChangedEvent;
private readonly ReloadEvent _reloadEvent;
@@ -59,6 +61,7 @@ public class ProfileManager : IDisposable
PluginConfiguration configuration,
ActorManager actorManager,
GameObjectService gameObjectService,
ObjectManager objectManager,
ProfileChanged @event,
TemplateChanged templateChangedEvent,
ReloadEvent reloadEvent,
@@ -71,6 +74,7 @@ public class ProfileManager : IDisposable
_configuration = configuration;
_actorManager = actorManager;
_gameObjectService = gameObjectService;
_objectManager = objectManager;
_event = @event;
_templateChangedEvent = templateChangedEvent;
_templateChangedEvent.Subscribe(OnTemplateChange, TemplateChanged.Priority.ProfileManager);
@@ -481,6 +485,12 @@ public class ProfileManager : IDisposable
//performance: using textual override for ProfileAppliesTo here to not call
//GetGameObjectName every time we are trying to check object against profiles
if (_objectManager.LobbyActor.Valid &&
_objectManager.TryGetValue(actorIdentifier, out var actorData) &&
actorData.Objects.Count == 1 &&
_objectManager.LobbyActor == actorData.Objects[0] && !_configuration.ProfileApplicationSettings.ApplyInLobby)
yield break;
(actorIdentifier, _) = _gameObjectService.GetTrueActorForSpecialTypeActor(actorIdentifier);
if (!actorIdentifier.IsValid)
@@ -499,7 +509,6 @@ public class ProfileManager : IDisposable
actorIdentifier.PlayerName != _actorManager.GetCurrentPlayer().PlayerName));
}
if (_templateEditorManager.IsEditorActive && _templateEditorManager.EditorProfile.Enabled && IsProfileAppliesToCurrentActor(_templateEditorManager.EditorProfile))
yield return _templateEditorManager.EditorProfile;

View File

@@ -122,7 +122,7 @@ public class StateMonitoringTab
ImGui.Text($"Count: {kvPair.Value.Objects.Count}");
foreach (var item in kvPair.Value.Objects)
{
ImGui.Text($"{item}, valid: {item.Valid}");
ImGui.Text($"[{item.Index}] - {item}, valid: {item.Valid}");
}
ImGui.Spacing();

View File

@@ -104,6 +104,7 @@ public class SettingsTab
DrawApplyInTryOnCheckbox();
DrawApplyInCardsCheckbox();
DrawApplyInInspectCheckbox();
DrawApplyInLobbyCheckbox();
}
private void DrawApplyInCharacterWindowCheckbox()
@@ -157,6 +158,19 @@ public class SettingsTab
_armatureManager.RebindAllArmatures();
}
}
private void DrawApplyInLobbyCheckbox()
{
var isChecked = _configuration.ProfileApplicationSettings.ApplyInLobby;
if (CtrlHelper.CheckboxWithTextAndHelp("##applyinlobby", "Apply Profiles on Character Select Screen",
"Apply appropriate profile for the character you have currently selected on character select screen during login.", ref isChecked))
{
_configuration.ProfileApplicationSettings.ApplyInLobby = isChecked;
_configuration.Save();
_armatureManager.RebindAllArmatures();
}
}
#endregion
#region Chat Commands Settings