Exemple #1
0
        protected override void DoWork(FoxTTSPlugin context)
        {
            bool firstRun = true;
            PluginIntegration currentIntegration = PluginIntegration.Auto;
            bool currentInjected = false;

            while (!WorkingThreadStopping)
            {
                bool longWait = true;
                try
                {
                    if (ActGlobals.oFormActMain.Visible)
                    {
                        PluginIntegration targetIntegration = context.Settings.PluginIntegration;
                        bool successfullyInjected           = false;
                        switch (targetIntegration)
                        {
                        case PluginIntegration.Auto:
                            successfullyInjected = true;
                            if (YukkuriInjector.isYukkuriEnabled())
                            {
                                actInjector.UnInject();
                                yukkuriInjector.Inject();
                                targetIntegration = PluginIntegration.Yukkuri;
                            }
                            else
                            {
                                yukkuriInjector.UnInject();
                                actInjector.Inject();
                                targetIntegration = PluginIntegration.Act;
                                longWait          = false;
                            }
                            break;

                        case PluginIntegration.Act:
                            yukkuriInjector.UnInject();
                            actInjector.Inject();
                            successfullyInjected = true;
                            longWait             = false;
                            break;

                        case PluginIntegration.Yukkuri:
                            actInjector.UnInject();
                            if (YukkuriInjector.isYukkuriEnabled())
                            {
                                successfullyInjected = true;
                                yukkuriInjector.Inject();
                            }
                            else
                            {
                                yukkuriInjector.UnInject();
                                longWait = false;
                            }
                            break;
                        }

                        if (currentIntegration != targetIntegration || currentInjected != successfullyInjected || firstRun)
                        {
                            currentIntegration = targetIntegration;
                            currentInjected    = successfullyInjected;
                            firstRun           = false;

                            switch (targetIntegration)
                            {
                            case PluginIntegration.Act:
                                context.Controller.NotifyLogMessageAppend(false, $"ACT integration: {successfullyInjected}");
                                break;

                            case PluginIntegration.Yukkuri:
                                context.Controller.NotifyLogMessageAppend(false, $"Yukkuri integration: {successfullyInjected}");
                                break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    context.Controller.NotifyLogMessageAppend(false, e.ToString());
                }

                SafeSleep(longWait ? 5000 : 1000);
            }
        }
Exemple #2
0
 public TTSInjector()
 {
     yukkuriInjector = new YukkuriInjector(this);
     actInjector     = new ActInjector(this);
 }