Show players on star select toggle (#321)

* Show players on star select toggle

* Make only toggleable by mods

* Allow player list to also be disabled
This commit is contained in:
Agent X 2023-03-23 21:12:26 -04:00 committed by GitHub
parent 3676d2030d
commit 4277230f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 19 deletions

View File

@ -1714,6 +1714,8 @@
--- @class ServerSettings
--- @field public bubbleDeath integer
--- @field public enableCheats integer
--- @field public enablePlayerList integer
--- @field public enablePlayersInLevelDisplay integer
--- @field public headlessServer integer
--- @field public playerInteractions PlayerInteractions
--- @field public playerKnockbackStrength integer

View File

@ -2174,6 +2174,8 @@
| ----- | ---- | ------ |
| bubbleDeath | `integer` | |
| enableCheats | `integer` | |
| enablePlayerList | `integer` | |
| enablePlayersInLevelDisplay | `integer` | |
| headlessServer | `integer` | |
| playerInteractions | [enum PlayerInteractions](constants.md#enum-PlayerInteractions) | |
| playerKnockbackStrength | `integer` | |

View File

@ -376,15 +376,17 @@ void print_act_selector_strings(void) {
print_menu_generic_string(x, 38, starNumbers);
#endif
// display player HUD head if they're in that act
for (int j = 0; j < MAX_PLAYERS; j++) {
struct NetworkPlayer* np = &gNetworkPlayers[j];
if (np == NULL || !np->connected) { continue; }
if (np->currCourseNum != gCurrCourseNum) { continue; }
if (np->currActNum != i) { continue; }
if (gServerSettings.enablePlayersInLevelDisplay) {
for (int j = 0; j < MAX_PLAYERS; j++) {
struct NetworkPlayer* np = &gNetworkPlayers[j];
if (np == NULL || !np->connected) { continue; }
if (np->currCourseNum != gCurrCourseNum) { continue; }
if (np->currActNum != i) { continue; }
char* displayHead = (gMarioStates[j].character) ? &gMarioStates[j].character->hudHead : ",";
print_text(x - 4, 207, displayHead); // 'Mario Head' glyph
break;
char* displayHead = (gMarioStates[j].character) ? &gMarioStates[j].character->hudHead : ",";
print_text(x - 4, 207, displayHead); // 'Mario Head' glyph
break;
}
}
}
@ -399,7 +401,7 @@ void print_act_selector_strings(void) {
playersInAct++;
}
if (playersInAct > 0) {
if (playersInAct > 0 && gServerSettings.enablePlayersInLevelDisplay) {
char message[16] = { 0 };
if (playersInAct == 1) {
if (snprintf(message, 16, " join ") < 0) {

View File

@ -222,7 +222,7 @@ bool djui_interactable_on_key_down(int scancode) {
}
}
if (gDjuiPlayerList != NULL || gDjuiModList != NULL) {
if ((gDjuiPlayerList != NULL || gDjuiModList != NULL) && gServerSettings.enablePlayerList) {
for (int i = 0; i < MAX_BINDS; i++) {
if (scancode == (int)configKeyPlayerList[i] && !gDjuiInMainMenu && gNetworkType != NT_NONE) {
if (gDjuiPlayerList != NULL) {

View File

@ -1885,16 +1885,18 @@ static struct LuaObjectField sRayIntersectionInfoFields[LUA_RAY_INTERSECTION_INF
{ "surface", LVT_COBJECT_P, offsetof(struct RayIntersectionInfo, surface), false, LOT_SURFACE },
};
#define LUA_SERVER_SETTINGS_FIELD_COUNT 8
#define LUA_SERVER_SETTINGS_FIELD_COUNT 10
static struct LuaObjectField sServerSettingsFields[LUA_SERVER_SETTINGS_FIELD_COUNT] = {
{ "bubbleDeath", LVT_U8, offsetof(struct ServerSettings, bubbleDeath), false, LOT_NONE },
{ "enableCheats", LVT_U8, offsetof(struct ServerSettings, enableCheats), false, LOT_NONE },
{ "headlessServer", LVT_U8, offsetof(struct ServerSettings, headlessServer), false, LOT_NONE },
{ "playerInteractions", LVT_S32, offsetof(struct ServerSettings, playerInteractions), false, LOT_NONE },
{ "playerKnockbackStrength", LVT_U8, offsetof(struct ServerSettings, playerKnockbackStrength), false, LOT_NONE },
{ "shareLives", LVT_U8, offsetof(struct ServerSettings, shareLives), false, LOT_NONE },
{ "skipIntro", LVT_U8, offsetof(struct ServerSettings, skipIntro), false, LOT_NONE },
{ "stayInLevelAfterStar", LVT_U8, offsetof(struct ServerSettings, stayInLevelAfterStar), false, LOT_NONE },
{ "bubbleDeath", LVT_U8, offsetof(struct ServerSettings, bubbleDeath), false, LOT_NONE },
{ "enableCheats", LVT_U8, offsetof(struct ServerSettings, enableCheats), false, LOT_NONE },
{ "enablePlayerList", LVT_U8, offsetof(struct ServerSettings, enablePlayerList), false, LOT_NONE },
{ "enablePlayersInLevelDisplay", LVT_U8, offsetof(struct ServerSettings, enablePlayersInLevelDisplay), false, LOT_NONE },
{ "headlessServer", LVT_U8, offsetof(struct ServerSettings, headlessServer), false, LOT_NONE },
{ "playerInteractions", LVT_S32, offsetof(struct ServerSettings, playerInteractions), false, LOT_NONE },
{ "playerKnockbackStrength", LVT_U8, offsetof(struct ServerSettings, playerKnockbackStrength), false, LOT_NONE },
{ "shareLives", LVT_U8, offsetof(struct ServerSettings, shareLives), false, LOT_NONE },
{ "skipIntro", LVT_U8, offsetof(struct ServerSettings, skipIntro), false, LOT_NONE },
{ "stayInLevelAfterStar", LVT_U8, offsetof(struct ServerSettings, stayInLevelAfterStar), false, LOT_NONE },
};
#define LUA_SOUND_STATE_FIELD_COUNT 4

View File

@ -67,6 +67,8 @@ struct ServerSettings gServerSettings = {
.shareLives = 0,
.enableCheats = 0,
.bubbleDeath = 1,
.enablePlayersInLevelDisplay = 1,
.enablePlayerList = 1,
.headlessServer = 0,
};

View File

@ -68,6 +68,8 @@ struct ServerSettings {
u8 shareLives;
u8 enableCheats;
u8 bubbleDeath;
u8 enablePlayersInLevelDisplay;
u8 enablePlayerList;
u8 headlessServer;
};