Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-02-15 18:02:33 +0000
committerStijn Buys <ingar@osirion.org>2010-02-15 18:02:33 +0000
commitfb95f7b74c1a4286e02b95c461bdc5068f2532e4 (patch)
tree527115de120bc49232c3a2e55e1ea5f7adfc7fd7 /src/render
parenta19a0cfe10f74fdd896e1b804b46fd64ea5b65a6 (diff)
Changed screenshot naming convention to yyyyddmm-nnnn
Diffstat (limited to 'src/render')
-rw-r--r--src/render/screenshot.cc38
-rw-r--r--src/render/screenshot.h3
2 files changed, 23 insertions, 18 deletions
diff --git a/src/render/screenshot.cc b/src/render/screenshot.cc
index 342977a..adab01b 100644
--- a/src/render/screenshot.cc
+++ b/src/render/screenshot.cc
@@ -24,7 +24,8 @@ core::Cvar *Screenshot::screenshotformat = 0;
core::Cvar *Screenshot::screenshotquality = 0;
-int Screenshot::number = 0;
+int Screenshot::current_number = 0;
+int Screenshot::current_date = 0;
void Screenshot::save()
{
@@ -66,36 +67,39 @@ void Screenshot::save()
(*screenshotformat) = "tga";
}
- // find the first available screenshots/osirion-yyyymmdd-hhmm-xxxx.ext
+ // check if the date has changed since the previous screenshot;
std::stringstream filenamestr;
int day, month, year, hour, min;
+ int date_serial;
sys::get_datetime(year, month, day, hour, min);
-
- filenamestr << filesystem::writedir() << "screenshots/osirion" << '-';
- // date
- filenamestr << std::setfill('0') << std::setw(4) << year << std::setw(2) << month << std::setw(2) << day << '-';
- // time
- filenamestr << std::setfill('0') << std::setw(2) << hour << std::setw(2) << min << '-';
+ date_serial = (day - 1) + (month - 1) * 31 + (year - 2000) * 31 * 12;
+ if (current_date != date_serial) {
+ current_number = 0;
+ current_date = date_serial;
+ }
do {
- std::stringstream nstr;
- nstr << std::setw(4) << std::setfill('0') << number;
-
+ std::stringstream filenamestr;
+ // screenshots directory
+ filenamestr << filesystem::writedir() << "screenshots/";
+ // date
+ filenamestr << std::setw(4) << std::setfill('0') << year << "-";
+ filenamestr << std::setw(2) << month << "-";
+ filenamestr << std::setw(2) << day << '-';
// sequence number
- filename.assign(filenamestr.str());
- filename.append(nstr.str());
+ filenamestr << std::setw(4) << std::setfill('0') << current_number;
// extension
- filename.append(".");
- filename.append(screenshotformat->str());
+ filenamestr << "." << screenshotformat->str();
- FILE *handle = fopen(filename.c_str(), "r");
+ // try to open the file
+ FILE *handle = fopen(filenamestr.str().c_str(), "r");
if (handle) {
fclose(handle);
} else {
available = true;
}
- number++;
+ current_number++;
} while (!available);
render::Image image(State::width(), State::height(), 3);
diff --git a/src/render/screenshot.h b/src/render/screenshot.h
index 4be57fa..5c0e22c 100644
--- a/src/render/screenshot.h
+++ b/src/render/screenshot.h
@@ -21,7 +21,8 @@ public:
static core::Cvar *screenshotquality;
private:
- static int number;
+ static int current_number;
+ static int current_date;
};
} // namespace render