static public FileStream GetSoundStream(MapfileVersion ver) { string soundPath = ""; FileStream fsSound; switch (ver) { case MapfileVersion.XHALO1: soundPath = HaloPC_SoundsPath; break; case MapfileVersion.HALOPC: soundPath = HaloPC_SoundsPath; break; case MapfileVersion.HALOCE: soundPath = HaloCE_SoundsPath; break; } try { FileInfo fiSound = new FileInfo(soundPath); fsSound = fiSound.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); } catch (Exception e) { throw new PrometheusException("Failed to load Sounds.map: " + e.Message, true); } return(fsSound); }
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 string GetMagfilePath(MapfileVersion ver) { string mag_path = ""; switch (ver) { case MapfileVersion.XHALO1: mag_path = Application.StartupPath + @"\Tag Structures\XHalo\"; break; case MapfileVersion.XHALO2: mag_path = Application.StartupPath + @"\Tag Structures\Halo2\"; break; case MapfileVersion.HALOPC: mag_path = Application.StartupPath + @"\Tag Structures\PcHalo\"; break; case MapfileVersion.HALOCE: mag_path = Application.StartupPath + @"\Tag Structures\CeHalo\"; break; } return(mag_path); }
static public FileStream GetBitmapStream(MapfileVersion ver) { string bitmapPath = ""; FileStream BitmapsMapStream; switch (ver) { case MapfileVersion.XHALO1: bitmapPath = HaloPC_BitmapsPath; break; case MapfileVersion.HALOPC: bitmapPath = HaloPC_BitmapsPath; break; case MapfileVersion.HALOCE: bitmapPath = HaloCE_BitmapsPath; break; } try { FileInfo fiBitmap = new FileInfo(bitmapPath); BitmapsMapStream = fiBitmap.Open(FileMode.Open, FileAccess.Read, FileShare.Read); } catch (Exception e) { throw new PrometheusException("Failed to load Bitmaps.map: " + e.Message, true); } return(BitmapsMapStream); }
public void Read(ref BinaryReader br) { int StartPos = (int)br.BaseStream.Position; m_Signature = br.ReadChars(4); m_HeaderSize = br.ReadInt32(); m_TagClass[0] = br.ReadUInt32(); m_TagClass[1] = br.ReadUInt32(); m_TagClass[2] = br.ReadUInt32(); m_TagRevision = br.ReadInt32(); GameVersion = (MapfileVersion)br.ReadInt32(); TagSize = br.ReadInt32(); AttachmentsSize = br.ReadInt32(); RawType = (RawDataType)br.ReadInt32(); switch (m_TagRevision) //schema { case 1: break; } int delta = m_HeaderSize - ((int)br.BaseStream.Position - StartPos); br.BaseStream.Position += delta; }
public TagFileName(string RelativePath, MapfileVersion ver, TagSource source) { m_RelativePath = RelativePath; m_Version = ver; m_TagSource = source; //TODO: run "Exists" test on source to see if we need to set the NotFound flag }
public void Read(byte[] buffer) { for (int i = 0; i < 4; i++) { m_Signature[i] = BitConverter.ToChar(buffer, i); } m_HeaderSize = BitConverter.ToInt32(buffer, 4); m_TagClass[0] = BitConverter.ToUInt32(buffer, 8); m_TagClass[1] = BitConverter.ToUInt32(buffer, 12); m_TagClass[2] = BitConverter.ToUInt32(buffer, 16); m_TagRevision = BitConverter.ToInt32(buffer, 20); GameVersion = (MapfileVersion)BitConverter.ToInt32(buffer, 24); TagSize = BitConverter.ToInt32(buffer, 28); AttachmentsSize = BitConverter.ToInt32(buffer, 32); RawType = (RawDataType)BitConverter.ToInt32(buffer, 36); }
public TagBrowserDialog(MapfileVersion ver) { InitializeComponent(); if (!DesignMode) { mapfileVersion = ver; switch (mapfileVersion) { case MapfileVersion.HALOPC: this.archiveLibrary = TagLibraryManager.HaloPC; break; case MapfileVersion.HALOCE: this.archiveLibrary = TagLibraryManager.HaloPC; break; case MapfileVersion.XHALO1: this.archiveLibrary = TagLibraryManager.HaloXbox; break; case MapfileVersion.XHALO2: this.archiveLibrary = TagLibraryManager.Halo2Xbox; break; } this.treeViewComboBox1.PathChanged += new TreeViewComboBox.PathChangedEventHandler(treeViewComboBox1_PathChanged); this.navBarControl1.SelectedLink = this.navBarControl1.Items[0].Links[0]; this.tagArchiveFileListView1.ItemDoubleClicked += new EventHandler(tagArchiveFileListView1_ItemDoubleClicked); this.tagArchiveFileListView1.SelectedIndexChanged += new EventHandler(tagArchiveFileListView1_SelectedIndexChanged); this.tagArchiveFileListView1.MultiSelect = false; //Initialize Project Section state navBarGroup1.ItemLinks[2].Item.Enabled = ProjectManager.ProjectLoaded; if (ProjectManager.ProjectLoaded) { this.projectLibrary = new DiskFolderTagLibrary(OptionsManager.ActiveProjectTagsPath, "Project Tags"); } //Initialize User Library section navBarGroup1.ItemLinks[1].Item.Enabled = false; this.userLibrary = null;//TagLibraryManager.Halo2Xbox; } }
static public void GetGuerillaHeader(MapfileVersion ver, string TagClass, byte[] HeaderData) { FileInfo fi = null; if (ver == MapfileVersion.XHALO2) { fi = new FileInfo(Application.StartupPath + @"\Halo2 Tag Headers\" + TagClass + "." + "BLAM"); } else { fi = new FileInfo(Application.StartupPath + @"\Tag Headers\" + TagClass + "." + "BLAM"); } FileStream TagHdrStream; TagHdrStream = fi.Open(FileMode.Open, FileAccess.Read); TagHdrStream.Read(HeaderData, 0, 64); TagHdrStream.Close(); }
public void Load(ref BinaryReader br, MapfileVersion ver) { uint SizeTest = (uint)br.BaseStream.Position; for (int x = 0; x < unk.Length; x++) { unk[x] = br.ReadUInt32(); } SubmeshHeaders.Load(ref br); if (ver == MapfileVersion.XHALO1) { XSUBMESHHEADERS = new XBOXMODEL_SUBMESH_HEADER[SubmeshHeaders.Count]; } else { SUBMESHHEADERS = new PCMODEL_SUBMESH_HEADER[SubmeshHeaders.Count]; } SizeTest = (uint)br.BaseStream.Position - SizeTest; }
static public ZipTagLibrary GetLibrary(MapfileVersion ver) { ZipTagLibrary lib = null; switch (ver) { case MapfileVersion.HALOPC: case MapfileVersion.HALOCE: lib = haloPC; break; case MapfileVersion.XHALO1: lib = haloXbox; break; case MapfileVersion.XHALO2: lib = halo2Xbox; break; } return(lib); }
static public string GetExtractPath(MapfileVersion version) { string extract_path = ""; switch (version) { case MapfileVersion.XHALO1: extract_path = Application.StartupPath + @"\Games\Xbox\Halo\"; break; case MapfileVersion.XHALO2: extract_path = Application.StartupPath + @"\Games\Xbox\Halo2\"; break; case MapfileVersion.HALOPC: case MapfileVersion.HALOCE: extract_path = Application.StartupPath + @"\Games\Pc\Halo\"; break; } return(extract_path); }
static public string GetSharedTagsPath(MapfileVersion version) { string shared_tags_path = ""; switch (version) { case MapfileVersion.XHALO1: shared_tags_path = Application.StartupPath + @"\Games\Xbox\Halo\Prefabs\Tags"; break; case MapfileVersion.XHALO2: shared_tags_path = Application.StartupPath + @"\Games\Xbox\Halo 2\Prefabs\Tags"; break; case MapfileVersion.HALOPC: case MapfileVersion.HALOCE: shared_tags_path = Application.StartupPath + @"\Games\PC\Halo\Prefabs\Tags"; break; } return(shared_tags_path); }
static public string GetPrefabPath(MapfileVersion version) { string prefab_path = ""; switch (version) { case MapfileVersion.XHALO1: prefab_path = Application.StartupPath + @"\Games\Xbox\Halo\Prefabs"; break; case MapfileVersion.XHALO2: prefab_path = Application.StartupPath + @"\Games\Xbox\Halo 2\Prefabs"; break; case MapfileVersion.HALOPC: case MapfileVersion.HALOCE: prefab_path = Application.StartupPath + @"\Games\PC\Halo\Prefabs"; break; } return(prefab_path); }
static public string GetProjectBaseFolder(MapfileVersion version) { string proj_base = ""; switch (version) { case MapfileVersion.XHALO1: proj_base = Application.StartupPath + @"\Games\Xbox\Halo\Projects\"; break; case MapfileVersion.XHALO2: proj_base = Application.StartupPath + @"\Games\Xbox\Halo2\Projects\"; break; case MapfileVersion.HALOPC: case MapfileVersion.HALOCE: proj_base = Application.StartupPath + @"\Games\Pc\Halo\Projects\"; break; } return(proj_base); }
public uint InitDecompiler(string FileName) { InitStringConversionTable(); FileInfo fiin = new FileInfo(FileName); fsin = fiin.Open(FileMode.Open, FileAccess.ReadWrite); byte[] TempHeaderBuffer = new byte[0x800]; fsin.Read(TempHeaderBuffer, 0, 0x800); fsin.Seek(0, System.IO.SeekOrigin.Begin); m_MapVersion = (MapfileVersion)BitConverter.ToUInt32(TempHeaderBuffer, 0x04); TempHeaderBuffer = null; switch (m_MapVersion) { case MapfileVersion.XHALO1: HaloMap = new Map(); HaloMap.Load(ref fsin); break; case MapfileVersion.HALOPC: case MapfileVersion.HALOCE: HaloMap = new Map(); HaloMap.Load(ref fsin); break; case MapfileVersion.XHALO2: Halo2Map = new sHalo2Map(); Halo2Map.Read(ref fsin); break; } //HaloMap = new Map(); //HaloMap.Load(ref fsin); return((uint)m_MapVersion); }
public void LoadH1ModelVertexData(int VertIndex, ref BinaryReader br, byte[] buffer, float UScale, float VScale, MapfileVersion ver) { m_ModelVerts[VertIndex] = new MODEL_VERT(); if (ver == MapfileVersion.XHALO1) { m_ModelVerts[VertIndex].LoadCompressed(ref br, buffer, UScale, VScale); } else { m_ModelVerts[VertIndex].Load(ref br, buffer, UScale, VScale); } boundingBox.Update(m_ModelVerts[VertIndex].dxv.X, m_ModelVerts[VertIndex].dxv.Y, m_ModelVerts[VertIndex].dxv.Z); }
public TagFileName(string RelativePath, string TagClass, MapfileVersion ver) { if (RelativePath == null) { Console.WriteLine("break here"); } m_TagClass = TagClass; m_RelativePath = RelativePath; m_Version = ver; if (m_RelativePath.IndexOf('.') == -1) { switch (TagClass) { case "soso": m_RelativePath += ".shader_model"; break; case "dahs": case "shad": m_RelativePath += ".shad"; break; case "antr": m_RelativePath += ".model_animations"; break; case "bitm": m_RelativePath += ".bitmap"; break; case "scen": m_RelativePath += ".scenery"; break; case "vehi": m_RelativePath += ".vehicle"; break; case "eqip": m_RelativePath += ".equipment"; break; case "weap": m_RelativePath += ".weapon"; break; case "scex": m_RelativePath += ".shader_transparent_chicago_extended"; break; case "schi": m_RelativePath += ".shader_transparent_chicago"; break; case "senv": m_RelativePath += ".shader_environment"; break; case "mod2": m_RelativePath += ".gbxmodel"; break; case "mode": m_RelativePath += ".model"; break; case "sgla": m_RelativePath += ".shader_transparent_glass"; break; case "smet": m_RelativePath += ".shader_metal"; break; case "sbsp": m_RelativePath += ".scenario_structure_bsp"; break; case "itmc": m_RelativePath += ".item_collection"; break; case "sky ": m_RelativePath += ".sky"; break; case "swat": m_RelativePath += ".shader_transparent_water"; break; case "sotr": m_RelativePath += ".shader_transparency_generic"; break; case "deca": m_RelativePath += ".decal"; break; case "spla": m_RelativePath += ".shader_transparent_plasma"; break; default: throw new PrometheusException("Error on TagFilename create: No matching TagClass for " + TagClass, true); break; } } DetermineTagSource(); }
public TagFileName(string RelativePath, MapfileVersion ver) { m_RelativePath = RelativePath; m_Version = ver; DetermineTagSource(); }
public void LoadScenario(Scenario st, TagBase scenario_data) { this.version = scenario_data.Header.GameVersion; int i; instanceCollection.Clear(); //Process palettes scenarioTag = st; //load bipeds for (i = 0; i < st.ScenarioValues.Bipeds.Count; i++) { CreateInstance(st.ScenarioValues.Bipeds[i]); } //load decals //for(i=0; i<st.ScenarioValues.Decals.Count; i++) // CreateInstance(st.ScenarioValues.Decals[i]); //load light fixtures for (i = 0; i < st.ScenarioValues.LightFixtures.Count; i++) { CreateInstance(st.ScenarioValues.LightFixtures[i]); } //load scenery for (i = 0; i < st.ScenarioValues.Scenery.Count; i++) { CreateInstance(st.ScenarioValues.Scenery[i]); } //load vehicles for (i = 0; i < st.ScenarioValues.Vehicles.Count; i++) { CreateInstance(st.ScenarioValues.Vehicles[i]); } //load netgame equipment for (i = 0; i < st.ScenarioValues.NetgameEquipment.Count; i++) { CreateInstance(st.ScenarioValues.NetgameEquipment[i]); } //load sound scenery for (i = 0; i < st.ScenarioValues.SoundScenery.Count; i++) { CreateInstance(st.ScenarioValues.SoundScenery[i]); } //load player spawns for (i = 0; i < st.ScenarioValues.PlayerStartingLocations.Count; i++) { CreateInstance(st.ScenarioValues.PlayerStartingLocations[i]); } //load netgame flags for (i = 0; i < st.ScenarioValues.NetgameFlags.Count; i++) { CreateInstance(st.ScenarioValues.NetgameFlags[i]); } if (st.ScenarioValues.StructureBsps.Count >= 1) { //get BSP filename TagFileName bsp_filename = new TagFileName(st.ScenarioValues.StructureBsps[0].StructureBsp.Value, "sbsp", scenario_data.Header.GameVersion); //get Sky filename TagFileName sky_filename = new TagFileName(st.ScenarioValues.Skies[0].Sky.Value, "sky ", scenario_data.Header.GameVersion); TagBase sky_data = new TagBase(); sky_data.LoadTagBuffer(sky_filename); BinaryReader sky_br = new BinaryReader(sky_data.Stream); Sky sky_tag = new Sky(); sky_tag.Read(sky_br); sky_tag.ReadChildData(sky_br); MdxRender.RGB fog = new MdxRender.RGB(); fog.R = sky_tag.SkyValues.OutdoorFogColor.R; fog.G = sky_tag.SkyValues.OutdoorFogColor.G; fog.B = sky_tag.SkyValues.OutdoorFogColor.B; MdxRender.FogColor = fog; /// Not sure how these units equate to d3d units - * 2.5 seems to be pretty good. MdxRender.FogStart = sky_tag.SkyValues.OutdoorFogStartDistance.Value * 2.5f; MdxRender.FogEnd = sky_tag.SkyValues.OutdoorFogOpaqueDistance.Value * 2.5f; MdxRender.FogDensity = sky_tag.SkyValues.OutdoorFogMaximumDensity.Value; MdxRender.ClearColor = Color.FromArgb( (int)(sky_tag.SkyValues.OutdoorAmbientRadiosityColor.R * 255), (int)(sky_tag.SkyValues.OutdoorAmbientRadiosityColor.G * 255), (int)(sky_tag.SkyValues.OutdoorAmbientRadiosityColor.B * 255)); MdxRender.FogEnabled = true; TagFileName sky_model_tfn; if (this.version == MapfileVersion.XHALO1) { sky_model_tfn = new TagFileName(sky_tag.SkyValues.Model.Value, "mode", scenario_data.Header.GameVersion); } else { sky_model_tfn = new TagFileName(sky_tag.SkyValues.Model.Value, "mod2", scenario_data.Header.GameVersion); } MdxRender.LoadBsp(bsp_filename, sky_model_tfn); //Load up them thar lights for Radiosity ProjectManager.RadiosityLights.Clear(); //sky_tag for (int l = 0; l < sky_tag.SkyValues.Lights.Count; l++) { RadiosityLight rl = new RadiosityLight(); rl.color[0] = sky_tag.SkyValues.Lights[l].Color.R; rl.color[1] = sky_tag.SkyValues.Lights[l].Color.G; rl.color[2] = sky_tag.SkyValues.Lights[l].Color.B; rl.power = sky_tag.SkyValues.Lights[l].Power.Value; //don't know how this is turned into a vector, but we'll figure it out //for now get x,y from yaw and z component from pitch (make sure Z component is negative) rl.direction.Z = -1; double y, p; y = sky_tag.SkyValues.Lights[l].Direction.Y; p = sky_tag.SkyValues.Lights[l].Direction.P; rl.direction.X = -(float)Math.Cos(y); rl.direction.Y = -(float)Math.Sin(y); rl.direction.Z = -(float)Math.Sin(p); ProjectManager.RadiosityLights.Add(rl); MdxRender.AddGlobalLight(0, rl); } } instanceCollection.UpdateObjectColors(); }