diff options
| author | oy <Tom_Adams@web.de> | 2010-12-12 16:48:13 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-12-12 16:48:13 +0100 |
| commit | c75a75b64ff804e7a14374e17b31377aabff0d63 (patch) | |
| tree | 0b49986e39b44ae0b1f4673753a712779723813d /src/engine/client | |
| parent | b4c007778cab749e9d163baec64d22349435ea3f (diff) | |
| download | zcatch-c75a75b64ff804e7a14374e17b31377aabff0d63.tar.gz zcatch-c75a75b64ff804e7a14374e17b31377aabff0d63.zip | |
made it possible to automatically take game over screenshots. Closes #339
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/client.cpp | 28 | ||||
| -rw-r--r-- | src/engine/client/client.h | 4 | ||||
| -rw-r--r-- | src/engine/client/graphics.cpp | 12 | ||||
| -rw-r--r-- | src/engine/client/graphics.h | 3 |
4 files changed, 38 insertions, 9 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 82e79a85..a2d5a53f 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -413,6 +413,7 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotD m_WindowMustRefocus = 0; m_SnapCrcErrors = 0; + m_AutoScreenshotRecycle = false; m_AckGameTick = -1; m_CurrentRecvTick = 0; @@ -1938,6 +1939,8 @@ void CClient::Run() } } + AutoScreenshot_Cleanup(); + // check conditions if(State() == IClient::STATE_QUITING) break; @@ -2023,10 +2026,33 @@ void CClient::Con_Ping(IConsole::IResult *pResult, void *pUserData) pSelf->m_PingStartTime = time_get(); } +void CClient::AutoScreenshot_Start() +{ + if(g_Config.m_ClAutoScreenshot) + { + Graphics()->TakeScreenshot("auto/autoscreen"); + m_AutoScreenshotRecycle = true; + } +} + +void CClient::AutoScreenshot_Cleanup() +{ + if(m_AutoScreenshotRecycle) + { + if(g_Config.m_ClAutoScreenshotMax) + { + // clean up auto taken screens + CFileCollection AutoScreens; + AutoScreens.Init(Storage(), "screenshots/auto", "autoscreen", ".png", g_Config.m_ClAutoScreenshotMax); + } + m_AutoScreenshotRecycle = false; + } +} + void CClient::Con_Screenshot(IConsole::IResult *pResult, void *pUserData) { CClient *pSelf = (CClient *)pUserData; - pSelf->Graphics()->TakeScreenshot(); + pSelf->Graphics()->TakeScreenshot(0); } void CClient::Con_Rcon(IConsole::IResult *pResult, void *pUserData) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 8486e481..a7385037 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -140,6 +140,7 @@ class CClient : public IClient, public CDemoPlayer::IListner NETADDR m_ServerAddress; int m_WindowMustRefocus; int m_SnapCrcErrors; + bool m_AutoScreenshotRecycle; int m_AckGameTick; int m_CurrentRecvTick; @@ -319,6 +320,9 @@ public: void DemoRecorder_HandleAutoStart(); void DemoRecorder_Stop(); + void AutoScreenshot_Start(); + void AutoScreenshot_Cleanup(); + virtual class CEngine *Engine() { return &m_Engine; } }; #endif diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index fb994953..82248f05 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -873,8 +873,11 @@ int CGraphics_SDL::WindowOpen() } -void CGraphics_SDL::TakeScreenshot() +void CGraphics_SDL::TakeScreenshot(const char *pFilename) { + char aDate[20]; + str_timestamp(aDate, sizeof(aDate)); + str_format(m_aScreenshotName, sizeof(m_aScreenshotName), "screenshots/%s_%s.png", pFilename?pFilename:"screenshot", aDate); m_DoScreenshot = true; } @@ -882,12 +885,7 @@ void CGraphics_SDL::Swap() { if(m_DoScreenshot) { - char aFilename[128]; - char aDate[20]; - - str_timestamp(aDate, sizeof(aDate)); - str_format(aFilename, sizeof(aFilename), "screenshots/screenshot_%s.png", aDate); - ScreenshotDirect(aFilename); + ScreenshotDirect(m_aScreenshotName); m_DoScreenshot = false; } diff --git a/src/engine/client/graphics.h b/src/engine/client/graphics.h index 17e3a83f..20be3504 100644 --- a/src/engine/client/graphics.h +++ b/src/engine/client/graphics.h @@ -41,6 +41,7 @@ protected: float m_Rotation; int m_Drawing; bool m_DoScreenshot; + char m_aScreenshotName[128]; float m_ScreenX0; float m_ScreenY0; @@ -136,7 +137,7 @@ public: virtual int WindowActive(); virtual int WindowOpen(); - virtual void TakeScreenshot(); + virtual void TakeScreenshot(const char *pFilename); virtual void Swap(); virtual int GetVideoModes(CVideoMode *pModes, int MaxModes); |