@@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
24
24
using System . Runtime . CompilerServices ;
25
25
using UnityEngine ;
26
26
using HarmonyLib ;
27
+ using KSPBuildTools ;
27
28
using Mono . Cecil ;
28
29
using Mono . Cecil . Cil ;
29
30
using Mono . Cecil . Rocks ;
@@ -64,7 +65,7 @@ static Shader FindLoadedShader(string shaderName)
64
65
{
65
66
Shader shader ;
66
67
if ( loadedShaders . TryGetValue ( shaderName , out shader ) ) {
67
- Log ( $ "custom shader: { shader . name } ") ;
68
+ Log . Message ( $ "custom shader: { shader . name } ") ;
68
69
return shader ;
69
70
}
70
71
@@ -82,7 +83,7 @@ public static Shader FindShader(string shaderName)
82
83
shader = FindLoadedShader ( replacement . shader ) ;
83
84
84
85
if ( shader == null ) {
85
- LogError ( $ "failed to find shader { replacement . shader } to replace { shaderName } ") ;
86
+ Log . Error ( $ "failed to find shader { replacement . shader } to replace { shaderName } ") ;
86
87
}
87
88
}
88
89
@@ -107,7 +108,7 @@ public static void MMPostLoadCallback()
107
108
var iconShaderName = iconNode . GetValue ( "iconShader" ) ;
108
109
var iconShader = FindShader ( iconShaderName ?? "" ) ;
109
110
if ( string . IsNullOrEmpty ( shader ) || iconShader == null ) {
110
- LogError ( $ "invalid icon shader specification { shader } -> { iconShaderName } ") ;
111
+ Log . Error ( $ "invalid icon shader specification { shader } -> { iconShaderName } ") ;
111
112
} else {
112
113
iconShaders [ shader ] = iconShader ;
113
114
}
@@ -119,13 +120,14 @@ public static void MMPostLoadCallback()
119
120
120
121
void Awake ( )
121
122
{
123
+ Debug . Log ( "Test context (shibboleth)" , this ) ;
122
124
if ( loadedShaders == null ) {
123
125
loadedShaders = new Dictionary < string , Shader > ( ) ;
124
126
125
127
harmony = new Harmony ( "Shabby" ) ;
126
128
harmony . PatchAll ( Assembly . GetExecutingAssembly ( ) ) ;
127
129
128
- LogDebug ( "hooked" ) ;
130
+ Log . Debug ( "hooked" ) ;
129
131
130
132
// Register as an explicit MM callback such that it is run before all reflected
131
133
// callbacks (as used by most mods), which may wish to access the MaterialDef library.
@@ -149,7 +151,7 @@ private void Start()
149
151
150
152
List < MethodBase > callSites = new List < MethodBase > ( ) ;
151
153
152
- LogDebug ( "Beginning search for callsites" ) ;
154
+ Log . Debug ( "Beginning search for callsites" ) ;
153
155
154
156
// Don't use appdomain, we don't want to accidentally patch Unity itself and this avoid
155
157
// having to iterate on the BCL and Unity assemblies.
@@ -190,7 +192,7 @@ private void Start()
190
192
if ( assemblyDef == null )
191
193
throw new FileLoadException ( $ "Couldn't read assembly \" { kspAssembly . assembly . Location } \" ") ;
192
194
} catch ( Exception e ) {
193
- LogWarning ( $ "Replace failed for assembly { kspAssembly . name } \n { e } ") ;
195
+ Log . Warning ( $ "Replace failed for assembly { kspAssembly . name } \n { e } ") ;
194
196
continue ;
195
197
}
196
198
@@ -211,7 +213,7 @@ private void Start()
211
213
if ( callSite == null )
212
214
throw new MemberAccessException ( ) ;
213
215
} catch {
214
- LogWarning (
216
+ Log . Warning (
215
217
$ "Failed to patch method { assemblyDef . Name } ::{ typeDef . Name } .{ methodDef . Name } ") ;
216
218
break ;
217
219
}
@@ -234,7 +236,7 @@ private void Start()
234
236
if ( callSite == mInfo_ShaderFind_Replacement )
235
237
continue ;
236
238
237
- Log (
239
+ Log . Debug (
238
240
$ "Patching call site : { callSite . DeclaringType . Assembly . GetName ( ) . Name } ::{ callSite . DeclaringType } .{ callSite . Name } ") ;
239
241
harmony . Patch ( callSite , null , null , new HarmonyMethod ( callSiteTranspiler ) ) ;
240
242
}
@@ -250,31 +252,5 @@ static IEnumerable<CodeInstruction> CallSiteTranspiler(IEnumerable<CodeInstructi
250
252
yield return instruction ;
251
253
}
252
254
}
253
-
254
- internal const string LogPrefix = "[Shabby] " ;
255
-
256
- [ System . Diagnostics . Conditional ( "DEBUG" ) ]
257
- internal static void LogDebug ( string message )
258
- {
259
- Debug . Log ( LogPrefix + message ) ;
260
- }
261
-
262
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
263
- internal static void Log ( string message )
264
- {
265
- Debug . Log ( LogPrefix + message ) ;
266
- }
267
-
268
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
269
- internal static void LogWarning ( string message )
270
- {
271
- Debug . LogWarning ( LogPrefix + message ) ;
272
- }
273
-
274
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
275
- internal static void LogError ( string message )
276
- {
277
- Debug . LogError ( LogPrefix + message ) ;
278
- }
279
255
}
280
256
}
0 commit comments