Exemplo n.º 1
0
        /// <summary>
        /// 表示切り替えボタン(スペスペボタン)の状態を切り替える
        /// </summary>
        /// <param name="visible">
        /// 切り替える状態</param>
        public static void ChangeSwitchVisibleButton(
            bool visible)
        {
            Settings.Default.OverlayVisible = visible;
            Settings.Default.Save();

            SpellTimerCore.Default.ClosePanels();
            OnePointTelopController.CloseTelops();

            FF14PluginHelper.RefreshPlayer();
            LogBuffer.RefreshPartyList();
            LogBuffer.RefreshPetID();

            if (Settings.Default.OverlayVisible)
            {
                SpellTimerCore.Default.ActivatePanels();
                OnePointTelopController.ActivateTelops();
            }

            ActInvoker.Invoke(() =>
            {
                if (Settings.Default.OverlayVisible)
                {
                    SwitchVisibleButton.BackColor = Color.OrangeRed;
                    SwitchVisibleButton.ForeColor = Color.WhiteSmoke;
                }
                else
                {
                    SwitchVisibleButton.BackColor = SystemColors.Control;
                    SwitchVisibleButton.ForeColor = Color.Black;
                }
            });
        }
        /// <summary>
        /// 終了する
        /// </summary>
        public void End()
        {
            // 戦闘分析を開放する
            CombatAnalyzer.Default.Denitialize();

            // ログバッファを開放する
            if (this.LogBuffer != null)
            {
                this.LogBuffer.Dispose();
                this.LogBuffer = null;
            }

            lock (lockObject)
            {
                // 監視を開放する
                if (this.RefreshTimer != null)
                {
                    this.RefreshTimer.Stop();
                    this.RefreshTimer.Dispose();
                    this.RefreshTimer = null;
                }
            }

            // 全てのPanelを閉じる
            this.ClosePanels();
            OnePointTelopController.CloseTelops();

            // 設定を保存する
            Settings.Default.Save();
            SpellTimerTable.Save();
            OnePointTelopTable.Default.Save();

            // instanceを初期化する
            instance = null;
        }
        /// <summary>
        /// 開始する
        /// </summary>
        public void Begin()
        {
            // 戦闘分析を初期化する
            CombatAnalyzer.Default.Initialize();

            // Panelリストを生成する
            this.SpellTimerPanels = new List <SpellTimerListWindow>();

            // ログバッファを生成する
            this.LogBuffer = new LogBuffer();

            // RefreshWindowタイマを開始する
            this.RefreshWindowTimer = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = new TimeSpan(0, 0, 0, 0, 100),
            };

            this.RefreshWindowTimer.Tick += this.RefreshWindowTimerOnTick;
            this.RefreshWindowTimer.Start();

            // ログ監視タイマを開始する
            this.WatchLogTimer = new System.Timers.Timer()
            {
                Interval  = Settings.Default.RefreshInterval,
                AutoReset = true,
            };

            this.WatchLogTimer.Elapsed += (s, e) =>
            {
#if DEBUG
                var sw = Stopwatch.StartNew();
#endif
                try
                {
                    if (this.WatchLogTimer != null &&
                        this.WatchLogTimer.Enabled)
                    {
                        this.WatchLog();
                    }
                }
                catch (Exception ex)
                {
                    ActGlobals.oFormActMain.WriteExceptionLog(
                        ex,
                        Translate.Get("SpellTimerRefreshError"));
                }
                finally
                {
#if DEBUG
                    sw.Stop();
                    Debug.WriteLine(
                        DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " " +
                        "●WatchLog " + sw.Elapsed.TotalMilliseconds.ToString("N4") + "ms");
#endif
                }
            };

            this.WatchLogTimer.Start();
        }
