Merge branch 'add-screenshot-dir-to-config' into main/yubo-dev

merge-requests/15/merge
Nuno 3 years ago
commit f878fd2a0b

@ -413,6 +413,7 @@ CClientConfig::CClientConfig()
CameraRecorderPrefix = "cam_rec"; CameraRecorderPrefix = "cam_rec";
CameraRecorderBlend = true; CameraRecorderBlend = true;
ScreenShotDirectory = "screenshots";
ScreenShotWidth = 0; ScreenShotWidth = 0;
ScreenShotHeight = 0; ScreenShotHeight = 0;
ScreenShotFullDetail = true; ScreenShotFullDetail = true;
@ -1142,6 +1143,7 @@ void CClientConfig::setValues()
READ_BOOL_FV(CameraRecorderBlend) READ_BOOL_FV(CameraRecorderBlend)
// Screenshot // Screenshot
READ_STRING_FV(ScreenShotDirectory)
READ_INT_FV(ScreenShotWidth) READ_INT_FV(ScreenShotWidth)
READ_INT_FV(ScreenShotHeight) READ_INT_FV(ScreenShotHeight)
READ_BOOL_FV(ScreenShotFullDetail) READ_BOOL_FV(ScreenShotFullDetail)

@ -306,6 +306,7 @@ struct CClientConfig
bool CameraRecorderBlend; bool CameraRecorderBlend;
/// Screen shot /// Screen shot
string ScreenShotDirectory;
uint ScreenShotWidth; // If 0 : normal screen shot, else custom screen shot without interface uint ScreenShotWidth; // If 0 : normal screen shot, else custom screen shot without interface
uint ScreenShotHeight; uint ScreenShotHeight;
bool ScreenShotFullDetail; // If set to true, then load balancing will be disabled for the duration of the screenshot bool ScreenShotFullDetail; // If set to true, then load balancing will be disabled for the duration of the screenshot

@ -62,9 +62,6 @@ extern NLMISC::CLog g_log;
//////////// ////////////
//static CCDBNodeLeaf *MenuColorWidgetValue = NULL; // db entry for the color menu widget (Red) //static CCDBNodeLeaf *MenuColorWidgetValue = NULL; // db entry for the color menu widget (Red)
static const string ScreenshotsDirectory("screenshots/"); // don't forget the final /
void preRenderNewSky (); void preRenderNewSky ();
// *************************************************************************** // ***************************************************************************
@ -602,11 +599,6 @@ void displayScreenShotSavedInfo(const string &filename)
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
} }
void initScreenshot()
{
if (!CFile::isExists(ScreenshotsDirectory)) CFile::createDirectory(ScreenshotsDirectory);
}
bool screenshotZBuffer(const std::string &filename) bool screenshotZBuffer(const std::string &filename)
{ {
std::string::size_type pos = filename.find("."); std::string::size_type pos = filename.find(".");
@ -672,6 +664,11 @@ bool screenshotZBuffer(const std::string &filename)
static std::string findNewScreenShotFileName(std::string filename) static std::string findNewScreenShotFileName(std::string filename)
{ {
// make screenshot directory if it does not exist
if (!CFile::isExists(ClientCfg.ScreenShotDirectory))
CFile::createDirectory(ClientCfg.ScreenShotDirectory);
filename = CPath::standardizePath(ClientCfg.ScreenShotDirectory) + filename;
static char cstime[25]; static char cstime[25];
time_t dtime; time_t dtime;
time(&dtime); time(&dtime);
@ -698,7 +695,7 @@ void screenShotTGA()
CBitmap btm; CBitmap btm;
getBuffer (btm); getBuffer (btm);
string filename = findNewScreenShotFileName(ScreenshotsDirectory+"screenshot.tga"); string filename = findNewScreenShotFileName("screenshot.tga");
COFile fs(filename); COFile fs(filename);
if (!btm.writeTGA(fs, 24, false)) if (!btm.writeTGA(fs, 24, false))
@ -720,7 +717,7 @@ void screenShotPNG()
CBitmap btm; CBitmap btm;
getBuffer (btm); getBuffer (btm);
string filename = findNewScreenShotFileName(ScreenshotsDirectory+"screenshot.png"); string filename = findNewScreenShotFileName("screenshot.png");
COFile fs(filename); COFile fs(filename);
if (!btm.writePNG(fs, 24)) if (!btm.writePNG(fs, 24))
@ -742,7 +739,7 @@ void screenShotJPG()
CBitmap btm; CBitmap btm;
getBuffer (btm); getBuffer (btm);
string filename = findNewScreenShotFileName(ScreenshotsDirectory+"screenshot.jpg"); string filename = findNewScreenShotFileName("screenshot.jpg");
COFile fs(filename); COFile fs(filename);
if (!btm.writeJPG(fs)) if (!btm.writeJPG(fs))

@ -181,7 +181,6 @@ 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();

@ -1000,9 +1000,6 @@ 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)

Loading…
Cancel
Save