123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using Harmony;
- using XUnity.AutoTranslator.Plugin.Core.Constants;
- namespace XUnity.AutoTranslator.Plugin.Core.Hooks
- {
- public static class NGUIImageHooks
- {
- public static readonly Type[] All = new Type[] {
- typeof( UIAtlas_spriteMaterial_Hook ),
- typeof( UISprite_OnInit_Hook ),
- typeof( UISprite_material_Hook ),
- typeof( UISprite_atlas_Hook ),
- typeof( UI2DSprite_sprite2D_Hook ),
- typeof( UI2DSprite_material_Hook ),
- typeof( UITexture_mainTexture_Hook ),
- typeof( UITexture_material_Hook ),
- typeof( UIPanel_clipTexture_Hook ),
- typeof( UIRect_OnInit_Hook ),
- //typeof( UIFont_dynamicFont_Hook ),
- //typeof( UIFont_material_Hook ),
- //typeof( UILabel_bitmapFont_Hook ),
- //typeof( UILabel_trueTypeFont_Hook ),
- };
- }
- [Harmony]
- public static class UIAtlas_spriteMaterial_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UIAtlas != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UIAtlas, "spriteMaterial" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance, null, false );
- }
- }
-
- [Harmony]
- public static class UISprite_OnInit_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UISprite != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Method( Constants.ClrTypes.UISprite, "OnInit" );
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance );
- }
- }
- [Harmony]
- public static class UISprite_material_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UISprite != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UISprite, "material" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance, null, false );
- }
- }
- [Harmony]
- public static class UISprite_atlas_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UISprite != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UISprite, "atlas" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance, null, false );
- }
- }
-
- [Harmony]
- public static class UITexture_mainTexture_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UITexture != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UITexture, "mainTexture" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance, null, false );
- }
- }
- [Harmony]
- public static class UITexture_material_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UITexture != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UITexture, "material" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance, null, false );
- }
- }
- [Harmony]
- public static class UIRect_OnInit_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UIRect != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Method( ClrTypes.UIRect, "OnInit" );
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance );
- }
- }
- [Harmony]
- public static class UI2DSprite_sprite2D_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UI2DSprite != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UI2DSprite, "sprite2D" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance, null, false );
- }
- }
- [Harmony]
- public static class UI2DSprite_material_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UI2DSprite != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UI2DSprite, "material" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance, null, false );
- }
- }
- [Harmony]
- public static class UIPanel_clipTexture_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UIPanel != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UIPanel, "clipTexture" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance );
- }
- }
- [Harmony]
- public static class UIFont_material_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UIFont != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UIFont, "material" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance );
- }
- }
- [Harmony]
- public static class UIFont_dynamicFont_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UIFont != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UIFont, "dynamicFont" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance );
- }
- }
- [Harmony]
- public static class UILabel_bitmapFont_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UILabel != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UILabel, "bitmapFont" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance );
- }
- }
- [Harmony]
- public static class UILabel_trueTypeFont_Hook
- {
- static bool Prepare( HarmonyInstance instance )
- {
- return ClrTypes.UILabel != null;
- }
- static MethodBase TargetMethod( HarmonyInstance instance )
- {
- return AccessTools.Property( ClrTypes.UILabel, "trueTypeFont" ).GetSetMethod();
- }
- public static void Postfix( object __instance )
- {
- AutoTranslationPlugin.Current.Hook_ImageChangedOnComponent( __instance );
- }
- }
- }
|