Exemplo n.º 4
0
        /// <summary>
        /// 表示切り替えボタンを配置する
        /// </summary>
        private void SetSwitchVisibleButton()
        {
            var changeColor = new Action <Button>((button) =>
            {
                if (Settings.Default.OverlayVisible)
                {
                    button.BackColor = Color.OrangeRed;
                    button.ForeColor = Color.WhiteSmoke;
                }
                else
                {
                    button.BackColor = SystemColors.Control;
                    button.ForeColor = Color.Black;
                }
            });

            SwitchVisibleButton           = new Button();
            SwitchVisibleButton.Name      = "SpecialSpellTimerSwitchVisibleButton";
            SwitchVisibleButton.Size      = new Size(90, 24);
            SwitchVisibleButton.Text      = Utility.Translate.Get("SupeSupe");
            SwitchVisibleButton.TextAlign = ContentAlignment.MiddleCenter;
            SwitchVisibleButton.UseVisualStyleBackColor = true;
            SwitchVisibleButton.Click += (s, e) =>
            {
                var button = s as Button;

                Settings.Default.OverlayVisible = !Settings.Default.OverlayVisible;
                Settings.Default.Save();

                SpellTimerCore.Default.ClosePanels();
                OnePointTelopController.CloseTelops();

                FF14PluginHelper.RefreshPlayer();
                LogBuffer.RefreshPartyList();
                LogBuffer.RefreshPetID();

                if (Settings.Default.OverlayVisible)
                {
                    SpellTimerCore.Default.ActivatePanels();
                    OnePointTelopController.ActivateTelops();
                }

                changeColor(s as Button);
            };

            changeColor(SwitchVisibleButton);

            ActGlobals.oFormActMain.Resize += this.oFormActMain_Resize;
            ActGlobals.oFormActMain.Controls.Add(SwitchVisibleButton);
            ActGlobals.oFormActMain.Controls.SetChildIndex(SwitchVisibleButton, 1);

            this.oFormActMain_Resize(this, null);
        }
        /// <summary>
        /// 開始する
        /// </summary>
        public void Begin()
        {
            // 戦闘分析を初期化する
            CombatAnalyzer.Default.Initialize();

            // Panelリストを生成する
            this.SpellTimerPanels = new List <SpellTimerListWindow>();

            // ログバッファを生成する
            this.LogBuffer = new LogBuffer();

            // Refreshタイマを開始する
            this.RefreshInterval = Settings.Default.RefreshInterval;
            this.RefreshTimer    = new System.Windows.Forms.Timer()
            {
                Interval = (int)this.RefreshInterval
            };

            this.RefreshTimer.Tick += (s1, e1) =>
            {
                lock (lockObject)
                {
#if DEBUG
                    var sw = Stopwatch.StartNew();
#endif
                    try
                    {
                        if (this.RefreshTimer != null &&
                            this.RefreshTimer.Enabled)
                        {
                            this.RefreshWindow();
                        }
                    }
                    catch (Exception ex)
                    {
                        ActGlobals.oFormActMain.WriteExceptionLog(
                            ex,
                            Translate.Get("SpellTimerRefreshError"));
                    }
                    finally
                    {
#if DEBUG
                        sw.Stop();
                        Debug.WriteLine("●Refresh " + sw.ElapsedMilliseconds.ToString("N0") + "ms");
#endif
                        this.RefreshTimer.Interval = (int)this.RefreshInterval;
                    }
                }
            };

            this.RefreshTimer.Start();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 開始する
        /// </summary>
        public void Begin()
        {
            // FFXIVのスキャンを開始する
            FFXIV.Instance.Start();

            // テーブルコンパイラを開始する
            TableCompiler.Instance.Begin();

            // 戦闘分析を初期化する
            CombatAnalyzer.Default.Initialize();

            // Panelリストを生成する
            this.SpellTimerPanels = new List <SpellTimerListWindow>();

            // ログバッファを生成する
            this.LogBuffer = new LogBuffer();

            // RefreshWindowタイマを開始する
            this.refreshWindowTimer =
                new System.Windows.Threading.DispatcherTimer(
                    System.Windows.Threading.DispatcherPriority.Render);
            this.refreshWindowTimer.Tick    += this.RefreshWindowTimerOnTick;
            this.refreshWindowTimer.Interval = TimeSpan.FromMilliseconds(Settings.Default.RefreshInterval);
            this.refreshWindowTimer.Start();

            // ログ監視タイマを開始する
            this.running   = true;
            this.logPoller = new Thread(() =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(5));
                Logger.Write("start log poll");
                while (this.running)
                {
                    try
                    {
                        WatchLog();
                    }
                    catch (ThreadAbortException)
                    {
                        this.running = false;
                    }
                    catch (Exception ex)
                    {
                        Logger.Write("logPoller error:", ex);
                    }
                }

                Logger.Write("end log poll");
            });

            this.logPoller.Start();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 終了する
        /// </summary>
        public void End()
        {
            this.running = false;

            // 戦闘分析を開放する
            CombatAnalyzer.Default.Denitialize();

            // ログバッファを開放する
            if (this.LogBuffer != null)
            {
                this.LogBuffer.Dispose();
                this.LogBuffer = null;
            }

            // 監視を開放する
            if (this.RefreshWindowTimer != null)
            {
                this.RefreshWindowTimer.Stop();
                this.RefreshWindowTimer = null;
            }

            if (this.logPoller != null)
            {
                if (this.logPoller.IsAlive)
                {
                    try
                    {
                        if (!this.logPoller.Join(TimeSpan.FromSeconds(5)))
                        {
                            this.logPoller.Abort();
                        }
                    }
                    catch
                    {
                    }

                    this.logPoller = null;
                }
            }

            // 全てのPanelを閉じる
            this.ClosePanels();
            OnePointTelopController.CloseTelops();

            // 設定を保存する
            Settings.Default.Save();
            SpellTimerTable.Save();
            OnePointTelopTable.Default.Save();

            // instanceを初期化する
            instance = null;
        }
        /// <summary>
        /// 終了する
        /// </summary>
        public void End()
        {
            this.isOver = true;

            // 戦闘分析を開放する
            CombatAnalyzer.Default.Denitialize();

            // Workerを開放する
            this.refreshSpellOverlaysWorker?.Stop();
            this.refreshTickerOverlaysWorker?.Stop();
            this.detectLogsWorker?.Abort();

            this.refreshSpellOverlaysWorker  = null;
            this.refreshTickerOverlaysWorker = null;
            this.detectLogsWorker            = null;

            this.backgroudWorker?.Stop();
            this.backgroudWorker?.Dispose();
            this.backgroudWorker = null;

            // ログバッファを開放する
            if (this.LogBuffer != null)
            {
                this.LogBuffer.Dispose();
                this.LogBuffer = null;
            }

            // Windowを閉じる
            SpellsController.Instance.ClosePanels();
            TickersController.Instance.CloseTelops();
            SpellsController.Instance.ExecuteClosePanels();
            TickersController.Instance.ExecuteCloseTelops();

            // 設定を保存する
            Settings.Default.Save();
            SpellPanelTable.Instance.Save();
            SpellTable.Instance.Save();
            TickerTable.Instance.Save();
            TagTable.Instance.Save();

            // サウンドコントローラを停止する
            SoundController.Instance.End();

            // テーブルコンパイラを停止する
            TableCompiler.Instance.End();
            TableCompiler.Free();

            // FFXIVのスキャンを停止する
            FFXIVPlugin.Instance.End();
            FFXIVPlugin.Free();
        }
