示例#1
0
			internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
			{
				//int index = BitmapGroup.Value & 0xFFFF;
				//if (index != -1) System.Diagnostics.Debug.WriteLine(string.Format(
				//	 "BitmapGroup: {0} {1}", index, c.Index.Tags[index].FileName));
				return true;
			}
示例#2
0
		protected override void ProcessDefinition(XmlNode node, BlamLib.CheApe.ProjectState state, BlamLib.IO.XmlStream s)
		{
			StringIdFieldsInitialize(state);

			switch (node.Name)
			{
				#region Tag Structs
				case "structs":
					s.SaveCursor(node);
					ProcessTagStructs(state, s);
					s.RestoreCursor();
					break;
				#endregion

				#region Tag Blocks
				case "blocks":
					s.SaveCursor(node);
					ProcessTagBlocks(state, s);
					s.RestoreCursor();
					break;
				#endregion

				#region Tag Groups
				case "groups":
					s.SaveCursor(node);
					ProcessTagGroups(state, s);
					s.RestoreCursor();
					break;
				#endregion
			}
		}
示例#3
0
			public void Write(BlamLib.IO.EndianWriter s)
			{
				if(nullBuffer == null)
					nullBuffer = new byte[ByteCount];

				s.Write(nullBuffer);
			}
			/// <summary>Initialize state for processing a tag hierarchy</summary>
			/// <param name="args"></param>
			/// <param name="instance"></param>
			public void InitializeStateForTagHierarchy(BlamLib.Blam.CacheExtractionArguments args, BlamLib.Blam.CacheIndex.Item instance)
			{
				m_sender = TagExtractionSender.TagTree;

				Arguments = args;
				Instance = instance;
			}
示例#5
0
		public override void Read(BlamLib.IO.EndianReader s)
		{
			Blam.CacheFile.ValidateHeader(s, 0x800);
			
			s.Seek(4);
			version = s.ReadInt32();
			if (version != 5) throw new InvalidCacheFileException(s.FileName);

			fileLength = s.ReadInt32();

			int xbox = s.ReadInt32(); // Xbox only field

			offsetToIndex = s.ReadInt32();
			s.ReadInt32(); // stream size

			s.ReadInt32(); s.ReadInt32();

			name = s.ReadTagString();

			build = s.ReadTagString(); // Xbox only field. Always '400'
			cacheType = (CacheType)s.ReadInt16();
			s.ReadInt16();
			s.ReadInt32(); // CRC

			s.Seek((485 * sizeof(int)) + sizeof(uint), System.IO.SeekOrigin.Current);


			CacheFile cf = s.Owner as CacheFile;
			if (xbox != 0)
				cf.EngineVersion = BlamVersion.Stubbs_Xbox;
			else // no way to tell when it's mac, which just seems to use PC maps anyway (byte swaps everything when map is loaded)
				cf.EngineVersion = BlamVersion.Stubbs_PC;
		}
示例#6
0
		public CheApe(BlamLib.BlamVersion engine)
		{
			InitializeComponent();

			MainMenu.Renderer = MainForm.kOpenSauceIDEToolStripRenderer;
			FileViewMenu.Renderer = MainForm.kOpenSauceIDEToolStripRenderer;

			SetState(false);

			#region FileViewRoot
			this.FileViewRoot = new System.Windows.Forms.TreeNode("Project Files");
			FileViewRoot.ContextMenuStrip = this.FileViewMenu;
			FileViewRoot.Name = "FileViewRoot";
			this.FileView.Nodes.Add(FileViewRoot);
			#endregion

			OpenDialog.DefaultExt = kFileExt;
			OpenDialog.Filter = kFileFilter;

			SaveDialog.DefaultExt = kFileExt;
			SaveDialog.Filter = kFileFilter;

			OpenProjDialog.Multiselect = false;
			OpenProjDialog.Filter = BlamLib.IO.TagGroups.CheApeProject.Filter;

			SaveProjDialog.Filter = BlamLib.IO.TagGroups.CheApeProject.Filter;

			ProjectInterface = BlamLib.CheApe.Project.GetInterface(engine);
		}
