public IMEPlugin() { Config = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); Config.Initialize(PluginInterface); this.InGameIMEFunc = SigScanner.ScanText("40 53 48 83 EC 20 41 C7 00 ?? ?? ?? ??"); this.IsDirectChatFunc = SigScanner.ScanText("40 56 48 83 EC 30 80 79 1C 00"); PluginLog.Log($"===== I M E P L U G I N ====="); PluginLog.Log($"InGameIMEFunc addr:{InGameIMEFunc:X}"); PluginLog.Log($"IsDirectChatFunc addr:{IsDirectChatFunc:X}"); this.InGameIMEFuncHook = new Hook <InGameIMEFuncDelegate>( InGameIMEFunc, new InGameIMEFuncDelegate(InGameIMEFuncDetour) ); this.IsDirectChatFuncHook = new Hook <IsDirectChatFuncDelegate>( IsDirectChatFunc, new IsDirectChatFuncDelegate(IsDirectChatFuncDetour) ); Gui = new PluginUi(this); CommandManager.AddHandler("/imeplugin", new CommandInfo(CommandHandler) { HelpMessage = "/imeplugin - open the IMEPlugin panel." }); this.InGameIMEFuncHook.Enable(); this.IsDirectChatFuncHook.Enable(); }
public PennyPincher() { configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); LoadConfig(); items = Data.GetExcelSheet <Item>(); newRequest = false; PluginInterface.UiBuilder.Draw += DrawWindow; PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi; CommandManager.AddHandler(commandName, new CommandInfo(Command) { HelpMessage = $"Opens the {Name} config menu", }); GameNetwork.NetworkMessage += OnNetworkEvent; try { var ptr = SigScanner.ScanText("E8 ?? ?? ?? ?? 48 85 C0 74 14 83 7B 44 00"); getFilePtr = Marshal.GetDelegateForFunctionPointer <GetFilePointer>(ptr); } catch (Exception e) { getFilePtr = null; PluginLog.LogError(e.ToString()); } }
public void OnMessageReceived(EventType eventType, PluginInterface.Message message) { switch (eventType) { case EventType.ApplicationClosing: case EventType.ApplicationStarted: break; // Here Error property will be null // Only Result will be non-null MessageBox.Show("I received a injection related message: " + message.Result); case EventType.TargetAssemblyLoaded: case EventType.InjectionAssemblyLoaded: break; // Here Error property will be null // Only Result will be non-null with injector/target assembly path MessageBox.Show("I received a injection related message: " + message.Result); case EventType.MethodInjectionStart: case EventType.MethodInjectionComplete: // Here Error property will be null // Expect Target, Injector will be non-null MessageBox.Show("I received a injection related message: " + message.ToString()); break; case EventType.ProcessComplete: case EventType.ProcessStart: // Here Error property will be null // Expect only the Result to be non-null MessageBox.Show("I received a process related message: " + message.Result); break; case EventType.Error: MessageBox.Show("I received an error message: " + message.Error); break; } }
public ChatTranslator() { _configuration = PluginInterface.GetPluginConfig() as Config ?? new Config(); Chat.ChatMessage += Chat_OnChatMessage; PluginInterface.UiBuilder.Draw += TranslatorConfigUi; PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi; CommandManager.AddHandler("/trn", new CommandInfo(Command) { HelpMessage = "Opens the Chat Translator config menu" }); _uiColours = Data.Excel.GetSheet <UIColor>(); _channels = _configuration.Channels; _textColour = _configuration.TextColour; _tranMode = _configuration.TranMode; _languageInt = _configuration.Lang; _whitelist = _configuration.Whitelist; _notSelf = _configuration.NotSelf; _oneChan = _configuration.OneChan; _oneInt = _configuration.OneInt; _chosenLanguages = _configuration.ChosenLanguages; _blacklist = _configuration.Blacklist; Thread t = new Thread(new ThreadStart(ThreadProc)); t.Start(); }
private void SaveConfig() { if (configMin < 1) { Chat.Print("Minimum price must be positive."); configMin = 1; } if (configMod < 1) { Chat.Print("Modulo must be positive."); configMod = 1; } configuration.delta = configDelta; configuration.min = configMin; configuration.mod = configMod; configuration.alwaysOn = configMode == 2; configuration.smart = configMode == 1; configuration.hq = configHq; configuration.verbose = configVerbose; PluginInterface.SavePluginConfig(configuration); }
private void button1_Click(object sender, EventArgs e) { PluginInterface pl = null; plugins.TryGetValue(comboBox1.SelectedItem.ToString(), out pl); List <string> links = null; List <string> chaptersList = null; List <string> selectedChapters = null; if (pl != null) { chaptersList = pl.getChapterList(textBox1.Text); ChapterList fen = new ChapterList(chaptersList); } if (!System.IO.Directory.Exists("Manga")) { System.IO.Directory.CreateDirectory("Manga"); } foreach (string c in selectedChapters) { links = pl.getChapterLink(c); int i = 1; foreach (string link in links) { WebClient w = new WebClient(); w.DownloadFile(link, ("Manga/" + c + i + ".jpg")); i++; } } }
public void Dispose() { this.InGameIMEFuncHook.Disable(); this.IsDirectChatFuncHook.Disable(); CommandManager.RemoveHandler("/imeplugin"); Gui?.Dispose(); PluginInterface?.Dispose(); }
public void Dispose() { this.iconReplacer.Dispose(); CommandManager.RemoveHandler("/pcombo"); PluginInterface.Dispose(); }
public void Dispose() { GameNetwork.NetworkMessage -= OnNetworkEvent; PluginInterface.UiBuilder.Draw -= DrawWindow; PluginInterface.UiBuilder.OpenConfigUi -= OpenConfigUi; CommandManager.RemoveHandler(commandName); PluginInterface.Dispose(); }
public void Dispose() { PluginInterface.UiBuilder.OnBuildUi -= this.BuildUI; FittingRoomUI?.Dispose(); itemSearchWindow?.Dispose(); RemoveCommands(); PluginInterface.Dispose(); }
public void Dispose() { PluginInterface.UiBuilder.OnBuildUi -= SettingsInterface.Draw; PluginInterface.CommandManager.RemoveHandler(CommandName); PluginInterface.Dispose(); ResourceLoader.Dispose(); }
public override void Disable() { if (!Enabled) { return; } Service.Chat.ChatMessage -= OnChatMessage; PluginInterface.RemoveChatLinkHandler((uint)LinkHandlerId.OpenUrlLink); base.Disable(); }
/// <summary> /// Add a plugin instance to this manager. This should be called inside /// PluginEntryPoint subclasses. Doing it this way allows a dll to load /// multiple plugins. /// </summary> /// <param name="plugin">The plugin to add.</param> public void addPlugin(PluginInterface plugin) { Log.Default.sendMessage("Plugin {0} added.", LogLevel.Info, "Engine", plugin.Name); loadedPlugins.Add(plugin); plugin.initialize(this, serviceCollection); if (renamedTypeMap != null) { plugin.setupRenamedSaveableTypes(renamedTypeMap); } }
public void Dispose() { PluginInterface.UiBuilder.OnBuildUi -= this.BuildUI; PluginInterface.UiBuilder.OnBuildFonts -= this.BuildFont; PluginInterface.UiBuilder.OnOpenConfigUi -= this.OnConfigCommandHandler; PluginInterface.Framework.OnUpdateEvent -= this.OnFrameworkUpdate; PluginInterface.UiBuilder.RebuildFonts(); fpsHistoryInterval?.Stop(); RemoveCommands(); PluginInterface.Dispose(); }
private void LoadPlugin(Type type) { var ctor = type.GetConstructor(new Type[0]); if (ctor != null) { PluginInterface plugin = ctor.Invoke(new object[0]) as PluginInterface; plugin.OnLoad(BooruApp.BooruApplication); Booru.BooruApp.BooruApplication.Log.Log(BooruLog.Category.Application, BooruLog.Severity.Info, "Loaded plugin '" + plugin.Name + "'"); LoadedPlugins.Add(plugin); } }
public void Dispose() { PluginInterface.UiBuilder.OnOpenConfigUi -= OnOpenConfigUi; PluginInterface.UiBuilder.OnBuildUi -= this.BuildUI; PluginInterface.Framework.OnUpdateEvent -= FrameworkUpdate; ActionManager?.Dispose(); IconManager?.Dispose(); generalStopwatch.Stop(); OutOfCombatTimer.Stop(); cacheTimer.Stop(); RemoveCommands(); PluginInterface.Dispose(); }
private void LoadConfig() { try { this.Configuration = PluginInterface.GetPluginConfig() as PluginConfig ?? new PluginConfig(); } catch (Exception ex) { Logger.LogError("Failed to load config so creating new one.", ex); this.Configuration = new PluginConfig(); this.SaveConfig(); } }
public void Dispose() { // ModManager?.Dispose(); PluginInterface !.UiBuilder.OnBuildUi -= SettingsInterface !.Draw; PluginInterface.CommandManager.RemoveHandler(CommandName); PluginInterface.Dispose(); ResourceLoader?.Dispose(); ShutdownWebServer(); }
private void SaveConfig() { _configuration.Lang = _languageInt; _configuration.Channels = _channels; _configuration.NotSelf = _notSelf; _configuration.Whitelist = _whitelist; _configuration.ChosenLanguages = _chosenLanguages; _configuration.OneChan = _oneChan; _configuration.OneInt = _oneInt; _configuration.TextColour = _textColour; _configuration.Blacklist = _blacklist; _configuration.TranMode = _tranMode; PluginInterface.SavePluginConfig(_configuration); }
public void Dispose() { PluginInterface.UiBuilder.OnBuildUi -= this.BuildUI; FittingRoomUI?.Dispose(); itemSearchWindow?.Dispose(); RemoveCommands(); PluginInterface.Dispose(); foreach (var t in textureDictionary) { t.Value?.Dispose(); } textureDictionary.Clear(); }
public override void Enable() { if (Enabled) { return; } PluginInterface.CommandManager.AddHandler("/chrdir", new CommandInfo(CommandHandler) { ShowInHelp = true, HelpMessage = "Print your character save directory to chat. '/chrdir open' to open the directory in explorer." }); linkPayload = PluginInterface.AddChatLinkHandler((uint)LinkHandlerId.OpenFolderLink, OpenFolder); Enabled = true; }
//lets reset the forms if plugin where remove private void removeToolStripMenuItem_Click(object sender, EventArgs e) { plugin = null; this.BackColor = SystemColors.Control; this.Font = new Font("MS Sans Serif", 8, FontStyle.Regular); //loop on all forms and reset the style foreach (Form form in Application.OpenForms) { form.BackColor = SystemColors.Control; form.Font = new Font("MS Sans Serif", 8, FontStyle.Regular); } //we forgot to loop on all controls foreach (Control control in this.Controls) { control.Font = new Font("MS Sans Serif", 8, FontStyle.Regular); } }
public static void Load(PluginInterface.logprintf_t logprint, string indent) { LogPrint = logprint; Indent = indent; if (!Directory.Exists(WorkingDir)) Directory.CreateDirectory(WorkingDir); ConvertIncludes(); CompilerParameters parameters = new CompilerParameters(); parameters.GenerateExecutable = false; parameters.GenerateInMemory = false; parameters.ReferencedAssemblies.AddRange(Assembly.GetExecutingAssembly().GetReferencedAssemblies().Select(entry => entry.Name).ToArray()); parameters.WarningLevel = 4; string[] csfiles = Directory.GetFiles(WorkingDir, "*.cs"); LogPrint(Indent + "Loading " + csfiles.Length + " CSharp files..."); foreach (string file in csfiles) { PrepCompilerParameters(file, parameters); //if (csfiles.Length > 0) //{ CSharpCodeProvider csprovider = new CSharpCodeProvider(); //CompilerResults results = csprovider.CompileAssemblyFromFile(parameters, csfiles); CompilerResults results = csprovider.CompileAssemblyFromFile(parameters, file); Parse(results); //} //parameters.ReferencedAssemblies.Add(file); //Hozzáadja az aktuális fájlt a következőhöz, hogy... - Csak a legutolsó kapná meg az összeset } LogPrint(Indent + "Loaded " + csfiles.Length + " CSharp files."); string[] vbfiles = Directory.GetFiles(WorkingDir, "*.vb"); LogPrint(Indent + "Loading " + vbfiles.Length + " VisualBasic files..."); //if (vbfiles.Length > 0) foreach (string file in vbfiles) { PrepCompilerParameters(file, parameters); VBCodeProvider vbprovider = new VBCodeProvider(); CompilerResults results = vbprovider.CompileAssemblyFromFile(parameters, vbfiles); Parse(results); } LogPrint(Indent + "Loaded " + vbfiles.Length + " VisualBasic files."); }
public bool AboutKingFisher() { Assembly assembly = Assembly.LoadFile(WanTai.Common.Configuration.GetThermoPluginPath() + @"Plugins\MibAiPlugin.dll"); PluginInterface AI = (PluginInterface)assembly.CreateInstance("MibAi.Plugins.BindItPlugin", true, BindingFlags.CreateInstance, null, null, CultureInfo.CurrentCulture, null); string userName = WanTai.Common.Configuration.GetThermoUsername(); string password = WanTai.Common.Configuration.GetThermoPassword(); bool result = AI.Login(userName, password); if (!result) { throw new Exception("Login KingFisher failed"); } result = AI.Connect(WanTai.Common.Configuration.GetThermoInstrumentName()); //if (!result) //{ // throw new Exception("Connect to KingFisher failed"); //} int state = 0; int error = 0; int currentStep = 0; string currentSessionName = ""; result = AI.GetAIServerStatus(ref state, ref error, ref currentSessionName, ref currentStep); if ((EngineState)state == EngineState.Executing) { result = AI.Abort(); if (!result) { return(false); } } result = AI.Disconnect(); if (!result) { throw new Exception("Disconnect from KingFisher failed"); } return(true); }
public void LoadConfig(bool clearConfig = false) { try { if (clearConfig) { this.PluginConfig = new RemindMeConfig(); } else { this.PluginConfig = (RemindMeConfig)PluginInterface.GetPluginConfig() ?? new RemindMeConfig(); } this.PluginConfig.Init(this, PluginInterface); } catch (Exception ex) { PluginLog.LogError("Failed to load config."); PluginLog.LogError(ex.ToString()); PluginConfig = new RemindMeConfig(); PluginConfig.Init(this, PluginInterface); configLoadException = ex; } }
/// <summary> /// Dispose plugin. /// </summary> public void Dispose() { try { ClientState.Login -= this.Login; this.XivCommon.Dispose(); this.WindowManager.Dispose(); PluginCommandManager.Dispose(); this.ContextMenuManager.Dispose(); this.HoveredItemManager.Dispose(); this.ItemCancellationTokenSource?.Dispose(); this.UniversalisClient.Dispose(); this.localization.Dispose(); } catch (Exception ex) { Logger.LogError(ex, "Failed to dispose plugin properly."); } PluginInterface.Dispose(); GC.SuppressFinalize(this); }
public XIVComboPlugin() { CommandManager.AddHandler("/pcombo", new CommandInfo(OnCommandDebugCombo) { HelpMessage = "Open a window to edit custom combo settings.", ShowInHelp = true }); this.Configuration = PluginInterface.GetPluginConfig() as XIVComboConfiguration ?? new XIVComboConfiguration(); if (Configuration.Version < 3) { Configuration.HiddenActions = new List <bool>(); for (var i = 0; i < Enum.GetValues(typeof(CustomComboPreset)).Length; i++) { Configuration.HiddenActions.Add(false); } Configuration.Version = 3; } this.iconReplacer = new IconReplacer(TargetModuleScanner, ClientState, this.Configuration); this.iconReplacer.Enable(); PluginInterface.UiBuilder.OpenConfigUi += () => isImguiComboSetupOpen = true; PluginInterface.UiBuilder.Draw += UiBuilder_OnBuildUi; /* * pluginInterface.Subscribe("PingPlugin", e => { * dynamic msg = e; * iconReplacer.UpdatePing(msg.LastRTT / 2); * PluginLog.Log("Ping was updated to {0} ms", msg.LastRTT / 2); * }); */ var values = Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>(); orderedByClassJob = values.Where(x => x != CustomComboPreset.None && x.GetAttribute <CustomComboInfoAttribute>() != null).OrderBy(x => x.GetAttribute <CustomComboInfoAttribute>().ClassJob).ToArray(); UpdateConfig(); }
/// <summary> /// Protected implementation of Dispose pattern. /// </summary> /// <param name="disposing">A value indicating whether we are disposing.</param> protected virtual void Dispose(bool disposing) { if (this.isDisposed) { return; } if (disposing) { // Save config PluginInterface.SavePluginConfig(this.config); // Remove command handlers PluginInterface.UiBuilder.Draw -= this.BuildMarketBoardUi; CommandManager.RemoveHandler("/pmb"); this.marketBoardWindow.Dispose(); // Remove context menu handler this.contextMenuBase.Functions.ContextMenu.OnOpenInventoryContextMenu -= this.OnContextMenuOpened; this.contextMenuBase.Dispose(); } this.isDisposed = true; }
//load the dll private void loadToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.FileName = String.Empty; openFileDialog1.Filter = "DLL files (*.dll)|"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { //load the dll Assembly pluginFile = Assembly.LoadFile(openFileDialog1.FileName); //filter out the dll foreach (Type type in pluginFile.GetExportedTypes()) { //make sure that the right plugin will be loaded if (type.IsClass && type.GetInterface("PluginInterface") != null) { //create an instance of the plugin plugin = Activator.CreateInstance(type) as PluginInterface; //apply the style on our host plugin.ChangeStyle(this); //lastly apply also the style on the opened forms foreach (Form form in Application.OpenForms) { plugin.ChangeStyle(form); } } else { MessageBox.Show("Wrong plugin!"); } } } //lets apply the style on all form }
/// <summary> /// Initializes a new instance of the <see cref="MBPlugin"/> class. /// This is the plugin's entry point. /// </summary> public MBPlugin() { this.config = (MBPluginConfig)PluginInterface.GetPluginConfig() ?? new MBPluginConfig(); this.marketBoardWindow = new MarketBoardWindow(this.config); // Set up command handlers CommandManager.AddHandler("/pmb", new CommandInfo(this.OnOpenMarketBoardCommand) { HelpMessage = "Open the market board window.", }); PluginInterface.UiBuilder.Draw += this.BuildMarketBoardUi; // Set up context menu this.contextMenuBase = new DalamudContextMenuBase(); this.inventoryContextMenuItem = new InventoryContextMenuItem( new SeString(new TextPayload("Search with Market Board Plugin")), this.OnSelectContextMenuItem); this.contextMenuBase.Functions.ContextMenu.OnOpenInventoryContextMenu += this.OnContextMenuOpened; #if DEBUG this.marketBoardWindow.IsOpen = true; #endif }
/// <summary> /// Initializes a new instance of the <see cref="PlayerTrackPlugin"/> class. /// </summary> public PlayerTrackPlugin() { Task.Run(() => { try { // setup common libs this.localization = new Localization(PluginInterface, CommandManager); this.BackupManager = new BackupManager(PluginInterface.GetPluginConfigDirectory()); this.XivCommon = new XivCommonBase(Hooks.NamePlates); // load config try { this.Configuration = PluginInterface.GetPluginConfig() as PlayerTrackConfig ?? new PlayerTrackConfig(); } catch (Exception ex) { Logger.LogError("Failed to load config so creating new one.", ex); this.Configuration = new PlayerTrackConfig(); this.SaveConfig(); } // setup services this.BaseRepository = new BaseRepository(GetPluginFolder()); this.LodestoneService = new LodestoneService(this); this.ActorManager = new ActorManager(this); this.CategoryService = new CategoryService(this); this.EncounterService = new EncounterService(this); this.PlayerService = new PlayerService(this); this.VisibilityService = new VisibilityService(this); this.FCNameColorService = new FCNameColorService(this); this.PlayerTrackProvider = new PlayerTrackProvider(PluginInterface, new PlayerTrackAPI(this)); this.WindowManager = new WindowManager(this); this.PluginCommandManager = new PluginCommandManager(this); this.NamePlateManager = new NamePlateManager(this); // run backup this.backupTimer = new Timer { Interval = this.Configuration.BackupFrequency, Enabled = false }; this.backupTimer.Elapsed += this.BackupTimerOnElapsed; var pluginVersion = Assembly.GetExecutingAssembly().VersionNumber(); if (this.Configuration.PluginVersion < pluginVersion) { Logger.LogInfo("Running backup since new version detected."); this.RunUpgradeBackup(); this.Configuration.PluginVersion = pluginVersion; this.SaveConfig(); } else { this.BackupTimerOnElapsed(this, null); } // migrate if needed var success = Migrator.Migrate(this); if (success) { // special handling for fresh install this.HandleFreshInstall(); // reset categories if failed to load if (this.CategoryService.GetCategories().Length == 0) { this.CategoryService.ResetCategories(); } // start plugin this.IsDoneLoading = true; this.backupTimer.Enabled = true; this.VisibilityService.Start(); this.FCNameColorService.Start(); this.ActorManager.Start(); this.WindowManager.AddWindows(); } } catch (Exception ex) { Logger.LogError(ex, "Failed to initialize plugin."); } }); }
public void push(PluginInterface plugin) { container.Add(plugin.Name, plugin); }
public void Startup(ushort maxConnections, int threadSleepTimer, ushort port, PluginInterface[] plugins) { rakPeerInterface = RakNetworkFactory.GetRakPeerInterface(); foreach (PluginInterface plugin in plugins) { RakPeerInterface.AttachPlugin(plugin); } // Initialize the peer SocketDescriptor socketDescriptor = new SocketDescriptor(port, string.Empty); RakPeerInterface.Startup(maxConnections, threadSleepTimer, new SocketDescriptor[] {socketDescriptor}, 1); RakPeerInterface.SetMaximumIncomingConnections(maxConnections); binder = new RpcBinder(RakPeerInterface, registry, processorLocator.Processor); binder.Bind(); }
public ICollection <PluginInterface> loadPlugins(string path) { string[] dllFilenames = null; if (System.IO.Directory.Exists(path)) { dllFilenames = System.IO.Directory.GetFiles(path, "*.dll"); ICollection <System.Reflection.Assembly> assemblies = new List <System.Reflection.Assembly>(dllFilenames.Length); foreach (string dllfilename in dllFilenames) { System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(dllfilename); System.Reflection.Assembly assembly = System.Reflection.Assembly.Load(an); assemblies.Add(assembly); } Type pluginType = typeof(PluginInterface); ICollection <Type> pluginTypes = new List <Type>(); foreach (System.Reflection.Assembly assembly in assemblies) { if (assembly != null) { Type[] types = null; try { types = assembly.GetTypes(); } catch (System.Reflection.ReflectionTypeLoadException e) { types = e.Types; } foreach (Type type in types) { if (type != null) { if (type.IsInterface || type.IsAbstract) { continue; } else { if (type.GetInterface(pluginType.FullName) != null) { pluginTypes.Add(type); } } } } } } ICollection <PluginInterface> plugins = new List <PluginInterface>(pluginTypes.Count); foreach (Type type in pluginTypes) { PluginInterface plugin = (PluginInterface)Activator.CreateInstance(type); plugins.Add(plugin); } return(plugins); } return(null); }