Ejemplo n.º 1
0
        static void CopyFileAndReferencesToFolder(MOWAP modData, string folderToCopy, params string[] originFolders)
        {
            string fileName = Path.GetFileName(modData.DllFilePath);

            if (Directory.GetFiles(folderToCopy, fileName).Length == 0)
            {
                Console.WriteLine(Path.GetFileName(modData.DllFilePath) + " wasn't in " + folderToCopy + ", copying it there");
                File.Copy(modData.DllFilePath, folderToCopy + '/' + fileName);
            }

            for (int i = 0; i < modData.Dependencies.Length; i++)
            {
                if (Directory.GetFiles(folderToCopy, modData.Dependencies[i]).Length == 0)
                {
                    Console.WriteLine("{0} wasn't in the folder, copying it there", modData.Dependencies[i]);
                    string filePath = "";

                    foreach (string origin in originFolders)
                    {
                        try
                        {
                            filePath = ModManager.GetFilePathInDirectory(modData.Dependencies[i], origin);
                        }
                        catch { }
                    }
                    if (filePath != "")
                    {
                        File.Copy(modData.DllFilePath, folderToCopy + '/' + modData.Dependencies[i]);
                    }
                    else
                    {
                        Console.WriteLine("Couldn't find the file {0}, a dependencie of {1}, in any folder, make sure that it is in there", modData.Dependencies[i], modData.ModName);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public Target MOWAPModInnitTarget(MOWAP modMOWAP, Patcher modPatcher)
 {
     return(MOWAPModInnitTarget(modMOWAP.ModType, modMOWAP.ModInnitMethod, modMOWAP.ModName, modPatcher, modMOWAP.ModLoadingPlace, modMOWAP.ModPriority));
 }
Ejemplo n.º 3
0
        public MOWAP GenerateModMOWAPFromDll(string file, Type imowaModInnitType)

        {
            MOWAP    mowap       = new MOWAP();
            string   path        = ModManager.GetFilePathInDirectory(file, modFolder);
            Assembly modAssembly = Assembly.LoadFrom(path);

            Type[] classesNoDll = modAssembly.GetTypes();

            //Ir em cada classe
            foreach (Type classeDoDll in classesNoDll)
            {
                //Ir em cada método de cada classe
                foreach (MethodInfo mInfo in classeDoDll.GetMethods())
                {
                    //Ir em cada atributo de cada método
                    foreach (Attribute attr in Attribute.GetCustomAttributes(mInfo))
                    {
                        // Ver se é o atributo que queremos
                        if (attr.GetType() == imowaModInnitType)
                        {
                            string      modName = "";
                            int         modLoadingPlace = 0, modPriority = 0;
                            FieldInfo[] fields = attr.GetType().GetFields();

                            foreach (FieldInfo f in fields)
                            {
                                if (f.Name == "modName")
                                {
                                    modName = (string)f.GetValue(attr);
                                }
                                else if (f.Name == "modLoadingPlace")
                                {
                                    modLoadingPlace = (int)f.GetValue(attr);
                                }
                                else if (f.Name == "modPriority")
                                {
                                    modPriority = (int)f.GetValue(attr);
                                }
                            }

                            mowap = new MOWAP()
                            {
                                ModType         = classeDoDll,
                                ModInnitMethod  = mInfo.Name,
                                ModName         = modName,
                                ModLoadingPlace = modLoadingPlace,
                                ModPriority     = modPriority,
                                DllFilePath     = path,
                                Dependencies    = ParseReferences(modAssembly.GetReferencedAssemblies())
                            };
                            break;
                        }
                    }
                    if (mowap.ModInnitMethod == mInfo.Name)
                    {
                        break;
                    }
                }
                if (mowap.ModType == classeDoDll)
                {
                    break;
                }
            }
            return(mowap);
        }