Exemple #1
0
        /// <summary>
        /// </summary>
        public static void LoadFilters()
        {
            if (Constants.XFilters != null)
            {
                PluginViewModel.Instance.Filters.Clear();
                foreach (XElement xElement in Constants.XFilters.Descendants().Elements("Filter"))
                {
                    var xKey = (string)xElement.Attribute("Key");
                    if (!SharedRegEx.IsValidRegex(xKey))
                    {
                        continue;
                    }

                    var xLevel = (string)xElement.Element("Level");
                    var xType  = (string)xElement.Element("Type");
                    if (string.IsNullOrWhiteSpace(xKey) || string.IsNullOrWhiteSpace(xType))
                    {
                        return;
                    }

                    int level;
                    int.TryParse(xLevel, out level);
                    var radarFilterItem = new RadarFilterItem(xKey)
                    {
                        Level = level
                    };
                    radarFilterItem.Type = xType;
                    PluginViewModel.Instance.Filters.Add(radarFilterItem);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// </summary>
        public static void LoadFilters()
        {
            if (Constants.XFilters != null)
            {
                PluginViewModel.Instance.Filters.Clear();
                foreach (var xElement in Constants.XFilters.Descendants()
                         .Elements("Filter"))
                {
                    var xKey   = (string)xElement.Attribute("Key");
                    var xLevel = (string)xElement.Element("Level");
                    var xType  = (string)xElement.Element("Type");
                    if (String.IsNullOrWhiteSpace(xKey) || String.IsNullOrWhiteSpace(xType))
                    {
                        return;
                    }
                    int level;
                    Int32.TryParse(xLevel, out level);
                    var radarFilterItem = new RadarFilterItem
                    {
                        Key   = xKey,
                        Level = level
                    };
                    if (!SharedRegEx.IsValidRegex(radarFilterItem.Key))
                    {
                        continue;
                    }
                    radarFilterItem.RegEx = new Regex(radarFilterItem.Key, SharedRegEx.DefaultOptions);
                    switch (xType)
                    {
                    case "PC":
                        radarFilterItem.Type = Actor.Type.PC;
                        break;

                    case "Monster":
                        radarFilterItem.Type = Actor.Type.Monster;
                        break;

                    case "NPC":
                        radarFilterItem.Type = Actor.Type.NPC;
                        break;

                    case "Aetheryte":
                        radarFilterItem.Type = Actor.Type.Aetheryte;
                        break;

                    case "Gathering":
                        radarFilterItem.Type = Actor.Type.Gathering;
                        break;

                    case "Minion":
                        radarFilterItem.Type = Actor.Type.Minion;
                        break;
                    }
                    PluginViewModel.Instance.Filters.Add(radarFilterItem);
                }
            }
        }
 public static void Process(ChatLogEntry chatLogEntry)
 {
     try
     {
         var line = chatLogEntry.Line.Replace("  ", " ");
         foreach (var item in PluginViewModel.Instance.Events)
         {
             if (!item.Enabled)
             {
                 continue;
             }
             var resuccess = false;
             var check     = new Regex(item.RegEx);
             if (SharedRegEx.IsValidRegex(item.RegEx))
             {
                 var reg = check.Match(line);
                 if (reg.Success)
                 {
                     resuccess = true;
                 }
             }
             else
             {
                 resuccess = (item.RegEx == line);
             }
             if (!resuccess)
             {
                 continue;
             }
             var         soundEvent = item;
             Func <bool> playSound  = delegate
             {
                 var delay = soundEvent.Delay;
                 var timer = new Timer(delay > 0 ? delay * 1000 : 1);
                 ElapsedEventHandler timerEventHandler = null;
                 timerEventHandler = delegate
                 {
                     DispatcherHelper.Invoke(() => SoundPlayerHelper.Play(Constants.BaseDirectory, soundEvent.Sound));
                     timer.Elapsed -= timerEventHandler;
                 };
                 timer.Elapsed += timerEventHandler;
                 timer.Start();
                 return(true);
             };
             playSound.BeginInvoke(null, null);
         }
     }
     catch (Exception ex)
     {
         Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
     }
 }
Exemple #4
0
        /// <summary>
        /// </summary>
        private static void AddOrUpdateFilter()
        {
            var selectedKey = string.Empty;

            try {
                if (MainView.View.Filters.SelectedItems.Count == 1)
                {
                    selectedKey = GetValueBySelectedItem(MainView.View.Filters, "Key");
                }
            }
            catch (Exception ex) {
                Logging.Log(Logger, new LogItem(ex, true));
            }

            if (MainView.View.TKey.Text.Trim() == string.Empty || MainView.View.TLevel.Text.Trim() == string.Empty)
            {
                return;
            }

            var xKey = MainView.View.TKey.Text;

            if (!SharedRegEx.IsValidRegex(xKey))
            {
                return;
            }

            var radarFilterItem = new RadarFilterItem(xKey);
            int level;

            if (int.TryParse(MainView.View.TLevel.Text, out level))
            {
                radarFilterItem.Level = level;
            }

            radarFilterItem.Type = MainView.View.TType.Text;
            if (string.IsNullOrWhiteSpace(selectedKey))
            {
                PluginViewModel.Instance.Filters.Add(radarFilterItem);
            }
            else
            {
                var index = PluginViewModel.Instance.Filters.TakeWhile(@event => @event.Key != selectedKey).Count();
                PluginViewModel.Instance.Filters[index] = radarFilterItem;
            }

            MainView.View.Filters.UnselectAll();
            MainView.View.TKey.Text = string.Empty;
        }
Exemple #5
0
        /// <summary>
        /// </summary>
        private static void AddOrUpdateFilter()
        {
            var selectedKey = "";

            try
            {
                if (MainView.View.Filters.SelectedItems.Count == 1)
                {
                    selectedKey = GetValueBySelectedItem(MainView.View.Filters, "Key");
                }
            }
            catch (Exception ex)
            {
                Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
            }
            if (MainView.View.TKey.Text.Trim() == "" || MainView.View.TLevel.Text.Trim() == "")
            {
                return;
            }
            var xKey = MainView.View.TKey.Text;

            if (!SharedRegEx.IsValidRegex(xKey))
            {
                return;
            }
            var radarFilterItem = new RadarFilterItem(xKey);
            int level;

            if (Int32.TryParse(MainView.View.TLevel.Text, out level))
            {
                radarFilterItem.Level = level;
            }
            radarFilterItem.Type = Entity.Type[MainView.View.TType.Text];
            if (String.IsNullOrWhiteSpace(selectedKey))
            {
                PluginViewModel.Instance.Filters.Add(radarFilterItem);
            }
            else
            {
                var index = PluginViewModel.Instance.Filters.TakeWhile(@event => @event.Key != selectedKey)
                            .Count();
                PluginViewModel.Instance.Filters[index] = radarFilterItem;
            }
            MainView.View.Filters.UnselectAll();
            MainView.View.TKey.Text = "";
        }
Exemple #6
0
        public static void Process(ChatLogEntry chatLogEntry)
        {
            try
            {
                var line = chatLogEntry.Line.Replace("  ", " ");
                foreach (var item in PluginViewModel.Instance.Events.Where(e => e.Enabled))
                {
                    var resuccess = false;
                    var arguments = item.Arguments;
                    var tts       = item.TTS;
                    if (SharedRegEx.IsValidRegex(item.RegEx))
                    {
                        var reg = Regex.Match(line, item.RegEx);
                        if (reg.Success)
                        {
                            resuccess = true;
                            arguments = reg.Result(item.Arguments);
                            tts       = reg.Result(tts);
                        }
                    }
                    else
                    {
                        resuccess = (item.RegEx == line);
                    }
                    if (!resuccess)
                    {
                        continue;
                    }

                    ExecutLogEvent(item, arguments, tts);
                }
            }
            catch (Exception ex)
            {
                Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
            }
        }
Exemple #7
0
        /// <summary>
        /// </summary>
        public static void LoadMonsterRegEx()
        {
            if (Constants.XRegEx == null)
            {
                return;
            }

            foreach (XElement xElement in Constants.XRegEx.Descendants().Elements("Monster"))
            {
                var xKey      = (string)xElement.Attribute("Key");
                var xLanguage = (string)xElement.Attribute("Language");
                var xValue    = (string)xElement.Element("Value");
                if (string.IsNullOrWhiteSpace(xKey) || string.IsNullOrWhiteSpace(xValue))
                {
                    continue;
                }

                if (!SharedRegEx.IsValidRegex(xValue))
                {
                    continue;
                }

                var regex = new Regex(xValue, SharedRegEx.DefaultOptions);
                switch (xLanguage)
                {
                case "EN":

                    #region Handle English Regular Expressions

                    switch (xKey)
                    {
                    case "Damage":
                        MonsterRegEx.DamageEn = regex;
                        break;

                    case "DamageAuto":
                        MonsterRegEx.DamageAutoEn = regex;
                        break;

                    case "Failed":
                        MonsterRegEx.FailedEn = regex;
                        break;

                    case "FailedAuto":
                        MonsterRegEx.FailedAutoEn = regex;
                        break;

                    case "Actions":
                        MonsterRegEx.ActionsEn = regex;
                        break;

                    case "Items":
                        MonsterRegEx.ItemsEn = regex;
                        break;

                    case "Cure":
                        MonsterRegEx.CureEn = regex;
                        break;

                    case "BeneficialGain":
                        MonsterRegEx.BeneficialGainEn = regex;
                        break;

                    case "BeneficialLose":
                        MonsterRegEx.BeneficialLoseEn = regex;
                        break;

                    case "DetrimentalGain":
                        MonsterRegEx.DetrimentalGainEn = regex;
                        break;

                    case "DetrimentalLose":
                        MonsterRegEx.DetrimentalLoseEn = regex;
                        break;
                    }

                    #endregion

                    break;

                case "FR":

                    #region Handle French Regular Expressions

                    switch (xKey)
                    {
                    case "Damage":
                        MonsterRegEx.DamageFr = regex;
                        break;

                    case "DamageAuto":
                        MonsterRegEx.DamageAutoFr = regex;
                        break;

                    case "Failed":
                        MonsterRegEx.FailedFr = regex;
                        break;

                    case "FailedAuto":
                        MonsterRegEx.FailedAutoFr = regex;
                        break;

                    case "Actions":
                        MonsterRegEx.ActionsFr = regex;
                        break;

                    case "Items":
                        MonsterRegEx.ItemsFr = regex;
                        break;

                    case "Cure":
                        MonsterRegEx.CureFr = regex;
                        break;

                    case "BeneficialGain":
                        MonsterRegEx.BeneficialGainFr = regex;
                        break;

                    case "BeneficialLose":
                        MonsterRegEx.BeneficialLoseFr = regex;
                        break;

                    case "DetrimentalGain":
                        MonsterRegEx.DetrimentalGainFr = regex;
                        break;

                    case "DetrimentalLose":
                        MonsterRegEx.DetrimentalLoseFr = regex;
                        break;
                    }

                    #endregion

                    break;

                case "JA":

                    #region Handle Japanese Regular Expressions

                    switch (xKey)
                    {
                    case "Damage":
                        MonsterRegEx.DamageJa = regex;
                        break;

                    case "DamageAuto":
                        MonsterRegEx.DamageAutoJa = regex;
                        break;

                    case "Failed":
                        MonsterRegEx.FailedJa = regex;
                        break;

                    case "FailedAuto":
                        MonsterRegEx.FailedAutoJa = regex;
                        break;

                    case "Actions":
                        MonsterRegEx.ActionsJa = regex;
                        break;

                    case "Items":
                        MonsterRegEx.ItemsJa = regex;
                        break;

                    case "Cure":
                        MonsterRegEx.CureJa = regex;
                        break;

                    case "BeneficialGain":
                        MonsterRegEx.BeneficialGainJa = regex;
                        break;

                    case "BeneficialLose":
                        MonsterRegEx.BeneficialLoseJa = regex;
                        break;

                    case "DetrimentalGain":
                        MonsterRegEx.DetrimentalGainJa = regex;
                        break;

                    case "DetrimentalLose":
                        MonsterRegEx.DetrimentalLoseJa = regex;
                        break;
                    }

                    #endregion

                    break;

                case "DE":

                    #region Handle German Regular Expressions

                    switch (xKey)
                    {
                    case "Damage":
                        MonsterRegEx.DamageDe = regex;
                        break;

                    case "DamageAuto":
                        MonsterRegEx.DamageAutoDe = regex;
                        break;

                    case "Failed":
                        MonsterRegEx.FailedDe = regex;
                        break;

                    case "FailedAuto":
                        MonsterRegEx.FailedAutoDe = regex;
                        break;

                    case "Actions":
                        MonsterRegEx.ActionsDe = regex;
                        break;

                    case "Items":
                        MonsterRegEx.ItemsDe = regex;
                        break;

                    case "Cure":
                        MonsterRegEx.CureDe = regex;
                        break;

                    case "BeneficialGain":
                        MonsterRegEx.BeneficialGainDe = regex;
                        break;

                    case "BeneficialLose":
                        MonsterRegEx.BeneficialLoseDe = regex;
                        break;

                    case "DetrimentalGain":
                        MonsterRegEx.DetrimentalGainDe = regex;
                        break;

                    case "DetrimentalLose":
                        MonsterRegEx.DetrimentalLoseDe = regex;
                        break;
                    }

                    #endregion

                    break;

                case "ZH":

                    #region Handle Chinese Regular Expressions

                    switch (xKey)
                    {
                    case "Damage":
                        MonsterRegEx.DamageZh = regex;
                        break;

                    case "DamageAuto":
                        MonsterRegEx.DamageAutoZh = regex;
                        break;

                    case "Failed":
                        MonsterRegEx.FailedZh = regex;
                        break;

                    case "FailedAuto":
                        MonsterRegEx.FailedAutoZh = regex;
                        break;

                    case "Actions":
                        MonsterRegEx.ActionsZh = regex;
                        break;

                    case "Items":
                        MonsterRegEx.ItemsZh = regex;
                        break;

                    case "Cure":
                        MonsterRegEx.CureZh = regex;
                        break;

                    case "BeneficialGain":
                        MonsterRegEx.BeneficialGainZh = regex;
                        break;

                    case "BeneficialLose":
                        MonsterRegEx.BeneficialLoseZh = regex;
                        break;

                    case "DetrimentalGain":
                        MonsterRegEx.DetrimentalGainZh = regex;
                        break;

                    case "DetrimentalLose":
                        MonsterRegEx.DetrimentalLoseZh = regex;
                        break;
                    }

                    #endregion

                    break;
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// </summary>
        private static void AddOrUpdateFilter()
        {
            var selectedKey = "";

            try
            {
                if (MainView.View.Filters.SelectedItems.Count == 1)
                {
                    selectedKey = GetValueBySelectedItem(MainView.View.Filters, "Key");
                }
            }
            catch (Exception ex)
            {
                Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
            }
            if (MainView.View.TKey.Text.Trim() == "" || MainView.View.TLevel.Text.Trim() == "")
            {
                return;
            }
            var radarFilterItem = new RadarFilterItem
            {
                Key = MainView.View.TKey.Text
            };
            int level;

            if (Int32.TryParse(MainView.View.TLevel.Text, out level))
            {
                radarFilterItem.Level = level;
            }
            switch (MainView.View.TType.Text)
            {
            case "PC":
                radarFilterItem.Type = Actor.Type.PC;
                break;

            case "Monster":
                radarFilterItem.Type = Actor.Type.Monster;
                break;

            case "NPC":
                radarFilterItem.Type = Actor.Type.NPC;
                break;

            case "Aetheryte":
                radarFilterItem.Type = Actor.Type.Aetheryte;
                break;

            case "Gathering":
                radarFilterItem.Type = Actor.Type.Gathering;
                break;

            case "Minion":
                radarFilterItem.Type = Actor.Type.Minion;
                break;
            }
            if (SharedRegEx.IsValidRegex(radarFilterItem.Key))
            {
                radarFilterItem.RegEx = new Regex(radarFilterItem.Key, SharedRegEx.DefaultOptions);
            }
            if (String.IsNullOrWhiteSpace(selectedKey))
            {
                PluginViewModel.Instance.Filters.Add(radarFilterItem);
            }
            else
            {
                var index = PluginViewModel.Instance.Filters.TakeWhile(@event => @event.Key != selectedKey)
                            .Count();
                PluginViewModel.Instance.Filters[index] = radarFilterItem;
            }
            MainView.View.Filters.UnselectAll();
            MainView.View.TKey.Text = "";
        }
Exemple #9
0
        public static void Process(ChatLogEntry chatLogEntry)
        {
            try
            {
                // setup variables
                var timeStampColor = Settings.Default.TimeStampColor.ToString();
                var timeStamp      = chatLogEntry.TimeStamp.ToString("[HH:mm:ss] ");
                var line           = chatLogEntry.Line.Replace("  ", " ");
                var rawLine        = line;
                var color          = (Constants.Colors.ContainsKey(chatLogEntry.Code)) ? Constants.Colors[chatLogEntry.Code][0] : "FFFFFF";
                var isLS           = Constants.Linkshells.ContainsKey(chatLogEntry.Code);
                line = isLS ? Constants.Linkshells[chatLogEntry.Code] + line : line;
                var playerName = "";

                // handle tabs
                if (CheckMode(chatLogEntry.Code, Constants.ChatPublic))
                {
                    playerName = line.Substring(0, line.IndexOf(":", StringComparison.Ordinal));
                    line       = line.Replace(playerName + ":", "");
                }
                if (Settings.Default.EnableAll)
                {
                    Common.Constants.FD.AppendFlow(timeStamp, playerName, line, new[]
                    {
                        timeStampColor, "#" + color
                    }, MainView.View.AllFD._FDR);
                }
                DispatcherHelper.Invoke(delegate
                {
                    foreach (var flowDoc in PluginViewModel.Instance.Tabs.Select(ti => (xFlowDocument)((TabItem)ti).Content))
                    {
                        var resuccess          = false;
                        var xRegularExpression = flowDoc.RegEx.Text;
                        switch (xRegularExpression)
                        {
                        case "*":
                            resuccess = true;
                            break;

                        default:
                            try
                            {
                                var check = new Regex(xRegularExpression);
                                if (SharedRegEx.IsValidRegex(xRegularExpression))
                                {
                                    var reg = check.Match(line);
                                    if (reg.Success)
                                    {
                                        resuccess = true;
                                    }
                                }
                            }
                            catch
                            {
                                resuccess = true;
                            }
                            break;
                        }
                        if (resuccess && flowDoc.Codes.Items.Contains(chatLogEntry.Code))
                        {
                            Common.Constants.FD.AppendFlow(timeStamp, playerName, line, new[]
                            {
                                timeStampColor, "#" + color
                            }, flowDoc._FDR);
                        }
                    }
                });
                // handle translation
                if (Settings.Default.EnableTranslate)
                {
                    if (CheckMode(chatLogEntry.Code, Constants.ChatSay) && Settings.Default.TranslateSay)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                    if (CheckMode(chatLogEntry.Code, Constants.ChatTell) && Settings.Default.TranslateTell)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                    if (CheckMode(chatLogEntry.Code, Constants.ChatParty) && Settings.Default.TranslateParty)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                    if (CheckMode(chatLogEntry.Code, Constants.ChatShout) && Settings.Default.TranslateShout)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                    if (CheckMode(chatLogEntry.Code, Constants.ChatYell) && Settings.Default.TranslateYell)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                    if (CheckMode(chatLogEntry.Code, Constants.ChatLS) && Settings.Default.TranslateLS)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                    if (CheckMode(chatLogEntry.Code, Constants.ChatFC) && Settings.Default.TranslateFC)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                    if (CheckMode(chatLogEntry.Code, Constants.ChatAlliance) && Settings.Default.TranslateAlliance)
                    {
                        Translate.GetAutomaticResult(rawLine, chatLogEntry.JP);
                    }
                }
                // handle debug tab
                if (Settings.Default.ShowASCIIDebug)
                {
                    var asciiString = "";
                    for (var j = 0; j < chatLogEntry.Bytes.Length; j++)
                    {
                        asciiString += chatLogEntry.Bytes[j].ToString(CultureInfo.CurrentUICulture) + " ";
                    }
                    asciiString = asciiString.Trim();
                    Common.Constants.FD.AppendFlow("", "", asciiString, new[]
                    {
                        "", "#FFFFFFFF"
                    }, MainView.View.DebugFD._FDR);
                }
                if (Settings.Default.EnableDebug)
                {
                    var raw = String.Format("{0}[{1}]{2}", chatLogEntry.Raw.Substring(0, 8), chatLogEntry.Code, chatLogEntry.Raw.Substring(12));
                    Common.Constants.FD.AppendFlow("", "", raw, new[]
                    {
                        "", "#FFFFFFFF"
                    }, MainView.View.DebugFD._FDR);
                }
            }
            catch (Exception ex)
            {
                Logging.Log(LogManager.GetCurrentClassLogger(), "", ex);
            }
        }