Control prompt localplayers cleanup

This commit is contained in:
Antonio Martinez 2025-06-01 16:04:14 -04:00
parent 9d3c0f0c68
commit 3a39399346
3 changed files with 30 additions and 12 deletions

View file

@ -73,6 +73,7 @@
#include "k_bans.h" #include "k_bans.h"
#include "k_director.h" #include "k_director.h"
#include "k_credits.h" #include "k_credits.h"
#include "k_hud.h" // K_AddMessage
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES #ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
#include "m_avrecorder.h" #include "m_avrecorder.h"
@ -180,6 +181,8 @@ static void Command_Archivetest_f(void);
static void Command_KartGiveItem_f(void); static void Command_KartGiveItem_f(void);
static void Command_DebugMessageFeed(void);
static void Command_Schedule_Add(void); static void Command_Schedule_Add(void);
static void Command_Schedule_Clear(void); static void Command_Schedule_Clear(void);
static void Command_Schedule_List(void); static void Command_Schedule_List(void);
@ -434,6 +437,8 @@ void D_RegisterServerCommands(void)
COM_AddDebugCommand("give3", Command_KartGiveItem_f); COM_AddDebugCommand("give3", Command_KartGiveItem_f);
COM_AddDebugCommand("give4", Command_KartGiveItem_f); COM_AddDebugCommand("give4", Command_KartGiveItem_f);
COM_AddDebugCommand("debugmessagefeed", Command_DebugMessageFeed);
COM_AddCommand("schedule_add", Command_Schedule_Add); COM_AddCommand("schedule_add", Command_Schedule_Add);
COM_AddCommand("schedule_clear", Command_Schedule_Clear); COM_AddCommand("schedule_clear", Command_Schedule_Clear);
COM_AddCommand("schedule_list", Command_Schedule_List); COM_AddCommand("schedule_list", Command_Schedule_List);
@ -6358,6 +6363,11 @@ static void Command_Archivetest_f(void)
} }
#endif #endif
static void Command_DebugMessageFeed(void)
{
K_AddMessage("Hello world! A = <a>, Right = <right>", true, false);
}
/** Give yourself an, optional quantity or one of, an item. /** Give yourself an, optional quantity or one of, an item.
*/ */
static void Command_KartGiveItem_f(void) static void Command_KartGiveItem_f(void)

View file

@ -7164,17 +7164,19 @@ static std::vector<messagestate_t> messagestates{MAXSPLITSCREENPLAYERS};
void K_AddMessage(const char *msg, boolean interrupt, boolean persist) void K_AddMessage(const char *msg, boolean interrupt, boolean persist)
{ {
for (auto &state : messagestates) for (UINT8 i = 0; i <= r_splitscreen; i++)
{ {
if (interrupt) messagestate_t *state = &messagestates[i];
state.clear();
std::string parsedmsg = srb2::Draw::TextElement().parse(msg).string(); if (interrupt)
state->clear();
std::string parsedmsg = srb2::Draw::TextElement().as(g_localplayers[i]).parse(msg).string();
if (persist) if (persist)
state.objective = parsedmsg; state->objective = parsedmsg;
else else
state.add(parsedmsg); state->add(parsedmsg);
} }
} }

View file

@ -22,6 +22,7 @@
#include "z_zone.h" #include "z_zone.h"
#include "k_profiles.h" // controls #include "k_profiles.h" // controls
#include "p_local.h" // stplyr #include "p_local.h" // stplyr
#include "r_fps.h" // R_GetViewNumber()
using srb2::Draw; using srb2::Draw;
using Chain = Draw::Chain; using Chain = Draw::Chain;
@ -176,17 +177,22 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw)
else if (auto it = translation.find(code); it != translation.end()) // This represents a gamecontrol, turn into Saturn button or generic button. else if (auto it = translation.find(code); it != translation.end()) // This represents a gamecontrol, turn into Saturn button or generic button.
{ {
UINT8 localplayer = 0; UINT8 localplayer = R_GetViewNumber();
UINT8 indexedplayer = as_.value_or(stplyr - players);
for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) if (as_.has_value())
{ {
if (g_localplayers[i] == indexedplayer) UINT8 indexedplayer = as_.value();
for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
localplayer = i; if (g_localplayers[i] == indexedplayer)
break; {
localplayer = i;
break;
}
} }
} }
// This isn't how v_video.cpp checks for buttons and I don't know why. // This isn't how v_video.cpp checks for buttons and I don't know why.
if (cv_descriptiveinput[localplayer].value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation? if (cv_descriptiveinput[localplayer].value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation?
{ {