Example #1
0
        /// <summary>
        /// XML化する
        /// </summary>
        /// <param name="t"></param>
        /// <returns>XML</returns>
        public static Task <string> ToXMLAsync(
            this ITrigger t)
        => Task.Run(() =>
        {
            if (t == null)
            {
                return(string.Empty);
            }

            var xws = new XmlWriterSettings()
            {
                OmitXmlDeclaration = true,
                Indent             = true,
            };

            var ns = new XmlSerializerNamespaces();
            ns.Add(string.Empty, string.Empty);

            var sb = new StringBuilder();
            using (var xw = XmlWriter.Create(sb, xws))
            {
                var xs = new XmlSerializer(t.GetType());
                WPFHelper.Invoke(() => xs.Serialize(xw, t, ns));
            }

            sb.Replace("utf-16", "utf-8");

            return(sb.ToString() + Environment.NewLine);
        });
        public static void ShowTimeline(
            TimelineModel timelineModel)
        {
            if (!TimelineSettings.Instance.Enabled ||
                !TimelineSettings.Instance.OverlayVisible)
            {
                return;
            }

            // 有効な表示データが含まれていない?
            if (!timelineModel.ExistsActivities())
            {
                return;
            }

            WPFHelper.Invoke(() =>
            {
                if (TimelineView == null)
                {
                    TimelineView = new TimelineOverlay();
                    TimelineView.Show();
                }

                TimelineView.Model = timelineModel;

                ChangeClickthrough(TimelineSettings.Instance.Clickthrough);

                TimelineView.OverlayVisible = true;
            });
        }
        /// <summary>
        /// 終了
        /// </summary>
        public virtual void End()
        {
            MainWorker.Instance.GetDataMethod           -= this.GetDataDelegate;
            MainWorker.Instance.UpdateOverlayDataMethod -= this.UpdateOverlayDataDelegate;

            lock (MainWorker.Instance.ViewRefreshLocker)
            {
                WPFHelper.Invoke(() =>
                {
                    foreach (var item in this.ViewList)
                    {
                        item.ViewModel?.Dispose();
                        item.View?.Close();
                    }

                    this.ViewList.Clear();
                });

                this.nameVM     = null;
                this.hpVM       = null;
                this.hpBarVM    = null;
                this.actionVM   = null;
                this.distanceVM = null;
            }
        }
Example #4
0
 public void CloseNotice()
 {
     WPFHelper.Invoke(() =>
     {
         this.Model = null;
         this.Close();
     });
 }
 public static void CloseNotice()
 {
     WPFHelper.Invoke(() =>
     {
         if (NoticeView != null)
         {
             NoticeView.DataContext = null;
             NoticeView.Close();
             NoticeView = null;
         }
     });
 }
 public static void CloseTimeline()
 {
     WPFHelper.Invoke(() =>
     {
         if (TimelineView != null)
         {
             TimelineView.Model       = null;
             TimelineView.DataContext = null;
             TimelineView.Close();
             TimelineView = null;
         }
     });
 }
Example #7
0
        /// <summary>
        /// アップデートを行う
        /// </summary>
        private void Update()
        {
            if ((DateTime.Now - Settings.Instance.LastUpdateDateTime).TotalHours
                >= Settings.UpdateCheckInterval)
            {
                var message = UpdateChecker.Update(
                    "ACT.UltraScouter",
                    Assembly.GetExecutingAssembly());
                if (!string.IsNullOrWhiteSpace(message))
                {
                    this.Logger.Fatal(message);
                }

                Settings.Instance.LastUpdateDateTime = DateTime.Now;
                WPFHelper.Invoke(() => Settings.Instance.Save());
            }
        }
        public void ShowNotice()
        {
            if (!TimelineSettings.Instance.Enabled ||
                !TimelineSettings.Instance.OverlayVisible)
            {
                return;
            }

            if (!this.OverlayVisible)
            {
                WPFHelper.Invoke(() =>
                {
                    this.OverlayVisible = true;
                },
                                 DispatcherPriority.Background);
            }
        }
