Ejemplo n.º 1
0
        void IActPluginV1.DeInitPlugin()
        {
            if (checkBoxShowView != null)
            {
                ActGlobals.oFormActMain.Controls.Remove(checkBoxShowView);
            }

            if (TimelineAutoLoader != null)
            {
                TimelineAutoLoader.Stop();
            }

            if (Settings != null)
            {
                Settings.Save();
            }

            if (TimelineView != null)
            {
                TimelineView.Close();
            }

            if (Controller != null)
            {
                Controller.Stop();
            }

            ActGlobals.oFormActMain.OnCombatEnd        -= CombatEnd;
            ActGlobals.oFormActMain.UpdateCheckClicked -= CheckForUpdate;

            if (StatusText != null)
            {
                StatusText.Text = "Plugin Exited m(_ _)m";
            }
        }
Ejemplo n.º 2
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            try
            {
                // DI log writer
                Globals.WriteLogImpl = (str) => { ActGlobals.oFormActMain.WriteInfoLog(String.Format("act_timeline: {0}", str)); };

                ScreenSpace = pluginScreenSpace;
                StatusText  = pluginStatusText;

                StatusText.Text = "Loading Sprache.dll";
#if DEBUG
                // Sprache.dll is already injected by libZ in Release builds.
                Assembly.LoadFrom("Sprache.dll");
#endif
                StatusText.Text = "Sprache.dll Load Success!";

#if DEBUG
                // See Issue #1
                // Control.CheckForIllegalCrossThreadCalls = true;
#endif

                Controller = new TimelineController();

                TimelineView = new TimelineView(Controller);
                TimelineView.Show();
                TimelineView.DoubleClick += TimelineView_DoubleClick;

                TimelineAutoLoader = new TimelineAutoLoader(this);
                TimelineAutoLoader.Start();

                Settings = new PluginSettings(this);
                Settings.AddStringSetting("TimelineTxtFilePath");
                Settings.AddStringSetting("FontString");
                Settings.AddIntSetting("TextWidth");
                Settings.AddIntSetting("BarWidth");
                Settings.AddIntSetting("OpacityPercentage");

                ActGlobals.oFormActMain.OnCombatEnd += CombatEnd;

                SetupTab();
                InjectButton();

                Settings.Load();

                SetupUpdateChecker();

                StatusText.Text = "Plugin Started (^^)!";
            }
            catch (Exception e)
            {
                if (StatusText != null)
                {
                    StatusText.Text = "Plugin Init Failed: " + e.Message;
                }
            }
        }
Ejemplo n.º 3
0
        public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
        {
            try
            {
                AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args)
                {
                    string asmFile = (args.Name.Contains(",") ? args.Name.Substring(0, args.Name.IndexOf(",")) : args.Name);

                    if (!ASMCHK.Contains(asmFile))
                    {
                        return(null);
                    }

                    try
                    {
                        return(Assembly.LoadFile(Path.Combine(GetPluginDirectory(), asmFile + ".dll")));
                    }
                    catch
                    {
                        return(null);
                    }
                };
                // DI log writer
                Globals.WriteLogImpl = (str) => { ActGlobals.oFormActMain.WriteInfoLog(String.Format("act_timeline: {0}", str)); };

                ScreenSpace = pluginScreenSpace;
                StatusText  = pluginStatusText;

                StatusText.Text = "Loading Sprache.dll";
#if DEBUG
                // Sprache.dll is already injected by libZ in Release builds.
                Assembly.LoadFrom("Sprache.dll");
#endif
                StatusText.Text = "Sprache.dll Load Success!";

#if DEBUG
                // See Issue #1
                // Control.CheckForIllegalCrossThreadCalls = true;
#endif

                Controller = new TimelineController();

                TimelineView              = new TimelineView(Controller);
                TimelineView.DoubleClick += TimelineView_DoubleClick;

                visibilityControl         = new VisibilityControl(TimelineView);
                visibilityControl.Visible = true;

                TimelineAutoLoader = new TimelineAutoLoader(Controller);
                TimelineAutoLoader.Start();

                Settings = new PluginSettings(this);
                Settings.AddStringSetting("TimelineTxtFilePath");
                Settings.AddStringSetting("FontString");
                Settings.AddIntSetting("TextWidth");
                Settings.AddIntSetting("BarWidth");
                Settings.AddIntSetting("OpacityPercentage");

                SetupTab();
                InjectButton();

                Settings.Load();

                SetupUpdateChecker();

                StatusText.Text = Translator.Get("_LN_PluginStarted");

                xivWindowTimer = new System.Threading.Timer(e => {
                    try
                    {
                        if (this.AutoHide)
                        {
                            uint pid;
                            var hWndFg = NativeMethods.GetForegroundWindow();
                            if (hWndFg == IntPtr.Zero)
                            {
                                return;
                            }
                            NativeMethods.GetWindowThreadProcessId(hWndFg, out pid);
                            var exePath = Process.GetProcessById((int)pid).MainModule.FileName;

                            if (Path.GetFileName(exePath) == "ffxiv.exe" ||
                                Path.GetFileName(exePath) == "ffxiv_dx11.exe")
                            {
                                this.TimelineView.Invoke(new Action(() => this.TimelineView.Visible = true));
                            }
                            else
                            {
                                this.TimelineView.Invoke(new Action(() => this.TimelineView.Visible = false));
                            }
                        }
                    }
                    catch
                    {
                    }
                });
            }
            catch (Exception e)
            {
                if (StatusText != null)
                {
                    StatusText.Text = "Plugin Init Failed: " + e.Message;
                }
            }
        }