示例#7
0
		public override void Read(BlamLib.IO.EndianReader s)
		{
			Blam.CacheFile.ValidateHeader(s, 0x800);
			
			s.Seek(4);
			s.ReadInt32(); // version, should be 5

			fileLength = s.ReadInt32();

			int xbox = s.ReadInt32(); // Xbox only field

			offsetToIndex = s.ReadInt32();
			s.ReadInt32(); // stream size

			s.ReadInt32(); s.ReadInt32();

			name = s.ReadTagString();

			build = s.ReadTagString(); // Xbox only field. Always '400'
			cacheType = (CacheType)s.ReadInt32();
			s.ReadInt32(); // CRC

			s.Seek((485 * sizeof(int)) + sizeof(uint), System.IO.SeekOrigin.Current);


			CacheFile cf = s.Owner as CacheFile;
			if (xbox != 0) cf.EngineVersion = BlamVersion.Stubbs_Xbox;
			else cf.EngineVersion = BlamVersion.Stubbs_PC; // no way to tell when its mac...
		}
示例#8
0
		public override void Read(BlamLib.IO.EndianReader s)
		{
			int pos = 0;

			Blam.CacheFile.ValidateHeaderAdjustEndian(s, 0x800);
			s.Seek(4);

			Halo1.Version ver = (Halo1.Version)(version = s.ReadInt32());
			fileLength = s.ReadInt32();
			if (fileLength < s.Length) throw new Debug.ExceptionLog("Compressed map editing not available yet!");

			s.ReadInt32();

			if (ver == Halo1.Version.PC_Demo)
			{
				pos = s.Position;
				s.Position = 0x5EC;
				offsetToIndex = s.ReadInt32();
				s.Position = pos;
			}
			else
				offsetToIndex = s.ReadInt32();

			tagBufferSize = s.ReadInt32();

			s.ReadInt32(); s.ReadInt32();

			if (ver == Halo1.Version.PC_Demo)
			{
				pos = s.Position;
				s.Position = 0x5E8;
				name = s.ReadTagString();
				s.Position = pos;
			}
			else
				name = s.ReadTagString();

			build = s.ReadTagString();
			cacheType = (CacheType)s.ReadInt16();
			s.ReadInt16();
			s.ReadInt32(); // CRC

			s.ReadInt32();
			s.Seek((484 * sizeof(int)) + sizeof(uint), System.IO.SeekOrigin.Current);

			CacheFile cache = s.Owner as CacheFile;
			if (ver == Halo1.Version.Xbox)										cache.EngineVersion = BlamVersion.Halo1_Xbox;
			else if (ver == Halo1.Version.PC || ver == Halo1.Version.PC_Demo)
			{
				if(s.State == IO.EndianState.Big)								cache.EngineVersion = BlamVersion.Halo1_XboxX;
				else
				{
					// Interestingly, HaloPC is build 01.00.00.0564, HA10 is build 01.00.01.0563
																				// Little
					if(build == "01.00.01.0563")								cache.EngineVersion = BlamVersion.Halo1_PCX;
					else														cache.EngineVersion = BlamVersion.Halo1_PC;
				}
			}
			else if (ver == Halo1.Version.CE)									cache.EngineVersion = BlamVersion.Halo1_CE;
		}
			/// <summary>Initialize state for processing a single tag</summary>
			/// <param name="instance"></param>
			/// <param name="base_dir"></param>
			/// <param name="name_override"></param>
			public void InitializeStateForTagInstance(BlamLib.Blam.CacheIndex.Item instance, string base_dir, string name_override)
			{
				m_sender = TagExtractionSender.TagInstance;

				Instance = instance;
				BaseDirectory = base_dir;
				NameOverride = name_override;
			}
示例#10
0
		void StringIdFieldsInitialize(BlamLib.CheApe.ProjectState state)
		{
			if (StringIdFieldDefinition != null) return;

			// Will add itself to the import state in the ctor
			StringIdFieldDefinition = new TagReference(state, kStringIdFieldDefinitionName, true, kStringIdGroupTag);
			StringIdFieldHandlePadding = new Field(state, state.kTypeIndexPad, "", kStringIdPadSize.ToString());
		}
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>   Gets the shader data from the tag. </summary>
		///
		/// <param name="tagIndex">     The parent tag index. </param>
		/// <param name="tagManager">   The tags' manager. </param>
		///
		/// <returns>   The shader data. </returns>
		private ModelShaderData GetShaderData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager)
		{
			var data = new ModelShaderData();

			data.CollectData(tagIndex, tagManager);

			return data;
		}
