diff --git a/Enums/ConditionType.cs b/Enums/AuthPage/AuthPageConditionsGeneric.cs similarity index 97% rename from Enums/ConditionType.cs rename to Enums/AuthPage/AuthPageConditionsGeneric.cs index 646ca8c..227f1c6 100644 --- a/Enums/ConditionType.cs +++ b/Enums/AuthPage/AuthPageConditionsGeneric.cs @@ -6,7 +6,7 @@ namespace HActLib { - public enum ConditionType : uint + public enum AuthPageConditionsGeneric : uint { dmy = 0x0, random = 0x1, @@ -85,5 +85,5 @@ public enum ConditionType : uint damage_reaction = 0x4A, has_cd = 0x4B, equip_armor = 0x4C, - }; + } } diff --git a/Enums/AuthPage/AuthPageConditionsY6.cs b/Enums/AuthPage/AuthPageConditionsY6.cs new file mode 100644 index 0000000..003cf63 --- /dev/null +++ b/Enums/AuthPage/AuthPageConditionsY6.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HActLib +{ + public enum AuthPageConditionsY6 : uint + { + dmy = 0, + page_end = 9, + hact_condition_flag = 17, + page_play_count = 27, + } +} diff --git a/Projects/CMNEdit/TreeViewItemCondition.cs b/Projects/CMNEdit/TreeViewItemCondition.cs index 3d34d05..791dc3d 100644 --- a/Projects/CMNEdit/TreeViewItemCondition.cs +++ b/Projects/CMNEdit/TreeViewItemCondition.cs @@ -21,9 +21,9 @@ public TreeViewItemCondition(Transition trans, Condition cond) : base() public string GetName() { - switch((ConditionType)Condition.ConditionID) + switch(ConditionConvert.GetName(Condition.ConditionID, Form1.curGame)) { - case ConditionType.hact_condition_flag: + case "hact_condition_flag": ConditionHActFlag flag = Condition as ConditionHActFlag; if (flag.ConditionFlagOn == 1 && flag.ConditionFlagOff == 0) @@ -33,7 +33,13 @@ public string GetName() break; } - return Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(((ConditionType)Condition.ConditionID).ToString().Replace("_", " ")); + + string name = ConditionConvert.GetName(Condition.ConditionID, Form1.curGame); + + if (string.IsNullOrEmpty(name)) + name = "Condition " + Condition.ConditionID.ToString(); + + return Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(name).ToString().Replace("_", " "); } } } diff --git a/Projects/CMNEdit/TreeViewItemPage.cs b/Projects/CMNEdit/TreeViewItemPage.cs index 91893ac..3c437a6 100644 --- a/Projects/CMNEdit/TreeViewItemPage.cs +++ b/Projects/CMNEdit/TreeViewItemPage.cs @@ -4,15 +4,13 @@ namespace CMNEdit { - public class TreeViewItemPage: TreeNode + public class TreeViewItemPage : TreeNode { public AuthPage Page; public TreeViewItemPage(AuthPage page) : base() { Page = page; - Text = page.PageTitleText + $" ({page.PageIndex})"; - Update(); foreach (Transition transition in page.Transitions) @@ -23,7 +21,10 @@ public TreeViewItemPage(AuthPage page) : base() public void Update() { - Text = Page.PageTitleText + $" ({Page.PageIndex})"; + if(Page.Format > 0) + Text = Page.PageTitleText + $" ({Page.PageIndex})"; + else + Text = Page.PageTitleText; } } } diff --git a/Projects/CMNEdit/Windows/Common/DE/DEElementDOFWindow.cs b/Projects/CMNEdit/Windows/Common/DE/DEElementDOFWindow.cs new file mode 100644 index 0000000..5e2793b --- /dev/null +++ b/Projects/CMNEdit/Windows/Common/DE/DEElementDOFWindow.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using HActLib; + +namespace CMNEdit.Windows +{ + internal static class DEElementDOFWindow + { + public static void Draw(Form1 form, Node element) + { + DEElementDOF dof = element as DEElementDOF; + + form.CreateHeader("DOF"); + form.CreateInput("Disable", Convert.ToInt32(dof.DisableDof).ToString(), delegate (string val) { dof.DisableDof = int.Parse(val) > 0; }); + form.CreateInput("Use Intr", Convert.ToInt32(dof.UseIntr).ToString(), delegate (string val) { dof.UseIntr = int.Parse(val) > 0; }); + + form.CreateInput("Shape", dof.Shape.ToString(), delegate (string val) { dof.Shape = int.Parse(val); }, NumberBox.NumberMode.Int); + form.CreateInput("Diapharagm Blades", dof.DiaphragmBladesNum.ToString(), delegate (string val) { dof.DiaphragmBladesNum = int.Parse(val); }, NumberBox.NumberMode.Int); + form.CreateInput("Aperture Circularity", dof.ApertureCircularity.ToString(), delegate (string val) { dof.ApertureCircularity = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + + form.CreateInput("Focus Dist Before", dof.FocusDistBefore.ToString(), delegate (string val) { dof.FocusDistBefore = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Focus Dist After", dof.FocusDistAfter.ToString(), delegate (string val) { dof.FocusDistAfter = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + + form.CreateInput("Edge Type", Convert.ToInt32(dof.EdgeType).ToString(), delegate (string val) { dof.EdgeType = int.Parse(val); }, NumberBox.NumberMode.Int); + form.CreateInput("Focus Threshold", dof.EdgeThreshold.ToString(), delegate (string val) { dof.EdgeThreshold = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + + form.CreateInput("Quality", Convert.ToInt32(dof.Quality).ToString(), delegate (string val) { dof.Quality = int.Parse(val); }, NumberBox.NumberMode.Int); + form.CreateInput("Focus Local Pos", Convert.ToInt32(dof.FocusLocalPos).ToString(), delegate (string val) { dof.FocusLocalPos = int.Parse(val); }, NumberBox.NumberMode.Int); + + form.CreateInput("Alpha To Coverage Depth Threshold", dof.AlphaToCoverageDepthThreshold.ToString(), delegate (string val) { dof.AlphaToCoverageDepthThreshold = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + + form.CreateInput("Lens Type", dof.LensType.ToString(), delegate (string val) { dof.LensType = int.Parse(val); }, NumberBox.NumberMode.Int); + + form.CreateInput("Aberration", dof.Aberration.ToString(), delegate (string val) { dof.Aberration = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Aberration FOV", dof.AberrationFOV.ToString(), delegate (string val) { dof.AberrationFOV = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + + form.CreateInput("Gradient Threshold", dof.GradientThreshold.ToString(), delegate (string val) { dof.GradientThreshold = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Gradient Min Threshold", dof.GradientMinThreshold.ToString(), delegate (string val) { dof.GradientMinThreshold = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Gradient Max Threshold", dof.GradientMaxThreshold.ToString(), delegate (string val) { dof.GradientMaxThreshold = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + + form.CreateInput("Near Focus Distance", dof.NearFocusDistance.ToString(), delegate (string val) { dof.NearFocusDistance = int.Parse(val); }, NumberBox.NumberMode.Int); + form.CreateInput("DOF After Disable Dist", dof.DOFAfterDisableDist.ToString(), delegate (string val) { dof.DOFAfterDisableDist = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + } + } +} diff --git a/Projects/CMNEdit/Windows/Common/DE/DEElementMotionBlurWindow.cs b/Projects/CMNEdit/Windows/Common/DE/DEElementMotionBlurWindow.cs new file mode 100644 index 0000000..6ed5b38 --- /dev/null +++ b/Projects/CMNEdit/Windows/Common/DE/DEElementMotionBlurWindow.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using HActLib; + +namespace CMNEdit +{ + internal static class DEElementMotionBlurWindow + { + public static void Draw(Form1 form, Node node) + { + DEElementMotionBlur mb = node as DEElementMotionBlur; + + form.CreateHeader("Motion Blur"); + form.CreateInput("Shutter Speed", mb.ShutterSpeed.ToString(), delegate (string val) { mb.ShutterSpeed = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Blur Length", mb.BlurLength.ToString(), delegate (string val) { mb.BlurLength = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Sampling Interleave", mb.SamplingInterleave.ToString(), delegate (string val) { mb.SamplingInterleave = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Falloff Start Distance", mb.FalloffStartDist.ToString(), delegate (string val) { mb.FalloffStartDist = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Falloff End Distance", mb.FalloffEndDist.ToString(), delegate (string val) { mb.FalloffStartDist = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Rotation Perspective Threshold", mb.RotationPerspectiveThreshold.ToString(), delegate (string val) { mb.RotationPerspectiveThreshold = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + form.CreateInput("Trans Threshold", mb.TransThreshold.ToString(), delegate (string val) { mb.TransThreshold = Utils.InvariantParse(val); }, NumberBox.NumberMode.Float); + + } + } +} diff --git a/Projects/CMNEdit/Windows/ConditionWindow.cs b/Projects/CMNEdit/Windows/ConditionWindow.cs index 2d88220..9356d05 100644 --- a/Projects/CMNEdit/Windows/ConditionWindow.cs +++ b/Projects/CMNEdit/Windows/ConditionWindow.cs @@ -10,9 +10,9 @@ public static void Draw(Pager form, TreeViewItemCondition cond) { form.CreateHeader("Condition Information"); - switch((ConditionType)cond.Condition.ConditionID) + switch(ConditionConvert.GetName(cond.Condition.ConditionID, Form1.curGame)) { - case ConditionType.enemy_num: + case "enemy_num": ConditionEnemyNum enemyCountCond = cond.Condition as ConditionEnemyNum; @@ -42,7 +42,7 @@ public static void Draw(Pager form, TreeViewItemCondition cond) }, NumberBox.NumberMode.Int); break; - case ConditionType.page_play_count: + case "page_play_count": ConditionPagePlayCount playCountCond = cond.Condition as ConditionPagePlayCount; @@ -54,7 +54,7 @@ public static void Draw(Pager form, TreeViewItemCondition cond) break; - case ConditionType.hact_condition_flag: + case "hact_condition_flag": ConditionHActFlag condHAct = cond.Condition as ConditionHActFlag; @@ -72,7 +72,7 @@ public static void Draw(Pager form, TreeViewItemCondition cond) break; - case ConditionType.program_param: + case "program_param": ConditionProgramParam condprog = cond.Condition as ConditionProgramParam; diff --git a/Projects/CMNEdit/Windows/Form1.cs b/Projects/CMNEdit/Windows/Form1.cs index bb5e528..25a4862 100644 --- a/Projects/CMNEdit/Windows/Form1.cs +++ b/Projects/CMNEdit/Windows/Form1.cs @@ -1713,9 +1713,15 @@ public void DrawElementWindow(NodeElement element) case "e_auth_element_post_effect_gradation": DEElementGradationWindow.Draw(this, element); break; + case "e_auth_element_post_effect_dof": + DEElementDOFWindow.Draw(this, element); + break; case "e_auth_element_post_effect_dof2": DEElementDOF2Window.Draw(this, element); break; + case "e_auth_element_post_effect_motion_blur": + DEElementMotionBlurWindow.Draw(this, element); + break; case "e_auth_element_post_effect_motion_blur2": DEElementMotionBlur2Window.Draw(this, element); break; @@ -2805,10 +2811,30 @@ private void convertBetweenGamesDEToolStripMenuItem_Click(object sender, EventAr nodes = genHact.GetNodes(); - foreach (AuthPage page in AuthPagesDE) + for(int i = 0; i < AuthPagesDE.Length; i++) { - page.IsOldDE = targetVer <= GameVersion.DE1; + AuthPage page = AuthPagesDE[i]; + //Convert between old and new formats + if ((page.Format == 0 && targetVer > GameVersion.Yakuza6) || (page.Format > 0 && targetVer <= GameVersion.Yakuza6)) + { + page.PageIndex = i; + + foreach (Transition transition in page.Transitions) + foreach (Condition condition in transition.Conditions) + { + string name = ConditionConvert.GetName(condition.ConditionID, curGame); + uint newID = ConditionConvert.GetID(name, prefixGame); + condition.ConditionID = newID; + } + } + + if (targetVer <= GameVersion.Yakuza6) + page.Format = 0; + else if (targetVer == GameVersion.DE1) + page.Format = 1; + else + page.Format = 2; if (page.IsTalkPage()) { diff --git a/Projects/CMNEdit/Windows/PageWindow.cs b/Projects/CMNEdit/Windows/PageWindow.cs index 8e87dd5..dd549e2 100644 --- a/Projects/CMNEdit/Windows/PageWindow.cs +++ b/Projects/CMNEdit/Windows/PageWindow.cs @@ -11,7 +11,9 @@ public static void Draw(Pager form, TreeViewItemPage page) { form.CreateHeader("Page Info"); - form.CreateInput("Name", page.Page.PageTitleText, delegate (string newVal) { page.Page.PageTitleText = newVal; page.Update(); }); + if(page.Page.Format > 1) + form.CreateInput("Name", page.Page.PageTitleText, delegate (string newVal) { page.Page.PageTitleText = newVal; page.Update(); }); + form.CreateInput("Flag", page.Page.Flag.ToString(), delegate (string newVal) { page.Page.Flag = uint.Parse(newVal); page.Update(); }, NumberBox.NumberMode.UInt); form.CreateInput("Start", page.Page.Start.Frame.ToString(), delegate (string newVal) { page.Page.Start.Frame = Utils.InvariantParse(newVal); }, NumberBox.NumberMode.Float); diff --git a/Types/Converter/DE/RyuseModule.cs b/Types/Converter/DE/RyuseModule.cs index 3a36529..ad20122 100644 --- a/Types/Converter/DE/RyuseModule.cs +++ b/Types/Converter/DE/RyuseModule.cs @@ -151,14 +151,6 @@ public static ConversionResult ConvertNode(Node node, Game inputGame, Game outpu } else { - if (!element.TryConvert(inputGame, outputGame)) - { - element.ElementKind = 0; - element.Name += " (invalid)"; - - return ConversionResult.Fail; - } - element.ElementKind = outputID; element.BEPDat.PropertyType = (ushort)outputID; @@ -169,6 +161,24 @@ public static ConversionResult ConvertNode(Node node, Game inputGame, Game outpu } else { + NodeElement convertedNode = node.TryConvert(inputGame, outputGame) as NodeElement; + + if (convertedNode != null) + { + Node.CopyBaseInfo(node, convertedNode); + Node.CopyBaseElementInfo(element, convertedNode); + + if (node.Parent != null) + { + int origIdx = node.Parent.Children.IndexOf(node); + node.Parent.Children.Remove(node); + node.Parent.Children.Insert(origIdx, convertedNode); + convertedNode.Parent = node.Parent; + node.Parent = null; + } + return ConversionResult.Success; + } + element.ElementKind = 0; element.Name += " (invalid)"; diff --git a/Types/Converter/OE/OEToDECmn.cs b/Types/Converter/OE/OEToDECmn.cs index 73384c1..75d062c 100644 --- a/Types/Converter/OE/OEToDECmn.cs +++ b/Types/Converter/OE/OEToDECmn.cs @@ -216,8 +216,8 @@ NodeElement GetNearestEndNodeInRange(float start) else { successPage.End.Frame = branchNodes.ElementAt(i + 1).Start - 1; - successPage.Transitions.Add(new Transition(pageIdx + 2, new ConditionHActFlag(1, 0), new ConditionPageEnd())); - successPage.Transitions.Add(new Transition(pageIdx + 3, new ConditionHActFlag(0, 1), new ConditionPageEnd())); + successPage.Transitions.Add(new Transition(pageIdx + 2, new ConditionHActFlag(CMN.LastHActDEGame, 1, 0), new ConditionPageEnd(CMN.LastHActDEGame))); + successPage.Transitions.Add(new Transition(pageIdx + 3, new ConditionHActFlag(CMN.LastHActDEGame, 0, 1), new ConditionPageEnd(CMN.LastHActDEGame))); } if (failEnd != null) @@ -238,12 +238,12 @@ NodeElement GetNearestEndNodeInRange(float start) } - startPage.Transitions.Add(new Transition(1, new ConditionPageEnd())); + startPage.Transitions.Add(new Transition(1, new ConditionPageEnd(CMN.LastHActDEGame))); AuthPage promptPage = new AuthPage("PROMPT START", buttonNodes.ElementAt(0).Start, branchNodes.ElementAt(0).Start - 1); promptPage.PageIndex = 1; - promptPage.Transitions.Add(new Transition(2, new ConditionHActFlag(1, 0), new ConditionPageEnd())); - promptPage.Transitions.Add(new Transition(3, new ConditionHActFlag(0, 1), new ConditionPageEnd())); + promptPage.Transitions.Add(new Transition(2, new ConditionHActFlag(CMN.LastHActDEGame, 1, 0), new ConditionPageEnd(CMN.LastHActDEGame))); + promptPage.Transitions.Add(new Transition(3, new ConditionHActFlag(CMN.LastHActDEGame, 0, 1), new ConditionPageEnd(CMN.LastHActDEGame))); pages.Insert(1, promptPage); @@ -252,7 +252,7 @@ NodeElement GetNearestEndNodeInRange(float start) { if (page.Transitions.Count <= 0) { - page.Transitions.Add(new Transition(-1, new ConditionPageEnd())); + page.Transitions.Add(new Transition(-1, new ConditionPageEnd(CMN.LastHActDEGame))); } } diff --git a/Types/Converter/OE/RyuseOEModule.cs b/Types/Converter/OE/RyuseOEModule.cs index 8a31ecb..c6c061e 100644 --- a/Types/Converter/OE/RyuseOEModule.cs +++ b/Types/Converter/OE/RyuseOEModule.cs @@ -157,6 +157,7 @@ public static ConversionResult ConvertNode(Node node, Node parent, Game inputGam return ConversionResult.NoChange; else { + /* if(!element.TryConvert(inputGame, outputGame)) { element.ElementKind = 0; @@ -164,6 +165,7 @@ public static ConversionResult ConvertNode(Node node, Node parent, Game inputGam return ConversionResult.Fail; } + */ element.ElementKind = outputID; element.BEPDat.PropertyType = (ushort)outputID; diff --git a/Types/Converter/OOE/OOEToDE.cs b/Types/Converter/OOE/OOEToDE.cs index 583b125..83e0487 100644 --- a/Types/Converter/OOE/OOEToDE.cs +++ b/Types/Converter/OOE/OOEToDE.cs @@ -170,8 +170,8 @@ Set2Element1019 GetNearestEndNodeInRange(float start) else { successPage.End.Frame = branchNodes.ElementAt(i + 1).Start - 1; - successPage.Transitions.Add(new Transition(pageIdx + 2, new ConditionHActFlag(1, 0), new ConditionPageEnd())); - successPage.Transitions.Add(new Transition(pageIdx + 3, new ConditionHActFlag(0, 1), new ConditionPageEnd())); + successPage.Transitions.Add(new Transition(pageIdx + 2, new ConditionHActFlag(CMN.LastHActDEGame, 1, 0), new ConditionPageEnd(CMN.LastHActDEGame))); + successPage.Transitions.Add(new Transition(pageIdx + 3, new ConditionHActFlag(CMN.LastHActDEGame, 0, 1), new ConditionPageEnd(CMN.LastHActDEGame))); } if (failEnd != null) @@ -192,12 +192,12 @@ Set2Element1019 GetNearestEndNodeInRange(float start) } - startPage.Transitions.Add(new Transition(1, new ConditionPageEnd())); + startPage.Transitions.Add(new Transition(1, new ConditionPageEnd(CMN.LastHActDEGame))); AuthPage promptPage = new AuthPage("PROMPT START", buttonNodes.ElementAt(0).Start, branchNodes.ElementAt(0).Start - 1); promptPage.PageIndex = 1; - promptPage.Transitions.Add(new Transition(2, new ConditionHActFlag(1, 0), new ConditionPageEnd())); - promptPage.Transitions.Add(new Transition(3, new ConditionHActFlag(0, 1), new ConditionPageEnd())); + promptPage.Transitions.Add(new Transition(2, new ConditionHActFlag(CMN.LastHActDEGame, 1, 0), new ConditionPageEnd(CMN.LastHActDEGame))); + promptPage.Transitions.Add(new Transition(3, new ConditionHActFlag(CMN.LastHActDEGame, 0, 1), new ConditionPageEnd(CMN.LastHActDEGame))); pages.Insert(1, promptPage); diff --git a/Types/DE/AuthPage/AuthPage.cs b/Types/DE/AuthPage/AuthPage.cs index 71d5d4a..cb4af52 100644 --- a/Types/DE/AuthPage/AuthPage.cs +++ b/Types/DE/AuthPage/AuthPage.cs @@ -34,12 +34,45 @@ Transition ProcessTransitionData(AuthPage authPage) } //read basic info - AuthPage page = reader.Read(); - page.IsOldDE = CMN.LastGameVersion == GameVersion.DE1; + AuthPage page = new AuthPage(); + GameVersion ver = CMN.LastGameVersion; - if (!page.IsOldDE) - // page.PageTitleText = reader.ReadString(32); - page.PageTitleText = reader.ReadString(32, System.Text.Encoding.GetEncoding(932)).Split(new[] { '\0' }, 2)[0]; + if (ver <= GameVersion.Yakuza6) + page.Format = 0; + else if (ver == GameVersion.DE1) + page.Format = 1; + else if (ver >= GameVersion.DE2) + page.Format = 2; + + if(page.Format > 0) + { + page.Version = reader.ReadUInt32(); + page.Flag = reader.ReadUInt32(); + } + + page.Start = new GameTick(reader.ReadUInt32()); + page.End = new GameTick(reader.ReadUInt32()); + + if (page.Format < 1) + page.Unk = reader.ReadInt32(); + + page.TransitionCount = reader.ReadInt32(); + page.TransitionSize = reader.ReadInt32(); + + page.SkipTick = new GameTick(reader.ReadUInt32()); + + if (page.Format > 0) + page.PageIndex = reader.ReadInt32(); + + page.SkipLinkIndexNum = reader.ReadInt32(); + + if (page.Format < 1) + reader.Stream.Position += 4; + else + reader.Stream.Position += 12; + + if (page.Format > 1) + page.PageTitleText = reader.ReadString(32, System.Text.Encoding.GetEncoding(932)).Split(new[] { '\0' }, 2)[0]; //Read transitions // long transitionStart = startPos + 80 + (page.SkipLinkIndexNum * 4); @@ -56,21 +89,6 @@ Transition ProcessTransitionData(AuthPage authPage) for (int i = 0; i < page.TransitionCount; i++) page.Transitions[i] = (ProcessTransitionData(page)); - //Console.WriteLine(reader.ReadUInt32()); - //reader.Stream.Position -= 4; - - - - //DE 1.0: Fake talk page - if(page.IsOldDE) - { - uint count = reader.ReadUInt32(); - reader.Stream.Position -= 4; - - //if (count <= 0) - //page.Flag = 0; - } - //read talk page related info if (page.IsTalkPage()) { @@ -89,30 +107,31 @@ Transition ProcessTransitionData(AuthPage authPage) [Yarhl.IO.Serialization.Attributes.Serializable] public class AuthPage : IFormat { - public uint Version { get; set; } - public uint Flag { get; set; } + public uint Version; + public uint Flag; - public GameTick Start { get; set; } = new GameTick(0); - public GameTick End { get; set; } = new GameTick(0); + public GameTick Start = new GameTick(0); + public GameTick End = new GameTick(0); - public int TransitionCount { get; set; } - public int TransitionSize { get; set; } + public int Unk = 0; //Y6 + + public int TransitionCount = 0; + public int TransitionSize = 0; public List Transitions = new List(); public int[] SkipLink = new int[0]; - public GameTick SkipTick { get; set; } = new GameTick(0); + public GameTick SkipTick = new GameTick(0); - public int PageIndex { get; set; } - public int SkipLinkIndexNum { get; set; } + public int PageIndex = 0; + public int SkipLinkIndexNum = 0; [BinaryString(FixedSize = 12, MaxSize = 12)] public string Padding { get; set; } = ""; - // [BinaryString(FixedSize = 32, MaxSize = 32)] public string PageTitleText = ""; - public bool IsOldDE = false; + public int Format = 0; //0 = Y6, 1 = DE 1.0, 2 = DE 2.0 /// /// The talk information header of the page if it exists. Otherwise null. @@ -149,7 +168,7 @@ public AuthPage Clone() public bool IsTalkPage() { - if (IsOldDE) + if (Format <= 1) return Flag > 0; else return (Flag & 0x40) > 0; @@ -159,7 +178,16 @@ public bool IsTalkPage() //Get the size of page. Used for writing. public int GetPageSize() { - int baseSize = (!IsOldDE ? 80 : 48) + GetTransitionSize() + (SkipLinkIndexNum * 4); + int pageSize = 0; + + if (Format == 0) + pageSize = 32; + else if (Format == 1) + pageSize = 48; + else + pageSize = 80; + + int baseSize = (pageSize) + GetTransitionSize() + (SkipLinkIndexNum * 4); if (TalkInfo != null && TalkInfo.Length > 0) baseSize += 16 + (TalkInfo.Length * 16); @@ -184,7 +212,12 @@ public int GetTransitionSize() public uint BaseSize() { - return (uint)((!IsOldDE ? 80 : 48) + TransitionSize + (SkipLinkIndexNum * 4)); + if(Format == 0) + return (uint)((32) + TransitionSize + (SkipLinkIndexNum * 4)); + else if(Format == 1) + return (uint)((48) + TransitionSize + (SkipLinkIndexNum * 4)); + else + return (uint)((80) + TransitionSize + (SkipLinkIndexNum * 4)); } public uint Size() diff --git a/Types/DE/AuthPage/Conditions/Condition.cs b/Types/DE/AuthPage/Conditions/Condition.cs index e2bea67..69cf1ef 100644 --- a/Types/DE/AuthPage/Conditions/Condition.cs +++ b/Types/DE/AuthPage/Conditions/Condition.cs @@ -7,21 +7,46 @@ namespace HActLib { public class ConditionConvert : IConverter { - internal Condition GetCondFromType(ConditionType cond) + + public static string GetName(uint cond, Game game) + { + Type enumType; + + if (game <= Game.Y6) + enumType = typeof(AuthPageConditionsY6); + else + enumType = typeof(AuthPageConditionsGeneric); + + return Enum.GetName(enumType, cond); + } + + public static uint GetID(string name, Game game) + { + Type enumType; + + if (game == Game.Y6) + enumType = typeof(AuthPageConditionsY6); + else + enumType = typeof(AuthPageConditionsGeneric); + + return (uint)Enum.Parse(enumType, name); + } + + internal Condition GetCondFromType(uint cond, Game game) { - switch(cond) + switch(GetName(cond, game)) { default: return new Condition(); - case ConditionType.page_play_count: + case "page_play_count": return new ConditionPagePlayCount(); - case ConditionType.play_count: + case "play_count": return new ConditionPlayCount(); - case ConditionType.hact_condition_flag: - return new ConditionHActFlag(); - case ConditionType.enemy_num: + case "hact_condition_flag": + return new ConditionHActFlag(game); + case "enemy_num": return new ConditionEnemyNum(); - case ConditionType.program_param: + case "program_param": return new ConditionProgramParam(); } } @@ -31,13 +56,13 @@ public Condition Convert(BinaryFormat format) { DataReader reader = new DataReader(format.Stream) { Endianness = EndiannessMode.LittleEndian, DefaultEncoding = System.Text.Encoding.GetEncoding(932) }; - ConditionType condType = (ConditionType)reader.ReadUInt32(); + uint condType = reader.ReadUInt32(); uint parameterSize = reader.ReadUInt32(); reader.ReadBytes(8); - Condition cond = GetCondFromType(condType); - cond.ConditionID = (uint)condType; + Condition cond = GetCondFromType(condType, CMN.LastHActDEGame); + cond.ConditionID = condType; long paramStart = reader.Stream.Position; long paramTargetPos = reader.Stream.Position + parameterSize; diff --git a/Types/DE/AuthPage/Conditions/ConditionHActFlag.cs b/Types/DE/AuthPage/Conditions/ConditionHActFlag.cs index d844f30..76e5063 100644 --- a/Types/DE/AuthPage/Conditions/ConditionHActFlag.cs +++ b/Types/DE/AuthPage/Conditions/ConditionHActFlag.cs @@ -12,14 +12,14 @@ public class ConditionHActFlag : Condition public uint ConditionFlagOn; public uint ConditionFlagOff; - public ConditionHActFlag() + public ConditionHActFlag(Game game) { - ConditionID = (uint)ConditionType.hact_condition_flag; + ConditionID = ConditionConvert.GetID("hact_condition_flag", game); } - public ConditionHActFlag(uint on, uint off) + public ConditionHActFlag(Game game, uint on, uint off) { - ConditionID = (uint)ConditionType.hact_condition_flag; + ConditionID = ConditionConvert.GetID("hact_condition_flag", game); ConditionFlagOn = on; ConditionFlagOff = off; diff --git a/Types/DE/AuthPage/Conditions/ConditionPageEnd.cs b/Types/DE/AuthPage/Conditions/ConditionPageEnd.cs index e9c1ca8..ad3deb6 100644 --- a/Types/DE/AuthPage/Conditions/ConditionPageEnd.cs +++ b/Types/DE/AuthPage/Conditions/ConditionPageEnd.cs @@ -9,9 +9,9 @@ namespace HActLib { public class ConditionPageEnd : Condition { - public ConditionPageEnd() + public ConditionPageEnd(Game game) { - ConditionID = (uint)ConditionType.page_end; + ConditionID = ConditionConvert.GetID("page_end", game); } internal override void Read(DataReader reader, uint parameterSize) diff --git a/Types/DE/CMN.cs b/Types/DE/CMN.cs index 64b2e5a..4c8e04e 100644 --- a/Types/DE/CMN.cs +++ b/Types/DE/CMN.cs @@ -82,7 +82,7 @@ public BinaryFormat Convert(CMN cmn) #region Page Info - if (cmn.GameVersion > GameVersion.Yakuza6) + if (cmn.GameVersion > GameVersion.Yakuza6Demo) { writer.Write(cmn.AuthPages.Count); @@ -92,18 +92,29 @@ public BinaryFormat Convert(CMN cmn) foreach (AuthPage page in cmn.AuthPages) { - writer.Write(page.Version); - writer.Write(page.Flag); + if (page.Format > 0) + { + writer.Write(page.Version); + writer.Write(page.Flag); + } + writer.Write(page.Start.Tick); writer.Write(page.End.Tick); + + if (page.Format < 1) + writer.Write(page.Unk); + writer.Write(page.Transitions.Count); writer.Write(page.GetTransitionSize()); writer.Write(page.SkipTick.Tick); - writer.Write(page.PageIndex); + + if(page.Format > 0) + writer.Write(page.PageIndex); + writer.Write(page.SkipLinkIndexNum); - writer.WriteTimes(0, 12); + writer.WriteTimes(0, page.Format > 0 ? 12 : 4); - if (cmn.GameVersion == GameVersion.DE2) + if (page.Format > 1) writer.Write(page.PageTitleText.ToLength(32), fixedSize: 32, nullTerminator: false, encoding: writer.DefaultEncoding); foreach (int i in page.SkipLink) @@ -566,7 +577,7 @@ public static CMN Read(byte[] buffer, Game game) //Read auth pages - if (VersionGreater(version, GameVersion.Yakuza6)) + if (VersionGreater(version, GameVersion.Yakuza6Demo)) cmn.ReadAuthPages(cmnReader); else { @@ -591,6 +602,10 @@ internal void ReadAuthPages(DataReader reader) for (int i = 0; i < AuthPages.Count; i++) { AuthPage page = (AuthPage)ConvertFormat.With(new BinaryFormat(reader.Stream)); + + if (page.Format <= 1) + page.PageTitleText = "Page " + i; + AuthPages[i] = page; #if !DEBUG } diff --git a/Types/Node/Element/DE/DEElementDOF.cs b/Types/Node/Element/DE/DEElementDOF.cs new file mode 100644 index 0000000..266c2c8 --- /dev/null +++ b/Types/Node/Element/DE/DEElementDOF.cs @@ -0,0 +1,152 @@ +using HActLib.Internal; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yarhl.IO; + +namespace HActLib +{ + [ElementID(Game.Y6, 0x8)] + [ElementID(Game.YK2, 0x8)] + [ElementID(Game.JE, 0x8)] + public class DEElementDOF : NodeElement + { + public bool DisableDof = false; + public bool UseIntr = false; + public int Shape = 7; + public int DiaphragmBladesNum = 6; + public float ApertureCircularity = 0; + + public float FocusDistBefore = 1; + public float FocusDistAfter = 1; + + public int EdgeType = -1; + public float EdgeThreshold = 0.1f; + + public int Quality = 5; + public int FocusLocalPos = 0; + + public float AlphaToCoverageDepthThreshold; + + public float[] Animation = new float[32]; + + public int LensType; + + public float Aberration; + public float AberrationFOV; + + public float GradientThreshold; + public float GradientMinThreshold; + public float GradientMaxThreshold; + + public int NearFocusDistance; + + public float DOFAfterDisableDist; + + internal override void ReadElementData(DataReader reader, NodeConvInf inf, GameVersion version) + { + DisableDof = reader.ReadInt32() > 0; + UseIntr = reader.ReadInt32() > 0; + + Shape = reader.ReadInt32(); + DiaphragmBladesNum = reader.ReadInt32(); + ApertureCircularity = reader.ReadSingle(); + + FocusDistBefore = reader.ReadSingle(); + FocusDistAfter = reader.ReadSingle(); + + EdgeType = reader.ReadInt32(); + EdgeThreshold = reader.ReadSingle(); + + Quality = reader.ReadInt32(); + FocusLocalPos = reader.ReadInt32(); + AlphaToCoverageDepthThreshold = reader.ReadSingle(); + + for (int i = 0; i < Animation.Length; i++) + Animation[i] = reader.ReadSingle(); + + LensType = reader.ReadInt32(); + Aberration = reader.ReadSingle(); + AberrationFOV = reader.ReadSingle(); + GradientThreshold = reader.ReadSingle(); + GradientMinThreshold = reader.ReadSingle(); + GradientMaxThreshold = reader.ReadSingle(); + + NearFocusDistance = reader.ReadInt32(); + DOFAfterDisableDist = reader.ReadSingle(); + } + + internal override void WriteElementData(DataWriter writer, GameVersion version) + { + writer.Write(Convert.ToInt32(DisableDof)); + writer.Write(Convert.ToInt32(UseIntr)); + + writer.Write(Shape); + writer.Write(DiaphragmBladesNum); + writer.Write(ApertureCircularity); + + writer.Write(FocusDistBefore); + writer.Write(FocusDistAfter); + + writer.Write(EdgeType); + writer.Write(EdgeThreshold); + + writer.Write(Quality); + writer.Write(FocusLocalPos); + writer.Write(AlphaToCoverageDepthThreshold); + + for (int i = 0; i < 32; i++) + writer.Write(Animation[i]); + + writer.Write(LensType); + writer.Write(Aberration); + writer.Write(AberrationFOV); + writer.Write(GradientThreshold); + writer.Write(GradientMinThreshold); + writer.Write(GradientMaxThreshold); + + writer.Write(NearFocusDistance); + writer.Write(DOFAfterDisableDist); + } + + public override Node TryConvert(Game input, Game output) + { + GameVersion outputVer = CMN.GetVersionForGame(output); + + if (outputVer >= GameVersion.DE2) + { + DEElementDOF2 blur2 = new DEElementDOF2(); + + blur2.DisableDof = DisableDof; + blur2.UseIntr = UseIntr; + + blur2.Shape = Shape; + blur2.DiaphragmBladesNum = DiaphragmBladesNum; + blur2.ApertureCircularity = ApertureCircularity; + + if(FocusDistBefore == 1 && FocusDistAfter == 1) + { + blur2.FocusDistBefore = 0; + blur2.FocusDistAfter = 0; + } + else + { + blur2.FocusDistBefore = FocusDistBefore; + blur2.FocusDistAfter = FocusDistAfter; + } + + blur2.NearFocusDistance = NearFocusDistance; + blur2.Animation = Animation; + + blur2.ElementKind = Reflection.GetElementIDByName("e_auth_element_post_effect_dof2", output); + blur2.BEPDat.PropertyType = (ushort)blur2.ElementKind; + + return blur2; + } + + return this; + } + } +} diff --git a/Types/Node/Element/DE/DEElementDOF2.cs b/Types/Node/Element/DE/DEElementDOF2.cs index 6d9b28b..729fff9 100644 --- a/Types/Node/Element/DE/DEElementDOF2.cs +++ b/Types/Node/Element/DE/DEElementDOF2.cs @@ -16,53 +16,53 @@ public class DEElementDOF2 : NodeElement { public bool DisableDof; - public float FocusDistBefore; - public float FocusDistAfter; + public float FocusDistBefore = 0; + public float FocusDistAfter = 0; public bool UseIntr; - public float FarCocRate; - public float NearCocRate; - - public float FocusFarD; - public float FarMaxCocDist; - public float FocusNearD; - public float NearMaxCocDist; - public float MaxCocRadius; - - public float SpecularBrightness; - public float SpecularThresold; - - public float Alpha; - public float ColorScale; - - public int Shape; - - public int DiaphragmBladesNum; - public int ShapeRotAngle; - public float ApertureCircularity; - public float BokehAttenBeginRate; - public float HighLumiEmphasisThresold; - public float HighLumiEmphasisColor; - public float HighLumiEmphasisScale; - - public bool FullResoBokeh; - public int NearFocusDistance; - public float FNumber; - public bool UseFNumber; - public bool EnableFocusAdjust; - public float FocusNearDFNumber; - public float FocusFarDFNumber; - public bool CalcBeforeTAA; - public float MaxCocRadiusF; - - public int CinematicDofQualityLevel; - public bool EnableMirror; - public bool EnableMirrorOnly; - public int ScatterMode; - public int RingCount; - public int TAAQuality; - public int RecombineQuality; + public float FarCocRate = 2; + public float NearCocRate = 2; + + public float FocusFarD = 0.5f; + public float FarMaxCocDist = 1f; + public float FocusNearD = 0.5f; + public float NearMaxCocDist = 0.5f; + public float MaxCocRadius = 8; + + public float SpecularBrightness = 0; + public float SpecularThresold = 0.95f; + + public float Alpha = 1; + public float ColorScale = 1; + + public int Shape = 7; + + public int DiaphragmBladesNum = 6; + public int ShapeRotAngle = 0; + public float ApertureCircularity = 1; + public float BokehAttenBeginRate = 0.9f; + public float HighLumiEmphasisThresold = 2; + public float HighLumiEmphasisColor = 1; + public float HighLumiEmphasisScale = 1; + + public bool FullResoBokeh = false; + public int NearFocusDistance = 0; + public float FNumber = 16; + public bool UseFNumber = true; + public bool EnableFocusAdjust = false; + public float FocusNearDFNumber = 0.5f; + public float FocusFarDFNumber = 0.5f; + public bool CalcBeforeTAA = false; + public float MaxCocRadiusF = 20f; + + public int CinematicDofQualityLevel = 0; + public bool EnableMirror = false; + public bool EnableMirrorOnly = false; + public int ScatterMode = 0; + public int RingCount = 3; + public int TAAQuality = 0; + public int RecombineQuality = 0; public int DOFFlag; public float[] Animation = new float[32]; diff --git a/Types/Node/Element/DE/DEElementMotionBlur.cs b/Types/Node/Element/DE/DEElementMotionBlur.cs new file mode 100644 index 0000000..7711fe9 --- /dev/null +++ b/Types/Node/Element/DE/DEElementMotionBlur.cs @@ -0,0 +1,67 @@ +using HActLib.Internal; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yarhl.FileSystem; +using Yarhl.IO; + +namespace HActLib +{ + [ElementID(Game.Y6, 0x1E)] + [ElementID(Game.YK2, 0x1E)] + [ElementID(Game.JE, 0x1E)] + public class DEElementMotionBlur : NodeElement + { + public float ShutterSpeed = 30; + public float BlurLength = 0.1f; + public float SamplingInterleave = 1f; + public float FalloffStartDist = 0f; + public float FalloffEndDist = 0f; + public float RotationPerspectiveThreshold = 0.02f; + public float TransThreshold = 0f; + + internal override void ReadElementData(DataReader reader, NodeConvInf inf, GameVersion version) + { + ShutterSpeed = reader.ReadSingle(); + BlurLength = reader.ReadSingle(); + SamplingInterleave = reader.ReadSingle(); + FalloffStartDist = reader.ReadSingle(); + FalloffEndDist = reader.ReadSingle(); + RotationPerspectiveThreshold = reader.ReadSingle(); + TransThreshold = reader.ReadSingle(); + } + + internal override void WriteElementData(DataWriter writer, GameVersion version) + { + writer.Write(ShutterSpeed); + writer.Write(BlurLength); + writer.Write(SamplingInterleave); + writer.Write(FalloffStartDist); + writer.Write(FalloffEndDist); + writer.Write(RotationPerspectiveThreshold); + writer.Write(TransThreshold); + } + + + public override Node TryConvert(Game input, Game output) + { + GameVersion outputVer = CMN.GetVersionForGame(output); + + if(outputVer >= GameVersion.DE2) + { + DEElementMotionBlur2 blur2 = new DEElementMotionBlur2(); + blur2.ShutterSpeed = ShutterSpeed; + blur2.BlurLength = BlurLength; + + blur2.ElementKind = Reflection.GetElementIDByName("e_auth_element_post_effect_motion_blur2", output); + blur2.BEPDat.PropertyType = (ushort)blur2.ElementKind; + + return blur2; + } + + return this; + } + } +} diff --git a/Types/Node/Element/DE/DEElementMotionBlur2.cs b/Types/Node/Element/DE/DEElementMotionBlur2.cs index c529a9b..0005893 100644 --- a/Types/Node/Element/DE/DEElementMotionBlur2.cs +++ b/Types/Node/Element/DE/DEElementMotionBlur2.cs @@ -1,4 +1,5 @@ -using System; +using HActLib.Internal; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -24,7 +25,8 @@ internal override void ReadElementData(DataReader reader, NodeConvInf inf, GameV BlurLength = reader.ReadSingle(); SampleCount = reader.ReadInt32(); - if (inf.expectedSize > 12) + //Spotted: LADIW + if (inf.expectedSize > 44) Unknown = reader.ReadSingle(); } @@ -37,5 +39,24 @@ internal override void WriteElementData(DataWriter writer, GameVersion version) if (CMN.LastHActDEGame >= Game.LADIW) writer.Write(Unknown); } + + public override Node TryConvert(Game input, Game output) + { + GameVersion outputVer = CMN.GetVersionForGame(output); + + if (outputVer <= GameVersion.DE1) + { + DEElementMotionBlur blur = new DEElementMotionBlur(); + blur.ShutterSpeed = ShutterSpeed; + blur.BlurLength = BlurLength; + + blur.ElementKind = Reflection.GetElementIDByName("e_auth_element_post_effect_motion_blur", output); + blur.BEPDat.PropertyType = (ushort)blur.ElementKind; + + return blur; + } + + return this; + } } } diff --git a/Types/Node/Element/DE/DETimingInfoAttack.cs b/Types/Node/Element/DE/DETimingInfoAttack.cs index 45ecd45..269288e 100644 --- a/Types/Node/Element/DE/DETimingInfoAttack.cs +++ b/Types/Node/Element/DE/DETimingInfoAttack.cs @@ -67,7 +67,7 @@ internal override void WriteElementData(DataWriter writer, GameVersion version) writer.Write(Data.AttackID); } - public override bool TryConvert(Game input, Game output) + public override Node TryConvert(Game input, Game output) { GameVersion inputGameVer = CMN.GetVersionForGame(input); GameVersion outputGameVer = CMN.GetVersionForGame(output); @@ -89,7 +89,7 @@ public override bool TryConvert(Game input, Game output) } */ - return true; + return this; } } diff --git a/Types/Node/Node.cs b/Types/Node/Node.cs index 4e44f33..3510a5f 100644 --- a/Types/Node/Node.cs +++ b/Types/Node/Node.cs @@ -254,9 +254,9 @@ public T[] GetChildsOfType() where T : Node /// /// Conversions that concern same engine different game /// - public virtual bool TryConvert(Game input, Game output) + public virtual Node TryConvert(Game input, Game output) { - return true; + return null; } } }