apply patch #164 to screenshot path building format
This commit is contained in:
parent
b95380054e
commit
e24720f69d
|
@ -342,60 +342,60 @@ public:
|
||||||
|
|
||||||
void formatname(char *output)
|
void formatname(char *output)
|
||||||
{
|
{
|
||||||
|
// Except 't' for tick and 'r' for random.
|
||||||
|
const char* strftimeArgs = "AbBcCdDeFgGhHIjmMnpRStTuUVwWxXyYzZ%";
|
||||||
|
|
||||||
std::string file;
|
std::string file;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
tm *time_struct = localtime(&now);
|
tm *time_struct = localtime(&now);
|
||||||
srand((unsigned int)now);
|
|
||||||
|
|
||||||
for(int i = 0; i < MAX_FORMAT;i++)
|
srand((unsigned)now);
|
||||||
{
|
|
||||||
char *c = &screenshotFormat[i];
|
|
||||||
char tmp[MAX_PATH] = {0};
|
|
||||||
|
|
||||||
if(*c == '%')
|
for (char* p = screenshotFormat,
|
||||||
|
*end = p + sizeof(screenshotFormat); p < end; p++)
|
||||||
{
|
{
|
||||||
c = &screenshotFormat[++i];
|
if (*p != '%')
|
||||||
switch(*c)
|
|
||||||
{
|
{
|
||||||
case 'f':
|
file.append(1, *p);
|
||||||
|
|
||||||
strcat(tmp, GetRomNameWithoutExtension().c_str());
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
strftime(tmp, MAX_PATH, "%d", time_struct);
|
|
||||||
break;
|
|
||||||
case 'M':
|
|
||||||
strftime(tmp, MAX_PATH, "%m", time_struct);
|
|
||||||
break;
|
|
||||||
case 'Y':
|
|
||||||
strftime(tmp, MAX_PATH, "%Y", time_struct);
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
strftime(tmp, MAX_PATH, "%H", time_struct);
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
strftime(tmp, MAX_PATH, "%M", time_struct);
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
strftime(tmp, MAX_PATH, "%S", time_struct);
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
sprintf(tmp, "%d", rand() % RAND_MAX);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int j;
|
p++;
|
||||||
for(j=i;j<MAX_FORMAT-i;j++)
|
|
||||||
if(screenshotFormat[j] != '%')
|
if (*p == 'f')
|
||||||
tmp[j-i]=screenshotFormat[j];
|
{
|
||||||
else
|
file.append(GetRomNameWithoutExtension());
|
||||||
break;
|
}
|
||||||
tmp[j-i]='\0';
|
else if (*p == 'r')
|
||||||
|
{
|
||||||
|
file.append(stditoa(rand()));
|
||||||
}
|
}
|
||||||
file += tmp;
|
else if (*p == 't')
|
||||||
|
{
|
||||||
|
file.append(stditoa(clock() >> 5));
|
||||||
|
}
|
||||||
|
else if (strchr(strftimeArgs, *p))
|
||||||
|
{
|
||||||
|
char tmp[MAX_PATH];
|
||||||
|
char format[] = { '%', *p, NULL };
|
||||||
|
strftime(tmp, MAX_PATH, format, time_struct);
|
||||||
|
file.append(tmp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// Replace invalid file name character.
|
||||||
|
{
|
||||||
|
const char* invalids = "\\/:*?\"<>|";
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = file.find_first_of(invalids, pos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
file[pos] = '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
strncpy(output, file.c_str(), MAX_PATH);
|
strncpy(output, file.c_str(), MAX_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,17 @@ BOOL PathSettings_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
|
||||||
ti.hinst = hAppInst;
|
ti.hinst = hAppInst;
|
||||||
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
|
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
|
||||||
ti.uId = (UINT_PTR)hwnd;
|
ti.uId = (UINT_PTR)hwnd;
|
||||||
ti.lpszText = "The format a screenshot should be saved in.\r\n%f\t\t\tFilename\r\n%D\t\t\tDay:Two Digit\r\n%M\t\t\tMonth:Two Digit\r\n%Y\t\t\tYear:Four Digit\r\n%h\t\t\tHour:Two Digit\r\n%m\t\t\tMinute: Two Digit\r\n%s\t\t\tSecond: Two Digit\r\n%r\t\tRandom: Min:0 Max:RAND_MAX";
|
ti.lpszText =
|
||||||
|
"The format a screenshot should be saved in.\r\n"
|
||||||
|
"%f\t\tFilename\r\n"
|
||||||
|
"%r\t\tRandom: 0 ~ RAND_MAX\r\n"
|
||||||
|
"%t\t\tTick: Reset on startup\r\n"
|
||||||
|
"%Y\t\tYear:Four Digit\r\n"
|
||||||
|
"%m\t\tMonth:Two Digit\r\n"
|
||||||
|
"%D\t\tDay:Two Digit\r\n"
|
||||||
|
"%H\t\tHour:Two Digit\r\n"
|
||||||
|
"%M\t\tMinute: Two Digit\r\n"
|
||||||
|
"%S\t\tSecond: Two Digit\r\n";
|
||||||
GetClientRect(hwnd, &ti.rect);
|
GetClientRect(hwnd, &ti.rect);
|
||||||
SendMessage(toolTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
|
SendMessage(toolTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue