mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Logging refactor
dll update
This commit is contained in:
parent
1859e51a2e
commit
885dfb3397
Binary file not shown.
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<MaterialKeywordProperty>(keyword);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<TMP_FontAsset>().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<TMP_FontAsset>();
|
||||
foreach (var font in loadedFonts) {
|
||||
Debug.Log($"[ConformalDecals] adding font {font.name}");
|
||||
Logging.Log($"Adding font {font.name}");
|
||||
font.fallbackFontAssets.Add(_fallbackFont);
|
||||
}
|
||||
}
|
||||
|
@ -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<TextMeshPro>();
|
||||
_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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -44,7 +44,6 @@ namespace ConformalDecals.UI {
|
||||
var tags = window.GetComponentsInChildren<UITag>(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);
|
||||
|
@ -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 LogError(this PartModule module, string message) =>
|
||||
Debug.LogError(FormatMessage(module, 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 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}";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user