Esempio n. 1
0
        public void InitPluginCore(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "SPESPE";

            EnvironmentMigrater.Migrate();
            MasterFilePublisher.Publish();
            WPFHelper.Start();
            WPFHelper.BeginInvoke(async() =>
            {
                AppLog.LoadConfiguration(AppLog.HojoringConfig);
                this.AppLogger?.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

                try
                {
                    this.PluginStatusLabel = pluginStatusText;

                    if (!EnvironmentHelper.IsValidPluginLoadOrder())
                    {
                        if (pluginStatusText != null)
                        {
                            pluginStatusText.Text = "Plugin Initialize Error";
                        }

                        return;
                    }

                    EnvironmentHelper.GarbageLogs();
                    EnvironmentHelper.StartActivator(() =>
                    {
                        BaseView.Instance.SetActivationStatus(false);
                        this.DeInitPluginCore();
                    });

                    Logger.Init();
                    Logger.Write("[SPESPE] Start InitPlugin");

                    // .NET FrameworkとOSのバージョンを確認する
                    if (!UpdateChecker.IsAvailableDotNet() ||
                        !UpdateChecker.IsAvailableWindows())
                    {
                        NotSupportedView.AddAndShow(pluginScreenSpace);
                        return;
                    }

                    // FFXIV.Framework.config を読み込ませる
                    lock (FFXIV.Framework.Config.ConfigBlocker)
                    {
                        _ = FFXIV.Framework.Config.Instance;
                    }

                    // HojoringのSplashを表示する
                    UpdateChecker.ShowSplash();

                    // 外部リソースをダウンロードする
                    await ResourcesDownloader.Instance.DownloadAsync();

                    // メイン設定ファイルを読み込む
                    Settings.Default.Load();
                    Settings.Default.ApplyRenderMode();
                    Settings.Default.StartAutoSave();

                    // 最小化する?
                    if (Settings.Default.IsMinimizeOnStart)
                    {
                        ActGlobals.oFormActMain.WindowState = FormWindowState.Minimized;
                    }

                    // 自身の場所を格納しておく
                    var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot);
                    if (plugin != null)
                    {
                        this.Location = plugin.pluginFile.DirectoryName;
                    }

                    // 設定ファイルを読み込む
                    SpellPanelTable.Instance.Load();
                    SpellTable.Instance.Load();
                    TickerTable.Instance.Load();
                    TagTable.Instance.Load();
                    _ = TimelineSettings.Instance;

                    // 設定ファイルをバックアップする
                    await EnvironmentHelper.BackupFilesAsync(
                        Settings.Default.FileName,
                        SpellPanelTable.Instance.DefaultFile,
                        SpellTable.Instance.DefaultFile,
                        TickerTable.Instance.DefaultFile,
                        TagTable.Instance.DefaultFile,
                        TimelineSettings.FileName,
                        FFXIV.Framework.Config.FileName);

                    TTSDictionary.Instance.Load();

                    // 設定Panelを追加する
                    var baseView = new BaseView(pluginScreenSpace.Font);
                    pluginScreenSpace.Controls.Add(new ElementHost()
                    {
                        Child = baseView,
                        Dock  = DockStyle.Fill,
                        Font  = pluginScreenSpace.Font,
                    });

                    EnvironmentHelper.WaitInitActDone();

                    // 本体を開始する
                    PluginMainWorker.Instance.Begin();
                    TimelineController.Init();

                    // 付加情報オーバーレイを表示する
                    LPSView.ShowLPS();
                    POSView.ShowPOS();

                    this.SetSwitchVisibleButton();

                    if (this.PluginStatusLabel != null)
                    {
                        this.PluginStatusLabel.Text = "Plugin Started";
                    }

                    Logger.Write("[SPESPE] End InitPlugin");

                    // 共通ビューを追加する
                    CommonViewHelper.Instance.AddCommonView(
                        pluginScreenSpace.Parent as TabControl);

                    this.isLoaded = true;

                    // アップデートを確認する
                    await Task.Run(() => this.Update());
                }
                catch (Exception ex)
                {
                    Logger.Write("InitPlugin error.", ex);

                    if (this.PluginStatusLabel != null)
                    {
                        this.PluginStatusLabel.Text = "Plugin Initialize Error";
                    }

                    ModernMessageBox.ShowDialog(
                        "Plugin init error !",
                        "ACT.SpecialSpellTimer",
                        System.Windows.MessageBoxButton.OK,
                        ex);
                }
            });
        }
