Clean code
This commit is contained in:
@@ -46,7 +46,6 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
|
||||
public override bool DrawConditions()
|
||||
{
|
||||
// Visible when explicitly opened; allow drawing even if discovery is disabled to show hint
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -168,8 +167,6 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Fallback on alias/name (legacy compatibility)
|
||||
var key = NormalizeKey(e.DisplayName ?? e.Name);
|
||||
if (string.IsNullOrEmpty(key)) return false;
|
||||
foreach (var p in _pairManager.DirectPairs)
|
||||
@@ -180,7 +177,6 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -386,8 +386,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
var onUmbra = _nearbyEntries?.Count(e => e.IsMatch) ?? 0;
|
||||
ImGui.TextUnformatted($"Nearby ({onUmbra})");
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) _nearbyOpen = !_nearbyOpen;
|
||||
|
||||
// Header action button to open Nearby window
|
||||
var btnWidth = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.UserPlus, "Nearby");
|
||||
var headerRight = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||
ImGui.SameLine();
|
||||
@@ -413,16 +411,12 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
foreach (var e in nearby)
|
||||
{
|
||||
// name
|
||||
var name = e.DisplayName ?? e.Name;
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(name);
|
||||
|
||||
// right side status/action
|
||||
var right = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||
ImGui.SameLine();
|
||||
|
||||
// detect if already paired (prefer UID if present)
|
||||
bool isPaired = false;
|
||||
try
|
||||
{
|
||||
@@ -430,7 +424,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
catch
|
||||
{
|
||||
// fall back to display name/alias matching if UID is not available
|
||||
var key = (e.DisplayName ?? e.Name) ?? string.Empty;
|
||||
isPaired = _pairManager.DirectPairs.Any(p => string.Equals(p.UserData.AliasOrUID, key, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
@@ -441,12 +434,10 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
|
||||
if (isPaired || !e.AcceptPairRequests)
|
||||
{
|
||||
// just paint the status
|
||||
ImGui.TextUnformatted(statusText);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no direct send from Compact; open Nearby window to send the invite there
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserPlus, "Invite", statusSize.X))
|
||||
{
|
||||
Mediator.Publish(new UiToggleMessage(typeof(AutoDetectUi)));
|
||||
@@ -454,8 +445,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pending Nearby requests (Accept / Dismiss)
|
||||
try
|
||||
{
|
||||
var inbox = _nearbyPending;
|
||||
@@ -606,8 +595,6 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
ImGui.SameLine(WindowContentWidth - textSize.X);
|
||||
ImGui.TextUnformatted(downloadText);
|
||||
}
|
||||
|
||||
// Space for three equal-width buttons laid out precisely (avoid overlap/wrap)
|
||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||
var bottomButtonWidth = (WindowContentWidth - spacing) / 2f;
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Character Analysis", bottomButtonWidth))
|
||||
@@ -646,7 +633,7 @@ public class CompactUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
UiSharedService.AttachToolTip("Open the UmbraSync Settings");
|
||||
|
||||
ImGui.SameLine(); //Important to draw the uidText consistently
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPos(originalPos);
|
||||
|
||||
if (_apiController.ServerState is ServerState.Connected)
|
||||
|
||||
@@ -44,10 +44,6 @@ public class DrawGroupPair : DrawPairBase
|
||||
var presenceText = entryUID + " is offline";
|
||||
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
|
||||
// We'll draw an optional prefix icon (pause or paired-moon). If we draw one,
|
||||
// we add a SameLine() before drawing the presence icon. Otherwise, we draw
|
||||
// the presence icon directly at the current cursor position to avoid gaps.
|
||||
bool drewPrefixIcon = false;
|
||||
|
||||
if (_pair.IsPaused)
|
||||
@@ -65,9 +61,6 @@ public class DrawGroupPair : DrawPairBase
|
||||
{
|
||||
bool individuallyPaired = _pair.UserPair != null;
|
||||
var violet = new Vector4(0.63f, 0.25f, 1f, 1f);
|
||||
|
||||
// Show a violet moon only when individually paired AND online/visible.
|
||||
// If offline or not individually paired, do not draw a moon at all.
|
||||
if (individuallyPaired && (_pair.IsOnline || _pair.IsVisible))
|
||||
{
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
@@ -77,8 +70,6 @@ public class DrawGroupPair : DrawPairBase
|
||||
drewPrefixIcon = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Presence status icon (eye when visible, cloud-moon otherwise)
|
||||
if (drewPrefixIcon)
|
||||
ImGui.SameLine();
|
||||
|
||||
|
||||
@@ -38,9 +38,7 @@ public class DrawUserPair : DrawPairBase
|
||||
|
||||
protected override void DrawLeftSide(float textPosY, float originalY)
|
||||
{
|
||||
// Primary presence indicator: moon (online = violet, offline = grey)
|
||||
var online = _pair.IsOnline;
|
||||
// Violet accent (#BA70EF)
|
||||
var violet = new Vector4(0.69f, 0.27f, 0.93f, 1f);
|
||||
var offlineGrey = ImGuiColors.DalamudGrey3;
|
||||
|
||||
@@ -51,9 +49,6 @@ public class DrawUserPair : DrawPairBase
|
||||
UiSharedService.AttachToolTip(online
|
||||
? "User is online"
|
||||
: "User is offline");
|
||||
|
||||
// Secondary pairing state badges (only if needed)
|
||||
// Not mutually paired -> red ArrowUp
|
||||
if (!(_pair.UserPair!.OwnPermissions.IsPaired() && _pair.UserPair!.OtherPermissions.IsPaired()))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
@@ -63,7 +58,6 @@ public class DrawUserPair : DrawPairBase
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has not added you back");
|
||||
}
|
||||
// Paused (either side) -> yellow PauseCircle
|
||||
else if (_pair.UserPair!.OwnPermissions.IsPaused() || _pair.UserPair!.OtherPermissions.IsPaused())
|
||||
{
|
||||
ImGui.SameLine();
|
||||
@@ -149,8 +143,6 @@ public class DrawUserPair : DrawPairBase
|
||||
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
|
||||
var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
|
||||
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
|
||||
|
||||
// Icon for individually applied permissions
|
||||
if (individualSoundsDisabled || individualAnimDisabled || individualVFXDisabled)
|
||||
{
|
||||
var icon = FontAwesomeIcon.ExclamationTriangle;
|
||||
@@ -205,8 +197,6 @@ public class DrawUserPair : DrawPairBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Icon for shared character data
|
||||
if (_charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData))
|
||||
{
|
||||
var icon = FontAwesomeIcon.Running;
|
||||
|
||||
@@ -54,17 +54,12 @@ public class PairGroupsUi
|
||||
ImGui.SameLine(buttonPauseOffset);
|
||||
if (_uiSharedService.IconButton(pauseButton))
|
||||
{
|
||||
// If all of the currently visible pairs (after applying filters to the pairs)
|
||||
// are paused we display a resume button to resume all currently visible (after filters)
|
||||
// pairs. Otherwise, we just pause all the remaining pairs.
|
||||
if (allArePaused)
|
||||
{
|
||||
// If all are paused => resume all
|
||||
ResumeAllPairs(availablePairsInThisTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise pause all remaining
|
||||
PauseRemainingPairs(availablePairsInThisTag);
|
||||
}
|
||||
}
|
||||
@@ -120,7 +115,6 @@ public class PairGroupsUi
|
||||
}
|
||||
else
|
||||
{
|
||||
// Avoid uncomfortably close group names
|
||||
if (!_tagHandler.IsTagOpen(tag))
|
||||
{
|
||||
var size = ImGui.CalcTextSize("").Y + ImGui.GetStyle().FramePadding.Y * 2f;
|
||||
@@ -163,8 +157,6 @@ public class PairGroupsUi
|
||||
};
|
||||
|
||||
string resultFolderName = !isSpecialTag ? $"{displayedName} ({visible}/{online}/{total} Pairs)" : $"{displayedName} ({online} Pairs)";
|
||||
|
||||
// FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight
|
||||
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
|
||||
_uiSharedService.IconText(icon);
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
|
||||
@@ -15,20 +15,8 @@ public class SelectGroupForPairUi
|
||||
private readonly UidDisplayHandler _uidDisplayHandler;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
|
||||
/// <summary>
|
||||
/// The group UI is always open for a specific pair. This defines which pair the UI is open for.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Pair? _pair;
|
||||
|
||||
/// <summary>
|
||||
/// Should the panel show, yes/no
|
||||
/// </summary>
|
||||
private bool _show;
|
||||
|
||||
/// <summary>
|
||||
/// For the add category option, this stores the currently typed in tag name
|
||||
/// </summary>
|
||||
private string _tagNameToAdd = "";
|
||||
|
||||
public SelectGroupForPairUi(TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, UiSharedService uiSharedService)
|
||||
@@ -49,7 +37,6 @@ public class SelectGroupForPairUi
|
||||
|
||||
var name = PairName(_pair);
|
||||
var popupName = $"Choose Groups for {name}";
|
||||
// Is the popup supposed to show but did not open yet? Open it
|
||||
if (_show)
|
||||
{
|
||||
ImGui.OpenPopup(popupName);
|
||||
@@ -91,10 +78,6 @@ public class SelectGroupForPairUi
|
||||
public void Open(Pair pair)
|
||||
{
|
||||
_pair = pair;
|
||||
// Using "_show" here to de-couple the opening of the popup
|
||||
// The popup name is derived from the name the user currently sees, which is
|
||||
// based on the showUidForEntry dictionary.
|
||||
// We'd have to derive the name here to open it popup modal here, when the Open() is called
|
||||
_show = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -547,7 +547,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
|
||||
if (ImGui.Checkbox($"Enable chat for this syncshell##{gid}", ref shellEnabled))
|
||||
{
|
||||
// If there is an active group with the same syncshell number, pick a new one
|
||||
int nextNumber = 1;
|
||||
bool conflict = false;
|
||||
foreach (var otherGroup in _pairManager.Groups)
|
||||
@@ -567,17 +566,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
using var pushDisabled = ImRaii.Disabled(!shellEnabled);
|
||||
|
||||
ImGui.SetNextItemWidth(50 * ImGuiHelpers.GlobalScale);
|
||||
|
||||
// _uiShared.DrawCombo() remembers the selected option -- we don't want that, because the value can change
|
||||
if (ImGui.BeginCombo("Syncshell number##{gid}", $"{shellNumber}"))
|
||||
{
|
||||
// Same hard-coded number in CommandManagerService
|
||||
for (int i = 1; i <= ChatService.CommandMaxNumber; ++i)
|
||||
{
|
||||
if (ImGui.Selectable($"{i}", i == shellNumber))
|
||||
{
|
||||
// Find an active group with the same syncshell number as selected, and swap it
|
||||
// This logic can leave duplicate IDs present in the config but its not critical
|
||||
|
||||
foreach (var otherGroup in _pairManager.Groups)
|
||||
{
|
||||
if (gid.Equals(otherGroup.Key.GID, StringComparison.Ordinal)) continue;
|
||||
@@ -1665,8 +1660,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
string selectedKeyName = string.Empty;
|
||||
if (selectedServer.SecretKeys.TryGetValue(item.SecretKeyIdx, out var selectedKey))
|
||||
selectedKeyName = selectedKey.FriendlyName;
|
||||
|
||||
// _uiShared.DrawCombo() remembers the selected option -- we don't want that, because the value can change
|
||||
if (ImGui.BeginCombo($"##{item.CharacterName}{i}", selectedKeyName))
|
||||
{
|
||||
foreach (var key in selectedServer.SecretKeys)
|
||||
@@ -1945,7 +1938,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
ImGui.BeginDisabled(_registrationInProgress);
|
||||
DrawServerConfiguration();
|
||||
ImGui.EndTabItem();
|
||||
ImGui.EndDisabled(); // _registrationInProgress
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTabItem("Chat"))
|
||||
|
||||
@@ -14,7 +14,6 @@ public class DiscoveryApiClient
|
||||
private readonly DiscoveryConfigProvider _configProvider;
|
||||
private readonly HttpClient _httpClient = new();
|
||||
private static readonly JsonSerializerOptions JsonOpt = new() { PropertyNameCaseInsensitive = true };
|
||||
// private readonly ISaltProvider _saltProvider; // For future use if needed
|
||||
|
||||
public DiscoveryApiClient(ILogger<DiscoveryApiClient> logger, TokenProvider tokenProvider, DiscoveryConfigProvider configProvider)
|
||||
{
|
||||
@@ -41,7 +40,6 @@ public class DiscoveryApiClient
|
||||
var resp = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
|
||||
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
// Retry once with a fresh token
|
||||
var token2 = await _tokenProvider.GetOrUpdateToken(ct).ConfigureAwait(false);
|
||||
if (string.IsNullOrEmpty(token2)) return [];
|
||||
using var req2 = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
||||
@@ -178,7 +176,6 @@ public class DiscoveryApiClient
|
||||
if (string.IsNullOrEmpty(jwt)) return;
|
||||
using var req = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
||||
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", jwt);
|
||||
// no body required
|
||||
var resp = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
|
||||
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user