public List <FomodFile> GetFilesToInstall(List <string> ModOptionNames, bool ignoreMissing = false) { List <FomodFile> filesToInstall = new List <FomodFile>(); Dictionary <string, string> flags = new Dictionary <string, string>(); if (ModOptionNames.Contains("Base FOMOD Files")) { filesToInstall.AddRange(BaseFiles); } foreach (string name in ModOptionNames) { FomodPlugin foundPlugin = Plugins.Find(p => p.Name.Equals(name)); if (foundPlugin != null) { filesToInstall.AddRange(foundPlugin.Files); foundPlugin.Flags.ForEach(f => flags[f.Name] = f.Value); } else { if (!ignoreMissing) { throw new Exception("Mod Option " + name + " not found."); } } } foreach (FomodPattern pattern in GetSatisfiedPatterns(flags)) { filesToInstall.AddRange(pattern.Files); } return(filesToInstall); }
public void Plugins_Load(PluginConfiguration config) { if (Plugins != null) { if (!enabledPlugins.Contains(config)) { IClientPlugin plugin = Plugins.Find(x => x.Title.ToUpper() == config.Name.ToUpper()); if (plugin != null) { try { plugin.SubCategories = config.SubCategories; plugin.SendData += Plugin_SendData; plugin.Initialize(); } catch { } var bt = new ListButton(); if (plugin.Image != null) { bt.Image = new BitmapImage(plugin.Image); } bt.Text = plugin.Title; bt.Selected += PageSelected; bt.DataObject = plugin; Pages.Add(bt); SortPageList(); enabledPlugins.Add(config); } } } }
/// <summary> /// Add the 'sub' plugins to the PluginConfiguration /// </summary> /// <param name="config"></param> private void Plugin_LoadSubPlugins(PluginConfiguration config) { var plugin = Plugins.Find(x => x.Title == config.Name && x.ParentPlugin == config.Parent && x.ParentPluginCategory == config.Category ); if (plugin != null) { plugin.Plugins = new List <IClientPlugin>(); if (config.SubCategories != null) { foreach (PluginConfigurationCategory subcategory in config.SubCategories) { foreach (PluginConfiguration subConfig in subcategory.PluginConfigurations) { var subplugin = Plugins.Find(x => x.Title == subConfig.Name && x.ParentPlugin == subConfig.Parent && x.ParentPluginCategory == subConfig.Category ); if (subplugin != null) { Plugin_LoadSubPlugins(subConfig); plugin.Plugins.Add(subplugin); } } } } } }
public static void LoadDisabledPluginsList() { for (int i = 0, cnt = Plugins.Count; i < cnt; i++) { Plugins[i].Active = true; } try { using (var r = new StreamReader(File.OpenRead("disabled_plugins.dat"))) { while (!r.EndOfStream) { try { var line = r.ReadLine().Split(null); //MessageBox.Show(string.Join("\n", line)); var field = line[0]; var pname = line[1]; var cname = line[2]; var p = Plugins.Find((t) => t.Field == field && t.AssemblyName == pname && t.ClassName == cname); if (p != null) { p.Active = false; } } catch { } } } } catch { } }
private void TableManager_Clicked(TrakHound_UI.Button bt) { var plugin = Plugins.Find(x => x.Title == "Table Manager"); if (plugin != null) { AddTab(plugin); } NavigationMenu_Hide(); }
private void Dashboard_Clicked(TrakHound_UI.Button bt) { var plugin = Plugins.Find(x => x.Title == "Dashboard"); if (plugin != null) { AddTab(plugin); } NavigationMenu_Hide(); }
static UFPlugin GetNextPlugin(UFPlugin origin) { var next = Plugins.Find(origin).Next; if (next != null) { var value = next.Value; return(value.Results.Count == 0 ? GetNextPlugin(value) : value); } return(null); }
static UFPlugin GetPreviousPlugin(UFPlugin origin) { var previous = Plugins.Find(origin).Previous; if (previous != null) { var value = previous.Value; return(value.Results.Count == 0 ? GetPreviousPlugin(value) : value); } return(null); }
/// <summary> /// Load Plugin if Enabled /// </summary> /// <param name="config"></param> public void Plugin_Load(PluginConfiguration config) { ///Check if Enabled if (config.Enabled) { var plugin = Plugins.Find(x => x.Title == config.Name && x.ParentPlugin == config.Parent && x.ParentPluginCategory == config.Category ); if (plugin != null) { try { // Assign event handlers plugin.SendData += Plugin_SendData; // Process SubPlugins plugin.SubCategories = config.SubCategories; Plugin_LoadSubPlugins(config); // Initialize plugin plugin.Initialize(); // If set to OpenOnStartUp then Open new Tab if (plugin.OpenOnStartUp) { AddTab(plugin); } // Create an Options page (if exists) Plugin_CreateOptionsPage(plugin); } catch (Exception ex) { var mData = new Controls.Message_Center.MessageData(); mData.Title = "Plugin Error"; mData.Text = "Error during plugin load"; mData.AdditionalInfo = ex.Message; mData.Type = TrakHound.API.Messages.MessageType.TRAKHOUND_ALERT; messageCenter.AddMessage(mData); } } } }
private void InitialisePlugin(string target) { var plugin = Plugin.FromFile(target, true); try { plugin.Init(this); } catch (InvalidCastException e) { // this happens if the assembly with the exact same version is loaded // AND the Init process tries to use types defined in its assembly throw new PluginAlreadyLoadedException("Failed to init plugin as its already loaded", e); } IPlugin pi = Plugins.Find(p => p.Filename == plugin.Filename); if (pi != null) { Plugins.Remove(pi); //we were updating } Plugins.Add(plugin); }
void AddSubPlugins(IClientPlugin plugin) { plugin.Plugins = new List <IClientPlugin>(); if (plugin.SubCategories != null) { foreach (PluginConfigurationCategory subcategory in plugin.SubCategories) { foreach (PluginConfiguration subConfig in subcategory.PluginConfigurations) { IClientPlugin cplugin = Plugins.Find(x => x.Title.ToUpper() == subConfig.Name.ToUpper()); if (cplugin != null) { plugin.Plugins.Add(cplugin); } } } } }
/// <summary> /// 插件全部卸载 /// </summary> public void UnLoad() { Loading = true; LogHelper.WriteLog("开始卸载插件..."); CallFunction(FunctionEnums.Functions.Exit); CallFunction(FunctionEnums.Functions.Disable); NotifyIconHelper.ClearAppMenu(); foreach (var item in AppDomainSave) { var c = Plugins.Find(x => x.iLib == item.Key); UnLoad(c); AppDomain.Unload(item.Value); } Plugins.Clear(); AppDomainSave.Clear(); GC.Collect(); Loading = false; LogHelper.WriteLog("插件卸载完毕"); }
/// <summary> /// Plugin has sent a DataEvent_Data object to other plugins /// </summary> /// <param name="de_d"></param> private void Plugin_SendData(EventData data) { foreach (var config in PluginConfigurations) { if (config.Enabled) { var plugin = Plugins.Find(x => x.Title == config.Name && x.ParentPlugin == config.Parent && x.ParentPluginCategory == config.Category ); if (plugin != null && plugin != data.Sender) { var sendDataInfo = new SendDataInfo(plugin, data); ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessSendData), sendDataInfo); } } } SendEventData(data); }
/// <summary> /// 根据插件名称获取插件 /// </summary> /// <param name="pluginName">插件名称</param> /// <returns></returns> public IPlug_Lrc BaseOnNameGetPlugin(string pluginName) { return(Plugins.Find(x => x.PlugInfo.PlugName.Equals(pluginName))); }
public T GetPlugin <T>(Guid guid) where T : IPlugin { return((T)Plugins.Find(plugin => plugin.Guid == guid)); }
public IPlugin GetPlugin(Guid guid) { return(Plugins.Find(plugin => plugin.Guid == guid)); }