Esempio n. 1
0
        /// <summary>
        /// ログを一行読取った
        /// </summary>
        /// <param name="isImport">Importか?</param>
        /// <param name="logInfo">ログ情報</param>
        private void oFormActMain_OnLogLineRead(bool isImport, LogLineEventArgs logInfo)
        {
            if (isImport)
            {
                return;
            }

#if false
            Debug.WriteLine(logInfo.logLine);
#endif

            var logLine = logInfo.logLine.Trim();

            // ジョブに変化あり?
            if (logLine.Contains("にチェンジした。") || logLine.Contains("You change to "))
            {
                FF14PluginHelper.RefreshPlayer();
            }

            // パーティに変化あり?
            if (ptmember == null ||
                logLine.Contains("パーティを解散しました。") ||
                logLine.Contains("がパーティに参加しました。") ||
                logLine.Contains("がパーティから離脱しました。") ||
                logLine.Contains("をパーティから離脱させました。") ||
                logLine.Contains("の攻略を開始した。") ||
                logLine.Contains("の攻略を終了した。") ||
                (logLine.Contains("You join ") && logLine.Contains("'s party.")) ||
                logLine.Contains("You left the party.") ||
                logLine.Contains("You dissolve the party.") ||
                logLine.Contains("The party has been disbanded.") ||
                logLine.Contains("joins the party.") ||
                logLine.Contains("has left the party.") ||
                logLine.Contains("was removed from the party."))
            {
                Task.Run(() =>
                {
                    Thread.Sleep(5 * 1000);
                    RefreshPTList();
                }).ContinueWith((t) =>
                {
                    t.Dispose();
                });
            }

            // ペットIDのCacheを更新する
            var player = FF14PluginHelper.GetPlayer();
            if (player != null)
            {
                var jobName = Job.GetJobName(player.Job);
                Debug.WriteLine("JOB NAME!! " + jobName);
                if (jobName == "巴術士" || jobName == "ARC" ||
                    jobName == "学者" || jobName == "SCH" ||
                    jobName == "召喚士" || jobName == "SMN")
                {
                    if (logLine.Contains(player.Name + "の「サモン") || logLine.Contains("You cast Summon"))
                    {
                        Task.Run(() =>
                        {
                            Thread.Sleep(5 * 1000);
                            RefreshPetID();
                        }).ContinueWith((t) =>
                        {
                            t.Dispose();
                        });
                    }

                    if (petidZone != ActGlobals.oFormActMain.CurrentZone)
                    {
                        Task.Run(() =>
                        {
                            lock (lockPetidObject)
                            {
                                var count = 0;
                                while (petidZone != ActGlobals.oFormActMain.CurrentZone)
                                {
                                    Thread.Sleep(15 * 1000);
                                    RefreshPetID();
                                    count++;

                                    if (count >= 6)
                                    {
                                        petidZone = ActGlobals.oFormActMain.CurrentZone;
                                        break;
                                    }
                                }
                            }
                        }).ContinueWith((t) =>
                        {
                            t.Dispose();
                        });
                    }
                }
            }

            lock (this.buffer)
            {
                this.buffer.Add(logLine);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// ログ行を返す
        /// </summary>
        /// <returns>
        /// ログ行の配列</returns>
        public IReadOnlyList <string> GetLogLines()
        {
            var playerRefreshed = false;
            var partyRefreshed  = false;

            // 最後のログから1min間が空いた?
            if ((DateTime.Now - this.lastLogineTimestamp).TotalMinutes >= 1.0d)
            {
                FF14PluginHelper.RefreshPlayer();
                playerRefreshed = true;

                RefreshPartyList();
                partyRefreshed = true;
            }

            if (logInfoQueue.IsEmpty)
            {
                return(EMPTY_STRING_LIST);
            }

            var list         = new List <string>(logInfoQueue.Count);
            var partyChanged = false;
            var jobChanged   = false;
            var summoned     = false;
            var zoneChanged  = false;

            LogLineEventArgs logInfo;

            while (logInfoQueue.TryDequeue(out logInfo))
            {
                string logLine = logInfo.logLine.Trim();
                // ジョブに変化あり?
                if (!jobChanged)
                {
                    if (IsJobChanged(logLine))
                    {
                        jobChanged = true;
                        if (!playerRefreshed)
                        {
                            FF14PluginHelper.RefreshPlayer();
                            playerRefreshed = true;
                        }

                        if (!partyRefreshed)
                        {
                            RefreshPartyList();
                            partyRefreshed = true;
                        }
                    }
                }

                // パーティに変化あり
                if (!partyChanged)
                {
                    if (IsPartyChanged(logLine))
                    {
                        partyChanged = true;
                    }
                }

                if (!(summoned && zoneChanged))
                {
                    // ペットIDのCacheを更新する
                    var player = FF14PluginHelper.GetPlayer();
                    if (player != null)
                    {
                        var jobName = Job.GetJobName(player.Job);
                        if (player.AsJob().IsSummoner())
                        {
                            if (logLine.Contains(player.Name + "の「サモン") ||
                                logLine.Contains("You cast Summon"))
                            {
                                summoned = true;
                            }

                            if (petIdCheckedZone != ActGlobals.oFormActMain.CurrentZone)
                            {
                                zoneChanged = true;
                            }
                        }
                    }
                }

                list.Add(logLine);
                // ログファイルに出力する
                this.AppendLogFile(logLine);
            }

            if (partyChanged)
            {
                Task.Run(async() =>
                {
                    await Task.Delay(TimeSpan.FromSeconds(5));
                    RefreshPartyList();
                });
            }

            if (summoned)
            {
                Task.Run(async() =>
                {
                    await Task.Delay(TimeSpan.FromSeconds(5));
                    RefreshPetID();
                });
            }

            if (zoneChanged)
            {
                var oldSource = petIdRefreshTaskCancelTokenSource;
                if (oldSource != null)
                {
                    lock (oldSource)
                    {
                        if (!oldSource.IsCancellationRequested)
                        {
                            try
                            {
                                oldSource.Cancel();
                            }
                            catch { }
                        }
                    }
                }

                var newSource = petIdRefreshTaskCancelTokenSource = new CancellationTokenSource();
                var token     = newSource.Token;
                var count     = 0;

                Task.Run(async() =>
                {
                    while (petIdCheckedZone != ActGlobals.oFormActMain.CurrentZone)
                    {
                        await Task.Delay(TimeSpan.FromSeconds(15));

                        RefreshPetID();
                        count++;

                        if (count >= 6)
                        {
                            return;
                        }
                    }
                }, token);
            }

            // ログのタイムスタンプを記録する
            this.lastLogineTimestamp = DateTime.Now;

            return(list);
        }
Esempio n. 3
0
        /// <summary>
        /// ログを一行読取った
        /// </summary>
        /// <param name="isImport">Importか?</param>
        /// <param name="logInfo">ログ情報</param>
        private void oFormActMain_OnLogLineRead(bool isImport, LogLineEventArgs logInfo)
        {
            if (isImport)
            {
                return;
            }

#if false
            Debug.WriteLine(logInfo.logLine);
#endif

            var logLine = logInfo.logLine.Trim();

            // 最後のログから1min間が空いた?
            if ((DateTime.Now - this.lastLogineTimestamp).TotalMinutes >= 1.0d)
            {
                FF14PluginHelper.RefreshPlayer();
                RefreshPTList();
            }

            // ジョブに変化あり?
            if (logLine.Contains("にチェンジした。") ||
                logLine.Contains("You change to "))
            {
                FF14PluginHelper.RefreshPlayer();
                RefreshPTList();
            }

            // パーティに変化あり?
            if (enabledPartyMemberPlaceHolder)
            {
                if (ptmember == null ||
                    replacementsByJobs == null ||
                    logLine.Contains("パーティを解散しました。") ||
                    logLine.Contains("がパーティに参加しました。") ||
                    logLine.Contains("がパーティから離脱しました。") ||
                    logLine.Contains("をパーティから離脱させました。") ||
                    logLine.Contains("の攻略を開始した。") ||
                    logLine.Contains("の攻略を終了した。") ||
                    (logLine.Contains("You join ") && logLine.Contains("'s party.")) ||
                    logLine.Contains("You left the party.") ||
                    logLine.Contains("You dissolve the party.") ||
                    logLine.Contains("The party has been disbanded.") ||
                    logLine.Contains("joins the party.") ||
                    logLine.Contains("has left the party.") ||
                    logLine.Contains("was removed from the party."))
                {
                    Task.Run(() =>
                    {
                        Thread.Sleep(5 * 1000);
                        RefreshPTList();
                    });
                }
            }

            // ペットIDのCacheを更新する
            var player = FF14PluginHelper.GetPlayer();
            if (player != null)
            {
                var jobName = Job.GetJobName(player.Job);
#if DEBUG
                Debug.WriteLine("JOB NAME!! " + jobName);
#endif
                if (jobName == "巴術士" || jobName == "ARC" ||
                    jobName == "学者" || jobName == "SCH" ||
                    jobName == "召喚士" || jobName == "SMN")
                {
                    if (logLine.Contains(player.Name + "の「サモン") ||
                        logLine.Contains("You cast Summon"))
                    {
                        Task.Run(() =>
                        {
                            Thread.Sleep(5 * 1000);
                            RefreshPetID();
                        });
                    }

                    if (petidZone != ActGlobals.oFormActMain.CurrentZone)
                    {
                        Task.Run(() =>
                        {
                            lock (lockPetidObject)
                            {
                                var count = 0;
                                while (petidZone != ActGlobals.oFormActMain.CurrentZone)
                                {
                                    Thread.Sleep(15 * 1000);
                                    RefreshPetID();
                                    count++;

                                    if (count >= 6)
                                    {
                                        petidZone = ActGlobals.oFormActMain.CurrentZone;
                                        break;
                                    }
                                }
                            }
                        });
                    }
                }
            }

            lock (this.buffer)
            {
                this.buffer.Add(logLine);

                // ログのタイムスタンプを記録する
                this.lastLogineTimestamp = DateTime.Now;
            }

            // ログファイルに出力する
            this.AppendLogFile(logLine);
        }