Browse Source

Make common timestamp a getter

All timestamps are in the format yyyyMMddHHmmss
habeebweeb 4 years ago
parent
commit
7c3626e83a

+ 4 - 4
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Constants.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
@@ -136,7 +136,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             string fullPath = Path.Combine(directory, filename);
 
-            if (File.Exists($"{fullPath}.xml")) fullPath += $"_{DateTime.Now:yyyyMMddHHmmss}";
+            if (File.Exists($"{fullPath}.xml")) fullPath += $"_{Utility.Timestamp}";
 
             fullPath = Path.GetFullPath($"{fullPath}.xml");
 
@@ -198,7 +198,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             string fullPath = Path.Combine(directory, filename);
 
-            if (File.Exists($"{fullPath}.anm")) fullPath += $"_{DateTime.Now:yyyyMMddHHmmss}";
+            if (File.Exists($"{fullPath}.anm")) fullPath += $"_{Utility.Timestamp}";
 
             fullPath = Path.GetFullPath($"{fullPath}.anm");
 
@@ -245,7 +245,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             string fullPath = Path.Combine(directory, filename);
 
-            if (File.Exists($"{fullPath}.xml")) fullPath += $"_{DateTime.Now:yyyyMMddHHmmss}";
+            if (File.Exists($"{fullPath}.xml")) fullPath += $"_{Utility.Timestamp}";
 
             fullPath = Path.GetFullPath($"{fullPath}.xml");
 

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/SceneManager.cs

@@ -271,7 +271,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 while (!File.Exists(screenshotPath));
 
                 string scenePrefix = KankyoMode ? "mpskankyo" : "mpsscene";
-                string fileName = $"{scenePrefix}{DateTime.Now:yyyyMMddHHmmss}.png";
+                string fileName = $"{scenePrefix}{Utility.Timestamp}.png";
                 string savePath = Path.Combine(CurrentScenesDirectory, fileName);
 
                 if (overwrite && CurrentScene != null)

+ 2 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Utility.cs

@@ -20,6 +20,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             Control, Shift, Alt
         }
+        public static string Timestamp => $"{DateTime.Now:yyyyMMddHHmmss}";
 
         public static void LogInfo(object data) => Logger.LogInfo(data);
 
@@ -92,7 +93,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "ScreenShot"
             );
             if (!Directory.Exists(screenShotDir)) Directory.CreateDirectory(screenShotDir);
-            return Path.Combine(screenShotDir, $"img{DateTime.Now:yyyyMMddHHmmss}.png");
+            return Path.Combine(screenShotDir, $"img{Timestamp}.png");
         }
 
         public static string TempScreenshotFilename()