private void ActivatePreview()
        {
            string path = BuildPath(TagTree.SelectedNode);

            if (path.IndexOf('.') != -1)
            {
                Trace.WriteLine("TagExplorer->PreviewTag: " + path);

                // TODO: I think we need to look at this design involving passing the MapfileVersion.
                // It's confusing to me, and it doesn't seem like the best way to go.
                // NOTE: After thinking about it, we should probably get the version from the tag.
                // This would most likely be accomplished by calling a "GetGameType(filename)" on the
                // current ITagArchive.  I will add that method to the interface.
                MapfileVersion version = MapfileVersion.HALOPC;
                if (this.Archive.Name == "Halo Xbox")
                {
                    version = MapfileVersion.XHALO1;
                }
                if (this.Archive.Name == "Halo 2 Xbox")
                {
                    version = MapfileVersion.XHALO2;
                }

                TagFileName tfn = new TagFileName(path, version);

                // HACK: For now, until we can look at this, I'm just sending the MafileVersion based on the archive name.
                MdxRender.PreviewManager.PreviewTag(tfn);
            }
        }
        static public void ScanDependencies()
        {
            //save all files
            DB.DependencyBuilder ib   = new DB.DependencyBuilder();
            TagFileName          stfn = new TagFileName(m_ScenarioData.TagFilename, m_ScenarioData.Header.GameVersion, TagSource.LocalProject);

            ib.ProcessDependants(stfn);

            string[] temp = DB.DependencyBuilder.mapfileTagsIndex.RelativePathList;
            for (int i = 0; i < temp.Length; i++)
            {
                Trace.WriteLine("Tag Dependency: " + temp[i]);
            }


            Trace.WriteLine("Broken Dependency List");
            string[] broken         = DB.DependencyBuilder.brokenDependencies.RelativePathList;
            string[] broken_parents = DB.DependencyBuilder.brokenDependenciesParents.RelativePathList;
            for (int i = 0; i < broken.Length; i++)
            {
                Trace.WriteLine("Broken Dependency: " + broken[i]);
            }

            for (int i = 0; i < broken_parents.Length; i++)
            {
                if (broken_parents[i] != null)
                {
                    Trace.WriteLine("Broken Parent: " + broken_parents[i]);
                }
                else
                {
                    Trace.WriteLine("Broken Parent: none");
                }
            }
        }
        private string[] ProcessItem(object o)
        {
            UniqueStringCollection deps = new UniqueStringCollection();

            if (o is TagReference)
            {
                TagReference tagRef = (o as TagReference);
                if (tagRef.Value != null)
                {
                    if (tagRef.Value.Length > 0)
                    {
                        string filename = tagRef.Value + TagFileName.GetFileExtension(tagRef.TagGroup);
                        deps.Add(filename);
                    }
                }
            }
            if (o is CollectionBase)
            {
                foreach (object child in (o as CollectionBase))
                {
                    if (child is IBlock)
                    {
                        string[] items = ProcessDependencies(child as IBlock);
                        deps.AddRange(items);
                    }
                }
            }
            if (o is IBlock)
            {
                string[] items = ProcessDependencies(o as IBlock);
                deps.AddRange(items);
            }
            return(deps.ToArray());
        }
        static public void PerformContextAction(string MenuText, TagFileName browsed_item)
        {
            ObjectType sect = ObjectType.Unknown;

            Menus.UpdateRecentItems(MenuText);

            //get action from text before "." delimiter
            int    j         = MenuText.IndexOf('.');
            string action    = MenuText.Substring(0, j);
            string item_path = MenuText.Substring(j + 1, MenuText.Length - j - 1);

            sect = GetObjectType(action);


            if (item_path == "Add...")
            {
                string rp     = browsed_item.RelativePath;
                int    k      = rp.IndexOf('.');
                string new_rp = rp.Substring(0, k);
                MapSpawnEditor.AddToPalette(sect, new_rp);
                Menus.UpdateMenuLists(m_ScenarioTag);
            }
            else
            {
                MapSpawnEditor.AddInstance(sect, item_path);
            }
        }
        static public void OpenProject(string ProjectFilename)
        {
            //set the Project Path global variable
            int i = ProjectFilename.LastIndexOf('\\');

            OptionsManager.ActiveProjectPath = ProjectFilename.Substring(0, i) + "\\";


            XmlDocument doc = new XmlDocument();

            doc.Load(ProjectFilename);
            m_ProjFile = new ProjectFile(doc);
            Trace.WriteLine("Project Loaded: " + m_ProjFile.MapName);

            //Load the scenario tag
            TagFileName scenario_tfn = new TagFileName(m_ProjFile.Tags["Scenario"].Path, MapfileVersion.HALOPC, TagSource.LocalProject);

            if (scenario_tfn.Exists)
            {
                LoadScenario(scenario_tfn);
            }
            else
            {
                //todo: freak out!
            }
            //todo: init prefabs?
        }
