Merge remote-tracking branch 'origin/2.0.2-Location' into 2.0.0-crashing-bugfixes

# Conflicts:
#	LightlessSync/UI/DtrEntry.cs
This commit is contained in:
choco
2025-12-27 23:13:20 +01:00
24 changed files with 362 additions and 124 deletions

View File

@@ -131,6 +131,7 @@ public class DrawFolderGroup : DrawFolderBase
bool disableSounds = perm.IsDisableSounds();
bool disableAnims = perm.IsDisableAnimations();
bool disableVfx = perm.IsDisableVFX();
bool shareLocation = perm.IsSharingLocation();
if ((_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != disableAnims
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != disableSounds
@@ -164,6 +165,13 @@ public class DrawFolderGroup : DrawFolderBase
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
ImGui.CloseCurrentPopup();
}
if (_uiSharedService.IconTextButton(!shareLocation ? FontAwesomeIcon.Globe : FontAwesomeIcon.StopCircle, !shareLocation ? "Share your location to all users in Syncshell" : "STOP Share your location to all users in Syncshell", menuWidth, true))
{
perm.SetShareLocation(!shareLocation);
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
ImGui.CloseCurrentPopup();
}
if (IsModerator || IsOwner)
{

View File

@@ -37,6 +37,7 @@ public class DrawUserPair
private readonly UiSharedService _uiSharedService;
private readonly PlayerPerformanceConfigService _performanceConfigService;
private readonly LightlessConfigService _configService;
private readonly LocationShareService _locationShareService;
private readonly CharaDataManager _charaDataManager;
private readonly PairLedger _pairLedger;
private float _menuWidth = -1;
@@ -57,6 +58,7 @@ public class DrawUserPair
UiSharedService uiSharedService,
PlayerPerformanceConfigService performanceConfigService,
LightlessConfigService configService,
LocationShareService locationShareService,
CharaDataManager charaDataManager,
PairLedger pairLedger)
{
@@ -74,6 +76,7 @@ public class DrawUserPair
_uiSharedService = uiSharedService;
_performanceConfigService = performanceConfigService;
_configService = configService;
_locationShareService = locationShareService;
_charaDataManager = charaDataManager;
_pairLedger = pairLedger;
}
@@ -216,6 +219,17 @@ public class DrawUserPair
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(_pair.UserData, permissions));
}
UiSharedService.AttachToolTip("Changes VFX sync permissions with this user." + (individual ? individualText : string.Empty));
var isShareingLocation = _pair.UserPair!.OwnPermissions.IsSharingLocation();
string isShareingLocationText = isShareingLocation ? "Disable location sharing" : "Enable location sharing";
var isShareingLocationIcon = isShareingLocation ? FontAwesomeIcon.StopCircle : FontAwesomeIcon.Globe;
if (_uiSharedService.IconTextButton(isShareingLocationIcon, isShareingLocationText, _menuWidth, true))
{
var permissions = _pair.UserPair.OwnPermissions;
permissions.SetShareLocation(!isShareingLocation);
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(_pair.UserData, permissions));
}
UiSharedService.AttachToolTip("Changes location sharing permissions with this user." + (individual ? individualText : string.Empty));
}
private void DrawIndividualMenu()
@@ -567,6 +581,7 @@ public class DrawUserPair
: UiSharedService.TooltipSeparator + "Hold CTRL to enable preferred permissions while pausing." + Environment.NewLine + "This will leave this pair paused even if unpausing syncshells including this pair."))
: "Resume pairing with " + _pair.UserData.AliasOrUID);
//Location sharing
if (_pair.IsPaired)
{
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
@@ -574,6 +589,66 @@ public class DrawUserPair
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
var individualIsSticky = _pair.UserPair!.OwnPermissions.IsSticky();
var individualIcon = individualIsSticky ? FontAwesomeIcon.ArrowCircleUp : FontAwesomeIcon.InfoCircle;
var shareLocationIcon = FontAwesomeIcon.Globe;
var shareLocation = _pair.UserPair?.OwnPermissions.IsSharingLocation() ?? false;
var shareLocationOther = _pair.UserPair?.OtherPermissions.IsSharingLocation() ?? false;
var shareColor = shareLocation switch
{
true when shareLocationOther => UIColors.Get("LightlessGreen"),
false when shareLocationOther => UIColors.Get("LightlessBlue"),
_ => UIColors.Get("LightlessYellow"),
};
if (shareLocation || shareLocationOther)
{
currentRightSide -= (_uiSharedService.GetIconSize(shareLocationIcon).X + spacingX);
ImGui.SameLine(currentRightSide);
using (ImRaii.PushColor(ImGuiCol.Text, shareColor, shareLocation || shareLocationOther))
_uiSharedService.IconText(shareLocationIcon);
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
if (shareLocationOther)
{
var location = _locationShareService.GetUserLocation(_pair.UserPair!.User.UID);
if (_pair.IsOnline)
{
if (!string.IsNullOrEmpty(location))
{
_uiSharedService.IconText(FontAwesomeIcon.LocationArrow);
ImGui.SameLine();
ImGui.TextUnformatted(location);
}
else
{
ImGui.TextUnformatted("Location info not updated, reconnect or waiting for zone-changing.");
}
}
else
{
ImGui.TextUnformatted("User not onlineㄟ( ▔, ▔ )ㄏ");
}
}
else
{
ImGui.TextUnformatted("NOT Sharing location with you.(⊙x⊙;)");
}
ImGui.Separator();
if (shareLocation)
{
ImGui.TextUnformatted("Sharing your location.ヾ(•ω•`)o");
}
else
{
ImGui.TextUnformatted("NOT sharing your location.(´。_。`)");
}
ImGui.EndTooltip();
}
}
if (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled || individualIsSticky)
{

View File

@@ -28,6 +28,7 @@ public class DrawEntityFactory
private readonly ServerConfigurationManager _serverConfigurationManager;
private readonly LightlessConfigService _configService;
private readonly UiSharedService _uiSharedService;
private readonly LocationShareService _locationShareService;
private readonly PlayerPerformanceConfigService _playerPerformanceConfigService;
private readonly CharaDataManager _charaDataManager;
private readonly SelectTagForPairUi _selectTagForPairUi;
@@ -52,6 +53,7 @@ public class DrawEntityFactory
ServerConfigurationManager serverConfigurationManager,
LightlessConfigService configService,
UiSharedService uiSharedService,
LocationShareService locationShareService,
PlayerPerformanceConfigService playerPerformanceConfigService,
CharaDataManager charaDataManager,
SelectTagForSyncshellUi selectTagForSyncshellUi,
@@ -71,6 +73,7 @@ public class DrawEntityFactory
_serverConfigurationManager = serverConfigurationManager;
_configService = configService;
_uiSharedService = uiSharedService;
_locationShareService = locationShareService;
_playerPerformanceConfigService = playerPerformanceConfigService;
_charaDataManager = charaDataManager;
_selectTagForSyncshellUi = selectTagForSyncshellUi;
@@ -162,6 +165,7 @@ public class DrawEntityFactory
_uiSharedService,
_playerPerformanceConfigService,
_configService,
_locationShareService,
_charaDataManager,
_pairLedger);
}

