Add list removal to context menu and more aggressively redraw on perf setting changes

This commit is contained in:
Loporrit
2025-02-22 02:06:08 +00:00
parent 06c2d8b007
commit bb6f219546
2 changed files with 39 additions and 48 deletions

View File

@@ -106,7 +106,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
{ {
if (msg.UID != null && !msg.UID.Equals(Pair.UserData.UID, StringComparison.Ordinal)) return; if (msg.UID != null && !msg.UID.Equals(Pair.UserData.UID, StringComparison.Ordinal)) return;
Logger.LogDebug("Recalculating performance for {uid}", Pair.UserData.UID); Logger.LogDebug("Recalculating performance for {uid}", Pair.UserData.UID);
pair.ApplyLastReceivedData(); pair.ApplyLastReceivedData(forced: true);
}); });
LastAppliedDataBytes = -1; LastAppliedDataBytes = -1;

View File

@@ -1,4 +1,5 @@
using Dalamud.Game.Gui.ContextMenu; using Dalamud.Game.Gui.ContextMenu;
using Dalamud.Game.Text.SeStringHandling;
using MareSynchronos.API.Data; using MareSynchronos.API.Data;
using MareSynchronos.API.Data.Comparer; using MareSynchronos.API.Data.Comparer;
using MareSynchronos.API.Data.Enum; using MareSynchronos.API.Data.Enum;
@@ -77,64 +78,54 @@ public class Pair : DisposableMediatorSubscriberBase
{ {
if (CachedPlayer == null || (args.Target is not MenuTargetDefault target) || target.TargetObjectId != CachedPlayer.PlayerCharacterId || IsPaused) return; if (CachedPlayer == null || (args.Target is not MenuTargetDefault target) || target.TargetObjectId != CachedPlayer.PlayerCharacterId || IsPaused) return;
args.AddMenuItem(new MenuItem() void Add(string name, Action<IMenuItemClickedArgs>? action)
{
Name = "Open Profile",
OnClicked = (a) => Mediator.Publish(new ProfileOpenStandaloneMessage(this)),
PrefixColor = 559,
PrefixChar = 'L'
});
if (!IsApplicationBlocked)
{ {
args.AddMenuItem(new MenuItem() args.AddMenuItem(new MenuItem()
{ {
Name = "Always Block Modded Appearance", Name = name,
OnClicked = (a) => { OnClicked = action,
PrefixColor = 559,
PrefixChar = 'L'
});
}
bool isBlocked = IsApplicationBlocked;
bool isBlacklisted = _serverConfigurationManager.IsUidBlacklisted(UserData.UID);
bool isWhitelisted = _serverConfigurationManager.IsUidWhitelisted(UserData.UID);
Add("Open Profile", _ => Mediator.Publish(new ProfileOpenStandaloneMessage(this)));
if (!isBlocked && !isBlacklisted)
Add("Always Block Modded Appearance", _ => {
_serverConfigurationManager.AddBlacklistUid(UserData.UID); _serverConfigurationManager.AddBlacklistUid(UserData.UID);
HoldApplication("Blacklist", maxValue: 1); HoldApplication("Blacklist", maxValue: 1);
}, ApplyLastReceivedData(forced: true);
PrefixColor = 559, });
PrefixChar = 'L', else if (isBlocked && !isWhitelisted)
}); Add("Always Allow Modded Appearance", _ => {
args.AddMenuItem(new MenuItem()
{
Name = "Reapply last data",
OnClicked = (a) => ApplyLastReceivedData(forced: true),
PrefixColor = 559,
PrefixChar = 'L',
});
}
else
{
args.AddMenuItem(new MenuItem()
{
Name = "Always Allow Modded Appearance",
OnClicked = (a) => {
_serverConfigurationManager.AddWhitelistUid(UserData.UID); _serverConfigurationManager.AddWhitelistUid(UserData.UID);
UnholdApplication("Blacklist", skipApplication: true); UnholdApplication("Blacklist", skipApplication: true);
// FIXME: Manually applying here should not be needed here if everything else was written properly
ApplyLastReceivedData(forced: true); ApplyLastReceivedData(forced: true);
}, });
PrefixColor = 559,
PrefixChar = 'L', if (isWhitelisted)
Add("Remove from Whitelist", _ => {
_serverConfigurationManager.RemoveWhitelistUid(UserData.UID);
ApplyLastReceivedData(forced: true);
}); });
} else if (isBlacklisted)
Add("Remove from Blacklist", _ => {
_serverConfigurationManager.RemoveBlacklistUid(UserData.UID);
UnholdApplication("Blacklist", skipApplication: true);
ApplyLastReceivedData(forced: true);
});
Add("Reapply last data", _ => ApplyLastReceivedData(forced: true));
if (UserPair != null) if (UserPair != null)
{ {
args.AddMenuItem(new MenuItem() Add("Change Permissions", _ => Mediator.Publish(new OpenPermissionWindow(this)));
{ Add("Cycle pause state", _ => Mediator.Publish(new CyclePauseMessage(UserData)));
Name = "Change Permissions",
OnClicked = (a) => Mediator.Publish(new OpenPermissionWindow(this)),
PrefixColor = 559,
PrefixChar = 'L',
});
args.AddMenuItem(new MenuItem()
{
Name = "Cycle pause state",
OnClicked = (a) => Mediator.Publish(new CyclePauseMessage(UserData)),
PrefixColor = 559,
PrefixChar = 'L',
});
} }
} }