示例#12
0
		internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
		{
			//PredictedResources.DeleteAll();
			//EditorScenarioData.Delete();
			LevelData.DeleteAll();
			//SharedReferences.DeleteAll();
			//SimulationDefinitionTable.DeleteAll();

			return true;
		}
示例#13
0
			internal byte[] CacheRead(BlamLib.Blam.CacheFile c)
			{
				// read the cache block...
				byte[] bytes;
				if (!CacheRead(c, out bytes)) return null;

				if (c.EngineVersion == BlamVersion.Halo2_PC) // ...and perform zlib decompression
					bytes = Util.ZLibBufferFromBytes(bytes, 0, GetPixelDataSize(c.EngineVersion));

				return bytes;
			}
示例#14
0
			int CalculateSize(BlamLib.CheApe.ProjectState state, Field f)
			{
				int size = 0;

				if (f.TypeIndex == state.kTypeIndexPad || f.TypeIndex == state.kTypeIndexSkip)
					size = f.ToInt();
				else
					size = state.GetFieldSize(f.TypeIndex);

				return size;
			}
示例#15
0
			int CalculateSize(BlamLib.CheApe.ProjectState state, Field f, int kUselessPadTypeIndex)
			{
				if (f.TypeIndex == state.kTypeIndexPad ||
					f.TypeIndex == kUselessPadTypeIndex ||
					f.TypeIndex == state.kTypeIndexSkip)
					return f.ToInt();
				//else if (f.TypeIndex == kStructTypeIndex)
				//	((Struct)state.ImportedBlocks[f.ToString()]).Block.Latest.CalculateSize();
				else
					return state.GetFieldSize(f.TypeIndex);
			}
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>   Gets the scenario data from the tag. </summary>
		///
		/// <param name="tagIndex">     Zero-based index of the tag. </param>
		/// <param name="tagManager">   The tag's manager. </param>
		///
		/// <returns>   The scenario data. </returns>
		private ScenarioData GetScenarioData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager)
		{
			var data = new ScenarioData();

			data.MessageSent += MessageRedirect;

			data.CollectData(tagIndex, tagManager);

			data.MessageSent -= MessageRedirect;

			return data;
		}
示例#17
0
		public CacheView(BlamLib.BlamVersion engine)
		{
			InitializeComponent();

			MainMenu.Renderer = MainForm.kOpenSauceIDEToolStripRenderer;
			MenuTagInstance.Renderer = MainForm.kOpenSauceIDEToolStripRenderer;

			m_tagTreeEditorMode = TagTreeEditorMode.TagExtraction;
			m_engine = engine;
			m_cache = null;

			bool tag_extraction_supported = (engine & kAllowedPlatforms) != 0;
			ViewUpdateExtractionSupportedState(tag_extraction_supported, false);
		}
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>   Gets the BSP data from the tag. </summary>
		///
		/// <param name="tagIndex">     The parent tag index. </param>
		/// <param name="tagManager">   The tag's manager. </param>
		///
		/// <returns>   The bsp data. </returns>
		private StructureBSPData GetBSPData(TagIndexBase tagIndex, BlamLib.Managers.TagManager tagManager)
		{
			var data = new StructureBSPData()
			{
				IncludeRenderMesh = mBspData.ExportRenderMesh,
				IncludePortals = mBspData.ExportPortals,
				IncludeFogPlanes = mBspData.ExportFogPlanes,
				IncludeBSPMarkers = mBspData.ExportBSPMarkers
			};

			data.CollectData(tagIndex, tagManager);

			return data;
		}
示例#19
0
			/// <summary>
			/// Calculates the block size in bytes via the field for this block
			/// eliminating the need for programmers to aid designers in creating
			/// the tag group definition files
			/// </summary>
			/// <returns></returns>
			public int CalculateSize(BlamLib.CheApe.ProjectState state)
			{
				int size = 0;

				for (int x = 0; x < fields.Count; x++)
				{
					if (fields[x].TypeIndex == state.kTypeIndexArrayStart)
						size += CalculateSizeFromArrayStart(state, ref x);
					else
						size += CalculateSize(state, fields[x]);
				}

				return size;
			}
