mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-20 13:33:02 +01:00
New file naming convention for screenshots
- With this change screenshot file names have the following pattern: save file name + + YYYY-MM-DD hh-mm-ss + .png - To get the correct date and time the method platform_get_time and platform_get_date are rewritten and to a version for UTC and a version for local time. This change gave the opportunity to simplify the code generating file names for autosaves. - SOUND_WINDOW_OPEN is now the new "shutter" sound when taking screenshot.
This commit is contained in:
@@ -45,9 +45,8 @@ void screenshot_check()
|
||||
|
||||
if (screenshotIndex != -1) {
|
||||
RCT2_GLOBAL(0x009A8C29, uint8) |= 1;
|
||||
|
||||
// TODO use a more obvious sound like a camera shutter
|
||||
audio_play_sound(SOUND_CLICK_1, 0, gScreenWidth / 2);
|
||||
|
||||
audio_play_sound(SOUND_WINDOW_OPEN, 100, gScreenWidth / 2);
|
||||
} else {
|
||||
window_error_open(STR_SCREENSHOT_FAILED, STR_NONE);
|
||||
}
|
||||
@@ -84,15 +83,13 @@ static int screenshot_get_next_path(char *path)
|
||||
format_string(park_name, gParkName, &gParkNameArgs);
|
||||
|
||||
// retrieve current time
|
||||
time_t now;
|
||||
time(&now);
|
||||
struct tm* tm_now = localtime(&now);
|
||||
rct2_date currentDate;
|
||||
platform_get_date_local(¤tDate);
|
||||
rct2_time currentTime;
|
||||
platform_get_time_local(¤tTime);
|
||||
|
||||
utf8 time_now_str[128] = { 0 };
|
||||
size_t size = strftime(time_now_str, 128, "%F %H-%M-%S", tm_now);
|
||||
assert(size != 0);
|
||||
|
||||
sprintf(path, "%s%s %s.png", screenshotPath, park_name, time_now_str);
|
||||
// Glue together path and filename
|
||||
sprintf(path, "%s%s %d-%02d-%02d %02d-%02d-%02d.png", screenshotPath, park_name, currentDate.year, currentDate.month, currentDate.day, currentTime.hour, currentTime.minute, currentTime.second);
|
||||
|
||||
if (!platform_file_exists(path)) {
|
||||
return 0; // path ok
|
||||
@@ -100,19 +97,21 @@ static int screenshot_get_next_path(char *path)
|
||||
|
||||
// multiple screenshots with same timestamp
|
||||
// might be possible when switching timezones
|
||||
// but should not happen
|
||||
// in the unlikely case that this does happen,
|
||||
// append (%d) to the filename and increment
|
||||
// this int until it doesn't overwrite any
|
||||
// other file in the directory.
|
||||
int i;
|
||||
for (i = 2; i < 1000; i++) {
|
||||
set_format_arg(0, uint16, i);
|
||||
for (i = 1; i < 1000; i++) {
|
||||
// Glue together path and filename
|
||||
sprintf(path, "%s%s %s (%d).png", screenshotPath, park_name, time_now_str, i);
|
||||
sprintf(path, "%s%s %d-%02d-%02d %02d-%02d-%02d (%d).png", screenshotPath, park_name, currentDate.year, currentDate.month, currentDate.day, currentTime.hour, currentTime.minute, currentTime.second, i);
|
||||
|
||||
if (!platform_file_exists(path)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
log_error("You have too many saved screenshots.\n");
|
||||
log_error("You have too many saved screenshots saved at exactly the same date and time.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user