Skip to content

Commit

Permalink
fix: disable buttons for non leader
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Jun 28, 2022
1 parent 6b9775d commit c2a4221
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Code/client/Services/Generic/OverlayService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Code/client/Services/Generic/PartyService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion Code/server/Services/PartyService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion Code/skyrim_ui/src/app/services/client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
));
Expand Down
13 changes: 11 additions & 2 deletions Code/skyrim_ui/src/app/services/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c2a4221

Please sign in to comment.