示例#1
0
        // true if merged back to previous..
        public static bool MergeEntries(JournalEntry prev, JournalEntry je)
        {
            if (prev != null)
            {
                if (je.EventTypeID == JournalTypeEnum.FuelScoop && prev.EventTypeID == JournalTypeEnum.FuelScoop)  // merge scoops
                {
                    EliteDangerousCore.JournalEvents.JournalFuelScoop jfs     = je as EliteDangerousCore.JournalEvents.JournalFuelScoop;
                    EliteDangerousCore.JournalEvents.JournalFuelScoop jfsprev = prev as EliteDangerousCore.JournalEvents.JournalFuelScoop;
                    jfsprev.Scooped += jfs.Scooped;
                    jfsprev.Total    = jfs.Total;
                    //System.Diagnostics.Debug.WriteLine("Merge FS " + jfsprev.EventTimeUTC);
                    return(true);
                }
                else if (je.EventTypeID == JournalTypeEnum.Friends && prev.EventTypeID == JournalTypeEnum.Friends) // merge friends
                {
                    EliteDangerousCore.JournalEvents.JournalFriends jfprev = prev as EliteDangerousCore.JournalEvents.JournalFriends;
                    EliteDangerousCore.JournalEvents.JournalFriends jf     = je as EliteDangerousCore.JournalEvents.JournalFriends;
                    jfprev.AddFriend(jf);
                    //System.Diagnostics.Debug.WriteLine("Merge Friends " + jfprev.EventTimeUTC + " " + jfprev.NameList.Count);
                    return(true);
                }
            }

            return(false);
        }
        public void AddFriend(JournalFriends next)
        {
            if (StatusList == null)     // if first time we added, move to status list format
            {
                StatusList = new List <FriendStatus>()
                {
                    StatusEnum
                };
                NameList = new List <string>()
                {
                    Name
                };
                Status = Name = string.Empty;
            }

            StatusList.Add(next.StatusEnum);
            NameList.Add(next.Name);

            OfflineCount = next.StatusEnum == FriendStatus.Offline ? 1 : 0;
            OnlineCount  = next.StatusEnum == FriendStatus.Online ? 1 : 0;
        }
        public void AddFriend(JournalFriends next)
        {
            if (StatusList == null)     // if first time we added, move to status list format
            {
                StatusList = new List <string>()
                {
                    Status
                };
                NameList = new List <string>()
                {
                    Name
                };
                Status = Name = string.Empty;
            }

            string stat = next.Status;

            StatusList.Add(stat);
            NameList.Add(next.Name);

            OfflineCount += stat.Equals("offline", System.StringComparison.InvariantCultureIgnoreCase) ? 1 : 0;
            OnlineCount  += stat.Equals("online", System.StringComparison.InvariantCultureIgnoreCase) ? 1 : 0;
        }
        // this allows entries to be merged or discarded before any processing
        // true if to discard
        public static bool MergeOrDiscardEntries(JournalEntry prev, JournalEntry je)
        {
            if (prev != null && !EliteConfigInstance.InstanceOptions.DisableMerge)
            {
                bool prevsame = je.EventTypeID == prev.EventTypeID;

                if (prevsame)
                {
                    if (je.EventTypeID == JournalTypeEnum.FuelScoop)  // merge scoops
                    {
                        EliteDangerousCore.JournalEvents.JournalFuelScoop jfs     = je as EliteDangerousCore.JournalEvents.JournalFuelScoop;
                        EliteDangerousCore.JournalEvents.JournalFuelScoop jfsprev = prev as EliteDangerousCore.JournalEvents.JournalFuelScoop;
                        jfsprev.Scooped += jfs.Scooped;
                        jfsprev.Total    = jfs.Total;
                        //System.Diagnostics.Debug.WriteLine("Merge FS " + jfsprev.EventTimeUTC);
                        return(true);
                    }
                    else if (je.EventTypeID == JournalTypeEnum.Friends) // merge friends
                    {
                        EliteDangerousCore.JournalEvents.JournalFriends jfprev = prev as EliteDangerousCore.JournalEvents.JournalFriends;
                        EliteDangerousCore.JournalEvents.JournalFriends jf     = je as EliteDangerousCore.JournalEvents.JournalFriends;
                        jfprev.AddFriend(jf);
                        //System.Diagnostics.Debug.WriteLine("Merge Friends " + jfprev.EventTimeUTC + " " + jfprev.NameList.Count);
                        return(true);
                    }
                    else if (je.EventTypeID == JournalTypeEnum.FSSSignalDiscovered)
                    {
                        var jdprev = prev as EliteDangerousCore.JournalEvents.JournalFSSSignalDiscovered;
                        var jd     = je as EliteDangerousCore.JournalEvents.JournalFSSSignalDiscovered;
                        jdprev.Add(jd);
                        return(true);
                    }
                    else if (je.EventTypeID == JournalTypeEnum.ShipTargeted)
                    {
                        var jdprev = prev as EliteDangerousCore.JournalEvents.JournalShipTargeted;
                        var jd     = je as EliteDangerousCore.JournalEvents.JournalShipTargeted;
                        jdprev.Add(jd);
                        return(true);
                    }
                    else if (je.EventTypeID == JournalTypeEnum.UnderAttack)
                    {
                        var jdprev = prev as EliteDangerousCore.JournalEvents.JournalUnderAttack;
                        var jd     = je as EliteDangerousCore.JournalEvents.JournalUnderAttack;
                        jdprev.Add(jd.Target);
                        return(true);
                    }
                    else if (je.EventTypeID == JournalTypeEnum.ReceiveText)
                    {
                        var jdprev = prev as EliteDangerousCore.JournalEvents.JournalReceiveText;
                        var jd     = je as EliteDangerousCore.JournalEvents.JournalReceiveText;

                        // merge if same channel
                        if (jd.Channel == jdprev.Channel)
                        {
                            jdprev.Add(jd);
                            return(true);
                        }
                    }
                    else if (je.EventTypeID == JournalTypeEnum.FSSAllBodiesFound)
                    {
                        var jdprev = prev as EliteDangerousCore.JournalEvents.JournalFSSAllBodiesFound;
                        var jd     = je as EliteDangerousCore.JournalEvents.JournalFSSAllBodiesFound;

                        // throw away if same..
                        if (jdprev.SystemName == jd.SystemName && jdprev.Count == jd.Count) // if same, we just waste the repeater, ED sometimes spews out multiples
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }