Track and display last known player names automatically

This commit is contained in:
Loporrit
2024-02-16 07:11:10 +00:00
parent 4091df858f
commit ab996692e3
15 changed files with 86 additions and 44 deletions

View File

@@ -368,11 +368,7 @@ public class CompactUi : WindowMediatorSubscriberBase
var ySize = TransferPartHeight == 0
? 1
: (ImGui.GetWindowContentRegionMax().Y - ImGui.GetWindowContentRegionMin().Y) - TransferPartHeight - ImGui.GetCursorPosY();
var users = GetFilteredUsers()
.OrderBy(
u => _configService.Current.ShowCharacterNameInsteadOfNotesForVisible && !string.IsNullOrEmpty(u.PlayerName)
? (_configService.Current.PreferNotesOverNamesForVisible ? u.GetNote() : u.PlayerName)
: (u.GetNote() ?? u.UserData.AliasOrUID), StringComparer.OrdinalIgnoreCase).ToList();
var users = GetFilteredUsers().OrderBy(u => u.GetNoteOrName());
var onlineUsers = users.Where(u => u.UserPair!.OtherPermissions.IsPaired() && (u.IsOnline || u.UserPair!.OwnPermissions.IsPaused())).Select(c => new DrawUserPair("Online" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi)).ToList();
var visibleUsers = users.Where(u => u.IsVisible).Select(c => new DrawUserPair("Visible" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi)).ToList();

View File

@@ -399,7 +399,7 @@ internal sealed class GroupPanel
.OrderByDescending(u => string.Equals(u.UserData.UID, groupDto.OwnerUID, StringComparison.Ordinal))
.ThenByDescending(u => u.GroupPair[groupDto].GroupPairStatusInfo.IsModerator())
.ThenByDescending(u => u.GroupPair[groupDto].GroupPairStatusInfo.IsPinned())
.ThenBy(u => u.GetNote() ?? u.UserData.AliasOrUID, StringComparer.OrdinalIgnoreCase);
.ThenBy(u => u.GetNoteOrName() ?? u.UserData.AliasOrUID, StringComparer.OrdinalIgnoreCase);
var visibleUsers = new List<DrawGroupPair>();
var onlineUsers = new List<DrawGroupPair>();

View File

@@ -144,13 +144,13 @@ public sealed class DtrEntry : IDisposable, IHostedService
{
visiblePairs = _pairManager.GetOnlineUserPairs()
.Where(x => x.IsVisible)
.Select(x => string.Format("{0} ({1})", _configService.Current.PreferNoteInDtrTooltip ? x.GetNote() ?? x.PlayerName : x.PlayerName, x.UserData.AliasOrUID ));
.Select(x => string.Format("{0} ({1})", _configService.Current.PreferNoteInDtrTooltip ? x.GetNoteOrName() : x.PlayerName, x.UserData.AliasOrUID ));
}
else
{
visiblePairs = _pairManager.GetOnlineUserPairs()
.Where(x => x.IsVisible)
.Select(x => string.Format("{0}", _configService.Current.PreferNoteInDtrTooltip ? x.GetNote() ?? x.PlayerName : x.PlayerName));
.Select(x => string.Format("{0}", _configService.Current.PreferNoteInDtrTooltip ? x.GetNoteOrName() : x.PlayerName));
}
tooltip = $"Loporrit: Connected{Environment.NewLine}----------{Environment.NewLine}{string.Join(Environment.NewLine, visiblePairs)}";

View File

@@ -165,12 +165,13 @@ public class UidDisplayHandler
playerText = pair.UserData.AliasOrUID;
}
if (_mareConfigService.Current.ShowCharacterNameInsteadOfNotesForVisible && pair.IsVisible && !showUidInsteadOfName)
if (_mareConfigService.Current.ShowCharacterNames && textIsUid && !showUidInsteadOfName)
{
playerText = pair.PlayerName;
textIsUid = false;
if (_mareConfigService.Current.PreferNotesOverNamesForVisible)
var name = pair.PlayerName;
if (name != null)
{
playerText = name;
textIsUid = false;
var note = pair.GetNote();
if (note != null)
{

View File

@@ -653,7 +653,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Separator();
UiSharedService.FontText("UI", _uiShared.UidFont);
var showNameInsteadOfNotes = _configService.Current.ShowCharacterNameInsteadOfNotesForVisible;
var showCharacterNames = _configService.Current.ShowCharacterNames;
var showVisibleSeparate = _configService.Current.ShowVisibleUsersSeparately;
var showOfflineSeparate = _configService.Current.ShowOfflineUsersSeparately;
var showProfiles = _configService.Current.ProfilesShow;
@@ -718,23 +718,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
UiSharedService.DrawHelpText("This will show all currently offline users in a special 'Offline' group in the main UI.");
if (ImGui.Checkbox("Show player name for visible players", ref showNameInsteadOfNotes))
if (ImGui.Checkbox("Show player names", ref showCharacterNames))
{
_configService.Current.ShowCharacterNameInsteadOfNotesForVisible = showNameInsteadOfNotes;
_configService.Current.ShowCharacterNames = showCharacterNames;
_configService.Save();
}
UiSharedService.DrawHelpText("This will show the character name instead of custom set note when a character is visible");
ImGui.Indent();
if (!_configService.Current.ShowCharacterNameInsteadOfNotesForVisible) ImGui.BeginDisabled();
if (ImGui.Checkbox("Prefer notes over player names for visible players", ref preferNotesInsteadOfName))
{
_configService.Current.PreferNotesOverNamesForVisible = preferNotesInsteadOfName;
_configService.Save();
}
UiSharedService.DrawHelpText("If you set a note for a player it will be shown instead of the player name");
if (!_configService.Current.ShowCharacterNameInsteadOfNotesForVisible) ImGui.EndDisabled();
ImGui.Unindent();
UiSharedService.DrawHelpText("This will show character names instead of UIDs when possible");
if (ImGui.Checkbox("Show Profiles on Hover", ref showProfiles))
{

View File

@@ -155,9 +155,10 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.TableNextColumn(); // online/name
string onlineText = pair.Key.IsOnline ? "Online" : "Offline";
if (!string.IsNullOrEmpty(pair.Key.PlayerName))
string? name = pair.Key.GetNoteOrName();
if (!string.IsNullOrEmpty(name))
{
onlineText += " (" + pair.Key.PlayerName + ")";
onlineText += " (" + name + ")";
}
var boolcolor = UiSharedService.GetBoolColor(pair.Key.IsOnline);
ImGui.AlignTextToFramePadding();