@@ -287,6 +287,11 @@ enum {
287
287
// 音声ファイル。
288
288
WCHAR xg_aszSoundFiles[I_SOUND_MAX][MAX_PATH];
289
289
290
+ // 連番ファイル名1。
291
+ WCHAR xg_szNumberingFileName1[MAX_PATH];
292
+ // 連番ファイル名2。
293
+ WCHAR xg_szNumberingFileName2[MAX_PATH];
294
+
290
295
// ////////////////////////////////////////////////////////////////////////////
291
296
// static variables
292
297
@@ -955,6 +960,9 @@ void XgResetSettings(void)
955
960
for (auto & item : xg_aszSoundFiles) {
956
961
item[0 ] = 0 ;
957
962
}
963
+
964
+ StringCchCopyW (xg_szNumberingFileName1, _countof (xg_szNumberingFileName1), L" Crossword-%Wx%H-%4N.xd" );
965
+ StringCchCopyW (xg_szNumberingFileName2, _countof (xg_szNumberingFileName2), L" Pat-%Wx%H-%4N.xd" );
958
966
}
959
967
960
968
// 設定を読み込む。
@@ -1243,6 +1251,12 @@ bool __fastcall XgLoadSettings(void)
1243
1251
StringCchCopy (xg_aszSoundFiles[2 ], _countof (xg_aszSoundFiles[2 ]), sz);
1244
1252
}
1245
1253
}
1254
+ if (!app_key.QuerySz (L" NumberingFilename1" , sz, _countof (sz))) {
1255
+ StringCchCopy (xg_szNumberingFileName1, _countof (xg_szNumberingFileName1), sz);
1256
+ }
1257
+ if (!app_key.QuerySz (L" NumberingFilename2" , sz, _countof (sz))) {
1258
+ StringCchCopy (xg_szNumberingFileName2, _countof (xg_szNumberingFileName2), sz);
1259
+ }
1246
1260
1247
1261
// 保存先のリストを取得する。
1248
1262
if (!app_key.QueryDword (L" SaveToCount" , dwValue)) {
@@ -1371,6 +1385,9 @@ bool __fastcall XgSaveSettings(void)
1371
1385
app_key.SetSz (L" SoundFile1" , xg_aszSoundFiles[1 ]);
1372
1386
app_key.SetSz (L" SoundFile2" , xg_aszSoundFiles[2 ]);
1373
1387
1388
+ app_key.SetSz (L" NumberingFilename1" , xg_szNumberingFileName1);
1389
+ app_key.SetSz (L" NumberingFilename2" , xg_szNumberingFileName2);
1390
+
1374
1391
// 保存先のリストを設定する。
1375
1392
nCount = static_cast <int >(xg_dirs_save_to.size ());
1376
1393
app_key.SetDword (L" SaveToCount" , nCount);
@@ -2797,6 +2814,60 @@ BOOL __fastcall XgOnOpen(HWND hwnd)
2797
2814
return FALSE ;
2798
2815
}
2799
2816
2817
+ XGStringW __fastcall XgGenerateNumberingFilename (HWND hwnd, LPCWSTR pszText, LPSYSTEMTIME pLocalTime, INT iFile)
2818
+ {
2819
+ WCHAR szN[32 ], szN1[32 ], szN2[32 ], szN3[32 ], szN4[32 ], szN5[32 ], szN6[32 ];
2820
+ WCHAR szW[32 ], szH[32 ];
2821
+ WCHAR szYear[32 ], szMonth[32 ], szDay[32 ];
2822
+ WCHAR szHour[32 ], szMinute[32 ], szSecond[32 ];
2823
+ WCHAR szComputer[64 ], szUser[64 ];
2824
+
2825
+ XGStringW str = pszText;
2826
+
2827
+ StringCchPrintfW (szN, _countof (szN), L" %d" , iFile);
2828
+ StringCchPrintfW (szN1, _countof (szN1), L" %01d" , iFile);
2829
+ StringCchPrintfW (szN2, _countof (szN2), L" %02d" , iFile);
2830
+ StringCchPrintfW (szN3, _countof (szN3), L" %03d" , iFile);
2831
+ StringCchPrintfW (szN4, _countof (szN4), L" %04d" , iFile);
2832
+ StringCchPrintfW (szN5, _countof (szN5), L" %05d" , iFile);
2833
+ StringCchPrintfW (szN6, _countof (szN6), L" %06d" , iFile);
2834
+ xg_str_replace_all (str, L" %N" , szN);
2835
+ xg_str_replace_all (str, L" %1N" , szN1);
2836
+ xg_str_replace_all (str, L" %2N" , szN2);
2837
+ xg_str_replace_all (str, L" %3N" , szN3);
2838
+ xg_str_replace_all (str, L" %4N" , szN4);
2839
+ xg_str_replace_all (str, L" %5N" , szN5);
2840
+ xg_str_replace_all (str, L" %6N" , szN6);
2841
+
2842
+ StringCchPrintfW (szW, _countof (szW), L" %d" , xg_nCols);
2843
+ StringCchPrintfW (szH, _countof (szH), L" %d" , xg_nRows);
2844
+ xg_str_replace_all (str, L" %W" , szW);
2845
+ xg_str_replace_all (str, L" %H" , szH);
2846
+
2847
+ StringCchPrintfW (szYear, _countof (szYear), L" %04d" , pLocalTime->wYear );
2848
+ StringCchPrintfW (szMonth, _countof (szMonth), L" %02d" , pLocalTime->wMonth );
2849
+ StringCchPrintfW (szDay, _countof (szDay), L" %02d" , pLocalTime->wDay );
2850
+ StringCchPrintfW (szHour, _countof (szHour), L" %02d" , pLocalTime->wHour );
2851
+ StringCchPrintfW (szMinute, _countof (szMinute), L" %02d" , pLocalTime->wMinute );
2852
+ StringCchPrintfW (szSecond, _countof (szSecond), L" %02d" , pLocalTime->wSecond );
2853
+ xg_str_replace_all (str, L" %Y" , szYear);
2854
+ xg_str_replace_all (str, L" %M" , szMonth);
2855
+ xg_str_replace_all (str, L" %D" , szDay);
2856
+ xg_str_replace_all (str, L" %h" , szHour);
2857
+ xg_str_replace_all (str, L" %m" , szMinute);
2858
+ xg_str_replace_all (str, L" %s" , szSecond);
2859
+
2860
+ DWORD cchComputer = _countof (szComputer);
2861
+ GetComputerNameW (szComputer, &cchComputer);
2862
+ xg_str_replace_all (str, L" %C" , szComputer);
2863
+
2864
+ DWORD cchUser = _countof (szUser);
2865
+ GetUserNameW (szUser, &cchUser);
2866
+ xg_str_replace_all (str, L" %U" , szUser);
2867
+
2868
+ return str;
2869
+ }
2870
+
2800
2871
// 連番保存。
2801
2872
BOOL __fastcall XgNumberingSave (HWND hwnd, BOOL bPattern)
2802
2873
{
@@ -2807,19 +2878,34 @@ BOOL __fastcall XgNumberingSave(HWND hwnd, BOOL bPattern)
2807
2878
WCHAR szFormat[MAX_PATH];
2808
2879
StringCchCopyW (szFormat, _countof (szFormat), pszDir);
2809
2880
if (bPattern)
2810
- PathAppendW (szFormat, L" Pat-%dx%d-%04u.xd " );
2881
+ PathAppendW (szFormat, xg_szNumberingFileName2 );
2811
2882
else
2812
- PathAppendW (szFormat, L" Crossword-%dx%d-%04u.xd" );
2883
+ PathAppendW (szFormat, xg_szNumberingFileName1);
2884
+
2885
+ // 現在の日時を取得。
2886
+ SYSTEMTIME stNow;
2887
+ ::GetLocalTime (&stNow);
2813
2888
2814
2889
WCHAR szPath[MAX_PATH];
2890
+ XGStringW strPath, oldName;
2815
2891
for (INT iFile = 0 ; iFile <= 99999 ; ++iFile) {
2816
- StringCchPrintfW (szPath, _countof (szPath), szFormat, xg_nCols, xg_nRows, iFile);
2817
- if (!PathFileExistsW (szPath))
2892
+ strPath = XgGenerateNumberingFilename (hwnd, szFormat, &stNow, iFile);
2893
+ if (oldName == strPath)
2894
+ {
2895
+ StringCchCopyW (szPath, _countof (szPath), strPath.c_str ());
2896
+ XGStringW strDotExt = PathFindExtensionW (szPath);
2897
+ PathRemoveExtensionW (szPath);
2898
+ StringCchCatW (szPath, _countof (szPath), L" ~" );
2899
+ PathAddExtensionW (szPath, strDotExt.c_str ());
2900
+ strPath = szPath;
2901
+ }
2902
+ if (!PathFileExistsW (strPath.c_str ()))
2818
2903
break ;
2904
+ oldName = strPath;
2819
2905
}
2820
2906
2821
2907
// 保存する。
2822
- xg_strFileName = szPath ;
2908
+ xg_strFileName = strPath ;
2823
2909
if (!XgOnSave (hwnd))
2824
2910
return FALSE ;
2825
2911
0 commit comments