MCPcopy Create free account
hub / github.com/GlobedGD/globed2 / onUserlistSetup

Method onUserlistSetup

src/modules/two-player/TwoPlayerModule.cpp:82–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82void TwoPlayerModule::onUserlistSetup(CCNode* container, int accountId, bool myself, UserListPopup* popup) {
83 if (myself) return;
84
85 // if we are already linked, show only an unlink button on the linked player
86 if (m_linkedPlayer) {
87 if (accountId != *m_linkedPlayer) {
88 return;
89 }
90
91 Build<CCSprite>::createSpriteName("gj_linkBtnOff_001.png")
92 .scale(0.8f)
93 .intoMenuItem([this, popup] {
94 this->unlink();
95 popup->hardRefresh();
96 })
97 .id("2p-unlink")
98 .parent(container);
99
100 return;
101 }
102
103 // otherwise, show a link button on all players
104
105 Build<CCSprite>::createSpriteName("gj_linkBtn_001.png")
106 .scale(0.8f)
107 .intoMenuItem([accountId, popup] {
108 LinkRequestPopup::create(accountId, popup)->show();
109 })
110 .id("2p-unlink")
111 .parent(container);
112}
113
114void TwoPlayerModule::onPlayerLeave(GlobedGJBGL* gjbgl, int accountId) {
115 if (accountId == m_linkedPlayer) {

Callers 1

customSetupMethod · 0.45

Calls 4

unlinkMethod · 0.95
hardRefreshMethod · 0.80
showMethod · 0.80
idMethod · 0.45

Tested by

no test coverage detected