Exemple #6
0
        private void tagArchiveFileListView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection items = tagArchiveFileListView1.SelectedItems;
            if (items.Count == 0)
            {
                return;
            }
            ListViewItem item = items[0];

            if (item.Tag == null)
            {
                return;
            }
            if (!(item.Tag is FileEntryInformation))
            {
                return;
            }
            FileEntryInformation entry = (item.Tag as FileEntryInformation);

            if (entry.FileType == FileEntryType.File)
            {
                UpdateTagComboBox(entry.FullPath);
                this.selectedTag = new TagFileName(entry.FullPath.Trim('\\'), mapfileVersion, WhichSource(this.activeLibrary));
            }
        }
Exemple #7
0
        public void RegisterShader(TagFileName tfn)
        {
            m_ShaderName  = tfn;
            m_ShaderIndex = MdxRender.SM.RegisterShader(tfn);

            //check to see if we need to do polygon sorting (two sided transparent)
            ShaderType st = MdxRender.SM.GetShaderType(tfn.TagClass);

            switch (st)
            {
            case ShaderType.Schi:
                TagSchi ts = MdxRender.SM.GetSchiShader(m_ShaderIndex);
                bUsesTwoSidedTransparentShader = ts.TwoSided;
                break;

            case ShaderType.Scex:
                TagScex tc = MdxRender.SM.GetScexShader(m_ShaderIndex);
                bUsesTwoSidedTransparentShader = tc.TwoSided;
                break;

            case ShaderType.Soso:
                TagSoso ss = MdxRender.SM.GetSosoShader(m_ShaderIndex);
                bUsesTwoSidedTransparentShader = ss.TwoSided;
                break;
            }

            if (bUsesTwoSidedTransparentShader)
            {
                ConvertTriStripToList();
                Trace.WriteLine("Two Sided Shader:  " + tfn.RelativePath);
            }
        }
