Ejemplo n.º 1
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;

            var getBaseUIObjScan    = this.pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
            var getUI2ObjByNameScan = this.pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

            this.getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(getBaseUIObjScan);
            this.getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(getUI2ObjByNameScan);
            this.chatLogObject   = this.getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog");

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

            this.pingTracker = new AggregatePingTracker(this.config,
                                                        new ComponentModelPingTracker(this.config),
                                                        new Win32APIPingTracker(this.config));

            this.pluginInterface.Framework.OnUpdateEvent += OnFrameworkUpdate;

            this.ui = new PingUI(this.pingTracker, this.config);

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

            AddCommandHandlers();
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;
            this.config          = (PingConfiguration)this.pluginInterface.GetPluginConfig() ?? new PingConfiguration();
            this.pingTracker     = new PingTracker();
            this.ui      = new PingUI(this.pingTracker, this.config);
            ui.IsVisible = true;

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

            this.pluginInterface.CommandManager.AddHandler("/ping",
                                                           new CommandInfo((command, args) => this.ui.IsVisible = !this.ui.IsVisible));

            this.pluginInterface.Framework.Network.OnNetworkMessage += OnNetworkMessage;
        }
Ejemplo n.º 5
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;
            this.config          = (PingConfiguration)this.pluginInterface.GetPluginConfig() ?? new PingConfiguration();
            this.config.Initialize(this.pluginInterface);

            this.pingTracker = new AggregatePingTracker(this.config,
                                                        new ComponentModelPingTracker(this.config),
                                                        new Win32APIPingTracker(this.config));

            this.pluginInterface.Framework.Network.OnNetworkMessage += OnNetworkMessage;

            this.ui = new PingUI(this.pingTracker, this.config);

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

            AddCommandHandlers();
        }
Ejemplo n.º 6
0
 public PingUI(PingTracker pingTracker, PingConfiguration config)
 {
     this.config      = config;
     this.pingTracker = pingTracker;
 }