Example #1
0
        private void VisualSettingControl_Load(object sender, EventArgs e)
        {
            var colorSetDirectory = this.GetColorSetDirectory;

            if (Directory.Exists(colorSetDirectory))
            {
                this.OpenFileDialog.InitialDirectory = colorSetDirectory;
                this.SaveFileDialog.InitialDirectory = colorSetDirectory;
            }

            this.WidthNumericUpDown.Value  = this.BarSize.Width;
            this.HeightNumericUpDown.Value = this.BarSize.Height;

            this.RefreshSampleImage();

            this.ChangeFontItem.Click += (s1, e1) =>
            {
                var f = new FontDialogWindow();
                f.SetOwner(this.ParentForm);

                f.FontInfo = this.GetFontInfo();
                if (f.ShowDialog().Value)
                {
                    this.SetFontInfo(f.FontInfo);
                    this.RefreshSampleImage();
                }
            };

            this.ChangeFontColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.FontColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.FontColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeFontOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.FontOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.FontOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeWarningFontColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.WarningFontColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.WarningFontColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeWarningFontOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.WarningFontOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.WarningFontOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBarColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.BarColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.BarColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBarOutlineColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.BarOutlineColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.BarOutlineColor = this.ColorDialog.Color;
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBackgoundColorItem.Click += (s1, e1) =>
            {
                this.ColorDialog.Color = this.backgroundColor;
                if (this.ColorDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.backgroundColor = Color.FromArgb(
                        this.alphaDialog.Alpha,
                        this.ColorDialog.Color);
                    this.RefreshSampleImage();
                }
            };

            this.ChangeBackgroundAlphaItem.Click += (s1, e1) =>
            {
                this.alphaDialog.Alpha = this.backgroundColor.A;
                if (this.alphaDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    this.backgroundColor = Color.FromArgb(
                        this.alphaDialog.Alpha,
                        this.backgroundColor);
                    this.RefreshSampleImage();
                }
            };

            this.LoadColorSetItem.Click += (s1, e1) =>
            {
                if (this.OpenFileDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    using (var sr = new StreamReader(this.OpenFileDialog.FileName, new UTF8Encoding(false)))
                    {
                        var xs       = new XmlSerializer(typeof(ColorSet));
                        var colorSet = xs.Deserialize(sr) as ColorSet;
                        if (colorSet != null)
                        {
                            this.FontColor               = colorSet.FontColor.FromHTML();
                            this.FontOutlineColor        = colorSet.FontOutlineColor.FromHTML();
                            this.WarningFontColor        = colorSet.WarningFontColor.FromHTML();
                            this.WarningFontOutlineColor = colorSet.WarningFontOutlineColor.FromHTML();
                            this.BarColor        = colorSet.BarColor.FromHTML();
                            this.BarOutlineColor = colorSet.BarOutlineColor.FromHTML();
                            this.backgroundColor = string.IsNullOrWhiteSpace(colorSet.BackgroundColor) ?
                                                   Color.Transparent :
                                                   Color.FromArgb(colorSet.BackgroundAlpha, colorSet.BackgroundColor.FromHTML());

                            this.RefreshSampleImage();

                            // カラーパレットに登録する
                            this.ColorDialog.CustomColors = new int[]
                            {
                                ColorTranslator.ToOle(colorSet.FontColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.FontOutlineColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.BarColor.FromHTML()),
                                ColorTranslator.ToOle(colorSet.BarOutlineColor.FromHTML()),
                            };
                        }
                    }
                }
            };

            this.SaveColorSetItem.Click += (s1, e1) =>
            {
                if (string.IsNullOrWhiteSpace(this.SaveFileDialog.FileName))
                {
                    this.SaveFileDialog.FileName = "スペスペ配色セット.xml";
                }

                if (this.SaveFileDialog.ShowDialog(this) != DialogResult.Cancel)
                {
                    var colorSet = new ColorSet()
                    {
                        FontColor               = this.FontColor.ToHTML(),
                        FontOutlineColor        = this.FontOutlineColor.ToHTML(),
                        WarningFontColor        = this.WarningFontColor.ToHTML(),
                        WarningFontOutlineColor = this.WarningFontOutlineColor.ToHTML(),
                        BarColor        = this.BarColor.ToHTML(),
                        BarOutlineColor = this.BarOutlineColor.ToHTML(),
                        BackgroundColor = this.backgroundColor.ToHTML(),
                        BackgroundAlpha = this.backgroundColor.A,
                    };

                    using (var sw = new StreamWriter(this.SaveFileDialog.FileName, false, new UTF8Encoding(false)))
                    {
                        var xs = new XmlSerializer(typeof(ColorSet));
                        xs.Serialize(sw, colorSet);
                    }
                }
            };

            this.WidthNumericUpDown.ValueChanged += (s1, e1) =>
            {
                this.RefreshSampleImage();
            };

            this.HeightNumericUpDown.ValueChanged += (s1, e1) =>
            {
                this.RefreshSampleImage();
            };

            this.ResetSpellFontItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.Font = this.GetFontInfo();
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetSpellBarSizeItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.BarWidth  = this.BarSize.Width;
                    s.BarHeight = this.BarSize.Height;
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetSpellColorItem.Click += (s1, e1) =>
            {
                foreach (var s in SpellTimerTable.Table)
                {
                    s.FontColor               = this.FontColor.ToHTML();
                    s.FontOutlineColor        = this.FontOutlineColor.ToHTML();
                    s.WarningFontColor        = this.WarningFontColor.ToHTML();
                    s.WarningFontOutlineColor = this.WarningFontOutlineColor.ToHTML();
                    s.BarColor        = this.BarColor.ToHTML();
                    s.BarOutlineColor = this.BarOutlineColor.ToHTML();
                    s.BackgroundColor = this.backgroundColor.ToHTML();
                    s.BackgroundAlpha = this.backgroundColor.A;
                }

                SpellTimerCore.Default.ClosePanels();
                SpellTimerTable.Save();
            };

            this.ResetTelopFontItem.Click += (s1, e1) =>
            {
                foreach (var s in OnePointTelopTable.Default.Table)
                {
                    s.Font = this.GetFontInfo();
                }

                OnePointTelopController.CloseTelops();
                OnePointTelopTable.Default.Save();
            };

            this.ResetTelopColorItem.Click += (s1, e1) =>
            {
                foreach (var s in OnePointTelopTable.Default.Table)
                {
                    s.FontColor        = this.FontColor.ToHTML();
                    s.FontOutlineColor = this.FontOutlineColor.ToHTML();
                    s.BackgroundColor  = this.backgroundColor.ToHTML();
                    s.BackgroundAlpha  = this.backgroundColor.A;
                }

                OnePointTelopController.CloseTelops();
                OnePointTelopTable.Default.Save();
            };
        }
