@@ -54,12 +54,12 @@ public void Run()
5454 private void LoadAssemblies ( )
5555 {
5656 _module = AssemblyDef . Load ( _assembly ) . Modules . Single ( ) ;
57- _emitter = new TranslationEmitter ( _module , _language ) ;
57+ _emitter = new TranslationEmitter ( _module , _language , _mod . Name ) ;
5858
5959 if ( _monoAssembly != null )
6060 {
6161 _monoModule = AssemblyDef . Load ( _monoAssembly ) . Modules . Single ( ) ;
62- _monoEmitter = new TranslationEmitter ( _monoModule , _language ) ;
62+ _monoEmitter = new TranslationEmitter ( _monoModule , _language , _mod . Name ) ;
6363 }
6464 }
6565
@@ -133,8 +133,10 @@ void ApplyItemsInternal(ItemTranslation translation, TranslationEmitter emitter)
133133
134134 if ( ins . OpCode . Equals ( OpCodes . Ldstr ) && inst [ index - 2 ] . OpCode . Equals ( OpCodes . Ldstr ) )
135135 {
136- inst [ index - 2 ] . Operand = translation . ModifyTooltips [ listIndex ++ ] ;
137- inst [ index - 1 ] . Operand = translation . ModifyTooltips [ listIndex ++ ] ;
136+ var cache = inst [ index - 1 ] ;
137+
138+ emitter . Emit ( method , inst [ index - 2 ] , translation . ModifyTooltips [ listIndex ++ ] ) ;
139+ emitter . Emit ( method , cache , translation . ModifyTooltips [ listIndex ++ ] ) ;
138140 }
139141 else if ( ins . OpCode . Equals ( OpCodes . Call ) && ins . Operand is MemberRef n && n . Name . Equals ( "Concat" ) ) // for thorium mod
140142 {
@@ -185,7 +187,7 @@ void ApplyItemsInternal(ItemTranslation translation, TranslationEmitter emitter)
185187 switch ( m . Name )
186188 {
187189 case "setBonus" :
188- inst [ index - 1 ] . Operand = translation . SetBonus ;
190+ emitter . Emit ( method , inst [ index - 1 ] , translation . SetBonus ) ;
189191 break ;
190192 }
191193 }
@@ -237,14 +239,7 @@ void ApplyNpcsInternal(NpcTranslation translation, TranslationEmitter emitter)
237239 if ( ins . OpCode != OpCodes . Ldstr )
238240 continue ;
239241
240- ins = inst [ ++ index ] ;
241-
242- if ( ( ins . OpCode . Equals ( OpCodes . Call ) || ins . OpCode . Equals ( OpCodes . Callvirt ) )
243- && ins . Operand is IMethodDefOrRef m )
244- if ( ! m . Name . ToString ( ) . Equals ( "Concat" ) || m . MethodSig . Params . Count == 1 )
245- continue ;
246-
247- inst [ index - 1 ] . Operand = translation . ChatTexts [ listindex ++ ] ;
242+ emitter . Emit ( method , ins , translation . ChatTexts [ listindex ++ ] ) ;
248243 }
249244 }
250245
@@ -263,9 +258,9 @@ void ApplyNpcsInternal(NpcTranslation translation, TranslationEmitter emitter)
263258 ins = inst [ index - 1 ] ;
264259
265260 if ( ins . OpCode . Equals ( OpCodes . Ldarg_1 ) )
266- inst [ index ] . Operand = translation . ShopButton1 ;
261+ emitter . Emit ( method , inst [ index ] , translation . ShopButton1 ) ;
267262 else if ( ins . OpCode . Equals ( OpCodes . Ldarg_2 ) )
268- inst [ index ] . Operand = translation . ShopButton2 ;
263+ emitter . Emit ( method , inst [ index ] , translation . ShopButton2 ) ;
269264 }
270265 }
271266 }
@@ -338,31 +333,7 @@ void ApplyMiscsInternal(NewTextTranslation translation, TranslationEmitter emitt
338333
339334 if ( ( ins = inst [ index - 5 ] ) . OpCode . Equals ( OpCodes . Ldstr ) )
340335 {
341- ins . Operand = translation . Contents [ listIndex ++ ] ;
342- }
343- else if ( ins . OpCode . Equals ( OpCodes . Call ) &&
344- ins . Operand is IMethodDefOrRef n &&
345- n . Name . ToString ( ) . Equals ( "Concat" , StringComparison . Ordinal ) )
346- {
347- var index2 = index ;
348- var count = 0 ;
349- var total = n . MethodSig . Params . Count ;
350- var list = translation . Contents . GetRange ( listIndex , translation . Contents . Count - listIndex ) . AsEnumerable ( ) . Reverse ( ) . ToList ( ) ;
351- var currentIndex = 0 ;
352- while ( -- index2 > 0 && count < total )
353- {
354- ins = inst [ index2 ] ;
355- if ( ins . OpCode . Equals ( OpCodes . Ldelem_Ref ) ) // for array
356- {
357- count ++ ;
358- }
359- else if ( ins . OpCode . Equals ( OpCodes . Ldstr ) )
360- {
361- count ++ ;
362- listIndex ++ ;
363- ins . Operand = list [ currentIndex ++ ] ;
364- }
365- }
336+ emitter . Emit ( method , ins , translation . Contents [ listIndex ++ ] ) ;
366337 }
367338 }
368339 }
0 commit comments