View File

@@ -364,28 +364,21 @@ public sealed class DtrEntry : IDisposable, IHostedService
return;
}
_ = Task.Run(async () =>
try
{
try
var cid = _dalamudUtilService.GetCID();
var hashedCid = cid.ToString().GetHash256();
_localHashedCid = hashedCid;
_localHashedCidFetchedAt = now;
return hashedCid;
}
catch (Exception ex)
{
if (now >= _localHashedCidNextErrorLog)
{
var cid = await _dalamudUtilService.GetCIDAsync().ConfigureAwait(false);
var hashedCid = cid.ToString().GetHash256();
lock (_localHashedCidLock)
{
_localHashedCid = hashedCid;
_localHashedCidFetchedAt = DateTime.UtcNow;
}
_logger.LogDebug(ex, "Failed to refresh local hashed CID for Lightfinder DTR entry.");
_localHashedCidNextErrorLog = now + _localHashedCidErrorCooldown;
}
catch (Exception ex)
{
var now = DateTime.UtcNow;
lock (_localHashedCidLock)
{
if (now >= _localHashedCidNextErrorLog)
{
_logger.LogDebug(ex, "Failed to refresh local hashed CID for Lightfinder DTR entry.");
_localHashedCidNextErrorLog = now + _localHashedCidErrorCooldown;
}
_localHashedCid = null;
_localHashedCidFetchedAt = now;

View File

@@ -43,6 +43,7 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
var disableSounds = _ownPermissions.IsDisableSounds();
var disableAnimations = _ownPermissions.IsDisableAnimations();
var disableVfx = _ownPermissions.IsDisableVFX();
var shareLocation = _ownPermissions.IsSharingLocation();
var style = ImGui.GetStyle();
var indentSize = ImGui.GetFrameHeight() + style.ItemSpacing.X;
@@ -70,6 +71,7 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
var otherDisableSounds = otherPerms.IsDisableSounds();
var otherDisableAnimations = otherPerms.IsDisableAnimations();
var otherDisableVFX = otherPerms.IsDisableVFX();
var otherShareLocation = otherPerms.IsSharingLocation();
using (ImRaii.PushIndent(indentSize, false))
{
@@ -124,6 +126,24 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding();
ImGui.Text(Pair.UserData.AliasOrUID + " has " + (!otherDisableVFX ? "not " : string.Empty) + "disabled VFX sync with you");
}
if (ImGui.Checkbox("Enable location Sharing", ref shareLocation))
{
_ownPermissions.SetShareLocation(shareLocation);
}
_uiSharedService.DrawHelpText("Enable location sharing will only effect your side." + UiSharedService.TooltipSeparator
+ "Note: this is NOT bidirectional, you can choose to share even others dont share with you.");
using (ImRaii.PushIndent(indentSize, false))
{
_uiSharedService.BooleanToColoredIcon(shareLocation, false);
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.Text((!shareLocation ? "Not" : string.Empty) + "sharing location with " + Pair.UserData.AliasOrUID + " .");
#if DEBUG
_uiSharedService.BooleanToColoredIcon(otherShareLocation, true);
#endif
}
ImGuiHelpers.ScaledDummy(0.5f);
ImGui.Separator();

View File

@@ -431,7 +431,7 @@ public class TopTabMenu
try
{
var myCidHash = (await _dalamudUtilService.GetCIDAsync().ConfigureAwait(false)).ToString().GetHash256();
var myCidHash = _dalamudUtilService.GetCID().ToString().GetHash256();
await _apiController.TryPairWithContentId(request.HashedCid).ConfigureAwait(false);
_pairRequestService.RemoveRequest(request.HashedCid);