示例#20
0
			int CalculateSizeFromArrayStart(BlamLib.CheApe.ProjectState state, ref int current_index)
			{
				int array_size = 0;
				int array_count = fields[current_index++].ToInt();

				for (; ; current_index++)
					if (fields[current_index].TypeIndex == state.kTypeIndexArrayStart)
						array_size += CalculateSizeFromArrayStart(state, ref current_index);
					else if (fields[current_index].TypeIndex == state.kTypeIndexArrayEnd)
						break;
					else
						array_size += CalculateSize(state, fields[current_index]);

				return array_size * array_count;
			}
示例#21
0
			internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
			{
				bool result = true;

				if (ParticleSystemData.Count != 1)
				{
					particle_system_lite_data_block data;
					ParticleSystemData.Add(out data);

					result = data.Reconstruct(GeometryBlockInfo.Value);
				}

				GeometryBlockInfo.Value.ClearPostReconstruction();

				return result;
			}
		void OnTagInstanceExtractAs(BlamLib.Blam.CacheIndex.Item tag_instance)
		{
			SaveFileDlg.Filter = tag_instance.GroupTag.Filter;
			if (SaveFileDlg.ShowDialog(this) == DialogResult.OK)
			{
				string path = SaveFileDlg.FileName;
				var tiei = new TagInstanceExtractionInfo();

				tiei.InitializeStateForTagInstance(tag_instance,
					System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), @"\"),
					System.IO.Path.GetFileNameWithoutExtension(path));
				tiei.InitializeExtractionForTagInstance();

				bgwTagExtract.RunWorkerAsync(tiei);
			}
			SaveFileDlg.Filter = "";
		}
示例#23
0
文件: Bsp.cs 项目: CodeAsm/open-sauce
		internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
		{
			bool result = true;

			// recreate the section data
			if (RenderData.Count != 1)
			{
				structure_bsp_cluster_data_block_new cdata;
				RenderData.Add(out cdata);

				result = cdata.Section.Value.Reconstruct(c, SectionInfo.Value, GeometryBlockInfo.Value);
			}

			GeometryBlockInfo.Value.ClearPostReconstruction();

			return result;
		}
示例#24
0
		internal override bool Reconstruct(BlamLib.Blam.CacheFile c)
		{
			bool result = true;

			// recreate the section data
			if (CacheBlockData.Count != 1)
			{
				decorator_cache_block_data_block cdata;
				CacheBlockData.Add(out cdata);

				result = cdata.Reconstruct(GeometryBlockInfo.Value);
			}

			GeometryBlockInfo.Value.ClearPostReconstruction();

			return result;
		}
示例#25
0
			/// <summary>
			/// Calculates the block size in bytes via the field for this block
			/// eliminating the need for programmers to aid designers in creating
			/// the tag group definition files
			/// </summary>
			/// <returns></returns>
			public int CalculateSize(BlamLib.CheApe.ProjectState state)
			{
				int size = 0;

				int kUselessPadTypeIndex = state.Definition.GetTypeIndex("UselessPad");
				//int kStructTypeIndex = state.Definition.GetTypeIndex("Struct");

				for (int x = 0; x < fields.Count; x++)
				{
					if (fields[x].TypeIndex == state.kTypeIndexArrayStart)
						size += CalculateSizeFromArrayStart(state, ref x, kUselessPadTypeIndex);
					else
						size += CalculateSize(state, fields[x], kUselessPadTypeIndex);
				}

				return size;
			}
