diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine/client/client.cpp | 1 | ||||
| -rw-r--r-- | src/engine/server/server.cpp | 13 | ||||
| -rw-r--r-- | src/engine/server/server.h | 4 | ||||
| -rw-r--r-- | src/engine/shared/config_variables.h | 1 | ||||
| -rw-r--r-- | src/game/client/components/binds.cpp | 1 | ||||
| -rw-r--r-- | src/game/client/components/chat.cpp | 15 | ||||
| -rw-r--r-- | src/game/client/components/chat.h | 4 | ||||
| -rw-r--r-- | src/game/client/components/hud.cpp | 55 | ||||
| -rw-r--r-- | src/game/client/components/hud.h | 7 | ||||
| -rw-r--r-- | src/game/client/components/menus.cpp | 7 | ||||
| -rw-r--r-- | src/game/client/components/menus_settings.cpp | 5 |
11 files changed, 75 insertions, 38 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index aca576a7..97adeeac 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1916,6 +1916,7 @@ void CClient::RegisterCommands() m_pConsole->Register("shutdown", "", CFGFLAG_SERVER, Con_ServerDummy, this, "Shut down"); m_pConsole->Register("record", "s", CFGFLAG_SERVER, Con_ServerDummy, this, "Record to a file"); m_pConsole->Register("stoprecord", "", CFGFLAG_SERVER, Con_ServerDummy, this, "Stop recording"); + m_pConsole->Register("reload", "", CFGFLAG_SERVER, Con_ServerDummy, this, "Reload the map"); m_pConsole->Register("quit", "", CFGFLAG_CLIENT, Con_Quit, this, "Quit Teeworlds"); m_pConsole->Register("exit", "", CFGFLAG_CLIENT, Con_Quit, this, "Quit Teeworlds"); diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 45cec1e4..05e56a74 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -178,6 +178,8 @@ CServer::CServer() : m_DemoRecorder(&m_SnapshotDelta) m_pCurrentMapData = 0; m_CurrentMapSize = 0; + + m_MapReload = 0; Init(); } @@ -1039,9 +1041,9 @@ int CServer::Run() int NewTicks = 0; // load new map TODO: don't poll this - if(str_comp(g_Config.m_SvMap, m_aCurrentMap) != 0 || g_Config.m_SvMapReload) + if(str_comp(g_Config.m_SvMap, m_aCurrentMap) != 0 || m_MapReload) { - g_Config.m_SvMapReload = 0; + m_MapReload = 0; // load map if(LoadMap(g_Config.m_SvMap)) @@ -1270,6 +1272,11 @@ void CServer::ConStopRecord(IConsole::IResult *pResult, void *pUser) ((CServer *)pUser)->m_DemoRecorder.Stop(); } +void CServer::ConMapReload(IConsole::IResult *pResult, void *pUser) +{ + ((CServer *)pUser)->m_MapReload = 1; +} + void CServer::ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) { pfnCallback(pResult, pCallbackUserData); @@ -1290,6 +1297,8 @@ void CServer::RegisterCommands() Console()->Register("record", "s", CFGFLAG_SERVER, ConRecord, this, ""); Console()->Register("stoprecord", "", CFGFLAG_SERVER, ConStopRecord, this, ""); + + Console()->Register("reload", "", CFGFLAG_SERVER, ConMapReload, this, ""); Console()->Chain("sv_name", ConchainSpecialInfoupdate, this); Console()->Chain("password", ConchainSpecialInfoupdate, this); diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 6904085a..7d56bd33 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -25,7 +25,7 @@ class CSnapIDPool int m_LastTimed; int m_Usage; int m_InUsage; - + public: CSnapIDPool(); @@ -105,6 +105,7 @@ public: int64 m_GameStartTime; //int m_CurrentGameTick; int m_RunServer; + int m_MapReload; char m_aBrowseinfoGametype[16]; int m_BrowseinfoProgression; @@ -181,6 +182,7 @@ public: static void ConShutdown(IConsole::IResult *pResult, void *pUser); static void ConRecord(IConsole::IResult *pResult, void *pUser); static void ConStopRecord(IConsole::IResult *pResult, void *pUser); + static void ConMapReload(IConsole::IResult *pResult, void *pUser); static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); void RegisterCommands(); diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index e5541911..cc36b932 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -67,7 +67,6 @@ MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, 8, 1, MAX_CLIENTS, CFGFLAG_SERVER MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only") MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing") MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 32, "", CFGFLAG_SERVER, "Remote console password") -MACRO_CONFIG_INT(SvMapReload, sv_map_reload, 0, 0, 1, CFGFLAG_SERVER, "Reload the current map") MACRO_CONFIG_INT(Debug, debug, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Debug mode") MACRO_CONFIG_INT(DbgStress, dbg_stress, 0, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Stress systems") diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index d08f363d..1fb5ecc5 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -85,6 +85,7 @@ void CBinds::SetDefaults() Bind(KEY_F1, "toggle_local_console"); Bind(KEY_F2, "toggle_remote_console"); Bind(KEY_TAB, "+scoreboard"); + Bind('u', "+show_chat"); Bind(KEY_F10, "screenshot"); Bind('a', "+left"); diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 1a2c828d..da56206f 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -28,6 +28,8 @@ void CChat::OnReset() m_aLines[i].m_aText[0] = 0; m_aLines[i].m_aName[0] = 0; } + + m_Show = false; } void CChat::OnStateChange(int NewState, int OldState) @@ -62,11 +64,17 @@ void CChat::ConChat(IConsole::IResult *pResult, void *pUserData) dbg_msg("console", "expected all or team as mode"); } +void CChat::ConShowChat(IConsole::IResult *pResult, void *pUserData) +{ + ((CChat *)pUserData)->m_Show = pResult->GetInteger(0) != 0; +} + void CChat::OnConsoleInit() { Console()->Register("say", "r", CFGFLAG_CLIENT, ConSay, this, "Say in chat"); Console()->Register("say_team", "r", CFGFLAG_CLIENT, ConSayTeam, this, "Say in team chat"); Console()->Register("chat", "s", CFGFLAG_CLIENT, ConChat, this, "Enable chat with all/team mode"); + Console()->Register("+show_chat", "", CFGFLAG_CLIENT, ConShowChat, this, "Show chat"); } bool CChat::OnInput(IInput::CEvent e) @@ -202,11 +210,11 @@ void CChat::OnRender() for(i = 0; i < MAX_LINES; i++) { int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES; - if(Now > m_aLines[r].m_Time+15*time_freq()) + if(Now > m_aLines[r].m_Time+15*time_freq() && !m_Show) break; float Begin = x; - float FontSize = 7.0f; + float FontSize = 5.0f; // get the y offset CTextCursor Cursor; @@ -217,7 +225,8 @@ void CChat::OnRender() y -= Cursor.m_Y + Cursor.m_FontSize; // cut off if msgs waste too much space - if(y < 200.0f) + int HeightLimit = m_Show ? 0.0f : 200.0f; + if(y < HeightLimit) break; // reset the cursor diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 8a33e9e8..02afc902 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -9,7 +9,7 @@ class CChat : public CComponent enum { - MAX_LINES = 10, + MAX_LINES = 25, }; struct CLine @@ -34,10 +34,12 @@ class CChat : public CComponent }; int m_Mode; + bool m_Show; static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSayTeam(IConsole::IResult *pResult, void *pUserData); static void ConChat(IConsole::IResult *pResult, void *pUserData); + static void ConShowChat(IConsole::IResult *pResult, void *pUserData); public: CChat(); diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index f4a24384..fd44af41 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -25,21 +25,11 @@ void CHud::OnReset() { } -void CHud::RenderGoals() +void CHud::RenderGameTimer() { - // TODO: split this up into these: - // render_gametimer - // render_suddendeath - // render_scorehud - // render_warmuptimer + float Half = 300.0f*Graphics()->ScreenAspect()/2.0f; + Graphics()->MapScreen(0, 0, 300.0f*Graphics()->ScreenAspect(), 300.0f); - int GameFlags = m_pClient->m_Snap.m_pGameobj->m_Flags; - - float Whole = 300*Graphics()->ScreenAspect(); - float Half = Whole/2.0f; - - - Graphics()->MapScreen(0,0,300*Graphics()->ScreenAspect(),300); if(!m_pClient->m_Snap.m_pGameobj->m_SuddenDeath) { char Buf[32]; @@ -54,18 +44,30 @@ void CHud::RenderGoals() else Time = (Client()->GameTick()-m_pClient->m_Snap.m_pGameobj->m_RoundStartTick)/Client()->GameTickSpeed(); - str_format(Buf, sizeof(Buf), "%d:%02d", Time /60, Time %60); - float w = TextRender()->TextWidth(0, 16, Buf, -1); - TextRender()->Text(0, Half-w/2, 2, 16, Buf, -1); + str_format(Buf, sizeof(Buf), "%d:%02d", Time/60, Time%60); + float FontSize = 10.0f; + float w = TextRender()->TextWidth(0, FontSize, Buf, -1); + TextRender()->Text(0, Half-w/2, 2, FontSize, Buf, -1); } +} +void CHud::RenderSuddenDeath() +{ if(m_pClient->m_Snap.m_pGameobj->m_SuddenDeath) { + float Half = 300.0f*Graphics()->ScreenAspect()/2.0f; const char *pText = "Sudden Death"; - float w = TextRender()->TextWidth(0, 16, pText, -1); - TextRender()->Text(0, Half-w/2, 2, 16, pText, -1); + float FontSize = 12.0f; + float w = TextRender()->TextWidth(0, FontSize, pText, -1); + TextRender()->Text(0, Half-w/2, 2, FontSize, pText, -1); } +} +void CHud::RenderScoreHud() +{ + int GameFlags = m_pClient->m_Snap.m_pGameobj->m_Flags; + float Whole = 300*Graphics()->ScreenAspect(); + // render small score hud if(!(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver) && (GameFlags&GAMEFLAG_TEAMS)) { @@ -122,21 +124,25 @@ void CHud::RenderGoals() TextRender()->Text(0, Whole-20-w/2, 300-40-15+t*20, 14, Buf, -1); } } +} +void CHud::RenderWarmupTimer() +{ // render warmup timer if(m_pClient->m_Snap.m_pGameobj->m_Warmup) { char Buf[256]; - float w = TextRender()->TextWidth(0, 24, "Warmup", -1); - TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 50, 24, "Warmup", -1); + float FontSize = 20.0f; + float w = TextRender()->TextWidth(0, FontSize, "Warmup", -1); + TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 50, FontSize, "Warmup", -1); int Seconds = m_pClient->m_Snap.m_pGameobj->m_Warmup/SERVER_TICK_SPEED; if(Seconds < 5) str_format(Buf, sizeof(Buf), "%d.%d", Seconds, (m_pClient->m_Snap.m_pGameobj->m_Warmup*10/SERVER_TICK_SPEED)%10); else str_format(Buf, sizeof(Buf), "%d", Seconds); - w = TextRender()->TextWidth(0, 24, Buf, -1); - TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 75, 24, Buf, -1); + w = TextRender()->TextWidth(0, FontSize, Buf, -1); + TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 75, FontSize, Buf, -1); } } @@ -310,7 +316,10 @@ void CHud::OnRender() if(m_pClient->m_Snap.m_pLocalCharacter && !Spectate && !(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)) RenderHealthAndAmmo(); - RenderGoals(); + RenderGameTimer(); + RenderSuddenDeath(); + RenderScoreHud(); + RenderWarmupTimer(); RenderFps(); if(Client()->State() != IClient::STATE_DEMOPLAYBACK) RenderConnectionWarning(); diff --git a/src/game/client/components/hud.h b/src/game/client/components/hud.h index 43f0e3a8..50f6b3b1 100644 --- a/src/game/client/components/hud.h +++ b/src/game/client/components/hud.h @@ -14,8 +14,11 @@ class CHud : public CComponent void RenderTeambalanceWarning(); void RenderVoting(); void RenderHealthAndAmmo(); - void RenderGoals(); - + void RenderGameTimer(); + void RenderSuddenDeath(); + void RenderScoreHud(); + void RenderWarmupTimer(); + void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup); public: CHud(); diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 763e33b4..29063b80 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -268,7 +268,8 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS CUIRect Textbox = *pRect; RenderTools()->DrawUIRect(&Textbox, vec4(1, 1, 1, 0.5f), Corners, 3.0f); - Textbox.VMargin(3.0f, &Textbox); + Textbox.VMargin(2.0f, &Textbox); + Textbox.HMargin(2.0f, &Textbox); const char *pDisplayStr = pStr; char aStars[128]; @@ -320,9 +321,9 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS Textbox = *pRect; Textbox.VSplitLeft(2.0f, 0, &Textbox); Textbox.x += (w-*Offset)*UI()->Scale(); - Textbox.y -= FontSize/10.f; + if((2*time_get()/time_freq()) % 2) // make it blink - UI()->DoLabel(&Textbox, "|", FontSize*1.1f, -1); + UI()->DoLabel(&Textbox, "|", FontSize, -1); } UI()->ClipDisable(); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index dc5451b2..af1c8fcc 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -302,6 +302,7 @@ static CKeyInfo gs_aKeys[] = { Localize("Vote no"), "vote no", 0 }, { Localize("Chat"), "chat all", 0 }, { Localize("Team chat"), "chat team", 0 }, + { Localize("Show chat"), "+show_chat", 0 }, { Localize("Emoticon"), "+emote", 0 }, { Localize("Console"), "toggle_local_console", 0 }, { Localize("Remote console"), "toggle_remote_console", 0 }, @@ -418,7 +419,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) TextRender()->Text(0, ChatSettings.x, ChatSettings.y, 14, Localize("Chat"), -1); ChatSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &ChatSettings); - UiDoGetButtons(14, 16, ChatSettings); + UiDoGetButtons(14, 17, ChatSettings); } // misc settings @@ -431,7 +432,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) TextRender()->Text(0, MiscSettings.x, MiscSettings.y, 14, Localize("Miscellaneous"), -1); MiscSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &MiscSettings); - UiDoGetButtons(16, 21, MiscSettings); + UiDoGetButtons(17, 21, MiscSettings); } // defaults |