/// <returns> Bool indicating if the installation successfull. If it is false, then there was an ID conflict. </returns> public bool InstallEntries(List <CharaSlot> installSlots, List <string> installIDs) { if (installSlots == null) { return(true); } foreach (var installSlot in installSlots) { CharaSlot charaSlot = GetCharaSlotFromInstallID(installSlot.InstallID); if (charaSlot == null) { charaSlot = new CharaSlot(); CharaSlots.Add(charaSlot); } foreach (var installCostume in installSlot.CostumeSlots) { if (!SlotExists(installCostume.InstallID)) { installIDs.Add(installCostume.InstallID); charaSlot.CostumeSlots.Add(installCostume); } else { return(false); } } } return(true); }
public static CharaSlotsFile Load(byte[] bytes) { string rawText = Encoding.ASCII.GetString(bytes); CharaSlotsFile charaFile = new CharaSlotsFile(); rawText = rawText.Replace("{", ""); rawText = rawText.Replace("[", ""); rawText = rawText.Replace(" ", ""); string[] charaSlotsText = rawText.Split('}'); foreach (var slot in charaSlotsText) { if (string.IsNullOrWhiteSpace(slot)) { continue; } string[] costumeSlotsText = slot.Split(']'); CharaSlot charaSlot = new CharaSlot(); foreach (var costume in costumeSlotsText) { if (string.IsNullOrWhiteSpace(costume)) { continue; } CharaCostumeSlot costumeSlot = new CharaCostumeSlot(); string[] parameters = costume.Split(','); if (parameters.Length != 8) { throw new InvalidDataException($"Invalid number of CharaSlot parameters. Expected 8, found {parameters.Length}."); } costumeSlot.CharaCode = parameters[0]; costumeSlot.Costume = int.Parse(parameters[1]); costumeSlot.Preset = int.Parse(parameters[2]); costumeSlot.UnlockIndex = int.Parse(parameters[3]); costumeSlot.flag_gk2 = (parameters[4] == "1") ? true : false; costumeSlot.CssVoice1 = int.Parse(parameters[5]); costumeSlot.CssVoice2 = int.Parse(parameters[6]); costumeSlot.DLC = (CstDlcVer)int.Parse(parameters[7]); charaSlot.CostumeSlots.Add(costumeSlot); } charaFile.CharaSlots.Add(charaSlot); } return(charaFile); }