Skip to content

Commit 6aa7273

Browse files
DaDev123DaDev123
authored andcommitted
Made the Player List in SNH/HNS More readable
1 parent 2d003e7 commit 6aa7273

2 files changed

Lines changed: 88 additions & 29 deletions

File tree

source/layouts/HideAndSeekIcon.cpp

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,37 +84,63 @@ void HideAndSeekIcon::exeWait() {
8484

8585
int playerCount = Client::getMaxPlayerCount();
8686

87-
if (playerCount > 0) {
88-
char playerNameBuf[0x200] = {0};
89-
sead::BufferedSafeStringBase<char> playerList =
90-
sead::BufferedSafeStringBase<char>(playerNameBuf, sizeof(playerNameBuf));
91-
92-
playerList.appendWithFormat("%s %s\n", mInfo->mIsPlayerIt ? "&" : "%%", Client::instance()->getClientName());
87+
if (playerCount > 0) {
88+
char playerNameBuf[0x200] = {0};
89+
sead::BufferedSafeStringBase<char> playerList =
90+
sead::BufferedSafeStringBase<char>(playerNameBuf, sizeof(playerNameBuf));
91+
92+
// Add current player first
93+
playerList.appendWithFormat("%s %s\n", mInfo->mIsPlayerIt ? "&" : "%%", Client::instance()->getClientName());
94+
95+
// IT players (seekers) then hiders
96+
for (int i = 0; i <= 1; i++) {
97+
bool isIt = i == 0;
98+
// Add players to the list that are in the same game mode
99+
for (int j = 0; j < playerCount; j++) {
100+
PuppetInfo* curPuppet = Client::getPuppetInfo(j);
101+
if (!curPuppet || !curPuppet->isConnected)
102+
continue;
103+
104+
if (curPuppet->gameMode != curGamemodeID)
105+
continue;
106+
107+
if (curPuppet->isIt != isIt)
108+
continue;
109+
110+
playerList.appendWithFormat("%s %s\n", curPuppet->isIt ? "&" : "%%", curPuppet->puppetName);
111+
}
112+
}
93113

94-
for (int i = 0; i < playerCount; i++) {
95-
PuppetInfo* curPuppet = Client::getPuppetInfo(i);
96-
if (!curPuppet || !curPuppet->isConnected)
97-
continue;
114+
// Add some spacing before non-mode players
115+
bool hasNonModePlayers = false;
116+
for (int i = 0; i < playerCount; i++) {
117+
PuppetInfo* curPuppet = Client::getPuppetInfo(i);
118+
if (!curPuppet || !curPuppet->isConnected)
119+
continue;
120+
121+
if (curPuppet->gameMode != curGamemodeID) {
122+
hasNonModePlayers = true;
123+
break;
124+
}
125+
}
98126

99-
if (curPuppet->gameMode == curGamemodeID) {
100-
playerList.appendWithFormat("%s %s\n", curPuppet->isIt ? "&" : "%%", curPuppet->puppetName);
127+
if (hasNonModePlayers) {
128+
playerList.appendWithFormat("\n"); // Add blank line for spacing
101129
}
102-
}
103130

104-
for (int i = 0; i < playerCount; i++) {
105-
PuppetInfo* curPuppet = Client::getPuppetInfo(i);
106-
if (!curPuppet || !curPuppet->isConnected)
107-
continue;
131+
// add players not in the mode
132+
for (int i = 0; i < playerCount; i++) {
133+
PuppetInfo* curPuppet = Client::getPuppetInfo(i);
134+
if (!curPuppet || !curPuppet->isConnected)
135+
continue;
108136

109-
if (curPuppet->gameMode != curGamemodeID) {
110-
playerList.appendWithFormat(" %s\n", curPuppet->puppetName); // no icon, indented
137+
if (curPuppet->gameMode != curGamemodeID) {
138+
playerList.appendWithFormat(" %s\n", curPuppet->puppetName); // no icon, indented
139+
}
111140
}
112-
}
113141

114-
al::setPaneStringFormat(this, "TxtPlayerList", playerList.cstr());
115-
}
116-
117-
142+
al::setPaneStringFormat(this, "TxtPlayerList", playerList.cstr());
143+
}
118144
}
119145

120146
void HideAndSeekIcon::exeEnd() {

source/layouts/SardineIcon.cpp

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,55 @@ void SardineIcon::exeWait() {
8888
char playerNameBuf[0x200] = {0};
8989
sead::BufferedSafeStringBase<char> playerList = sead::BufferedSafeStringBase<char>(playerNameBuf, sizeof(playerNameBuf));
9090

91+
// Add current player first
9192
if (mInfo->mIsIt || GameModeManager::instance()->isModeAndActive(GameMode::SARDINE)) {
9293
playerList.appendWithFormat("%s %s\n", mInfo->mIsIt ? "@" : "©", Client::instance()->getClientName());
9394
}
9495

96+
// IT players (sardines) then pack
97+
for (int i = 0; i <= 1; i++) {
98+
bool isIt = i == 0;
99+
// Add players to the list that are in the same game mode
100+
for (int j = 0; j < playerCount; j++) {
101+
PuppetInfo* curPuppet = Client::getPuppetInfo(j);
102+
if (!curPuppet || !curPuppet->isConnected)
103+
continue;
104+
105+
if (curPuppet->gameMode != curGamemodeID)
106+
continue;
107+
108+
if (curPuppet->isIt != isIt)
109+
continue;
110+
111+
playerList.appendWithFormat("%s %s\n", curPuppet->isIt ? "@" : "©", curPuppet->puppetName);
112+
}
113+
}
114+
115+
// Add some spacing before non-mode players
116+
bool hasNonModePlayers = false;
95117
for (int i = 0; i < playerCount; i++) {
96118
PuppetInfo* curPuppet = Client::getPuppetInfo(i);
97-
if (curPuppet && curPuppet->isConnected && curPuppet->gameMode == curGamemodeID) {
98-
// Role icon: "@" for sardine "it", "©" for others
99-
playerList.appendWithFormat("%s %s\n", curPuppet->isIt ? "@" : "©", curPuppet->puppetName);
119+
if (!curPuppet || !curPuppet->isConnected)
120+
continue;
121+
122+
if (curPuppet->gameMode != curGamemodeID) {
123+
hasNonModePlayers = true;
124+
break;
100125
}
101126
}
102127

128+
if (hasNonModePlayers) {
129+
playerList.appendWithFormat("\n"); // Add blank line for spacing
130+
}
131+
132+
// add players not in the mode
103133
for (int i = 0; i < playerCount; i++) {
104134
PuppetInfo* curPuppet = Client::getPuppetInfo(i);
105-
if (curPuppet && curPuppet->isConnected && curPuppet->gameMode != curGamemodeID) {
106-
playerList.appendWithFormat(" %s\n", curPuppet->puppetName); // No icon, indented
135+
if (!curPuppet || !curPuppet->isConnected)
136+
continue;
137+
138+
if (curPuppet->gameMode != curGamemodeID) {
139+
playerList.appendWithFormat(" %s\n", curPuppet->puppetName); // no icon, indented
107140
}
108141
}
109142

0 commit comments

Comments
 (0)