Skip to content

Commit 728640b

Browse files
committed
use KSPBT's logging
1 parent 97fe1d1 commit 728640b

File tree

7 files changed

+31
-45
lines changed

7 files changed

+31
-45
lines changed

Source/GUI/ConfigurationGUI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Text;
88
using UnityEngine;
99
using UnityEngine.Rendering.PostProcessing;
10+
using Log = KSPBuildTools.Log;
1011

1112
namespace TUFX
1213
{
@@ -226,7 +227,7 @@ private void renderSelectionWindow()
226227
if (GUILayout.Button(profileNames[i]))
227228
{
228229
string newProfileName = profileNames[i];
229-
Log.debug("Profile Selected: " + newProfileName);
230+
Log.Debug("Profile Selected: " + newProfileName);
230231
TexturesUnlimitedFXLoader.INSTANCE.ChangeProfileForScene(newProfileName, scene);
231232
}
232233
GUILayout.EndHorizontal();

Source/GUI/DebugGUI.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using UnityEngine;
8+
using Log = KSPBuildTools.Log;
89

910
namespace TUFX
1011
{
@@ -28,7 +29,7 @@ public void Start()
2829
{
2930
layerFlags[i] = (mask & (1 << i)) > 0;
3031
}
31-
Log.debug("Camera layer mask: " + camera.cullingMask);
32+
Log.Debug("Camera layer mask: " + camera.cullingMask);
3233
}
3334

3435
public void OnGUI()
@@ -45,7 +46,7 @@ private void renderWindow(int id)
4546
GUILayout.Label("Skybox: ");
4647
if (GUILayout.Button((camera.clearFlags == CameraClearFlags.Depth).ToString()))
4748
{
48-
Log.debug("Clear flags: " + camera.clearFlags);
49+
Log.Debug("Clear flags: " + camera.clearFlags);
4950
if (camera.clearFlags == CameraClearFlags.Skybox) { camera.clearFlags = CameraClearFlags.Depth; }
5051
else { camera.clearFlags = CameraClearFlags.Skybox; }
5152
}

Source/PostProcessing/PostProcessEffectSettings.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using TUFX;
66
using System.Collections.Generic;
7+
using Log = KSPBuildTools.Log;
78

89
namespace UnityEngine.Rendering.PostProcessing
910
{
@@ -200,12 +201,12 @@ internal void loadVector4Parameter(ConfigNode node, string name, ParameterOverri
200201

201202
internal void loadSplineParameter(ConfigNode node, string name, ParameterOverride<Spline> param)
202203
{
203-
Log.debug("Loading spline for: " + GetType() + " with name: " + name);
204+
Log.Debug("Loading spline for: " + GetType() + " with name: " + name);
204205
ConfigNode splineNode = node.GetNode("SPLINE", "name", name);
205-
Log.debug("Node: " + splineNode);
206+
Log.Debug("Node: " + splineNode);
206207
if (splineNode == null)
207208
{
208-
Log.debug("Node was null...");
209+
Log.Debug("Node was null...");
209210
return;
210211
}
211212
string[] keys = splineNode.GetValues("key");

Source/Scattering/TUFXScatteringManager.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading.Tasks;
66
using UnityEngine;
77
using UnityEngine.Rendering.PostProcessing;
8+
using Log = KSPBuildTools.Log;
89

910
namespace TUFX
1011
{
@@ -42,7 +43,7 @@ private void onLevelLoaded(GameScenes scene)
4243
GameObject[] objects = GameObject.FindObjectsOfType<GameObject>();
4344
foreach (GameObject go in objects)
4445
{
45-
Log.debug("Main Menu Object: " + go.name + " pos: " + go.transform.position + " parent: " + go.transform.parent?.name);
46+
Log.Debug("Main Menu Object: " + go.name + " pos: " + go.transform.position + " parent: " + go.transform.parent?.name);
4647
}
4748
if (debugModel != null)
4849
{
@@ -56,7 +57,7 @@ internal void debugProfileSetup(PostProcessVolume volume, PostProcessLayer layer
5657
{
5758
if (TUFXScatteringResources.PrecomputeShader == null)
5859
{
59-
Log.debug("Could not create model; precompute shader is null...");
60+
Log.Debug("Could not create model; precompute shader is null...");
6061
return;
6162
}
6263
createTestModel();
@@ -109,7 +110,7 @@ public void Update()
109110
private void createTestModel()
110111
{
111112
if (debugModel != null) { return; }
112-
Log.debug("Creating debug atmo model...");
113+
Log.Debug("Creating debug atmo model...");
113114
// Values from "Reference Solar Spectral Irradiance: ASTM G-173", ETR column
114115
// (see http://rredc.nrel.gov/solar/spectra/am1.5/ASTMG173/ASTMG173.html),
115116
// summed and averaged in each bin (e.g. the value for 360nm is the average

Source/TUFXEffectTextureList.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using UnityEngine;
7+
using Log = KSPBuildTools.Log;
78

89
namespace TUFX
910
{
@@ -45,7 +46,7 @@ public List<Texture2D> GetTextures(string propertyName)
4546
List<Texture2D> textures;
4647
if (!propertyTextures.TryGetValue(propertyName, out textures))
4748
{
48-
Log.debug("No textures found for property: " + propertyName);
49+
Log.Debug("No textures found for property: " + propertyName);
4950
return new List<Texture2D>();//because C# doesn't have a static (and typed) empty list construct?
5051
}
5152
return textures;

Source/TexturesUnlimitedFXLoader.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using ToolbarControl_NS;
77
using UnityEngine;
88
using UnityEngine.Rendering.PostProcessing;
9+
using Log = KSPBuildTools.Log;
910

1011
namespace TUFX
1112
{
@@ -153,7 +154,7 @@ public void Start()
153154
}
154155
public void ModuleManagerPostLoad()
155156
{
156-
Log.log("TUFXLoader - MMPostLoad()");
157+
Log.Message("TUFXLoader - MMPostLoad()");
157158

158159
//only load resources once. In case of MM reload...
159160
if (Resources == null)
@@ -208,7 +209,7 @@ private void loadResources()
208209
if (!this.shaders.ContainsKey(shaders[i].name))
209210
{
210211
this.shaders.Add(shaders[i].name, shaders[i]);
211-
Log.debug("Loading scattering shader: " + shaders[i].name);
212+
Log.Debug("Loading scattering shader: " + shaders[i].name);
212213
}
213214
}
214215
compShaders = bundle.LoadAllAssets<ComputeShader>();
@@ -218,7 +219,7 @@ private void loadResources()
218219
if (!this.computeShaders.ContainsKey(compShaders[i].name))
219220
{
220221
this.computeShaders.Add(compShaders[i].name, compShaders[i]);
221-
Log.debug("Loading scattering compute shader: " + compShaders[i].name);
222+
Log.Debug("Loading scattering compute shader: " + compShaders[i].name);
222223
}
223224
}
224225
bundle.Unload(false);
@@ -227,7 +228,7 @@ private void loadResources()
227228
}
228229
catch (Exception e)
229230
{
230-
Log.debug(e.ToString());
231+
Log.Debug(e.ToString());
231232
}
232233

233234
#region REGION - Load standard Post Process Effect Shaders
@@ -314,13 +315,13 @@ private void loadTextures()
314315
int len = textureListNodes.Length;
315316
for (int i = 0; i < len; i++)
316317
{
317-
Log.debug("Loading TUFX_TEXTURES[" + textureListNodes[i].GetValue("name") + "]");
318+
Log.Debug("Loading TUFX_TEXTURES[" + textureListNodes[i].GetValue("name") + "]");
318319
ConfigNode[] effectTextureLists = textureListNodes[i].GetNodes("EFFECT");
319320
int len2 = effectTextureLists.Length;
320321
for (int k = 0; k < len2; k++)
321322
{
322323
string effectName = effectTextureLists[k].GetValue("name");
323-
Log.debug("Loading EFFECT[" + effectName + "]");
324+
Log.Debug("Loading EFFECT[" + effectName + "]");
324325
if (!this.EffectTextureLists.TryGetValue(effectName, out TUFXEffectTextureList etl))
325326
{
326327
this.EffectTextureLists[effectName] = etl = new TUFXEffectTextureList();
@@ -331,13 +332,13 @@ private void loadTextures()
331332
{
332333
string propName = names[m];
333334
if (propName == "name") { continue; }//don't load textures for the 'name=' entry in the configs
334-
Log.debug("Loading Textures for property [" + propName + "]");
335+
Log.Debug("Loading Textures for property [" + propName + "]");
335336
string[] values = effectTextureLists[k].GetValues(propName);
336337
int len4 = values.Length;
337338
for (int r = 0; r < len4; r++)
338339
{
339340
string texName = values[r];
340-
Log.debug("Loading Texture for name [" + texName + "]");
341+
Log.Debug("Loading Texture for name [" + texName + "]");
341342
Texture2D tex = GameDatabase.Instance.GetTexture(texName, false);
342343
if (tex != null)
343344
{
@@ -347,12 +348,12 @@ private void loadTextures()
347348
}
348349
else
349350
{
350-
Log.log("Ignoring duplicate texture: " + texName + " for effect: " + effectName + " property: " + propName);
351+
Log.Message("Ignoring duplicate texture: " + texName + " for effect: " + effectName + " property: " + propName);
351352
}
352353
}
353354
else
354355
{
355-
Log.error("Texture specified by path: " + texName + " was not found when attempting to load textures for effect: " + effectName + " propertyName: " + propName);
356+
Log.Error("Texture specified by path: " + texName + " was not found when attempting to load textures for effect: " + effectName + " propertyName: " + propName);
356357
}
357358
}
358359
}
@@ -376,7 +377,7 @@ private void loadProfiles()
376377
}
377378
else
378379
{
379-
Log.error("TUFX Profiles already contains profile for name: " + profile.ProfileName + ". This is the result of a configuration with" +
380+
Log.Error("TUFX Profiles already contains profile for name: " + profile.ProfileName + ". This is the result of a configuration with" +
380381
" a duplicate name; please check your configurations and remove any duplicates. Only the first configuration parsed for any one name will be loaded.");
381382
}
382383
}
@@ -436,7 +437,7 @@ internal bool isBuiltinTexture(Texture2D tex)
436437
/// <param name="scene"></param>
437438
private void onLevelLoaded(GameScenes gameScene)
438439
{
439-
Log.debug("TUFXLoader - onLevelLoaded( " + gameScene + " )");
440+
Log.Debug("TUFXLoader - onLevelLoaded( " + gameScene + " )");
440441

441442
CloseConfigGui();
442443

@@ -580,7 +581,7 @@ private TUFXProfile GetProfileByName(string profileName)
580581

581582

582583

583-
Log.error($"Profile {profileName} not found; falling back to {Configuration.EMPTY_PROFILE_NAME}");
584+
Log.Error($"Profile {profileName} not found; falling back to {Configuration.EMPTY_PROFILE_NAME}");
584585
return Profiles[Configuration.EMPTY_PROFILE_NAME];
585586
}
586587

Source/Utils.cs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Threading.Tasks;
1010
using UnityEngine;
1111
using Debug = UnityEngine.Debug;
12+
using Log = KSPBuildTools.Log;
1213

1314
namespace TUFX
1415
{
@@ -78,7 +79,7 @@ public static T GetEnumValue<T>(this ConfigNode node, string name, T defaultValu
7879
}
7980
catch (Exception e)
8081
{
81-
Log.debug(e.ToString());
82+
Log.Debug(e.ToString());
8283
return defaultValue;
8384
}
8485
}
@@ -244,25 +245,4 @@ static internal TUFXScene GetCurrentScene()
244245
return TUFXScene.Flight;
245246
}
246247
}
247-
248-
public static class Log
249-
{
250-
[Conditional("DEBUG")]
251-
public static void debug(string msg)
252-
{
253-
#if DEBUG
254-
MonoBehaviour.print("[TUFX-DEBUG] " + msg);
255-
#endif
256-
}
257-
public static void log(string msg) { MonoBehaviour.print("[TUFX] " + msg); }
258-
public static void exception(Exception ex)
259-
{
260-
Debug.LogException(ex);
261-
}
262-
263-
public static void error(string msg)
264-
{
265-
Debug.LogError(msg);
266-
}
267-
}
268248
}

0 commit comments

Comments
 (0)