public void FillAdded()
        {
            foreach (string key in DataDumper.FilesTable.Keys)
            {
                LuaInfo lua = DataDumper.FilesTable[key] as LuaInfo;

                string Type = "Buildings";
                switch (lua.Type)
                {
                case InfoTypes.Unit:
                    Type = "Squads";
                    break;

                case InfoTypes.Building:
                    Type = "Buildings";
                    break;
                }

                TreeNode node = treeView2.Nodes[treeView2.Nodes.IndexOfKey(Type)];

                TreeNode subNode = node.Nodes[node.Nodes.IndexOfKey(lua.Race)];
                TreeNode newNode = new TreeNode(key);
                newNode.Name = key;
                subNode.Nodes.Add(newNode);
            }
        }
示例#2
0
        // Writes the files list
        public static void WriteFilesList()
        {
            // Writes the filesList
            ArrayList list = new ArrayList(FilesTable.Keys);

            list.Sort();
            StreamWriter writer = new StreamWriter(File.Create(Path.Combine(Directory.GetCurrentDirectory(), "Config/FilesIndex.def")));

            foreach (string k in list)
            {
                LuaInfo lInfo = FilesTable[k] as LuaInfo;
                if (lInfo.Type != InfoTypes.Research)
                {
                    writer.WriteLine("<" + lInfo.Type.ToString() + "> <" + lInfo.Race + "> <" + k + ">");
                }
            }
            writer.Close();
        }
示例#3
0
        public int CompareTo(object o)
        {
            LuaInfo toCompare = o as LuaInfo;

            if (Race.CompareTo(toCompare.Race) < 0)
            {
                return(-1);
            }
            if (Race.CompareTo(toCompare.Race) > 0)
            {
                return(1);
            }
            int result = (CompareTypes(toCompare.Type));

            if (result == 0)
            {
                return(Path.CompareTo(toCompare.Path));
            }

            return(result);
        }
示例#4
0
        public static void Dump()
        {
            // Clear Resources
            Addons.Clear();
            Skills.Clear();
            Squads.Clear();
            Buildings.Clear();
            Units.Clear();
            Researches.Clear();
            MainForm.Log("Lua processing started...");
            DateTime start = DateTime.Now;


            Hashtable temp = (Hashtable)FilesTable.Clone();

            foreach (string lua in temp.Keys)
            {
                LuaInfo lInfo = temp[lua] as LuaInfo;
                if (lInfo.Type == InfoTypes.Building)
                {
                    StreamReader file = new StreamReader(File.OpenRead(lInfo.Path), System.Text.Encoding.ASCII);
                    file.BaseStream.Seek(0, SeekOrigin.Begin);

                    string s = file.ReadToEnd();

                    file.Close();

                    MatchCollection mccR = Regex.Matches(s, @"GameData\[""research_ext""\]\[""research_table""\]\[""research_([0-9]?[0-9]?)""\]\s=\s""(.*\\\\)?((?<research>.*)\.lua|(?<research>.*))""");
                    if (mccR.Count > 0)
                    {
                        foreach (Match mt in mccR)
                        {
                            Group research = mt.Groups["research"];

                            if (research.Success && research.Value != "")
                            {
                                string res = research.Value;
                                if (!res.EndsWith(".lua"))
                                {
                                    res += ".lua";
                                }
                                res = Path.Combine("research", res);
                                string path = DataPath.GetPath(res);

                                string  race   = GetRace(lInfo.Path);
                                LuaInfo resLua = new LuaInfo(path, InfoTypes.Research, race);

                                if (!FilesTable.Contains(res))
                                {
                                    FilesTable.Add(res, resLua);
                                }
                            }
                        }
                    }
                }
            }
            int count = FilesTable.Count;

            MainForm.BarSetMax(Bars.Data, count);
            // Collecting resources from lua files.
            foreach (string lua in FilesTable.Keys)
            {
                LuaInfo lInfo = FilesTable[lua] as LuaInfo;

                switch (lInfo.Type)
                {
                case InfoTypes.Research:
                    ResearchInfo rInfo = new ResearchInfo();
                    rInfo.Race     = lInfo.Race;
                    rInfo.FileName = Regex.Replace(lua, @"\.lua|\.nil|(.*)\\", "");

                    try
                    {
                        LuaParser.ParseResearch(lInfo.Path, rInfo);
                    }
                    catch (Exception e)
                    {
                    }

                    MainForm.BarInc(Bars.Data);
                    Researches.Add(rInfo);
                    break;

                case InfoTypes.Unit:

                    SquadInfo sInfo = new SquadInfo();
                    sInfo.Race     = lInfo.Race;
                    sInfo.FileName = Regex.Replace(lua, @"\.lua|\.nil", "");
                    LuaParser.ParseSquad(lInfo.Path, sInfo);
                    MainForm.BarInc(Bars.Data);
                    if (sInfo.Unit != null)
                    {
                        Squads.Add(sInfo);
                    }
                    break;

                case InfoTypes.Building:
                    BuildingInfo bInfo = new BuildingInfo();
                    bInfo.Race     = lInfo.Race;
                    bInfo.FileName = Regex.Replace(lua, @"\.lua|\.nil", "");
                    LuaParser.ParseBuilding(lInfo.Path, bInfo);
                    MainForm.BarInc(Bars.Data);
                    Buildings.Add(bInfo);
                    break;
                }
            }
            Researches.Sort();
            Squads.Sort();
            Buildings.Sort();

            TimeSpan elapsed = DateTime.Now - start;

            MainForm.Log("Lua processing done in " + Math.Round(elapsed.TotalSeconds, 2) + " seconds.");
        }