Add date in screenshots. Sorry, GMT time
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11454 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
90b28e86f1
commit
cc4affabd4
@ -1610,12 +1610,22 @@ void IrrDriver::update(float dt)
|
||||
video::IImage* image = m_video_driver->createScreenShot();
|
||||
if (image)
|
||||
{
|
||||
static int screenshot_id = 1;
|
||||
time_t rawtime;
|
||||
time ( &rawtime );
|
||||
tm* timeInfo = gmtime( &rawtime );
|
||||
std::string now = StringUtils::insertValues(std::string("%i.%i.%i %i.%i.%i"),
|
||||
timeInfo->tm_year + 1900,
|
||||
timeInfo->tm_mon, timeInfo->tm_mday,
|
||||
timeInfo->tm_hour, timeInfo->tm_min,
|
||||
timeInfo->tm_sec);
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
std::string path = StringUtils::insertValues("C:\\Temp\\supertuxkart_%s_%i.png", race_manager->getTrackName().c_str(), screenshot_id++);
|
||||
std::string path = StringUtils::insertValues("C:\\Temp\\supertuxkart %s %s.png",
|
||||
race_manager->getTrackName().c_str(), now);
|
||||
#else
|
||||
std::string path = StringUtils::insertValues("/tmp/supertuxkart_%s_%i.png", race_manager->getTrackName().c_str(), screenshot_id++);
|
||||
std::string path = StringUtils::insertValues("/tmp/supertuxkart %s %s.png",
|
||||
race_manager->getTrackName().c_str(), now);
|
||||
#endif
|
||||
|
||||
if (irr_driver->getVideoDriver()->writeImageToFile(image, io::path(path.c_str()), 0))
|
||||
@ -1623,7 +1633,8 @@ void IrrDriver::update(float dt)
|
||||
RaceGUIBase* base = World::getWorld()->getRaceGUI();
|
||||
if (base != NULL)
|
||||
{
|
||||
base->addMessage(core::stringw(("Screenshot saved to\n" + path).c_str()), NULL, 2.0f, video::SColor(255,255,255,255), true, false);
|
||||
base->addMessage(core::stringw(("Screenshot saved to\n" + path).c_str()), NULL,
|
||||
2.0f, video::SColor(255,255,255,255), true, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1631,7 +1642,8 @@ void IrrDriver::update(float dt)
|
||||
RaceGUIBase* base = World::getWorld()->getRaceGUI();
|
||||
if (base != NULL)
|
||||
{
|
||||
base->addMessage(core::stringw(("FAILED saving screenshot to\n" + path + "\n:(").c_str()), NULL, 2.0f, video::SColor(255,255,255,255), true, false);
|
||||
base->addMessage(core::stringw(("FAILED saving screenshot to\n" + path + "\n:(").c_str()),
|
||||
NULL, 2.0f, video::SColor(255,255,255,255), true, false);
|
||||
}
|
||||
}
|
||||
image->drop();
|
||||
|
@ -127,6 +127,51 @@ namespace StringUtils
|
||||
// ------------------------------------------------------------------------
|
||||
// Note: the order in which the templates are specified is important, since
|
||||
// otherwise some compilers will not find the right template to use.
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
std::string insertValues(const std::string &s, const T1 &v1,
|
||||
const T2 &v2, const T3 &v3, const T4 &v4,
|
||||
const T5 &v5,const T6 &v6)
|
||||
{
|
||||
std::vector<std::string> all_vals;
|
||||
std::ostringstream dummy;
|
||||
dummy << v1; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v2; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v3; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v4; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v5; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v6; all_vals.push_back(dummy.str());
|
||||
return insertValues(s, all_vals);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
std::string insertValues(const std::string &s, const T1 &v1,
|
||||
const T2 &v2, const T3 &v3, const T4 &v4,
|
||||
const T5 &v5)
|
||||
{
|
||||
std::vector<std::string> all_vals;
|
||||
std::ostringstream dummy;
|
||||
dummy << v1; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v2; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v3; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v4; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v5; all_vals.push_back(dummy.str());
|
||||
return insertValues(s, all_vals);
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
std::string insertValues(const std::string &s, const T1 &v1,
|
||||
const T2 &v2, const T3 &v3, const T4 &v4)
|
||||
{
|
||||
std::vector<std::string> all_vals;
|
||||
std::ostringstream dummy;
|
||||
dummy << v1; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v2; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v3; all_vals.push_back(dummy.str()); dummy.str("");
|
||||
dummy << v4; all_vals.push_back(dummy.str());
|
||||
return insertValues(s, all_vals);
|
||||
}
|
||||
|
||||
/** Shortcut insert_values taking three values, see above for
|
||||
* full docs.
|
||||
* \param s String in which all %s or %d are replaced.
|
||||
|
Loading…
Reference in New Issue
Block a user