Exemple #1
0
        public bool Parse()
        {
            if (!_msgParser.Parse())
            {
                return(false);
            }
            _dict = _msgParser.GetSpecificData(106021, 107000);
            if (_dict == null)
            {
                return(false);
            }

            _IsParsed = true;
            return(true);
        }
Exemple #2
0
        public static bool LoadConfig()
        {
            StreamReader file;
            try
            {
                file = File.OpenText("PerkEditor.cfg");
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot open the config file.");
                return false;
            }

            try
            {
                string rec = file.ReadLine();
                Regex regexp = new Regex(@"([^=]+)=([^=]+)");
                Match match = regexp.Match(rec);
                if (!match.Success || !match.Groups[1].Value.Equals("server"))
                {
                    MessageBox.Show("Cannot parse the config file.");
                    return false;
                }
                ServerPath = match.Groups[2].Value;
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot parse the config file.");
                return false;
            }
            MsgParser = new FOCommon.Parsers.MSGParser(ServerPath + "/text/engl/FOGAME.MSG");
            if (!MsgParser.Parse())
            {
                MessageBox.Show("Cannot parse FOGAME.MSG.");
                return false;
            }

            try
            {
                StreamReader reader = new StreamReader(ServerPath + "/scripts/_defines.fos");

                Regex expr = new Regex(@"#pragma[\s]+crdata[\s]+""[\s]*([^\s]+)[\s]+([^\s]+)[\s]+([^\s]+)[\s]*""");
                while (!reader.EndOfStream)
                {
                    string s = reader.ReadLine();
                    Match match = expr.Match(s);
                    if (!match.Success) continue;
                    //MessageBox.Show(match.Groups[1].Value + "," + match.Groups[2].Value + "," + match.Groups[3].Value);
                    if (match.Groups[1].Value.Equals("Stat"))
                    {
                        StatBegin = Int32.Parse(match.Groups[2].Value);
                        StatEnd = Int32.Parse(match.Groups[3].Value);
                    }
                    else if (match.Groups[1].Value.Equals("Skill"))
                    {
                        SkillBegin = Int32.Parse(match.Groups[2].Value);
                        SkillEnd = Int32.Parse(match.Groups[3].Value);
                    }
                    else if (match.Groups[1].Value.Equals("Perk"))
                    {
                        PerkBegin = Int32.Parse(match.Groups[2].Value);
                        PerkEnd = Int32.Parse(match.Groups[3].Value);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot open _defines.fos.");
                return false;
            }
            MakeNames();
            return true;
        }
Exemple #3
0
        public bool Parse()
        {
            if (!File.Exists(_fileName))
            {
                Utils.Log(_fileName + " doesn't exist. Can't parse data.");
                return(false);
            }

            _lines.Clear();
            _lines.AddRange(File.ReadAllLines(_fileName, Encoding.GetEncoding("Windows-1251")));

            bool parseMode = false;
            bool isNode    = true;

            Node node      = null;
            var  languages = new List <string>();

            _textStrings.Parse();
            var langEndLine = new Regex("^\\[.*\\]");

            int answerNum = 0;
            int nodeNum   = 0;

            _dialog = new Dialog.Dialog();

            int parseLine = 0;

            foreach (string line in _lines)
            {
                parseLine++;
                if (line == "[dialog]")
                {
                    parseMode = true;
                    continue;
                }

                if (parseLine == 2)
                {
                    _dialog.Comment = line;
                }

                if (line.Contains("lang="))
                {
                    string langStr = line.Substring(5, line.Length - 5);
                    languages.AddRange(langStr.Split(' '));
                    _dialog.LanguageTrees = languages;

                    foreach (String lang in languages)
                    {
                        ParseLanguageStrings(langEndLine, lang);
                    }
                }

                if (!parseMode)
                {
                    continue;
                }
                if (String.IsNullOrEmpty(line))
                {
                    break;
                }

                if (line == "&")
                {
                    continue;
                }
                String[] parts = line.Split(' ');
                if (isNode)
                {
                    node = ParseNode(langEndLine, languages, parts, ref nodeNum);
                }
                else // It's an answer
                {
                    var ans = ParseAnswer(answerNum, langEndLine, parts, languages, nodeNum);
                    node.Answers.Add(ans);
                }
                if (IsLastTok(parts, '@'))
                {
                    _dialog.Nodes.Add(node);
                    isNode    = true;
                    answerNum = 0;
                }
                else
                {
                    answerNum++;
                    isNode = false;
                }

                if (IsLastTok(parts, '&'))
                {
                    _dialog.Nodes.Add(node);
                    parseMode = false;
                }
            }
            return(true);
        }
Exemple #4
0
        public static bool LoadConfig()
        {
            StreamReader file;

            try
            {
                file = File.OpenText("PerkEditor.cfg");
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot open the config file.");
                return(false);
            }

            try
            {
                string rec    = file.ReadLine();
                Regex  regexp = new Regex(@"([^=]+)=([^=]+)");
                Match  match  = regexp.Match(rec);
                if (!match.Success || !match.Groups[1].Value.Equals("server"))
                {
                    MessageBox.Show("Cannot parse the config file.");
                    return(false);
                }
                ServerPath = match.Groups[2].Value;
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot parse the config file.");
                return(false);
            }
            MsgParser = new FOCommon.Parsers.MSGParser(ServerPath + "/text/engl/FOGAME.MSG");
            if (!MsgParser.Parse())
            {
                MessageBox.Show("Cannot parse FOGAME.MSG.");
                return(false);
            }

            try
            {
                StreamReader reader = new StreamReader(ServerPath + "/scripts/_defines.fos");

                Regex expr = new Regex(@"[\s]*#[\s]*pragma[\s]+crdata[\s]+""[\s]*([^\s]+)[\s]+([^\s]+)[\s]+([^\s]+)[\s]*""");
                while (!reader.EndOfStream)
                {
                    string s     = reader.ReadLine();
                    Match  match = expr.Match(s);
                    if (!match.Success)
                    {
                        continue;
                    }
                    //MessageBox.Show(match.Groups[1].Value + "," + match.Groups[2].Value + "," + match.Groups[3].Value);
                    if (match.Groups[1].Value.Equals("Stat"))
                    {
                        StatBegin = Int32.Parse(match.Groups[2].Value);
                        StatEnd   = Int32.Parse(match.Groups[3].Value);
                    }
                    else if (match.Groups[1].Value.Equals("Skill"))
                    {
                        SkillBegin = Int32.Parse(match.Groups[2].Value);
                        SkillEnd   = Int32.Parse(match.Groups[3].Value);
                    }
                    else if (match.Groups[1].Value.Equals("Perk"))
                    {
                        PerkBegin = Int32.Parse(match.Groups[2].Value);
                        PerkEnd   = Int32.Parse(match.Groups[3].Value);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Cannot parse _defines.fos.");
                return(false);
            }
            MakeNames();
            return(true);
        }