Example #9
0
        public void ShowNotice()
        {
            if (!TimelineSettings.Instance.Enabled ||
                !TimelineSettings.Instance.OverlayVisible)
            {
                return;
            }

            if (!this.OverlayVisible)
            {
                WPFHelper.Invoke(() =>
                {
                    this.IsClickthrough = this.Config.Clickthrough;
                    this.OverlayVisible = true;
                },
                                 DispatcherPriority.Normal);
            }
        }
        public static void ShowNotice()
        {
            if (!TimelineSettings.Instance.Enabled ||
                !TimelineSettings.Instance.OverlayVisible)
            {
                return;
            }

            WPFHelper.Invoke(() =>
            {
                if (NoticeView == null)
                {
                    NoticeView = new TimelineNoticeOverlay();
                    NoticeView.Show();
                }

                ChangeClickthrough(TimelineSettings.Instance.Clickthrough);
            });
        }
Example #11
0
        /// <summary>
        /// XMLからオブジェクト化する
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="xml">XML</param>
        /// <returns>オブジェクト</returns>
        public static Task <T> FromXMLAsync <T>(
            this T t,
            string xml) where T : class, ITrigger
        => Task.Run(() =>
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }

            var obj = default(T);

            using (var sr = new StringReader(xml))
                using (var xr = XmlReader.Create(sr))
                {
                    var xs = new XmlSerializer(typeof(T));
                    WPFHelper.Invoke(() =>
                    {
                        obj = xs.Deserialize(xr) as T;
                    });
                }

            return(obj);
        });
Example #12
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;
            }
        }
Example #13
0
        public Task <FFXIVReaderStartingResult> WaitForReaderToStartedAsync(
            TabPage baseTabPage) => Task.Run(() =>
        {
            var result = new FFXIVReaderStartingResult();

            lock (this)
            {
                // 旧の単独DLL版が存在したら念のため削除する
                var dll = Path.Combine(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                    "FFXIV_MemoryReader.dll");
                if (File.Exists(dll))
                {
                    var message = new StringBuilder();

                    try
                    {
                        File.Delete(dll);

                        message.Clear();
                        message.AppendLine($@"""FFXIV_MemoryReader.dll"" was deleted.");
                        message.AppendLine($@"Please, restart ACT.");
                        WPFHelper.BeginInvoke(() => ModernMessageBox.ShowDialog(
                                                  message.ToString(),
                                                  "Warning",
                                                  MessageBoxButton.OK));
                    }
                    catch (Exception)
                    {
                    }

                    if (File.Exists(dll))
                    {
                        message.Clear();
                        message.AppendLine($@"""FFXIV_MemoryReader.dll"" is exists yet.");
                        message.AppendLine($@"You should delete ""FFXIV_MemoryReader.dll"".");
                        message.AppendLine();
                        message.AppendLine("Path:");
                        message.AppendLine(dll);

                        WPFHelper.BeginInvoke(() => ModernMessageBox.ShowDialog(
                                                  message.ToString(),
                                                  "Warning",
                                                  MessageBoxButton.OK));
                    }
                }

                if (this.MemoryPlugin != null)
                {
                    result.Status = FFXIVReaderStartingStatus.AlreadyStarted;
                    return(result);
                }

                var succeeded = false;

                WPFHelper.Invoke(() =>
                {
                    var parentTabControl = baseTabPage.Parent as TabControl;
                    if (parentTabControl == null)
                    {
                        return;
                    }

                    var memoryReaderTabPage = new TabPage();
                    var dummyLabel          = new Label();
                    parentTabControl.TabPages.Add(memoryReaderTabPage);

                    this.tab     = parentTabControl;
                    this.tabPage = memoryReaderTabPage;

                    try
                    {
                        this.MemoryPlugin = new MemoryPlugin();
                        this.MemoryPlugin.InitPlugin(memoryReaderTabPage, dummyLabel);

                        succeeded = dummyLabel.Text.ContainsIgnoreCase("Started");

                        if (succeeded)
                        {
                            result.Status = FFXIVReaderStartingStatus.Started;
                        }
                        else
                        {
                            result.Status  = FFXIVReaderStartingStatus.Error;
                            result.Message = "Error occurred initializing FFXIV_MemoryReader.";
                            this.MemoryPlugin?.DeInitPlugin();
                            this.MemoryPlugin = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        result.Status    = FFXIVReaderStartingStatus.Error;
                        result.Message   = "Fatal error occurred initializing FFXIV_MemoryReader.";
                        result.Exception = ex;

                        ModernMessageBox.ShowDialog(
                            result.Message,
                            "Fatal Error",
                            MessageBoxButton.OK,
                            ex);
                    }
                },
                                 DispatcherPriority.Normal);

                this.IsAvailable = succeeded;
            }

            return(result);
        });