mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Adjusted spectator bottom-right box, broadcast network back-end, options to disable/mute it
This commit is contained in:
parent
af49073f55
commit
dc449f84e5
|
@ -242,6 +242,10 @@ Messages = [
|
|||
NetMessage("Sv_Motd", [
|
||||
NetString("m_pMessage"),
|
||||
]),
|
||||
|
||||
NetMessage("Sv_Broadcast", [
|
||||
NetString("m_pMessage"),
|
||||
]),
|
||||
|
||||
NetMessage("Sv_Chat", [
|
||||
NetIntRange("m_Mode", 0, 'NUM_CHATS-1'),
|
||||
|
|
|
@ -24,6 +24,8 @@ MACRO_CONFIG_INT(ClAutoDemoMax, cl_auto_demo_max, 10, 0, 1000, CFGFLAG_SAVE|CFGF
|
|||
MACRO_CONFIG_INT(ClAutoScreenshot, cl_auto_screenshot, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Automatically take game over screenshot")
|
||||
MACRO_CONFIG_INT(ClAutoScreenshotMax, cl_auto_screenshot_max, 10, 0, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Maximum number of automatically created screenshots (0 = no limit)")
|
||||
|
||||
MACRO_CONFIG_INT(ClShowServerBroadcast, cl_show_server_broadcast, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Show server broadcast")
|
||||
|
||||
MACRO_CONFIG_STR(BrFilterString, br_filter_string, 25, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Server browser filtering string")
|
||||
|
||||
MACRO_CONFIG_INT(BrSort, br_sort, 0, 0, 256, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||
|
|
|
@ -44,9 +44,11 @@ inline bool IsCharANum(char c)
|
|||
|
||||
void CHud::OnMessage(int MsgType, void* pRawMsg)
|
||||
{
|
||||
if(MsgType == NETMSGTYPE_SV_CHAT)
|
||||
// process server broadcast message
|
||||
if(MsgType == NETMSGTYPE_SV_BROADCAST && g_Config.m_ClShowServerBroadcast &&
|
||||
!m_pClient->m_MuteServerBroadcast)
|
||||
{
|
||||
CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
|
||||
CNetMsg_Sv_Broadcast *pMsg = (CNetMsg_Sv_Broadcast *)pRawMsg;
|
||||
|
||||
// new broadcast message
|
||||
int MsgLen = str_length(pMsg->m_pMessage);
|
||||
|
@ -674,7 +676,8 @@ void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
|||
void CHud::RenderSpectatorHud()
|
||||
{
|
||||
// draw the box
|
||||
CUIRect Rect = {m_Width-180.0f, m_Height-15.0f, 180.0f, 15.0f};
|
||||
const float Width = m_Width * 0.25f - 2.0f;
|
||||
CUIRect Rect = {m_Width-Width, m_Height-15.0f, Width, 15.0f};
|
||||
RenderTools()->DrawUIRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.4f), CUI::CORNER_TL, 5.0f);
|
||||
|
||||
// draw the text
|
||||
|
@ -685,7 +688,7 @@ void CHud::RenderSpectatorHud()
|
|||
char aBuf[128];
|
||||
|
||||
CTextCursor Cursor;
|
||||
TextRender()->SetCursor(&Cursor, m_Width-174.0f, m_Height-13.0f, 8.0f, TEXTFLAG_RENDER);
|
||||
TextRender()->SetCursor(&Cursor, m_Width-Width+6.0f, m_Height-13.0f, 8.0f, TEXTFLAG_RENDER);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "%s: ", Localize("Spectate"));
|
||||
TextRender()->TextEx(&Cursor, aBuf, -1);
|
||||
|
@ -777,6 +780,9 @@ inline bool IsCharWhitespace(char c)
|
|||
|
||||
void CHud::RenderBroadcast()
|
||||
{
|
||||
if(!g_Config.m_ClShowServerBroadcast || m_pClient->m_MuteServerBroadcast)
|
||||
return;
|
||||
|
||||
const float DisplayDuration = 10.0f;
|
||||
const float DisplayStartFade = 9.0f;
|
||||
const float DeltaTime = Client()->LocalTime() - m_BroadcastReceivedTime;
|
||||
|
@ -791,9 +797,6 @@ void CHud::RenderBroadcast()
|
|||
const float Fade = 1.0f - max(0.0f, (DeltaTime - DisplayStartFade) / (DisplayDuration - DisplayStartFade));
|
||||
|
||||
CUIRect ScreenRect = {0, 0, m_Width, m_Height};
|
||||
const bool IsSpecMode = m_pClient->m_Snap.m_SpecInfo.m_Active;
|
||||
if(IsSpecMode)
|
||||
ScreenRect.y -= 20.0f;
|
||||
|
||||
CUIRect BcView = ScreenRect;
|
||||
BcView.x += m_Width * 0.25f;
|
||||
|
@ -804,13 +807,12 @@ void CHud::RenderBroadcast()
|
|||
float FontSize = 11.0f;
|
||||
|
||||
vec4 ColorTop(0, 0, 0, 0);
|
||||
vec4 ColorBot(0, 0, 0, (IsSpecMode ? 0.2f : 0.4f) * Fade);
|
||||
vec4 ColorBot(0, 0, 0, 0.4f * Fade);
|
||||
CUIRect BgRect;
|
||||
BcView.HSplitBottom(10.0f, 0, &BgRect);
|
||||
|
||||
RenderTools()->DrawUIRect4(&BgRect, ColorTop, ColorTop,
|
||||
ColorBot, ColorBot, IsSpecMode ? CUI::CORNER_B:0,
|
||||
IsSpecMode ? 2.0f:0);
|
||||
ColorBot, ColorBot, 0, 0);
|
||||
|
||||
// server broadcast line
|
||||
CUIRect TitleRect;
|
||||
|
|
|
@ -11,11 +11,11 @@ class CHud : public CComponent
|
|||
float m_AverageFPS;
|
||||
int64 m_WarmupHideTick;
|
||||
|
||||
// broadcast
|
||||
// server broadcast
|
||||
typedef unsigned char u8;
|
||||
struct CBcColor
|
||||
{
|
||||
u8 m_R,m_G,m_B;
|
||||
u8 m_R, m_G, m_B;
|
||||
int m_CharPos;
|
||||
};
|
||||
|
||||
|
|
|
@ -363,6 +363,17 @@ void CMenus::RenderServerInfo(CUIRect MainView)
|
|||
ServerBrowser()->AddFavorite(&CurrentServerInfo);
|
||||
}
|
||||
|
||||
{
|
||||
CUIRect Button;
|
||||
ServerInfo.HSplitBottom(20.0f, &ServerInfo, &Button);
|
||||
static int s_MuteBroadcast = 0;
|
||||
if(DoButton_CheckBox(&s_MuteBroadcast, Localize("Mute broadcast"),
|
||||
m_pClient->m_MuteServerBroadcast, &Button))
|
||||
{
|
||||
m_pClient->m_MuteServerBroadcast ^= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// gameinfo
|
||||
GameInfo.VSplitLeft(1.0f, 0, &GameInfo);
|
||||
RenderTools()->DrawUIRect(&GameInfo, vec4(0.0, 0.0, 0.0, 0.25f), CUI::CORNER_ALL, 5.0f);
|
||||
|
|
|
@ -249,7 +249,7 @@ void CGameClient::OnInit()
|
|||
m_UI.SetGraphics(Graphics(), TextRender());
|
||||
m_RenderTools.m_pGraphics = Graphics();
|
||||
m_RenderTools.m_pUI = UI();
|
||||
|
||||
|
||||
int64 Start = time_get();
|
||||
|
||||
// set the language
|
||||
|
@ -369,6 +369,7 @@ void CGameClient::OnReset()
|
|||
m_DemoSpecMode = SPEC_FREEVIEW;
|
||||
m_DemoSpecID = -1;
|
||||
m_Tuning = CTuningParams();
|
||||
m_MuteServerBroadcast = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -633,7 +634,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
if(m_LocalClientID != -1 && !pMsg->m_Silent)
|
||||
{
|
||||
DoEnterMessage(pMsg->m_pName, pMsg->m_ClientID, pMsg->m_Team);
|
||||
|
||||
|
||||
if(m_pDemoRecorder->IsRecording())
|
||||
{
|
||||
CNetMsg_De_ClientEnter Msg;
|
||||
|
@ -746,7 +747,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
if(pMsg->m_Silent == 0)
|
||||
{
|
||||
DoTeamChangeMessage(m_aClients[pMsg->m_ClientID].m_aName, pMsg->m_ClientID, pMsg->m_Team);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_SV_READYTOENTER)
|
||||
{
|
||||
|
@ -983,7 +984,7 @@ void CGameClient::OnNewSnapshot()
|
|||
m_ServerMode = SERVERMODE_PURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// network items
|
||||
if(Item.m_Type == NETOBJTYPE_PLAYERINFO)
|
||||
{
|
||||
|
@ -1018,7 +1019,7 @@ void CGameClient::OnNewSnapshot()
|
|||
// clamp ammo count for non ninja weapon
|
||||
if(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_Weapon != WEAPON_NINJA)
|
||||
m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_AmmoCount = clamp(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_AmmoCount, 0, 10);
|
||||
|
||||
|
||||
if(pOld)
|
||||
{
|
||||
m_Snap.m_aCharacters[Item.m_ID].m_Active = true;
|
||||
|
@ -1199,7 +1200,7 @@ void CGameClient::OnDemoRecSnap()
|
|||
CNetObj_De_GameInfo *pGameInfo = static_cast<CNetObj_De_GameInfo *>(Client()->SnapNewItem(NETOBJTYPE_DE_GAMEINFO, 0, sizeof(CNetObj_De_GameInfo)));
|
||||
if(!pGameInfo)
|
||||
return;
|
||||
|
||||
|
||||
pGameInfo->m_GameFlags = m_GameInfo.m_GameFlags;
|
||||
pGameInfo->m_ScoreLimit = m_GameInfo.m_ScoreLimit;
|
||||
pGameInfo->m_TimeLimit = m_GameInfo.m_TimeLimit;
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
const char *NetobjFailedOn() { return m_NetObjHandler.FailedObjOn(); };
|
||||
int NetobjNumFailures() { return m_NetObjHandler.NumObjFailures(); };
|
||||
const char *NetmsgFailedOn() { return m_NetObjHandler.FailedMsgOn(); };
|
||||
|
||||
|
||||
bool m_SuppressEvents;
|
||||
|
||||
// TODO: move this
|
||||
|
@ -129,7 +129,7 @@ public:
|
|||
const CNetObj_GameDataTeam *m_pGameDataTeam;
|
||||
const CNetObj_GameDataFlag *m_pGameDataFlag;
|
||||
int m_GameDataFlagSnapID;
|
||||
|
||||
|
||||
int m_NotReadyCount;
|
||||
int m_AliveCount[NUM_TEAMS];
|
||||
|
||||
|
@ -194,6 +194,7 @@ public:
|
|||
CClientData m_aClients[MAX_CLIENTS];
|
||||
int m_LocalClientID;
|
||||
int m_TeamCooldownTick;
|
||||
bool m_MuteServerBroadcast;
|
||||
|
||||
struct CGameInfo
|
||||
{
|
||||
|
|
|
@ -241,6 +241,13 @@ void CGameContext::SendChat(int ChatterClientID, int Mode, int To, const char *p
|
|||
}
|
||||
}
|
||||
|
||||
void CGameContext::SendBroadcast(const char* pText, int ClientID)
|
||||
{
|
||||
CNetMsg_Sv_Broadcast Msg;
|
||||
Msg.m_pMessage = pText;
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID);
|
||||
}
|
||||
|
||||
void CGameContext::SendEmoticon(int ClientID, int Emoticon)
|
||||
{
|
||||
CNetMsg_Sv_Emoticon Msg;
|
||||
|
@ -1094,6 +1101,12 @@ void CGameContext::ConSay(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->SendChat(-1, CHAT_ALL, -1, pResult->GetString(0));
|
||||
}
|
||||
|
||||
void CGameContext::ConBroadcast(IConsole::IResult* pResult, void* pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
pSelf->SendBroadcast(pResult->GetString(0), -1);
|
||||
}
|
||||
|
||||
void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
@ -1381,6 +1394,7 @@ void CGameContext::OnConsoleInit()
|
|||
Console()->Register("change_map", "?r", CFGFLAG_SERVER|CFGFLAG_STORE, ConChangeMap, this, "Change map");
|
||||
Console()->Register("restart", "?i", CFGFLAG_SERVER|CFGFLAG_STORE, ConRestart, this, "Restart in x seconds (0 = abort)");
|
||||
Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, "Say in chat");
|
||||
Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, "Broadcast message");
|
||||
Console()->Register("set_team", "ii?i", CFGFLAG_SERVER, ConSetTeam, this, "Set team of player to team");
|
||||
Console()->Register("set_team_all", "i", CFGFLAG_SERVER, ConSetTeamAll, this, "Set team of all players to team");
|
||||
Console()->Register("swap_teams", "", CFGFLAG_SERVER, ConSwapTeams, this, "Swap the current teams");
|
||||
|
|
|
@ -49,6 +49,7 @@ class CGameContext : public IGameServer
|
|||
static void ConChangeMap(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConRestart(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConSay(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConBroadcast(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConSetTeam(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConSetTeamAll(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConSwapTeams(IConsole::IResult *pResult, void *pUserData);
|
||||
|
@ -132,6 +133,7 @@ public:
|
|||
|
||||
// network
|
||||
void SendChat(int ChatterClientID, int Mode, int To, const char *pText);
|
||||
void SendBroadcast(const char *pText, int ClientID);
|
||||
void SendEmoticon(int ClientID, int Emoticon);
|
||||
void SendWeaponPickup(int ClientID, int Weapon);
|
||||
void SendMotd(int ClientID);
|
||||
|
|
Loading…
Reference in a new issue