Exemple #8
0
        public int RegisterTexture2(TagFileName tfn)
        {
            int  tex_index     = DEFAULT_TEXTURE;
            bool bTextureFound = false;

            //TODO:  use hash table?
            for (tex_index = 0; ((tex_index < MaxElements) && (tex_index < m_LookupCount)); tex_index++)
            {
                if (m_LookupTable[tex_index].name == tfn.RelativePath)
                {
                    bTextureFound = true;
                    break;
                }
            }

            if (bTextureFound == false)
            {
                try
                {
                    H2BitmTag.H2Bitmap bmp = new H2BitmTag.H2Bitmap();
                    if (!bmp.LoadTagBuffer(tfn))
                    {
                        throw new Exception("Could not load bitmap: " + tfn.RelativePath);
                    }
                    bmp.LoadTagData();

                    m_LookupTable[m_LookupCount] = new TEXTURE_LOOKUP_ELEMENT();

                    //TODO: create array of textures
                    m_LookupTable[m_LookupCount].TextureList = new TextureWithFormat[bmp.m_header.Bitmaps.Count];
                    Trace.WriteLine("Loading texture: " + tfn.RelativePath);
                    for (int t = 0; t < bmp.m_header.Bitmaps.Count; t++)
                    {
                        m_LookupTable[m_LookupCount].TextureList[t] = new TextureWithFormat();

                        MemoryStream stream = new MemoryStream();
                        BinaryWriter bw     = new BinaryWriter(stream);
                        // Write the DDS header
                        H2BitmTag.DDSWriter d = new H2BitmTag.DDSWriter();
                        d.WriteHeader(ref bw, ref bmp.m_images[t]);
                        // Now copy the binary data to the stream
                        bw.Write(bmp.m_images[t].DDSData);
                        stream.Seek(0, SeekOrigin.Begin);

                        m_LookupTable[m_LookupCount].TextureList[t].texture = TextureLoader.FromStream(MdxRender.Dev, stream);
                    }

                    tex_index = m_LookupCount;
                    m_LookupCount++;
                }
                catch (Exception e)
                {
                    Trace.WriteLine("TextureManager Exception: " + e.Message);
                }
            }

            return(tex_index);
        }
 public void DebugLoadH2Bsp(TagFileName name)
 {
     m_activeH2Bsp = new Halo2BSP();
     m_activeH2Bsp.LoadTagBuffer(name);
     m_activeH2Bsp.LoadTagData(name.RelativePath);
     SetPreviewMode(PreviewMode.H2Bsp);
     MdxRender.SetZbufRange(30.0f, 300.0f);
     MdxRender.Camera.UpdateCameraByCentroid(m_activeH2Bsp.m_BoundingBox);
 }
 public void DebugLoadBsp(TagFileName name)
 {
     m_activeBsp = new TagBsp();
     m_activeBsp.LoadTagBuffer(name);
     m_activeBsp.LoadTagData();
     SetPreviewMode(PreviewMode.Bsp);
     MdxRender.SetZbufRange(30.0f, 300.0f);
     MdxRender.Camera.UpdateCameraByCentroid(m_activeBsp.m_BoundingBox);
 }
        static public void SaveProject()
        {
            if (m_ProjFile != null)
            {
                TagFileName scenario_tfn = new TagFileName(m_ProjFile.Tags["Scenario"].Path, ProjectManager.Version, TagSource.LocalProject);

                m_ProjFile.SaveToXML();
                SaveScenario(scenario_tfn);
            }
        }
 public void DebugLoadTexture2(TagFileName name)
 {
     m_ActiveTextureIndex = MdxRender.SM.m_TextureManager.RegisterTexture2(name);
     MdxRender.Dev.RenderState.Lighting = false;
     MdxRender.Dev.RenderState.CullMode = Cull.CounterClockwise;
     MdxRender.Dev.VertexFormat         = CustomVertex.PositionTextured.Format;
     MdxRender.SM.DisableBlend();
     m_PreviewMode = PreviewMode.Texture;
     MdxRender.Camera.SetLookAt(new Vector3(-18, 0, 0), new Vector3());
 }
 /// <summary>
 /// Constructor.  Requires a model filename to initialize properly.
 /// </summary>
 /// <param name="tfn"></param>
 public Instance3D(TagFileName tfn)
 {
     m_SelectTool = new SelectTool();
     SetModel(tfn);
     UpdateTransform();
     objectColor.Ambient     = Color.Gray;
     objectColor.Diffuse     = Color.White;
     fullBrightColor.Ambient = Color.White;
     fullBrightColor.Diffuse = Color.White;
 }
        private void LoadBipedPreview(TagFileName tfn)
        {
            TagBase tagdata = new TagBase();

            tagdata.LoadTagBuffer(tfn);
            BinaryReader br = new BinaryReader(tagdata.Stream);

            Biped obj = new Biped();

            obj.Read(br);
            obj.ReadChildData(br);
            LoadModelTag(new TagFileName(obj.ObjectValues.Model.Value, "mod2", tfn.Version));
            LoadAnimationTag(new TagFileName(obj.ObjectValues.AnimationGraph.Value, "antr", tfn.Version));
        }
 public bool LoadModelTag(TagFileName tfn)
 {
     try
     {
         int index = MdxRender.MM.RegisterModel(tfn);
         m_ActiveModel = new Instance3D(MdxRender.MM.GetModel(index));
         m_ActiveModel.Model.LevelOfDetail = eLOD.CAUSES_FIRES;
         MdxRender.Camera.UpdateCameraByBoundingBox(ref m_ActiveModel.Model.m_BoundingBox, 2.0f, 5.0f);
         m_PreviewMode = PreviewMode.Model;
     }
     catch
     {
     }
     return(false);
 }
 public bool LoadHalo2ModelTag(TagFileName filename)
 {
     try
     {
         int     index = MdxRender.MM.RegisterModel(filename);
         Model3D model = MdxRender.MM.GetModel(index);
         //MdxRender.Camera.UpdateCameraByBoundingBox(ref model.m_BoundingBox, 2.0f, 5.0f);
         m_PreviewMode = PreviewMode.H2Model;
         return(true);
     }
     catch
     {
     }
     return(false);
 }
