Преглед на файлове

Add logger convenience methods

habeebweeb преди 4 години
родител
ревизия
329aa50341

+ 5 - 6
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Constants.cs

@@ -127,7 +127,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             if (!fullPath.StartsWith(Constants.customPosePath))
             {
-                Utility.Logger.LogError($"Could not save pose! Path is invalid: '{fullPath}'");
+                Utility.LogError($"Could not save pose! Path is invalid: '{fullPath}'");
                 return;
             }
 
@@ -174,7 +174,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             if (!fullPath.StartsWith(Constants.customHandPath))
             {
-                Utility.Logger.LogError($"Could not save hand! Path is invalid: '{fullPath}'");
+                Utility.LogError($"Could not save hand! Path is invalid: '{fullPath}'");
                 return;
             }
 
@@ -640,7 +640,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         private static void InitializeModProps()
         {
-            // TODO: cache menu files
             for (int i = 1; i < MenuFileUtility.MenuCategories.Length; i++)
             {
                 ModPropDict[MenuCategories[i]] = new List<ModItem>();
@@ -704,7 +703,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (!MenuFileUtility.MenuFilesReady)
                 {
-                    Utility.Logger.LogInfo("Menu files are not ready yet");
+                    Utility.LogMessage("Menu files are not ready yet");
                     return null;
                 }
             }
@@ -733,7 +732,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                         string iconFile = item.IconFile;
                         if (string.IsNullOrEmpty(iconFile) || !GameUty.FileSystem.IsExistentFile(iconFile))
                         {
-                            Utility.Logger.LogWarning($"Could not find icon '{iconFile}' for menu '{item.MenuFile}");
+                            Utility.LogWarning($"Could not find icon '{iconFile}' for menu '{item.MenuFile}");
                             return true;
                         }
                         else
@@ -750,7 +749,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                                 }
                                 catch
                                 {
-                                    Utility.Logger.LogWarning($"Could not load '{iconFile}' for menu '{item.MenuFile}");
+                                    Utility.LogWarning($"Could not load '{iconFile}' for menu '{item.MenuFile}");
                                     return true;
                                 }
                             }

+ 2 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/PropManager.cs

@@ -92,8 +92,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             MyRoomCustom.PlacementData.Data data = MyRoomCustom.PlacementData.GetData(item.ID);
             GameObject dogu = GameObject.Instantiate(data.GetPrefab());
             string name = Translation.Get("myRoomPropNames", item.PrefabName);
-            if (dogu != null) AttachDragPoint(dogu, name, new Vector3(0f, 0f, 0.5f));
-            else Utility.Logger.LogInfo($"Could not load MyRoomCreative prop '{item.PrefabName}'");
+            else Utility.LogInfo($"Could not load MyRoomCreative prop '{item.PrefabName}'");
         }
 
         public void SpawnBG(string assetName)
@@ -234,7 +233,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             else
             {
-                Utility.Logger.LogError($"Could not spawn object '{assetName}'");
+                Utility.LogInfo($"Could not spawn object '{assetName}'");
             }
         }
 

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MenuFileCache.cs

@@ -58,7 +58,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (binaryReader.ReadInt32() != cacheVersion)
                 {
-                    Utility.Logger.LogInfo($"Cache version out of date. Rebuilding");
+                    Utility.LogInfo($"Cache version out of date. Rebuilding");
                     return;
                 }
                 while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)

+ 14 - 14
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MenuFileUtility.cs

@@ -261,7 +261,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 else
                 {
-                    Utility.Logger.LogError("invalid model");
+                    Utility.LogError("invalid model");
                     return null;
                 }
             }
