Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Reflection;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using PluginSystem;
- namespace MEAExplorerWV
- {
- public static class Plugins
- {
- public static List<IPlugin> PluginList = new List<IPlugin>();
- public static IPluginHost Host;
- public static void Init()
- {
- try
- {
- Host = new PluginHost();
- if (!Directory.Exists("plugins"))
- return;
- string[] files = Directory.GetFiles("plugins\\", "*.dll", SearchOption.AllDirectories);
- ICollection<Assembly> assemblies = new List<Assembly>();
- foreach (string file in files)
- {
- try
- {
- AssemblyName an = AssemblyName.GetAssemblyName(file);
- Assembly assembly = Assembly.Load(an);
- assemblies.Add(assembly);
- }
- catch { }
- }
- Type pluginType = typeof(IPlugin);
- ICollection<Type> pluginTypes = new List<Type>();
- foreach (Assembly assembly in assemblies)
- if (assembly != null)
- {
- Type[] types = assembly.GetTypes();
- foreach (Type type in types)
- if (type.IsInterface || type.IsAbstract)
- continue;
- else
- if (type.GetInterface(pluginType.FullName) != null)
- pluginTypes.Add(type);
- }
- foreach (Type type in pluginTypes)
- {
- IPlugin plugin = (IPlugin)Activator.CreateInstance(type);
- plugin.Host = Host;
- PluginList.Add(plugin);
- }
- }
- catch (Exception ex)
- {
- Log.WriteLine("Error loading plugins: " + ex.Message);
- Log.WriteLine(ex.StackTrace);
- }
- }
- public class PluginHost : IPluginHost
- {
- public List<string> getTOCFiles()
- {
- List<string> result = new List<string>();
- foreach (FS.TOCEntry toc in FS.TOClist)
- result.Add(toc.filePath);
- return result;
- }
- public List<string> getTOCFileLabels()
- {
- List<string> result = new List<string>();
- foreach (FS.TOCEntry toc in FS.TOClist)
- result.Add(toc.displayName);
- return result;
- }
- public List<string> getBundleNames(string toc)
- {
- return FS.getAllBundleNames(toc);
- }
- public List<DataInfo> getAllEBX(string toc, string bundle)
- {
- return FS.getAllBundleEntries(toc, bundle, "ebx");
- }
- public List<DataInfo> getAllRES(string toc, string bundle)
- {
- return FS.getAllBundleEntries(toc, bundle, "res");
- }
- public List<ChunkInfo> getAllTocCHUNKs(string toc)
- {
- return FS.getAllTocChunks(toc);
- }
- public List<ChunkInfo> getAllBundleCHUNKs(string toc, string bundle)
- {
- return FS.getAllBundleChunks(toc, bundle);
- }
- public byte[] getDataBySha1(byte[] sha1)
- {
- return FS.FindDataBySha1(sha1);
- }
- public int setDataBySha1(byte[] data, byte[] sha1, string toc)
- {
- return FS.SetDataBySha1(data, sha1, toc);
- }
- public void setAutoPatching(bool value)
- {
- FS.autoPatchData = value;
- }
- public void AddModJob(string pname, string desc, byte[] payload)
- {
- Mods.Jobs.Add(new Mods.ModJob(pname, desc, payload));
- }
- public Dictionary<string, string> getEBXGuids()
- {
- return FS.ebxGUIDs;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement