Ejemplo n.º 1
0
        public bool Parse( DefineParser itemPids )
        {
            if( !File.Exists( _fileName ) )
                return (false);

            string currentLine = String.Empty;
            List<string> lines = new List<string>( File.ReadAllLines( _fileName ) );

            try
            {
                Dictionary<string, string> bags = new Dictionary<string, string>();
                Dictionary<string, string> defines = new Dictionary<string, string>();

                Match match = null;
                string reAlias = "^(.*?)[\t ]*=[\t ]*(.*?)$";
                string reBag = "^[\t ]*bag_([0-9]+)$";
                foreach( string line in lines )
                {
                    if( line.Length == 0 || Regex.Match( line, "^[\t ]*#" ).Success )
                        continue;

                    match = Regex.Match( line, reAlias );
                    if( match.Success )
                    {
                        string bag = match.Groups[1].Value;
                        string def = match.Groups[2].Value;

                        match = Regex.Match( bag, reBag );
                        if( match.Success )
                        {
                            if( !bags.ContainsKey( bag ) )
                                bags.Add( bag, def );
                            else
                                bags[bag] = def;
                        }
                        else
                        {
                            if( !defines.ContainsKey( bag ) )
                                defines.Add( bag, def );
                            else
                                defines[bag] = def;
                        }
                    }
                }
            }
            catch( IndexOutOfRangeException ex )
            {
                Utils.Log( "Failed to parse line: '" + currentLine + "' in " + _fileName );
                SetError( _fileName, ex, currentLine );
                return false;
            }

            return (true);
        }
Ejemplo n.º 2
0
        public frmFilter(DefineParser DefineParser, Filtering Filter)
        {
            InitializeComponent();
            this.Filter = Filter;
            if (Filter == null)
                this.Filter = new Filtering();
            this.DefineParser = DefineParser;
            List<Item> items = ItemPid.GetItems();
            foreach (Item item in items)
                cmbItem.Items.Add(item.Define);
            cmbPerk.Items.AddRange(DefineParser.GetDefinesByPrefix("PE_").Keys.ToArray<String>());

            cmbItem.Sorted = true;
            cmbPerk.Sorted = true;
        }
Ejemplo n.º 3
0
        public frmEncounterGroupEditor(List<IZone> Zones, FOGAMEParser GameParser, EncounterGroupParser GroupParser, DialogListParser DialogParser, MSGParser FOObj, MSGParser FODLG, DefineParser DefineParser)
        {
            this.Zones = Zones;
            this.FODLG = FODLG;
            this.DefineParser = DefineParser;
            this.GameParser = GameParser;
            this.GroupParser = GroupParser;
            this.DialogParser = DialogParser;
            InitializeComponent();
            LoadCrTypeDefines();
            LoadArmorProtos(Config.PathArmorProtos, Config.PathHelmetProtos, FOObj);

            foreach (ArmorProto ItProt in ArmorProtos)
                AddArmorProtoToCmb(ItProt, cmbArmorPid);
            foreach (ArmorProto ItProt in HelmetProtos)
                AddArmorProtoToCmb(ItProt, cmbHelmetPid);

            cmbArmorPid.SelectedIndex = 0;
            cmbHelmetPid.SelectedIndex = 0;

            this.frmFilter = new frmFilter(this.DefineParser, null);
        }
Ejemplo n.º 4
0
        public static void Init()
        {
            if (!File.Exists(Config.PathItemPid))
            {
                Message.Show("Can't find ITEMPID.H", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, true);
                Environment.Exit(0);
                return;
            }

            DefineParser defineParser = new DefineParser();
            if (!defineParser.ReadDefines(Config.PathItemPid))
            {
                Utils.HandleParseError(defineParser.Error, Config.PathItemPid);
                return;
            }

            foreach (KeyValuePair<string, int> kvp in defineParser.Defines)
            {
                Items.Add(new Item(kvp.Value, kvp.Key));
            }

            Utils.Log("Found " + Items.Count + " PIDs in ITEMPID.H");
            IsInitialized = true;
        }
Ejemplo n.º 5
0
 public WorldMapFormat(DefineParser WorldMapHeaderDefines)
 {
     this.Defines = WorldMapHeaderDefines;
 }
Ejemplo n.º 6
0
        private void LoadCrTypeDefines()
        {
            if (!File.Exists(Config.PathScriptsDir + "_basetypes.fos"))
                return;

            DefineParser CrTypeParser = new DefineParser();
            if (!CrTypeParser.ReadDefines(Config.PathScriptsDir + "_basetypes.fos"))
                Utils.HandleParseError(CrTypeParser.Error, Config.PathScriptsDir + "_basetypes.fos");
            CrTypeDefines = CrTypeParser.Defines;
        }
