fix: handle cross-world correctly again

This commit is contained in:
Anna 2024-08-08 17:52:22 -04:00
parent 5e4e443e4f
commit 542c05524b
Signed by: anna
GPG Key ID: D0943384CD9F87D1

View File

@ -348,6 +348,7 @@ public class Plugin : IDalamudPlugin {
Mana = member.Object != null ? member.Object->Mana : null, Mana = member.Object != null ? member.Object->Mana : null,
PartyListIndex = i, PartyListIndex = i,
ClassJob = member.Object != null ? member.Object->ClassJob : null, ClassJob = member.Object != null ? member.Object->ClassJob : null,
IsFullMember = member.Object != null,
}; };
names.Add(info); names.Add(info);
@ -357,6 +358,11 @@ public class Plugin : IDalamudPlugin {
var crossInfo = InfoProxyCrossRealm.Instance(); var crossInfo = InfoProxyCrossRealm.Instance();
if (crossInfo->IsInCrossRealmParty != 0) { if (crossInfo->IsInCrossRealmParty != 0) {
var crossGroup = crossInfo->CrossRealmGroups[crossInfo->LocalPlayerGroupIndex]; var crossGroup = crossInfo->CrossRealmGroups[crossInfo->LocalPlayerGroupIndex];
var fullMembers = AgentHUD.Instance()->PartyMembers;
var fullMemberIds = new uint[fullMembers.Length];
for (var i = 0; i < fullMembers.Length; i++) {
fullMemberIds[i] = fullMembers[i].EntityId;
}
for (var i = 0; i < crossGroup.GroupMemberCount && i < list->PartyMembers.Length; i++) { for (var i = 0; i < crossGroup.GroupMemberCount && i < list->PartyMembers.Length; i++) {
var member = crossGroup.GroupMembers[i]; var member = crossGroup.GroupMembers[i];
@ -380,6 +386,7 @@ public class Plugin : IDalamudPlugin {
Mana = null, Mana = null,
PartyListIndex = member.MemberIndex, PartyListIndex = member.MemberIndex,
ClassJob = member.ClassJobId, ClassJob = member.ClassJobId,
IsFullMember = Array.IndexOf(fullMemberIds, member.EntityId) != -1,
}; };
names.Add(info); names.Add(info);
@ -410,7 +417,7 @@ public class Plugin : IDalamudPlugin {
return false; return false;
} }
private unsafe (Pointer<AtkTextNode>, Pointer<AtkTextNode>) GetTextNodes(AddonPartyList.PartyListMemberStruct unit) { private static unsafe (Pointer<AtkTextNode>, Pointer<AtkTextNode>) GetTextNodes(AddonPartyList.PartyListMemberStruct unit) {
if (unit.MPGaugeBar == null) { if (unit.MPGaugeBar == null) {
return (null, null); return (null, null);
} }
@ -427,8 +434,8 @@ public class Plugin : IDalamudPlugin {
); );
} }
private unsafe void ResetTextColour(AddonPartyList.PartyListMemberStruct unit) { private static unsafe void ResetTextColour(AddonPartyList.PartyListMemberStruct unit) {
var (left, right) = this.GetTextNodes(unit); var (left, right) = GetTextNodes(unit);
if (left.Value == null) { if (left.Value == null) {
return; return;
@ -458,16 +465,22 @@ public class Plugin : IDalamudPlugin {
right.Value->MultiplyBlue = left.Value->MultiplyBlue; right.Value->MultiplyBlue = left.Value->MultiplyBlue;
} }
private unsafe void ResetManaText(AddonPartyList.PartyListMemberStruct unit, uint? mana) { private static unsafe void ResetManaText(AddonPartyList.PartyListMemberStruct unit, uint? mana) {
var (left, right) = this.GetTextNodes(unit); var (left, right) = GetTextNodes(unit);
if (left.Value == null) { if (left.Value == null) {
return; return;
} }
var manaString = mana == null if (mana == null) {
? "???" if (right.Value != null) {
: mana.Value.ToString(CultureInfo.InvariantCulture); left.Value->SetText("");
right.Value->SetText("???");
} else {
left.Value->SetText("???");
}
} else {
var manaString = mana.Value.ToString(CultureInfo.InvariantCulture);
if (right.Value != null) { if (right.Value != null) {
if (manaString.Length <= 1) { if (manaString.Length <= 1) {
left.Value->SetText(""); left.Value->SetText("");
@ -480,6 +493,7 @@ public class Plugin : IDalamudPlugin {
left.Value->SetText(manaString); left.Value->SetText(manaString);
} }
} }
}
private unsafe void ResetMember( private unsafe void ResetMember(
AddonPartyList* list, AddonPartyList* list,
@ -521,8 +535,8 @@ public class Plugin : IDalamudPlugin {
} }
} }
this.ResetTextColour(unit); ResetTextColour(unit);
this.ResetManaText(unit, info.Mana); ResetManaText(unit, info.Mana);
} }
private unsafe void ResetMembers(AddonPartyList* list) { private unsafe void ResetMembers(AddonPartyList* list) {
@ -531,7 +545,7 @@ public class Plugin : IDalamudPlugin {
member.TargetGlow->SetWidth(320); member.TargetGlow->SetWidth(320);
} }
this.ResetTextColour(member); ResetTextColour(member);
} }
if (list->Chocobo.TargetGlow != null) { if (list->Chocobo.TargetGlow != null) {
@ -669,7 +683,7 @@ public class Plugin : IDalamudPlugin {
var hasTimer = chocoboTimer != null && chocoboTimer->IsVisible(); var hasTimer = chocoboTimer != null && chocoboTimer->IsVisible();
var hasTimerIcon = chocoboTimerIcon != null && chocoboTimerIcon->IsVisible(); var hasTimerIcon = chocoboTimerIcon != null && chocoboTimerIcon->IsVisible();
if (this.Config.Alternate && this.Config.AlternateChocobo && (!this.Config.OnlyAlternateInCombat || inCombat) && !this._showDps) { if (this.Config is { Alternate: true, AlternateChocobo: true } && (!this.Config.OnlyAlternateInCombat || inCombat) && !this._showDps) {
this.ResetMember(list, info, false, false); this.ResetMember(list, info, false, false);
} else { } else {
if (hasTimer) { if (hasTimer) {
@ -686,15 +700,17 @@ public class Plugin : IDalamudPlugin {
if (this.Config.Mode == MeterMode.Mana && member.MPGaugeBar != null) { if (this.Config.Mode == MeterMode.Mana && member.MPGaugeBar != null) {
var left = (AtkTextNode*) member.MPGaugeBar->GetTextNodeById(2); var left = (AtkTextNode*) member.MPGaugeBar->GetTextNodeById(2);
var right = (AtkTextNode*) member.MPGaugeBar->GetTextNodeById(3); var right = (AtkTextNode*) member.MPGaugeBar->GetTextNodeById(3);
var hasLeft = left != null && left->IsVisible(); if (left == null) {
var hasRight = right != null && right->IsVisible();
if (!hasLeft) {
return; return;
} }
if (!left->ParentNode->IsVisible() && !info.IsChocobo && InfoProxyCrossRealm.Instance()->IsInCrossRealmParty != 0) { if (info is { IsFullMember: false, IsChocobo: false } && InfoProxyCrossRealm.Instance()->IsInCrossRealmParty != 0) {
var gauge = left->ParentNode; var gauge = left->ParentNode;
gauge->ToggleVisibility(true); gauge->ToggleVisibility(true);
left->ToggleVisibility(true);
if (right != null) {
right->ToggleVisibility(true);
}
for (var sibling = left->NextSiblingNode; sibling != null; sibling = sibling->NextSiblingNode) { for (var sibling = left->NextSiblingNode; sibling != null; sibling = sibling->NextSiblingNode) {
if (sibling->NodeId is not (6 or 7)) { if (sibling->NodeId is not (6 or 7)) {
@ -705,8 +721,14 @@ public class Plugin : IDalamudPlugin {
} }
} }
var hasLeft = left->IsVisible();
var hasRight = right != null && right->IsVisible();
if (!hasLeft) {
return;
}
if (this.Config.Alternate && (!this.Config.OnlyAlternateInCombat || inCombat) && !this._showDps && info.ClassJob is { } classJob) { if (this.Config.Alternate && (!this.Config.OnlyAlternateInCombat || inCombat) && !this._showDps && info.ClassJob is { } classJob) {
var shouldAlternate = this.Config.AlternateJobs.Contains(classJob); var shouldAlternate = info.IsFullMember && this.Config.AlternateJobs.Contains(classJob);
if (shouldAlternate) { if (shouldAlternate) {
this.ResetMember(list, info, false, false); this.ResetMember(list, info, false, false);
return; return;
@ -775,4 +797,5 @@ public class ListInfo {
public required int PartyListIndex { get; set; } public required int PartyListIndex { get; set; }
public required uint? Mana { get; init; } public required uint? Mana { get; init; }
public required byte? ClassJob { get; init; } public required byte? ClassJob { get; init; }
public required bool IsFullMember { get; init; }
} }