public static void ShowTitleCard(
            string title,
            int tryCount,
            DateTime recordingTime)
        {
            if (window == null)
            {
                window = new TitleCardView();
            }

            window.VideoTitle    = title;
            window.TryCount      = tryCount;
            window.RecordingTime = recordingTime;

            window.Show();

            if (!window.Config.IsAlwaysShow)
            {
                WPFHelper.BeginInvoke(async() =>
                {
                    await Task.Delay(TimeSpan.FromSeconds(2.7));
                    window.Close();
                    window = null;
                });
            }
        }
 public static void CloseTitleCard()
 {
     if (window != null)
     {
         window.Close();
         window = null;
     }
 }
Exemplo n.º 3
0
        public void DetectCapture(
            XIVLog xivlog)
        {
            if (!xivlog.Log.StartsWith("00:") &&
                !xivlog.Log.StartsWith("01:") &&
                !xivlog.Log.StartsWith("02:") &&
                !xivlog.Log.StartsWith("19:") &&
                !xivlog.Log.StartsWith("21:"))
            {
                return;
            }

            // 攻略を開始した
            var match = ContentStartLogRegex.Match(xivlog.Log);

            if (match.Success)
            {
                this.contentName = match.Groups["content"]?.Value;

                var contentName = !string.IsNullOrEmpty(this.contentName) ?
                                  this.contentName :
                                  ActGlobals.oFormActMain.CurrentZone;

                if (Config.Instance.TryCountContentName != contentName ||
                    (DateTime.Now - Config.Instance.TryCountTimestamp) >=
                    TimeSpan.FromHours(Config.Instance.TryCountResetInterval))
                {
                    this.TryCount = 0;
                }

                return;
            }

            // 攻略を終了した
            match = ContentEndLogRegex.Match(xivlog.Log);
            if (match.Success)
            {
                this.FinishRecording();
                this.contentName = string.Empty;
                WPFHelper.Invoke(() => TitleCardView.CloseTitleCard());
                return;
            }

            var isStart = StartCountdownRegex.IsMatch(xivlog.Log);

            if (!isStart)
            {
                isStart = FeastStartRegex.IsMatch(xivlog.Log);
                if (isStart)
                {
                    this.inFeast     = true;
                    this.contentName = ActGlobals.oFormActMain.CurrentZone;

                    if (Config.Instance.TryCountContentName != this.contentName ||
                        (DateTime.Now - Config.Instance.TryCountTimestamp) >=
                        TimeSpan.FromHours(Config.Instance.TryCountResetInterval))
                    {
                        this.TryCount = 0;
                    }
                }
            }

            if (isStart ||
                xivlog.Log.Contains("/xivlog rec"))
            {
                SystemSounds.Beep.Play();
                this.deathCount = 0;
                this.StartRecording();
                return;
            }

            var isCancel = xivlog.Log.EndsWith("戦闘開始カウントがキャンセルされました。");

            if (isCancel)
            {
                this.TryCount--;
            }

            if (isCancel ||
                xivlog.Log.Contains("/xivlog stop") ||
                StopVideoKeywords.Any(x => xivlog.Log.Contains(x)) ||
                (this.inFeast && FeastEndRegex.IsMatch(xivlog.Log)))
            {
                this.FinishRecording();
                SystemSounds.Beep.Play();
                return;
            }

            // Player change
            match = PlayerChangedLogRegex.Match(xivlog.Log);
            if (match.Success)
            {
                this.defeatedLog = $"19:{match.Groups["player"]?.Value} was defeated";
                return;
            }

            // Player defeated
            if (xivlog.Log.StartsWith(this.defeatedLog))
            {
                this.deathCount++;
                return;
            }
        }