Ejemplo n.º 1
0
        public void PerformTest()
        {
            OpenFileDialog      ofd = new OpenFileDialog();
            SaveFileDialog      sfd = new SaveFileDialog();
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description = "Where did you decompile to?";
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        GameDefinition gd      = Core.Prometheus.Instance.GetGameDefinitionByGameID("halopc");
                        IMapFile       map     = gd.CreateMapFileObject();
                        ILibrary       library = new DiskFileLibrary(fbd.SelectedPath, "Compiler Test Library");
                        map.RegisterTag(library, ofd.FileName.Replace(fbd.SelectedPath + '\\', ""));
                        map.RegisterTag(library, @"globals\globals.globals");
                        map.RegisterTag(library, @"ui\ui_tags_loaded_all_scenario_types.tag_collection");
                        map.RegisterTag(library, @"ui\shell\bitmaps\background.bitmap");
                        map.RegisterTag(library, @"ui\shell\strings\loading.unicode_string_list");
                        map.RegisterTag(library, @"ui\shell\main_menu\mp_map_list.unicode_string_list");
                        map.RegisterTag(library, @"ui\shell\bitmaps\trouble_brewing.bitmap");
                        map.RegisterTag(library, @"sound\sfx\ui\cursor.sound");
                        map.RegisterTag(library, @"sound\sfx\ui\forward.sound");
                        map.RegisterTag(library, @"sound\sfx\ui\back.sound");
                        map.RegisterTag(library, @"ui\ui_tags_loaded_multiplayer_scenario_type.tag_collection");

                        FileStream fs = File.Create(sfd.FileName);
                        map.CompileCache(fs, library);
                        fs.Close();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void PerformTest()
        {
            OpenFileDialog      ofd = new OpenFileDialog();
            SaveFileDialog      sfd = new SaveFileDialog();
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description = "Where did you decompile to?";
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        FileStream fs = File.OpenRead(ofd.FileName);
                        TagFile    tf = new TagFile(fs);
                        fs.Close();

                        GameDefinition gd      = Core.Prometheus.Instance.GetGameDefinitionByGameID(tf.GameID);
                        IMapFile       map     = gd.CreateMapFileObject();
                        ILibrary       library = new DiskFileLibrary(fbd.SelectedPath, "Compiler Test Library");
                        map.RegisterTag(library, ofd.FileName.Replace(fbd.SelectedPath + '\\', ""));
                        while (ofd.ShowDialog() == DialogResult.OK)
                        {
                            map.RegisterTag(library, ofd.FileName.Replace(fbd.SelectedPath + '\\', ""));
                        }

                        fs = File.Create(sfd.FileName);
                        map.CompileCache(fs, library);
                        fs.Close();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an XML file containing a list of all retail tags for the specified game.
        /// </summary>
        public static void GenerateList(string gameID)
        {
            GameDefinition def = null;

            foreach (GameDefinition g in Core.Prometheus.Instance.Games)
            {
                if (g.GameID == gameID)
                {
                    def = g;
                }
            }

            if (def == null)
            {
                MessageBoxEx.Show("Could not locate a game definition for '" + gameID + "'");
                return;
            }

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (def.MapFilePath != "")
            {
                if (Directory.Exists(def.MapFilePath))
                {
                    fbd.SelectedPath = def.MapFilePath;
                }
            }

            fbd.Description = "Select the folder that contains your '" + gameID + "' map files.";
            if (fbd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string basePath = fbd.SelectedPath;

            StreamWriter    writer = new StreamWriter(basePath + "\\" + gameID + " mapinfo.txt");
            TagListCompiler comp   = new TagListCompiler();

            try
            {
                foreach (MapFileDefinition mapDef in def.Maps)
                {
                    IMapFile map  = def.CreateMapFileObject();
                    string   file = basePath + "\\" + mapDef.Filename;
                    if (!File.Exists(file))
                    {
                        Output.Write(OutputTypes.Warning, "File not found: " + file);
                        continue;
                    }
                    map.Load(file);
                    byte[]     checksum   = map.CalculateChecksum();
                    long       low        = BitConverter.ToInt64(checksum, 0);
                    long       high       = BitConverter.ToInt64(checksum, 8);
                    FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    long       fileSize   = fileStream.Length;
                    fileStream.Close();

                    // 0 = filename, 1 = checksum low, 2 = checksum high, 3 = filesize
                    writer.WriteLine("new MapFileDefinition(\"{0}\", 0x{1}, 0x{2}, {3}),",
                                     mapDef.Filename, Convert.ToString(low, 16), Convert.ToString(high, 16), fileSize);

                    comp.AddMap(map);
                }
            }
            finally
            {
                writer.Close();
            }
            comp.WriteXml(basePath + "\\" + gameID + " tag list.xml");
        }