Exemple #1
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            // Core plugin initialization
            this.pluginInterface = pluginInterface;

            this.config = (PingConfiguration)this.pluginInterface.GetPluginConfig() ?? new PingConfiguration();
            this.config.Initialize(this.pluginInterface);

            // Set up ping trackers
            this.pingTracker = new AggregatePingTracker(this.config,
                                                        new ComponentModelPingTracker(this.config),
                                                        new Win32APIPingTracker(this.config)
                                                        /*new LinuxViaWinePingTracker(this.config)*/);
            this.pingTracker.OnPingUpdated += payload =>
            {
                dynamic obj = new ExpandoObject();
                obj.LastRTT    = payload.LastRTT;
                obj.AverageRTT = payload.AverageRTT;
                this.pluginInterface.SendMessage(obj);
            };

            this.pluginInterface.Framework.OnUpdateEvent += OnFrameworkUpdate;

            // Set up UI
            this.ui = new PingUI(this.pingTracker, this.pluginInterface.UiBuilder, this.config);

            this.pluginInterface.UiBuilder.OnOpenConfigUi += (sender, e) => this.ui.ConfigVisible = true;
            this.pluginInterface.UiBuilder.OnBuildUi      += this.ui.BuildUi;

            // Initialize command manager
            this.commandManager = new PluginCommandManager <PingPlugin>(this, this.pluginInterface);
        }
Exemple #2
0
        public PingPlugin(DalamudPluginInterface pluginInterface, CommandManager commands, DtrBar dtrBar, GameNetwork network)
        {
            this.pluginInterface = pluginInterface;
            this.network         = network;

            this.config = (PingConfiguration)this.pluginInterface.GetPluginConfig() ?? new PingConfiguration();
            this.config.Initialize(this.pluginInterface);

            this.addressDetector = this.pluginInterface.Create <AggregateAddressDetector>();
            if (this.addressDetector == null)
            {
                throw new InvalidOperationException("Failed to create game address detector. The provided arguments may be incorrect.");
            }

            this.pingTracker = RequestNewPingTracker(this.config.TrackingMode);
            this.pingTracker.Start();

            InitIpc();

            // Most of these can't be created using service injection because the service container only checks ctors for
            // exact types.
            this.ui = new PingUI(this.pingTracker, this.pluginInterface, dtrBar, this.config, RequestNewPingTracker);
            this.pingTracker.OnPingUpdated += this.ui.UpdateDtrBarPing;

            this.pluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
            this.pluginInterface.UiBuilder.Draw         += this.ui.Draw;

            this.pluginCommandManager = new PluginCommandManager <PingPlugin>(this, commands);
        }