Exemplo n.º 9
0
        /// <summary>
        /// 終了する
        /// </summary>
        public void End()
        {
            this.running = false;

            // 戦闘分析を開放する
            CombatAnalyzer.Default.Denitialize();

            // ログバッファを開放する
            if (this.LogBuffer != null)
            {
                this.LogBuffer.Dispose();
                this.LogBuffer = null;
            }

            // Viewの描画を開放する
            if (this.refreshWindowTimer != null)
            {
                this.refreshWindowTimer.Stop();
                this.refreshWindowTimer = null;
            }

            // 監視を開放する
            if (this.logPoller != null)
            {
                this.logPoller.Join(TimeSpan.FromSeconds(5));
                if (this.logPoller.IsAlive)
                {
                    this.logPoller.Abort();
                }

                this.logPoller = null;
            }

            // 全てのPanelを閉じる
            this.ClosePanels();
            OnePointTelopController.CloseTelops();

            // 設定を保存する
            Settings.Default.Save();
            SpellTimerTable.Save();
            OnePointTelopTable.Default.Save();

            // テーブルコンパイラを停止する
            TableCompiler.Instance.End();

            // FFXIVのスキャンを停止する
            FFXIV.Instance.End();

            // instanceを初期化する
            instance = null;
        }
Exemplo n.º 10
0
        /// <summary>
        /// 開始する
        /// </summary>
        public void Begin()
        {
            this.isOver = false;

            // FFXIVのスキャンを開始する
            FFXIVPlugin.Initialize();
            FFXIVPlugin.Instance.Start();

            // ログバッファを生成する
            this.LogBuffer = new LogBuffer();

            // テーブルコンパイラを開始する
            TableCompiler.Initialize();
            TableCompiler.Instance.Begin();

            // 戦闘分析を初期化する
            CombatAnalyzer.Default.Initialize();

            // サウンドコントローラを開始する
            SoundController.Instance.Begin();

            // Overlayの更新スレッドを開始する
            this.BeginOverlaysThread();

            // ログ監視タイマを開始する
            this.detectLogsWorker = new ThreadWorker(() =>
            {
                this.DetectLogsCore();
            },
                                                     0,
                                                     nameof(this.detectLogsWorker));

            // Backgroudスレッドを開始する
            this.backgroudWorker           = new System.Timers.Timer();
            this.backgroudWorker.AutoReset = true;
            this.backgroudWorker.Interval  = 5000;
            this.backgroudWorker.Elapsed  += (s, e) =>
            {
                this.BackgroundCore();
            };

            this.detectLogsWorker.Run();
            this.backgroudWorker.Start();
        }
        /// <summary>
        /// 開始する
        /// </summary>
        public void Begin()
        {
            // 戦闘分析を初期化する
            CombatAnalyzer.Default.Initialize();

            // Panelリストを生成する
            this.SpellTimerPanels = new List<SpellTimerListWindow>();

            // ログバッファを生成する
            this.LogBuffer = new LogBuffer();

            // Refreshタイマを開始する
            this.RefreshInterval = Settings.Default.RefreshInterval;
            this.RefreshTimer = new System.Windows.Forms.Timer()
            {
                Interval = (int)this.RefreshInterval
            };

            this.RefreshTimer.Tick += this.RefreshTimerOnTick;
            this.RefreshTimer.Start();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Commandとマッチングする
        /// </summary>
        /// <param name="logLines">
        /// ログ行</param>
        public static void MatchCommand(
            IReadOnlyList <string> logLines)
        {
            var commandDone = false;

            foreach (var log in logLines)
            {
                // 正規表現の前にキーワードがなければ抜けてしまう
                if (!log.ToLower().Contains("/spespe"))
                {
                    continue;
                }

                var match = regexCommand.Match(log);
                if (!match.Success)
                {
                    continue;
                }

                var command     = match.Groups["command"].ToString().ToLower();
                var target      = match.Groups["target"].ToString().ToLower();
                var windowname  = match.Groups["windowname"].ToString().Replace(@"""", string.Empty);
                var valueAsText = match.Groups["value"].ToString();
                var value       = false;
                if (!bool.TryParse(valueAsText, out value))
                {
                    value = false;
                }

                switch (command)
                {
                case "analyze":
                    switch (target)
                    {
                    case "on":
                        SpecialSpellTimerPlugin.ConfigPanel.CombatAnalyzerEnabled = true;
                        commandDone = true;
                        break;

                    case "off":
                        SpecialSpellTimerPlugin.ConfigPanel.CombatAnalyzerEnabled = false;
                        commandDone = true;
                        break;
                    }

                    break;

                case "refresh":
                    switch (target)
                    {
                    case "spells":
                        SpellTimerCore.Default.ClosePanels();
                        commandDone = true;
                        break;

                    case "telops":
                        OnePointTelopController.CloseTelops();
                        commandDone = true;
                        break;

                    case "me":
                        FF14PluginHelper.RefreshPlayer();
                        commandDone = true;
                        break;

                    case "pt":
                        LogBuffer.RefreshPartyList();
                        commandDone = true;
                        break;

                    case "pet":
                        LogBuffer.RefreshPetID();
                        commandDone = true;
                        break;
                    }

                    break;

                case "changeenabled":
                    var changed = false;
                    switch (target)
                    {
                    case "spells":
                        foreach (var spell in SpellTimerTable.Table)
                        {
                            if (spell.Panel.Trim().ToLower() == windowname.Trim().ToLower() ||
                                spell.SpellTitle.Trim().ToLower() == windowname.Trim().ToLower() ||
                                windowname.Trim().ToLower() == "all")
                            {
                                changed       = true;
                                spell.Enabled = value;
                            }
                        }

                        if (changed)
                        {
                            ActInvoker.Invoke(() =>
                            {
                                SpecialSpellTimerPlugin.ConfigPanel.LoadSpellTimerTable();
                            });

                            commandDone = true;
                        }

                        break;

                    case "telops":
                        foreach (var telop in OnePointTelopTable.Default.Table)
                        {
                            if (telop.Title.Trim().ToLower() == windowname.Trim().ToLower() ||
                                windowname.Trim().ToLower() == "all")
                            {
                                changed       = true;
                                telop.Enabled = value;
                            }
                        }

                        if (changed)
                        {
                            ActInvoker.Invoke(() =>
                            {
                                SpecialSpellTimerPlugin.ConfigPanel.LoadTelopTable();
                            });

                            commandDone = true;
                        }

                        break;
                    }

                    break;

                case "set":
                    switch (target)
                    {
                    case "placeholder":
                        if (windowname.Trim().ToLower() != "all" &&
                            windowname.Trim() != string.Empty &&
                            valueAsText.Trim() != string.Empty)
                        {
                            LogBuffer.SetCustomPlaceholder(windowname.Trim(), valueAsText.Trim());

                            commandDone = true;
                        }

                        break;
                    }

                    break;

                case "clear":
                    switch (target)
                    {
                    case "placeholder":
                        if (windowname.Trim().ToLower() == "all")
                        {
                            LogBuffer.ClearCustomPlaceholderAll();

                            commandDone = true;
                        }
                        else if (windowname.Trim() != string.Empty)
                        {
                            LogBuffer.ClearCustomPlaceholder(windowname.Trim());

                            commandDone = true;
                        }

                        break;
                    }

                    break;

                case "on":
                    SpecialSpellTimerPlugin.ChangeSwitchVisibleButton(true);
                    commandDone = true;
                    break;

                case "off":
                    SpecialSpellTimerPlugin.ChangeSwitchVisibleButton(false);
                    commandDone = true;
                    break;
                }
            }   // loop end logLines

            // コマンドを実行したらシステム音を鳴らす
            if (commandDone)
            {
                SystemSounds.Asterisk.Play();
            }
        }   // method end
Exemplo n.º 13
0
        /// <summary>
        /// 終了する
        /// </summary>
        public void End()
        {
            running = false;

            // 戦闘分析を開放する
            CombatAnalyzer.Default.Denitialize();

            // ログバッファを開放する
            if (this.LogBuffer != null)
            {
                this.LogBuffer.Dispose();
                this.LogBuffer = null;
            }

            // 監視を開放する
            if (this.RefreshWindowTimer != null)
            {
                this.RefreshWindowTimer.Stop();
                this.RefreshWindowTimer = null;
            }

            if (logPoller != null)
            {
                if (logPoller.IsAlive)
                {
                    try
                    {
                        if (!logPoller.Join(TimeSpan.FromSeconds(5)))
                        {
                            logPoller.Abort();
                        }
                    }
                    catch
                    {
                    }
                    logPoller = null;
                }
            }

            // 全てのPanelを閉じる
            this.ClosePanels();
            OnePointTelopController.CloseTelops();

            // 設定を保存する
            Settings.Default.Save();
            SpellTimerTable.Save();
            OnePointTelopTable.Default.Save();

            // instanceを初期化する
            instance = null;
        }
        /// <summary>
        /// ログ1行とマッチングする
        /// </summary>
        /// <param name="logLine">ログ行</param>
        /// <returns>
        /// コマンドを実行したか?</returns>
        public static bool MatchCommandCore(
            string logLine)
        {
            var r = false;

            // 正規表現の前にキーワードがなければ抜けてしまう
            if (!logLine.ToLower().Contains("/spespe") &&
                !logLine.ToLower().Contains("/tts"))
            {
                return(r);
            }

            // 読み仮名コマンドとマッチングする
            var isPhonetic = MatchPhoneticCommand(logLine);

            if (isPhonetic)
            {
                return(isPhonetic);
            }

            // ログコマンドとマッチングする
            var isLog = MatchLogCommand(logLine);

            if (isLog)
            {
                return(isLog);
            }

            // TTSコマンドとマッチングする
            MatchTTSCommand(logLine);

            // その他の通常コマンドとマッチングする
            var match = regexCommand.Match(logLine);

            if (!match.Success)
            {
                return(r);
            }

            var command     = match.Groups["command"].ToString().ToLower();
            var target      = match.Groups["target"].ToString().ToLower();
            var windowname  = match.Groups["windowname"].ToString().Replace(@"""", string.Empty);
            var valueAsText = match.Groups["value"].ToString();
            var value       = false;

            if (!bool.TryParse(valueAsText, out value))
            {
                value = false;
            }

            switch (command)
            {
            case "refresh":
                switch (target)
                {
                case "all":
                    TableCompiler.Instance.RefreshCombatants();
                    TableCompiler.Instance.RefreshPlayerPlacceholder();
                    TableCompiler.Instance.RefreshPartyPlaceholders();
                    TableCompiler.Instance.RefreshPetPlaceholder();
                    TableCompiler.Instance.RecompileSpells();
                    TableCompiler.Instance.RecompileTickers();
                    r = true;
                    break;

                case "spells":
                    SpellsController.Instance.ClosePanels();
                    r = true;
                    break;

                case "telops":
                    TickersController.Instance.CloseTelops();
                    r = true;
                    break;

                case "pt":
                    TableCompiler.Instance.RefreshPlayerPlacceholder();
                    TableCompiler.Instance.RefreshPartyPlaceholders();
                    TableCompiler.Instance.RecompileSpells();
                    TableCompiler.Instance.RecompileTickers();
                    r = true;
                    break;

                case "pet":
                    TableCompiler.Instance.RefreshPetPlaceholder();
                    TableCompiler.Instance.RecompileSpells();
                    TableCompiler.Instance.RecompileTickers();
                    r = true;
                    break;
                }

                break;

            case "changeenabled":
                switch (target)
                {
                case "spells":
                    foreach (var spell in SpellTable.Instance.Table)
                    {
                        if (spell.Panel.PanelName.Trim().ToLower() == windowname.Trim().ToLower() ||
                            spell.SpellTitle.Trim().ToLower() == windowname.Trim().ToLower() ||
                            windowname.Trim().ToLower() == "all")
                        {
                            spell.Enabled = value;
                            TableCompiler.Instance.RecompileSpells();

                            r = true;
                        }
                    }

                    break;

                case "telops":
                    foreach (var telop in TickerTable.Instance.Table)
                    {
                        if (telop.Title.Trim().ToLower() == windowname.Trim().ToLower() ||
                            windowname.Trim().ToLower() == "all")
                        {
                            telop.Enabled = value;
                            TableCompiler.Instance.RecompileTickers();

                            r = true;
                        }
                    }

                    break;
                }

                break;

            case "set":
                switch (target)
                {
                case "placeholder":
                    if (windowname.Trim().ToLower() != "all" &&
                        windowname.Trim() != string.Empty &&
                        valueAsText.Trim() != string.Empty)
                    {
                        TableCompiler.Instance.SetCustomPlaceholder(windowname.Trim(), valueAsText.Trim());

                        r = true;
                    }

                    break;
                }

                break;

            case "clear":
                switch (target)
                {
                case "placeholder":
                    if (windowname.Trim().ToLower() == "all")
                    {
                        TableCompiler.Instance.ClearCustomPlaceholderAll();

                        r = true;
                    }
                    else if (windowname.Trim() != string.Empty)
                    {
                        TableCompiler.Instance.ClearCustomPlaceholder(windowname.Trim());

                        r = true;
                    }

                    break;
                }

                break;

            case "on":
                PluginCore.Instance.ChangeSwitchVisibleButton(true);
                r = true;
                break;

            case "off":
                PluginCore.Instance.ChangeSwitchVisibleButton(false);
                r = true;
                break;

            case "pos":
                LogBuffer.DumpPosition();
                r = true;
                break;
            }

            return(r);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 開始する
        /// </summary>
        public void Begin()
        {
            // 戦闘分析を初期化する
            CombatAnalyzer.Default.Initialize();

            // Panelリストを生成する
            this.SpellTimerPanels = new List<SpellTimerListWindow>();

            // ログバッファを生成する
            this.LogBuffer = new LogBuffer();

            // RefreshWindowタイマを開始する
            this.RefreshWindowTimer = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(Settings.Default.RefreshInterval)
            };

            this.RefreshWindowTimer.Tick += this.RefreshWindowTimerOnTick;
            this.RefreshWindowTimer.Start();

            running = true;
            // ログ監視タイマを開始する
            logPoller = new Thread(() =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(5));
                Logger.Write("start log poll");
                while (running)
                {
                    try
                    {
                        WatchLog();
                    }
                    catch (ThreadAbortException)
                    {
                        running = false;
                    }
                    catch (Exception ex)
                    {
                        Logger.Write("logPoller error:", ex);
                    }
                }
                Logger.Write("end log poll");
            });

            logPoller.Start();
        }
Exemplo n.º 16
0
        /// <summary>
        /// ログを1行読取った
        /// </summary>
        /// <param name="isImport">Importか?</param>
        /// <param name="logInfo">ログ情報</param>
        private void oFormActMain_OnLogLineRead(
            bool isImport,
            LogLineEventArgs logInfo)
        {
            if (!Settings.Default.CombatLogEnabled)
            {
                return;
            }

            if (this.CurrentCombatLogList == null)
            {
                return;
            }

            // ログにペットが含まれている?
            if (logInfo.logLine.Contains("・エギ") ||
                logInfo.logLine.Contains("フェアリー・") ||
                logInfo.logLine.Contains("カーバンクル・"))
            {
                return;
            }

            // インポートログではない?
            if (!isImport)
            {
                // プレイヤ情報とパーティリストを取得する
                var player = FF14PluginHelper.GetPlayer();
                var ptlist = LogBuffer.GetPTMember();

                if (player == null ||
                    ptlist == null)
                {
                    return;
                }

                // ログにプレイヤ名が含まれている?
                if (logInfo.logLine.Contains(player.Name))
                {
                    return;
                }

                // ログにパーティメンバ名が含まれている?
                foreach (var name in ptlist)
                {
                    if (logInfo.logLine.Contains(name))
                    {
                        return;
                    }
                }
            }

            // キャストのキーワードが含まれている?
            foreach (var keyword in CastKeywords)
            {
                if (logInfo.logLine.Contains(keyword))
                {
                    this.StoreCastLog(logInfo);
                    return;
                }
            }

            // アクションのキーワードが含まれている?
            foreach (var keyword in ActionKeywords)
            {
                if (logInfo.logLine.Contains(keyword))
                {
                    this.StoreActionLog(logInfo);
                    return;
                }
            }

            // 残HP率のキーワードが含まれている?
            foreach (var keyword in HPRateKeywords)
            {
                if (logInfo.logLine.Contains(keyword))
                {
                    this.StoreHPRateLog(logInfo);
                    return;
                }
            }

            // Addedのキーワードが含まれている?
            foreach (var keyword in AddedKeywords)
            {
                if (logInfo.logLine.Contains(keyword))
                {
                    this.StoreAddedLog(logInfo);
                    return;
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// ログとマッチングする
        /// </summary>
        /// <param name="logLines">ログ行</param>
        public static void Match(
            string[] logLines)
        {
            var telops = OnePointTelopTable.Default.EnabledTable;

            // 不要になったWindowを閉じる
            var removeWindowList = new List <OnePointTelopWindow>();

            foreach (var window in telopWindowList.Values)
            {
                if (!telops.Any(x => x.ID == window.DataSource.ID))
                {
                    removeWindowList.Add(window);
                }
            }

            foreach (var window in removeWindowList)
            {
                ActInvoker.Invoke(() =>
                {
                    window.DataSource.Left = window.Left;
                    window.DataSource.Top  = window.Top;
                    window.Close();
                });

                telopWindowList.Remove(window.DataSource.ID);
            }

            foreach (var telop in telops.AsParallel())
            {
                var regex       = telop.Regex;
                var regexToHide = telop.RegexToHide;
                var isForceHide = false;

                foreach (var log in logLines)
                {
                    // 通常マッチ
                    if (regex == null)
                    {
                        var keyword = LogBuffer.MakeKeyword(telop.Keyword);
                        if (!string.IsNullOrWhiteSpace(keyword))
                        {
                            if (log.ToUpper().Contains(
                                    keyword.ToUpper()))
                            {
                                if (!telop.AddMessageEnabled)
                                {
                                    telop.MessageReplaced = telop.Message;
                                }
                                else
                                {
                                    telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                             telop.Message :
                                                             Environment.NewLine + telop.Message;
                                }

                                telop.MatchDateTime = DateTime.Now;
                                telop.Delayed       = false;
                                telop.MatchedLog    = log;

                                SoundController.Default.Play(telop.MatchSound);
                                SoundController.Default.Play(telop.MatchTextToSpeak);

                                continue;
                            }
                        }
                    }

                    // 正規表現マッチ
                    if (regex != null)
                    {
                        if (regex.IsMatch(log))
                        {
                            if (!telop.AddMessageEnabled)
                            {
                                telop.MessageReplaced = regex.Replace(log, telop.Message);
                            }
                            else
                            {
                                telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                         regex.Replace(log, telop.Message) :
                                                         Environment.NewLine + regex.Replace(log, telop.Message);
                            }

                            telop.MatchDateTime = DateTime.Now;
                            telop.Delayed       = false;
                            telop.MatchedLog    = log;

                            SoundController.Default.Play(telop.MatchSound);
                            if (!string.IsNullOrWhiteSpace(telop.MatchTextToSpeak))
                            {
                                var tts = regex.Replace(log, telop.MatchTextToSpeak);
                                SoundController.Default.Play(tts);
                            }

                            continue;
                        }
                    }

                    // 通常マッチ(強制非表示)
                    if (regexToHide == null)
                    {
                        var keyword = LogBuffer.MakeKeyword(telop.KeywordToHide);
                        if (!string.IsNullOrWhiteSpace(keyword))
                        {
                            if (log.ToUpper().Contains(
                                    keyword.ToUpper()))
                            {
                                isForceHide = true;
                                continue;
                            }
                        }
                    }

                    // 正規表現マッチ(強制非表示)
                    if (regexToHide != null)
                    {
                        if (regexToHide.IsMatch(log))
                        {
                            isForceHide = true;
                            continue;
                        }
                    }
                }   // end loop logLines

                // ディレイ時間が経過した?
                if (!telop.Delayed &&
                    telop.MatchDateTime > DateTime.MinValue &&
                    telop.Delay > 0)
                {
                    var delayed = telop.MatchDateTime.AddSeconds(telop.Delay);
                    if (DateTime.Now >= delayed)
                    {
                        telop.Delayed = true;
                        SoundController.Default.Play(telop.DelaySound);
                        var tts = regex != null && !string.IsNullOrWhiteSpace(telop.DelayTextToSpeak) ?
                                  regex.Replace(telop.MatchedLog, telop.DelayTextToSpeak) :
                                  telop.DelayTextToSpeak;
                        SoundController.Default.Play(tts);
                    }
                }

                var w = telopWindowList.ContainsKey(telop.ID) ? telopWindowList[telop.ID] : null;
                if (w == null)
                {
                    w = new OnePointTelopWindow()
                    {
                        Title      = "OnePointTelop - " + telop.Title,
                        DataSource = telop
                    };

                    if (Settings.Default.ClickThroughEnabled)
                    {
                        w.ToTransparentWindow();
                    }

                    w.Opacity = 0;
                    w.Show();

                    telopWindowList.Add(telop.ID, w);
                }

                // telopの位置を保存する
                if (DateTime.Now.Second == 0)
                {
                    telop.Left = w.Left;
                    telop.Top  = w.Top;
                    OnePointTelopTable.Default.Save();
                }

                if (Settings.Default.OverlayVisible &&
                    Settings.Default.TelopAlwaysVisible)
                {
                    // ドラッグ中じゃない?
                    if (!w.IsDragging)
                    {
                        w.Refresh();
                        w.ShowOverlay();
                    }

                    continue;
                }

                if (telop.MatchDateTime > DateTime.MinValue)
                {
                    var start = telop.MatchDateTime.AddSeconds(telop.Delay);
                    var end   = telop.MatchDateTime.AddSeconds(telop.Delay + telop.DisplayTime);

                    if (start <= DateTime.Now && DateTime.Now <= end)
                    {
                        w.Refresh();
                        w.ShowOverlay();
                    }
                    else
                    {
                        w.HideOverlay();

                        if (DateTime.Now > end)
                        {
                            telop.MatchDateTime   = DateTime.MinValue;
                            telop.MessageReplaced = string.Empty;
                        }
                    }

                    if (isForceHide)
                    {
                        w.HideOverlay();
                        telop.MatchDateTime   = DateTime.MinValue;
                        telop.MessageReplaced = string.Empty;
                    }
                }
                else
                {
                    w.HideOverlay();
                    telop.MessageReplaced = string.Empty;
                }
            }   // end loop telops
        }
Exemplo n.º 18
0
        /// <summary>
        /// 終了する
        /// </summary>
        public void End()
        {
            // 戦闘分析を開放する
            CombatAnalyzer.Default.Denitialize();

            // ログバッファを開放する
            if (this.LogBuffer != null)
            {
                this.LogBuffer.Dispose();
                this.LogBuffer = null;
            }

            // 監視を開放する
            if (this.RefreshWindowTimer != null)
            {
                this.RefreshWindowTimer.Stop();
                this.RefreshWindowTimer = null;
            }

            if (this.WatchLogTimer != null)
            {
                this.WatchLogTimer.Stop();
                this.WatchLogTimer.Dispose();
                this.WatchLogTimer = null;
            }

            // 全てのPanelを閉じる
            this.ClosePanels();
            OnePointTelopController.CloseTelops();

            // 設定を保存する
            Settings.Default.Save();
            SpellTimerTable.Save();
            OnePointTelopTable.Default.Save();

            // instanceを初期化する
            instance = null;
        }
Exemplo n.º 19
0
        /// <summary>
        /// 開始する
        /// </summary>
        public void Begin()
        {
            // 戦闘分析を初期化する
            CombatAnalyzer.Default.Initialize();

            // Panelリストを生成する
            this.SpellTimerPanels = new List<SpellTimerListWindow>();

            // ログバッファを生成する
            this.LogBuffer = new LogBuffer();

            // RefreshWindowタイマを開始する
            this.RefreshWindowTimer = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = new TimeSpan(0, 0, 0, 0, 100),
            };

            this.RefreshWindowTimer.Tick += this.RefreshWindowTimerOnTick;
            this.RefreshWindowTimer.Start();

            // ログ監視タイマを開始する
            this.WatchLogTimer = new System.Timers.Timer()
            {
                Interval = Settings.Default.RefreshInterval,
                AutoReset = true,
            };

            this.WatchLogTimer.Elapsed += (s, e) =>
            {
#if DEBUG
                var sw = Stopwatch.StartNew();
#endif
                try
                {
                    if (this.WatchLogTimer != null &&
                        this.WatchLogTimer.Enabled)
                    {
                        this.WatchLog();
                    }
                }
                catch (Exception ex)
                {
                    ActGlobals.oFormActMain.WriteExceptionLog(
                        ex,
                        Translate.Get("SpellTimerRefreshError"));
                }
                finally
                {
#if DEBUG
                    sw.Stop();
                    Debug.WriteLine(
                        DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " " +
                        "●WatchLog " + sw.Elapsed.TotalMilliseconds.ToString("N4") + "ms");
#endif
                }
            };

            this.WatchLogTimer.Start();
        }