Exemplo n.º 1
0
        private static Dictionary <string, string> ParseFile(ValveFormatParser parser)
        {
            var root = parser.RootNode;
            var dict = new Dictionary <string, string>();

            foreach (var node1 in root.SubNodes)
            {
                if (node1.Key != "items")
                {
                    continue;
                }
                foreach (var node2 in node1.SubNodes)
                {
                    var defindex = node2.Key;
                    var rarity   = "common";
                    foreach (var node3 in node2.SubNodes.Where(node3 => node3.Key == "item_rarity"))
                    {
                        rarity = node3.Value;
                        break;
                    }
                    dict.Add(defindex, rarity);
                }
            }
            return(dict);
        }
Exemplo n.º 2
0
        private void tfenglishtxtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ret = "";

            using (var diag = new OpenFileWindow())
            {
                Cursor = Cursors.WaitCursor;
                ret    = diag.ShowWindow("tf_english.txt", @"\tf\resource\");
            }
            Cursor = Cursors.Arrow;
            if (!String.IsNullOrEmpty(ret))
            {
                wait           = true;
                Cursor.Current = Cursors.WaitCursor;
                englishParser  = new ValveFormatParser(ret);
                englishParser.LoadFile();
                Cursor.Current = Cursors.Arrow;
                if (englishParser.RootNode.Key != "lang")
                {
                    MessageBox.Show("That is not tf_english.txt.\r\nPlease select tf_english.txt!",
                                    "TF2 Items Editor",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    englishParser = null;
                    wait          = false;
                    return;
                }
                stripTxt.Text                 = "";
                stripTxt.Image                = null;
                groupTips.Enabled             = true;
                comboTipClasses.SelectedIndex = 0;
                wait = false;
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var parser = new ValveFormatParser {
                Path = @"C:\VFP.txt"
            };

            parser.LoadFile();

            /*parser.Nodes.ForEach(delegate(DataNode n)
             *                       {
             *                           Console.WriteLine(n.Key + " = " + n.Value);
             *                           n.SubNodes.ForEach(delegate(DataNode no)
             *                                                  {
             *                                                      Console.WriteLine("\t" + no.Key + " = " + no.Value);
             *                                                      no.SubNodes.ForEach(delegate(DataNode nod)
             *                                                                              {
             *                                                                                  Console.WriteLine("\t\t" + nod.Key + " = " + nod.Value);
             *                                                                              });
             *                                                  });
             *                       });*/
            Console.WriteLine("Saving tree...");
            File.WriteAllText(@"C:\VFP_out.txt", parser.RootNode.ToString());
            Console.WriteLine("Saving output...");
            parser.SaveFile(@"C:\VFP_save.txt");
            Console.WriteLine("Done!");
            Console.ReadLine();
        }
Exemplo n.º 4
0
        private void itemsgametxtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ret;

            using (var diag = new OpenFileWindow())
            {
                Cursor = Cursors.WaitCursor;
                ret    = diag.ShowWindow("items_game.txt", @"\tf\scripts\items\");
            }
            Cursor = Cursors.Arrow;
            if (!String.IsNullOrEmpty(ret))
            {
                Cursor.Current = Cursors.WaitCursor;
                itemsParser    = new ValveFormatParser(ret);
                itemsParser.LoadFile();
                Cursor.Current = Cursors.Arrow;
                if (itemsParser.RootNode.Key != "items_game")
                {
                    MessageBox.Show("That is not items_game.txt.\r\nPlease select items_game.txt!",
                                    "TF2 Items Editor",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    itemsParser = null;
                    return;
                }
                LoadItems();
                stripTxt.Text  = "Edit->Attributes to open the attributes window!";
                stripTxt.Image = images.Images["Info"];
            }
        }
Exemplo n.º 5
0
        public static ItemsGame FetchItemsGame(string url)
        {
            string cachefile = "d2_items_game.cache";
            string result    = "";

            if (File.Exists(cachefile) && File.Exists(cachefile + ".dat"))
            {
                var prevurl = File.ReadAllText(cachefile + ".dat");
                if (prevurl != url)
                {
                    using (var wc = new WebClient())
                    {
                        result = wc.DownloadString(url);
                        File.WriteAllText(cachefile, result);
                        File.WriteAllText(cachefile + ".dat", url);
                    }
                }
            }
            else
            {
                using (var wc = new WebClient())
                {
                    result = wc.DownloadString(url);
                    File.WriteAllText(cachefile, result);
                    File.WriteAllText(cachefile + ".dat", url);
                }
            }
            var parser = new ValveFormatParser(cachefile);

            parser.LoadFile();
            var dict = ParseFile(parser);

            return(new ItemsGame {
                Response = result, Parser = parser, Items = dict
            });
        }