diff --git a/AA2Data/AA2Data.csproj b/AA2Data/AA2Data.csproj index d613d96..845e60c 100644 --- a/AA2Data/AA2Data.csproj +++ b/AA2Data/AA2Data.csproj @@ -64,6 +64,7 @@ + diff --git a/AA2Data/LST.cs b/AA2Data/LST.cs index da9718d..4482f52 100644 --- a/AA2Data/LST.cs +++ b/AA2Data/LST.cs @@ -62,7 +62,7 @@ public virtual int Slot } } - public virtual string Name + public virtual string ID { get { @@ -74,7 +74,7 @@ public virtual string Name } } - public virtual string Label + public virtual string Name { get { @@ -227,7 +227,7 @@ public override int Slot } } - public override string Name + public override string ID { get { @@ -239,7 +239,7 @@ public override string Name } } - public override string Label + public override string Name { get { diff --git a/AA2Snowflake/AA2Snowflake.csproj b/AA2Snowflake/AA2Snowflake.csproj index 0dc3b1a..bd88673 100644 --- a/AA2Snowflake/AA2Snowflake.csproj +++ b/AA2Snowflake/AA2Snowflake.csproj @@ -77,6 +77,7 @@ + Form @@ -108,6 +109,7 @@ formMain.cs + diff --git a/AA2Snowflake/Changelog.txt b/AA2Snowflake/Changelog.txt index d2e5bcb..16048c1 100644 --- a/AA2Snowflake/Changelog.txt +++ b/AA2Snowflake/Changelog.txt @@ -2,6 +2,7 @@ + Fixed setting pose for male personalities + Added personality label blanking + Fixed LST editing with custom/append personalities ++ Possibly fixed pose issues after restoring changing pose values v2.0.1 + Fixed some issues diff --git a/AA2Snowflake/LST.cs b/AA2Snowflake/LST.cs new file mode 100644 index 0000000..0886194 --- /dev/null +++ b/AA2Snowflake/LST.cs @@ -0,0 +1,51 @@ +using AA2Snowflake.Personalities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SB3Utility; +using AA2Data; +using System.IO; + +namespace AA2Snowflake +{ + public enum LSTMode + { + Default, + Custom + } + + public static class LSTFactory + { + public static PersonalityLST LoadLST(this IPersonality p) + { + if (p.Custom) + { + return new CustomPersonalityLST(p.GetLst().ToStream().ToArray()); + } + else + { + return new PersonalityLST(p.GetLst().ToStream().ToArray()); + } + } + + public static PersonalityLST LoadLST(this IWriteFile iw, LSTMode mode) + { + if (mode == LSTMode.Custom) + { + return new CustomPersonalityLST(iw.ToStream().ToArray()); + } + else + { + return new PersonalityLST(iw.ToStream().ToArray()); + } + + } + + public static IWriteFile ToSubfile(this BaseLST lst, string name) + { + return new MemSubfile(new MemoryStream(lst.raw), name); + } + } +} diff --git a/AA2Snowflake/Personality.cs b/AA2Snowflake/Personality.cs index feac822..9d381e2 100644 --- a/AA2Snowflake/Personality.cs +++ b/AA2Snowflake/Personality.cs @@ -80,23 +80,25 @@ public static class PersonalityFactory public static CustomPersonality LoadPersonality(ppParser pp) { - if (!pp.Subfiles.Select(iw => iw.Name).Any(n => n.EndsWith(".icf")) || //check if it's a valid personality .pp which contains everything we need - !pp.Subfiles.Select(iw => iw.Name).Any(n => n.EndsWith(".lst") && n.StartsWith("jg2p"))) + if (!pp.Subfiles.Select(x => x.Name).Any(n => n.EndsWith(".icf")) || //check if it's a valid personality .pp which contains everything we need + !pp.Subfiles.Select(x => x.Name).Any(n => n.EndsWith(".lst") && n.StartsWith("jg2p"))) return null; string filename = pp.FilePath.Remove(0, pp.FilePath.LastIndexOf('\\') + 1); - IWriteFile lst = pp.Subfiles.First(iw => iw.Name.EndsWith(".lst") && iw.Name.StartsWith("jg2p")); //you can thank a certain person for making this difficult (http://pastebin.com/3zkjpM7e) + IWriteFile iw = pp.Subfiles.First(x => x.Name.EndsWith(".lst") && x.Name.StartsWith("jg2p")); //you can thank a certain person for making this difficult (http://pastebin.com/3zkjpM7e) - byte slot = byte.Parse(Tools.GetLstValue(lst, 2)); + var lst = LSTFactory.LoadLST(iw, LSTMode.Custom); - Gender gender = (Gender)byte.Parse(Tools.GetLstValue(lst, 6)); //not sure if more accurate than grabbing ID letter, this column is set to 1 for female and 0 for male + byte slot = (byte)lst.Slot; - string ID = Tools.GetLstValue(lst, 7); + Gender gender = lst.Gender; //not sure if more accurate than grabbing ID letter, this column is set to 1 for female and 0 for male - string Name = Tools.GetLstValue(lst, 8); + string ID = lst.ID; + + string Name = lst.Name; Name = AppendTranslation.GetValueOrDefault(Name, Name); - return new CustomPersonality(gender, filename, ID, filename + "/" + lst.Name, Name, slot); + return new CustomPersonality(gender, filename, ID, filename + "/" + iw.Name, Name, slot); } public static BasePersonality[] BasePersonalities @@ -159,10 +161,10 @@ public static ppParser GetLstPP(this IPersonality personality) return new ppParser(path, new ppFormat_AA2()); } - public static IWriteFile GetLstFromPP(this ppParser pp, IPersonality personality) + public static IWriteFile GetLst(this IPersonality personality) { string file = personality.LSTLocation.GetFilename('/'); - return pp.Subfiles.First(iw => iw.Name == file); + return personality.GetLstPP().Subfiles.First(iw => iw.Name == file); } public static ppParser GetIcfPP(this IPersonality personality) diff --git a/AA2Snowflake/formMain.cs b/AA2Snowflake/formMain.cs index c159b52..2980921 100644 --- a/AA2Snowflake/formMain.cs +++ b/AA2Snowflake/formMain.cs @@ -605,8 +605,14 @@ private void btnMove31_Click(object sender, EventArgs e) { Application.DoEvents(); } - index = PP.jg2e00_00_00.Subfiles.IndexOf(PP.jg2e00_00_00.Subfiles.First(pp => pp.Name == "jg2e_00_01_00_00.lst")); - var sub = Tools.ManipulateLst(PP.jg2e00_00_00.Subfiles[index], 4, "51"); + + //This part was indicated as in snowflake guide v2 but I'm starting to question whether or not it's necessary + + /*index = PP.jg2e00_00_00.Subfiles.IndexOf(PP.jg2e00_00_00.Subfiles.First(pp => pp.Name == "jg2e_00_01_00_00.lst")); + + var lst = LSTFactory.LoadLST(PP.jg2e00_00_00.Subfiles[index], LSTMode.Default); + lst.AA2EditPose + var sub = Tools.ManipulateLst(, 4, "51"); sub.Name = "jg2e_00_01_00_00.lst"; PP.jg2e00_00_00.Subfiles[index] = sub; back = PP.jg2e00_00_00.WriteArchive(PP.jg2e00_00_00.FilePath, false, "bak", true); @@ -614,7 +620,7 @@ private void btnMove31_Click(object sender, EventArgs e) while (back.IsBusy) { Application.DoEvents(); - } + }*/ HideLoadingForm(); MessageBox.Show("Finished!"); } @@ -634,7 +640,7 @@ public void GenerateLSTBackups() foreach (IPersonality personality in Personalities.Values) using (MemoryStream ms = new MemoryStream()) { - personality.GetLstPP().GetLstFromPP(personality).WriteTo(ms); + personality.GetLst().WriteTo(ms); backup[personality.LSTLocation] = ms.ToByteArray(); } File.WriteAllText(Paths.BACKUP + "\\lstbackup.xml", backup.SerializeObject()); @@ -648,23 +654,27 @@ private void btnSet32_Click(object sender, EventArgs e) IPersonality personality = Personalities.ElementAt(cmbPersonality32.SelectedIndex).Value; //i've rewritten this to change only 1 personality since you don't want to rewrite 5gb of files everytime you change poses ppParser pp = personality.GetLstPP(); - IWriteFile sub = pp.GetLstFromPP(personality); - int index = pp.Subfiles.IndexOf(sub); + IWriteFile sub = personality.GetLst(); + int index = pp.Subfiles.FindIndex(x => x.Name == sub.Name); + + var lst = LSTFactory.LoadLST(personality); if (chkPose32.Checked) - sub = Tools.ManipulateLst(sub, 6, numPose32.Value.ToString()); + lst.AA2EditPose = (int)numPose32.Value; if (chkEyebrow32.Checked) - sub = Tools.ManipulateLst(sub, 7, numEyebrow32.Value.ToString()); + lst.AA2EditEyebrow = (int)numEyebrow32.Value; if (chkEyeOS32.Checked) - sub = Tools.ManipulateLst(sub, 8, numEyeOS32.Value.ToString()); + lst.AA2EditEye = (int)numEye32.Value; if (chkEye32.Checked) - sub = Tools.ManipulateLst(sub, 9, numEye32.Value.ToString()); + lst.AA2EditEyeOS = (int)numEyeOS32.Value; if (chkMouth32.Checked) - sub = Tools.ManipulateLst(sub, 10, numMouth32.Value.ToString()); + lst.AA2EditMouth = (int)numMouth32.Value; - sub = Tools.ManipulateLst(sub, 4, "51"); + //lst.WriteValue(1, "1"); + + //sub = Tools.ManipulateLst(sub, 4, "51"); //sub.Name = "jg2e_00_01_00_00.lst"; - pp.Subfiles[index] = sub; + pp.Subfiles[index] = lst.ToSubfile(sub.Name); var back = pp.WriteArchive(pp.FilePath, false, "bak", true); ShowLoadingForm(); back.RunWorkerAsync(); @@ -708,7 +718,7 @@ private void btnRestore32_Click(object sender, EventArgs e) IPersonality personality = Personalities.ElementAt(cmbPersonality32.SelectedIndex).Value; ppParser pp = personality.GetLstPP(); - IWriteFile sub = pp.GetLstFromPP(personality); + IWriteFile sub = personality.GetLst(); var index = pp.Subfiles.IndexOf(pp.Subfiles.First(iw => iw.Name == sub.Name)); sub = new MemSubfile(new MemoryStream(backup[personality.LSTLocation]), sub.Name); pp.Subfiles[index] = sub; @@ -781,7 +791,7 @@ public void LoadICF() Logger.WriteLine(string.Join("\r\n", pp.Subfiles.Where(p => p.Name.ToLower().EndsWith("icf")))); IWriteFile sub = pp.Subfiles.First(iw => iw.Name.ToLower() == name.ToLower()); ICF icf; - using (MemoryStream mem = Tools.GetStreamFromSubfile(sub)) + using (MemoryStream mem = sub.ToStream()) icf = new ICF(mem); txtRotX.Text = icf.Rotation.X.RadiansToDegrees().ToString();