Example #2
0
        /// <summary>
        /// オプションのLoad
        /// </summary>
        private void LoadOption()
        {
            this.LoadSettingsOption();

            this.OverlayForceVisibleCheckBox.CheckedChanged += (s1, e1) =>
            {
                Settings.Default.OverlayForceVisible = this.OverlayForceVisibleCheckBox.Checked;
                Settings.Default.Save();
            };

            this.UseOtherThanFFXIVCheckbox.CheckedChanged += (s1, e1) =>
            {
                if (this.UseOtherThanFFXIVCheckbox.Checked)
                {
                    this.OverlayForceVisibleCheckBox.Checked  = true;
                    this.EnabledPTPlaceholderCheckBox.Checked = false;
                    this.ResetOnWipeOutCheckBox.Checked       = false;

                    this.OverlayForceVisibleCheckBox.Enabled  = false;
                    this.EnabledPTPlaceholderCheckBox.Enabled = false;
                    this.ResetOnWipeOutCheckBox.Enabled       = false;
                }
                else
                {
                    this.OverlayForceVisibleCheckBox.Enabled  = true;
                    this.EnabledPTPlaceholderCheckBox.Enabled = true;
                    this.ResetOnWipeOutCheckBox.Enabled       = true;
                }
            };

            this.SwitchOverlayButton.Click += (s1, e1) =>
            {
                Settings.Default.OverlayVisible = !Settings.Default.OverlayVisible;
                Settings.Default.Save();
                this.LoadSettingsOption();

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

            this.SwitchTelopButton.Click += (s1, e1) =>
            {
                Settings.Default.TelopAlwaysVisible = !Settings.Default.TelopAlwaysVisible;
                Settings.Default.Save();
                this.LoadSettingsOption();
            };

            this.LanguageComboBox.SelectedValueChanged += (s1, e1) =>
            {
                Language language = (Language)this.LanguageComboBox.SelectedItem;
                this.LanguageRestartLabel.Text = Utility.Translate.GetTranslationsFor(language.Value).GetString("RequiresRestart");
                Settings.Default.Language      = language.Value;
                Settings.Default.Save();
                this.LoadSettingsOption();
            };

            this.SaveLogCheckBox.CheckedChanged += (s1, e1) =>
            {
                this.SaveLogTextBox.Enabled = this.SaveLogCheckBox.Checked;
                this.SaveLogButton.Enabled  = this.SaveLogCheckBox.Checked;
            };

            this.SaveLogButton.Click += (s1, e1) =>
            {
                if (!string.IsNullOrWhiteSpace(this.SaveLogTextBox.Text))
                {
                    this.SaveLogFileDialog.FileName = this.SaveLogTextBox.Text;
                }

                if (this.SaveLogFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    this.SaveLogTextBox.Text = this.SaveLogFileDialog.FileName;
                }
            };

            Action action = new Action(() =>
            {
                if (Settings.Default.OverlayVisible)
                {
                    this.SwitchOverlayButton.Text = Translate.Get("OverlayDisplaySwitchIsOn");
                }
                else
                {
                    this.SwitchOverlayButton.Text = Translate.Get("OverlayDisplaySwitchIsOff");
                }
            });

            this.OptionTabPage.MouseHover       += (s1, e1) => action();
            this.SwitchOverlayButton.MouseHover += (s1, e1) => action();
        }
Example #3
0
        /// <summary>
        /// Commandとマッチングする
        /// </summary>
        /// <param name="logLines">
        /// ログ行</param>
        public static void MatchCommand(
            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().ToLower().Replace(@"""", string.Empty);
                var valueAsText = match.Groups["value"].ToString().ToLower();
                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.RefreshPTList();
                        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;
                }
            }   // loop end logLines

            // コマンドを実行したらシステム音を鳴らす
            if (commandDone)
            {
                SystemSounds.Asterisk.Play();
            }
        }   // method end
Example #4
0
        /// <summary>
        /// RefreshWindowTimerOnTick
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void RefreshWindowTimerOnTick(
            object sender,
            EventArgs e)
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif
            try
            {
                if (Interlocked.CompareExchange(ref settingsIsValid, VALID, INVALID) == INVALID)
                {
                    this.RefreshWindowTimer.Interval = TimeSpan.FromMilliseconds(Settings.Default.RefreshInterval);
                }

                if (this.RefreshWindowTimer != null &&
                    this.RefreshWindowTimer.IsEnabled)
                {
                    Logger.Update();

                    if (SpecialSpellTimerPlugin.ConfigPanel != null)
                    {
                        SpecialSpellTimerPlugin.ConfigPanel.UpdateMonitor();
                    }

                    // 有効なスペルとテロップのリストを取得する
                    var spellArray = SpellTimerTable.EnabledTable;
                    var telopArray = OnePointTelopTable.Default.EnabledTable;

                    if ((DateTime.Now.Second % 5) == 0)
                    {
                        // 不要なWindowを閉じる
                        OnePointTelopController.GarbageWindows(telopArray);
                        this.GarbageSpellPanelWindows(spellArray);
                    }

                    if (ActGlobals.oFormActMain == null)
                    {
                        this.HidePanels();

                        Thread.Sleep(1000);
                        return;
                    }

                    // FFXIVでの使用?
                    if (!Settings.Default.UseOtherThanFFXIV)
                    {
                        if ((DateTime.Now - this.LastFFXIVProcessDateTime).TotalSeconds >= 5.0d)
                        {
                            // FF14が起動していない?
                            if (FF14PluginHelper.GetFFXIVProcess == null)
                            {
                                if (!Settings.Default.OverlayForceVisible)
                                {
                                    this.ClosePanels();
                                    OnePointTelopController.CloseTelops();

                                    return;
                                }
                            }

                            this.LastFFXIVProcessDateTime = DateTime.Now;
                        }
                    }

                    // オーバーレイが非表示?
                    if (!Settings.Default.OverlayVisible)
                    {
                        this.HidePanels();
                        OnePointTelopController.HideTelops();
                        return;
                    }

                    // 非アクティブのとき非表示にする?
                    if (Settings.Default.HideWhenNotActive)
                    {
                        if (!this.IsActive())
                        {
                            this.HidePanels();
                            OnePointTelopController.HideTelops();
                            return;
                        }
                    }

                    // テロップWindowを表示する
                    OnePointTelopController.RefreshTelopWindows(telopArray);

                    // スペルWindowを表示する
                    this.RefreshSpellPanelWindows(spellArray);
                }
            }
            catch (Exception ex)
            {
                Logger.Write(Translate.Get("SpellTimerRefreshError"), ex);
            }
            finally
            {
#if DEBUG
                sw.Stop();
                Debug.WriteLine(
                    DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " " +
                    "◎RefreshWindow " + sw.Elapsed.TotalMilliseconds.ToString("N4") + "ms");
#endif
            }
        }
Example #5
0
        /// <summary>
        /// テロップ更新 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void TelopUpdateButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.TelopTitleTextBox.Text))
            {
                MessageBox.Show(
                    this,
                    Translate.Get("UpdateTelopNameTitle"),
                    "ACT.SpecialSpellTimer",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
                return;
            }

            var src = this.TelopDetailGroupBox.Tag as OnePointTelop;

            if (src != null)
            {
                src.Title              = this.TelopTitleTextBox.Text;
                src.Message            = this.TelopMessageTextBox.Text;
                src.Keyword            = this.TelopKeywordTextBox.Text;
                src.KeywordToHide      = this.TelopKeywordToHideTextBox.Text;
                src.RegexEnabled       = this.TelopRegexEnabledCheckBox.Checked;
                src.Delay              = (long)this.TelopDelayNumericUpDown.Value;
                src.DisplayTime        = (long)this.DisplayTimeNumericUpDown.Value;
                src.AddMessageEnabled  = this.EnabledAddMessageCheckBox.Checked;
                src.ProgressBarEnabled = this.TelopProgressBarEnabledCheckBox.Checked;
                src.FontColor          = this.TelopVisualSetting.FontColor.ToHTML();
                src.FontOutlineColor   = this.TelopVisualSetting.FontOutlineColor.ToHTML();
                src.FontFamily         = this.TelopVisualSetting.TextFont.Name;
                src.FontSize           = this.TelopVisualSetting.TextFont.Size;
                src.FontStyle          = (int)this.TelopVisualSetting.TextFont.Style;
                src.BackgroundColor    = this.TelopVisualSetting.BackgroundColor.ToHTML();
                src.BackgroundAlpha    = this.TelopVisualSetting.BackgroundColor.A;
                src.Left             = (double)this.TelopLeftNumericUpDown.Value;
                src.Top              = (double)this.TelopTopNumericUpDown.Value;
                src.MatchSound       = (string)this.TelopMatchSoundComboBox.SelectedValue ?? string.Empty;
                src.MatchTextToSpeak = this.TelopMatchTTSTextBox.Text;
                src.DelaySound       = (string)this.TelopDelaySoundComboBox.SelectedValue ?? string.Empty;
                src.DelayTextToSpeak = this.TelopDelayTTSTextBox.Text;

                if ((int)this.TelopLeftNumericUpDown.Tag != src.Left ||
                    (int)this.TelopTopNumericUpDown.Tag != src.Top)
                {
                    OnePointTelopController.SetLocation(
                        src.ID,
                        src.Left,
                        src.Top);
                }

                OnePointTelopTable.Default.Save();
                this.LoadTelopTable();

                // 一度全てのテロップを閉じる
                OnePointTelopController.CloseTelops();

                foreach (TreeNode node in this.TelopTreeView.Nodes)
                {
                    var ds = node.Tag as OnePointTelop;
                    if (ds != null)
                    {
                        if (ds.ID == src.ID)
                        {
                            this.TelopTreeView.SelectedNode = node;
                            break;
                        }
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource"></param>
        private void ShowTelopDetail(
            OnePointTelop dataSource)
        {
            var src = dataSource;

            if (src == null)
            {
                this.TelopDetailGroupBox.Visible = false;
                return;
            }

            this.TelopDetailGroupBox.Visible = true;

            this.TelopTitleTextBox.Text                  = src.Title;
            this.TelopMessageTextBox.Text                = src.Message;
            this.TelopKeywordTextBox.Text                = src.Keyword;
            this.TelopKeywordToHideTextBox.Text          = src.KeywordToHide;
            this.TelopRegexEnabledCheckBox.Checked       = src.RegexEnabled;
            this.TelopDelayNumericUpDown.Value           = src.Delay;
            this.DisplayTimeNumericUpDown.Value          = src.DisplayTime;
            this.EnabledAddMessageCheckBox.Checked       = src.AddMessageEnabled;
            this.TelopProgressBarEnabledCheckBox.Checked = src.ProgressBarEnabled;

            this.TelopVisualSetting.FontColor        = src.FontColor.FromHTML();
            this.TelopVisualSetting.FontOutlineColor = src.FontOutlineColor.FromHTML();
            this.TelopVisualSetting.FontColor        = src.FontColor.FromHTML();
            this.TelopVisualSetting.TextFont         = new Font(
                src.FontFamily,
                src.FontSize,
                (FontStyle)src.FontStyle);
            this.TelopVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                                                      Settings.Default.BackgroundColor :
                                                      Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.TelopVisualSetting.RefreshSampleImage();

            var left = (int)src.Left;
            var top  = (int)src.Top;

            double x, y;

            OnePointTelopController.GettLocation(
                src.ID,
                out x,
                out y);

            if (x != 0)
            {
                left = (int)x;
            }

            if (y != 0)
            {
                top = (int)y;
            }

            this.TelopLeftNumericUpDown.Value = left;
            this.TelopLeftNumericUpDown.Tag   = left;
            this.TelopTopNumericUpDown.Value  = top;
            this.TelopTopNumericUpDown.Tag    = top;

            this.TelopMatchSoundComboBox.SelectedValue = src.MatchSound;
            this.TelopMatchTTSTextBox.Text             = src.MatchTextToSpeak;

            this.TelopDelaySoundComboBox.SelectedValue = src.DelaySound;
            this.TelopDelayTTSTextBox.Text             = src.DelayTextToSpeak;

            // データソースをタグに突っ込んでおく
            this.TelopDetailGroupBox.Tag = src;
        }
Example #7
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 "pt":
                        TableCompiler.Instance.RefreshPlayerPlacceholder();
                        TableCompiler.Instance.RefreshPartyPlaceholders();
                        TableCompiler.Instance.RecompileSpells();
                        TableCompiler.Instance.RecompileTickers();
                        commandDone = true;
                        break;

                    case "pet":
                        TableCompiler.Instance.RefreshPetPlaceholder();
                        TableCompiler.Instance.RecompileSpells();
                        TableCompiler.Instance.RecompileTickers();
                        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)
                        {
                            TableCompiler.Instance.SetCustomPlaceholder(windowname.Trim(), valueAsText.Trim());

                            commandDone = true;
                        }

                        break;
                    }

                    break;

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

                            commandDone = true;
                        }
                        else if (windowname.Trim() != string.Empty)
                        {
                            TableCompiler.Instance.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
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource"></param>
        private void ShowTelopDetail(
            OnePointTelop dataSource)
        {
            var src = dataSource;

            if (src == null)
            {
                this.TelopDetailGroupBox.Visible = false;
                return;
            }

            this.TelopDetailGroupBox.Visible = true;

            this.TelopTitleTextBox.Text                  = src.Title;
            this.TelopMessageTextBox.Text                = src.Message;
            this.TelopKeywordTextBox.Text                = src.Keyword;
            this.TelopKeywordToHideTextBox.Text          = src.KeywordToHide;
            this.TelopRegexEnabledCheckBox.Checked       = src.RegexEnabled;
            this.TelopDelayNumericUpDown.Value           = src.Delay;
            this.DisplayTimeNumericUpDown.Value          = src.DisplayTime;
            this.EnabledAddMessageCheckBox.Checked       = src.AddMessageEnabled;
            this.TelopProgressBarEnabledCheckBox.Checked = src.ProgressBarEnabled;

            this.TelopVisualSetting.FontColor        = src.FontColor.FromHTML();
            this.TelopVisualSetting.FontOutlineColor = src.FontOutlineColor.FromHTML();
            this.TelopVisualSetting.FontColor        = src.FontColor.FromHTML();
            this.TelopVisualSetting.SetFontInfo(src.Font);
            this.TelopVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                                                      Settings.Default.BackgroundColor :
                                                      Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.TelopVisualSetting.RefreshSampleImage();

            var left = (int)src.Left;
            var top  = (int)src.Top;

            double x, y;

            OnePointTelopController.GettLocation(
                src.ID,
                out x,
                out y);

            if (x != 0)
            {
                left = (int)x;
            }

            if (y != 0)
            {
                top = (int)y;
            }

            this.TelopLeftNumericUpDown.Value = left;
            this.TelopLeftNumericUpDown.Tag   = left;
            this.TelopTopNumericUpDown.Value  = top;
            this.TelopTopNumericUpDown.Tag    = top;

            this.TelopMatchSoundComboBox.SelectedValue = src.MatchSound;
            this.TelopMatchTTSTextBox.Text             = src.MatchTextToSpeak;

            this.TelopDelaySoundComboBox.SelectedValue = src.DelaySound;
            this.TelopDelayTTSTextBox.Text             = src.DelayTextToSpeak;

            // データソースをタグに突っ込んでおく
            this.TelopDetailGroupBox.Tag = src;

            // ジョブ限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectJobButton.ForeColor = src.JobFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // ゾーン限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectZoneButton.ForeColor = src.ZoneFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // 条件設定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSetConditionButton.ForeColor =
                (src.TimersMustRunningForStart.Length != 0 || src.TimersMustStoppingForStart.Length != 0) ?
                Color.Blue :
                Button.DefaultForeColor;
        }
        /// <summary>
        /// RefreshWindowTimerOnTick
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void RefreshWindowTimerOnTick(
            object sender,
            EventArgs e)
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif
            try
            {
                if (this.RefreshWindowTimer != null &&
                    this.RefreshWindowTimer.IsEnabled)
                {
                    // 有効なスペルとテロップのリストを取得する
                    var spellArray = SpellTimerTable.EnabledTable;
                    var telopArray = OnePointTelopTable.Default.EnabledTable;

                    if ((DateTime.Now.Second % 5) == 0)
                    {
                        // 不要なWindowを閉じる
                        OnePointTelopController.GarbageWindows(telopArray);
                        this.GarbageSpellPanelWindows(spellArray);
                    }

                    if (ActGlobals.oFormActMain == null ||
                        !ActGlobals.oFormActMain.Visible)
                    {
                        this.HidePanels();

                        Thread.Sleep(1000);
                        return;
                    }

                    if ((DateTime.Now - this.LastFFXIVProcessDateTime).TotalSeconds >= 5.0d)
                    {
                        // FF14が起動していない?
                        if (FF14PluginHelper.GetFFXIVProcess == null)
                        {
                            if (!Settings.Default.OverlayForceVisible)
                            {
                                this.ClosePanels();
                                OnePointTelopController.CloseTelops();

                                return;
                            }
                        }

                        this.LastFFXIVProcessDateTime = DateTime.Now;
                    }

                    // オーバーレイが非表示?
                    if (!Settings.Default.OverlayVisible)
                    {
                        this.HidePanels();
                        OnePointTelopController.HideTelops();
                        return;
                    }

                    // テロップWindowを表示する
                    OnePointTelopController.RefreshTelopWindows(telopArray);

                    // スペルWindowを表示する
                    this.RefreshSpellPanelWindows(spellArray);
                }
            }
            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]") + " " +
                    "◎RefreshWindow " + sw.Elapsed.TotalMilliseconds.ToString("N4") + "ms");
#endif
            }
        }
Example #10
0
        private void RefreshWindowCore()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif
            try
            {
                if (Interlocked.CompareExchange(ref settingsIsValid, VALID, INVALID) == INVALID)
                {
                    this.refreshWindowTimer.Interval =
                        TimeSpan.FromMilliseconds(Settings.Default.RefreshInterval);
                }

                if (this.refreshWindowTimer != null &&
                    this.refreshWindowTimer.IsEnabled)
                {
                    Logger.Update();

                    // 有効なスペルとテロップのリストを取得する
                    var spells = TableCompiler.Instance.SpellList;
                    var telops = TableCompiler.Instance.TickerList;

                    if ((DateTime.Now.Second % 30) == 0)
                    {
                        // 不要なWindowを閉じる
                        OnePointTelopController.GarbageWindows(telops);
                        this.GarbageSpellPanelWindows(spells);
                    }

                    if (ActGlobals.oFormActMain == null)
                    {
                        this.HidePanels();

                        Thread.Sleep(1000);
                        return;
                    }

                    // FFXIVでの使用?
                    if (!Settings.Default.UseOtherThanFFXIV)
                    {
                        if ((DateTime.Now - this.LastFFXIVProcessDateTime).TotalSeconds >= 5.0d)
                        {
                            // FF14が起動していない?
                            if (FFXIV.Instance.Process == null)
                            {
                                if (!Settings.Default.OverlayForceVisible)
                                {
                                    this.ClosePanels();
                                    OnePointTelopController.CloseTelops();

                                    return;
                                }
                            }

                            this.LastFFXIVProcessDateTime = DateTime.Now;
                        }
                    }

                    // オーバーレイが非表示?
                    if (!Settings.Default.OverlayVisible)
                    {
                        this.HidePanels();
                        OnePointTelopController.HideTelops();
                        return;
                    }

                    // 非アクティブのとき非表示にする?
                    if (Settings.Default.HideWhenNotActive)
                    {
                        if (!this.IsActive())
                        {
                            this.HidePanels();
                            OnePointTelopController.HideTelops();
                            return;
                        }
                    }

                    // テロップWindowを表示する
                    OnePointTelopController.RefreshTelopWindows(telops);

                    // スペルWindowを表示する
                    this.RefreshSpellPanelWindows(spells);
                }
            }
            finally
            {
#if DEBUG
                sw.Stop();
                Debug.WriteLine(
                    DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " " +
                    "◎RefreshWindow " + sw.Elapsed.TotalMilliseconds.ToString("N4") + "ms");
#endif
            }
        }
        /// <summary>
        /// Windowを更新する
        /// </summary>
        private void RefreshWindow()
        {
#if DEBUG
            var sw1 = Stopwatch.StartNew();
#endif
            // 有効なSpellリストを取得する
            var spellArray = SpellTimerTable.EnabledTable;

            // 不要なWindowを閉じる
            if (this.SpellTimerPanels != null)
            {
                var removeList = new List <SpellTimerListWindow>();
                foreach (var panel in this.SpellTimerPanels)
                {
                    // パネルの位置を保存する
                    var setting = (
                        from x in PanelSettings.Default.SettingsTable
                        where
                        x.PanelName == panel.PanelName
                        select
                        x).FirstOrDefault();

                    if (setting == null)
                    {
                        setting = PanelSettings.Default.SettingsTable.NewPanelSettingsRow();
                        PanelSettings.Default.SettingsTable.AddPanelSettingsRow(setting);
                    }

                    setting.PanelName = panel.PanelName;
                    setting.Left      = panel.Left;
                    setting.Top       = panel.Top;

                    // 毎分0秒の時保存する
                    if (DateTime.Now.Second == 0)
                    {
                        PanelSettings.Default.Save();
                    }

                    // スペルリストに存在しないパネルを閉じる
                    if (!spellArray.Any(x => x.Panel == panel.PanelName))
                    {
                        ActInvoker.Invoke(() => panel.Close());
                        removeList.Add(panel);
                    }
                }

                foreach (var item in removeList)
                {
                    this.SpellTimerPanels.Remove(item);
                }
            }

#if DEBUG
            sw1.Stop();
            Debug.WriteLine("Refresh ClosePanels ->" + sw1.ElapsedMilliseconds.ToString("N0") + "ms");
#endif

            // ACTが起動していない?
            if (ActGlobals.oFormActMain == null ||
                !ActGlobals.oFormActMain.Visible)
            {
                this.HidePanels();
                this.RefreshInterval = 1000;
                return;
            }

            if ((DateTime.Now - this.LastFFXIVProcessDateTime).TotalSeconds >= 5.0d)
            {
                // FF14が起動していない?
                if (FF14PluginHelper.GetFFXIVProcess == null)
                {
                    this.RefreshInterval = 1000;

                    if (!Settings.Default.OverlayForceVisible)
                    {
                        this.ClosePanels();
                        OnePointTelopController.CloseTelops();
                        return;
                    }
                }

                this.LastFFXIVProcessDateTime = DateTime.Now;
            }

            // タイマの間隔を標準に戻す
            this.RefreshInterval = Settings.Default.RefreshInterval;

            // ログを取り出す
#if DEBUG
            var sw2 = Stopwatch.StartNew();
#endif
            var logLines = this.LogBuffer.GetLogLines();
#if DEBUG
            sw2.Stop();
            Debug.WriteLine("Refresh GetLog ->" + sw2.ElapsedMilliseconds.ToString("N0") + "ms");
#endif

            // テロップとマッチングする
#if DEBUG
            var sw3 = Stopwatch.StartNew();
#endif
            OnePointTelopController.Match(
                logLines);
#if DEBUG
            sw3.Stop();
            Debug.WriteLine("Refresh MatchTelop ->" + sw3.ElapsedMilliseconds.ToString("N0") + "ms");
#endif

            // スペルリストとマッチングする
#if DEBUG
            var sw4 = Stopwatch.StartNew();
#endif
            this.MatchSpells(
                spellArray,
                logLines);
#if DEBUG
            sw4.Stop();
            Debug.WriteLine("Refresh MatchSpell ->" + sw4.ElapsedMilliseconds.ToString("N0") + "ms");
#endif

            // コマンドとマッチングする
            TextCommandController.MatchCommand(
                logLines);

            // オーバーレイが非表示?
            if (!Settings.Default.OverlayVisible)
            {
                this.HidePanels();
                OnePointTelopController.HideTelops();
                return;
            }

            // Windowを表示する
#if DEBUG
            var sw5 = Stopwatch.StartNew();
#endif
            var panelNames = spellArray.Select(x => x.Panel.Trim()).Distinct();
            foreach (var name in panelNames)
            {
                var w = this.SpellTimerPanels.Where(x => x.PanelName == name).FirstOrDefault();
                if (w == null)
                {
                    w = new SpellTimerListWindow()
                    {
                        Title     = "SpecialSpellTimer - " + name,
                        PanelName = name,
                    };

                    this.SpellTimerPanels.Add(w);

                    // クリックスルー?
                    if (Settings.Default.ClickThroughEnabled)
                    {
                        w.ToTransparentWindow();
                    }

                    w.Show();
                }

                w.SpellTimers = (
                    from x in spellArray
                    where
                    x.Panel.Trim() == name
                    select
                    x).ToArray();

                // ドラッグ中じゃない?
                if (!w.IsDragging)
                {
                    w.RefreshSpellTimer();
                }
            }

#if DEBUG
            sw5.Stop();
            Debug.WriteLine("Refresh RefreshSpell ->" + sw5.ElapsedMilliseconds.ToString("N0") + "ms");
#endif
        }