private bool ReadSceneCard(string fileName, CardTypes cardType, BinaryReader reader, long pngEnd) { var finderArr = new CardTypeFinder[] { new CardTypeFinder(CardTypes.KoiKatuChara), new CardTypeFinder(CardTypes.KoiKatuCharaS), new CardTypeFinder(CardTypes.KoiKatuCharaSP), new CardTypeFinder(CardTypes.AIS_Chara), new CardTypeFinder(CardTypes.HoneySelectCharaMale), new CardTypeFinder(CardTypes.HoneySelectCharaFemale) }; if (cardType == CardTypes.PHStudio) { PHSceneCard pHScene = new PHSceneCard(fileName); pHScene.Parse(reader, pngEnd); if (pHScene.CharaCards.Count > 0) { this.Cards.AddRange(pHScene.CharaCards); } return(true); } foreach (var finder in finderArr) { reader.Seek(pngEnd, SeekOrigin.Begin); if (finder.Find(reader, false)) { try { do { long charaPos = finder.Position; reader.Seek(charaPos + finder.MarkerPattern.Length, SeekOrigin.Begin); ICharaCard card = null; switch (finder.CardType) { case CardTypes.KoiKatuChara: case CardTypes.KoiKatuCharaS: case CardTypes.KoiKatuCharaSP: card = new KKCharaCard(fileName, 100, finder.Marker); break; case CardTypes.AIS_Chara: card = new AISCharaCard(fileName, 100, finder.Marker); break; case CardTypes.HoneySelectCharaMale: card = new HSCharaCard(fileName, finder.Marker, 0); break; case CardTypes.HoneySelectCharaFemale: card = new HSCharaCard(fileName, finder.Marker, 1); break; default: break; } if (card != null && card.Parse(reader, 0)) { Cards.Add(card); } reader.Seek(charaPos + finder.MarkerPattern.Length + 1, SeekOrigin.Begin); } while (finder.Find(reader, false)); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } } } return(true); }
public bool TryParse(FileInfo file) { string fileName = file.FullName; using (BinaryReader reader = new BinaryReader(file.OpenRead())) { long pngSize = 0L; if (!CheckPngData(reader.BaseStream, ref pngSize, true)) { return(false); } if (reader.BaseStream.Length - reader.BaseStream.Position == 0L) { return(false); } try { int loadProductNo = reader.ReadInt32(); if (loadProductNo != 100) { CardTypes sceneCardType = CheckIfSceneCard(reader); if (sceneCardType != CardTypes.Unknown) // Scene Card { return(ReadSceneCard(fileName, sceneCardType, reader, pngSize)); } reader.Seek(pngSize, SeekOrigin.Begin); } ICharaCard card = null; string marker = reader.ReadString(); CardTypes cardType = CardTypeFinder.IsMarkerOf(marker); switch (cardType) { case CardTypes.KoiKatuChara: case CardTypes.KoiKatuCharaS: case CardTypes.KoiKatuCharaSP: card = new KKCharaCard(fileName, loadProductNo, marker); break; case CardTypes.AIS_Chara: card = new AISCharaCard(fileName, loadProductNo, marker); break; case CardTypes.HoneySelectCharaMale: card = new HSCharaCard(fileName, marker, 0); break; case CardTypes.HoneySelectCharaFemale: card = new HSCharaCard(fileName, marker, 1); break; case CardTypes.PlayHome_Male: card = new PHCharaCard(fileName, marker, 0); break; case CardTypes.PlayHome_Female: card = new PHCharaCard(fileName, marker, 1); break; case CardTypes.PremiumResortCharaMale: card = new SBPRCharaCard(fileName, marker, 0); break; case CardTypes.PremiumResortCharaFemale: card = new SBPRCharaCard(fileName, marker, 1); break; default: break; } if (card != null && card.Parse(reader, pngSize)) { Cards.Add(card); return(true); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } } return(false); }
protected virtual void ReadOICharInfo(BinaryReader reader, Version version) { ReadObjectInfo(reader, version, true); reader.ReadBytes(4); // sex int productNo = reader.ReadInt32(); if (productNo <= 100) { var mark = reader.ReadString(); KKCharaCard charaCard = new KKCharaCard(this.SourceFileName, productNo, mark); charaCard.Parse(reader, 0L); this.CharaCards.Add(charaCard); } // bones int countBones = reader.ReadInt32(); for (int i = 0; i < countBones; i++) { reader.ReadBytes(4); // key ReadObjectInfo(reader, version, false); } // IkTarget int countIkTarget = reader.ReadInt32(); for (int i = 0; i < countIkTarget; i++) { reader.ReadBytes(4); // key ReadObjectInfo(reader, version, false); } int countChild = reader.ReadInt32(); for (int i = 0; i < countChild; i++) { reader.ReadBytes(4); ReadChild(reader, version); } // kinematicMode, animeInfo.group, animeInfo.category, animeInfo.no // handPtnL, handPtnR, nipple, siru, mouthOpen, lipSync reader.ReadBytes(38); // lookAtTarget ReadObjectInfo(reader, version, false); // enableIK, activeIK, enableFK, activeFK reader.ReadBytes(14); // expression if (version < VersionOf(0, 0, 9)) { reader.ReadBytes(4); } else { reader.ReadBytes(8); } // animeSpeed, animePattern, animeOptionVisible, isAnimeForceLoop reader.ReadBytes(10); // voiceCtrl int cVoice = reader.ReadInt32(); for (int i = 0; i < cVoice; i++) { // group, category, no reader.ReadBytes(12); } reader.ReadBytes(4); // repeat // sonLength, visibleSimple reader.ReadBytes(5); reader.ReadString(); // simpleColor // animeOptionParam[0], animeOptionParam[1] reader.ReadBytes(8); // neckByteData int cNeckByte = reader.ReadInt32(); reader.ReadBytes(cNeckByte); // eyesByteData int cEyesByte = reader.ReadInt32(); reader.ReadBytes(cEyesByte); reader.ReadBytes(4); // animeNormalizedTime // dicAccessGroup int accessGroup = reader.ReadInt32(); if (accessGroup > 0) { reader.ReadBytes(8 * accessGroup); } // dicAccessNo int accessNo = reader.ReadInt32(); if (accessNo > 0) { reader.ReadBytes(8 * accessNo); } }