some profile ui rework
This commit is contained in:
@@ -57,15 +57,16 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase
|
||||
Mods = 4
|
||||
}
|
||||
|
||||
public string? PlayerName { get; private set; }
|
||||
public string PlayerNameHash => OnlineUser.Ident;
|
||||
private OnlineUserIdentDto OnlineUser { get; set; }
|
||||
public IntPtr PlayerCharacter => _charaHandler?.Address ?? IntPtr.Zero;
|
||||
|
||||
public unsafe uint PlayerCharacterId => (_charaHandler?.Address ?? IntPtr.Zero) == IntPtr.Zero
|
||||
? uint.MaxValue
|
||||
: ((GameObject*)_charaHandler.Address)->ObjectID;
|
||||
|
||||
public string? PlayerName { get; private set; }
|
||||
public string PlayerNameHash => OnlineUser.Ident;
|
||||
private OnlineUserIdentDto OnlineUser { get; set; }
|
||||
|
||||
public void ApplyCharacterData(CharacterData characterData, OptionalPluginWarning warning, bool forced = false)
|
||||
{
|
||||
SetUploading(false);
|
||||
@@ -339,21 +340,21 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase
|
||||
}
|
||||
|
||||
bool heelsOffsetDifferent = oldData.HeelsOffset != newData.HeelsOffset;
|
||||
if (heelsOffsetDifferent || forced)
|
||||
if (heelsOffsetDifferent || (forced && newData.HeelsOffset != 0))
|
||||
{
|
||||
Logger.LogDebug("Updating {object}/{kind} (Diff heels data) => {change}", this, objectKind, PlayerChanges.Heels);
|
||||
charaDataToUpdate[objectKind].Add(PlayerChanges.Heels);
|
||||
}
|
||||
|
||||
bool customizeDataDifferent = !string.Equals(oldData.CustomizePlusData, newData.CustomizePlusData, StringComparison.Ordinal);
|
||||
if (customizeDataDifferent || forced)
|
||||
if (customizeDataDifferent || (forced && !string.IsNullOrEmpty(newData.CustomizePlusData)))
|
||||
{
|
||||
Logger.LogDebug("Updating {object}/{kind} (Diff customize data) => {change}", this, objectKind, PlayerChanges.Customize);
|
||||
charaDataToUpdate[objectKind].Add(PlayerChanges.Customize);
|
||||
}
|
||||
|
||||
bool palettePlusDataDifferent = !string.Equals(oldData.PalettePlusData, newData.PalettePlusData, StringComparison.Ordinal);
|
||||
if (palettePlusDataDifferent || forced)
|
||||
if (palettePlusDataDifferent || (forced && !string.IsNullOrEmpty(newData.PalettePlusData)))
|
||||
{
|
||||
Logger.LogDebug("Updating {object}/{kind} (Diff palette data) => {change}", this, objectKind, PlayerChanges.Palette);
|
||||
charaDataToUpdate[objectKind].Add(PlayerChanges.Palette);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Dalamud.ContextMenu;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Utility;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Comparer;
|
||||
@@ -7,6 +6,7 @@ using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -18,14 +18,17 @@ public class Pair
|
||||
private readonly Func<OnlineUserIdentDto, CachedPlayer> _cachedPlayerFactory;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly ILogger<Pair> _logger;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private OnlineUserIdentDto? _onlineUserIdentDto = null;
|
||||
private OptionalPluginWarning? _pluginWarnings;
|
||||
|
||||
public Pair(ILogger<Pair> logger, Func<OnlineUserIdentDto, CachedPlayer> cachedPlayerFactory, MareConfigService configService, ServerConfigurationManager serverConfigurationManager)
|
||||
public Pair(ILogger<Pair> logger, Func<OnlineUserIdentDto, CachedPlayer> cachedPlayerFactory,
|
||||
MareMediator mediator, MareConfigService configService, ServerConfigurationManager serverConfigurationManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_cachedPlayerFactory = cachedPlayerFactory;
|
||||
_mediator = mediator;
|
||||
_configService = configService;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
}
|
||||
@@ -46,6 +49,30 @@ public class Pair
|
||||
public UserPairDto? UserPair { get; set; }
|
||||
private CachedPlayer? CachedPlayer { get; set; }
|
||||
|
||||
public void AddContextMenu(GameObjectContextMenuOpenArgs args)
|
||||
{
|
||||
if (CachedPlayer == null || args.ObjectId != CachedPlayer.PlayerCharacterId) return;
|
||||
|
||||
if (!IsPaused)
|
||||
{
|
||||
args.AddCustomItem(new GameObjectContextMenuItem("[Mare] Open Profile", (a) =>
|
||||
{
|
||||
_mediator.Publish(new ProfileOpenStandaloneMessage(this));
|
||||
}));
|
||||
}
|
||||
args.AddCustomItem(new GameObjectContextMenuItem("[Mare] Reapply last data", (a) =>
|
||||
{
|
||||
ApplyLastReceivedData(true);
|
||||
}, false));
|
||||
if (UserPair != null && UserPair.OtherPermissions.IsPaired() && UserPair.OwnPermissions.IsPaired())
|
||||
{
|
||||
args.AddCustomItem(new GameObjectContextMenuItem("[Mare] Cycle pause state", (a) =>
|
||||
{
|
||||
_mediator.Publish(new CyclePauseMessage(UserData));
|
||||
}, false));
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyData(OnlineUserCharaDataDto data)
|
||||
{
|
||||
if (CachedPlayer == null) throw new InvalidOperationException("CachedPlayer not initialized");
|
||||
@@ -172,14 +199,4 @@ public class Pair
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void AddContextMenu(GameObjectContextMenuOpenArgs args)
|
||||
{
|
||||
if (CachedPlayer == null || args.ObjectId != CachedPlayer.PlayerCharacterId) return;
|
||||
|
||||
args.AddCustomItem(new GameObjectContextMenuItem("Reapply last data", (a) =>
|
||||
{
|
||||
ApplyLastReceivedData(true);
|
||||
} ,true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user