diff options
| author | Thomas <lordskelethom@gmail.com> | 2010-05-30 12:01:11 +0000 |
|---|---|---|
| committer | Thomas <lordskelethom@gmail.com> | 2010-05-30 12:01:11 +0000 |
| commit | 361380d63039737df51c1ed684d5f70758c96790 (patch) | |
| tree | 6709a802772f65dc26eb6acf332023b89bf193f8 /src/game/client/components | |
| parent | 47b68170ad8a0d6b4fd5be182d8ba0c953114cb4 (diff) | |
| download | zcatch-361380d63039737df51c1ed684d5f70758c96790.tar.gz zcatch-361380d63039737df51c1ed684d5f70758c96790.zip | |
*some esthetic changes
*split "CHud::RenderGoals()" *added "reload" command *added the ability to show last chat lines (+show_chat) *updated french.txt
Diffstat (limited to 'src/game/client/components')
| -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 |
7 files changed, 60 insertions, 34 deletions
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 |