diff --git a/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/GameData/ConformalDecals/Plugins/ConformalDecals.dll index 2db784f..aca4399 100644 Binary files a/GameData/ConformalDecals/Plugins/ConformalDecals.dll and b/GameData/ConformalDecals/Plugins/ConformalDecals.dll differ diff --git a/Source/ConformalDecals/DecalConfig.cs b/Source/ConformalDecals/DecalConfig.cs index c5bbcae..a0cc843 100644 --- a/Source/ConformalDecals/DecalConfig.cs +++ b/Source/ConformalDecals/DecalConfig.cs @@ -107,7 +107,7 @@ namespace ConformalDecals { } private static Texture2D MakeBlankNormal() { - Debug.Log("ConformalDecals: Generating neutral normal map texture"); + Logging.Log("Generating neutral normal map texture"); var width = 2; var height = 2; var color = new Color32(255, 128, 128, 128); @@ -133,7 +133,7 @@ namespace ConformalDecals { var configs = GameDatabase.Instance.GetConfigs("CONFORMALDECALS"); if (configs.Length > 0) { - Debug.Log("ConformalDecals: loading config"); + Logging.Log("loading config"); foreach (var config in configs) { ParseConfig(config.config); } diff --git a/Source/ConformalDecals/DecalIconFixer.cs b/Source/ConformalDecals/DecalIconFixer.cs index 491a95f..68537e3 100644 --- a/Source/ConformalDecals/DecalIconFixer.cs +++ b/Source/ConformalDecals/DecalIconFixer.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using ConformalDecals.Util; using UnityEngine; namespace ConformalDecals { @@ -12,11 +13,11 @@ namespace ConformalDecals { public void Start() { foreach (var partName in PartNames) { - Debug.Log($"Unf*&king decal preview on {partName}"); + Logging.Log($"Unf*&king decal preview on '{partName}'"); var partInfo = PartLoader.getPartInfoByName(partName); if (partInfo == null) { - Debug.Log($"Part {partName} not found!"); + Logging.LogError($"Part {partName} not found!"); continue; } @@ -28,12 +29,12 @@ namespace ConformalDecals { var backTransform = Part.FindHeirarchyTransform(icon.transform, decalModule.decalBack); if (frontTransform == null) { - Debug.Log($"Part {partName} has no frontTransform"); + Logging.Log($"Part '{partName}' has no frontTransform"); continue; } if (backTransform == null) { - Debug.Log($"Part {partName} has no backTransform"); + Logging.Log($"Part '{partName}' has no backTransform"); continue; } diff --git a/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs b/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs index e12cfac..579ff23 100644 --- a/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs +++ b/Source/ConformalDecals/MaterialProperties/MaterialPropertyCollection.cs @@ -202,7 +202,7 @@ namespace ConformalDecals.MaterialProperties { public void SetShader(string shaderName) { if (string.IsNullOrEmpty(shaderName)) { if (_shader == null) { - Debug.Log("Using default decal shader"); + Logging.Log("Using default decal shader"); shaderName = "ConformalDecals/Decal/Standard"; } else { @@ -211,7 +211,7 @@ namespace ConformalDecals.MaterialProperties { } if (DecalConfig.IsLegacy(shaderName, out var newShader, out var keywords)) { - Debug.LogWarning($"[ConformalDecals] Part is using shader {shaderName}, which has been replaced by {newShader}."); + Logging.LogWarning($"Part is using shader {shaderName}, which has been replaced by {newShader}."); shaderName = newShader; foreach (var keyword in keywords) { var newProperty = AddOrGetProperty(keyword); diff --git a/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs b/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs index 6d0af85..6766f3b 100644 --- a/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs +++ b/Source/ConformalDecals/MaterialProperties/MaterialTextureProperty.cs @@ -109,7 +109,7 @@ namespace ConformalDecals.MaterialProperties { } private static Texture2D LoadTexture(string textureUrl, bool isNormal) { - Debug.Log($"loading texture '{textureUrl}', isNormalMap = {isNormal}"); + //Logging.Log($"loading texture '{textureUrl}', isNormalMap = {isNormal}"); if ((string.IsNullOrEmpty(textureUrl) && isNormal) || textureUrl == "Bump") { return Texture2D.normalTexture; } diff --git a/Source/ConformalDecals/Text/FontLoader.cs b/Source/ConformalDecals/Text/FontLoader.cs index ddb13e5..1fe5863 100644 --- a/Source/ConformalDecals/Text/FontLoader.cs +++ b/Source/ConformalDecals/Text/FontLoader.cs @@ -1,6 +1,7 @@ using System.IO; using System.Collections; using System.Collections.Generic; +using ConformalDecals.Util; using TMPro; using UniLinq; using UnityEngine; @@ -15,18 +16,18 @@ namespace ConformalDecals.Text { public override IEnumerator Load(UrlDir.UrlFile urlFile, FileInfo fileInfo) { if (_fallbackFont == null) { _fallbackFont = Resources.FindObjectsOfTypeAll().First(o => o.name == FallbackName); - if (_fallbackFont == null) Debug.LogError($"Could not find fallback font '{FallbackName}'"); + if (_fallbackFont == null) Logging.LogError($"Could not find fallback font '{FallbackName}'"); } - Debug.Log($"[ConformalDecals] '{urlFile.fullPath}'"); + Logging.Log($"Loading font file '{urlFile.fullPath}'"); var bundle = AssetBundle.LoadFromFile(urlFile.fullPath); if (!bundle) { - Debug.Log($"[ConformalDecals] could not load font asset {urlFile.fullPath}"); + Logging.Log($"Could not load font asset {urlFile.fullPath}"); } else { var loadedFonts = bundle.LoadAllAssets(); foreach (var font in loadedFonts) { - Debug.Log($"[ConformalDecals] adding font {font.name}"); + Logging.Log($"Adding font {font.name}"); font.fallbackFontAssets.Add(_fallbackFont); } } diff --git a/Source/ConformalDecals/Text/TextRenderer.cs b/Source/ConformalDecals/Text/TextRenderer.cs index f7eb319..5f25400 100644 --- a/Source/ConformalDecals/Text/TextRenderer.cs +++ b/Source/ConformalDecals/Text/TextRenderer.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using ConformalDecals.Util; using TMPro; using UnityEngine; using UnityEngine.Events; @@ -66,7 +67,6 @@ namespace ConformalDecals.Text { /// Unregister a user of a piece of text public static void UnregisterText(DecalText text) { - Debug.Log($"[ConformalDecals] Unregistering text '{text.Text}'"); if (RenderCache.TryGetValue(text, out var renderedText)) { renderedText.UserCount--; if (renderedText.UserCount <= 0) { @@ -78,10 +78,10 @@ namespace ConformalDecals.Text { private void Start() { if (_instance != null) { - Debug.Log("[ConformalDecals] Duplicate TextRenderer created???"); + Logging.LogError("Duplicate TextRenderer created???"); } - Debug.Log("[ConformalDecals] Creating TextRenderer Object"); + Logging.Log("Creating TextRenderer Object"); _instance = this; DontDestroyOnLoad(gameObject); } @@ -90,13 +90,13 @@ namespace ConformalDecals.Text { private void Setup() { if (_isSetup) return; - Debug.Log("[ConformalDecals] Setting Up TextRenderer Object"); + Logging.Log("Setting Up TextRenderer Object"); _tmp = gameObject.AddComponent(); _tmp.renderer.enabled = false; // dont automatically render _blitShader = Shabby.Shabby.FindShader(ShaderName); - if (_blitShader == null) Debug.LogError($"[ConformalDecals] could not find text blit shader named '{ShaderName}'"); + if (_blitShader == null) Logging.LogError($"Could not find text blit shader named '{ShaderName}'"); _isSetup = true; } @@ -108,11 +108,6 @@ namespace ConformalDecals.Text { return null; } - Debug.Log($"[ConformalDecals] Starting Text Rendering Job. queue depth = {RenderJobs.Count}, cache size = {RenderCache.Count}"); - foreach (var cacheitem in RenderCache) { - Debug.Log($"[ConformalDecals] Cache item: '{cacheitem.Key.Text}' with {cacheitem.Value.UserCount} users"); - } - job.Start(); Texture2D texture = null; @@ -123,15 +118,10 @@ namespace ConformalDecals.Text { if (oldRender.UserCount <= 0) { // this is the only usage of this output, so we are free to re-render into the texture - Debug.Log("Render output is not shared with other users, so reusing texture and removing cache slot"); texture = oldRender.Texture; RenderCache.Remove(job.OldText); } - else { - // other things are using this render output, so decriment usercount, and we'll make a new entry instead - Debug.Log("Render output is shared with other users, so making new output"); - } } // now that all old references are handled, begin rendering the new output @@ -210,7 +200,7 @@ namespace ConformalDecals.Text { }; if (textureSize.x == 0 || textureSize.y == 0) { - Debug.LogWarning("[ConformalDecals] No text present or error in texture size calculation. Aborting."); + Logging.LogWarning("No text present or error in texture size calculation. Aborting."); return new TextRenderOutput(Texture2D.blackTexture, Rect.zero); } diff --git a/Source/ConformalDecals/UI/FontMenuController.cs b/Source/ConformalDecals/UI/FontMenuController.cs index 60e0115..14928bf 100644 --- a/Source/ConformalDecals/UI/FontMenuController.cs +++ b/Source/ConformalDecals/UI/FontMenuController.cs @@ -46,7 +46,6 @@ namespace ConformalDecals.UI { Toggle active = null; foreach (var font in fonts.OrderBy(x => x.Title)) { - Debug.Log(font.Title); var listItem = GameObject.Instantiate(_menuItem, _menuList.transform); listItem.name = font.Title; listItem.SetActive(true); diff --git a/Source/ConformalDecals/UI/TextEntryController.cs b/Source/ConformalDecals/UI/TextEntryController.cs index 7d40431..c735d77 100644 --- a/Source/ConformalDecals/UI/TextEntryController.cs +++ b/Source/ConformalDecals/UI/TextEntryController.cs @@ -1,5 +1,6 @@ using System; using ConformalDecals.Text; +using ConformalDecals.Util; using TMPro; using UnityEngine; using UnityEngine.Events; @@ -102,7 +103,7 @@ namespace ConformalDecals.UI { _style.LineSpacing = Mathf.Clamp(value, _lineSpacingRange.x, _lineSpacingRange.y); } else { - Debug.LogWarning("[ConformalDecals] line spacing value '{text}' could not be parsed."); + Logging.LogWarning("Line spacing value '{text}' could not be parsed."); } UpdateLineSpacing(); @@ -125,7 +126,7 @@ namespace ConformalDecals.UI { _style.CharSpacing = Mathf.Clamp(value, _charSpacingRange.x, _charSpacingRange.y); } else { - Debug.LogWarning("[ConformalDecals] char spacing value '{text}' could not be parsed."); + Logging.LogWarning("Char spacing value '{text}' could not be parsed."); } UpdateCharSpacing(); diff --git a/Source/ConformalDecals/UI/UILoader.cs b/Source/ConformalDecals/UI/UILoader.cs index 67dfa04..18c92f7 100644 --- a/Source/ConformalDecals/UI/UILoader.cs +++ b/Source/ConformalDecals/UI/UILoader.cs @@ -44,7 +44,6 @@ namespace ConformalDecals.UI { var tags = window.GetComponentsInChildren(true); foreach (var tag in tags) { - Debug.Log($"Handling object {tag.gameObject.name}"); switch (tag.type) { case UITag.UIType.Window: ProcessImage(tag.gameObject, skin.window); diff --git a/Source/ConformalDecals/Util/Logging.cs b/Source/ConformalDecals/Util/Logging.cs index a3206f3..8a48793 100644 --- a/Source/ConformalDecals/Util/Logging.cs +++ b/Source/ConformalDecals/Util/Logging.cs @@ -3,18 +3,23 @@ using UnityEngine; namespace ConformalDecals.Util { public static class Logging { + public static void Log(string message) => Debug.Log("[ConformalDecals] " + message); + public static void Log(this PartModule module, string message) => Debug.Log(FormatMessage(module, message)); - public static void LogWarning(this PartModule module, string message) => - Debug.LogWarning(FormatMessage(module, message)); + public static void LogWarning(string message) => Debug.LogWarning("[ConformalDecals] " + message); + + public static void LogWarning(this PartModule module, string message) => Debug.LogWarning(FormatMessage(module, message)); + + public static void LogError(string message) => Debug.LogError("[ConformalDecals] " + message); - public static void LogError(this PartModule module, string message) => - Debug.LogError(FormatMessage(module, message)); + public static void LogError(this PartModule module, string message) => Debug.LogError(FormatMessage(module, message)); + + public static void LogException(string message, Exception exception) => Debug.LogException(new Exception("[ConformalDecals] " + message, exception)); public static void LogException(this PartModule module, string message, Exception exception) => Debug.LogException(new Exception(FormatMessage(module, message), exception)); - private static string FormatMessage(PartModule module, string message) => $"[{GetPartName(module.part)} {module.GetType()}] {message}";