Exemple #17
0
 private void ChangePath(string path)
 {
     this.currentPath = path.Trim('\\');
     if (this.currentPath.Length > 0)
     {
         this.btnParentFolder.Enabled = true;
     }
     else
     {
         this.btnParentFolder.Enabled = false;
     }
     this.selectedTag = null;
     this.tagArchiveFileListView1.SetCurrentDirectory(path);
     this.treeViewComboBox1.SelectPath(this.currentPath);
 }
Exemple #18
0
        private void CreateInstance(Scenario.ScenarioDecalsBlock block)
        {
            Instance3D scenario_object = null;
            string     obj_name        = scenarioTag.ScenarioValues.DecalPalette[block.DecalType.Value].Reference.Value;

            TagFileName bitmap_tfn = GetDecalBitmap(new TagFileName(obj_name, "deca", this.version));
            PromDecal   pd         = new PromDecal(1, bitmap_tfn);

            scenario_object = new Instance3D(pd);
            //scenario_object.InitializeRotationBinding(block.Position);
            //todo: bind the byte rotation that these objects use
            scenario_object.InitializeTranslationBinding(block.Position);
            scenario_object.InitializeRotationBinding(block.Ya, block.Pitc);
            scenario_object.ObjectType = ObjectType.Decals;
            scenario_object.ObjectName = obj_name;
            instanceCollection.Add(scenario_object);
        }
Exemple #19
0
        public PromDecal(float radius, TagFileName BitmapTFN)
        {
            dx = radius * 0.5f;
            dy = radius * 0.5f;

            decalTextureIndex = MdxRender.SM.m_TextureManager.RegisterTexture(BitmapTFN);
            decalVerts        = new CustomVertex.PositionTextured[4];
            decalVerts[0]     = new CustomVertex.PositionTextured(dx, -dy, 0, 1, 1);
            decalVerts[1]     = new CustomVertex.PositionTextured(dx, dy, 0, 1, 0);
            decalVerts[2]     = new CustomVertex.PositionTextured(-dx, -dy, 0, 0, 1);
            decalVerts[3]     = new CustomVertex.PositionTextured(-dx, dy, 0, 0, 0);

            m_VertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionTextured), decalVerts.Length, MdxRender.Dev,
                                              Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);
            m_VertexBuffer.Created += new EventHandler(OnVertexBufferUpdate);
            OnVertexBufferUpdate(m_VertexBuffer, null);
        }
Exemple #20
0
        private TagFileName GetDecalBitmap(TagFileName tfn)
        {
            TagFileName bitmap_name = null;

            if (tfn.Exists)
            {
                TagBase tagdata = new TagBase();
                tagdata.LoadTagBuffer(tfn);
                BinaryReader br = new BinaryReader(tagdata.Stream);

                Decal obj = new Decal();
                obj.Read(br);
                obj.ReadChildData(br);
                bitmap_name = new TagFileName(obj.DecalValues.Map.Value, "bitm", tfn.Version);
                //model_name = new TagFileName(obj.ObjectValues.Model.Value, "mod2", tfn.Version);
            }
            return(bitmap_name);
        }
