private void openiffToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog OFD = new OpenFileDialog(); OFD.Filter = "Iff files (*.iff)|*.iff|Floor files (*.flr)|*.flr|Wall files (*.wll)|*.wll|SPF files (*.spf)|*.spf"; OFD.Title = "Open Iff Archive..."; OFD.AddExtension = true; m_CurrentSPRFrame = 0; m_CurrentSPR2Frame = 0; m_CurrentGroupFrame = 0; if (OFD.ShowDialog() == DialogResult.OK) { m_CurrentArchive = new Iffinator.Flash.Iff(OFD.FileName); LblNumChunks.Visible = true; LblNumChunks.Text = "Number of chunks: " + m_CurrentArchive.Chunks.Count; if (m_CurrentArchive.SPR2s.Count > 0) { m_CurrentSPR2 = m_CurrentArchive.GetSprite(0); PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; } LstSPR2s.Items.Clear(); /*foreach (Flash.IffChunk Chunk in m_CurrentArchive.Chunks) * { * if (Chunk.Resource == "SPR2") * LstSPR2s.Items.Add("ID: " + Chunk.ID); * }*/ } }
/// <summary> /// User clicked on a different SPR2 or DGRP chunk. /// </summary> private void LstSPR2s_SelectedValueChanged(object sender, EventArgs e) { if (RdiSPR.Checked) { m_CurrentSPR = m_CurrentArchive.SPRs[LstSPR2s.SelectedIndex]; PictCurrentFrame.Image = m_CurrentSPR.GetFrame(0).BitmapData.BitMap; m_CurrentSPRFrame = 0; } else if (RdiSpr2.Checked) { m_CurrentSPR2 = m_CurrentArchive.SPR2s[LstSPR2s.SelectedIndex]; PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(0).BitmapData.BitMap; m_CurrentSPR2Frame = 0; } else if (RdiDgrp.Checked) { m_CurrentGroup = m_CurrentArchive.DrawGroups[LstSPR2s.SelectedIndex]; PictCurrentFrame.Image = m_CurrentGroup.GetImage(0).CompiledBitmap; m_CurrentGroupFrame = 0; } }
/// <summary> /// User clicked on the list of sprites. /// </summary> private void LstSPR2s_Click(object sender, EventArgs e) { if (m_CurrentArchive != null) { if (RdiSPR.Checked) { string Caption = (string)LstSPR2s.SelectedItem; int ID = 0; string Name = ""; if (Caption.Contains("ID: ")) { ID = int.Parse(Caption.Replace("ID: ", "")); } else { Name = Caption.Replace("Name: ", ""); } foreach (SPRParser Sprite in m_CurrentArchive.SPRs) { if (ID != 0) { if (Sprite.ID == ID) { m_CurrentSPR = Sprite; PictCurrentFrame.Image = m_CurrentSPR.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } else { if (Sprite.NameString == Name) { m_CurrentSPR = Sprite; PictCurrentFrame.Image = m_CurrentSPR.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } } } else if (RdiSpr2.Checked) { string Caption = (string)LstSPR2s.SelectedItem; int ID = 0; string Name = ""; if (Caption.Contains("ID: ")) { ID = int.Parse(Caption.Replace("ID: ", "")); } else { Name = Caption.Replace("Name: ", ""); } foreach (SPR2Parser Sprite in m_CurrentArchive.SPR2s) { if (ID != 0) { if (Sprite.ID == ID) { m_CurrentSPR2 = Sprite; PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } else { if (Sprite.NameString == Name) { m_CurrentSPR2 = Sprite; PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } } } else if (RdiStr.Checked) { if (m_CurrentArchive.StringTables.Count > 0) { string Str = (string)LstSPR2s.SelectedItem; Str = Str.Replace("String: ", ""); Str = Str.Replace("String2: ", ""); MessageBox.Show(Str); } } else if (RdiBhavs.Checked) { if (m_CurrentArchive.BHAVs.Count > 0) { BHAVEdit Editor = new BHAVEdit(m_CurrentArchive, m_CurrentArchive.BHAVs[LstSPR2s.SelectedIndex]); Editor.Show(); } } else if (RdiDgrp.Checked) { string Caption = (string)LstSPR2s.SelectedItem; int ID = 0; string Name = ""; if (Caption.Contains("ID: ")) { ID = int.Parse(Caption.Replace("ID: ", "")); } else { Name = Caption.Replace("Name: ", ""); } foreach (DrawGroup DGRP in m_CurrentArchive.DrawGroups) { if (ID != 0) { if (DGRP.ID == ID) { m_CurrentGroup = DGRP; if (m_CurrentGroupFrame < m_CurrentGroup.ImageCount) { PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } else { m_CurrentGroupFrame = m_CurrentGroup.ImageCount - 1; PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } break; } } else { if (DGRP.NameString == Name) { m_CurrentGroup = DGRP; if (m_CurrentGroupFrame < m_CurrentGroup.ImageCount) { PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } else { m_CurrentGroupFrame = m_CurrentGroup.ImageCount - 1; PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } break; } } } } } }
/// <summary> /// User clicked on the button to view the previous frame in a SPR2 or DGRP chunk. /// </summary> private void BtnPrevFrame_Click(object sender, EventArgs e) { if (m_CurrentArchive != null) { if (RdiSPR.Checked) { m_CurrentSPRFrame--; if (m_CurrentArchive.SPRs.Count > 1) { if (m_CurrentSPRFrame < m_CurrentSPR.FrameCount && m_CurrentSPRFrame >= 0) { if (m_CurrentSPR.FrameCount >= 1) { PictCurrentFrame.Image = m_CurrentSPR.GetFrame(m_CurrentSPRFrame).BitmapData.BitMap; } } else if (m_CurrentSPRFrame < 0) { m_CurrentSPRFrame = 0; } else if (m_CurrentSPRFrame > m_CurrentSPR.FrameCount) { m_CurrentSPRFrame = (int)m_CurrentSPR.FrameCount - 1; } } } else if (RdiSpr2.Checked) { m_CurrentSPR2Frame--; if (!ChkZBuffer.Checked) { if (m_CurrentArchive.SPR2s.Count > 1) { if (m_CurrentSPR2Frame < m_CurrentSPR2.FrameCount && m_CurrentSPR2Frame >= 0) { if (m_CurrentSPR2.FrameCount >= 1) { PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; } } else if (m_CurrentSPR2Frame < 0) { m_CurrentSPR2Frame = 0; } else if (m_CurrentSPR2Frame > m_CurrentSPR2.FrameCount) { m_CurrentSPR2Frame = (int)m_CurrentSPR2.FrameCount - 1; } } } else { if (m_CurrentArchive.SPR2s.Count > 1) { if (m_CurrentSPR2Frame < m_CurrentSPR2.FrameCount && m_CurrentSPR2Frame >= 0) { if (m_CurrentSPR2.FrameCount >= 1) { if (m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).HasZBuffer) { PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).ZBuffer.BitMap; } else { PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; } } } else if (m_CurrentSPR2Frame < 0) { m_CurrentSPR2Frame = 0; } else if (m_CurrentSPR2Frame > m_CurrentSPR2.FrameCount) { m_CurrentSPR2Frame = (int)m_CurrentSPR2.FrameCount - 1; } } } } else if (RdiDgrp.Checked) { m_CurrentGroupFrame--; if (m_CurrentArchive.DrawGroups.Count >= 1) { if (m_CurrentGroupFrame < m_CurrentGroup.ImageCount && m_CurrentGroupFrame >= 0 && m_CurrentGroup.ImageCount >= 1) { if (m_CurrentGroup.ImageCount >= 1) { PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } } else if (m_CurrentGroupFrame < 0) { m_CurrentGroupFrame = 0; } } else if (m_CurrentGroupFrame > m_CurrentGroup.ImageCount) { m_CurrentGroupFrame = (int)m_CurrentGroup.ImageCount - 1; } } } }