Ejemplo n.º 7
0
        public bool Parse(DefineParser itemPids)
        {
            if (!File.Exists(_fileName))
            {
                return(false);
            }

            string        currentLine = String.Empty;
            List <string> lines       = new List <string>(File.ReadAllLines(_fileName));

            try
            {
                Dictionary <string, string> bags    = new Dictionary <string, string>();
                Dictionary <string, string> defines = new Dictionary <string, string>();

                Match  match   = null;
                string reAlias = "^(.*?)[\t ]*=[\t ]*(.*?)$";
                string reBag   = "^[\t ]*bag_([0-9]+)$";
                foreach (string line in lines)
                {
                    if (line.Length == 0 || Regex.Match(line, "^[\t ]*#").Success)
                    {
                        continue;
                    }

                    match = Regex.Match(line, reAlias);
                    if (match.Success)
                    {
                        string bag = match.Groups[1].Value;
                        string def = match.Groups[2].Value;

                        match = Regex.Match(bag, reBag);
                        if (match.Success)
                        {
                            if (!bags.ContainsKey(bag))
                            {
                                bags.Add(bag, def);
                            }
                            else
                            {
                                bags[bag] = def;
                            }
                        }
                        else
                        {
                            if (!defines.ContainsKey(bag))
                            {
                                defines.Add(bag, def);
                            }
                            else
                            {
                                defines[bag] = def;
                            }
                        }
                    }
                }
            }
            catch (IndexOutOfRangeException ex)
            {
                Utils.Log("Failed to parse line: '" + currentLine + "' in " + _fileName);
                SetError(_fileName, ex, currentLine);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        public static bool LoadDefines(Config Cfg)
        {
            ClearLists();
            DefineParser defines = new DefineParser();
            string CurrentLine="";
            string CurrentFile="";

            if (!defines.ReadDefines(@Cfg.PathDefines))
            {
                Message.Show("Can't find " + Cfg.PathDefines, MessageBoxButtons.OK, MessageBoxIcon.Error, true);
                return false;
            }

            try
            {
                Defines = defines.Defines;

                ItemPid.Add("", 0); // none
                WeaponPerks.Add("", 0);

                CurrentFile = "_defines.fos";
                // Read stuff from parsed defines from _defines.fos
                foreach (KeyValuePair<string, int> kvp in Defines)
                {
                    CurrentLine = kvp.Key;
                    if (kvp.Key.StartsWith("ITEM_TYPE_")) ItemTypes.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 10) : kvp.Key), kvp.Value);
                    if (kvp.Key.StartsWith("CALIBER_")) Calibers.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 8) : kvp.Key), kvp.Value);
                    if (kvp.Key.StartsWith("WEAPON_PERK_")) WeaponPerks.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 12) : kvp.Key), kvp.Value);
                    if (kvp.Key.StartsWith("DAMAGE_")) DamageTypes.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 7) : kvp.Key), kvp.Value);
                }

                if (!File.Exists(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "DefineNames.lst"))
                {
                    Message.Show("Can't find DefinesNames.lst", MessageBoxButtons.OK, MessageBoxIcon.Error, true);
                    return false;
                }

                List<String> Lines = new List<String>(File.ReadAllLines(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "DefineNames.lst", Encoding.UTF8));
                bool PAnim1 = false;
                bool PAnim2 = false;
                bool PSkills = false;
                int BaseNum = 0;
                char[] Sep = { ' ', '\t' };
                CurrentFile = "DefineNames.lst";
                foreach (String Line in Lines)
                {
                    CurrentLine = Line;
                    if (Line.Length == 0 || Line[0] == '#')
                        continue;

                    if (Line[0] == '*')
                    {
                        PAnim1 = false;
                        PAnim2 = false;
                        PSkills = false;
                        BaseNum = Int32.Parse(Line.Remove(0, 1));
                    }

                    if (Line.Length < 6)
                        continue;

                    string[] Parts = Line.Split(Sep, StringSplitOptions.RemoveEmptyEntries);
                    if (PAnim1) Anim1.Add(Parts[1], BaseNum + Int32.Parse(Parts[0]));
                    if (PAnim2) Anim2.Add(Parts[1], BaseNum + Int32.Parse(Parts[0]));
                    if (PSkills) Skills.Add(Parts[1], BaseNum + Int32.Parse(Parts[0]));

                    if (Line.Contains("---ANIM1---")) PAnim1 = true;
                    else if (Line.Contains("---ANIM2---")) PAnim2 = true;
                    else if (Line.Contains("---SKILLS---")) PSkills = true;
                }

                if (!File.Exists(Cfg.PathDataFolder + Path.DirectorySeparatorChar +"ItemNames.lst"))
                {
                    Message.Show("Can't find ItemNames.lst", MessageBoxButtons.OK, MessageBoxIcon.Error, true);
                    return false;
                }

                CurrentFile = "ItemNames.lst";
                Lines = new List<String>(File.ReadAllLines(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "ItemNames.lst", Encoding.UTF8));
                foreach (String Line in Lines)
                {
                    CurrentLine = Line;
                    if (Line.Length < 4) continue;
                    string[] Parts = Line.Split(Sep, StringSplitOptions.RemoveEmptyEntries);
                    if (ItemPid.ContainsKey(Parts[1]))
                        ItemPid[Parts[1]] = Int32.Parse(Parts[0]);
                    else
                        ItemPid.Add(Parts[1], Int32.Parse(Parts[0]));
                }
            }
            catch (IndexOutOfRangeException)
            {
                Message.Show("Error while parsing line '" + CurrentLine + "' in " + CurrentFile, MessageBoxButtons.OK, MessageBoxIcon.Error, true);
            }
            return true;
        }
Ejemplo n.º 9
0
        private void bwMaps_DoWork(object sender, DoWorkEventArgs e)
        {
            DefineParser WorldMapHeaderData = new DefineParser();
                if (!WorldMapHeaderData.ReadDefines(@Config.PathWorldmapHeader))
                    Utils.HandleParseError(WorldMapHeaderData.Error, @Config.PathWorldmapHeader);

                worldmap = new WorldMap(Config.PathWorldMap, Config.PathWorldMapCompiled, new WorldMapFormat(WorldMapHeaderData));
                worldmap.Parse();

                //worldmap = new WorldMap("worldmap_sdk.fowm", "worldmap_sdk.focwm", new SDKWorldMapFormat(WorldMapHeaderData));
                bwMaps.ReportProgress(52);
                this.BeginInvoke((MethodInvoker)delegate
                {
                    pctWorldMap.Refresh();
                    locationEditorToolStripMenuItem.Enabled = true;
                    mapdataEditorToolStripMenuItem.Enabled = true;
                });
                Utils.Log("Loaded maps and location data.");
                bwMaps.ReportProgress(100);
        }