Browse Source

Add utilities

ScreenshotFilename returns the game screenshot path and filename in the
form of yyyyMMddHHmmss

Add MouseExposition helper
habeebweeb 4 years ago
parent
commit
295d7d898e
1 changed files with 19 additions and 2 deletions
  1. 19 2
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Utility.cs

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

@@ -1,3 +1,5 @@
+using System;
+using System.IO;
 using System.Reflection;
 using UnityEngine;
 
@@ -55,8 +57,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         internal static void SetFieldValue<TType, TValue>(TType instance, string name, TValue value)
         {
-            FieldInfo fieldInfo = GetFieldInfo<TType>(name);
-            fieldInfo.SetValue(instance, value);
+            GetFieldInfo<TType>(name).SetValue(instance, value);
         }
 
         internal static bool GetModKey(ModKey key)
@@ -74,5 +75,21 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             return Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2);
         }
+
+        internal static string ScreenshotFilename()
+        {
+            string screenShotDir = Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "ScreenShot");
+            if (!Directory.Exists(screenShotDir))
+            {
+                Directory.CreateDirectory(screenShotDir);
+            }
+            return Path.Combine(screenShotDir, $"img{DateTime.Now:yyyyMMddHHmmss}.png");
+        }
+
+        internal static void ShowMouseExposition(string text, float time = 2f)
+        {
+            MouseExposition mouseExposition = MouseExposition.GetObject();
+            mouseExposition.SetText(text, time);
+        }
     }
 }