Exemple #21
0
        void LoadSwatShader(TagFileName tfn)
        {
            TagSwat shdr = new TagSwat();

            try
            {
                shdr.Load(tfn);
                shdr.LoadTextures();
            }
            catch (Exception e)
            {
                Trace.WriteLine("Swat Shader Load failed: " + tfn.RelativePath + "(" + e.Message + ")");
                shdr.EnableDefaultShading();
            }

            m_LookupTable[LookupCount].index = (short)m_SwatArray.Count;
            m_SwatArray.Add(shdr);
        }
        static public void LoadScenario(TagFileName tfn)
        {
            if (tfn.Version == MapfileVersion.XHALO2)
            {
            }
            else
            {
                m_ScenarioData = new TagBase();
                m_ScenarioData.LoadTagBuffer(tfn);
                BinaryReader br = new BinaryReader(m_ScenarioData.Stream);

                m_ScenarioTag = new Scenario();
                m_ScenarioTag.Read(br);
                m_ScenarioTag.ReadChildData(br);
                MapSpawnEditor.LoadHalo1Scenario(m_ScenarioTag, m_ScenarioData);
                Menus.UpdateMenuLists(m_ScenarioTag);
            }
        }
        private void btnTestTagEditorGUI_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();

                // Load the XML Tag Definition
                //ofd.Filter = "Antenna Tag Definition|antenna.xml";
                ofd.Filter = "XML Tag Definition|*.xml";
                if (ofd.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                string      tdfFilename   = ofd.FileName;
                XmlDocument tagDefinition = new XmlDocument();
                tagDefinition.Load(tdfFilename);

                // Load the tag data
                string      tagDataFilename = @"vehicles\warthog\warthog antenna.antenna";
                TagFileName testTagFileName = new TagFileName(
                    tagDataFilename, MapfileVersion.HALOPC, TagSource.Archive);
                TagBase testTag = new TagBase();
                testTag.LoadTagBuffer(testTagFileName);
                BinaryReader br      = new BinaryReader(testTag.Stream);
                Antenna      antenna = new Antenna();
                antenna.Read(br);
                antenna.ReadChildData(br);

                Form test = new Form();
                test.Size = new Size(640, 480);
                TagEditorControl tagEditor = new TagEditorControl();
                tagEditor.Dock = DockStyle.Top;

                tagEditor.Create(tagDefinition, antenna);

                test.Controls.Add(tagEditor);
                test.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Exemple #24
0
        void LoadSenvShader(TagFileName tfn)
        {
            TagSenv shdr = new TagSenv();

            try
            {
                shdr.LoadTagBuffer(tfn);
                shdr.LoadTagData();
                shdr.LoadTextures(ref m_TextureManager, this.MaxTextureStages);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Senv Shader Load failed: " + tfn.RelativePath + "(" + e.Message + ")");
                shdr.EnableDefaultShading();
            }

            m_LookupTable[LookupCount].index = (short)m_SenvArray.Count;
            m_SenvArray.Add(shdr);
        }
Exemple #25
0
        private void CreateInstance(Scenario.ScenarioVehicleBlock block)
        {
            Instance3D  scenario_object = null;
            string      obj_name        = scenarioTag.ScenarioValues.VehiclePalette[block.Type.Value].Name.Value;
            TagFileName model_name      = GetModelName(new TagFileName(obj_name, "vehi", version));

            if (model_name.Exists)
            {
                scenario_object = new Instance3D(model_name);
            }
            else
            {
                scenario_object = new Instance3D(MdxRender.MM.DefaultModel);
            }

            scenario_object.InitializeRotationBinding(block.Rotation);
            scenario_object.InitializeTranslationBinding(block.Position);
            scenario_object.ObjectType = ObjectType.Vehicle;
            scenario_object.ObjectName = obj_name;
            instanceCollection.Add(scenario_object);
        }
Exemple #26
0
        private void CreateInstance(Scenario.ScenarioNetgameEquipmentBlock block)
        {
            Instance3D  scenario_object = null;
            string      obj_name        = block.ItemCollection.Value;
            TagFileName model_name      = GetModelName(new TagFileName(obj_name, "itmc", version));

            if (model_name.Exists)
            {
                scenario_object = new Instance3D(model_name);
            }
            else
            {
                scenario_object = new Instance3D(MdxRender.MM.DefaultModel);
            }

            scenario_object.InitializeRotationBinding(block.Facing);
            scenario_object.InitializeTranslationBinding(block.Position);
            scenario_object.ObjectType = ObjectType.Equipment;
            scenario_object.ObjectName = obj_name;
            instanceCollection.Add(scenario_object);
        }
        public DependencyBuilder(TagFileName tagFile)
        {
            // Load the proper tag definition.
            XmlDocument tagDefinition = TagDefinitionManager.GetTagDefinitionByName(tagFile.FileExtension);

            // Load the tag data
            TagBase tag = new TagBase();

            tag.LoadTagBuffer(tagFile);
            BinaryReader br = new BinaryReader(tag.Stream);

            // Create the appropriate type.
            XmlNode  nameNode      = tagDefinition.SelectSingleNode("//name");
            string   tagTypeString = "TagLibrary.Halo1." + nameNode.InnerText;
            Assembly a             = Assembly.GetAssembly(typeof(IField));
            IBlock   tagBlock      = (a.CreateInstance(tagTypeString) as IBlock);

            tagBlock.Read(br);
            tagBlock.ReadChildData(br);

            Dependencies = ProcessDependencies(tagBlock);
        }
        static public void LoadBsp(TagFileName bsp_tfn, TagFileName sky_tfn)
        {
            if (bsp_tfn.Version == MapfileVersion.XHALO2)
            {
                Halo1_Bsp = null;
                //TODO: load Halo2 bsp
            }
            else
            {
                if (sky_tfn != null)
                {
                    int index = MdxRender.MM.RegisterModel(sky_tfn);
                    MdxRender.SkyBox = MdxRender.MM.GetModel(index);
                }
                //TODO: null out Halo2 bsp, clean up old resources

                Halo1_Bsp = new TagBsp();
                Halo1_Bsp.LoadTagBuffer(bsp_tfn);
                Halo1_Bsp.LoadTagData();
                MdxRender.Camera.UpdateCameraByCentroid(Halo1_Bsp.m_BoundingBox);
            }
        }
        static public void SaveScenario(TagFileName tfn)
        {
            if (tfn.Version == MapfileVersion.XHALO2)
            {
            }
            else
            {
                m_ScenarioData        = new TagBase();
                m_ScenarioData.Stream = new MemoryStream();
                BinaryWriter bw = new BinaryWriter(m_ScenarioData.Stream);

                m_ScenarioData.Header.GameVersion = tfn.Version;
                m_ScenarioData.Header.TagClass0   = 0x73636E72;
                m_ScenarioData.Header.TagClass1   = 0xffffffff;
                m_ScenarioData.Header.TagClass2   = 0xffffffff;

                m_ScenarioTag.Write(bw);
                m_ScenarioTag.WriteChildData(bw);
                m_ScenarioData.Header.TagSize = (int)bw.BaseStream.Position;
                m_ScenarioData.SaveTagBuffer(tfn);
            }
        }
        public bool LoadAnimationTag(TagFileName tfn)
        {
            m_AnimationLoaded = false;
            try
            {
                m_activeAnimationTag = new Animations();
                m_activeAnimationTag.LoadTagBuffer(tfn);
                m_activeAnimationTag.LoadTagData();
                m_ActiveModel.InitializeAnimationProcessing();
                m_activeAnimationTag.ActivateAnimation(0);
                m_PreviewMode = PreviewMode.Animation;
            }
            catch (Exception ex)
            {
                throw new PrometheusException(
                          "Error loading animation tag: " + tfn.RelativePath,
                          ex,
                          true);
            }
            m_AnimationLoaded = true;

            return(false);
        }