From 107545da0a5c3a7ee860679ded994173f48c39ad Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 11 Oct 2010 00:16:37 +0200 Subject: [PATCH 01/10] localised "REC"-notification --- src/game/client/components/scoreboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 25e71f8b4..fd8623489 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -295,7 +295,7 @@ void CScoreboard::RenderRecordingNotification(float x) Graphics()->QuadsEnd(); //draw the text - TextRender()->Text(0, x+50.0f, 8.0f, 24.0f, "REC", -1); + TextRender()->Text(0, x+50.0f, 8.0f, 24.0f, Localize("REC"), -1); } void CScoreboard::OnRender() From bed7b64457c3c99a73088efdf7f31178e70c57dc Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 9 Oct 2010 20:04:14 +0200 Subject: [PATCH 02/10] fixed map selection in map editor --- src/game/editor/ed_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 0b84fe389..295f72b94 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -2147,7 +2147,7 @@ static void EditorListdirCallback(const char *pName, int IsDir, int StorageType, void CEditor::AddFileDialogEntry(int Index, CUIRect *pView) { m_FilesCur++; - if(m_FilesCur-1 < m_FilesStartAt || m_FilesCur > m_FilesStopAt) + if(m_FilesCur-1 < m_FilesStartAt || m_FilesCur >= m_FilesStopAt) return; CUIRect Button; From 00c142103455d3d87d43f31df04213db4d92571b Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 9 Oct 2010 20:05:52 +0200 Subject: [PATCH 03/10] fixed so the rcon password is not in the history (fixes #170) --- src/game/client/components/console.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 5fa328dd9..9808a99f7 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -100,8 +100,11 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) { if(m_Input.GetString()[0]) { - char *pEntry = m_History.Allocate(m_Input.GetLength()+1); - mem_copy(pEntry, m_Input.GetString(), m_Input.GetLength()+1); + if(m_Type != 1 || m_pGameConsole->Client()->RconAuthed()) + { + char *pEntry = m_History.Allocate(m_Input.GetLength()+1); + mem_copy(pEntry, m_Input.GetString(), m_Input.GetLength()+1); + } ExecuteLine(m_Input.GetString()); m_Input.Clear(); m_pHistoryEntry = 0x0; From 5754812dea6598335f60858d125639c92ec67914 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 11 Oct 2010 00:30:56 +0200 Subject: [PATCH 04/10] clear history of the remote console on disconnect and cleaned up some old stuff in console.cpp --- src/game/client/components/console.cpp | 43 ++++++-------------------- src/game/client/components/console.h | 2 ++ 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 9808a99f7..b99137c27 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -1,4 +1,3 @@ -//#include "gc_console.h" #include #include @@ -38,10 +37,6 @@ enum CGameConsole::CInstance::CInstance(int Type) { - // init ringbuffers - //history = ringbuf_init(history_data, sizeof(history_data), RINGBUF_FLAG_RECYCLE); - //backlog = ringbuf_init(backlog_data, sizeof(backlog_data), RINGBUF_FLAG_RECYCLE); - m_pHistoryEntry = 0x0; m_Type = Type; @@ -69,6 +64,12 @@ void CGameConsole::CInstance::ClearBacklog() m_BacklogActPage = 0; } +void CGameConsole::CInstance::ClearHistory() +{ + m_History.Init(); + m_pHistoryEntry = 0; +} + void CGameConsole::CInstance::ExecuteLine(const char *pLine) { if(m_Type == 0) @@ -673,34 +674,8 @@ void CGameConsole::OnConsoleInit() Console()->Register("dump_remote_console", "", CFGFLAG_CLIENT, ConDumpRemoteConsole, this, "Dump remote console"); } -/* -static void con_team(void *result, void *user_data) +void CGameConsole::OnStateChange(int NewState, int OldState) { - send_switch_team(console_arg_int(result, 0)); + if(NewState == IClient::STATE_OFFLINE) + m_RemoteConsole.ClearHistory(); } - -static void con_kill(void *result, void *user_data) -{ - send_kill(-1); -} - -void send_kill(int client_id); - -static void con_emote(void *result, void *user_data) -{ - send_emoticon(console_arg_int(result, 0)); -} - -extern void con_chat(void *result, void *user_data); - -void client_console_init() -{ - // - MACRO_REGISTER_COMMAND("team", "i", con_team, 0x0); - MACRO_REGISTER_COMMAND("kill", "", con_kill, 0x0); - - // chatting - MACRO_REGISTER_COMMAND("emote", "i", con_emote, 0); - MACRO_REGISTER_COMMAND("+emote", "", con_key_input_state, &emoticon_selector_active); -} -*/ diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index a4d227902..ae05aa8ba 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -32,6 +32,7 @@ class CGameConsole : public CComponent void Init(CGameConsole *pGameConsole); void ClearBacklog(); + void ClearHistory(); void ExecuteLine(const char *pLine); @@ -72,6 +73,7 @@ public: void PrintLine(int Type, const char *pLine); + virtual void OnStateChange(int NewState, int OldState); virtual void OnConsoleInit(); virtual void OnReset(); virtual void OnRender(); From 7aefbca742c20206ce18a64bc83322331ee67b39 Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 9 Oct 2010 20:19:58 +0200 Subject: [PATCH 05/10] made so we can add the reason for a kick/ban (fixes #123) --- src/engine/client/client.cpp | 4 ++-- src/engine/server/server.cpp | 33 ++++++++++++++++++---------- src/engine/server/server.h | 2 +- src/engine/shared/network.h | 4 ++-- src/engine/shared/network_conn.cpp | 6 ++--- src/engine/shared/network_server.cpp | 18 +++++++-------- 6 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 7c0c632e3..44997ce0d 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1950,8 +1950,8 @@ void CClient::RegisterCommands() { m_pConsole = Kernel()->RequestInterface(); // register server dummy commands for tab completion - m_pConsole->Register("kick", "i", CFGFLAG_SERVER, 0, 0, "Kick player with specified id"); - m_pConsole->Register("ban", "s?i", CFGFLAG_SERVER, 0, 0, "Ban player with ip/id for x minutes"); + m_pConsole->Register("kick", "i?s", CFGFLAG_SERVER, 0, 0, "Kick player with specified id for any reason"); + m_pConsole->Register("ban", "s?is", CFGFLAG_SERVER, 0, 0, "Ban player with ip/id for x minutes for any reason"); m_pConsole->Register("unban", "s", CFGFLAG_SERVER, 0, 0, "Unban ip"); m_pConsole->Register("bans", "", CFGFLAG_SERVER, 0, 0, "Show banlist"); m_pConsole->Register("status", "", CFGFLAG_SERVER, 0, 0, "List players"); diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index c7b728d46..fc8ad4119 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -634,7 +634,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) { // OH FUCK! wrong version, drop him char aReason[256]; - str_format(aReason, sizeof(aReason), "wrong version. server is running '%s' and client '%s'.", GameServer()->NetVersion(), aVersion); + str_format(aReason, sizeof(aReason), "Wrong version : server is running \"%s\" and client \"%s\"", GameServer()->NetVersion(), aVersion); m_NetServer.Drop(ClientId, aReason); return; } @@ -646,7 +646,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) if(g_Config.m_Password[0] != 0 && str_comp(g_Config.m_Password, pPassword) != 0) { // wrong password - m_NetServer.Drop(ClientId, "wrong password"); + m_NetServer.Drop(ClientId, "Wrong password"); return; } @@ -823,7 +823,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) else { NETADDR Addr = m_NetServer.ClientAddr(ClientId); - BanAdd(Addr, g_Config.m_SvRconBantime*60); + BanAdd(Addr, g_Config.m_SvRconBantime*60, "Too many remote console authentication tries"); } } } @@ -947,7 +947,7 @@ void CServer::UpdateServerInfo() } } -int CServer::BanAdd(NETADDR Addr, int Seconds) +int CServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason) { Addr.port = 0; char aAddrStr[128]; @@ -959,7 +959,7 @@ int CServer::BanAdd(NETADDR Addr, int Seconds) str_format(aBuf, sizeof(aBuf), "banned %s for life", aAddrStr); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); - return m_NetServer.BanAdd(Addr, Seconds); + return m_NetServer.BanAdd(Addr, Seconds, pReason); } int CServer::BanRemove(NETADDR Addr) @@ -1240,7 +1240,7 @@ int CServer::Run() for(int i = 0; i < MAX_CLIENTS; ++i) { if(m_aClients[i].m_State != CClient::STATE_EMPTY) - m_NetServer.Drop(i, "server shutdown"); + m_NetServer.Drop(i, "Server shutdown"); } GameServer()->OnShutdown(); @@ -1253,7 +1253,14 @@ int CServer::Run() void CServer::ConKick(IConsole::IResult *pResult, void *pUser) { - ((CServer *)pUser)->Kick(pResult->GetInteger(0), "kicked by console"); + if(pResult->NumArguments() > 1) + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Kicked by console (%s)", pResult->GetString(1)); + ((CServer *)pUser)->Kick(pResult->GetInteger(0), aBuf); + } + else + ((CServer *)pUser)->Kick(pResult->GetInteger(0), "Kicked by console"); } void CServer::ConBan(IConsole::IResult *pResult, void *pUser) @@ -1262,10 +1269,14 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser) CServer *pServer = (CServer *)pUser; const char *pStr = pResult->GetString(0); int Minutes = 30; + const char *pReason = "No reason given"; if(pResult->NumArguments() > 1) Minutes = pResult->GetInteger(1); + if(pResult->NumArguments() > 2) + pReason = pResult->GetString(2); + if(net_addr_from_str(&Addr, pStr) == 0) { if(pServer->m_RconClientId >= 0 && pServer->m_RconClientId < MAX_CLIENTS && pServer->m_aClients[pServer->m_RconClientId].m_State != CClient::STATE_EMPTY) @@ -1278,7 +1289,7 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser) return; } } - pServer->BanAdd(Addr, Minutes*60); + pServer->BanAdd(Addr, Minutes*60, pReason); } else if(StrAllnum(pStr)) { @@ -1296,7 +1307,7 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser) } Addr = pServer->m_NetServer.ClientAddr(ClientId); - pServer->BanAdd(Addr, Minutes*60); + pServer->BanAdd(Addr, Minutes*60, pReason); } else { @@ -1426,8 +1437,8 @@ void CServer::RegisterCommands() { m_pConsole = Kernel()->RequestInterface(); - Console()->Register("kick", "i", CFGFLAG_SERVER, ConKick, this, ""); - Console()->Register("ban", "s?i", CFGFLAG_SERVER|CFGFLAG_STORE, ConBan, this, ""); + Console()->Register("kick", "i?s", CFGFLAG_SERVER, ConKick, this, ""); + Console()->Register("ban", "s?is", CFGFLAG_SERVER|CFGFLAG_STORE, ConBan, this, ""); Console()->Register("unban", "s", CFGFLAG_SERVER|CFGFLAG_STORE, ConUnban, this, ""); Console()->Register("bans", "", CFGFLAG_SERVER|CFGFLAG_STORE, ConBans, this, ""); Console()->Register("status", "", CFGFLAG_SERVER, ConStatus, this, ""); diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 98ba50bb9..3a720034a 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -165,7 +165,7 @@ public: void SendServerInfo(NETADDR *pAddr, int Token); void UpdateServerInfo(); - int BanAdd(NETADDR Addr, int Seconds); + int BanAdd(NETADDR Addr, int Seconds, const char *pReason); int BanRemove(NETADDR Addr); diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h index a2232320c..ef83a1916 100644 --- a/src/engine/shared/network.h +++ b/src/engine/shared/network.h @@ -272,10 +272,10 @@ public: int Update(); // - int Drop(int ClientID, const char *Reason); + int Drop(int ClientID, const char *pReason); // banning - int BanAdd(NETADDR Addr, int Seconds); + int BanAdd(NETADDR Addr, int Seconds, const char *pReason); int BanRemove(NETADDR Addr); int BanNum(); // caution, slow int BanGet(int Index, CBanInfo *pInfo); // caution, slow diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp index 4ed157eb2..b97575000 100644 --- a/src/engine/shared/network_conn.cpp +++ b/src/engine/shared/network_conn.cpp @@ -226,7 +226,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr) SetError(Str); } else - SetError("no reason given"); + SetError("No reason given"); if(g_Config.m_Debug) dbg_msg("conn", "closed reason='%s'", ErrorString()); @@ -304,7 +304,7 @@ int CNetConnection::Update() (Now-m_LastRecvTime) > time_freq()*10) { m_State = NET_CONNSTATE_ERROR; - SetError("timeout"); + SetError("Timeout"); } // fix resends @@ -316,7 +316,7 @@ int CNetConnection::Update() if(Now-pResend->m_FirstSendTime > time_freq()*10) { m_State = NET_CONNSTATE_ERROR; - SetError("too weak connection (not acked for 10 seconds)"); + SetError("Too weak connection (not acked for 10 seconds)"); } else { diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index ed714365f..692787750 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -139,7 +139,7 @@ int CNetServer::BanRemove(NETADDR Addr) return -1; } -int CNetServer::BanAdd(NETADDR Addr, int Seconds) +int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason) { int IpHash = (Addr.ip[0]+Addr.ip[1]+Addr.ip[2]+Addr.ip[3])&0xff; int Stamp = -1; @@ -213,9 +213,9 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds) NETADDR BanAddr; if(Seconds) - str_format(Buf, sizeof(Buf), "you have been banned for %d minutes", Seconds/60); + str_format(Buf, sizeof(Buf), "You have been banned for %d minutes (%s)", Seconds/60, pReason); else - str_format(Buf, sizeof(Buf), "you have been banned for life"); + str_format(Buf, sizeof(Buf), "You have been banned for life (%s)", pReason); for(int i = 0; i < MaxClients(); i++) { @@ -295,12 +295,12 @@ int CNetServer::Recv(CNetChunk *pChunk) { int Mins = ((pBan->m_Info.m_Expires - Now)+59)/60; if(Mins == 1) - str_format(BanStr, sizeof(BanStr), "banned for %d minute", Mins); + str_format(BanStr, sizeof(BanStr), "Banned for 1 minute"); else - str_format(BanStr, sizeof(BanStr), "banned for %d minutes", Mins); + str_format(BanStr, sizeof(BanStr), "Banned for %d minutes", Mins); } else - str_format(BanStr, sizeof(BanStr), "banned for life"); + str_format(BanStr, sizeof(BanStr), "Banned for life"); CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, BanStr, str_length(BanStr)+1); continue; } @@ -352,7 +352,7 @@ int CNetServer::Recv(CNetChunk *pChunk) if(FoundAddr++ >= m_MaxClientsPerIP) { char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "only %i players with same ip allowed", m_MaxClientsPerIP); + str_format(aBuf, sizeof(aBuf), "Only %d players with the same IP are allowed", m_MaxClientsPerIP); CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, aBuf, sizeof(aBuf)); return 0; } @@ -373,7 +373,7 @@ int CNetServer::Recv(CNetChunk *pChunk) if(!Found) { - const char FullMsg[] = "server is full"; + const char FullMsg[] = "This server is full"; CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, FullMsg, sizeof(FullMsg)); } } @@ -429,7 +429,7 @@ int CNetServer::Send(CNetChunk *pChunk) } else { - Drop(pChunk->m_ClientID, "error sending data"); + Drop(pChunk->m_ClientID, "Error sending data"); } } return 0; From 61201fea1311b62bd5390a3f1684695073315290 Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 9 Oct 2010 20:34:17 +0200 Subject: [PATCH 06/10] added reason to kick a player in the callvote tab --- src/game/client/components/menus.cpp | 1 + src/game/client/components/menus.h | 1 + src/game/client/components/menus_ingame.cpp | 20 ++++++++++++++++++-- src/game/client/components/voting.cpp | 11 +++++++---- src/game/client/components/voting.h | 2 +- src/game/server/gamecontext.cpp | 13 ++++++++++--- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index caad5a80b..05eb975be 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -99,6 +99,7 @@ CMenus::CMenus() m_LastInput = time_get(); str_copy(m_aCurrentDemoFolder, "demos", sizeof(m_aCurrentDemoFolder)); + m_aCallvoteReason[0] = 0; } vec4 CMenus::ButtonColorMul(const void *pID) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 3d11cf91c..1a63f5e54 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -152,6 +152,7 @@ class CMenus : public CComponent // for call vote int m_CallvoteSelectedOption; int m_CallvoteSelectedPlayer; + char m_aCallvoteReason[16]; // demo struct CDemoItem diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index f1a4b0dd7..972b1f594 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -414,12 +414,28 @@ void CMenus::RenderServerControl(CUIRect MainView) if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { - m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer); + m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason); + m_aCallvoteReason[0] = 0; SetActive(false); } } } - + + // render kick reason + if(s_ControlPage == 1) + { + CUIRect Reason; + Bottom.VSplitRight(140.0f, &Bottom, &Reason); + Bottom.VSplitRight(200.0f, &Bottom, &Reason); + const char *pLabel = Localize("Reason:"); + UI()->DoLabel(&Reason, pLabel, 14.0f, -1); + float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1); + Reason.VSplitLeft(w, 0, &Reason); + Reason.VSplitLeft(10.0f, 0, &Reason); + static float s_Offset = 0.0f; + DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL); + } + // force vote button (only available when authed in rcon) if(Client()->RconAuthed()) { diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index 17c0fe31f..c5e6a56c9 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -29,11 +29,14 @@ void CVoting::Callvote(const char *pType, const char *pValue) Client()->SendPackMsg(&Msg, MSGFLAG_VITAL); } -void CVoting::CallvoteKick(int ClientId) +void CVoting::CallvoteKick(int ClientId, char *pReason) { - char Buf[32]; - str_format(Buf, sizeof(Buf), "%d", ClientId); - Callvote("kick", Buf); + char aBuf[32]; + if(pReason[0]) + str_format(aBuf, sizeof(aBuf), "%d %s", ClientId, pReason); + else + str_format(aBuf, sizeof(aBuf), "%d", ClientId); + Callvote("kick", aBuf); } void CVoting::CallvoteOption(int OptionId) diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h index 1f5d2fc5e..1fc2aa530 100644 --- a/src/game/client/components/voting.h +++ b/src/game/client/components/voting.h @@ -39,7 +39,7 @@ public: void RenderBars(CUIRect Bars, bool Text); - void CallvoteKick(int ClientId); + void CallvoteKick(int ClientId, char *pReason); void CallvoteOption(int Option); void ForcevoteKick(int ClientId); void ForcevoteOption(int Option); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 4300bc2ef..95a7e5582 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -669,15 +669,22 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) return; } - str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s'", Server()->ClientName(ClientId), Server()->ClientName(KickId)); + const char *pReason = "No reason given"; + for(int i = 0; i < str_length(pMsg->m_Value)-1; i++) + { + if(pMsg->m_Value[i] == ' ') + pReason = &pMsg->m_Value[i+1]; + } + + str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientId), Server()->ClientName(KickId), pReason); str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId)); if (!g_Config.m_SvVoteKickBantime) - str_format(aCmd, sizeof(aCmd), "kick %d", KickId); + str_format(aCmd, sizeof(aCmd), "kick %d %s", KickId, pReason); else { char aBuf[64] = {0}; Server()->GetClientIP(KickId, aBuf, sizeof(aBuf)); - str_format(aCmd, sizeof(aCmd), "ban %s %d", aBuf, g_Config.m_SvVoteKickBantime); + str_format(aCmd, sizeof(aCmd), "ban %s %d %s", aBuf, g_Config.m_SvVoteKickBantime, pReason); } } From 8557d3a022cf250628dc8a03bdc26efd0338bc5d Mon Sep 17 00:00:00 2001 From: Choupom Date: Sun, 10 Oct 2010 12:11:58 +0200 Subject: [PATCH 07/10] updated french translation --- data/languages/french.txt | 486 +++++++++++++++++++------------------- 1 file changed, 242 insertions(+), 244 deletions(-) diff --git a/data/languages/french.txt b/data/languages/french.txt index 84be8803c..d028cc179 100644 --- a/data/languages/french.txt +++ b/data/languages/french.txt @@ -4,12 +4,39 @@ %d of %d servers, %d players == %d/%d serveurs, %d joueurs +%ds left +== %ds a quitté + +[N] Flip brush horizontal +== [N] Retourner horizontalement + +[NumPad+] Zoom in +== [ClavierNum+] Zoomer + +[NumPad-] Zoom out +== [ClavierNum-] Dézoomer + +[M] Flip brush vertical +== [M] Retourner verticalement + Abort == Annuler +Add +== Ajouter + +Add group +== Ajouter un groupe + +Add Image +== Ajouter une image + Address == Adresse +Adds a new group +== Ajoute un nouveau groupe + All == Tout le monde @@ -19,6 +46,15 @@ Alpha Always show name plates == Toujours afficher les pseudonymes +Anim +== Anim. + +Append +== Joindre + +Append map +== Joindre une carte + Are you sure that you want to quit? == Êtes-vous sûr de vouloir quitter ? @@ -34,15 +70,27 @@ Blue team wins! Body == Corps +Border +== Bordure + Call vote == Voter +Cancel +== Annuler + Chat == Chat +Clear collision +== Nettoyer la collision + Close == Fermer +Color+ +== Couleur+ + Compatible version == Version compatible @@ -52,12 +100,21 @@ Connect Connecting to == Connexion à +Connection Problems... +== Problèmes de connexion... + Console == Console Controls == Contrôles +Constructs collision from this layer +== Fait la collision depuis cette couche + +Creates a new map +== Crée une nouvelle carte + Current == Actuellement @@ -67,9 +124,30 @@ Current version: %s Custom colors == Couleurs personnalisées +Decrease +== Réduire + +Decrease animation speed +== Réduire la vitesse des animations + +Delete +== Supprimer + +Delete group +== Supprimer le groupe + +Delete layer +== Supprimer la couche + +Deletes the layer +== Supprime la couche + Demos == Démos +Detail +== Détail + Disconnect == Partir @@ -88,17 +166,38 @@ Draw! Dynamic Camera == Caméra dynamique +Embed +== Intégrer + +Embedded +== Intégré + +Embeds the image into the map file. +== Intègre l'image dans la carte. + Emoticon == Émoticônes Enter == Démarrer +Error +== Erreur + +error loading demo +== erreur de chargement de la démo + +Exits from the editor +== Ferme l'éditeur + +External +== Externe + FSAA samples == Échantillons FSAA Favorite -== Favoris +== Favori Favorites == Favoris @@ -106,6 +205,12 @@ Favorites Feet == Pieds +File +== Fichier + +Filename: +== Nom du fichier : + Filter == Filtre @@ -131,7 +236,7 @@ Game type == Type de jeu Game types: -== Types de jeu: +== Types de jeu : General == Général @@ -142,12 +247,18 @@ Graphics Grenade == Lance-grenade +Group +== Groupe + Hammer == Maillet Has people playing == Au moins un joueur +Height +== Hauteur + High Detail == Tous les détails @@ -160,6 +271,18 @@ Host address Hue == Teinte +Image +== Image + +Images +== Images + +Increase +== Augmenter + +Increase animation speed +== Augmenter la vitesse des animations + Info == Info. @@ -187,20 +310,32 @@ LAN Language == Langue +Layers +== Couches + Lht. == Lum. +Load a new image to use in the map +== Charger une image pour l'utiliser dans la carte + Loading == Chargement MOTD == MOTD +Make collision +== Faire la collision + +Make external +== Mettre en externe + Map == Carte Maximum ping: -== Ping maximum: +== Ping maximum : Miscellaneous == Divers @@ -223,6 +358,9 @@ Mute when not active Name == Nom +New +== Nouveau + News == Nouvelles @@ -232,6 +370,9 @@ Next weapon Nickname == Pseudonyme +Name: +== Nom : + No == Non @@ -244,13 +385,34 @@ No servers found No servers match your filter criteria == Aucun serveur ne correspond à vos critères +None +== Aucun + +Normal animation speed +== Vitesse normale des animations + Ok == Ok +Open +== Ouvrir + +Open map +== Ouvrir une carte + +Opens a map and adds everything from that map to the current one +== Ouvre une carte et ajoute son contenu dans la carte actuelle + +Opens a map for editing +== Ouvre une carte pour la modifier + +Order +== Ordre + Password == Mot de passe -Password Incorrect +Password incorrect == Mot de passe incorrect Ping @@ -268,6 +430,15 @@ Player Players == Joueurs +Please balance teams! +== Équilibrez les équipes ! + +Pos.+ +== Pos.+ + +Press right mouse button to create a new point +== Clic-droit pour créer un nouveau point + Prev. weapon == Arme précédente @@ -275,7 +446,7 @@ Quality Textures == Textures haute qualité Quick search: -== Recherche rapide: +== Recherche rapide : Quit == Quitter @@ -295,6 +466,27 @@ Refreshing master servers Remote console == Console serveur +Remove +== Enlever + +Removes collision from this layer +== Enlève la collision depuis cette couche + +Removes the image from the map file. +== Enlève l'image de la carte. + +Removes the image from the map +== Enlève l'image de la carte + +Replace +== Remplacer + +Replace Image +== Remplacer l'image + +Replaces the image with a new one +== Remplace l'image par une nouvelle + Reset filter == Filtres par défaut @@ -313,6 +505,27 @@ Sample rate Sat. == Sat. +Save +== Enregistrer + +Save As +== Enregistrer sous + +Save map +== Enregistrer la carte + +Saves the current map +== Enregistre la carte actuelle + +Saves the current map under a new name +== Enregistre la carte actuelle sous un autre nom + +Select group. Right click for properties. +== Sélectionner un groupe. Clic-droit pour voir les propriétés. + +Select layer. Right click for properties. +== Sélectionner une couche. Clic-droit pour voir les propriétés. + Score == Score @@ -320,7 +533,7 @@ Score board == Scores Score limit -== Score maxi +== Score limite Scoreboard == Scores @@ -328,11 +541,14 @@ Scoreboard Screenshot == Capture d'écran +Select image +== Sélectionner une image + Server details == Détails du serveur Server info -== Infos. serveur +== Info. serveur Server not full == Pas de serveurs pleins @@ -367,12 +583,18 @@ Spectate Spectators == Spectateurs +Square +== Carré + Standard gametype == Types de jeu standards Standard map == Cartes standards +Sudden Death +== Mort Subite + Switch weapon on pickup == Sélectionner l'arme ramassée @@ -421,12 +643,18 @@ Vote yes Voting == Vote +Warmup +== Échauffement + Weapon == Arme Welcome to Teeworlds == Bienvenue dans Teeworlds +Width +== Largeur + Yes == Oui @@ -436,53 +664,21 @@ You must restart the game for all settings to take effect. Your skin == Votre skin +ZI +== Z+ + +ZO +== Z- + + ##### needs translation #### -Password incorrect -== Password incorrect - -Please balance teams! -== Please balance teams! - -Connection Problems... -== Connection Problems... - -Warmup -== Warmup - -Sudden Death -== Sudden Death - -%ds left -== %ds left - -error loading demo -== error loading demo - -Error -== Error - -Open map -== Open map - -Open -== Open - -Save map -== Save map - -Save -== Save - HD == HD [ctrl+h] Toggle High Detail == [ctrl+h] Toggle High Detail -Anim -== Anim - [ctrl+m] Toggle animation == [ctrl+m] Toggle animation @@ -492,36 +688,9 @@ Proof [ctrl+p] Toggles proof borders. These borders represent what a player maximum can see. == [ctrl+p] Toggles proof borders. These borders represent what a player maximum can see. -ZO -== ZO - -[NumPad-] Zoom out -== [NumPad-] Zoom out - [NumPad*] Zoom to normal and remove editor offset == [NumPad*] Zoom to normal and remove editor offset -ZI -== ZI - -[NumPad+] Zoom in -== [NumPad+] Zoom in - -Increase animation speed -== Increase animation speed - -Normal animation speed -== Normal animation speed - -Decrease animation speed -== Decrease animation speed - -[N] Flip brush horizontal -== [N] Flip brush horizontal - -[M] Flip brush vertical -== [M] Flip brush vertical - CCW == CCW @@ -540,9 +709,6 @@ Add Quad Adds a new quad == Adds a new quad -Border -== Border - Left mouse button to move. Hold shift to move pivot. Hold ctrl to rotate. == Left mouse button to move. Hold shift to move pivot. Hold ctrl to rotate. @@ -555,84 +721,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == Use left mouse button to paint with the brush. Right button clears the brush. -Decrease -== Decrease - -Increase -== Increase - -None -== None - Toggle group visibility == Toggle group visibility -Select group. Right click for properties. -== Select group. Right click for properties. - -Add group -== Add group - -Adds a new group -== Adds a new group - -Embed -== Embed - -Embeds the image into the map file. -== Embeds the image into the map file. - -Make external -== Make external - -Removes the image from the map file. -== Removes the image from the map file. - -Replace -== Replace - -Replaces the image with a new one -== Replaces the image with a new one - -Replace Image -== Replace Image - -Remove -== Remove - -Removes the image from the map -== Removes the image from the map - -Embedded -== Embedded - -External -== External - -Select image -== Select image - -Load a new image to use in the map -== Load a new image to use in the map - -Add Image -== Add Image - -Add -== Add - -Filename: -== Filename: - -Cancel -== Cancel - -Layers -== Layers - -Images -== Images - Switch between images and layers managment. == Switch between images and layers managment. @@ -645,15 +736,9 @@ Toggles the envelope editor. %s Right click for context menu. == %s Right click for context menu. -Color+ -== Color+ - Creates a new color envelope == Creates a new color envelope -Pos.+ -== Pos.+ - Creates a new pos envelope == Creates a new pos envelope @@ -663,72 +748,12 @@ Previous Envelope Next Envelope == Next Envelope -Name: -== Name: - -Press right mouse button to create a new point -== Press right mouse button to create a new point - Switch curve type == Switch curve type Left mouse to drag. Hold shift to alter time point aswell. Right click to delete. == Left mouse to drag. Hold shift to alter time point aswell. Right click to delete. -New -== New - -Creates a new map -== Creates a new map - -Opens a map for editing -== Opens a map for editing - -Append -== Append - -Opens a map and adds everything from that map to the current one -== Opens a map and adds everything from that map to the current one - -Append map -== Append map - -Saves the current map -== Saves the current map - -Save As -== Save As - -Saves the current map under a new name -== Saves the current map under a new name - -Exits from the editor -== Exits from the editor - -Clear collision -== Clear collision - -Removes collision from this layer -== Removes collision from this layer - -Make collision -== Make collision - -Constructs collision from this layer -== Constructs collision from this layer - -Width -== Width - -Height -== Height - -Image -== Image - -Delete group -== Delete group - Add quads layer == Add quads layer @@ -741,30 +766,9 @@ Add tile layer Creates a new tile layer == Creates a new tile layer -Delete layer -== Delete Layer - -Deletes the layer -== Deletes the layer - -Group -== Group - -Order -== Order - -Detail -== Detail - -Delete -== Delete - Deletes the current quad == Deletes the current quad -Square -== Square - Squares the current quad == Squares the current quad @@ -780,13 +784,7 @@ Color Env Color TO == Color TO -Select layer. Right click for properties. -== Select layer. Right click for properties. - Toggle layer visibility == Toggle layer visibility -File -== File - ##### old translations #### From b65a26fe93e54af74d6304e66ec5942ecf4c48e8 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 11 Oct 2010 01:06:44 +0200 Subject: [PATCH 08/10] fixed last commits --- data/languages/french.txt | 8 ++++---- src/engine/server/server.cpp | 2 +- src/game/client/components/menus_ingame.cpp | 11 ++++++----- src/game/client/components/voting.cpp | 13 ++++++++----- src/game/client/components/voting.h | 4 ++-- src/game/server/gamecontext.cpp | 13 ++++++++----- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/data/languages/french.txt b/data/languages/french.txt index d028cc179..eaaa09dab 100644 --- a/data/languages/french.txt +++ b/data/languages/french.txt @@ -209,7 +209,7 @@ File == Fichier Filename: -== Nom du fichier : +== Nom du fichier: Filter == Filtre @@ -236,7 +236,7 @@ Game type == Type de jeu Game types: -== Types de jeu : +== Types de jeu: General == Général @@ -335,7 +335,7 @@ Map == Carte Maximum ping: -== Ping maximum : +== Ping maximum: Miscellaneous == Divers @@ -371,7 +371,7 @@ Nickname == Pseudonyme Name: -== Nom : +== Nom: No == Non diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index fc8ad4119..3b8771e41 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -634,7 +634,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) { // OH FUCK! wrong version, drop him char aReason[256]; - str_format(aReason, sizeof(aReason), "Wrong version : server is running \"%s\" and client \"%s\"", GameServer()->NetVersion(), aVersion); + str_format(aReason, sizeof(aReason), "Wrong version. Server is running '%s' and client '%s'", GameServer()->NetVersion(), aVersion); m_NetServer.Drop(ClientId, aReason); return; } diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 972b1f594..236a25dc8 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -425,13 +425,13 @@ void CMenus::RenderServerControl(CUIRect MainView) if(s_ControlPage == 1) { CUIRect Reason; - Bottom.VSplitRight(140.0f, &Bottom, &Reason); - Bottom.VSplitRight(200.0f, &Bottom, &Reason); + Bottom.VSplitRight(40.0f, &Bottom, 0); + Bottom.VSplitRight(160.0f, &Bottom, &Reason); + Reason.HSplitTop(5.0f, 0, &Reason); const char *pLabel = Localize("Reason:"); UI()->DoLabel(&Reason, pLabel, 14.0f, -1); float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1); - Reason.VSplitLeft(w, 0, &Reason); - Reason.VSplitLeft(10.0f, 0, &Reason); + Reason.VSplitLeft(w+10.0f, 0, &Reason); static float s_Offset = 0.0f; DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL); } @@ -453,7 +453,8 @@ void CMenus::RenderServerControl(CUIRect MainView) if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { - m_pClient->m_pVoting->ForcevoteKick(m_CallvoteSelectedPlayer); + m_pClient->m_pVoting->ForcevoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason); + m_aCallvoteReason[0] = 0; SetActive(false); } } diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index c5e6a56c9..8a98e1b08 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -29,7 +29,7 @@ void CVoting::Callvote(const char *pType, const char *pValue) Client()->SendPackMsg(&Msg, MSGFLAG_VITAL); } -void CVoting::CallvoteKick(int ClientId, char *pReason) +void CVoting::CallvoteKick(int ClientId, const char *pReason) { char aBuf[32]; if(pReason[0]) @@ -55,11 +55,14 @@ void CVoting::CallvoteOption(int OptionId) } } -void CVoting::ForcevoteKick(int ClientId) +void CVoting::ForcevoteKick(int ClientId, const char *pReason) { - char Buf[32]; - str_format(Buf, sizeof(Buf), "kick %d", ClientId); - Client()->Rcon(Buf); + char aBuf[32]; + if(pReason[0]) + str_format(aBuf, sizeof(aBuf), "kick %d \"%s\"", ClientId, pReason); + else + str_format(aBuf, sizeof(aBuf), "kick %d", ClientId); + Client()->Rcon(aBuf); } void CVoting::ForcevoteOption(int OptionId) diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h index 1fc2aa530..ff982640e 100644 --- a/src/game/client/components/voting.h +++ b/src/game/client/components/voting.h @@ -39,9 +39,9 @@ public: void RenderBars(CUIRect Bars, bool Text); - void CallvoteKick(int ClientId, char *pReason); + void CallvoteKick(int ClientId, const char *pReason); void CallvoteOption(int Option); - void ForcevoteKick(int ClientId); + void ForcevoteKick(int ClientId, const char *pReason); void ForcevoteOption(int Option); void Vote(int v); // -1 = no, 1 = yes diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 95a7e5582..0faba6fc1 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -670,21 +670,24 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) } const char *pReason = "No reason given"; - for(int i = 0; i < str_length(pMsg->m_Value)-1; i++) + for(const char *p = pMsg->m_Value; *p; ++p) { - if(pMsg->m_Value[i] == ' ') - pReason = &pMsg->m_Value[i+1]; + if(*p == ' ') + { + pReason = p+1; + break; + } } str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientId), Server()->ClientName(KickId), pReason); str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId)); if (!g_Config.m_SvVoteKickBantime) - str_format(aCmd, sizeof(aCmd), "kick %d %s", KickId, pReason); + str_format(aCmd, sizeof(aCmd), "kick %d \"Kicked by vote\"", KickId); else { char aBuf[64] = {0}; Server()->GetClientIP(KickId, aBuf, sizeof(aBuf)); - str_format(aCmd, sizeof(aCmd), "ban %s %d %s", aBuf, g_Config.m_SvVoteKickBantime, pReason); + str_format(aCmd, sizeof(aCmd), "ban %s %d \"Banned by vote\"", aBuf, g_Config.m_SvVoteKickBantime); } } From de7504282c372a391bca19bb664b9ccf22fad47b Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 11 Oct 2010 01:36:46 +0200 Subject: [PATCH 09/10] made edit boxes scrollable. Closes #96 --- src/game/client/components/menus.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 05eb975be..33dcbb999 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -220,7 +220,10 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS { int Inside = UI()->MouseInside(pRect); bool ReturnValue = false; + bool UpdateOffset = false; static int s_AtIndex = 0; + static bool s_DoScroll = false; + static float s_ScrollStart = 0.0f; if(UI()->LastActiveItem() == pID) { @@ -230,6 +233,8 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS if(Inside && UI()->MouseButton(0)) { + s_DoScroll = true; + s_ScrollStart = UI()->MouseX(); int MxRel = (int)(UI()->MouseX() - pRect->x); for(int i = 1; i <= Len; i++) @@ -244,6 +249,24 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS s_AtIndex = Len; } } + else if(!UI()->MouseButton(0)) + s_DoScroll = false; + else if(s_DoScroll) + { + // do scrolling + if(UI()->MouseX() < pRect->x && s_ScrollStart-UI()->MouseX() > 10.0f) + { + s_AtIndex = max(0, s_AtIndex-1); + s_ScrollStart = UI()->MouseX(); + UpdateOffset = true; + } + else if(UI()->MouseX() > pRect->x+pRect->w && UI()->MouseX()-s_ScrollStart > 10.0f) + { + s_AtIndex = min(Len, s_AtIndex+1); + s_ScrollStart = UI()->MouseX(); + UpdateOffset = true; + } + } for(int i = 0; i < m_NumInputEvents; i++) { @@ -257,7 +280,10 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS if(UI()->ActiveItem() == pID) { if(!UI()->MouseButton(0)) + { + s_DoScroll = false; UI()->SetActiveItem(0); + } } else if(UI()->HotItem() == pID) { @@ -292,7 +318,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS } // check if the text has to be moved - if(UI()->LastActiveItem() == pID && !JustGotActive && m_NumInputEvents) + if(UI()->LastActiveItem() == pID && !JustGotActive && (UpdateOffset || m_NumInputEvents)) { float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex)*UI()->Scale(); if(w-*Offset > Textbox.w) From 411db8b88517bc5cf81289bdbcc1ed71326c6f87 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 11 Oct 2010 02:29:30 +0200 Subject: [PATCH 10/10] fixed that chat message gets out of the window. Closes #102 --- src/engine/client/text.cpp | 11 ++++++++--- src/engine/textrender.h | 1 + src/game/client/components/chat.cpp | 24 +++++++++++++++++++++++- src/game/client/components/chat.h | 2 ++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index 0fb6b043f..79f95b305 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -541,6 +541,7 @@ public: int i; int GotNewLine = 0; float DrawX, DrawY; + int LineCount; float CursorX, CursorY; const char *pEnd; @@ -590,6 +591,7 @@ public: const char *pEnd = pCurrent+Length; DrawX = CursorX; DrawY = CursorY; + LineCount = pCursor->m_LineCount; if(pCursor->m_Flags&TEXTFLAG_RENDER) { @@ -607,7 +609,7 @@ public: Graphics()->SetColor(m_TextR, m_TextG, m_TextB, m_TextA); } - while(pCurrent < pEnd) + while(pCurrent < pEnd && (pCursor->m_MaxLines < 1 || LineCount <= pCursor->m_MaxLines)) { int NewLine = 0; const char *pBatchEnd = pEnd; @@ -666,7 +668,9 @@ public: DrawY += Size; DrawX = (int)(DrawX * FakeToScreenX) / FakeToScreenX; // realign DrawY = (int)(DrawY * FakeToScreenY) / FakeToScreenY; - ++pCursor->m_LineCount; + ++LineCount; + if(pCursor->m_MaxLines > 0 && LineCount > pCursor->m_MaxLines) + break; continue; } @@ -702,7 +706,7 @@ public: GotNewLine = 1; DrawX = (int)(DrawX * FakeToScreenX) / FakeToScreenX; // realign DrawY = (int)(DrawY * FakeToScreenY) / FakeToScreenY; - ++pCursor->m_LineCount; + ++LineCount; } } @@ -711,6 +715,7 @@ public: } pCursor->m_X = DrawX; + pCursor->m_LineCount = LineCount; if(GotNewLine) pCursor->m_Y = DrawY; diff --git a/src/engine/textrender.h b/src/engine/textrender.h index 6e28b1d5d..4fa1ac5bc 100644 --- a/src/engine/textrender.h +++ b/src/engine/textrender.h @@ -17,6 +17,7 @@ public: int m_Flags; int m_LineCount; int m_CharCount; + int m_MaxLines; float m_StartX; float m_StartY; diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index d0b216a5e..1fcdc0cba 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -31,6 +31,8 @@ void CChat::OnReset() } m_Show = false; + m_InputUpdate = false; + m_ChatStringOffset = 0; } void CChat::OnRelease() @@ -101,7 +103,10 @@ bool CChat::OnInput(IInput::CEvent e) m_pClient->OnRelease(); } else + { m_Input.ProcessInput(e); + m_InputUpdate = true; + } return true; } @@ -203,6 +208,7 @@ void CChat::OnRender() CTextCursor Cursor; TextRender()->SetCursor(&Cursor, x, y, 8.0f, TEXTFLAG_RENDER); Cursor.m_LineWidth = 200.0f; + Cursor.m_MaxLines = 2; if(m_Mode == MODE_ALL) TextRender()->TextEx(&Cursor, Localize("All"), -1); @@ -213,7 +219,23 @@ void CChat::OnRender() TextRender()->TextEx(&Cursor, ": ", -1); - TextRender()->TextEx(&Cursor, m_Input.GetString(), m_Input.GetCursorOffset()); + // check if the visible text has to be moved + if(m_InputUpdate) + { + if(m_ChatStringOffset > m_Input.GetCursorOffset()) + --m_ChatStringOffset; + else + { + CTextCursor Temp = Cursor; + Temp.m_Flags = 0; + TextRender()->TextEx(&Temp, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset); + TextRender()->TextEx(&Temp, "|", -1); + if(Temp.m_LineCount > 2) + ++m_ChatStringOffset; + } + } + + TextRender()->TextEx(&Cursor, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset); CTextCursor Marker = Cursor; TextRender()->TextEx(&Marker, "|", -1); TextRender()->TextEx(&Cursor, m_Input.GetString()+m_Input.GetCursorOffset(), -1); diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index c1867c002..85aca296d 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -35,6 +35,8 @@ class CChat : public CComponent int m_Mode; bool m_Show; + bool m_InputUpdate; + int m_ChatStringOffset; static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSayTeam(IConsole::IResult *pResult, void *pUserData);