From c2a4221ea86a05f75a81955eac79096da4bcc67c Mon Sep 17 00:00:00 2001 From: Robbe Bryssinck Date: Tue, 28 Jun 2022 23:37:27 +0200 Subject: [PATCH] fix: disable buttons for non leader --- Code/client/Services/Generic/OverlayService.cpp | 2 +- Code/client/Services/Generic/PartyService.cpp | 1 + Code/server/Services/PartyService.cpp | 1 - .../components/party-menu/party-menu.component.ts | 6 +++--- Code/skyrim_ui/src/app/services/client.service.ts | 2 +- Code/skyrim_ui/src/app/services/group.service.ts | 13 +++++++++++-- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Code/client/Services/Generic/OverlayService.cpp b/Code/client/Services/Generic/OverlayService.cpp index 63386a15a..15b30a971 100644 --- a/Code/client/Services/Generic/OverlayService.cpp +++ b/Code/client/Services/Generic/OverlayService.cpp @@ -286,7 +286,7 @@ void OverlayService::OnConnectedEvent(const ConnectedEvent& acEvent) noexcept auto pArguments = CefListValue::Create(); pArguments->SetInt(0, acEvent.PlayerId); - m_pOverlay->ExecuteAsync("setServerId", pArguments); + m_pOverlay->ExecuteAsync("setLocalPlayerId", pArguments); } void OverlayService::OnDisconnectedEvent(const DisconnectedEvent&) noexcept diff --git a/Code/client/Services/Generic/PartyService.cpp b/Code/client/Services/Generic/PartyService.cpp index 5a4ffde25..28d1d6722 100644 --- a/Code/client/Services/Generic/PartyService.cpp +++ b/Code/client/Services/Generic/PartyService.cpp @@ -120,6 +120,7 @@ void PartyService::OnPartyInfo(const NotifyPartyInfo& acPartyInfo) noexcept pPlayerIds->SetInt(i, m_partyMembers[i]); pArguments->SetList(0, pPlayerIds); + pArguments->SetInt(1, acPartyInfo.LeaderPlayerId); m_world.GetOverlayService().GetOverlayApp()->ExecuteAsync("partyInfo", pArguments); } diff --git a/Code/server/Services/PartyService.cpp b/Code/server/Services/PartyService.cpp index 4f9a03948..e12421fc8 100644 --- a/Code/server/Services/PartyService.cpp +++ b/Code/server/Services/PartyService.cpp @@ -329,7 +329,6 @@ void PartyService::RemovePlayerFromParty(Player* apPlayer) noexcept } } -// TODO(cosideci): why broadcast the whole list every time? Why not just the diff? void PartyService::BroadcastPlayerList(Player* apPlayer) const noexcept { auto pIgnoredPlayer = apPlayer; diff --git a/Code/skyrim_ui/src/app/components/party-menu/party-menu.component.ts b/Code/skyrim_ui/src/app/components/party-menu/party-menu.component.ts index 9e0be9def..e8e7e3f24 100644 --- a/Code/skyrim_ui/src/app/components/party-menu/party-menu.component.ts +++ b/Code/skyrim_ui/src/app/components/party-menu/party-menu.component.ts @@ -54,15 +54,15 @@ export class PartyMenuComponent implements OnInit, OnDestroy { } public get isPartyLeader(): boolean { - return this.groupService.group.value.isEnabled && this.groupService.group.value.owner == this.clientService.localPlayerId; + return this.groupService.group.value.isEnabled && this.groupService.group.value.owner == this.clientService.localPlayerId; } public get getMembersLength(): number { - return this.groupService.getMembersLength(); + return this.groupService.getMembersLength(true); } isLaunchPartyDisabled(): boolean { - return this.groupService.getMembersLength() > 1; + return this.groupService.getMembersLength(false) > 1; } public launchParty() { diff --git a/Code/skyrim_ui/src/app/services/client.service.ts b/Code/skyrim_ui/src/app/services/client.service.ts index ab96f91d5..220abb719 100644 --- a/Code/skyrim_ui/src/app/services/client.service.ts +++ b/Code/skyrim_ui/src/app/services/client.service.ts @@ -618,7 +618,7 @@ export class ClientService implements OnDestroy { this.loadingService.setLoading(false); this.partyInfoChange.next(new PartyInfo( { - playerIds: [], + playerIds: [this.localPlayerId], leaderId: this.localPlayerId } )); diff --git a/Code/skyrim_ui/src/app/services/group.service.ts b/Code/skyrim_ui/src/app/services/group.service.ts index 3613ecc04..68553d1de 100644 --- a/Code/skyrim_ui/src/app/services/group.service.ts +++ b/Code/skyrim_ui/src/app/services/group.service.ts @@ -288,8 +288,17 @@ export class GroupService implements OnDestroy { } } - public getMembersLength(): number { - return (this.group.value ? this.group.value.members.length : 0); + public getMembersLength(excludeLocal: boolean): number { + if (!this.group.value) { + return 0; + } + + let members = this.group.value.members; + if (excludeLocal) { + members = members.filter(member => member !== this.clientService.localPlayerId); + } + + return members.length; } public isPartyEnabled(): boolean {