From 5e1b3c74ef898cfb5a802eaf7acc60483a2eb81b Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 6 Sep 2010 17:04:10 +0200 Subject: [PATCH 1/5] Git does this one automatically, I guess it fixes lineendings. --- src/game/client/components/chat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 4429837ba..167fe181e 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -207,8 +207,8 @@ void CChat::OnRender() y -= 8.0f; int64 Now = time_get(); - float LineWidth = m_pClient->m_pScoreboard->Active() ? 95.0f : 200.0f; - float HeightLimit = m_pClient->m_pScoreboard->Active() ? 220.0f : m_Show ? 50.0f : 200.0f; + float LineWidth = m_pClient->m_pScoreboard->Active() ? 95.0f : 200.0f; + float HeightLimit = m_pClient->m_pScoreboard->Active() ? 220.0f : m_Show ? 50.0f : 200.0f; for(int i = 0; i < MAX_LINES; i++) { int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES; From ea25972e21f0d3ec599f7822981b40cf1b029e4a Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 7 Sep 2010 19:03:59 +0200 Subject: [PATCH 2/5] added rec notification by ghost91-. Closes #82 --- src/game/client/components/scoreboard.cpp | 25 +++++++++++++++++++++++ src/game/client/components/scoreboard.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 5f9aeea76..2214c2d14 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -261,6 +262,29 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch } } +void CScoreboard::RenderRecordingNotification(float x) +{ + if(!m_pClient->DemoRecorder()->IsRecording()) + return; + + //draw the box + Graphics()->BlendNormal(); + Graphics()->TextureSet(-1); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.4f); + RenderTools()->DrawRoundRectExt(x, 0.0f, 120.0f, 50.0f, 15.0f, CUI::CORNER_B); + Graphics()->QuadsEnd(); + + //draw the red dot + Graphics()->QuadsBegin(); + Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); + RenderTools()->DrawRoundRect(x+20, 15.0f, 20.0f, 20.0f, 10.0f); + Graphics()->QuadsEnd(); + + //draw the text + TextRender()->Text(0, x+50.0f, 8.0f, 24.0f, "REC", -1); +} + void CScoreboard::OnRender() { bool DoScoreBoard = false; @@ -321,6 +345,7 @@ void CScoreboard::OnRender() RenderGoals(Width/2-w/2, 150+750+25, w); RenderSpectators(Width/2-w/2, 150+750+25+50+25, w); + RenderRecordingNotification((Width/7)*4); } bool CScoreboard::Active() diff --git a/src/game/client/components/scoreboard.h b/src/game/client/components/scoreboard.h index f94c6b49f..be0292cfa 100644 --- a/src/game/client/components/scoreboard.h +++ b/src/game/client/components/scoreboard.h @@ -7,6 +7,7 @@ class CScoreboard : public CComponent void RenderGoals(float x, float y, float w); void RenderSpectators(float x, float y, float w); void RenderScoreboard(float x, float y, float w, int Team, const char *pTitle); + void RenderRecordingNotification(float x); static void ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData); From 56c4081da403728486bf747666c0f745567a0be6 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 6 Sep 2010 21:36:39 +0200 Subject: [PATCH 3/5] Demo name is now showed while playing a demo file --- src/engine/demo.h | 1 + src/engine/shared/demorec.cpp | 15 +++++++++++++++ src/engine/shared/demorec.h | 2 ++ src/game/client/components/menus_demo.cpp | 16 ++++++++++++++-- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/engine/demo.h b/src/engine/demo.h index 6abc9b2d8..e0cad3875 100644 --- a/src/engine/demo.h +++ b/src/engine/demo.h @@ -24,6 +24,7 @@ public: virtual void Pause() = 0; virtual void Unpause() = 0; virtual const CInfo *BaseInfo() const = 0; + virtual char *GetDemoName() = 0; }; class IDemoRecorder : public IInterface diff --git a/src/engine/shared/demorec.cpp b/src/engine/shared/demorec.cpp index 960634b19..0c2efd40c 100644 --- a/src/engine/shared/demorec.cpp +++ b/src/engine/shared/demorec.cpp @@ -516,6 +516,9 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const return -1; } + // store the filename + str_copy(m_aFilename, pFilename, sizeof(m_aFilename)); + // clear the playback info mem_zero(&m_Info, sizeof(m_Info)); m_Info.m_Info.m_FirstTick = -1; @@ -722,7 +725,19 @@ int CDemoPlayer::Stop() m_File = 0; mem_free(m_pKeyFrames); m_pKeyFrames = 0; + str_copy(m_aFilename, "", sizeof(m_aFilename)); return 0; } +char *CDemoPlayer::GetDemoName() +{ + // get the name of the demo without its path + char *pDemoShortName = &m_aFilename[0]; + for(int i = 0; i < str_length(m_aFilename)-1; i++) + { + if(m_aFilename[i] == '/' || m_aFilename[i] == '\\') + pDemoShortName = &m_aFilename[i+1]; + } + return pDemoShortName; +} diff --git a/src/engine/shared/demorec.h b/src/engine/shared/demorec.h index cdf46e99a..39e9ebdb9 100644 --- a/src/engine/shared/demorec.h +++ b/src/engine/shared/demorec.h @@ -83,6 +83,7 @@ private: class IConsole *m_pConsole; IOHANDLE m_File; + char m_aFilename[256]; CKeyFrame *m_pKeyFrames; CPlaybackInfo m_Info; @@ -109,6 +110,7 @@ public: void SetSpeed(float Speed); int SetPos(float Precent); const CInfo *BaseInfo() const { return &m_Info.m_Info; } + char *GetDemoName(); int Update(); diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 8e89ee061..526ff0a98 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -42,11 +43,12 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) const float SeekBarHeight = 15.0f; const float ButtonbarHeight = 20.0f; + const float NameBarHeight = 20.0f; const float Margins = 5.0f; float TotalHeight; if(m_MenuActive) - TotalHeight = SeekBarHeight+ButtonbarHeight+Margins*3; + TotalHeight = SeekBarHeight+ButtonbarHeight+NameBarHeight+Margins*3; else TotalHeight = SeekBarHeight+Margins*2; @@ -58,7 +60,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) MainView.Margin(5.0f, &MainView); - CUIRect SeekBar, ButtonBar; + CUIRect SeekBar, ButtonBar, NameBar; int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick; int TotalTicks = pInfo->m_LastTick - pInfo->m_FirstTick; @@ -67,6 +69,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) { MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar); ButtonBar.HSplitTop(Margins, 0, &ButtonBar); + ButtonBar.HSplitBottom(NameBarHeight, &ButtonBar, &NameBar); + NameBar.HSplitTop(3.5f, 0, &NameBar); } else SeekBar = MainView; @@ -198,6 +202,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) static int s_ExitButton = 0; if(DoButton_DemoPlayer(&s_ExitButton, Localize("Close"), 0, &Button)) Client()->Disconnect(); + + // demo name + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Demofile: %s", DemoPlayer()->GetDemoName()); + CTextCursor Cursor; + TextRender()->SetCursor(&Cursor, NameBar.x, NameBar.y, Button.h*0.7f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = 450.0f; + TextRender()->TextEx(&Cursor, aBuf, -1); } } From eecdff0cf5c5153cc55c74e6227a2fd9b7068923 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 7 Sep 2010 19:31:20 +0200 Subject: [PATCH 4/5] fixed overlapping in last commit --- src/game/client/components/menus_demo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 526ff0a98..6c5dcbe4c 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -70,7 +70,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar); ButtonBar.HSplitTop(Margins, 0, &ButtonBar); ButtonBar.HSplitBottom(NameBarHeight, &ButtonBar, &NameBar); - NameBar.HSplitTop(3.5f, 0, &NameBar); + NameBar.HSplitTop(4.0f, 0, &NameBar); } else SeekBar = MainView; @@ -207,8 +207,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) char aBuf[128]; str_format(aBuf, sizeof(aBuf), "Demofile: %s", DemoPlayer()->GetDemoName()); CTextCursor Cursor; - TextRender()->SetCursor(&Cursor, NameBar.x, NameBar.y, Button.h*0.7f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); - Cursor.m_LineWidth = 450.0f; + TextRender()->SetCursor(&Cursor, NameBar.x, NameBar.y, Button.h*0.5f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = MainView.w; TextRender()->TextEx(&Cursor, aBuf, -1); } } From 3baf5223302363139e59691fd3d1c658312facf4 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 6 Sep 2010 21:55:09 +0200 Subject: [PATCH 5/5] added the option to hide the console window on the client, too. Fixes #48 --- src/engine/client/client.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 6ddf364f4..42dd4a9ea 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -25,6 +25,12 @@ #include "client.h" +#if defined(CONF_FAMILY_WINDOWS) + #define _WIN32_WINNT 0x0500 + #define NOGDI + #include +#endif + void CGraph::Init(float Min, float Max) { @@ -1997,6 +2003,17 @@ extern "C" int SDL_main(int argc, const char **argv) // ignore_convention int main(int argc, const char **argv) // ignore_convention #endif { +#if defined(CONF_FAMILY_WINDOWS) + for(int i = 1; i < argc; i++) // ignore_convention + { + if(str_comp("-s", argv[i]) == 0 || str_comp("--silent", argv[i]) == 0) // ignore_convention + { + ShowWindow(GetConsoleWindow(), SW_HIDE); + break; + } + } +#endif + // init the engine dbg_msg("client", "starting..."); m_Client.InitEngine("Teeworlds");