private void exportSp2MenuItem_Click(object sender, EventArgs e) { int index = Int32.Parse((sender as Menu).Tag.ToString()); MonsterSprite sprite = allSpritesEditor1.CurrentSprite.GetAbstractSpriteFromIso(currentStream) as MonsterSprite; if (sprite != null) { saveFileDialog.Filter = "SP2 files (*.SP2)|*.sp2"; saveFileDialog.FileName = string.Empty; saveFileDialog.CreatePrompt = false; saveFileDialog.OverwritePrompt = true; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, sprite.ToByteArray(index)); } } }
private void importSp2MenuItem_Click(object sender, EventArgs e) { int index = Int32.Parse((sender as Menu).Tag.ToString()); MonsterSprite sprite = allSpritesEditor1.CurrentSprite.GetAbstractSpriteFromIso(currentStream) as MonsterSprite; if (sprite != null) { openFileDialog.Filter = "SP2 files (*.SP2)|*.sp2"; openFileDialog.FileName = string.Empty; openFileDialog.CheckFileExists = true; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { (allSpritesEditor1.CurrentSprite as CharacterSprite).ImportSp2(currentStream, openFileDialog.FileName, index - 1); allSpritesEditor1.ReloadCurrentSprite(); } } }
public void LoadFullSpriteSet(FullSpriteSet set) { this.set = new Set <KeyValuePair <AbstractSprite, int> >(); isoPathTextBox.Text = string.Empty; listView1.BeginUpdate(); listView1.Items.Clear(); foreach (AbstractSprite sprite in set.Sprites) { ListViewItem item = GenerateItem( sprite.Filenames[0], sprite.OriginalSize, sprite.MaximumSize, sprite.CurrentSize); item.Tag = new KeyValuePair <AbstractSprite, int>(sprite, 0); listView1.Items.Add(item); if (sprite is MonsterSprite) { MonsterSprite m = sprite as MonsterSprite; if (m.Filenames.Count > 1) { for (int i = 1; i < m.Filenames.Count; i++) { const int sp2Length = 32768; string lengthString = sp2Length.ToString(); ListViewItem item2 = GenerateItem( sprite.Filenames[i], sp2Length, sp2Length, sp2Length); item2.Tag = new KeyValuePair <AbstractSprite, int>(sprite, i); listView1.Items.Add(item2); } } } } listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); listView1.EndUpdate(); }
private void sp2Menu_Popup(object sender, EventArgs e) { foreach (MenuItem mi in sp2Menu.MenuItems) { mi.Enabled = false; } if (allSpritesEditor1.CurrentSprite != null) { MonsterSprite sprite = allSpritesEditor1.CurrentSprite.GetAbstractSpriteFromIso(currentStream) as MonsterSprite; if (sprite != null && allSpritesEditor1.CurrentSprite is CharacterSprite) { int numChildren = (allSpritesEditor1.CurrentSprite as CharacterSprite).NumChildren; for (int i = 0; i < numChildren; i++) { sp2Menu.MenuItems[i * 3].Enabled = true; sp2Menu.MenuItems[i * 3 + 1].Enabled = true; } } } }
protected override AbstractSprite GetAbstractSpriteFromPsxIso(System.IO.Stream iso, bool ignoreCache) { if (CachedSprite == null || ignoreCache) { IList <byte> bytes = Position.ReadIso(iso); switch (SHP) { case SpriteType.TYPE1: CachedSprite = new TYPE1Sprite(bytes); break; case SpriteType.TYPE2: CachedSprite = new TYPE2Sprite(bytes); break; case SpriteType.RUKA: CachedSprite = new MonsterSprite(bytes); break; case SpriteType.MON: byte[][] sp2Bytes = new byte[location.SubSpriteLocations.Count][]; if (location.SubSpriteLocations.Count > 0) { for (int i = 0; i < location.SubSpriteLocations.Count; i++) { sp2Bytes[i] = PatcherLib.Iso.PsxIso.ReadFile( iso, (PatcherLib.Iso.PsxIso.Sectors)location.SubSpriteLocations[i].Sector, 0, (int)location.SubSpriteLocations[i].Size); } } CachedSprite = new MonsterSprite(bytes, sp2Bytes); break; case SpriteType.KANZEN: CachedSprite = new KANZEN(bytes); break; case SpriteType.CYOKO: CachedSprite = new CYOKO(bytes); break; case SpriteType.ARUTE: CachedSprite = new ARUTE(bytes); break; case SpriteType.WEP1: case SpriteType.WEP2: CachedSprite = new WEPSprite(bytes); break; case SpriteType.EFF1: CachedSprite = new WEP3Sprite(bytes); break; default: CachedSprite = null; break; } } return(CachedSprite); }
protected override AbstractSprite GetAbstractSpriteFromPspIso(System.IO.Stream iso, PatcherLib.Iso.PspIso.PspIsoInfo info, bool ignoreCache) { if (CachedSprite == null || ignoreCache) { IList <byte> bytes = Position.ReadIso(iso); System.Diagnostics.Debug.Assert(bytes.Count == this.Size); switch (SHP) { case SpriteType.TYPE1: CachedSprite = new TYPE1Sprite(bytes); break; case SpriteType.TYPE2: CachedSprite = new TYPE2Sprite(bytes); break; case SpriteType.RUKA: CachedSprite = new MonsterSprite(bytes); break; case SpriteType.MON: byte[][] sp2Bytes = new byte[location.SubSpriteLocations.Count][]; if (location.SubSpriteLocations.Count > 0) { for (int i = 0; i < location.SubSpriteLocations.Count; i++) { sp2Bytes[i] = PatcherLib.Iso.PspIso.GetFile( iso, info, (PatcherLib.Iso.FFTPack.Files)location.SubSpriteLocations[i].Sector, 0, (int)location.SubSpriteLocations[i].Size).ToArray(); } } CachedSprite = new MonsterSprite(bytes, sp2Bytes); break; case SpriteType.KANZEN: CachedSprite = new KANZEN(bytes); break; case SpriteType.CYOKO: CachedSprite = new CYOKO(bytes); break; case SpriteType.ARUTE: CachedSprite = new ARUTE(bytes); break; case SpriteType.WEP1: case SpriteType.WEP2: CachedSprite = new WEPSprite(bytes); break; //case SpriteType.WEP3: // cachedSprite = new WEP3Sprite(bytes); // break; default: CachedSprite = null; break; } } return(CachedSprite); }
protected override AbstractSprite GetAbstractSpriteFromPsxIso(System.IO.Stream iso, bool ignoreCache) { if (CachedSprite == null || ignoreCache) { IList<byte> bytes = Position.ReadIso(iso); switch (SHP) { case SpriteType.TYPE1: CachedSprite = new TYPE1Sprite(bytes); break; case SpriteType.TYPE2: CachedSprite = new TYPE2Sprite(bytes); break; case SpriteType.RUKA: CachedSprite = new MonsterSprite(bytes); break; case SpriteType.MON: byte[][] sp2Bytes = new byte[location.SubSpriteLocations.Count][]; if (location.SubSpriteLocations.Count > 0) { for (int i = 0; i < location.SubSpriteLocations.Count; i++) { sp2Bytes[i] = PatcherLib.Iso.PsxIso.ReadFile( iso, (PatcherLib.Iso.PsxIso.Sectors)location.SubSpriteLocations[i].Sector, 0, (int)location.SubSpriteLocations[i].Size); } } CachedSprite = new MonsterSprite(bytes, sp2Bytes); break; case SpriteType.KANZEN: CachedSprite = new KANZEN(bytes); break; case SpriteType.CYOKO: CachedSprite = new CYOKO(bytes); break; case SpriteType.ARUTE: CachedSprite = new ARUTE(bytes); break; case SpriteType.WEP1: case SpriteType.WEP2: CachedSprite = new WEPSprite(bytes); break; case SpriteType.EFF1: CachedSprite = new WEP3Sprite(bytes); break; default: CachedSprite = null; break; } } return CachedSprite; }
protected override AbstractSprite GetAbstractSpriteFromPspIso(System.IO.Stream iso, PatcherLib.Iso.PspIso.PspIsoInfo info, bool ignoreCache) { if (CachedSprite == null || ignoreCache) { IList<byte> bytes = Position.ReadIso(iso); System.Diagnostics.Debug.Assert(bytes.Count == this.Size); switch (SHP) { case SpriteType.TYPE1: CachedSprite = new TYPE1Sprite(bytes); break; case SpriteType.TYPE2: CachedSprite = new TYPE2Sprite(bytes); break; case SpriteType.RUKA: CachedSprite = new MonsterSprite(bytes); break; case SpriteType.MON: byte[][] sp2Bytes = new byte[location.SubSpriteLocations.Count][]; if (location.SubSpriteLocations.Count > 0) { for (int i = 0; i < location.SubSpriteLocations.Count; i++) { sp2Bytes[i] = PatcherLib.Iso.PspIso.GetFile( iso, info, (PatcherLib.Iso.FFTPack.Files)location.SubSpriteLocations[i].Sector, 0, (int)location.SubSpriteLocations[i].Size).ToArray(); } } CachedSprite = new MonsterSprite(bytes, sp2Bytes); break; case SpriteType.KANZEN: CachedSprite = new KANZEN(bytes); break; case SpriteType.CYOKO: CachedSprite = new CYOKO(bytes); break; case SpriteType.ARUTE: CachedSprite = new ARUTE(bytes); break; case SpriteType.WEP1: case SpriteType.WEP2: CachedSprite = new WEPSprite(bytes); break; //case SpriteType.WEP3: // cachedSprite = new WEP3Sprite(bytes); // break; default: CachedSprite = null; break; } } return CachedSprite; }