Exemplo n.º 1
0
        public void InitPlugin(
            IActPluginV1 plugin,
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "YUKKURI";

            EnvironmentMigrater.Migrate();
            MasterFilePublisher.Publish();
            WPFHelper.Start();
            WPFHelper.BeginInvoke(async() =>
            {
                AppLog.LoadConfiguration(AppLog.HojoringConfig);
                this.Logger?.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(() =>
                    {
                        ConfigBaseView.Instance.SetActivationStatus(false);
                        this.DeInitPlugin();
                    });

                    this.Logger.Trace("[YUKKURI] Start InitPlugin");

                    var pluginInfo = ActGlobals.oFormActMain.PluginGetSelfData(plugin);
                    if (pluginInfo != null)
                    {
                        this.PluginDirectory = pluginInfo.pluginFile.DirectoryName;
                    }

                    // .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.StatusAlertSettings.EnabledTPAlert = false;

                    // 設定ファイルをバックアップする
                    await EnvironmentHelper.BackupFilesAsync(
                        Settings.FilePath);

                    // 漢字変換を初期化する
                    KanjiTranslator.Default.Initialize();

                    // TTSキャッシュの移行とGarbageを行う
                    await Task.Run(() =>
                    {
                        this.MigrateTTSCache();
                        this.GarbageTTSCache();
                    });

                    EnvironmentHelper.WaitInitActDone();

                    await Task.Run(() =>
                    {
                        // TTSを初期化する
                        SpeechController.Default.Initialize();

                        // FF14監視スレッドを初期化する
                        FFXIVWatcher.Initialize();
                    });

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

                    // TTSメソッドを置き換える
                    this.StartReplaceTTSMethodTimer();

                    await Task.Run(() =>
                    {
                        // DISCORD BOT クライアントを初期化する
                        DiscordClientModel.Model.Initialize();

                        // AutoJoinがONならば接続する
                        if (Settings.Default.DiscordSettings.AutoJoin)
                        {
                            DiscordClientModel.Model.Connect(true);
                        }
                    });

                    await Task.Run(() =>
                    {
                        // VOICEROIDを起動する
                        if (SpeechController.Default is VoiceroidSpeechController ctrl)
                        {
                            ctrl.Start();
                        }
                    });

                    // Bridgeにメソッドを登録する
                    PlayBridge.Instance.SetBothDelegate((message, voicePalette, isSync, volume) => this.Speak(message, PlayDevices.Both, voicePalette, isSync, volume));
                    PlayBridge.Instance.SetMainDeviceDelegate((message, voicePalette, isSync, volume) => this.Speak(message, PlayDevices.Main, voicePalette, isSync, volume));
                    PlayBridge.Instance.SetSubDeviceDelegate((message, voicePalette, isSync, volume) => this.Speak(message, PlayDevices.Sub, voicePalette, isSync, volume));
                    PlayBridge.Instance.SetSyncStatusDelegate(() => Settings.Default.Player == WavePlayerTypes.WASAPIBuffered);

                    // テキストコマンドの購読を登録する
                    this.SubscribeTextCommands();

                    // サウンドデバイスを初期化する
                    SoundPlayerWrapper.Init();
                    SoundPlayerWrapper.LoadTTSCache();

                    // CeVIOをアイコン化する
                    if (Settings.Default.TTS == TTSType.Sasara)
                    {
                        CevioTrayManager.Start();
                        CevioTrayManager.ToIcon();
                    }

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

                    this.Logger.Trace("[YUKKURI] End InitPlugin");

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

                    this.isLoaded = true;

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

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

                    // TTSをゆっくりに戻す
                    Settings.Default.TTS = TTSType.Yukkuri;
                    Settings.Default.Save();
                }
            });
        }
Exemplo n.º 2
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);
                }
            });
        }
Exemplo n.º 3
0
        public void StartPlugin(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            this.isLoaded = false;

            // タイトルをセットする
            pluginScreenSpace.Text = "ULTRA SCOUTER";

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

                try
                {
                    this.PluginTabPage     = pluginScreenSpace;
                    this.PluginStatusLabel = pluginStatusText;

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

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

                    this.Logger.Trace("[ULTRA SCOUTER] Start InitPlugin");

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

                    // 設定ファイルを読み込む
                    Settings.Instance.Load();
                    Settings.Instance.MPTicker.UpdateUnlockMPSync();

                    // 設定ファイルをバックアップする
                    await EnvironmentHelper.BackupFilesAsync(
                        Settings.Instance.FileName);

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

                    // 各種ファイルを読み込む
                    await Task.Run(() =>
                    {
                        TTSDictionary.Instance.Load();
                        Settings.Instance.MobList.LoadTargetMobList();
                    });

                    EnvironmentHelper.WaitInitActDone();

                    // FFXIVプラグインへのアクセスを開始する
                    await Task.Run(() =>
                    {
                        XIVPluginHelper.Instance.Start(
                            Settings.Instance.PollingRate,
                            Settings.Instance.FFXIVLocale);
                    });

                    // ターゲット情報ワーカを開始する
                    MainWorker.Instance.Start();

                    // タブページを登録する
                    this.SetupPluginTabPages(pluginScreenSpace);

                    // テキストコマンドの購読を追加する
                    this.SubscribeTextCommands();

                    this.PluginStatusLabel.Text = "Plugin started.";
                    this.Logger.Trace("[ULTRA SCOUTER] End InitPlugin");

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

                    this.isLoaded = true;

                    // FFLogsの統計データベースをロードする
                    StatisticsDatabase.Instance.Logger = Logger;
                    await StatisticsDatabase.Instance.LoadAsync();

                    // アップデートを確認する
                    await Task.Run(() => this.Update());
                }
                catch (Exception ex)
                {
                    this.Logger.Fatal(ex, "InitPlugin error.");
                    this.ShowMessage("InitPlugin error.", ex);
                }
            });
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        public void InitPluginCore(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "SPESPE";

            EnvironmentMigrater.Migrate();
            MasterFilePublisher.Publish();
            WPFHelper.Start();
            WPFHelper.BeginInvoke(async() =>
            {
                // FFXIV_MemoryReaderを先にロードさせる
                var result = await FFXIVReader.Instance.WaitForReaderToStartedAsync(pluginScreenSpace);

                this.PluginStatusLabel = pluginStatusText;

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

                try
                {
                    EnvironmentHelper.GarbageLogs();
                    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);
                }
            });
        }
Exemplo n.º 6
0
        public void StartPlugin(
            TabPage pluginScreenSpace,
            Label pluginStatusText)
        {
            // タイトルをセットする
            pluginScreenSpace.Text = "ULTRA SCOUTER";

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

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

                try
                {
                    this.Logger.Trace("[ULTRA SCOUTER] Start InitPlugin");

                    this.PluginTabPage = pluginScreenSpace;
                    this.PluginStatusLabel = pluginStatusText;

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

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

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

                    // 各種ファイルを読み込む
                    await Task.Run(() =>
                    {
                        TTSDictionary.Instance.Load();
                        Settings.Instance.MobList.LoadTargetMobList();
                    });

                    // FFXIVプラグインへのアクセスを開始する
                    await Task.Run(() => FFXIVPlugin.Instance.Start(
                        Settings.Instance.PollingRate,
                        Settings.Instance.FFXIVLocale));

                    // ターゲット情報ワーカを開始する
                    MainWorker.Instance.Start();

                    // タブページを登録する
                    this.SetupPluginTabPages(pluginScreenSpace);

                    this.PluginStatusLabel.Text = "Plugin started.";
                    this.Logger.Trace("[ULTRA SCOUTER] End InitPlugin");

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