Changed: only check screenshot folder presence one time

This commit is contained in:
kervala 2010-07-17 18:47:38 +02:00
parent 2a91013055
commit 4441f54bba
3 changed files with 9 additions and 3 deletions

View file

@ -595,12 +595,16 @@ void displayScreenShotSavedInfo(const string &filename)
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
} }
void initScreenshot()
{
if (!CFile::isExists(ScreenshotsDirectory)) CFile::createDirectory(ScreenshotsDirectory);
}
void screenShotTGA() void screenShotTGA()
{ {
CBitmap btm; CBitmap btm;
getBuffer (btm); getBuffer (btm);
if(!ScreenshotsDirectory.empty() && !CFile::isExists(ScreenshotsDirectory)) CFile::createDirectory(ScreenshotsDirectory);
string filename = CFile::findNewFile (ScreenshotsDirectory+"screenshot.tga"); string filename = CFile::findNewFile (ScreenshotsDirectory+"screenshot.tga");
COFile fs(filename); COFile fs(filename);
btm.writeTGA(fs, 24, false); btm.writeTGA(fs, 24, false);
@ -613,7 +617,6 @@ void screenShotPNG()
CBitmap btm; CBitmap btm;
getBuffer (btm); getBuffer (btm);
if(!ScreenshotsDirectory.empty() && !CFile::isExists(ScreenshotsDirectory)) CFile::createDirectory(ScreenshotsDirectory);
string filename = CFile::findNewFile (ScreenshotsDirectory+"screenshot.png"); string filename = CFile::findNewFile (ScreenshotsDirectory+"screenshot.png");
COFile fs(filename); COFile fs(filename);
if (!btm.writePNG(fs, 24)) if (!btm.writePNG(fs, 24))
@ -634,7 +637,6 @@ void screenShotJPG()
CBitmap btm; CBitmap btm;
getBuffer (btm); getBuffer (btm);
if(!ScreenshotsDirectory.empty() && !CFile::isExists(ScreenshotsDirectory)) CFile::createDirectory(ScreenshotsDirectory);
string filename = CFile::findNewFile (ScreenshotsDirectory+"screenshot.jpg"); string filename = CFile::findNewFile (ScreenshotsDirectory+"screenshot.jpg");
COFile fs(filename); COFile fs(filename);
btm.writeJPG(fs); btm.writeJPG(fs);

View file

@ -174,6 +174,7 @@ public:
/** Capture current content of framebuffer and save the result. If a custom size is asked in ClientCfg, then the scene is rendered again /** Capture current content of framebuffer and save the result. If a custom size is asked in ClientCfg, then the scene is rendered again
* instead (possibly multiple time) * instead (possibly multiple time)
*/ */
void initScreenshot();
void screenShotTGA(); void screenShotTGA();
void screenShotPNG(); void screenShotPNG();
void screenShotJPG(); void screenShotJPG();

View file

@ -1443,6 +1443,9 @@ bool mainLoop()
// initialize the structure for the ping. // initialize the structure for the ping.
Ping.init(); Ping.init();
// initialize screenshots directory
initScreenshot();
// Call a function for a demo to init. // Call a function for a demo to init.
if (ClientCfg.Local) if (ClientCfg.Local)