Esempio n. 2
0
        public void InitPluginCore(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "SPESPE";

            WPFHelper.Start();
            WPFHelper.BeginInvoke(async() =>
            {
                // FFXIV_MemoryReaderを先にロードさせる
                await FFXIVReader.Instance.WaitForReaderToStartedAsync();

                this.PluginStatusLabel = pluginStatusText;

                AppLog.LoadConfiguration(AppLog.HojoringConfig);
                this.AppLogger.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

                try
                {
                    Logger.Init();
                    Logger.Write("[SPESPE] Start InitPlugin");

                    // .NET FrameworkとOSのバージョンを確認する
                    if (!UpdateChecker.IsAvailableDotNet() ||
                        !UpdateChecker.IsAvailableWindows())
                    {
                        NotSupportedView.AddAndShow(pluginScreenSpace);
                        return;
                    }

                    // メイン設定ファイルを読み込む
                    Settings.Default.Load();
                    Settings.Default.ApplyRenderMode();

                    // 最小化する?
                    if (Settings.Default.IsMinimizeOnStart)
                    {
                        ActGlobals.oFormActMain.WindowState = FormWindowState.Minimized;
                    }

                    // HojoringのSplashを表示する
                    UpdateChecker.ShowSplash();

                    // 自身の場所を格納しておく
                    var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot);
                    if (plugin != null)
                    {
                        this.Location = plugin.pluginFile.DirectoryName;
                    }

                    // 設定ファイルを読み込む
                    SpellPanelTable.Instance.Load();
                    SpellTable.Instance.Load();
                    TickerTable.Instance.Load();
                    TagTable.Instance.Load();

                    await Task.Run(() =>
                    {
                        SpellPanelTable.Instance.Backup();
                        SpellTable.Instance.Backup();
                        TickerTable.Instance.Backup();
                        TagTable.Instance.Backup();
                    });

                    TTSDictionary.Instance.Load();

                    // 設定Panelを追加する
                    var baseView = new BaseView(pluginScreenSpace.Font);
                    pluginScreenSpace.Controls.Add(new ElementHost()
                    {
                        Child = baseView,
                        Dock  = DockStyle.Fill,
                        Font  = pluginScreenSpace.Font,
                    });

                    // 本体を開始する
                    PluginMainWorker.Instance.Begin();
                    TimelineController.Init();

                    // 付加情報オーバーレイを表示する
                    LPSView.ShowLPS();
                    POSView.ShowPOS();

                    this.SetSwitchVisibleButton();
                    this.PluginStatusLabel.Text = "Plugin Started";

                    Logger.Write("[SPESPE] End InitPlugin");

                    // アップデートを確認する
                    await Task.Run(() => this.Update());
                }
                catch (Exception ex)
                {
                    Logger.Write("InitPlugin error.", ex);

                    if (this.PluginStatusLabel != null)
                    {
                        this.PluginStatusLabel.Text = "Plugin Initialize Error";
                    }

                    ModernMessageBox.ShowDialog(
                        "Plugin init error !",
                        "ACT.SpecialSpellTimer",
                        System.Windows.MessageBoxButton.OK,
                        ex);
                }
            });
        }
        public void InitPluginCore(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            this.PluginStatusLabel = pluginStatusText;

            AppLog.LoadConfiguration(AppLog.HojoringConfig);
            this.AppLogger.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start.");

            try
            {
                Logger.Init();
                Logger.Write("Plugin Start.");

                pluginScreenSpace.Text = "SPESPE";

                // .NET Frameworkのバージョンを確認する
                if (!UpdateChecker.IsAvalableDotNet())
                {
                    return;
                }

                // 設定ファイルを読み込む
                Settings.Default.Load();
                Settings.Default.ApplyRenderMode();

                // 最小化する?
                if (Settings.Default.IsMinimizeOnStart)
                {
                    ActGlobals.oFormActMain.WindowState = FormWindowState.Minimized;
                    Application.DoEvents();
                }

                // HojoringのSplashを表示する
                WPFHelper.Start();
                UpdateChecker.ShowSplash();

                // アップデートを確認する
                Task.Run(() =>
                {
                    this.Update();
                });

                // 自身の場所を格納しておく
                var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot);
                if (plugin != null)
                {
                    this.Location = plugin.pluginFile.DirectoryName;
                }

                // 設定ファイルを読み込む
                SpellPanelTable.Instance.Load();
                SpellTable.Instance.Load();
                TickerTable.Instance.Load();
                TagTable.Instance.Load();

                // 設定ファイルのバックアップを作成する
                SpellPanelTable.Instance.Backup();
                SpellTable.Instance.Backup();
                TickerTable.Instance.Backup();
                TagTable.Instance.Backup();

                // TTS辞書を読み込む
                TTSDictionary.Instance.Load();

                // 設定Panelを追加する
                var baseView = new BaseView(pluginScreenSpace.Font);
                pluginScreenSpace.Controls.Add(new ElementHost()
                {
                    Child = baseView,
                    Dock  = DockStyle.Fill,
                    Font  = pluginScreenSpace.Font,
                });

                // 本体を開始する
                PluginMainWorker.Instance.Begin();
                TimelineController.Init();

                // LPSViewを表示する
                LPSView.ShowLPS();

                this.SetSwitchVisibleButton();
                this.PluginStatusLabel.Text = "Plugin Started";

                Logger.Write("Plugin Started.");
            }
            catch (Exception ex)
            {
                ActGlobals.oFormActMain.WriteExceptionLog(
                    ex,
                    "Plugin init error.");

                Logger.Write("Plugin init error.", ex);

                if (this.PluginStatusLabel != null)
                {
                    this.PluginStatusLabel.Text = "Plugin Initialize Error";
                }

                ModernMessageBox.ShowDialog(
                    "Plugin init error !",
                    "ACT.SpecialSpellTimer",
                    System.Windows.MessageBoxButton.OK,
                    ex);
            }
        }