示例#26
0
		void OnApply(BlamLib.BlamVersion v)
		{
			Exception exception = null;
			CheApeInterface.UnlockToolsBase unlocker = null;

			switch(v)
			{
				case BlamLib.BlamVersion.Halo1_CE:
					try						{ unlocker = new CheApeInterface.UnlockH1(txtPathOutput.Text, txtPathGuerilla.Text, txtPathTool.Text, txtPathSapien.Text); }
					catch (Exception ex)	{ exception = ex; }
					break;

				case BlamLib.BlamVersion.Halo2_PC:
					try						{ unlocker = new CheApeInterface.UnlockH2(txtPathOutput.Text, txtPathGuerilla.Text, txtPathTool.Text, txtPathSapien.Text); }
					catch (Exception ex)	{ exception = ex; }
					break;

				default: MessageBox.Show(this, string.Format("the quarter ({0}) isn't under any of the cups you f****n cheater i kill you", cbEngineVersion.SelectedText),
							"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return;
			}

			if (unlocker != null) // If the unlocker api was initialized OK, run the unlocking operations
			{
				try
				{
					unlocker.Unlock(false);
					unlocker.Close();
				}
				catch (Exception ex)	{ exception = ex; }
			}

			if (exception != null)
				OnApplyException(v, exception);

			string msg = exception == null ? 
				"CheApe successfully applied!" :
				"There was an error while trying to apply CheApe. Validate that you selected copies of the original tools and try again.";

			if (unlocker.EncounteredInvalidExe)
				OnApplyMsg(true, "CheApe couldn't be applied to some or all of the exes. Check the debug log for more details");
			else
				OnApplyMsg(exception != null, msg);
		}
示例#27
0
			public void Read(BlamLib.CheApe.ProjectState state, IO.XmlStream s)
			{
				int array_start_depth = 0;

				foreach (XmlNode n in s.Cursor.ChildNodes)
				{
					if (n.Name != "field") continue;

					Field f;
					s.SaveCursor(n);
					fields.Add(f = new Field(state, s));
					s.RestoreCursor();

					if (f.TypeIndex == state.kTypeIndexArrayStart) array_start_depth++;
					else if (f.TypeIndex == state.kTypeIndexArrayEnd) array_start_depth--;
				}

				if (array_start_depth != 0)
					throw new Debug.ExceptionLog("Unterminated ArrayStart or extra ArrayEnd in '{0}'.{1}{2}", 
						s.FileName, Program.NewLine, s.Cursor.OuterXml);
			}
示例#28
0
		public CheApeApplier(BlamLib.BlamVersion version)
		{
			InitializeComponent();

			cbEngineVersion.Items.Add(BlamLib.BlamVersion.Halo1_CE);
			cbEngineVersion.Items.Add(BlamLib.BlamVersion.Halo2_PC);

			// NOTE: this isn't the best control logic for this. Will probably want to change this later
				 if (version == BlamLib.BlamVersion.Halo1_CE) cbEngineVersion.SelectedIndex = 0;
			else if (version == BlamLib.BlamVersion.Halo2_PC) cbEngineVersion.SelectedIndex = 1;

// 			txtPathOutput.Text = @"C:\Mount\B\Kornner\Projects\bin\_Halo1\";
// 			txtPathGuerilla.Text = @"C:\Program Files (x86)\Microsoft Games\Halo Custom Edition\guerilla.exe";
// 			txtPathTool.Text = @"C:\Program Files (x86)\Microsoft Games\Halo Custom Edition\tool.exe";
// 			txtPathSapien.Text = @"C:\Program Files (x86)\Microsoft Games\Halo Custom Edition\sapien.exe";

// 			txtPathOutput.Text = @"C:\Mount\B\Kornner\Projects\bin\_Halo2\";
// 			txtPathGuerilla.Text = @"C:\Program Files (x86)\Microsoft Games\Halo 2 Map Editor\H2Guerilla.exe";
// 			txtPathTool.Text = @"C:\Program Files (x86)\Microsoft Games\Halo 2 Map Editor\H2Tool.exe";
// 			txtPathSapien.Text = @"C:\Program Files (x86)\Microsoft Games\Halo 2 Map Editor\H2Sapien.exe";
		}
示例#29
0
			bool CacheRead(BlamLib.Blam.CacheFile c, out byte[] data)
			{
				data = null;

				ResourcePtr offset = GetOffset(0);
				int size = GetSize(0);

				var rsrc_cache = Program.Halo2.FromLocation(c as Halo2.CacheFile, offset);

				// the shared cache isn't loaded, break
				if (rsrc_cache == null)
					return false;

				// get the input stream we need
				IO.EndianReader er = rsrc_cache.InputStream;

				// read the bitmap
				er.Seek(offset.Offset);
				data = er.ReadBytes(size);

				return true;
			}
示例#30
0
		public static string ReadCString(uint offset, BlamLib.IO.EndianReader io)
		{
			if (offset == 0) return string.Empty;

			uint pos = io.PositionUnsigned;

			io.Seek(offset);

			byte btchar = 0;
			var cstring = new System.Text.StringBuilder();

			do
			{
				btchar = io.ReadByte();
				if (btchar != 0)
					cstring.Append((char)btchar);

			} while (btchar != 0);

			io.Seek(pos);

			return cstring.ToString();
		}