public static async Task <SaveModes> Save(ActorViewModel?actor, SaveModes mode = SaveModes.All) { if (actor == null) { return(mode); } SaveResult result = await FileService.Save <CharacterFile>(); if (string.IsNullOrEmpty(result.Path) || result.Info == null) { return(CharacterFileOptions.Result); } CharacterFile file = new CharacterFile(); file.WriteToFile(actor, mode); using FileStream stream = new FileStream(result.Path, FileMode.Create); result.Info.SerializeFile(file, stream); return(CharacterFileOptions.Result); }
public CharacterFile Upgrade() { if (this.Data == null) { throw new Exception("Dat Appearance Fila has no data."); } CharacterFile file = new CharacterFile(); file.Race = (Appearance.Races) this.Data[0]; file.Gender = (Appearance.Genders) this.Data[1]; file.Age = (Appearance.Ages) this.Data[2]; file.Height = this.Data[3]; file.Tribe = (Appearance.Tribes) this.Data[4]; file.Head = this.Data[5]; file.Hair = this.Data[6]; file.EnableHighlights = this.Data[7] != 0; file.Skintone = this.Data[8]; file.REyeColor = this.Data[9]; file.HairTone = this.Data[10]; file.Highlights = this.Data[11]; file.FacialFeatures = (Appearance.FacialFeature) this.Data[12]; file.LimbalEyes = this.Data[13]; file.Eyebrows = this.Data[14]; file.LEyeColor = this.Data[15]; file.Eyes = this.Data[16]; file.Nose = this.Data[17]; file.Jaw = this.Data[18]; file.Mouth = this.Data[19]; file.LipsToneFurPattern = this.Data[20]; file.EarMuscleTailSize = this.Data[21]; file.TailEarsType = this.Data[22]; file.Bust = this.Data[23]; file.FacePaint = this.Data[24]; file.FacePaintColor = this.Data[25]; return(file); }
public new FileBase Upgrade() { if (this.CharacterBytes == null) { throw new Exception("CMTool Apearance file has no data"); } CharacterFile allFile = base.Upgrade(); allFile.SaveMode = CharacterFile.SaveModes.All; byte[] data = this.StringtoBytes(this.CharacterBytes); // From CM2: MainWindow.xaml.cs line 708 allFile.Race = (Appearance.Races)data[0]; allFile.Gender = (Appearance.Genders)data[1]; allFile.Age = (Appearance.Ages)data[2]; allFile.Height = data[3]; allFile.Tribe = (Appearance.Tribes)data[4]; allFile.Head = data[5]; allFile.Hair = data[6]; allFile.EnableHighlights = data[7] != 0; allFile.Skintone = data[8]; allFile.REyeColor = data[9]; allFile.HairTone = data[10]; allFile.Highlights = data[11]; allFile.FacialFeatures = (Appearance.FacialFeature)data[12]; allFile.LimbalEyes = data[13]; allFile.Eyebrows = data[14]; allFile.LEyeColor = data[15]; allFile.Eyes = data[16]; allFile.Nose = data[17]; allFile.Jaw = data[18]; allFile.Mouth = data[19]; allFile.LipsToneFurPattern = data[20]; allFile.EarMuscleTailSize = data[21]; allFile.TailEarsType = data[22]; allFile.Bust = data[23]; allFile.FacePaint = data[24]; allFile.FacePaintColor = data[25]; if (this.characterDetails?.ModelType != null) { allFile.ModelType = (int)this.characterDetails.ModelType.value; } if (this.characterDetails?.SkinRedPigment != null && this.characterDetails.SkinGreenPigment != null && this.characterDetails.SkinBluePigment != null) { allFile.SkinColor = new Color((float)this.characterDetails.SkinRedPigment.value, (float)this.characterDetails.SkinGreenPigment.value, (float)this.characterDetails.SkinBluePigment.value); } if (this.characterDetails?.SkinRedGloss != null && this.characterDetails.SkinGreenGloss != null && this.characterDetails.SkinBlueGloss != null) { allFile.SkinGloss = new Color((float)this.characterDetails.SkinRedGloss.value, (float)this.characterDetails.SkinGreenGloss.value, (float)this.characterDetails.SkinBlueGloss.value); } if (this.characterDetails?.LeftEyeRed != null && this.characterDetails.LeftEyeGreen != null && this.characterDetails.LeftEyeBlue != null) { allFile.LeftEyeColor = new Color((float)this.characterDetails.LeftEyeRed.value, (float)this.characterDetails.LeftEyeGreen.value, (float)this.characterDetails.LeftEyeBlue.value); } if (this.characterDetails?.RightEyeRed != null && this.characterDetails.RightEyeBlue != null && this.characterDetails.RightEyeGreen != null) { allFile.RightEyeColor = new Color((float)this.characterDetails.RightEyeRed.value, (float)this.characterDetails.RightEyeGreen.value, (float)this.characterDetails.RightEyeBlue.value); } if (this.characterDetails?.LimbalR != null && this.characterDetails.LimbalG != null && this.characterDetails.LimbalB != null) { allFile.LimbalRingColor = new Color((float)this.characterDetails.LimbalR.value, (float)this.characterDetails.LimbalG.value, (float)this.characterDetails.LimbalB.value); } if (this.characterDetails?.HairRedPigment != null && this.characterDetails.HairGreenPigment != null && this.characterDetails.HairBluePigment != null) { allFile.HairColor = new Color((float)this.characterDetails.HairRedPigment.value, (float)this.characterDetails.HairGreenPigment.value, (float)this.characterDetails.HairBluePigment.value); } if (this.characterDetails?.HairGlowRed != null && this.characterDetails.HairGlowGreen != null && this.characterDetails.HairGlowBlue != null) { allFile.HairGloss = new Color((float)this.characterDetails.HairGlowRed.value, (float)this.characterDetails.HairGlowGreen.value, (float)this.characterDetails.HairGlowBlue.value); } if (this.characterDetails?.HighlightRedPigment != null && this.characterDetails.HighlightGreenPigment != null && this.characterDetails.HighlightBluePigment != null) { allFile.HairHighlight = new Color((float)this.characterDetails.HighlightRedPigment.value, (float)this.characterDetails.HighlightGreenPigment.value, (float)this.characterDetails.HighlightBluePigment.value); } if (this.characterDetails?.LipsR != null && this.characterDetails?.LipsG != null && this.characterDetails?.LipsB != null && this.characterDetails?.LipsBrightness != null) { allFile.MouthColor = new Color4((float)this.characterDetails.LipsR.value, (float)this.characterDetails.LipsG.value, (float)this.characterDetails.LipsB.value, (float)this.characterDetails.LipsBrightness.value); } return(allFile); }
public FileBase Upgrade() { CharacterFile file = new CharacterFile(); file.SaveMode = CharacterFile.SaveModes.All; file.MainHand = this.MainHand?.Upgrade(); file.OffHand = this.OffHand?.Upgrade(); if (this.EquipmentBytes != null) { byte[] data = this.StringtoBytes(this.EquipmentBytes); // From CM2: CharacterDetailsView2.xaml.cs line 801 file.HeadGear = new CharacterFile.ItemSave(); file.HeadGear.ModelBase = (ushort)(data[0] + (data[1] * 256)); file.HeadGear.ModelVariant = data[2]; file.HeadGear.DyeId = data[3]; file.Body = new CharacterFile.ItemSave(); file.Body.ModelBase = (ushort)(data[4] + (data[5] * 256)); file.Body.ModelVariant = data[6]; file.Body.DyeId = data[7]; file.Hands = new CharacterFile.ItemSave(); file.Hands.ModelBase = (ushort)(data[8] + (data[9] * 256)); file.Hands.ModelVariant = data[10]; file.Hands.DyeId = data[11]; file.Legs = new CharacterFile.ItemSave(); file.Legs.ModelBase = (ushort)(data[12] + (data[13] * 256)); file.Legs.ModelVariant = data[14]; file.Legs.DyeId = data[15]; file.Feet = new CharacterFile.ItemSave(); file.Feet.ModelBase = (ushort)(data[16] + (data[17] * 256)); file.Feet.ModelVariant = data[18]; file.Feet.DyeId = data[19]; file.Ears = new CharacterFile.ItemSave(); file.Ears.ModelBase = (ushort)(data[20] + (data[21] * 256)); file.Ears.ModelVariant = data[22]; file.Neck = new CharacterFile.ItemSave(); file.Neck.ModelBase = (ushort)(data[24] + (data[25] * 256)); file.Neck.ModelVariant = data[26]; file.Wrists = new CharacterFile.ItemSave(); file.Wrists.ModelBase = (ushort)(data[28] + (data[29] * 256)); file.Wrists.ModelVariant = data[30]; file.RightRing = new CharacterFile.ItemSave(); file.RightRing.ModelBase = (ushort)(data[32] + (data[33] * 256)); file.RightRing.ModelVariant = data[34]; file.LeftRing = new CharacterFile.ItemSave(); file.LeftRing.ModelBase = (ushort)(data[36] + (data[37] * 256)); file.LeftRing.ModelVariant = data[38]; } if (this.CharacterBytes != null) { byte[] data = this.StringtoBytes(this.CharacterBytes); // From CM2: MainWindow.xaml.cs line 708 file.Race = (Appearance.Races)data[0]; file.Gender = (Appearance.Genders)data[1]; file.Age = (Appearance.Ages)data[2]; file.Height = data[3]; file.Tribe = (Appearance.Tribes)data[4]; file.Head = data[5]; file.Hair = data[6]; file.EnableHighlights = data[7] != 0; file.Skintone = data[8]; file.REyeColor = data[9]; file.HairTone = data[10]; file.Highlights = data[11]; file.FacialFeatures = (Appearance.FacialFeature)data[12]; file.LimbalEyes = data[13]; file.Eyebrows = data[14]; file.LEyeColor = data[15]; file.Eyes = data[16]; file.Nose = data[17]; file.Jaw = data[18]; file.Mouth = data[19]; file.LipsToneFurPattern = data[20]; file.EarMuscleTailSize = data[21]; file.TailEarsType = data[22]; file.Bust = data[23]; file.FacePaint = data[24]; file.FacePaintColor = data[25]; if (this.characterDetails?.ModelType != null) { file.ModelType = (int)this.characterDetails.ModelType.value; } if (this.characterDetails?.SkinRedPigment != null && this.characterDetails.SkinGreenPigment != null && this.characterDetails.SkinBluePigment != null) { file.SkinColor = new Color((float)this.characterDetails.SkinRedPigment.value, (float)this.characterDetails.SkinGreenPigment.value, (float)this.characterDetails.SkinBluePigment.value); } if (this.characterDetails?.SkinRedGloss != null && this.characterDetails.SkinGreenGloss != null && this.characterDetails.SkinBlueGloss != null) { file.SkinGloss = new Color((float)this.characterDetails.SkinRedGloss.value, (float)this.characterDetails.SkinGreenGloss.value, (float)this.characterDetails.SkinBlueGloss.value); } if (this.characterDetails?.LeftEyeRed != null && this.characterDetails.LeftEyeGreen != null && this.characterDetails.LeftEyeBlue != null) { file.LeftEyeColor = new Color((float)this.characterDetails.LeftEyeRed.value, (float)this.characterDetails.LeftEyeGreen.value, (float)this.characterDetails.LeftEyeBlue.value); } if (this.characterDetails?.RightEyeRed != null && this.characterDetails.RightEyeBlue != null && this.characterDetails.RightEyeGreen != null) { file.RightEyeColor = new Color((float)this.characterDetails.RightEyeRed.value, (float)this.characterDetails.RightEyeGreen.value, (float)this.characterDetails.RightEyeBlue.value); } if (this.characterDetails?.LimbalR != null && this.characterDetails.LimbalG != null && this.characterDetails.LimbalB != null) { file.LimbalRingColor = new Color((float)this.characterDetails.LimbalR.value, (float)this.characterDetails.LimbalG.value, (float)this.characterDetails.LimbalB.value); } if (this.characterDetails?.HairRedPigment != null && this.characterDetails.HairGreenPigment != null && this.characterDetails.HairBluePigment != null) { file.HairColor = new Color((float)this.characterDetails.HairRedPigment.value, (float)this.characterDetails.HairGreenPigment.value, (float)this.characterDetails.HairBluePigment.value); } if (this.characterDetails?.HairGlowRed != null && this.characterDetails.HairGlowGreen != null && this.characterDetails.HairGlowBlue != null) { file.HairGloss = new Color((float)this.characterDetails.HairGlowRed.value, (float)this.characterDetails.HairGlowGreen.value, (float)this.characterDetails.HairGlowBlue.value); } if (this.characterDetails?.HighlightRedPigment != null && this.characterDetails.HighlightGreenPigment != null && this.characterDetails.HighlightBluePigment != null) { file.HairHighlight = new Color((float)this.characterDetails.HighlightRedPigment.value, (float)this.characterDetails.HighlightGreenPigment.value, (float)this.characterDetails.HighlightBluePigment.value); } if (this.characterDetails?.LipsR != null && this.characterDetails?.LipsG != null && this.characterDetails?.LipsB != null && this.characterDetails?.LipsBrightness != null) { file.MouthColor = new Color4((float)this.characterDetails.LipsR.value, (float)this.characterDetails.LipsG.value, (float)this.characterDetails.LipsB.value, (float)this.characterDetails.LipsBrightness.value); } if (this.characterDetails?.Height != null) { file.HeightMultiplier = (float)this.characterDetails.Height.value; } } return(file); }
/// <summary> /// Upgrades a CM2 equipment set to a CM3 equipment set file. /// </summary> public CharacterFile Upgrade() { if (this.EquipmentBytes == null) { throw new Exception("CMTool equipment set file missing data"); } CharacterFile file = new CharacterFile(); file.SaveMode = CharacterFile.SaveModes.EquipmentGear | CharacterFile.SaveModes.EquipmentAccessories; file.MainHand = this.MainHand?.Upgrade(); file.OffHand = this.OffHand?.Upgrade(); byte[] data = this.StringtoBytes(this.EquipmentBytes); // From CM2: CharacterDetailsView2.xaml.cs line 801 file.HeadGear = new CharacterFile.ItemSave(); file.HeadGear.ModelBase = (ushort)(data[0] + (data[1] * 256)); file.HeadGear.ModelVariant = data[2]; file.HeadGear.DyeId = data[3]; file.Body = new CharacterFile.ItemSave(); file.Body.ModelBase = (ushort)(data[4] + (data[5] * 256)); file.Body.ModelVariant = data[6]; file.Body.DyeId = data[7]; file.Hands = new CharacterFile.ItemSave(); file.Hands.ModelBase = (ushort)(data[8] + (data[9] * 256)); file.Hands.ModelVariant = data[10]; file.Hands.DyeId = data[11]; file.Legs = new CharacterFile.ItemSave(); file.Legs.ModelBase = (ushort)(data[12] + (data[13] * 256)); file.Legs.ModelVariant = data[14]; file.Legs.DyeId = data[15]; file.Feet = new CharacterFile.ItemSave(); file.Feet.ModelBase = (ushort)(data[16] + (data[17] * 256)); file.Feet.ModelVariant = data[18]; file.Feet.DyeId = data[19]; file.Ears = new CharacterFile.ItemSave(); file.Ears.ModelBase = (ushort)(data[20] + (data[21] * 256)); file.Ears.ModelVariant = data[22]; file.Neck = new CharacterFile.ItemSave(); file.Neck.ModelBase = (ushort)(data[24] + (data[25] * 256)); file.Neck.ModelVariant = data[26]; file.Wrists = new CharacterFile.ItemSave(); file.Wrists.ModelBase = (ushort)(data[28] + (data[29] * 256)); file.Wrists.ModelVariant = data[30]; file.RightRing = new CharacterFile.ItemSave(); file.RightRing.ModelBase = (ushort)(data[32] + (data[33] * 256)); file.RightRing.ModelVariant = data[34]; file.LeftRing = new CharacterFile.ItemSave(); file.LeftRing.ModelBase = (ushort)(data[36] + (data[37] * 256)); file.LeftRing.ModelVariant = data[38]; return(file); }