@@ -353,7 +353,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     string text2 = binaryReader.ReadString();
                     if (!hashtable.ContainsKey(text2))
                     {
-                        Utility.Logger.LogError("nullbone= " + text2);
+                        Utility.LogError("nullbone= " + text2);
                     }
                     else
                     {
@@ -470,7 +470,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 {
                     if (fileStream == null || fileStream.Length == 0)
                     {
-                        Utility.Logger.LogError("Could not open mod menu");
+                        Utility.LogWarning($"Could not open mod menu file '{modItem.MenuFile}'");
                         return null;
                     }
                     else
@@ -487,12 +487,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (afileBase == null || !afileBase.IsValid())
                 {
-                    Utility.Logger.LogError("Could not open menu");
+                    Utility.LogWarning($"Could not open menu file '{menu}'");
                     return null;
                 }
                 else if (afileBase.GetSize() == 0)
                 {
-                    Utility.Logger.LogError("Mod menu is empty");
+                    Utility.LogWarning($"Mod menu is empty '{menu}'");
                     return null;
                 }
                 else
@@ -513,7 +513,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch
                 {
-                    Utility.Logger.LogError($"Could not load mesh for '{modItem.MenuFile}'");
+                    Utility.LogWarning($"Could not load mesh for '{modItem.MenuFile}'");
                 }
 
                 if (gameObject != null)
@@ -528,8 +528,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                             )
                             {
                                 renderer.materials[matChange.MaterialIndex] = ImportCM.LoadMaterial(
-                                        matChange.MaterialFile, null, renderer.materials[matChange.MaterialIndex]
-                                    );
+                                    matChange.MaterialFile, null, renderer.materials[matChange.MaterialIndex]
+                                );
                             }
                         }
                     }
@@ -544,7 +544,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             else
             {
-                Utility.Logger.LogWarning($"Could not parse menu file '{modItem.MenuFile}'");
+                Utility.LogMessage($"Could not parse menu file '{modItem.MenuFile}'");
                 return null;
             }
         }
@@ -579,7 +579,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             catch
             {
-                Utility.Logger.LogError($"Could not read menu file '{menuFile}'");
+                Utility.LogError($"Could not read menu file '{menuFile}'");
                 return false;
             }
 
@@ -643,7 +643,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch (Exception e)
                 {
-                    Utility.Logger.LogWarning($"Could not parse menu file '{menuFile}' because {e.Message}");
+                    Utility.LogWarning($"Could not parse menu file '{menuFile}' because {e.Message}");
                     return false;
                 }
             }
@@ -662,7 +662,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     if (fileStream == null) return false;
                     if (fileStream.Length == 0L)
                     {
-                        Utility.Logger.LogError($"Mod menu file '{modMenuFile}' is empty");
+                        Utility.LogError($"Mod menu file '{modMenuFile}' is empty");
                         return false;
                     }
                     buf = new byte[fileStream.Length];
@@ -671,7 +671,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             catch (Exception e)
             {
-                Utility.Logger.LogError($"Could not read mod menu file '{modMenuFile} because {e.Message}'");
+                Utility.LogError($"Could not read mod menu file '{modMenuFile} because {e.Message}'");
                 return false;
             }
 
@@ -725,7 +725,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch (Exception e)
                 {
-                    Utility.Logger.LogWarning($"Could not parse mod menu file '{modMenuFile}' because {e}");
+                    Utility.LogWarning($"Could not parse mod menu file '{modMenuFile}' because {e}");
                     return false;
                 }
             }

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

@@ -27,7 +27,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             if (!Directory.Exists(currentTranslationPath))
             {
-                Utility.Logger.LogWarning(
+                Utility.LogWarning(
                     $"No translations found for '{CurrentLanguage}' in '{currentTranslationPath}'"
                 );
                 return;
@@ -54,7 +54,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch
                 {
-                    Utility.Logger.LogError($"Could not find translation file '{translationFile}'");
+                    Utility.LogError($"Could not find translation file '{translationFile}'");
                 }
             }
         }
@@ -82,7 +82,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (warn)
                 {
-                    Utility.Logger.LogWarning($"Could not translate '{text}': category '{category}' was not found");
+                    Utility.LogWarning($"Could not translate '{text}': category '{category}' was not found");
                 }
                 return false;
             }
@@ -91,7 +91,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (warn)
                 {
-                    Utility.Logger.LogWarning(
+                    Utility.LogWarning(
                         $"Could not translate '{text}': '{text}' was not found in category '{category}'"
                     );
                 }

+ 10 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Utility.cs

@@ -14,6 +14,16 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             Control, Shift, Alt
         }
 
+        public static void LogInfo(object data) => Logger.LogInfo(data);
+
+        public static void LogMessage(object data) => Logger.LogInfo(data);
+
+        public static void LogWarning(object data) => Logger.LogWarning(data);
+
+        public static void LogError(object data) => Logger.LogError(data);
+
+        public static void LogDebug(object data) => Logger.LogDebug(data);
+
         public static int Wrap(int value, int min, int max)
         {
             max -= 1;