public void addRawImage(string name, CuiRectTransformComponent rectangle, string imgData, string parent = "Hud", GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0) { if (string.IsNullOrEmpty(name)) { name = "image"; } else { name = PluginInstance.encodeName(this, name); } purgeDuplicates(name); this.Add(new CuiElement { Parent = PluginInstance.encodeName(this, parent), Name = name, Components = { new CuiRawImageComponent { Color = (panelColor != null)?panelColor.getColorString():"1 1 1 1", FadeIn = FadeIn, Png = imgData }, rectangle }, FadeOut = FadeOut }); }
public void addPlainPanel(string name, CuiRectTransformComponent rectangle, string parent = "Hud", GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, bool blur = false) { if (string.IsNullOrEmpty(name)) { name = "plainPanel"; } else { name = PluginInstance.encodeName(this, name); } purgeDuplicates(name); this.Add(new CuiElement { Parent = PluginInstance.encodeName(this, parent), Name = name, Components = { new CuiImageComponent { Color = (panelColor != null)?panelColor.getColorString():"0 0 0 0", FadeIn = FadeIn, Material = blur?"assets/content/ui/uibackgroundblur-ingamemenu.mat":"Assets/Icons/IconMaterial.mat" }, rectangle }, FadeOut = FadeOut }); }
public void addText(string name, CuiRectTransformComponent rectangle, GuiText text = null, float FadeIn = 0, float FadeOut = 0, string parent = "Hud") { if (string.IsNullOrEmpty(name)) { name = "text"; } else { name = PluginInstance.encodeName(this, name); } purgeDuplicates(name); text.FadeIn = FadeIn; this.Add(new CuiElement { Parent = PluginInstance.encodeName(this, parent), Name = name, Components = { text, rectangle }, FadeOut = FadeOut }); }
public void addPanel(string name, CuiRectTransformComponent rectangle, string parent = "Hud", GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, string imgName = null, bool blur = false) { if (string.IsNullOrEmpty(name)) { name = "panel"; } else { name = PluginInstance.encodeName(this, name); } purgeDuplicates(name); if (string.IsNullOrEmpty(imgName)) { addPlainPanel(PluginInstance.decodeName(this, name), rectangle, parent, panelColor, FadeIn, FadeOut, blur); } else { this.addImage(PluginInstance.decodeName(this, name), rectangle, imgName, parent, panelColor, FadeIn, FadeOut); } if (text != null) { this.addText(PluginInstance.decodeName(this, name) + "_txt", new Rectangle(), text, FadeIn, FadeOut, PluginInstance.decodeName(this, name)); } }
public ServiceSettingsView(PluginInstance servicePlugin) { this.servicePlugin = servicePlugin; service = servicePlugin.Service; authenticatable = service.AsAuthenticatable(); InitializeComponent(); if (authenticatable == null) { authPanel.Visible = false; } else { UpdateViews(); } try { var control = service.GetSettingsControl(); control.Dock = DockStyle.Fill; servicePanel.Controls.Add(control); } catch (Exception ex) { Log.WriteException(Level.Error, Lag, ex, "service.GetSettingsControl()"); var text = "An error occurred while trying to display the service's settings panel.\n\n" + ex; var label = new Label { AutoSize = false, Dock = DockStyle.Fill, Padding = new Padding(10), Text = text }; servicePanel.Controls.Add(label); } }
/// <summary> /// </summary> /// <param name="assemblyPath"></param> private void VerifyPlugin(string assemblyPath) { try { var bytes = File.ReadAllBytes(assemblyPath); var pAssembly = Assembly.Load(bytes); var pType = pAssembly.GetType(pAssembly.GetName() .Name + ".Plugin"); var implementsIPlugin = typeof(IPlugin).IsAssignableFrom(pType); if (!implementsIPlugin) { Logging.Log(Logger, String.Format("*IPlugin Not Implemented* :: {0}", pAssembly.GetName() .Name)); return; } var plugin = new PluginInstance { Instance = (IPlugin)Activator.CreateInstance(pType), AssemblyPath = assemblyPath }; plugin.Instance.Initialize(Instance); Loaded.Add(plugin); } catch (Exception ex) { } }
protected async Task GetPresetsUsingFullBank(PresetBank bank, int start, int numPresets, string sourceFile) { if (start < 0) { Logger.Error("GetPresets start index is less than 0, ignoring. This is probably a bug or a " + "misconfiguration. Please report this including the full log file."); return; } var endIndex = start + numPresets; if (endIndex > PluginInstance.Plugin.PluginInfo.ProgramCount) { Logger.Error( $"Tried to retrieve presets between the index {start} and {endIndex}, but this would exceed maximum " + $"program count of {PluginInstance.Plugin.PluginInfo.ProgramCount}, ignoring. You might wish to " + "report this as a bug."); return; } for (var index = start; index < endIndex; index++) { PluginInstance.SetProgram(index); var preset = new PresetParserMetadata { PresetName = PluginInstance.GetCurrentProgramName(), BankPath = bank.BankPath, SourceFile = sourceFile + ":" + index, Plugin = PluginInstance.Plugin }; await DataPersistence.PersistPreset(preset, PluginInstance.GetChunk(false)); } }
public void deliver() { StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); foreach (ulong id in Conversation.Participants) { Profile profile = ProfileData.getProfile(id); BasePlayer player = profile.Player; if (player == Sender) { continue; } player.ChatMessage(string.Format(PluginInstance.lang.GetMessage(msg.message.ToString(), PluginInstance), SenderName, Content)); profile.lastConversation = Conversation.ID; sb1.Append($" {player.displayName}[{player.userID}]"); sb2.Append($"\n{player.displayName}({profile.Status})"); } string logEntry = $"{DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")} {SenderName}[{SenderID}] -> [{sb1.ToString().Trim()}]: \"{Content}\""; PluginInstance.Puts(logEntry); PluginInstance.LogToFile("Messages", logEntry, PluginInstance); PluginInstance.PrintToChat(Sender, PluginInstance.lang.GetMessage(msg.messageSent.ToString(), PluginInstance, Sender.UserIDString), Content, sb2); //Sender.ChatMessage($"Message: {Content} \ndelivered to {sb2}"); }
public static GuiImage GetNewGuiImage(Plugin plugin, string name, Rectangle rectangle, string imgNameOrData, bool raw = false, GuiElement parent = null, Layer layer = Layer.hud, GuiColor panelColor = null, float fadeIn = 0, float fadeOut = 0) { Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } return(new GuiImage { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], Color = panelColor, FadeOut = fadeOut, Components = { new CuiRawImageComponent { Color = panelColor?.getColorString() ?? "1 1 1 1", FadeIn = fadeIn, Png = raw?imgNameOrData:PluginInstance.getImageData(plugin, imgNameOrData) }, rectangle.WithParent(parent?.Rectangle) } }); }
private void LoadPluginInformation(PluginInstance pluginInstance) { lblPlaceholder.Visible = pluginInstance == null; if (pluginInstance != null) { lblPluginFilename.Text = string.Format("{0}...{1}{2}{1}{3}", Path.GetPathRoot(pluginInstance.FileInfo.FullName), Path.DirectorySeparatorChar, Path.GetFileName(Path.GetDirectoryName(pluginInstance.FileInfo.FullName)), pluginInstance.FileInfo.Name); lblPluginAuthor.Text = pluginInstance.Plugin.Author ?? Resources.NotAvailableAbbreviation; lblPluginVersion.Text = pluginInstance.Plugin.Version != null ? pluginInstance.Plugin.Version.ToString() : Resources.NotAvailableAbbreviation; lblPluginDescription.Text = pluginInstance.Plugin.Description ?? Resources.NotAvailableAbbreviation; lblPluginHomepage.Tag = pluginInstance.Plugin.Website.DnsSafeHost; if (pluginInstance.Plugin.Website != null) { lblPluginHomepage.Text = pluginInstance.Plugin.Website.DnsSafeHost; lblPluginHomepage.LinkArea = new LinkArea(0, lblPluginHomepage.Text.Length); } else { lblPluginHomepage.Text = Resources.NotAvailableAbbreviation; lblPluginHomepage.LinkArea = new LinkArea(0, 0); } } }
public static void EnsureAppDomainInitialized(PluginFileInfo pluginFileInfo) { var pluginInfoName = pluginFileInfo.Name; if (_initialized) { return; } lock (PluginInitLocker) { if (_initialized) { return; } Logger.Info($"current mahua platform :{MahuaGlobal.CurrentPlatform:G}"); Logger.Debug(pluginFileInfo.ToString()); Logger.Debug($"plugin name is {pluginInfoName}"); IPluginLoader loader = new PluginLoader(); Logger.Debug($"loading plugin {pluginInfoName}"); loader.LoadPlugin(pluginFileInfo.PluginEntryPointDllFullFilename); var pluginInstance = new PluginInstance { PluginLoader = loader, PluginFileInfo = pluginFileInfo, }; _instance = pluginInstance; _initialized = true; } }
public ServiceSettingsView(PluginInstance servicePlugin) { this.servicePlugin = servicePlugin; service = servicePlugin.Service; authenticatable = service.AsAuthenticatable(); if (authenticatable == null) { throw new ArgumentException("Service instance passed must implement IAuthenticatable", nameof(service)); } InitializeComponent(); sspSignInStatus = new SplitStringParser(signInStatusLabel); sspSignInButton = new SplitStringParser(signInButton); if (authenticatable.IsAuthenticated) { signInStatusLabel.Text = String.Format(sspSignInStatus.Get(authenticatable.IsAuthenticated), LocalisableAccountNameFormat.GetFormattedName(authenticatable.Account)); } else { sspSignInStatus.Update(false); } sspSignInButton.Update(authenticatable.IsAuthenticated); var control = service.GetSettingsControl(); control.Dock = DockStyle.Fill; servicePanel.Controls.Add(control); }
public void RefreshChunks() { var bankChunk = PluginInstance.GetChunk(false); if (!(bankChunk is null)) { ChunkBankMemoryStream.SetLength(0); ChunkBankMemoryStream.Write(bankChunk, 0, bankChunk.Length); ChunkBankHash = HashUtils.getIxxHash(bankChunk); BankChunkChanged?.Invoke(this, EventArgs.Empty); } var presetChunk = PluginInstance.GetChunk(true); if (!(presetChunk is null)) { ChunkPresetMemoryStream.SetLength(0); ChunkPresetMemoryStream.Write(presetChunk, 0, presetChunk.Length); ChunkPresetHash = HashUtils.getIxxHash(presetChunk); PresetChunkChanged?.Invoke(this, EventArgs.Empty); } }
public static string GetSearchEngineIdentifier(PluginInstance pluginInstance, ITablatureSearchEngine engine) { if (string.IsNullOrEmpty(engine.Name)) return null; return string.Format("{0}:{1}", pluginInstance.Plugin.Guid, engine.Name); }
public string GetDetailedDescription() { var loadStyle = PluginInstance != null ? $"Instance based: {PluginInstance.GetType().AssemblyQualifiedName}" : $"Assembly path based: {PluginAssemblyPath}"; var entryPointStyle = EntryPoints != null ? "Explicit entry-point based" : ProjectGraph != null ? "Static graph based" : "Visual Studio Workaround based"; var entryPoints = EntryPoints != null ? string.Join( "\n", EntryPoints.Select(e => $"{e.ProjectFile} {{{FormatGlobalProperties(e.GlobalProperties)}}}")) : ProjectGraph != null ? string.Join( "\n", ProjectGraph !.EntryPointNodes.Select( n => $"{n.ProjectInstance.FullPath} {{{FormatGlobalProperties(n.ProjectInstance.GlobalProperties)}}}")) : "Solution file"; return($"{loadStyle}\nEntry-point style: {entryPointStyle}\nEntry-points:\n{entryPoints}");
public ServiceSettingsWindow(PluginInstance instance) { InitializeComponent(); this.instance = instance; Title = $"{instance.Info.Name} settings"; FormsHost.Child = instance.Service.GetSettingsControl(); }
private void SendPlayerUI(BasePlayer player, UIState uiState) { var cuiElements = new CuiElementContainer { { new CuiButton { Text = { Text = PluginInstance.GetMessage(player.IPlayer, uiState == UIState.AddLock ? "UI.AddCodeLock" : "UI.RemoveCodeLock"), Color = Settings.ButtonTextColor, Align = TextAnchor.MiddleCenter, FadeIn = 0.25f }, Button = { Color = uiState == UIState.AddLock ? Settings.AddButtonColor : Settings.RemoveButtonColor, Command = uiState == UIState.AddLock ? "carcodelock.ui.deploy" : "carcodelock.ui.remove" }, RectTransform = { AnchorMin = Settings.AnchorMin, AnchorMax = Settings.AnchorMax, OffsetMin = Settings.OffsetMin, OffsetMax = Settings.OffsetMax } }, "Hud.Menu", CodeLockUIName } }; CuiHelper.AddUi(player, cuiElements); PlayerUIStates.Add(player, uiState); }
/// <summary> /// </summary> /// <param name="pluginName"></param> /// <param name="popupContent"></param> public void PopupMessage(string pluginName, PopupContent popupContent) { if (popupContent == null) { return; } PluginInstance pluginInstance = App.Plugins.Loaded.Find(popupContent.PluginName); if (pluginInstance == null) { return; } var title = $"[{pluginName}] {popupContent.Title}"; var message = popupContent.Message; Action cancelAction = null; if (popupContent.CanCancel) { cancelAction = delegate { pluginInstance.Instance.PopupResult = false; }; } MessageBoxHelper.ShowMessageAsync( title, message, delegate { pluginInstance.Instance.PopupResult = true; }, cancelAction); }
/// <summary> /// </summary> /// <param name="assemblyPath"></param> private void VerifyPlugin(string assemblyPath) { try { byte[] bytes = File.ReadAllBytes(assemblyPath); Assembly pAssembly = Assembly.Load(bytes); Type pType = pAssembly.GetType(pAssembly.GetName().Name + ".Plugin"); var implementsIPlugin = typeof(IPlugin).IsAssignableFrom(pType); if (!implementsIPlugin) { Logging.Log(Logger, $"*IPlugin Not Implemented* :: {pAssembly.GetName().Name}"); return; } var plugin = new PluginInstance { Instance = (IPlugin)Activator.CreateInstance(pType), AssemblyPath = assemblyPath }; plugin.Instance.Initialize(Instance); plugin.Loaded = true; this.Loaded.Add(plugin); } catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } }
public static void LoadPluginTabItem(PluginInstance pluginInstance) { try { if (!pluginInstance.Loaded) { return; } var pluginName = pluginInstance.Instance.FriendlyName; if (SettingsViewModel.Instance.HomePluginList.Any(p => p.ToUpperInvariant().StartsWith(pluginName.ToUpperInvariant()))) { pluginName = $"{pluginName}[{new Random().Next(1000, 9999)}]"; } SettingsViewModel.Instance.HomePluginList.Add(pluginName); TabItem tabItem = pluginInstance.Instance.CreateTab(); tabItem.Name = Regex.Replace(pluginInstance.Instance.Name, @"[^A-Za-z]", string.Empty); var iconfile = Path.Combine(Path.GetDirectoryName(pluginInstance.AssemblyPath), pluginInstance.Instance.Icon); var icon = File.Exists(iconfile) ? new Bitmap(iconfile) : Theme.DefaultPluginLogo; tabItem.Header = ImageHeader(icon, pluginInstance.Instance.FriendlyName); AppViewModel.Instance.PluginTabItems.Add(tabItem); } catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } }
void TryGetNewPet(BaseNPC npcPet) { var OwnedNpc = npcPet.GetComponent <NpcAI>(); if (OwnedNpc != null && OwnedNpc.owner != this) { owner.ChatMessage(NoOwn); return; } if (NextTimeToControl >= Time.realtimeSinceStartup) { owner.ChatMessage(ReloadMsg); return; } if (UsePermission && !PluginInstance.HasPermission(owner, "can" + npcPet.mdlPrefab.Get().name.Replace("_skin", ""))) { owner.ChatMessage(NoPermPetMsg); return; } NextTimeToControl = Time.realtimeSinceStartup + ReloadControl; npc = npcPet.gameObject.AddComponent <NpcAI>(); npc.owner = this; owner.ChatMessage(NewPetMsg); }
/// <summary>Toggle the enabled status of plugin <paramref name="pluginInstance" /></summary> /// <param name="pluginInstance">The plugin to enable or disable</param> /// <returns></returns> private async Task PluginEnableDisableAsync(PluginInstance pluginInstance) { if (_ignoreEnabledChanged) { _ignoreEnabledChanged = false; return; } if (pluginInstance.Metadata.Enabled) { return; } if (pluginInstance.Status != PluginStatus.Stopped) { if (await PromptUserConfirmationAsync($"{pluginInstance.Metadata.DisplayName} will be stopped. Continue ?").ConfigureAwait(true) == false) { _ignoreEnabledChanged = true; pluginInstance.Metadata.Enabled = true; return; } await PluginMgr.StopPlugin(pluginInstance).ConfigureAwait(true); } pluginInstance.Metadata.Enabled = false; }
public static void LoadPluginTabItem(PluginInstance pluginInstance) { try { if (!pluginInstance.Loaded) { return; } var pluginName = pluginInstance.Instance.FriendlyName; if (SettingsViewModel.Instance.HomePluginList.Any(p => p.ToUpperInvariant() .StartsWith(pluginName.ToUpperInvariant()))) { pluginName = String.Format("{0}[{1}]", pluginName, new Random().Next(1000, 9999)); } SettingsViewModel.Instance.HomePluginList.Add(pluginName); var tabItem = pluginInstance.Instance.CreateTab(); tabItem.Name = Regex.Replace(pluginInstance.Instance.Name, @"[^A-Za-z]", ""); var iconfile = String.Format("{0}\\{1}", Path.GetDirectoryName(pluginInstance.AssemblyPath), pluginInstance.Instance.Icon); var icon = new BitmapImage(new Uri(Common.Constants.DefaultIcon)); icon = File.Exists(iconfile) ? ImageUtilities.LoadImageFromStream(iconfile) : icon; tabItem.HeaderTemplate = ImageHeader(icon, pluginInstance.Instance.FriendlyName); AppViewModel.Instance.PluginTabItems.Add(tabItem); } catch (Exception ex) { } }
public void destroyGui(Plugin plugin, GuiContainer container, string name = null) { if (container == null) { return; } if (name == null) { List <GuiContainer> garbage = new List <GuiContainer>(); destroyGuiContainer(plugin, container, garbage); foreach (GuiContainer cont in garbage) { activeGuiContainers.Remove(cont); } } else { name = removeWhiteSpaces(name); name = PluginInstance.prependContainerName(container, name); List <GuiElement> eGarbage = new List <GuiElement>(); destroyGuiElement(plugin, container, name, eGarbage); foreach (GuiElement element in eGarbage) { container.Remove(element); } } }
public void display(BasePlayer player) { if (this.Count == 0) { return; } foreach (CuiElement element in this) { if (!string.IsNullOrEmpty(element.Name)) { element.Name = PluginInstance.prependContainerName(this, element.Name); } if (!string.IsNullOrEmpty(element.Parent) && !layers.Contains(element.Parent)) { element.Parent = PluginInstance.prependContainerName(this, element.Parent); } } GuiTracker.getGuiTracker(player).addGuiToTracker(plugin, this); #if DEBUG PluginInstance.Puts(JsonConvert.SerializeObject(this)); player.ConsoleMessage(JsonConvert.SerializeObject(this)); #endif CuiHelper.AddUi(player, CuiContainer); }
public static string GetSearchEngineIdentifier(PluginInstance pluginInstance, ITablatureSearchEngine engine) { if (string.IsNullOrEmpty(engine.Name)) { return(null); } return(string.Format("{0}:{1}", pluginInstance.Plugin.Guid, engine.Name)); }
public override async Task DoScan() { await PluginInstance.LoadPlugin(); DeterminateVstPresetSaveMode(); await GetFactoryPresets(); await base.DoScan(); }
public void addPlainButton(string name, CuiRectTransformComponent rectangle, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, string parent = "Hud", bool blur = false) { if (string.IsNullOrEmpty(name)) { name = "plainButton"; } else { name = PluginInstance.encodeName(this, name); } purgeDuplicates(name); StringBuilder closeString = new StringBuilder(""); if (close != null) { closeString.Append(" --close "); closeString.Append(close); } this.Add(new CuiElement { Name = name, Parent = PluginInstance.encodeName(this, parent), Components = { new CuiButtonComponent { Command = $"gui.input {plugin.Name} {this.name} {name}{closeString.ToString()}", FadeIn = FadeIn, Color = (panelColor != null) ? panelColor.getColorString() : "0 0 0 0", Material = blur?"assets/content/ui/uibackgroundblur-ingamemenu.mat":"Assets/Icons/IconMaterial.mat" }, rectangle }, FadeOut = FadeOut }); if (text != null) { this.addText(PluginInstance.decodeName(this, name) + "_txt", new CuiRectTransformComponent(), text, FadeIn, FadeOut, PluginInstance.decodeName(this, name)); } if (CursorEnabled) { this.Add(new CuiElement() { Name = PluginInstance.decodeName(this, name) + "_cursor", Parent = name, Components = { new CuiNeedsCursorComponent() } }); } if (callback != null) { this.registerCallback(name, callback); } }
private static PluginInstance SearchAssembly(Assembly assembly) { Type pluginType = typeof(IPlugin); PluginInstance plugin = new PluginInstance(); if (assembly != null) { try { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsInterface || type.IsAbstract) { continue; } else { if (type.GetInterface(pluginType.FullName) != null) { plugin.PluginHandler = (IPlugin)Activator.CreateInstance(type); } AddTypeList(plugin.FileFormats, type); AddTypeList(plugin.CompressionFormats, type); AddTypeList(plugin.FileEditors, type); AddTypeList(plugin.TextureDecoders, type); AddTypeList(plugin.FileIconLoaders, type); AddTypeList(plugin.ExportableTextures, type); AddTypeList(plugin.ImportableTextures, type); } } } catch (ReflectionTypeLoadException ex) { StringBuilder sb = new StringBuilder(); foreach (Exception exSub in ex.LoaderExceptions) { sb.AppendLine(exSub.Message); FileNotFoundException exFileNotFound = exSub as FileNotFoundException; if (exFileNotFound != null) { if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) { sb.AppendLine("Fusion Log:"); sb.AppendLine(exFileNotFound.FusionLog); } } sb.AppendLine(); } string errorMessage = sb.ToString(); throw new Exception(errorMessage); } } return(plugin); }
public string lastSeen() { string newLastSeen = PluginInstance.lastSeen(target); if (newLastSeen != null) { lastSeenString = newLastSeen; } return(lastSeenString); }
/// <summary> /// </summary> public void UnloadPlugin(string name) { PluginInstance plugin = this.Loaded.Find(name); if (plugin != null) { plugin.Instance.Dispose(); this.Loaded.Remove(plugin); } }
public IPlugin create(ICore core, PluginInstance instance) { return new test.MyPlugin(core, instance.PluginID); }