public FindChunkAndDecode ( int bitmap, int chunknumber, int mipmap, |
||
bitmap | int | The bitmap. |
chunknumber | int | The chunknumber. |
mipmap | int | The mipmap. |
meta | The meta. | |
map | The map. | |
visualchunkindex | int | The visualchunkindex. |
bspnumber | int | The bspnumber. |
Результат |
/// <summary> /// The h 2 shader info. /// </summary> /// <param name="TagIndex">The TagIndex.</param> /// <param name="map">The map.</param> /// <remarks></remarks> public void H2ShaderInfo(int TagIndex, Map map) { bool alreadyOpen = true; if (!(map.isOpen && map.openMapType == MapTypes.Internal)) { map.OpenMap(MapTypes.Internal); alreadyOpen = false; } this.TagIndex = TagIndex; if (this.TagIndex == -1) { return; } this.shaderName = map.FileNames.Name[this.TagIndex]; map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 4; int tempstem = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32()); if (tempstem != -1) { if (map.FileNames.Name[tempstem].IndexOf("alphatest") != -1) { this.Alpha = AlphaType.AlphaTest; } else if (map.FileNames.Name[tempstem].IndexOf("alpha") != -1) { this.Alpha = AlphaType.AlphaBlend; } else if (map.FileNames.Name[tempstem].IndexOf("water") != -1) { this.Alpha = AlphaType.AlphaBlend; } else { this.Alpha = AlphaType.None; } } else { this.Alpha = AlphaType.None; } map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 12; int tempc2 = map.BR.ReadInt32(); int tempr2 = map.BR.ReadInt32() - map.SecondaryMagic; if (tempc2 != 0) { map.BR.BaseStream.Position = tempr2 + 4; int tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32()); if (tempcrap != -1) { Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, false); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.MainName = map.FileNames.Name[tempcrap]; this.levels = pm.Properties[0].mipMapCount; } } //map.OpenMap(MapTypes.Internal); map.BR.BaseStream.Position = map.MetaInfo.Offset[this.TagIndex] + 32; tempc2 = map.BR.ReadInt32(); tempr2 = map.BR.ReadInt32() - map.SecondaryMagic; map.BR.BaseStream.Position = tempr2 + 24; int fuckr = map.BR.ReadInt32(); if (fuckr != 0) { fuckr -= map.SecondaryMagic; map.BR.BaseStream.Position = fuckr; this.primarydetailuscale = map.BR.ReadSingle(); this.primarydetailvscale = map.BR.ReadSingle(); this.primarydetailwscale = map.BR.ReadSingle(); map.BR.ReadSingle(); this.secondarydetailuscale = map.BR.ReadSingle(); this.secondarydetailvscale = map.BR.ReadSingle(); this.secondarydetailwscale = map.BR.ReadSingle(); } map.BR.BaseStream.Position = tempr2 + 4; tempc2 = map.BR.ReadInt32(); tempr2 = map.BR.ReadInt32() - map.SecondaryMagic; /* for (int x = 0; x < tempc2; x++) { map.BR.BaseStream.Position = tempr2 + (x * 12); int tempcrap = map.Functions.Meta.FindMetaByID(map.BR.ReadInt32(), map); if (tempcrap == -1) { continue; } Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, map, false); Raw.ParsedBitmap pm = new Raw.ParsedBitmap(ref tempmeta, map); Bitmaps.Add(pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0)); BitmapNames.Add(map.FileNames.Name[tempcrap]); } */ // map.BR.BaseStream.Position = tempr + 20; // tempc2 = map.BR.ReadInt32(); // tempr2 = map.BR.ReadInt32() - map.SecondaryMagic; // tempc2 = tempc; // tempr2 = tempr; if (tempc2 != 0) { map.BR.BaseStream.Position = tempr2; int tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32()); if (tempcrap != -1) { int test = map.FileNames.Name[tempcrap].IndexOf("reflection_maps"); if (map.FileNames.Name[tempcrap].IndexOf("_bump") != -1) { Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, false); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); // this.BumpMapBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.BumpMapName = map.FileNames.Name[tempcrap]; } else if (map.FileNames.Name[tempcrap].IndexOf("_cube_map") != -1) { Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, false); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); // this.CubeMapBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.CubeMapName = map.FileNames.Name[tempcrap]; } else if (map.FileNames.Name[tempcrap].IndexOf("default_") == -1 && this.MainBitmap == null && test == -1) { Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, false); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); // Try to load LOD2-MIP3 if that fails, load LOD2-MIP0, otherwise LOD0-MIP0 this.MainBitmap = pm.FindChunkAndDecode(0, 2, 3, ref tempmeta, map, 0, 0); if (this.MainBitmap == null) { this.MainBitmap = pm.FindChunkAndDecode(0, 2, 0, ref tempmeta, map, 0, 0); if (this.MainBitmap == null) this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); } this.MainName = map.FileNames.Name[tempcrap]; this.levels = pm.Properties[0].mipMapCount; } else if (test != -1) { map.BR.BaseStream.Position += 8; tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32()); Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, false); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); // this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map); // this.MainName = map.FileNames.Name[tempcrap]; } } map.BR.BaseStream.Position = tempr2 + 24; tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32()); if (tempcrap != -1 && this.MainBitmap == null) { Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, false); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.MainName = map.FileNames.Name[tempcrap]; this.levels = pm.Properties[0].mipMapCount; } else if (this.MainBitmap == null) { map.BR.BaseStream.Position = tempr2 + 12; tempcrap = map.Functions.ForMeta.FindMetaByID(map.BR.ReadInt32()); if (tempcrap != -1) { Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(tempcrap, false); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.MainName = map.FileNames.Name[tempcrap]; this.levels = pm.Properties[0].mipMapCount; } } } if (!alreadyOpen) { map.CloseMap(); } }
private void loadSkin() { animation = new List<animationData>(); bitmapBlocks = new List<bitmapData>(); textBlocks = new List<textBlockData>(); BinaryReader br = new BinaryReader(meta.MS); BinaryReader br2 = br; #region Animation Frames reflexive br2 = br; br.BaseStream.Position = 20; int animationCount = br.ReadInt32(); int animationOffset = br.ReadInt32() - map.SecondaryMagic; // Handles reflexives in other tags (pointers) int animationTag = map.Functions.ForMeta.FindMetaByOffset(animationOffset); if (animationCount > 0 && animationTag != meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(animationTag, meta.Map, false, true); br2 = new BinaryReader(newMeta.MS); animationOffset -= newMeta.offset; } else animationOffset -= meta.offset; for (int list = 0; list < animationCount; list++) { animationData ad = new animationData(list, meta); ad.offset = animationOffset + list * 16; ad.Read(br2); this.animation.Add(ad); } #endregion #region Text blocks reflexive br2 = br; br.BaseStream.Position = 28; int textBlockCount = br.ReadInt32(); int textBlockOffset = br.ReadInt32() - map.SecondaryMagic; // Handles reflexives in other tags (pointers) int textBlockTag = map.Functions.ForMeta.FindMetaByOffset(textBlockOffset); if (textBlockCount > 0 && textBlockTag != meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(textBlockTag, map, false, true); br2 = new BinaryReader(newMeta.MS); textBlockOffset -= newMeta.offset; } else textBlockOffset -= meta.offset; for (int list = 0; list < textBlockCount; list++) { textBlockData tbd = new textBlockData(list); tbd.offset = textBlockOffset + list * 44; tbd.Read(br2); this.textBlocks.Add(tbd); } #endregion #region Bitmap block reflexive br.BaseStream.Position = 36; int bitmapBlockCount = br.ReadInt32(); int bitmapBlockOffset = br.ReadInt32() - map.SecondaryMagic; // Handles reflexives in other tags (pointers) int bitmBlockTag = map.Functions.ForMeta.FindMetaByOffset(bitmapBlockOffset); if (bitmapBlockCount > 0 && bitmBlockTag != meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(bitmBlockTag, map, false, true); br2 = new BinaryReader(newMeta.MS); bitmapBlockOffset -= newMeta.offset; } else bitmapBlockOffset -= meta.offset; // Always add 3 in case of using sub bitmaps for (int list = 0; list < bitmapBlockCount; list++) { bitmapData bd = new bitmapData(list); bd.offset = bitmapBlockOffset + list * 56; bd.Read(br2); int bitmID = map.Functions.ForMeta.FindMetaByID(bd.bitmIdent); if (bitmID != -1) { bd.meta = Map.GetMetaFromTagIndex(bitmID, map, false, false); ParsedBitmap pm = new ParsedBitmap(ref bd.meta, map); bd.link = pm.FindChunkAndDecode(0, 0, 0, ref bd.meta, map, 0, 0); this.bitmapBlocks.Add(bd); if (pm.Properties.Length > 1) { bd = (bitmapData)bd.Clone(); bd.link = pm.FindChunkAndDecode(1, 0, 0, ref bd.meta, map, 0, 0); } this.bitmapBlocks.Add(bd); if (pm.Properties.Length > 2) { bd = (bitmapData)bd.Clone(); bd.link = pm.FindChunkAndDecode(2, 0, 0, ref bd.meta, map, 0, 0); } this.bitmapBlocks.Add(bd); } } #endregion isLoaded = true; }
/// <summary> /// The tree view 1_ after select. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (treeView1.SelectedNode.Level == 2) { currBitm = treeView1.SelectedNode.Parent.Parent.Index; currChunk = treeView1.SelectedNode.Parent.Index; currMipMap = treeView1.SelectedNode.Index; } else if (treeView1.SelectedNode.Level == 1) { currBitm = treeView1.SelectedNode.Parent.Index; currChunk = treeView1.SelectedNode.Index; currMipMap = 0; } else { currBitm = treeView1.SelectedNode.Index; currChunk = 0; currMipMap = 0; } DisplayBitmap(currBitm, currChunk, currMipMap); object o = ((Form)this.TopLevelControl).ActiveMdiChild; if (o is MapForm) { MapForm mf = (MapForm)o; Meta meta = map.SelectedMeta; ParsedBitmap pm = new ParsedBitmap(ref meta, map); Bitmap b = pm.FindChunkAndDecode(currBitm, currChunk, currMipMap, ref meta, map, 0, 0); mf.pictureBox = (Bitmap)pictureBox1.Image.Clone(); mf.statusBarText = (Math.Max(pm.Properties[currBitm].width >> currChunk >> currMipMap,1)).ToString().PadLeft(4) + " X " + (Math.Max(pm.Properties[currBitm].height >> currChunk >> currMipMap,1)).ToString().PadRight(4) + "X " + (Math.Max(pm.Properties[currBitm].depth >> currChunk >> currMipMap,1)).ToString().PadRight(4) + " " + ("(" + pm.Properties[currBitm].typename.ToString().Remove(0, 10) + ") ").PadRight(10) + pm.Properties[currBitm].formatname.ToString().Remove(0, 12).PadRight(10) + " - Swizzle:" + pm.Properties[0].swizzle + "- Location: " + meta.raw.rawChunks[0].rawLocation; } }
/// <summary> /// The ce shader info. /// </summary> /// <param name="TagIndex">The TagIndex.</param> /// <param name="map">The map.</param> /// <remarks></remarks> public void CEShaderInfo(int TagIndex, Map map) { this.TagIndex = TagIndex; if (this.TagIndex == -1) { return; } this.shaderName = map.FileNames.Name[this.TagIndex]; map.OpenMap(MapTypes.Internal); int mainid = 0; int primarydetail = -1; int secondarydetail = -1; int micro = -1; switch (map.MetaInfo.TagType[TagIndex]) { case "schi": map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 228; mainid = map.BR.ReadInt32(); break; case "soso": map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 176; mainid = map.BR.ReadInt32(); break; case "sgla": map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 356; mainid = map.BR.ReadInt32(); break; case "scex": map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 900; mainid = map.BR.ReadInt32(); break; case "senv": map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 148; mainid = map.BR.ReadInt32(); map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 180; this.primarydetailuscale = map.BR.ReadSingle(); this.primarydetailvscale = this.primarydetailuscale; this.primarydetailwscale = 1; map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 196; primarydetail = map.BR.ReadInt32(); map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 200; this.secondarydetailuscale = map.BR.ReadSingle(); this.secondarydetailvscale = this.secondarydetailuscale; this.secondarydetailwscale = 1; map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 216; secondarydetail = map.BR.ReadInt32(); map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 248; this.microdetailuscale = map.BR.ReadSingle(); this.microdetailvscale = this.secondarydetailuscale; this.microdetailwscale = 1; map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 264; micro = map.BR.ReadInt32(); map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 40; byte alphatest = map.BR.ReadByte(); int test = alphatest & 1; if (test != 0) { this.Alpha = AlphaType.AlphaTest; } break; case "swat": map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 88; mainid = map.BR.ReadInt32(); break; case "smet": map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 88; mainid = map.BR.ReadInt32(); break; } map.CloseMap(); mainid = map.Functions.ForMeta.FindMetaByID(mainid); primarydetail = map.Functions.ForMeta.FindMetaByID(primarydetail); secondarydetail = map.Functions.ForMeta.FindMetaByID(secondarydetail); micro = map.Functions.ForMeta.FindMetaByID(micro); if (mainid == -1) { return; } if (map.MetaInfo.external[mainid]) { map.OpenMap(MapTypes.Bitmaps); } else { map.OpenMap(MapTypes.Internal); } Meta tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(mainid, false); map.CloseMap(); ParsedBitmap pm = new ParsedBitmap(ref tempmeta, map); // Attempt to load LOD2, if that fails, load LOD0 try { this.MainBitmap = pm.FindChunkAndDecode(0, 2, 0, ref tempmeta, map, 0, 0); } catch { this.MainBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); } this.MainName = map.FileNames.Name[mainid]; if (primarydetail != -1) { if (map.MetaInfo.external[primarydetail]) { map.OpenMap(MapTypes.Bitmaps); } else { map.OpenMap(MapTypes.Internal); } tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(primarydetail, false); map.CloseMap(); pm = new ParsedBitmap(ref tempmeta, map); this.primarydetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.primarydetailName = map.FileNames.Name[primarydetail]; } if (secondarydetail != -1) { if (map.MetaInfo.external[secondarydetail]) { map.OpenMap(MapTypes.Bitmaps); } else { map.OpenMap(MapTypes.Internal); } tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(secondarydetail, false); map.CloseMap(); pm = new ParsedBitmap(ref tempmeta, map); this.secondarydetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.secondarydetailName = map.FileNames.Name[secondarydetail]; } if (micro != -1) { if (map.MetaInfo.external[micro]) { map.OpenMap(MapTypes.Bitmaps); } else { map.OpenMap(MapTypes.Internal); } tempmeta = new Meta(map); tempmeta.ReadMetaFromMap(micro, false); map.CloseMap(); pm = new ParsedBitmap(ref tempmeta, map); this.microdetailBitmap = pm.FindChunkAndDecode(0, 0, 0, ref tempmeta, map, 0, 0); this.microdetailName = map.FileNames.Name[micro]; } }
/// <summary> /// The btn load image_ click. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void btnLoadImage_Click(object sender, EventArgs e) { OpenFileDialog getImage = new OpenFileDialog(); getImage.InitialDirectory = Prefs.pathBitmapsFolder; getImage.DefaultExt = "dds"; getImage.Filter = "DDS & Map files|*.dds;*.map|DDS files (*.dds)|*.dds|Map Files (*.map)|*.map"; if (getImage.ShowDialog() == DialogResult.OK) { Prefs.pathBitmapsFolder = getImage.FileName.Substring(0, getImage.FileName.LastIndexOf('\\')); if (getImage.FileName.EndsWith("dds", StringComparison.OrdinalIgnoreCase)) { FileStream fs = new FileStream(getImage.FileName, FileMode.Open); BinaryReader br = new BinaryReader(fs); DDS.DDS_HEADER_STRUCTURE dds = new DDS.DDS_HEADER_STRUCTURE(); dds.ReadStruct(ref br); int tempsize = dds.ddsd.width * dds.ddsd.height; switch (dds.ddsd.ddfPixelFormat.FourCC) { case "DXT1": tempsize /= 2; break; case "DXT2": case "DXT3": case "DXT4": case "DXT5": // tempsize /= 1; break; // for non-compressed default: tempsize *= dds.ddsd.ddfPixelFormat.RGBBitCount >> 3; break; } int widthPad = 0; if (dds.ddsd.width % 16 != 0) widthPad = 16 - dds.ddsd.width % 16; int byteStep = dds.ddsd.ddfPixelFormat.RGBBitCount / 8; byte[] guh = new byte[tempsize + (dds.ddsd.height * widthPad * byteStep)]; if (widthPad == 0) { br.BaseStream.Read(guh, 0, guh.Length); } else { // Change data to include padding for (int h = 0; h < dds.ddsd.height; h++) { br.BaseStream.Read( guh, h * (dds.ddsd.width + widthPad) * byteStep, dds.ddsd.width * byteStep); } } br.Close(); fs.Close(); int tagNum = map.Functions.ForMeta.FindMetaByID( currentLevels[lbMapListing.SelectedIndex].Preview_Image_Ident); if (tagNum != -1) { map.SelectedMeta = Map.GetMetaFromTagIndex(tagNum, map, false, false); } #region Confirm 224x207 A8R8G8B8 file and save to CurrentLevel[].ScreenShot & Cur...[].ScreenShotRaw ParsedBitmap.BitmapFormat bmf = DDS.getBitmapFormat(dds); if ((bmf == ParsedBitmap.BitmapFormat.BITM_FORMAT_A8R8G8B8) && (dds.ddsd.width + widthPad == 224) && (dds.ddsd.height == 207)) { currentLevels[lbMapListing.SelectedIndex].screenShotRaw.MS.Position = 0; currentLevels[lbMapListing.SelectedIndex].screenShotRaw.MS.Write( guh, 0, (int)Math.Min(map.SelectedMeta.raw.rawChunks[0].MS.Length, guh.Length)); currentLevels[lbMapListing.SelectedIndex].screenShotRaw.size = (int)currentLevels[lbMapListing.SelectedIndex].screenShotRaw.MS.Length; currentLevels[lbMapListing.SelectedIndex].screenShot = ParsedBitmap.DecodeBitm( guh, dds.ddsd.height, dds.ddsd.width, dds.ddsd.depth, dds.ddsd.ddfPixelFormat.RGBBitCount, ParsedBitmap.BitmapType.BITM_TYPE_2D, bmf, false, null, -1, -1); pbMapBitmap.Image = currentLevels[lbMapListing.SelectedIndex].screenShot; } else { MessageBox.Show("Bitmap must be a 224x207 A8R8G8B8 file"); } #endregion } else if (getImage.FileName.EndsWith("map", StringComparison.OrdinalIgnoreCase)) { this.Enabled = false; Map tempmap = Map.LoadFromFile(getImage.FileName); this.Enabled = true; if (tempmap == null) { MessageBox.Show("Unable to load image from map: " + getImage.FileName); return; } // Load Map Picture as raw data (for transfer) and Bitmap (for display) tempmap.OpenMap(MapTypes.Internal); Meta m = MapForm.GetMapBitmapMeta(tempmap); ////////////////////////////////// // Backwash for example has no internal picture, so it errors. ////////////////////////////////// if (m != null) { currentLevels[lbMapListing.SelectedIndex].screenShotRaw = m.raw.rawChunks[0]; ParsedBitmap pm = new ParsedBitmap(ref m, tempmap); currentLevels[lbMapListing.SelectedIndex].screenShot = pm.FindChunkAndDecode( 0, 0, 0, ref m, tempmap, 0, 0); } else { // No map listing found } tempmap.CloseMap(); pbMapBitmap.Image = currentLevels[lbMapListing.SelectedIndex].screenShot; } } }
/// <summary> /// The load bitmaps. /// </summary> /// <remarks></remarks> private void loadBitmaps() { Map thisMap = map; // Load Map Bitmap & RawChunk for Campaign for (int i = 0; i < campaignLevels.Count; i++) { int metaNum = map.Functions.ForMeta.FindMetaByID(campaignLevels[i].Preview_Image_Ident); if (metaNum != -1) { Meta m = Map.GetMetaFromTagIndex(metaNum, map, false, false); campaignLevels[i].screenShotRaw = m.raw.rawChunks[0]; campaignLevels[i].screenShotOffset = m.raw.rawChunks[0].offset; ParsedBitmap pm = new ParsedBitmap(ref m, map); campaignLevels[i].screenShot = pm.FindChunkAndDecode(0, 0, 0, ref m, map, 0, 0); } } // Load Map Bitmap & RawChunk for MP for (int i = 0; i < MPLevels.Count; i++) { int metaNum = map.Functions.ForMeta.FindMetaByID(MPLevels[i].Preview_Image_Ident); if (metaNum != -1) { Meta m = Map.GetMetaFromTagIndex(metaNum, map, false, false); MPLevels[i].screenShotRaw = m.raw.rawChunks[0]; MPLevels[i].screenShotOffset = m.raw.rawChunks[0].offset; ParsedBitmap pm = new ParsedBitmap(ref m, map); MPLevels[i].screenShot = pm.FindChunkAndDecode(0, 0, 0, ref m, map, 0, 0); } // Checks the offsets to see if they are shared. // Allows us to know if we need to internalize a new bitmap when adding maps for (int j = 0; j < i; j++) { if (MPLevels[i].screenShotOffset == MPLevels[j].screenShotOffset) { if (MPLevels[i].mapID != -1 && MPLevels[j].mapID == -1) { MPLevels[j].screenShotOriginal = false; } else if (MPLevels[i].mapID == -1 && MPLevels[j].mapID != -1) { MPLevels[i].screenShotOriginal = false; } else { MPLevels[i].screenShotOriginal = false; MPLevels[j].screenShotOriginal = false; } } } } }
/// <summary> /// The load lightmaps. /// </summary> /// <remarks></remarks> public void LoadLightmaps() { if (map.BSP.sbsp[this.BspNumber].LightMap_TagNumber == -1) { LightMapBitmap = new Bitmap[this.BSPRawDataMetaChunks.Length]; SceneryLightMapBitmap = new Bitmap[this.PermutationInfo.Length]; return; } map.OpenMap(MapTypes.Internal); Meta m = new Meta(map); m.ReadMetaFromMap(map.BSP.sbsp[this.BspNumber].LightMap_TagNumber, false); ParsedBitmap pb = new ParsedBitmap(ref m, map); LightMapBitmap = new Bitmap[this.BSPRawDataMetaChunks.Length]; for (int x = 0; x < this.BSPRawDataMetaChunks.Length; x++) { int visualchunk = map.BSP.sbsp[this.BspNumber].VisualChunk_Bitmap_Index[x]; if (visualchunk == -1) { LightMapBitmap[x] = null; continue; } LightMapBitmap[x] = pb.FindChunkAndDecode(visualchunk, 0, 0, ref m, m.Map, x, this.BspNumber); } SceneryLightMapBitmap = new Bitmap[this.PermutationInfo.Length]; for (int x = 0; x < this.PermutationInfo.Length; x++) { int visualchunk = map.BSP.sbsp[this.BspNumber].SceneryChunk_Bitmap_Index[x]; if (visualchunk == -1) { SceneryLightMapBitmap[x] = null; continue; } SceneryLightMapBitmap[x] = pb.FindChunkAndDecode( visualchunk, 0, 0, ref m, m.Map, -x - 1, this.BspNumber); } map.CloseMap(); }
/// <summary> /// The add map. /// </summary> /// <param name="filename">The filename.</param> /// <remarks></remarks> private void addMap(string filename) { if (currentLevels[currentLevels.Count - 1].mapID != -1) { MessageBox.Show("There are already " + currentLevels.Count + " maps! No more can be added."); return; } Map tempmap = Map.LoadFromFile(filename); if (tempmap == null) { MessageBox.Show("Unable to load MAP: " + filename); } // Set default gametype numbers gametypes gameTypes = new gametypes(); // Load SCNR tag for (int i = 0; i < tempmap.IndexHeader.metaCount; i++) { if (tempmap.MetaInfo.TagType[i] == "scnr") { tempmap.SelectedMeta = Map.GetMetaFromTagIndex(1, tempmap, false, false); break; } } Meta m = tempmap.SelectedMeta; BinaryReader br = new BinaryReader(m.MS); // Netgame flags, size 32 br.BaseStream.Position = 280; int netgameFlagsCount = br.ReadInt32(); int netgameFlagsOffset = br.ReadInt32() - m.offset - m.magic; for (int i = 0; i < netgameFlagsCount; i++) { // offset 16 is netgame type (0-1=CTF, 2-3=Assault, 4=Odball, 6=Race, 9=Headhunter, 10=Territories, 11-18=KOTH) br.BaseStream.Position = netgameFlagsOffset + i * 32 + 16; int gameType = br.ReadInt16(); int teamNum = br.ReadInt16(); // We only need to check CTF & Assault. For all else, it will default to 8 teams max if (gameType == 0 || gameType == 1) { gameTypes.gameTypes[(int)gametypes.gameTypesNames.CTF].Teams[teamNum] = true; } else if (gameType == 2 || gameType == 3) { gameTypes.gameTypes[(int)gametypes.gameTypesNames.Assault].Teams[teamNum] = true; } } // Start new MapID at 90 for MP, 101 for Campaign int newID = currentLevels[0].campaignNumber == -1 ? 90 : 201; for (int i = 0; i < currentLevels.Count; i++) { if (currentLevels[i].MapID == newID) { // increase MapID by 10 for MP, 100 for Campaign and restart search newID = currentLevels[i].MapID + (currentLevels[0].campaignNumber == -1 ? 10 : 100); i = -1; } } mapInfo newMap = new mapInfo(tempmap.MapHeader.mapName.Trim('\0'), tempmap.MapHeader.scenarioPath, newID); gameTypes.Save(newMap); // Load Map Picture as raw data (for transfer) and Bitmap (for display) tempmap.OpenMap(MapTypes.Internal); m = MapForm.GetMapBitmapMeta(tempmap); ////////////////////////////////// // Backwash for example has no internal picture, so it errors. ////////////////////////////////// if (m != null) { newMap.screenShotRaw = m.raw.rawChunks[0]; ParsedBitmap pm = new ParsedBitmap(ref m, tempmap); newMap.screenShot = pm.FindChunkAndDecode(0, 0, 0, ref m, tempmap, 0, 0); } else { newMap.screenShotRaw = new RawDataChunk(); newMap.screenShotRaw.MS = new MemoryStream(); newMap.screenShotRaw.pointerMetaOffset = 104; } tempmap.CloseMap(); // Save the current Map Bitmap Offset listing in case a map has been added, then removed, so we don't keep // adding new un-needed Raw Listings newMap.screenShotOffset = currentLevels[lbMapListing.Items.Count].screenShotOffset; // Insert the new map & remove the current listing to make sure that we keep the same # of maps total for // when we rewrite currentLevels[this.lbMapListing.Items.Count] = newMap; this.lbMapListing.Items.Add(newMap.Name); }
/// <summary> /// The load meta. /// </summary> /// <param name="tag">The tag.</param> /// <remarks></remarks> public void LoadMeta(int tag) { Meta meta = Map.GetMetaFromTagIndex(tag, map, scanbspwithifp.Checked, parsedCheckBox.Checked); map.SelectedMeta = meta; buttonInternalize.Visible = false; if (meta.type == "bitm") { // ;&&Map.HaloVersion!= Map.HaloVersionEnum.Halo1 ) ParsedBitmap pm = new ParsedBitmap(ref meta, map); Bitmap b = pm.FindChunkAndDecode(0, 0, 0, ref meta, map, 0, 0); // Raw.ParsedBitmap.BitmapInfo bmInfo = new Entity.Raw.ParsedBitmap.BitmapInfo(pm.Properties[0].formatname, pm.Properties[0].swizzle); // b = DDS_Convert.DecodeDDS( DDS_Convert.EncodeDDS(b, ref bmInfo), bmInfo ); pictureBox1.Image = b; pictureBox1.Tag = 0; statusbar.Text = pm.Properties[0].width.ToString().PadLeft(4) + " X " + pm.Properties[0].height.ToString().PadRight(4) + " " + ("(" + pm.Properties[0].typename.ToString().Remove(0, 10) + ") ").PadRight(10) + pm.Properties[0].formatname.ToString().Remove(0, 12).PadRight(10) + " - Swizzle:" + pm.Properties[0].swizzle + "- Location: " + meta.raw.rawChunks[0].rawLocation; if (meta.raw.rawChunks[0].rawLocation != MapTypes.Internal) { buttonInternalize.Visible = true; } timer1.Start(); } else { statusbar.Text = string.Empty; } // Main Form Offsets/Idents/etc metaOffsetBox.Text = "0x" + meta.offset.ToString("X8") + "\n" + meta.offset.ToString("N0") + " bytes"; metaSizeBox.Text = "0x" + meta.size.ToString("X4") + "\n" + meta.size.ToString("N0") + " bytes"; metaIdentBox.Text = meta.ident.ToString("X"); metaTypeBox.Text = meta.type; if (meta.raw != null) { int tempRawSize = 0; for (int i = 0; i < meta.raw.rawChunks.Count; i++) { tempRawSize += meta.raw.rawChunks[i].size; } metaRawBox.Text = "0x" + tempRawSize.ToString("X4") + "\n" + tempRawSize.ToString("N0") + " bytes"; } else metaRawBox.Text = "n/a"; switch (meta.type) { case "PRTM": rawDataDropDown.DropDown = prtmcontext; rawDataDropDown.Enabled = true; break; case "mode": case "mod2": rawDataDropDown.DropDown = ModelContextStrip; rawDataDropDown.Enabled = true; break; case "bitm": rawDataDropDown.DropDown = BitmapContextStrip; rawDataDropDown.Enabled = true; if (ltmpTools.Visible) { bitmapEditorToolStripMenuItem_Click(bitmapEditorToolStripMenuItem, null); } break; case "sbsp": rawDataDropDown.DropDown = BSPcontextMenu; rawDataDropDown.Enabled = true; break; case "coll": rawDataDropDown.DropDown = collContextMenu; rawDataDropDown.Enabled = true; break; default: rawDataDropDown.Enabled = false; break; } switch (getEditorMode()) { case EditorModes.HexViewer: hexView1.Reload(meta, map); hexView1.Setup(map.filePath); break; case EditorModes.MetaEditor1: if (map.SelectedMeta != null) { if (this.metaEditor1.selectedTagType == map.SelectedMeta.type) { this.metaEditor1.ReloadMetaForSameTagType(true); } else { this.metaEditor1.loadControls(map); } } break; case EditorModes.MetaEditor2: if (map.SelectedMeta != null) { if (wME == null || wME.IsDisposed) { wME = new entity.MetaEditor2.WinMetaEditor(this, map); wME.BackgroundColor = this.LibraryPanel.BackColor; wME.ForegroundColor = this.LibraryPanel.ForeColor; wME.TopLevel = false; this.MetaEditor2Panel.Controls.Add(wME); MetaEditor2Panel.BringToFront(); wME.FormBorderStyle = FormBorderStyle.None; wME.FormClosed += new FormClosedEventHandler(wME_FormClosed); } // If we are not switching from a different editor mode (on MetaEditor2) and // we already have the current tag loaded in the editor, then we can load a duplicate wME.addNewTab(map.SelectedMeta, getEditorMode() == EditorModes.MetaEditor2 && wME.tabs.Tabs.Count > 0 && wME.tabs.SelectedTab.Text == ("[" + map.SelectedMeta.type + "] " + map.SelectedMeta.name.Substring(map.SelectedMeta.name.LastIndexOf('\\') + 1))); wME.Dock = DockStyle.Fill; } break; case EditorModes.ReferenceEditor: formFuncs.AddReferencesToListView(meta, references, map.DisplayType); break; } if (selectedplugin != -1 && LibraryPanel.Visible) { if (plugins.Plugin[selectedplugin].tagtype == meta.type || plugins.Plugin[selectedplugin].tagtype == "!*.*") { plugins.Plugin[selectedplugin].Run(map, ref progressbar); } } UpdatePluginsMenu(); Prefs.Save(); AddToHistory(tag); }
private void timer1_Tick(object sender, EventArgs e) { if (map.SelectedMeta.type != "bitm") { timer1.Stop(); return; } if (!showAnimatedBitmapsToolStripMenuItem.Checked) return; ParsedBitmap pm = new ParsedBitmap(ref map.SelectedMeta, map); // Show next frame of 3D images if (pm.Properties[0].typename == ParsedBitmap.BitmapType.BITM_TYPE_3D) #region 3D images { pictureBox1.Image.Dispose(); // For 3D images, bitmapCount = pm.Properties[0].depth + 1 because index 0 is an overview if (bitmapCount > pm.Properties[0].depth) bitmapCount = 1; Bitmap b = pm.FindChunkAndDecode(0, 0, 0, ref map.SelectedMeta, map, bitmapCount++, 0); pictureBox1.Image = b; return; } #endregion // For Sequenced images, show next sprite else #region 2D Sequenced Images { int sprites = 1; BinaryReader br = new BinaryReader(map.SelectedMeta.MS); br.BaseStream.Seek(60, SeekOrigin.Begin); int seqCount = br.ReadInt32(); int seqOffset = br.ReadInt32() - map.SelectedMeta.magic - map.SelectedMeta.offset; if (seqCount > 0) { // Allows the animated picture to cycle through different animations every 6 seconds int sequenceSelect = (DateTime.Now.Minute * 60 + DateTime.Now.Second) / 6 % seqCount; br.BaseStream.Seek(seqOffset + sequenceSelect * 60 + 32, SeekOrigin.Begin); int bitmIndex = br.ReadInt16(); // Always 0? int bitmCount = br.ReadInt16(); // Always 0? #if DEBUG if (bitmIndex + bitmCount > 0) { //MessageBox.Show("DEBUG ONLY: Found a Bitmap with Index or Count > 0"); } #endif br.BaseStream.Seek(seqOffset + sequenceSelect * 60 + 52, SeekOrigin.Begin); int sprCount = br.ReadInt32(); int sprOffset = br.ReadInt32() - map.SelectedMeta.magic - map.SelectedMeta.offset; if (sprCount != 0) { if (pictureBox1.Tag == null) pictureBox1.Tag = 0; int currentSprite = (int)pictureBox1.Tag; pictureBox1.Tag = currentSprite = (currentSprite + 1) % sprCount; // Each sprite record is 32 bytes in length, values start at offset 8 br.BaseStream.Seek(sprOffset + currentSprite * 32 + 8, SeekOrigin.Begin); // The following are ratios between 0 - 1) float Left = br.ReadSingle(); float Right = br.ReadSingle(); float Top = br.ReadSingle(); float Bottom = br.ReadSingle(); Bitmap b = pm.FindChunkAndDecode(bitmIndex, 0, 0, ref map.SelectedMeta, map, 0, 0); if (pictureBox1.Image != null) { ((IDisposable)pictureBox1.Image).Dispose(); pictureBox1.Image = null; } pictureBox1.Image = b.Clone( new RectangleF( Left * b.Width, Top * b.Height, (Right - Left) * b.Width, (Bottom - Top) * b.Height), b.PixelFormat); if (b.Tag != null) Marshal.FreeHGlobal((IntPtr)b.Tag); b.Dispose(); return; } } } #endregion // If it is neither, stop further image updates //timer1.Stop(); }
/// <summary> /// The display map bitmap. /// </summary> /// <remarks></remarks> public void DisplayMapBitmap() { map.OpenMap(MapTypes.Internal); try { Meta m = GetMapBitmapMeta(map); if (m != null) { ParsedBitmap pm = new ParsedBitmap(ref m, map); //if (bitmMainPtr != IntPtr.Zero) //{ // Marshal.FreeHGlobal(bitmMainPtr); //} pictureBox1.Image = pm.FindChunkAndDecode(0, 0, 0, ref m, map, 0, 0); } } catch { // Who cares if we can't load the map bitmap due to a missing MainMenu.map? } finally { map.CloseMap(); } }
// Used for Injection Selection box /// <summary> /// The convert to bump map tool strip menu item_ click. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> /// <remarks></remarks> private void convertToBumpMapToolStripMenuItem_Click(object sender, EventArgs e) { if (saveBitmapDialog1.ShowDialog() == DialogResult.Cancel) { return; } Panel p = new Panel(); Renderer r = new Renderer(); r.CreateDevice(p); map.OpenMap(MapTypes.Internal); ParsedBitmap pm = new ParsedBitmap(ref map.SelectedMeta, map); Bitmap b = pm.FindChunkAndDecode(0, 0, 0, ref map.SelectedMeta, map, 0, 0); ShaderInfo s = new ShaderInfo(); s.BumpMapBitmap = b; map.CloseMap(); s.MakeTextures(ref r.device); TextureLoader.Save(saveBitmapDialog1.FileName, ImageFileFormat.Dds, s.NormalMap); }
private void lbPanes_SelectedIndexChanged(object sender, EventArgs e) { if (lbPanes.Focused) writePaneToMemory(); if (lbPanes.SelectedIndex == -1) return; paneData pd = (paneData)lbPanes.SelectedItem; br = new BinaryReader(pd.meta.MS); #region Bitmaps // Clear the list of bitmaps pd.bitmaps.Clear(); // Add a default "no selection" to the top of the list pd.bitmaps.Add(new bitmapData(0)); pd.bitmaps[0].title = "<None>"; br.BaseStream.Position = pd.offset + 36; int bitmapCount = br.ReadInt32(); int bitmapOffset = br.ReadInt32() - map.SecondaryMagic; if (bitmapCount > 0) { BinaryReader br2 = br; // Handle pointers to other tags int bitmTag = map.Functions.ForMeta.FindMetaByOffset(bitmapOffset); if (bitmTag != currentScreen.meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(bitmTag, map, false, true); br2 = new BinaryReader(newMeta.MS); bitmapOffset -= newMeta.offset; } else bitmapOffset -= currentScreen.meta.offset; for (int bitmaps = 0; bitmaps < bitmapCount; bitmaps++) { bitmapData bitmSD = new bitmapData(bitmaps); bitmSD.offset = bitmapOffset + bitmaps * 56; bitmSD.Read(br2); int tagNum = bitmSD.bitmIdent != -1 ? (int)map.MetaInfo.identHT[bitmSD.bitmIdent] : -1; if (tagNum != -1) { bitmSD.meta = Map.GetMetaFromTagIndex(tagNum, map, false, true); bitmSD.title = map.FileNames.Name[tagNum].Substring(map.FileNames.Name[tagNum].LastIndexOf('\\') + 1); } else { bitmSD.meta = null; bitmSD.title = string.Empty; } if (bitmSD.meta == null) { bitmSD.link = null; continue; } ParsedBitmap pm = new ParsedBitmap(ref bitmSD.meta, map); Bitmap b = pm.FindChunkAndDecode(bitmSD.bitmNumber, 0, 0, ref bitmSD.meta, map, 0, 0); System.Drawing.Imaging.ImageAttributes imgAttr = new System.Drawing.Imaging.ImageAttributes(); // If alpha-blended = 1, invert alpha channel now (way faster to do once!) if (bitmSD.blendMethod == 1) { Bitmap bTemp = new Bitmap(b.Width, b.Height); using (Graphics g = Graphics.FromImage(bTemp)) { System.Drawing.Imaging.ColorMatrix cm = new System.Drawing.Imaging.ColorMatrix(); cm.Matrix00 = 1.0f; cm.Matrix03 = -1.0f; // Reverse red alpha cm.Matrix11 = 1.0f; cm.Matrix13 = -1.0f; // Reverse green alpha cm.Matrix22 = 1.0f; cm.Matrix23 = -1.0f; // REverse blue alpha cm.Matrix33 = 1.0f; imgAttr.SetColorMatrix(cm); g.Clear(Color.Empty); g.DrawImage( b, new Rectangle( 0, 0, b.Width, b.Height), 0, 0, b.Width, b.Height, GraphicsUnit.Pixel, imgAttr ); g.Dispose(); } b.Dispose(); b = bTemp; } bitmSD.link = b; pd.bitmaps.Add(bitmSD); } drawBitmap(); } tabControl1.TabPages[0].Text = "Bitmaps [" + bitmapCount.ToString() + "]"; tabControl1.TabPages[0].Enabled = (bitmapCount > 0); #endregion #region List Blocks // Clear the list of List Blocks pd.listBlocks.Clear(); // Always use the first panes Data for list blocks br.BaseStream.Position = ((paneData)lbPanes.Items[0]).offset + 12; int listBlockCount = br.ReadInt32(); int listBlockOffset = br.ReadInt32() - map.SecondaryMagic; if (listBlockCount > 0) { BinaryReader br2 = br; // Handle pointers to other tags int listBlockTag = map.Functions.ForMeta.FindMetaByOffset(listBlockOffset); if (listBlockTag != currentScreen.meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(listBlockTag, map, false, true); br2 = new BinaryReader(newMeta.MS); listBlockOffset -= newMeta.offset; } else listBlockOffset -= currentScreen.meta.offset; for (int listBlock = 0; listBlock < listBlockCount; listBlock++) { listBlockData ld = new listBlockData(listBlock); br2.BaseStream.Position = ld.offset = listBlockOffset + listBlock * 24; ld.Read(br2); //bitmSD.link = b; pd.listBlocks.Add(ld); } } tabControl1.TabPages[1].Text = "List Boxes [" + listBlockCount.ToString() + "]"; tabControl1.TabPages[1].Enabled = (listBlockCount > 0); #endregion #region Text Blocks br.BaseStream.Position = pd.offset + 28; int textBlockCount = br.ReadInt32(); int textBlockOffset = br.ReadInt32() - map.SecondaryMagic; if (textBlockCount > 0) { BinaryReader br2 = br; // Handle pointers to other tags int textBlockTag = map.Functions.ForMeta.FindMetaByOffset(textBlockOffset); if (textBlockTag != currentScreen.meta.TagIndex) { Meta newMeta = Map.GetMetaFromTagIndex(textBlockTag, map, false, true); br2 = new BinaryReader(newMeta.MS); textBlockOffset -= newMeta.offset; } else textBlockOffset -= currentScreen.meta.offset; pd.textBlocks.Clear(); for (int textBlock = 0; textBlock < textBlockCount; textBlock++) { textBlockData tb = new textBlockData(textBlock); br2.BaseStream.Position = tb.offset = textBlockOffset + textBlock * 44; tb.Read(br2); tb.title = textBlock.ToString("0: ") + sSwap.getStringFromID(tb.stringID.sidIndexer); pd.textBlocks.Add(tb); } } tabControl1.TabPages[2].Text = "Text Blocks [" + textBlockCount.ToString() + "]"; tabControl1.TabPages[2].Enabled = (textBlockCount > 0); #endregion #region Model Scenes br.BaseStream.Position = pd.offset + 44; int modelScenesCount = br.ReadInt32(); int modelScenesOffset = br.ReadInt32() - map.SecondaryMagic; if (modelScenesCount > 0) { } tabControl1.TabPages[3].Text = "Model Scenes [" + modelScenesCount.ToString() + "]"; tabControl1.TabPages[3].Enabled = (modelScenesCount > 0); #endregion #region Variable Buttons br.BaseStream.Position = pd.offset + 68; int variableButtonsCount = br.ReadInt32(); int variableButtonsOffset = br.ReadInt32() - map.SecondaryMagic; if (variableButtonsCount > 0) { } tabControl1.TabPages[4].Text = "Variable Buttons [" + variableButtonsCount.ToString() + "]"; tabControl1.TabPages[4].Enabled = (variableButtonsCount > 0); #endregion #region Buttons br.BaseStream.Position = pd.offset + 4; int buttonsCount = br.ReadInt32(); int buttonsOffset = br.ReadInt32() - map.SecondaryMagic; if (buttonsCount > 0) { } tabControl1.TabPages[5].Text = "Buttons [" + buttonsCount.ToString() + "]"; tabControl1.TabPages[5].Enabled = (buttonsCount > 0); #endregion screenData screenSelected = (screenData)lbScreensList.SelectedItem; // offset stores the last currently selected pane for that screen screenSelected.offset = lbPanes.SelectedIndex; #region Set the bitmap list box to display our data in pd.bitmaps lbBitmaps.DataSource = pd.bitmaps; #endregion #region Set the skin combo box to display the current skin if (pd.listBlocks.Count > 0) { cbLBSkinIdent.Enabled = true; // Change value to be sure skin is created cbLBSkinIdent.SelectedIndex = -1; cbLBSkinIdent.SelectedIndex = pd.listBlocks[0].skinIndex; } else { cbLBSkinIdent.Enabled = false; cbLBSkinIdent.SelectedIndex = -1; } #endregion #region Set the text block list box to display our data in pd.textBlocks lbTBTextBlocks.DataSource = pd.textBlocks; foreach (textBlockData td in pd.textBlocks) { List<bitmapData> lbd = new List<bitmapData>(); entity.MetaFuncs.MEStringsSelector.Unicode[] ul = sSwap.getUnicodesFromID(td.stringID.sidIndexer); screenData sd = ((screenData)lbScreensList.SelectedItem); // Default to first string s = ul.Length > 0 ? ul[0].unicode : string.Empty; for (int i = 0; i < ul.Length; i++) { foreach (entity.MetaFuncs.MEStringsSelector.Unicode uni in sd.strings) if (ul[i].position == uni.position) { s = ul[i].unicode; i = ul.Length; break; } } // Create bitmap from Text if (s != string.Empty) { bitmapData bd = Skin.createText(map, td, s, true); if (bd != null) lbd.Add(bd); } td.link = lbd; } #endregion // Transfer List Box Data to text boxes, etc showListBoxData(); // link holds an array of last selected bitmap #s for each pane if (screenSelected.link != null) { int[] paneBitmapSelections = (int[])screenSelected.link; lbBitmaps.SelectedIndex = paneBitmapSelections[screenSelected.offset]; } else lbBitmaps.SelectedIndex = 0; }
private void cbBitmapIndex_SelectedIndexChanged(object sender, EventArgs e) { if (!cbBitmapIndex.Focused) return; bitmapData bd = (bitmapData)lbBitmaps.SelectedItem; bitmapInfo bi = (bitmapInfo)((baseData)cbBitmapIdent.SelectedItem).link; bd.bitmNumber = bi.BitmapIndex = (short)cbBitmapIndex.SelectedIndex; ParsedBitmap pm = new ParsedBitmap(ref bd.meta, map); bd.link = bi.Image = pm.FindChunkAndDecode(bd.bitmNumber, 0, 0, ref bd.meta, map, 0, 0); }
private void cbBitmapIdent_SelectedIndexChanged(object sender, EventArgs e) { if (!cbBitmapIdent.Focused) return; baseData sd = (baseData)cbBitmapIdent.SelectedItem; bitmapInfo bi = (bitmapInfo)sd.link; bitmapData bsd = (bitmapData)lbBitmaps.SelectedItem; if (sd.meta == null) { sd.meta = new Meta(map); map.OpenMap(MapTypes.MainMenu); sd.meta.ReadMetaFromMap(sd.offset, false); map.CloseMap(); sd.title = sd.meta.name; sd.link = bi = new bitmapInfo(); ParsedBitmap pm = new ParsedBitmap(ref sd.meta, map); bi.BitmapIndexMax = (short)pm.Properties.Length; bi.BitmapIndex = 0; bi.Image = pm.FindChunkAndDecode(bi.BitmapIndex, 0, 0, ref sd.meta, map, 0, 0); sd.link = bi; } bsd.bitmNumber = bi.BitmapIndex; bsd.link = bi.Image; bsd.meta = sd.meta; bsd.bitmIdent = bsd.meta.ident; bsd.title = sd.title.Substring(sd.title.LastIndexOf('\\') + 1); #region do this to update text in listbox, otherwise although changed, it doesn't show Control control = this.ActiveControl; while (control is ContainerControl) { control = ((ContainerControl)control).ActiveControl; } int selIndex = lbBitmaps.SelectedIndex; ((bitmapData)lbBitmaps.SelectedItem).title = bsd.title; // Actually update ListBox with data source ((CurrencyManager)lbBitmaps.BindingContext[lbBitmaps.DataSource]).Refresh(); #endregion }