Exemple #1
0
        /// <summary>
        /// This method will set up the Texture Replacer object and wrap all the methods/functions
        /// </summary>
        /// <param name="Force">This option will force the Init function to rebind everything</param>
        /// <returns></returns>
        public static Boolean InitTRWrapper()
        {
            //reset the internal objects
            _TRWrapped         = false;
            actualTR           = null;
            TexRepPersonaliser = null;
            LogFormatted_DebugOnly("Attempting to Grab TextureReplacer Types...");

            //find the base type
            TRType = getType("TextureReplacer.TextureReplacer");

            if (TRType == null)
            {
                return(false);
            }

            LogFormatted("TextureReplacer Version:{0}", TRType.Assembly.GetName().Version.ToString());

            //find the personaliser class type
            TRPersonaliserType = getType("TextureReplacer.Personaliser");

            if (TRPersonaliserType == null)
            {
                return(false);
            }

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");
            try
            {
                actualTR = TRType.GetField("isInitialised", BindingFlags.Public | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                LogFormatted("No Texture Replacer isInitialised found");
                //throw;
            }
            try
            {
                actualTRPersonaliser = TRPersonaliserType.GetField("instance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                LogFormatted("No Texture Replacer Personaliser Instance found");
                //throw;
            }
            if (actualTR == null || actualTRPersonaliser == null)
            {
                LogFormatted("Failed grabbing Instance");
                return(false);
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted_DebugOnly("Got Instance, Creating Wrapper Objects");
            TexRepPersonaliser = new TRPersonaliserAPI(actualTRPersonaliser);

            _TRWrapped = true;
            return(true);
        }
        /// <summary>
        /// This method will set up the Texture Replacer object and wrap all the methods/functions
        /// </summary>
        /// <param name="Force">This option will force the Init function to rebind everything</param>
        /// <returns></returns>
        public static Boolean InitTRWrapper()
        {
            //reset the internal objects
            _TRWrapped = false;
            actualTR = null;
            TexRepPersonaliser = null;
            LogFormatted_DebugOnly("Attempting to Grab TextureReplacer Types...");

            //find the base type
            TRType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "TextureReplacer.TextureReplacer");

            if (TRType == null)
            {
                return false;
            }

            LogFormatted("TextureReplacer Version:{0}", TRType.Assembly.GetName().Version.ToString());

            //find the personaliser class type
            TRPersonaliserType = AssemblyLoader.loadedAssemblies
                .Select(a => a.assembly.GetExportedTypes())
                .SelectMany(t => t)
                .FirstOrDefault(t => t.FullName == "TextureReplacer.Personaliser");

            if (TRPersonaliserType == null)
            {
                return false;
            }

            //now grab the running instance
            LogFormatted_DebugOnly("Got Assembly Types, grabbing Instances");
            try
            {
                actualTR = TRType.GetField("isInitialised", BindingFlags.Public | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                LogFormatted("No Texture Replacer isInitialised found");
                //throw;
            }
            try
            {
                actualTRPersonaliser = TRPersonaliserType.GetField("instance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
            }
            catch (Exception)
            {
                LogFormatted("No Texture Replacer Personaliser Instance found");
                //throw;
            }
            if (actualTR == null || actualTRPersonaliser == null)
            {
                LogFormatted("Failed grabbing Instance");
                return false;
            }

            //If we get this far we can set up the local object and its methods/functions
            LogFormatted_DebugOnly("Got Instance, Creating Wrapper Objects");
            TexRepPersonaliser = new TRPersonaliserAPI(actualTRPersonaliser);

            _TRWrapped = true;
            return true;
        }