コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerTrackProvider"/> class.
        /// </summary>
        /// <param name="pluginInterface">plugin interface.</param>
        /// <param name="api">plugin api.</param>
        public PlayerTrackProvider(DalamudPluginInterface pluginInterface, IPlayerTrackAPI api)
        {
            this.API = api;

            try
            {
                this.ProviderAPIVersion = pluginInterface.GetIpcProvider <int>(LabelProviderApiVersion);
                this.ProviderAPIVersion.RegisterFunc(() => api.APIVersion);
            }
            catch (Exception ex)
            {
                Logger.LogError($"Error registering IPC provider for {LabelProviderApiVersion}:\n{ex}");
            }

            try
            {
                this.ProviderGetPlayerCurrentNameWorld =
                    pluginInterface.GetIpcProvider <string, uint, string>(LabelProviderGetPlayerCurrentNameWorld);
                this.ProviderGetPlayerCurrentNameWorld.RegisterFunc(api.GetPlayerCurrentNameWorld);
            }
            catch (Exception e)
            {
                Logger.LogError($"Error registering IPC provider for {LabelProviderGetPlayerCurrentNameWorld}:\n{e}");
            }
        }
コード例 #2
0
        public DiscordBridgeProvider(DalamudPluginInterface pluginInterface, IDiscordBridgeAPI api)
        {
            try
            {
                this.providerAPIVersion = pluginInterface.GetIpcProvider <int>(LabelProviderApiVersion);
                this.providerAPIVersion.RegisterFunc(() => api.APIVersion);

                this.providerSendMessage =
                    pluginInterface.GetIpcProvider <string, string, string, object>(LabelProviderSendMessage);
                this.providerSendMessage.RegisterAction(api.SendMessage);
            }
            catch (Exception ex)
            {
                PluginLog.LogError($"Error registering IPC provider:\n{ex}");
            }
        }
コード例 #3
0
ファイル: PenumbraIpc.cs プロジェクト: pmgr/Penumbra
        public PenumbraIpc(DalamudPluginInterface pi, IPenumbraApi api)
        {
            Api = api;

            try
            {
                ProviderApiVersion = pi.GetIpcProvider <int>(LabelProviderApiVersion);
                ProviderApiVersion.RegisterFunc(() => api.ApiVersion);
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderApiVersion}:\n{e}");
            }

            try
            {
                ProviderRedrawName = pi.GetIpcProvider <string, int, object>(LabelProviderRedrawName);
                ProviderRedrawName.RegisterAction((s, i) => api.RedrawObject(s, CheckRedrawType(i)));
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderRedrawName}:\n{e}");
            }

            try
            {
                ProviderRedrawObject = pi.GetIpcProvider <GameObject, int, object>(LabelProviderRedrawObject);
                ProviderRedrawObject.RegisterAction((o, i) => api.RedrawObject(o, CheckRedrawType(i)));
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderRedrawObject}:\n{e}");
            }

            try
            {
                ProviderRedrawAll = pi.GetIpcProvider <int, object>(LabelProviderRedrawAll);
                ProviderRedrawAll.RegisterAction(i => api.RedrawAll(CheckRedrawType(i)));
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderRedrawAll}:\n{e}");
            }

            try
            {
                ProviderResolveDefault = pi.GetIpcProvider <string, string>(LabelProviderResolveDefault);
                ProviderResolveDefault.RegisterFunc(api.ResolvePath);
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderResolveDefault}:\n{e}");
            }

            try
            {
                ProviderResolveCharacter = pi.GetIpcProvider <string, string, string>(LabelProviderResolveCharacter);
                ProviderResolveCharacter.RegisterFunc(api.ResolvePath);
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderResolveCharacter}:\n{e}");
            }

            try
            {
                ProviderChangedItemTooltip = pi.GetIpcProvider <ChangedItemType, uint, object>(LabelProviderChangedItemTooltip);
                api.ChangedItemTooltip    += OnTooltip;
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderChangedItemTooltip}:\n{e}");
            }

            try
            {
                ProviderChangedItemClick = pi.GetIpcProvider <MouseButton, ChangedItemType, uint, object>(LabelProviderChangedItemClick);
                api.ChangedItemClicked  += OnClick;
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderChangedItemClick}:\n{e}");
            }

            try
            {
                ProviderGetChangedItems = pi.GetIpcProvider <string, IReadOnlyDictionary <string, object?> >(LabelProviderGetChangedItems);
                ProviderGetChangedItems.RegisterFunc(api.GetChangedItemsForCollection);
            }
            catch (Exception e)
            {
                PluginLog.Error($"Error registering IPC provider for {LabelProviderChangedItemClick}:\n{e}");
            }
        }