2019-08-29 22:33:23 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Syroot.Maths;
|
|
|
|
|
using Toolbox.Library.IO;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
using Toolbox.Library.Animations;
|
2019-08-29 23:17:24 +02:00
|
|
|
|
using Toolbox.Library;
|
2019-08-30 01:01:47 +02:00
|
|
|
|
using WeifenLuo.WinFormsUI.Docking;
|
2019-08-31 03:53:00 +02:00
|
|
|
|
using System.ComponentModel;
|
2020-01-19 02:59:49 +01:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
2020-02-12 01:19:23 +01:00
|
|
|
|
using SharpYaml.Serialization;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
|
|
|
|
namespace LayoutBXLYT
|
|
|
|
|
{
|
2020-01-19 02:59:49 +01:00
|
|
|
|
public class BasePane : SectionCommon, ICloneable
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
2019-10-06 03:15:19 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
|
|
|
|
internal BxlytHeader LayoutFile;
|
2019-10-06 03:15:19 +02:00
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
|
|
|
|
internal PaneAnimController animController = new PaneAnimController();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
|
|
|
|
internal TreeNodeCustom NodeWrapper;
|
2019-09-07 01:12:39 +02:00
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
|
|
|
|
internal bool IsRoot
|
2019-10-06 03:15:19 +02:00
|
|
|
|
{
|
|
|
|
|
get { return Parent == null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
|
|
|
|
internal bool ParentIsRoot
|
2019-09-07 01:12:39 +02:00
|
|
|
|
{
|
|
|
|
|
get { return Parent != null && Parent.IsRoot; }
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-09-13 00:52:47 +02:00
|
|
|
|
internal RenderablePane renderablePane;
|
|
|
|
|
|
2019-08-31 03:53:00 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
|
|
|
|
internal virtual bool DisplayInEditor { get; set; } = true;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
private string name;
|
|
|
|
|
|
2019-08-31 03:53:00 +02:00
|
|
|
|
[DisplayName("Name"), CategoryAttribute("Pane")]
|
2019-10-06 03:15:19 +02:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return name; }
|
|
|
|
|
set
|
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
//Adjust necessary parameters if the user changes the name
|
|
|
|
|
if (name != null && LayoutFile != null)
|
|
|
|
|
{
|
|
|
|
|
//Adjust name table entry
|
|
|
|
|
if (LayoutFile != null && LayoutFile.PaneLookup.ContainsKey(name))
|
|
|
|
|
LayoutFile.PaneLookup.Remove(name);
|
|
|
|
|
|
|
|
|
|
//Adjust material reference
|
|
|
|
|
if (this is IPicturePane)
|
|
|
|
|
((IPicturePane)this).Material.SetName(name, value);
|
|
|
|
|
else if (this is ITextPane)
|
|
|
|
|
((ITextPane)this).Material.SetName(name, value);
|
|
|
|
|
else if (this is IWindowPane)
|
|
|
|
|
{
|
|
|
|
|
var wnd = this as IWindowPane;
|
|
|
|
|
wnd.Content?.Material?.SetName(name, value);
|
|
|
|
|
|
|
|
|
|
if (wnd.WindowFrames != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var frame in wnd.WindowFrames)
|
|
|
|
|
{
|
|
|
|
|
if (frame.Material == null) continue;
|
|
|
|
|
frame.Material.SetName(name, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-06 03:15:19 +02:00
|
|
|
|
|
|
|
|
|
name = value;
|
|
|
|
|
|
2019-10-06 15:39:23 +02:00
|
|
|
|
if (LayoutFile != null && !LayoutFile.PaneLookup.ContainsKey(name))
|
2019-10-06 03:15:19 +02:00
|
|
|
|
LayoutFile.PaneLookup.Add(name, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2020-02-15 22:30:10 +01:00
|
|
|
|
[DisplayName("Parts Flag"), CategoryAttribute("Flags")]
|
|
|
|
|
public byte PaneMagFlags { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("User Data Info"), CategoryAttribute("User Data")]
|
|
|
|
|
public string UserDataInfo { get; set; }
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[DisplayName("Is Visible"), CategoryAttribute("Flags")]
|
|
|
|
|
public virtual bool Visible { get; set; }
|
|
|
|
|
|
2019-11-11 22:54:39 +01:00
|
|
|
|
public BxlytMaterial TryGetActiveMaterial()
|
|
|
|
|
{
|
|
|
|
|
if (this is IPicturePane)
|
|
|
|
|
return ((IPicturePane)this).Material;
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-31 03:53:00 +02:00
|
|
|
|
[DisplayName("Translate"), CategoryAttribute("Pane")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public Vector3F Translate { get; set; }
|
2019-08-31 03:53:00 +02:00
|
|
|
|
|
|
|
|
|
[DisplayName("Rotate"), CategoryAttribute("Pane")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public Vector3F Rotate { get; set; }
|
2019-08-31 03:53:00 +02:00
|
|
|
|
|
|
|
|
|
[DisplayName("Scale"), CategoryAttribute("Pane")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public Vector2F Scale { get; set; }
|
2019-08-31 03:53:00 +02:00
|
|
|
|
|
|
|
|
|
[DisplayName("Width"), CategoryAttribute("Pane")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public float Width { get; set; }
|
2019-08-31 03:53:00 +02:00
|
|
|
|
|
2019-09-08 21:15:42 +02:00
|
|
|
|
[DisplayName("Height"), CategoryAttribute("Pane")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public float Height { get; set; }
|
|
|
|
|
|
2019-08-31 03:53:00 +02:00
|
|
|
|
[DisplayName("Origin X"), CategoryAttribute("Origin")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public virtual OriginX originX { get; set; }
|
2019-08-31 03:53:00 +02:00
|
|
|
|
|
|
|
|
|
[DisplayName("Origin X"), CategoryAttribute("Origin")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public virtual OriginY originY { get; set; }
|
2019-08-31 03:53:00 +02:00
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
[DisplayName("Parent Origin X"), CategoryAttribute("Origin")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public virtual OriginX ParentOriginX { get; set; }
|
2019-08-31 03:53:00 +02:00
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
[DisplayName("Parent Origin Y"), CategoryAttribute("Origin")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public virtual OriginY ParentOriginY { get; set; }
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[DisplayName("Alpha"), CategoryAttribute("Alpha")]
|
|
|
|
|
public byte Alpha { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Influence Alpha"), CategoryAttribute("Alpha")]
|
|
|
|
|
public virtual bool InfluenceAlpha { get; set; }
|
|
|
|
|
|
2019-08-31 03:53:00 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public BasePane Parent { get; set; }
|
|
|
|
|
|
2019-08-31 03:53:00 +02:00
|
|
|
|
[Browsable(false)]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public List<BasePane> Childern { get; set; } = new List<BasePane>();
|
|
|
|
|
|
2019-08-31 03:53:00 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
|
|
|
|
internal bool HasChildern
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
|
|
|
|
get { return Childern.Count > 0; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 22:41:58 +02:00
|
|
|
|
public OpenTK.Matrix4 GetRotationMatrix()
|
|
|
|
|
{
|
|
|
|
|
var paneRotate = GetRotation();
|
|
|
|
|
OpenTK.Matrix4 rotationX = OpenTK.Matrix4.CreateRotationX(OpenTK.MathHelper.DegreesToRadians(paneRotate.X));
|
|
|
|
|
OpenTK.Matrix4 rotationY = OpenTK.Matrix4.CreateRotationY(OpenTK.MathHelper.DegreesToRadians(paneRotate.Y));
|
|
|
|
|
OpenTK.Matrix4 rotationZ = OpenTK.Matrix4.CreateRotationZ(OpenTK.MathHelper.DegreesToRadians(paneRotate.Z));
|
|
|
|
|
var rotationMatrix = rotationX * rotationY * rotationZ;
|
|
|
|
|
|
|
|
|
|
if (Parent != null)
|
|
|
|
|
rotationMatrix = Parent.GetRotationMatrix() * rotationMatrix;
|
|
|
|
|
return rotationMatrix;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-19 23:36:16 +02:00
|
|
|
|
public Vector3F GetTranslation()
|
|
|
|
|
{
|
|
|
|
|
var posX = Translate.X;
|
|
|
|
|
var posY = Translate.Y;
|
|
|
|
|
var posZ = Translate.Z;
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.TranslateX))
|
|
|
|
|
posX = animController.PaneSRT[LPATarget.TranslateX];
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.TranslateY))
|
|
|
|
|
posY = animController.PaneSRT[LPATarget.TranslateY];
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.TranslateZ))
|
|
|
|
|
posZ = animController.PaneSRT[LPATarget.TranslateZ];
|
|
|
|
|
return new Vector3F(posX, posY, posZ);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector3F GetRotation()
|
|
|
|
|
{
|
|
|
|
|
var rotX = Rotate.X;
|
|
|
|
|
var rotY = Rotate.Y;
|
|
|
|
|
var rotZ = Rotate.Z;
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.RotateX))
|
|
|
|
|
rotX = animController.PaneSRT[LPATarget.RotateX];
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.RotateY))
|
|
|
|
|
rotY = animController.PaneSRT[LPATarget.RotateY];
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.RotateZ))
|
|
|
|
|
rotZ = animController.PaneSRT[LPATarget.RotateZ];
|
|
|
|
|
return new Vector3F(rotX, rotY, rotZ);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector2F GetScale()
|
|
|
|
|
{
|
|
|
|
|
var scaX = Scale.X;
|
|
|
|
|
var scaY = Scale.Y;
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.ScaleX))
|
|
|
|
|
scaX = animController.PaneSRT[LPATarget.ScaleX];
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.ScaleY))
|
|
|
|
|
scaY = animController.PaneSRT[LPATarget.ScaleY];
|
|
|
|
|
return new Vector2F(scaX, scaY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector2F GetSize()
|
|
|
|
|
{
|
|
|
|
|
var scaX = Width;
|
|
|
|
|
var scaY = Height;
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.SizeX))
|
|
|
|
|
scaX = animController.PaneSRT[LPATarget.SizeX];
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.SizeY))
|
|
|
|
|
scaY = animController.PaneSRT[LPATarget.SizeY];
|
|
|
|
|
return new Vector2F(scaX, scaY);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-31 00:53:45 +02:00
|
|
|
|
public BasePane()
|
|
|
|
|
{
|
|
|
|
|
originX = OriginX.Center;
|
|
|
|
|
originY = OriginY.Center;
|
|
|
|
|
ParentOriginX = OriginX.Center;
|
|
|
|
|
ParentOriginY = OriginY.Center;
|
|
|
|
|
}
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public virtual void LoadDefaults()
|
|
|
|
|
{
|
|
|
|
|
Alpha = 255;
|
|
|
|
|
Name = "";
|
|
|
|
|
Translate = new Vector3F(0, 0, 0);
|
|
|
|
|
Rotate = new Vector3F(0, 0, 0);
|
|
|
|
|
Scale = new Vector2F(1, 1);
|
|
|
|
|
Width = 30;
|
|
|
|
|
Height = 40;
|
|
|
|
|
|
|
|
|
|
originX = OriginX.Center;
|
|
|
|
|
originY = OriginY.Center;
|
|
|
|
|
ParentOriginX = OriginX.Center;
|
|
|
|
|
ParentOriginY = OriginY.Center;
|
|
|
|
|
InfluenceAlpha = false;
|
|
|
|
|
Visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 00:17:16 +02:00
|
|
|
|
public virtual BasePane Copy()
|
|
|
|
|
{
|
|
|
|
|
return new BasePane();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-19 02:59:49 +01:00
|
|
|
|
public object Clone()
|
2020-01-29 23:17:12 +01:00
|
|
|
|
{
|
|
|
|
|
BasePane copiedPane = (BasePane)this.MemberwiseClone();
|
|
|
|
|
if (copiedPane is IPicturePane)
|
|
|
|
|
((IPicturePane)copiedPane).CopyMaterial();
|
|
|
|
|
if (copiedPane is ITextPane)
|
|
|
|
|
((ITextPane)copiedPane).CopyMaterial();
|
|
|
|
|
if (copiedPane is IWindowPane)
|
|
|
|
|
((IWindowPane)copiedPane).CopyWindows();
|
|
|
|
|
return copiedPane;
|
2020-01-19 02:59:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public virtual UserData CreateUserData()
|
|
|
|
|
{
|
|
|
|
|
return new UserData();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 20:05:37 +02:00
|
|
|
|
public bool IsNullPane
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (this is IPicturePane)
|
|
|
|
|
return false;
|
|
|
|
|
else if (this is IWindowPane)
|
|
|
|
|
return false;
|
|
|
|
|
else if (this is ITextPane)
|
|
|
|
|
return false;
|
|
|
|
|
else if (this is IBoundryPane)
|
|
|
|
|
return false;
|
2019-10-06 17:18:53 +02:00
|
|
|
|
else if (this is IPartPane)
|
2019-10-05 20:05:37 +02:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-16 01:26:58 +02:00
|
|
|
|
public void ResetParentTransform(BasePane newParent)
|
|
|
|
|
{
|
|
|
|
|
//We need to get the difference in the parent transform and remove it to the current transform of this pane
|
2019-10-16 02:13:17 +02:00
|
|
|
|
var transform = GetParentTransform(Parent);
|
|
|
|
|
var newParentTransform = GetParentTransform(newParent);
|
|
|
|
|
Translate += transform;
|
|
|
|
|
Translate -= newParentTransform;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"newParentTransform {newParentTransform.X} {newParentTransform.Y} {newParentTransform.Z}");
|
|
|
|
|
Console.WriteLine($"transform {transform.X} {transform.Y} {transform.Z}");
|
2019-10-16 01:26:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-16 02:13:17 +02:00
|
|
|
|
private Vector3F GetParentTransform(BasePane parent) {
|
|
|
|
|
return GetParentTransform(parent.Translate);
|
2019-10-16 01:26:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Vector3F GetParentTransform(Vector3F translate)
|
|
|
|
|
{
|
|
|
|
|
if (Parent != null)
|
2019-10-16 02:13:17 +02:00
|
|
|
|
translate = Parent.Translate + Parent.GetParentTransform(translate);
|
|
|
|
|
|
|
|
|
|
return translate;
|
|
|
|
|
|
2019-10-16 01:26:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 23:48:52 +02:00
|
|
|
|
public void KeepChildrenTransform(float newTransX, float newTransY)
|
|
|
|
|
{
|
|
|
|
|
Vector2F distance = new Vector2F(newTransX - Translate.X, newTransY - Translate.Y);
|
2019-10-19 20:09:16 +02:00
|
|
|
|
KeepChildrenTransform(distance, newTransX, newTransY);
|
2019-10-15 23:48:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-19 20:09:16 +02:00
|
|
|
|
private void KeepChildrenTransform(Vector2F distance, float newTransX, float newTransY)
|
2019-10-15 23:48:52 +02:00
|
|
|
|
{
|
|
|
|
|
if (HasChildern)
|
|
|
|
|
{
|
|
|
|
|
foreach (var child in Childern)
|
|
|
|
|
{
|
|
|
|
|
child.Translate -= new Vector3F(distance.X, distance.Y, 0);
|
2019-10-19 20:09:16 +02:00
|
|
|
|
child.KeepChildrenTransform(child.Translate.X, child.Translate.Y);
|
2019-10-15 23:48:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
public CustomRectangle TransformParent(CustomRectangle rect)
|
|
|
|
|
{
|
2019-10-19 23:36:16 +02:00
|
|
|
|
return rect.GetTransformedRectangle(Parent, GetTranslation(),GetRotation(), GetScale());
|
2019-10-05 19:25:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 01:48:47 +02:00
|
|
|
|
private CustomRectangle rectangle;
|
2019-09-08 21:15:42 +02:00
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2020-02-15 00:25:08 +01:00
|
|
|
|
public virtual CustomRectangle Rectangle
|
2019-09-03 01:48:47 +02:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-09-07 01:12:39 +02:00
|
|
|
|
UpdateRectangle();
|
2019-09-03 01:48:47 +02:00
|
|
|
|
return rectangle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 01:56:41 +02:00
|
|
|
|
private void UpdateRectangle()
|
|
|
|
|
{
|
2019-09-03 01:48:47 +02:00
|
|
|
|
rectangle = CreateRectangle();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public CustomRectangle CreateRectangle(uint width, uint height)
|
|
|
|
|
{
|
|
|
|
|
//Do origin transforms
|
|
|
|
|
var transformed = TransformOrientation((int)width, (int)height, originX, originY);
|
|
|
|
|
var parentTransform = ParentOriginTransform(transformed);
|
|
|
|
|
|
|
|
|
|
return new CustomRectangle(
|
|
|
|
|
parentTransform.X,
|
|
|
|
|
parentTransform.Y,
|
|
|
|
|
parentTransform.Z,
|
|
|
|
|
parentTransform.W);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 23:48:52 +02:00
|
|
|
|
public void TransformRectangle(LayoutViewer.PickAction pickAction, CustomRectangle selectionBox, float pickMouseX, float pickMouseY)
|
2019-10-05 19:25:28 +02:00
|
|
|
|
{
|
2019-10-15 23:48:52 +02:00
|
|
|
|
CustomRectangle currentRectangle = this.CreateRectangle();
|
2019-10-19 23:36:16 +02:00
|
|
|
|
|
|
|
|
|
currentRectangle = currentRectangle.GetTransformedRectangle(Parent, GetTranslation(), GetRotation(), GetScale());
|
2019-10-15 23:48:52 +02:00
|
|
|
|
|
|
|
|
|
//The selection box can have mutlile panes selected in one box
|
|
|
|
|
//Scaling the edges will have different distances
|
|
|
|
|
float distanceLeft = selectionBox.LeftPoint - currentRectangle.LeftPoint;
|
|
|
|
|
float distanceRight = selectionBox.RightPoint - currentRectangle.RightPoint;
|
|
|
|
|
float distanceTop = selectionBox.TopPoint - currentRectangle.TopPoint;
|
|
|
|
|
float distanceBottom = selectionBox.BottomPoint - currentRectangle.BottomPoint;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("distanceLeft " + distanceLeft);
|
|
|
|
|
Console.WriteLine("distanceRight " + distanceRight);
|
|
|
|
|
Console.WriteLine("distanceTop " + distanceTop);
|
|
|
|
|
Console.WriteLine("distanceBottom " + distanceBottom);
|
|
|
|
|
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
float posX = Translate.X;
|
|
|
|
|
float posY = Translate.Y;
|
|
|
|
|
float posZ = Translate.Z;
|
|
|
|
|
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
float pickWidth = pickMouseX;
|
|
|
|
|
float pickHeight = pickMouseY;
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
switch (pickAction)
|
|
|
|
|
{
|
|
|
|
|
case LayoutViewer.PickAction.DragLeft:
|
|
|
|
|
Width += pickMouseX;
|
2019-10-14 03:02:39 +02:00
|
|
|
|
|
|
|
|
|
if (originX == OriginX.Left)
|
|
|
|
|
posX = Translate.X - pickMouseX;
|
|
|
|
|
else if (originX == OriginX.Right)
|
|
|
|
|
posX = Translate.X + pickMouseX;
|
|
|
|
|
else
|
|
|
|
|
posX = Translate.X - (pickMouseX / 2);
|
2019-10-05 19:25:28 +02:00
|
|
|
|
break;
|
|
|
|
|
case LayoutViewer.PickAction.DragRight:
|
2019-10-14 03:02:39 +02:00
|
|
|
|
|
|
|
|
|
if (originX == OriginX.Right)
|
|
|
|
|
{
|
|
|
|
|
Width -= pickMouseX;
|
|
|
|
|
posX = Translate.X + pickMouseX;
|
|
|
|
|
}
|
|
|
|
|
else if (originX == OriginX.Left)
|
|
|
|
|
{
|
|
|
|
|
Width -= pickMouseX;
|
|
|
|
|
posX = Translate.X + pickMouseX;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Width -= pickMouseX;
|
|
|
|
|
posX = Translate.X - (pickMouseX / 2);
|
|
|
|
|
}
|
2019-10-05 19:25:28 +02:00
|
|
|
|
break;
|
|
|
|
|
case LayoutViewer.PickAction.DragTop:
|
2019-10-14 03:02:39 +02:00
|
|
|
|
if (originY == OriginY.Top)
|
|
|
|
|
{
|
|
|
|
|
Height -= pickMouseY;
|
|
|
|
|
posY = Translate.Y - pickMouseY;
|
|
|
|
|
}
|
|
|
|
|
else if (originY == OriginY.Bottom)
|
|
|
|
|
{
|
|
|
|
|
Height -= pickMouseY;
|
|
|
|
|
posY = Translate.Y - pickMouseY;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Height -= pickMouseY;
|
|
|
|
|
posY = Translate.Y - (pickMouseY / 2);
|
|
|
|
|
}
|
2019-10-05 19:25:28 +02:00
|
|
|
|
break;
|
|
|
|
|
case LayoutViewer.PickAction.DragBottom:
|
|
|
|
|
Height += pickMouseY;
|
|
|
|
|
posY = Translate.Y - (pickMouseY / 2);
|
|
|
|
|
break;
|
|
|
|
|
case LayoutViewer.PickAction.DragTopLeft:
|
|
|
|
|
Width += pickMouseX;
|
|
|
|
|
Height -= pickMouseY;
|
|
|
|
|
posX = Translate.X - (pickMouseX / 2);
|
|
|
|
|
posY = Translate.Y - (pickMouseY / 2);
|
|
|
|
|
break;
|
|
|
|
|
case LayoutViewer.PickAction.DragBottomLeft:
|
|
|
|
|
Width += pickMouseX;
|
|
|
|
|
Height += pickMouseY;
|
|
|
|
|
posX = Translate.X - (pickMouseX / 2);
|
|
|
|
|
posY = Translate.Y - (pickMouseY / 2);
|
|
|
|
|
break;
|
|
|
|
|
case LayoutViewer.PickAction.DragBottomRight:
|
|
|
|
|
Width -= pickMouseX;
|
|
|
|
|
Height += pickMouseY;
|
|
|
|
|
posX = Translate.X - (pickMouseX / 2);
|
|
|
|
|
posY = Translate.Y - (pickMouseY / 2);
|
|
|
|
|
break;
|
|
|
|
|
case LayoutViewer.PickAction.DragTopRight:
|
|
|
|
|
Width -= pickMouseX;
|
|
|
|
|
Height -= pickMouseY;
|
|
|
|
|
posX = Translate.X - (pickMouseX / 2);
|
|
|
|
|
posY = Translate.Y - (pickMouseY / 2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-19 20:09:16 +02:00
|
|
|
|
if (!Runtime.LayoutEditor.TransformChidlren)
|
|
|
|
|
KeepChildrenTransform(posX, posY);
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
Translate = new Vector3F(posX, posY, posZ);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
private Vector2F SetOrientation(float pickWidth, float pickHeight)
|
|
|
|
|
{
|
|
|
|
|
float posX = 0;
|
|
|
|
|
float posY = 0;
|
|
|
|
|
switch (originX)
|
|
|
|
|
{
|
|
|
|
|
case OriginX.Left:
|
|
|
|
|
Width += pickWidth;
|
|
|
|
|
posX = pickWidth;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Width += pickWidth;
|
|
|
|
|
posX = pickWidth / 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
switch (originY)
|
|
|
|
|
{
|
|
|
|
|
case OriginY.Top:
|
|
|
|
|
Height += pickHeight;
|
|
|
|
|
posY = pickHeight;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Height += pickHeight;
|
|
|
|
|
posY = pickHeight / 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return new Vector2F(posX, posY);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public CustomRectangle CreateRectangle()
|
|
|
|
|
{
|
|
|
|
|
//Do origin transforms
|
2019-09-28 23:27:48 +02:00
|
|
|
|
var transformed = new Vector4();
|
|
|
|
|
int paneWidth = (int)Width;
|
|
|
|
|
int paneHeight = (int)Height;
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.SizeX))
|
|
|
|
|
paneWidth = (int)animController.PaneSRT[LPATarget.SizeX];
|
|
|
|
|
if (animController.PaneSRT.ContainsKey(LPATarget.SizeY))
|
|
|
|
|
paneHeight = (int)animController.PaneSRT[LPATarget.SizeY];
|
|
|
|
|
|
|
|
|
|
transformed = TransformOrientation(paneWidth, paneHeight, originX, originY);
|
2019-09-07 01:12:39 +02:00
|
|
|
|
var parentTransform = ParentOriginTransform(transformed);
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
return new CustomRectangle(
|
|
|
|
|
parentTransform.X,
|
|
|
|
|
parentTransform.Y,
|
|
|
|
|
parentTransform.Z,
|
|
|
|
|
parentTransform.W);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-20 00:02:10 +02:00
|
|
|
|
public static float MixColors(params float[] c)
|
|
|
|
|
{
|
|
|
|
|
float a = c[0];
|
|
|
|
|
for (int i = 1; i < c.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
a *= c[i];
|
|
|
|
|
}
|
|
|
|
|
for (int i = 1; i < c.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
a /= 255f;
|
|
|
|
|
}
|
|
|
|
|
return a / 255f;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
//Get the previous transform from the parent origin
|
|
|
|
|
private Vector4 ParentOriginTransform(Vector4 points)
|
|
|
|
|
{
|
|
|
|
|
//Dont shift the root or the first child of the root
|
|
|
|
|
//The parent setting shouldn't be set, but it doesn't hurt to do this
|
|
|
|
|
if (IsRoot || ParentIsRoot || Parent == null)
|
|
|
|
|
return points;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
var transformedPosition = TransformOrientationPosition((int)Parent.Width, (int)Parent.Height, ParentOriginX, ParentOriginY);
|
|
|
|
|
var transformed = ShiftRectangle(transformedPosition, points);
|
|
|
|
|
if (Parent != null)
|
|
|
|
|
return Parent.ParentOriginTransform(transformed);
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
return transformed;
|
|
|
|
|
}
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
private static Vector4 ShiftRectangle(Vector2 position, Vector4 points)
|
|
|
|
|
{
|
|
|
|
|
int left = points[0] + position.X;
|
|
|
|
|
int right = points[1] + position.X;
|
|
|
|
|
int top = points[2] + position.Y;
|
|
|
|
|
int bottom = points[3] + position.Y;
|
|
|
|
|
return new Vector4(left, right, top, bottom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Vector2 TransformOrientationPosition(int Width, int Height, OriginX originX, OriginY originY)
|
|
|
|
|
{
|
|
|
|
|
int x = 0;
|
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
|
|
if (originX == OriginX.Left)
|
|
|
|
|
x = -(Width / 2);
|
|
|
|
|
else if (originX == OriginX.Right)
|
|
|
|
|
x = (Width / 2);
|
|
|
|
|
|
|
|
|
|
if (originY == OriginY.Top)
|
|
|
|
|
y = Height / 2;
|
|
|
|
|
else if (originY == OriginY.Bottom)
|
|
|
|
|
y = -(Height / 2);
|
|
|
|
|
|
2019-09-17 01:56:41 +02:00
|
|
|
|
return new Vector2(x, y);
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-07 01:12:39 +02:00
|
|
|
|
private static Vector4 TransformOrientation(int Width, int Height, OriginX originX, OriginY originY)
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
|
|
|
|
int left = 0;
|
|
|
|
|
int right = 0;
|
|
|
|
|
int top = 0;
|
|
|
|
|
int bottom = 0;
|
|
|
|
|
|
|
|
|
|
if (originX == OriginX.Left)
|
|
|
|
|
right = Width;
|
|
|
|
|
else if (originX == OriginX.Right)
|
|
|
|
|
left = -Width;
|
|
|
|
|
else //To center
|
|
|
|
|
{
|
|
|
|
|
left = -Width / 2;
|
|
|
|
|
right = Width / 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (originY == OriginY.Top)
|
2019-09-08 21:15:42 +02:00
|
|
|
|
bottom = -Height;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
else if (originY == OriginY.Bottom)
|
2019-09-08 21:15:42 +02:00
|
|
|
|
top = Height;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
else //To center
|
|
|
|
|
{
|
2019-09-10 00:37:33 +02:00
|
|
|
|
top = Height / 2;
|
|
|
|
|
bottom = -Height / 2;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Vector4(left, right, top, bottom);
|
|
|
|
|
}
|
2019-09-03 01:48:47 +02:00
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public bool IsHit(CustomRectangle selectionBox)
|
|
|
|
|
{
|
|
|
|
|
var rect = CreateRectangle();
|
2019-10-19 23:36:16 +02:00
|
|
|
|
var transformed = rect.GetTransformedRectangle(Parent, GetTranslation(), GetRotation(), GetScale());
|
2019-10-14 03:02:39 +02:00
|
|
|
|
|
|
|
|
|
if ((selectionBox.LeftPoint < transformed.RightPoint) &&
|
|
|
|
|
(selectionBox.RightPoint > transformed.LeftPoint) &&
|
|
|
|
|
(selectionBox.TopPoint > transformed.BottomPoint) &&
|
|
|
|
|
(selectionBox.BottomPoint < transformed.TopPoint))
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 01:48:47 +02:00
|
|
|
|
public bool IsHit(int X, int Y)
|
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
var rect = CreateRectangle();
|
2019-10-19 23:36:16 +02:00
|
|
|
|
var transformed = rect.GetTransformedRectangle(Parent, GetTranslation(), GetRotation(), GetScale());
|
2019-10-06 03:15:19 +02:00
|
|
|
|
|
|
|
|
|
bool isInBetweenX = (X > transformed.LeftPoint) && (X < transformed.RightPoint) ||
|
|
|
|
|
(X < transformed.LeftPoint) && (X > transformed.RightPoint);
|
|
|
|
|
|
|
|
|
|
bool isInBetweenY = (Y > transformed.BottomPoint) && (Y < transformed.TopPoint) ||
|
|
|
|
|
(Y < transformed.BottomPoint) && (Y > transformed.TopPoint);
|
2019-10-05 19:25:28 +02:00
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
if (isInBetweenX && isInBetweenY)
|
2019-09-03 01:48:47 +02:00
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
public BasePane SearchPane(string name)
|
|
|
|
|
{
|
|
|
|
|
if (Name == name)
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
|
|
foreach (var child in Childern)
|
|
|
|
|
{
|
|
|
|
|
var matchPane = child.SearchPane(name);
|
|
|
|
|
if (matchPane != null) return matchPane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class VertexColorHelper
|
|
|
|
|
{
|
|
|
|
|
public static System.Drawing.Color Mix(System.Drawing.Color colorA, System.Drawing.Color colorB, float value)
|
|
|
|
|
{
|
|
|
|
|
byte R = (byte)InterpolationHelper.Lerp(colorA.R, colorB.R, value);
|
|
|
|
|
byte G = (byte)InterpolationHelper.Lerp(colorA.G, colorB.G, value);
|
|
|
|
|
byte B = (byte)InterpolationHelper.Lerp(colorA.B, colorB.B, value);
|
|
|
|
|
byte A = (byte)InterpolationHelper.Lerp(colorA.A, colorB.A, value);
|
|
|
|
|
return System.Drawing.Color.FromArgb(A, R, G, B);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class PaneAnimController
|
|
|
|
|
{
|
|
|
|
|
public Dictionary<LPATarget, float> PaneSRT = new Dictionary<LPATarget, float>();
|
|
|
|
|
public Dictionary<LVCTarget, float> PaneVertexColors = new Dictionary<LVCTarget, float>();
|
|
|
|
|
public bool Visibile = true;
|
|
|
|
|
|
|
|
|
|
public void ResetAnim()
|
|
|
|
|
{
|
|
|
|
|
Visibile = true;
|
|
|
|
|
PaneSRT.Clear();
|
|
|
|
|
PaneVertexColors.Clear();
|
|
|
|
|
}
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 22:30:10 +01:00
|
|
|
|
public enum TexGenMatrixType : byte
|
|
|
|
|
{
|
|
|
|
|
Matrix2x4 = 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum TexGenType : byte
|
|
|
|
|
{
|
|
|
|
|
TextureCoord0 = 0,
|
|
|
|
|
TextureCoord1 = 1,
|
|
|
|
|
TextureCoord2 = 2,
|
|
|
|
|
OrthographicProjection = 3,
|
|
|
|
|
PaneBasedProjection = 4,
|
|
|
|
|
PerspectiveProjection = 5
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum PartPaneScaling
|
|
|
|
|
{
|
|
|
|
|
Scaling = 0,
|
|
|
|
|
Ignore = 1,
|
|
|
|
|
FitBoundries = 2,
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-09 02:47:19 +02:00
|
|
|
|
public enum FilterMode
|
|
|
|
|
{
|
|
|
|
|
Near = 0,
|
|
|
|
|
Linear = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum WrapMode
|
|
|
|
|
{
|
|
|
|
|
Clamp = 0,
|
|
|
|
|
Repeat = 1,
|
|
|
|
|
Mirror = 2
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public enum OriginX : byte
|
|
|
|
|
{
|
|
|
|
|
Center = 0,
|
|
|
|
|
Left = 1,
|
|
|
|
|
Right = 2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public enum OriginY : byte
|
|
|
|
|
{
|
|
|
|
|
Center = 0,
|
|
|
|
|
Top = 1,
|
|
|
|
|
Bottom = 2
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-04 00:58:58 +02:00
|
|
|
|
public interface IUserDataContainer
|
|
|
|
|
{
|
|
|
|
|
UserData UserData { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-09 02:47:19 +02:00
|
|
|
|
public class BxlytTextureRef
|
|
|
|
|
{
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public short ID { get; set; }
|
|
|
|
|
|
2019-09-09 02:47:19 +02:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual WrapMode WrapModeU { get; set; }
|
|
|
|
|
public virtual WrapMode WrapModeV { get; set; }
|
2020-02-15 22:30:10 +01:00
|
|
|
|
public virtual FilterMode MinFilterMode { get; set; } = FilterMode.Linear;
|
|
|
|
|
public virtual FilterMode MaxFilterMode { get; set; } = FilterMode.Linear;
|
2019-09-09 02:47:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public class BxlytAlphaCompare
|
|
|
|
|
{
|
|
|
|
|
public GfxAlphaFunction CompareMode { get; set; }
|
|
|
|
|
public float Value { get; set; }
|
|
|
|
|
|
|
|
|
|
public BxlytAlphaCompare()
|
|
|
|
|
{
|
|
|
|
|
CompareMode = GfxAlphaFunction.Always;
|
|
|
|
|
Value = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BxlytAlphaCompare(FileReader reader, BxlytHeader header)
|
|
|
|
|
{
|
|
|
|
|
CompareMode = reader.ReadEnum<GfxAlphaFunction>(false);
|
|
|
|
|
reader.ReadBytes(0x3);
|
|
|
|
|
Value = reader.ReadSingle();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public virtual void Write(FileWriter writer)
|
2019-10-14 03:02:39 +02:00
|
|
|
|
{
|
|
|
|
|
writer.Write(CompareMode, false);
|
|
|
|
|
writer.Seek(3);
|
|
|
|
|
writer.Write(Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlytBlendMode
|
|
|
|
|
{
|
|
|
|
|
public GX2BlendOp BlendOp { get; set; }
|
|
|
|
|
public GX2BlendFactor SourceFactor { get; set; }
|
|
|
|
|
public GX2BlendFactor DestFactor { get; set; }
|
|
|
|
|
public GX2LogicOp LogicOp { get; set; }
|
|
|
|
|
|
|
|
|
|
public BxlytBlendMode()
|
|
|
|
|
{
|
|
|
|
|
BlendOp = GX2BlendOp.Add;
|
|
|
|
|
SourceFactor = GX2BlendFactor.SourceAlpha;
|
|
|
|
|
DestFactor = GX2BlendFactor.SourceInvAlpha;
|
2020-02-12 01:19:23 +01:00
|
|
|
|
LogicOp = GX2LogicOp.Set;
|
2019-10-14 03:02:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 03:14:53 +01:00
|
|
|
|
public bool HasDefaults()
|
|
|
|
|
{
|
|
|
|
|
return BlendOp == GX2BlendOp.Add &&
|
|
|
|
|
SourceFactor == GX2BlendFactor.SourceAlpha &&
|
|
|
|
|
DestFactor == GX2BlendFactor.SourceInvAlpha &&
|
|
|
|
|
LogicOp == GX2LogicOp.Set;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public BxlytBlendMode(FileReader reader, BxlytHeader header)
|
|
|
|
|
{
|
|
|
|
|
BlendOp = (GX2BlendOp)reader.ReadByte();
|
|
|
|
|
SourceFactor = (GX2BlendFactor)reader.ReadByte();
|
|
|
|
|
DestFactor = (GX2BlendFactor)reader.ReadByte();
|
|
|
|
|
LogicOp = (GX2LogicOp)reader.ReadByte();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write(FileWriter writer)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(BlendOp, false);
|
|
|
|
|
writer.Write(SourceFactor, false);
|
|
|
|
|
writer.Write(DestFactor, false);
|
|
|
|
|
writer.Write(LogicOp, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum GX2BlendFactor : byte
|
|
|
|
|
{
|
|
|
|
|
Factor0 = 0,
|
|
|
|
|
Factor1 = 1,
|
|
|
|
|
DestColor = 2,
|
|
|
|
|
DestInvColor = 3,
|
|
|
|
|
SourceAlpha = 4,
|
|
|
|
|
SourceInvAlpha = 5,
|
|
|
|
|
DestAlpha = 6,
|
|
|
|
|
DestInvAlpha = 7,
|
|
|
|
|
SourceColor = 8,
|
|
|
|
|
SourceInvColor = 9
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum GX2BlendOp : byte
|
|
|
|
|
{
|
|
|
|
|
Disable = 0,
|
|
|
|
|
Add = 1,
|
|
|
|
|
Subtract = 2,
|
|
|
|
|
ReverseSubtract = 3,
|
|
|
|
|
SelectMin = 4,
|
|
|
|
|
SelectMax = 5
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum GX2LogicOp : byte
|
|
|
|
|
{
|
|
|
|
|
Disable = 0,
|
|
|
|
|
NoOp = 1,
|
|
|
|
|
Clear = 2,
|
|
|
|
|
Set = 3,
|
|
|
|
|
Copy = 4,
|
|
|
|
|
InvCopy = 5,
|
|
|
|
|
Inv = 6,
|
|
|
|
|
And = 7,
|
|
|
|
|
Nand = 8,
|
|
|
|
|
Or = 9,
|
|
|
|
|
Nor = 10,
|
|
|
|
|
Xor = 11,
|
|
|
|
|
Equiv = 12,
|
|
|
|
|
RevAnd = 13,
|
|
|
|
|
InvAd = 14,
|
|
|
|
|
RevOr = 15,
|
|
|
|
|
InvOr = 16
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 00:58:58 +02:00
|
|
|
|
public class UserData : SectionCommon
|
|
|
|
|
{
|
|
|
|
|
public List<UserDataEntry> Entries { get; set; }
|
|
|
|
|
|
|
|
|
|
public UserData()
|
|
|
|
|
{
|
|
|
|
|
Entries = new List<UserDataEntry>();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 17:18:18 +01:00
|
|
|
|
public virtual UserDataEntry CreateUserData() {
|
|
|
|
|
return new UserDataEntry();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
public override void Write(FileWriter writer, LayoutHeader header)
|
2019-09-04 00:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UserDataEntry
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public UserDataType Type { get; set; }
|
|
|
|
|
public byte Unknown { get; set; }
|
|
|
|
|
|
|
|
|
|
public object data;
|
|
|
|
|
|
|
|
|
|
public string GetString()
|
|
|
|
|
{
|
|
|
|
|
return (string)data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float[] GetFloats()
|
|
|
|
|
{
|
|
|
|
|
return (float[])data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int[] GetInts()
|
|
|
|
|
{
|
|
|
|
|
return (int[])data;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 02:16:13 +01:00
|
|
|
|
public byte[] GetBytes()
|
|
|
|
|
{
|
|
|
|
|
return (byte[])data;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 01:23:04 +02:00
|
|
|
|
public void SetValue(string value)
|
2019-09-04 00:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
data = value;
|
|
|
|
|
Type = UserDataType.String;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetValue(float[] value)
|
|
|
|
|
{
|
|
|
|
|
data = value;
|
|
|
|
|
Type = UserDataType.Float;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetValue(int[] value)
|
|
|
|
|
{
|
|
|
|
|
data = value;
|
|
|
|
|
Type = UserDataType.Int;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 02:16:13 +01:00
|
|
|
|
public void SetValue(List<UserDataStruct> value)
|
|
|
|
|
{
|
|
|
|
|
data = value;
|
|
|
|
|
Type = UserDataType.StructData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<UserDataStruct> GetStructs()
|
|
|
|
|
{
|
|
|
|
|
return (List<UserDataStruct>)data;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 00:58:58 +02:00
|
|
|
|
internal long _pos;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 02:16:13 +01:00
|
|
|
|
public class UserDataStruct
|
|
|
|
|
{
|
|
|
|
|
public ushort Unknown { get; set; } // 0
|
|
|
|
|
|
|
|
|
|
public List<UserDataStructEntry> Entries = new List<UserDataStructEntry>();
|
|
|
|
|
|
|
|
|
|
public UserDataStruct(FileReader reader, BxlytHeader header)
|
|
|
|
|
{
|
|
|
|
|
long pos = reader.Position;
|
|
|
|
|
|
|
|
|
|
ushort unknown = reader.ReadUInt16();
|
|
|
|
|
ushort numEntries = reader.ReadUInt16();
|
|
|
|
|
uint[] offsets = reader.ReadUInt32s(numEntries);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numEntries; i++)
|
|
|
|
|
{
|
|
|
|
|
reader.SeekBegin(pos + offsets[i]);
|
|
|
|
|
Entries.Add(new UserDataStructEntry(reader, header));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write(FileWriter writer, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
long pos = writer.Position;
|
|
|
|
|
|
|
|
|
|
writer.Write(Unknown);
|
|
|
|
|
writer.Write((ushort)Entries.Count);
|
|
|
|
|
|
|
|
|
|
long _ofsPos = writer.Position;
|
|
|
|
|
//Fill empty spaces for offsets later
|
|
|
|
|
writer.Write(new uint[Entries.Count]);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Entries.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
|
|
|
|
|
Entries[i].Write(writer, header);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UserDataStructEntry
|
|
|
|
|
{
|
|
|
|
|
public uint DataType { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<object> Data { get; set; }
|
|
|
|
|
|
|
|
|
|
public UserDataStructEntry(FileReader reader, BxlytHeader header)
|
|
|
|
|
{
|
|
|
|
|
long pos = reader.Position;
|
|
|
|
|
|
|
|
|
|
DataType = reader.ReadUInt32();
|
|
|
|
|
Console.WriteLine($"USD1 Struct DataType " + DataType);
|
2020-01-15 02:26:51 +01:00
|
|
|
|
if (DataType == 0)
|
2019-12-08 02:16:13 +01:00
|
|
|
|
{
|
2020-01-15 02:26:51 +01:00
|
|
|
|
uint numEntries = reader.ReadUInt32();
|
|
|
|
|
uint[] offsets = reader.ReadUInt32s((int)numEntries);
|
|
|
|
|
|
|
|
|
|
Data = new List<object>();
|
|
|
|
|
for (int i = 0; i < numEntries; i++)
|
2019-12-08 02:16:13 +01:00
|
|
|
|
{
|
2020-01-15 02:26:51 +01:00
|
|
|
|
reader.SeekBegin(pos + offsets[i]);
|
|
|
|
|
switch (DataType)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
string str = reader.ReadZeroTerminatedString();
|
|
|
|
|
Console.WriteLine($"USD1 str " + str);
|
|
|
|
|
Data.Add(str);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-12-08 02:16:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write(FileWriter writer, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
long pos = writer.Position;
|
|
|
|
|
|
|
|
|
|
writer.Write(DataType);
|
2020-01-15 02:26:51 +01:00
|
|
|
|
switch (DataType)
|
2019-12-08 02:16:13 +01:00
|
|
|
|
{
|
2020-01-15 02:26:51 +01:00
|
|
|
|
case 0:
|
|
|
|
|
writer.Write(Data.Count);
|
|
|
|
|
long _ofsPos = writer.Position;
|
|
|
|
|
//Fill empty spaces for offsets later
|
|
|
|
|
writer.Write(new uint[Data.Count]);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Data.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
|
2019-12-08 02:16:13 +01:00
|
|
|
|
writer.WriteString((string)Data[i]);
|
|
|
|
|
|
2020-01-15 02:26:51 +01:00
|
|
|
|
if (i == Data.Count - 1)
|
|
|
|
|
writer.Align(64);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2019-12-08 02:16:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 00:58:58 +02:00
|
|
|
|
public enum UserDataType : byte
|
|
|
|
|
{
|
|
|
|
|
String,
|
|
|
|
|
Int,
|
|
|
|
|
Float,
|
2019-12-08 02:16:13 +01:00
|
|
|
|
StructData,
|
2019-09-04 00:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
public enum AnimationTarget : byte
|
|
|
|
|
{
|
|
|
|
|
Pane = 0,
|
|
|
|
|
Material = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LPATarget : byte
|
|
|
|
|
{
|
|
|
|
|
TranslateX = 0x00,
|
|
|
|
|
TranslateY = 0x01,
|
|
|
|
|
TranslateZ = 0x02,
|
|
|
|
|
RotateX = 0x03,
|
|
|
|
|
RotateY = 0x04,
|
|
|
|
|
RotateZ = 0x05,
|
|
|
|
|
ScaleX = 0x06,
|
|
|
|
|
ScaleY = 0x07,
|
|
|
|
|
SizeX = 0x08,
|
2019-09-28 23:27:48 +02:00
|
|
|
|
SizeY = 0x09,
|
2019-09-10 00:37:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LTSTarget : byte
|
|
|
|
|
{
|
|
|
|
|
TranslateS = 0x00,
|
|
|
|
|
TranslateT = 0x01,
|
|
|
|
|
Rotate = 0x02,
|
|
|
|
|
ScaleS = 0x03,
|
|
|
|
|
ScaleT = 0x04,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LVITarget : byte
|
|
|
|
|
{
|
|
|
|
|
Visibility = 0x00,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LVCTarget : byte
|
|
|
|
|
{
|
|
|
|
|
LeftTopRed = 0x00,
|
|
|
|
|
LeftTopGreen = 0x01,
|
|
|
|
|
LeftTopBlue = 0x02,
|
|
|
|
|
LeftTopAlpha = 0x03,
|
|
|
|
|
|
|
|
|
|
RightTopRed = 0x04,
|
|
|
|
|
RightTopGreen = 0x05,
|
|
|
|
|
RightTopBlue = 0x06,
|
|
|
|
|
RightTopAlpha = 0x07,
|
|
|
|
|
|
|
|
|
|
LeftBottomRed = 0x08,
|
|
|
|
|
LeftBottomGreen = 0x09,
|
|
|
|
|
LeftBottomBlue = 0x0A,
|
|
|
|
|
LeftBottomAlpha = 0x0B,
|
|
|
|
|
|
|
|
|
|
RightBottomRed = 0x0C,
|
|
|
|
|
RightBottomGreen = 0x0D,
|
|
|
|
|
RightBottomBlue = 0x0E,
|
|
|
|
|
RightBottomAlpha = 0x0F,
|
|
|
|
|
|
|
|
|
|
PaneAlpha = 0x10,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LTPTarget : byte
|
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
Image1 = 0x00,
|
|
|
|
|
Image2 = 0x01, //Unsure if mutliple are used but just in case
|
|
|
|
|
Image3 = 0x02,
|
2019-09-10 00:37:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public enum RevLMCTarget : byte
|
|
|
|
|
{
|
|
|
|
|
MatColorRed,
|
|
|
|
|
MatColorGreen,
|
|
|
|
|
MatColorBlue,
|
|
|
|
|
MatColorAlpha,
|
|
|
|
|
BlackColorRed,
|
|
|
|
|
BlackColorGreen,
|
|
|
|
|
BlackColorBlue,
|
|
|
|
|
BlackColorAlpha,
|
|
|
|
|
WhiteColorRed,
|
|
|
|
|
WhiteColorGreen,
|
|
|
|
|
WhiteColorBlue,
|
|
|
|
|
WhiteColorAlpha,
|
|
|
|
|
ColorReg3Red,
|
|
|
|
|
ColorReg3Green,
|
|
|
|
|
ColorReg3Blue,
|
|
|
|
|
ColorReg3Alpha,
|
|
|
|
|
TevColor1Red,
|
|
|
|
|
TevColor1Green,
|
|
|
|
|
TevColor1Blue,
|
|
|
|
|
TevColor1Alpha,
|
|
|
|
|
TevColor2Red,
|
|
|
|
|
TevColor2Green,
|
|
|
|
|
TevColor2Blue,
|
|
|
|
|
TevColor2Alpha,
|
|
|
|
|
TevColor3Red,
|
|
|
|
|
TevColor3Green,
|
|
|
|
|
TevColor3Blue,
|
|
|
|
|
TevColor3Alpha,
|
|
|
|
|
TevColor4Red,
|
|
|
|
|
TevColor4Green,
|
|
|
|
|
TevColor4Blue,
|
|
|
|
|
TevColor4Alpha,
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
public enum LMCTarget : byte
|
|
|
|
|
{
|
2019-09-13 00:52:47 +02:00
|
|
|
|
BlackColorRed,
|
|
|
|
|
BlackColorGreen,
|
|
|
|
|
BlackColorBlue,
|
|
|
|
|
BlackColorAlpha,
|
|
|
|
|
WhiteColorRed,
|
|
|
|
|
WhiteColorGreen,
|
|
|
|
|
WhiteColorBlue,
|
|
|
|
|
WhiteColorAlpha,
|
2019-09-24 00:16:50 +02:00
|
|
|
|
TextureColorBlendRatio,
|
|
|
|
|
TexColor0Red,
|
|
|
|
|
TexColor0Green,
|
|
|
|
|
TexColor0Blue,
|
|
|
|
|
TexColor0Alpha,
|
|
|
|
|
TexColor1Red,
|
|
|
|
|
TexColor1Green,
|
|
|
|
|
TexColor1Blue,
|
|
|
|
|
TexColor1Alpha,
|
|
|
|
|
TexColor2Red,
|
|
|
|
|
TexColor2Green,
|
|
|
|
|
TexColor2Blue,
|
|
|
|
|
TexColor2Alpha,
|
|
|
|
|
TevKonstantColor0Red,
|
|
|
|
|
TevKonstantColor0Green,
|
|
|
|
|
TevKonstantColor0Blue,
|
|
|
|
|
TevKonstantColor0Alpha,
|
|
|
|
|
TevKonstantColor1Red,
|
|
|
|
|
TevKonstantColor1Green,
|
|
|
|
|
TevKonstantColor1Blue,
|
|
|
|
|
TevKonstantColor1Alpha,
|
|
|
|
|
TevKonstantColor2Red,
|
|
|
|
|
TevKonstantColor2Green,
|
|
|
|
|
TevKonstantColor2Blue,
|
|
|
|
|
TevKonstantColor2Alpha,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LIMTarget : byte
|
|
|
|
|
{
|
|
|
|
|
Rotation,
|
|
|
|
|
ScaleU,
|
|
|
|
|
ScaleV,
|
2019-09-13 00:52:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LFSTarget : byte
|
|
|
|
|
{
|
|
|
|
|
FontShadowBlackColorRed,
|
|
|
|
|
FontShadowBlackColorGreen,
|
|
|
|
|
FontShadowBlackColorBlue,
|
|
|
|
|
FontShadowBlackColorAlpha,
|
|
|
|
|
FontShadowWhiteColorRed,
|
|
|
|
|
FontShadowWhiteColorGreen,
|
|
|
|
|
FontShadowWhiteColorBlue,
|
|
|
|
|
FontShadowWhiteColorAlpha,
|
|
|
|
|
}
|
2019-09-10 00:37:33 +02:00
|
|
|
|
|
2019-09-13 00:52:47 +02:00
|
|
|
|
public enum LCTTarget : byte
|
|
|
|
|
{
|
|
|
|
|
FontShadowBlackColorRed,
|
|
|
|
|
FontShadowBlackColorGreen,
|
|
|
|
|
FontShadowBlackColorBlue,
|
|
|
|
|
FontShadowBlackColorAlpha,
|
|
|
|
|
FontShadowWhiteColorRed,
|
|
|
|
|
FontShadowWhiteColorGreen,
|
|
|
|
|
FontShadowWhiteColorBlue,
|
|
|
|
|
FontShadowWhiteColorAlpha,
|
2019-09-10 00:37:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public enum WindowKind
|
|
|
|
|
{
|
|
|
|
|
Around = 0,
|
|
|
|
|
Horizontal = 1,
|
|
|
|
|
HorizontalNoContent = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum WindowFrameTexFlip : byte
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
FlipH = 1,
|
|
|
|
|
FlipV = 2,
|
|
|
|
|
Rotate90 = 3,
|
|
|
|
|
Rotate180 = 4,
|
|
|
|
|
Rotate270 = 5
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public enum GfxAlphaFunction : byte
|
|
|
|
|
{
|
|
|
|
|
Never = 0,
|
|
|
|
|
Less = 1,
|
|
|
|
|
LessOrEqual = 2,
|
|
|
|
|
Equal = 3,
|
|
|
|
|
NotEqual = 4,
|
|
|
|
|
GreaterOrEqual = 5,
|
|
|
|
|
Greater = 6,
|
|
|
|
|
Always = 7,
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public enum GfxAlphaOp : byte
|
|
|
|
|
{
|
|
|
|
|
And = 0,
|
|
|
|
|
Or = 1,
|
|
|
|
|
Xor = 2,
|
|
|
|
|
Nor = 3,
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-20 00:02:10 +02:00
|
|
|
|
public enum TevMode : byte
|
|
|
|
|
{
|
|
|
|
|
Replace,
|
|
|
|
|
Modulate,
|
|
|
|
|
Add,
|
|
|
|
|
AddSigned,
|
|
|
|
|
Interpolate,
|
|
|
|
|
Subtract,
|
|
|
|
|
AddMultiplicate,
|
|
|
|
|
MultiplcateAdd,
|
|
|
|
|
Overlay,
|
|
|
|
|
Indirect,
|
|
|
|
|
BlendIndirect,
|
|
|
|
|
EachIndirect,
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
2019-10-17 00:17:16 +02:00
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public enum TevScale
|
|
|
|
|
{
|
|
|
|
|
Scale1,
|
|
|
|
|
Scale2,
|
|
|
|
|
Scale4
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum TevSource
|
|
|
|
|
{
|
|
|
|
|
Tex0 = 0,
|
|
|
|
|
Tex1 = 1,
|
|
|
|
|
Tex2 = 2,
|
|
|
|
|
Tex3 = 3,
|
|
|
|
|
Constant = 4,
|
|
|
|
|
Primary = 5,
|
|
|
|
|
Previous = 6,
|
|
|
|
|
Register = 7
|
|
|
|
|
}
|
|
|
|
|
public enum TevColorOp
|
|
|
|
|
{
|
|
|
|
|
RGB = 0,
|
|
|
|
|
InvRGB = 1,
|
|
|
|
|
Alpha = 2,
|
|
|
|
|
InvAlpha = 3,
|
|
|
|
|
RRR = 4,
|
|
|
|
|
InvRRR = 5,
|
|
|
|
|
GGG = 6,
|
|
|
|
|
InvGGG = 7,
|
|
|
|
|
BBB = 8,
|
|
|
|
|
InvBBB = 9
|
|
|
|
|
}
|
|
|
|
|
public enum TevAlphaOp
|
|
|
|
|
{
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
InvAlpha = 1,
|
|
|
|
|
R = 2,
|
|
|
|
|
InvR = 3,
|
|
|
|
|
G = 4,
|
|
|
|
|
InvG = 5,
|
|
|
|
|
B = 6,
|
|
|
|
|
InvB = 7
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IPicturePane
|
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
ushort MaterialIndex { get; set; }
|
|
|
|
|
|
|
|
|
|
BxlytMaterial Material { get; set; }
|
|
|
|
|
|
|
|
|
|
TexCoord[] TexCoords { get; set; }
|
|
|
|
|
|
|
|
|
|
STColor8 ColorTopLeft { get; set; }
|
|
|
|
|
STColor8 ColorTopRight { get; set; }
|
|
|
|
|
STColor8 ColorBottomLeft { get; set; }
|
|
|
|
|
STColor8 ColorBottomRight { get; set; }
|
2020-01-29 23:17:12 +01:00
|
|
|
|
|
|
|
|
|
void CopyMaterial();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IBoundryPane
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITextPane
|
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
ushort MaterialIndex { get; set; }
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
string Text { get; set; }
|
|
|
|
|
OriginX HorizontalAlignment { get; set; }
|
2019-10-14 03:02:39 +02:00
|
|
|
|
OriginY VerticalAlignment { get; set; }
|
|
|
|
|
|
|
|
|
|
List<string> GetFonts { get; }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
ushort TextLength { get; set; }
|
|
|
|
|
ushort MaxTextLength { get; set; }
|
2019-10-14 03:02:39 +02:00
|
|
|
|
ushort RestrictedLength { get; }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
BxlytMaterial Material { get; set; }
|
|
|
|
|
Toolbox.Library.Rendering.RenderableTex RenderableFont { get; set; }
|
|
|
|
|
|
|
|
|
|
byte TextAlignment { get; set; }
|
|
|
|
|
LineAlign LineAlignment { get; set; }
|
|
|
|
|
|
|
|
|
|
float ItalicTilt { get; set; }
|
|
|
|
|
|
2019-10-06 17:18:53 +02:00
|
|
|
|
STColor8 FontTopColor { get; set; }
|
|
|
|
|
STColor8 FontBottomColor { get; set; }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
Vector2F FontSize { get; set; }
|
|
|
|
|
|
|
|
|
|
float CharacterSpace { get; set; }
|
|
|
|
|
float LineSpace { get; set; }
|
|
|
|
|
|
|
|
|
|
Vector2F ShadowXY { get; set; }
|
|
|
|
|
Vector2F ShadowXYSize { get; set; }
|
|
|
|
|
|
|
|
|
|
STColor8 ShadowForeColor { get; set; }
|
|
|
|
|
STColor8 ShadowBackColor { get; set; }
|
|
|
|
|
|
|
|
|
|
float ShadowItalic { get; set; }
|
|
|
|
|
|
|
|
|
|
string TextBoxName { get; set; }
|
|
|
|
|
|
|
|
|
|
bool RestrictedTextLengthEnabled { get; set; }
|
|
|
|
|
bool ShadowEnabled { get; set; }
|
|
|
|
|
string FontName { get; set; }
|
2019-10-14 03:02:39 +02:00
|
|
|
|
ushort FontIndex { get; set; }
|
2020-01-29 23:17:12 +01:00
|
|
|
|
|
|
|
|
|
void CopyMaterial();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 20:05:37 +02:00
|
|
|
|
public interface IPartPane
|
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
string LayoutFileName { get; set; }
|
2019-10-05 20:05:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 00:42:48 +02:00
|
|
|
|
public interface IWindowPane
|
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
System.Drawing.Color[] GetVertexColors();
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
void ReloadFrames();
|
2019-09-11 00:42:48 +02:00
|
|
|
|
bool UseOneMaterialForAll { get; set; }
|
|
|
|
|
bool UseVertexColorForAll { get; set; }
|
|
|
|
|
WindowKind WindowKind { get; set; }
|
|
|
|
|
bool NotDrawnContent { get; set; }
|
|
|
|
|
ushort StretchLeft { get; set; }
|
|
|
|
|
ushort StretchRight { get; set; }
|
|
|
|
|
ushort StretchTop { get; set; }
|
|
|
|
|
ushort StretchBottm { get; set; }
|
|
|
|
|
ushort FrameElementLeft { get; set; }
|
|
|
|
|
ushort FrameElementRight { get; set; }
|
|
|
|
|
ushort FrameElementTop { get; set; }
|
|
|
|
|
ushort FrameElementBottm { get; set; }
|
|
|
|
|
byte FrameCount { get; set; }
|
|
|
|
|
|
|
|
|
|
BxlytWindowContent Content { get; set; }
|
|
|
|
|
|
2019-09-17 01:56:41 +02:00
|
|
|
|
[Browsable(false)]
|
2019-09-11 00:42:48 +02:00
|
|
|
|
List<BxlytWindowFrame> WindowFrames { get; set; }
|
2020-01-29 23:17:12 +01:00
|
|
|
|
|
|
|
|
|
void CopyWindows();
|
2019-09-11 00:42:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public class BXLAN
|
|
|
|
|
{
|
|
|
|
|
public BxlanHeader BxlanHeader;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 23:17:12 +01:00
|
|
|
|
public class BxlytWindowContent : ICloneable
|
2019-09-11 00:42:48 +02:00
|
|
|
|
{
|
|
|
|
|
public STColor8 ColorTopLeft { get; set; }
|
|
|
|
|
public STColor8 ColorTopRight { get; set; }
|
|
|
|
|
public STColor8 ColorBottomLeft { get; set; }
|
|
|
|
|
public STColor8 ColorBottomRight { get; set; }
|
|
|
|
|
|
|
|
|
|
public ushort MaterialIndex { get; set; }
|
|
|
|
|
|
|
|
|
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
|
|
|
public virtual BxlytMaterial Material { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<TexCoord> TexCoords = new List<TexCoord>();
|
2019-10-17 02:15:36 +02:00
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-17 02:15:36 +02:00
|
|
|
|
private BxlytHeader LayoutFile;
|
|
|
|
|
|
2020-01-29 23:17:12 +01:00
|
|
|
|
public object Clone()
|
|
|
|
|
{
|
|
|
|
|
return this.MemberwiseClone();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 00:25:08 +01:00
|
|
|
|
public BxlytWindowContent(BxlytHeader header) {
|
|
|
|
|
LayoutFile = header;
|
|
|
|
|
ColorTopLeft = STColor8.White;
|
|
|
|
|
ColorTopRight = STColor8.White;
|
|
|
|
|
ColorBottomLeft = STColor8.White;
|
|
|
|
|
ColorBottomRight = STColor8.White;
|
|
|
|
|
TexCoords.Add(new TexCoord());
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 02:15:36 +02:00
|
|
|
|
public BxlytWindowContent(BxlytHeader header, string name)
|
|
|
|
|
{
|
|
|
|
|
LayoutFile = header;
|
|
|
|
|
ColorTopLeft = STColor8.White;
|
|
|
|
|
ColorTopRight = STColor8.White;
|
|
|
|
|
ColorBottomLeft = STColor8.White;
|
|
|
|
|
ColorBottomRight = STColor8.White;
|
|
|
|
|
|
|
|
|
|
TexCoords.Add(new TexCoord());
|
|
|
|
|
|
|
|
|
|
//Add new material
|
|
|
|
|
Material = header.CreateNewMaterial($"{name}_C");
|
|
|
|
|
MaterialIndex = (ushort)header.AddMaterial(Material);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BxlytWindowContent(FileReader reader, BxlytHeader header)
|
|
|
|
|
{
|
|
|
|
|
LayoutFile = header;
|
|
|
|
|
|
|
|
|
|
ColorTopLeft = reader.ReadColor8RGBA();
|
|
|
|
|
ColorTopRight = reader.ReadColor8RGBA();
|
|
|
|
|
ColorBottomLeft = reader.ReadColor8RGBA();
|
|
|
|
|
ColorBottomRight = reader.ReadColor8RGBA();
|
|
|
|
|
MaterialIndex = reader.ReadUInt16();
|
|
|
|
|
byte UVCount = reader.ReadByte();
|
|
|
|
|
reader.ReadByte(); //padding
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < UVCount; i++)
|
|
|
|
|
TexCoords.Add(new TexCoord()
|
|
|
|
|
{
|
|
|
|
|
TopLeft = reader.ReadVec2SY(),
|
|
|
|
|
TopRight = reader.ReadVec2SY(),
|
|
|
|
|
BottomLeft = reader.ReadVec2SY(),
|
|
|
|
|
BottomRight = reader.ReadVec2SY(),
|
|
|
|
|
});
|
|
|
|
|
|
2020-02-12 22:56:16 +01:00
|
|
|
|
Material = LayoutFile.Materials[MaterialIndex];
|
2019-10-17 02:15:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write(FileWriter writer)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(ColorTopLeft);
|
|
|
|
|
writer.Write(ColorTopRight);
|
|
|
|
|
writer.Write(ColorBottomLeft);
|
|
|
|
|
writer.Write(ColorBottomRight);
|
|
|
|
|
writer.Write(MaterialIndex);
|
|
|
|
|
writer.Write((byte)TexCoords.Count);
|
|
|
|
|
writer.Write((byte)0);
|
|
|
|
|
foreach (var texCoord in TexCoords)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(texCoord.TopLeft);
|
|
|
|
|
writer.Write(texCoord.TopRight);
|
|
|
|
|
writer.Write(texCoord.BottomLeft);
|
|
|
|
|
writer.Write(texCoord.BottomRight);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-11 00:42:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 23:17:12 +01:00
|
|
|
|
public class BxlytWindowFrame : ICloneable
|
2019-09-11 00:42:48 +02:00
|
|
|
|
{
|
|
|
|
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
|
|
|
public BxlytMaterial Material { get; set; }
|
|
|
|
|
|
|
|
|
|
public ushort MaterialIndex;
|
2019-09-19 00:23:27 +02:00
|
|
|
|
public WindowFrameTexFlip TextureFlip { get; set; }
|
2019-10-17 00:17:16 +02:00
|
|
|
|
|
2020-01-29 23:17:12 +01:00
|
|
|
|
public object Clone()
|
|
|
|
|
{
|
|
|
|
|
return this.MemberwiseClone();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 00:25:08 +01:00
|
|
|
|
public BxlytWindowFrame()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 00:17:16 +02:00
|
|
|
|
public BxlytWindowFrame(BxlytHeader header, string materialName)
|
|
|
|
|
{
|
|
|
|
|
TextureFlip = WindowFrameTexFlip.None;
|
|
|
|
|
|
|
|
|
|
var mat = header.CreateNewMaterial(materialName);
|
|
|
|
|
MaterialIndex = (ushort)header.AddMaterial(mat);
|
2020-02-15 03:14:53 +01:00
|
|
|
|
Console.WriteLine($"NEW MAT {mat.Name} {MaterialIndex}");
|
2019-10-17 00:17:16 +02:00
|
|
|
|
Material = mat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BxlytWindowFrame(FileReader reader, BxlytHeader header)
|
|
|
|
|
{
|
|
|
|
|
MaterialIndex = reader.ReadUInt16();
|
|
|
|
|
TextureFlip = (WindowFrameTexFlip)reader.ReadByte();
|
|
|
|
|
reader.ReadByte(); //padding
|
|
|
|
|
|
2020-02-12 22:56:16 +01:00
|
|
|
|
Material = header.Materials[MaterialIndex];
|
2019-10-17 00:17:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write(FileWriter writer)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(MaterialIndex);
|
|
|
|
|
writer.Write(TextureFlip, false);
|
|
|
|
|
writer.Write((byte)0);
|
|
|
|
|
}
|
2019-09-11 00:42:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TexCoord
|
|
|
|
|
{
|
|
|
|
|
public Vector2F TopLeft { get; set; }
|
|
|
|
|
public Vector2F TopRight { get; set; }
|
|
|
|
|
public Vector2F BottomLeft { get; set; }
|
|
|
|
|
public Vector2F BottomRight { get; set; }
|
|
|
|
|
|
|
|
|
|
public TexCoord()
|
|
|
|
|
{
|
|
|
|
|
TopLeft = new Vector2F(0, 0);
|
|
|
|
|
TopRight = new Vector2F(1, 0);
|
|
|
|
|
BottomLeft = new Vector2F(0, 1);
|
|
|
|
|
BottomRight = new Vector2F(1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
public class LayoutHeader : IDisposable
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public TextureManager TextureManager = new TextureManager();
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
public PartsManager PartsManager = new PartsManager();
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
[Browsable(false)]
|
2019-08-31 00:53:45 +02:00
|
|
|
|
public string FileName
|
|
|
|
|
{
|
|
|
|
|
get { return FileInfo.FileName; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
[DisplayName("Use Big Endian"), CategoryAttribute("File Settings")]
|
2019-09-01 19:02:48 +02:00
|
|
|
|
public bool IsBigEndian { get; set; }
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
[Browsable(false)]
|
2019-08-30 01:01:47 +02:00
|
|
|
|
internal IFileFormat FileInfo;
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
[Browsable(false)]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
internal uint Version;
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
[DisplayName("Version"), CategoryAttribute("File Settings")]
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public string VersionFull
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-09-04 20:10:17 +02:00
|
|
|
|
return $"{VersionMajor},{VersionMinor},{VersionMicro},{VersionMicro2}";
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
|
|
|
public uint VersionMajor { get; set; }
|
|
|
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
|
|
|
public uint VersionMinor { get; set; }
|
|
|
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
|
|
|
public uint VersionMicro { get; set; }
|
|
|
|
|
[RefreshProperties(RefreshProperties.All)]
|
|
|
|
|
public uint VersionMicro2 { get; set; }
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
internal void SetVersionInfo()
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
2019-09-04 20:10:17 +02:00
|
|
|
|
VersionMajor = Version >> 24;
|
|
|
|
|
VersionMinor = Version >> 16 & 0xFF;
|
|
|
|
|
VersionMicro = Version >> 8 & 0xFF;
|
|
|
|
|
VersionMicro2 = Version & 0xFF;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
internal uint SaveVersion()
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
2019-09-04 20:10:17 +02:00
|
|
|
|
return VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
2019-08-30 01:01:47 +02:00
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
public static void WriteSection(FileWriter writer, string magic, SectionCommon section, Action WriteMethod = null)
|
|
|
|
|
{
|
|
|
|
|
long startPos = writer.Position;
|
|
|
|
|
writer.WriteSignature(magic);
|
|
|
|
|
writer.Write(uint.MaxValue);
|
|
|
|
|
WriteMethod?.Invoke();
|
|
|
|
|
writer.Align(4);
|
|
|
|
|
|
|
|
|
|
long endPos = writer.Position;
|
|
|
|
|
|
|
|
|
|
using (writer.TemporarySeek(startPos + 4, System.IO.SeekOrigin.Begin))
|
|
|
|
|
{
|
|
|
|
|
writer.Write((uint)(endPos - startPos));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public virtual BasePane CreateNewNullPane(string name)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BasePane CreateNewTextPane(string name)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BasePane CreateNewPicturePane(string name)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BasePane CreateNewWindowPane(string name)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BasePane CreateNewBoundryPane(string name)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BasePane CreateNewPartPane(string name)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-30 01:01:47 +02:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
PartsManager?.Dispose();
|
2019-10-14 03:02:39 +02:00
|
|
|
|
TextureManager?.Dispose();
|
2019-08-30 01:01:47 +02:00
|
|
|
|
FileInfo.Unload();
|
|
|
|
|
}
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
public class BxlanHeader : LayoutHeader
|
|
|
|
|
{
|
2019-09-19 00:23:27 +02:00
|
|
|
|
public BxlanPAT1 AnimationTag;
|
|
|
|
|
public BxlanPAI1 AnimationInfo;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
2019-12-08 02:16:13 +01:00
|
|
|
|
public static bool ContainsEntry(byte[] bxlanFile, string[] EntryNames)
|
|
|
|
|
{
|
|
|
|
|
using (var reader = new FileReader(new System.IO.MemoryStream(bxlanFile)))
|
|
|
|
|
{
|
|
|
|
|
reader.SetByteOrder(true);
|
|
|
|
|
|
2020-02-18 01:54:50 +01:00
|
|
|
|
ushort sectionCount = 0;
|
|
|
|
|
|
|
|
|
|
string signature = reader.ReadString(4, Encoding.ASCII);
|
|
|
|
|
if (signature == "RLAN")
|
|
|
|
|
{
|
|
|
|
|
ushort byteOrderMark = reader.ReadUInt16();
|
|
|
|
|
reader.CheckByteOrderMark(byteOrderMark);
|
|
|
|
|
uint Version = reader.ReadUInt16();
|
|
|
|
|
uint FileSize = reader.ReadUInt32();
|
|
|
|
|
ushort HeaderSize = reader.ReadUInt16();
|
|
|
|
|
sectionCount = reader.ReadUInt16();
|
|
|
|
|
reader.ReadUInt16(); //Padding
|
|
|
|
|
reader.SeekBegin(HeaderSize);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ushort byteOrderMark = reader.ReadUInt16();
|
|
|
|
|
reader.CheckByteOrderMark(byteOrderMark);
|
|
|
|
|
ushort HeaderSize = reader.ReadUInt16();
|
|
|
|
|
uint Version = reader.ReadUInt32();
|
|
|
|
|
uint FileSize = reader.ReadUInt32();
|
|
|
|
|
sectionCount = reader.ReadUInt16();
|
|
|
|
|
reader.ReadUInt16(); //Padding
|
|
|
|
|
reader.SeekBegin(HeaderSize);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 02:16:13 +01:00
|
|
|
|
for (int i = 0; i < sectionCount; i++)
|
|
|
|
|
{
|
|
|
|
|
long pos = reader.Position;
|
|
|
|
|
string Signature = reader.ReadString(4, Encoding.ASCII);
|
|
|
|
|
uint SectionSize = reader.ReadUInt32();
|
|
|
|
|
if (Signature == "pai1")
|
|
|
|
|
{
|
|
|
|
|
reader.ReadUInt16(); //FrameSize
|
|
|
|
|
reader.ReadBoolean(); //Loop
|
|
|
|
|
reader.ReadByte(); //padding
|
|
|
|
|
var numTextures = reader.ReadUInt16();
|
|
|
|
|
var numEntries = reader.ReadUInt16();
|
|
|
|
|
var entryOffsetTbl = reader.ReadUInt32();
|
|
|
|
|
|
|
|
|
|
reader.SeekBegin(pos + entryOffsetTbl);
|
|
|
|
|
var entryOffsets = reader.ReadUInt32s(numEntries);
|
|
|
|
|
for (int e = 0; e < numEntries; e++)
|
|
|
|
|
{
|
|
|
|
|
reader.SeekBegin(pos + entryOffsets[e]);
|
2020-02-18 01:54:50 +01:00
|
|
|
|
if (signature == "RLAN")
|
|
|
|
|
{
|
|
|
|
|
string name = reader.ReadString(0x14, true);
|
|
|
|
|
if (EntryNames.Contains(name))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string name = reader.ReadString(28, true);
|
|
|
|
|
if (EntryNames.Contains(name))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-12-08 02:16:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
reader.SeekBegin(pos + SectionSize);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-19 21:48:18 +02:00
|
|
|
|
public BxlanPaiEntry TryGetTag(string name)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < AnimationInfo.Entries?.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (AnimationInfo.Entries[i].Name == name)
|
|
|
|
|
return AnimationInfo.Entries[i];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 02:16:13 +01:00
|
|
|
|
public bool ContainsEntry(string name)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < AnimationInfo.Entries?.Count; i++) {
|
|
|
|
|
if (AnimationInfo.Entries[i].Name == name)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public virtual void Read(FileReader reader, BXLAN header)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Write(FileWriter writer)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-05 19:25:28 +02:00
|
|
|
|
public LytAnimation GetGenericAnimation()
|
|
|
|
|
{
|
|
|
|
|
return animation;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
private LytAnimation animation;
|
|
|
|
|
public LytAnimation ToGenericAnimation(BxlytHeader parentLayout)
|
|
|
|
|
{
|
|
|
|
|
if (animation == null)
|
|
|
|
|
animation = new LytAnimation(this, parentLayout);
|
2019-12-20 01:51:57 +01:00
|
|
|
|
|
|
|
|
|
animation.UpdateLayout(parentLayout);
|
2019-09-28 23:27:48 +02:00
|
|
|
|
return animation;
|
|
|
|
|
}
|
2019-09-19 00:23:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlanPAT1 : SectionCommon
|
|
|
|
|
{
|
|
|
|
|
[DisplayName("Name"), CategoryAttribute("Animation")]
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Groups"), CategoryAttribute("Animation")]
|
2020-07-12 22:52:07 +02:00
|
|
|
|
[Editor(@"System.Windows.Forms.Design.StringCollectionEditor," +
|
|
|
|
|
"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
|
|
|
|
|
typeof(System.Drawing.Design.UITypeEditor))]
|
2019-09-19 00:23:27 +02:00
|
|
|
|
public List<string> Groups { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Start"), CategoryAttribute("Frames")]
|
|
|
|
|
public short StartFrame { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("End"), CategoryAttribute("Frames")]
|
|
|
|
|
public short EndFrame { get; set; }
|
2019-09-17 01:56:41 +02:00
|
|
|
|
|
2019-09-19 00:23:27 +02:00
|
|
|
|
[DisplayName("Animation Order"), CategoryAttribute("Parameters")]
|
|
|
|
|
public ushort AnimationOrder { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Child Binding"), CategoryAttribute("Parameters")]
|
|
|
|
|
public bool ChildBinding { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlanPAI1 : SectionCommon
|
|
|
|
|
{
|
|
|
|
|
public ushort FrameSize;
|
|
|
|
|
public bool Loop;
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public bool ContainsEntry(string name)
|
|
|
|
|
{
|
|
|
|
|
return Entries.Any(x => x.Name == name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BxlanPaiEntry AddEntry(string name, byte target)
|
|
|
|
|
{
|
|
|
|
|
return new BxlanPaiEntry();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-12 22:52:07 +02:00
|
|
|
|
[Editor(@"System.Windows.Forms.Design.StringCollectionEditor," +
|
|
|
|
|
"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
|
|
|
|
|
typeof(System.Drawing.Design.UITypeEditor))]
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public List<string> Textures { get; set; } = new List<string>();
|
2020-07-12 22:52:07 +02:00
|
|
|
|
|
2019-09-19 00:23:27 +02:00
|
|
|
|
public List<BxlanPaiEntry> Entries = new List<BxlanPaiEntry>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlanPaiEntry
|
|
|
|
|
{
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public virtual BxlanPaiTag AddEntry(string tag)
|
|
|
|
|
{
|
|
|
|
|
return new BxlanPaiTag();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-19 00:23:27 +02:00
|
|
|
|
[DisplayName("Name"), CategoryAttribute("Animation")]
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Animation")]
|
|
|
|
|
public AnimationTarget Target { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<BxlanPaiTag> Tags = new List<BxlanPaiTag>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlanPaiTag
|
|
|
|
|
{
|
2019-10-05 19:25:28 +02:00
|
|
|
|
public BxlanPaiTag()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BxlanPaiTag(string tag)
|
|
|
|
|
{
|
|
|
|
|
Tag = tag;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public BxlanPaiTagEntry CreateTarget(object TargetType, byte interpolationType)
|
|
|
|
|
{
|
|
|
|
|
byte target = (byte)TargetType;
|
2020-02-12 22:56:16 +01:00
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
string tagType = Tag.Remove(0, 1);
|
2019-10-20 19:30:09 +02:00
|
|
|
|
switch (tagType)
|
2019-10-20 18:57:48 +02:00
|
|
|
|
{
|
|
|
|
|
case "LPA":
|
|
|
|
|
return new LPATagEntry(target, interpolationType);
|
|
|
|
|
case "LTS":
|
|
|
|
|
return new LTSTagEntry(target, interpolationType);
|
|
|
|
|
case "LVI":
|
|
|
|
|
return new LVITagEntry(target, interpolationType);
|
|
|
|
|
case "LVC":
|
|
|
|
|
return new LVCTagEntry(target, interpolationType);
|
|
|
|
|
case "LMC":
|
|
|
|
|
return new LMCTagEntry(target, interpolationType);
|
|
|
|
|
case "LTP":
|
|
|
|
|
return new LTPTagEntry(target, interpolationType);
|
|
|
|
|
default:
|
|
|
|
|
return new BxlanPaiTagEntry(target, interpolationType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-19 00:23:27 +02:00
|
|
|
|
public List<BxlanPaiTagEntry> Entries = new List<BxlanPaiTagEntry>();
|
|
|
|
|
|
|
|
|
|
public string Tag;
|
|
|
|
|
|
|
|
|
|
public string Type
|
|
|
|
|
{
|
|
|
|
|
get { return TypeDefine.ContainsKey(Tag) ? TypeDefine[Tag] : Tag; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 19:14:21 +02:00
|
|
|
|
public static Dictionary<string, string> CafeTypeDefine = new Dictionary<string, string>()
|
|
|
|
|
{
|
|
|
|
|
{"FLPA","PaneSRT" },
|
|
|
|
|
{"FLVI","Visibility" },
|
|
|
|
|
{"FLTS","TextureSRT" },
|
|
|
|
|
{"FLVC","VertexColor" },
|
|
|
|
|
{"FLMC","MaterialColor" },
|
|
|
|
|
{"FLTP","TexturePattern" },
|
|
|
|
|
{"FLIM","IndTextureSRT" },
|
|
|
|
|
{"FLAC","AlphaTest" },
|
|
|
|
|
{"FLCT","FontShadow" },
|
|
|
|
|
{"FLCC","PerCharacterTransformCurve" },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static Dictionary<string, string> RevTypeDefine = new Dictionary<string, string>()
|
|
|
|
|
{
|
|
|
|
|
{"RLPA","PaneSRT" },
|
|
|
|
|
{"RLVI","Visibility" },
|
|
|
|
|
{"RLTS","TextureSRT" },
|
|
|
|
|
{"RLVC","VertexColor" },
|
|
|
|
|
{"RLMC","MaterialColor" },
|
|
|
|
|
{"RLTP","TexturePattern" },
|
|
|
|
|
{"RLIM","IndTextureSRT" },
|
|
|
|
|
{"RLAC","AlphaTest" },
|
|
|
|
|
{"RLCT","FontShadow" },
|
|
|
|
|
{"RLCC","PerCharacterTransformCurve" },
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-12 22:56:16 +01:00
|
|
|
|
public static Dictionary<string, string> CtrTypeDefine = new Dictionary<string, string>()
|
|
|
|
|
{
|
|
|
|
|
{"CLPA","PaneSRT" },
|
|
|
|
|
{"CLVI","Visibility" },
|
|
|
|
|
{"CLTS","TextureSRT" },
|
|
|
|
|
{"CLVC","VertexColor" },
|
|
|
|
|
{"CLMC","MaterialColor" },
|
|
|
|
|
{"CLTP","TexturePattern" },
|
|
|
|
|
{"CLIM","IndTextureSRT" },
|
|
|
|
|
{"CLAC","AlphaTest" },
|
|
|
|
|
{"CLCT","FontShadow" },
|
|
|
|
|
{"CLCC","PerCharacterTransformCurve" },
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public static Dictionary<string, string> TypeDefine = new Dictionary<string, string>()
|
2019-09-19 00:23:27 +02:00
|
|
|
|
{
|
|
|
|
|
{"FLPA","PaneSRT" },
|
|
|
|
|
{"FLVI","Visibility" },
|
|
|
|
|
{"FLTS","TextureSRT" },
|
|
|
|
|
{"FLVC","VertexColor" },
|
|
|
|
|
{"FLMC","MaterialColor" },
|
|
|
|
|
{"FLTP","TexturePattern" },
|
|
|
|
|
{"FLIM","IndTextureSRT" },
|
|
|
|
|
{"FLAC","AlphaTest" },
|
|
|
|
|
{"FLCT","FontShadow" },
|
|
|
|
|
{"FLCC","PerCharacterTransformCurve" },
|
|
|
|
|
|
|
|
|
|
{"RLPA","PaneSRT" },
|
|
|
|
|
{"RLVI","Visibility" },
|
|
|
|
|
{"RLTS","TextureSRT" },
|
|
|
|
|
{"RLVC","VertexColor" },
|
|
|
|
|
{"RLMC","MaterialColor" },
|
|
|
|
|
{"RLTP","TexturePattern" },
|
|
|
|
|
{"RLIM","IndTextureSRT" },
|
|
|
|
|
{"RLAC","AlphaTest" },
|
|
|
|
|
{"RLCT","FontShadow" },
|
|
|
|
|
{"RLCC","PerCharacterTransformCurve" },
|
|
|
|
|
|
|
|
|
|
{"CLPA","PaneSRT" },
|
|
|
|
|
{"CLVI","Visibility" },
|
|
|
|
|
{"CLTS","TextureSRT" },
|
|
|
|
|
{"CLVC","VertexColor" },
|
|
|
|
|
{"CLMC","MaterialColor" },
|
|
|
|
|
{"CLTP","TexturePattern" },
|
|
|
|
|
{"CLIM","IndTextureSRT" },
|
|
|
|
|
{"CLAC","AlphaTest" },
|
|
|
|
|
{"CLCT","FontShadow" },
|
|
|
|
|
{"CLCC","PerCharacterTransformCurve" },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
public class LPATagEntry : BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
public override string TargetName => Target.ToString();
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Tag")]
|
|
|
|
|
public LPATarget Target
|
|
|
|
|
{
|
|
|
|
|
get { return (LPATarget)AnimationTarget; }
|
|
|
|
|
set { AnimationTarget = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public LPATagEntry(byte target, byte curveType) : base(target, curveType) { }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public LPATagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LTSTagEntry : BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
public override string TargetName => Target.ToString();
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Tag")]
|
|
|
|
|
public LTSTarget Target
|
|
|
|
|
{
|
|
|
|
|
get { return (LTSTarget)AnimationTarget; }
|
|
|
|
|
set { AnimationTarget = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public LTSTagEntry(byte target, byte curveType) : base(target, curveType) { }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public LTSTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LVITagEntry : BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
public override string TargetName => Target.ToString();
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Tag")]
|
|
|
|
|
public LVITarget Target
|
|
|
|
|
{
|
|
|
|
|
get { return (LVITarget)AnimationTarget; }
|
|
|
|
|
set { AnimationTarget = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public LVITagEntry(byte target, byte curveType) : base(target, curveType) { }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public LVITagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LVCTagEntry : BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
public override string TargetName => Target.ToString();
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Tag")]
|
|
|
|
|
public LVCTarget Target
|
|
|
|
|
{
|
|
|
|
|
get { return (LVCTarget)AnimationTarget; }
|
|
|
|
|
set { AnimationTarget = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public LVCTagEntry(byte target, byte curveType) : base(target, curveType) { }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public LVCTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LMCTagEntry : BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
public override string TargetName => Target.ToString();
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Tag")]
|
|
|
|
|
public LMCTarget Target
|
|
|
|
|
{
|
|
|
|
|
get { return (LMCTarget)AnimationTarget; }
|
|
|
|
|
set { AnimationTarget = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public LMCTagEntry(byte target, byte curveType) : base(target, curveType) { }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public LMCTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public class RevLMCTagEntry : BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
public override string TargetName => Target.ToString();
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Tag")]
|
|
|
|
|
public RevLMCTarget Target
|
|
|
|
|
{
|
|
|
|
|
get { return (RevLMCTarget)AnimationTarget; }
|
|
|
|
|
set { AnimationTarget = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RevLMCTagEntry(byte target, byte curveType) : base(target, curveType) { }
|
|
|
|
|
public RevLMCTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public class LTPTagEntry : BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
public override string TargetName => Target.ToString();
|
|
|
|
|
[DisplayName("Target"), CategoryAttribute("Tag")]
|
|
|
|
|
public LTPTarget Target
|
|
|
|
|
{
|
|
|
|
|
get { return (LTPTarget)AnimationTarget; }
|
|
|
|
|
set { AnimationTarget = (byte)value; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public LTPTagEntry(byte target, byte curveType) : base(target, curveType) { }
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public LTPTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-19 00:23:27 +02:00
|
|
|
|
public class BxlanPaiTagEntry
|
|
|
|
|
{
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public virtual string TargetName
|
|
|
|
|
{
|
|
|
|
|
get { return AnimationTarget.ToString(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte AnimationTarget;
|
|
|
|
|
|
|
|
|
|
[DisplayName("Index"), CategoryAttribute("Tag")]
|
|
|
|
|
public byte Index { get; set; }
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
[DisplayName("Curve Type"), CategoryAttribute("Tag")]
|
|
|
|
|
public CurveType CurveType { get; set; }
|
2019-09-19 00:23:27 +02:00
|
|
|
|
|
|
|
|
|
public List<KeyFrame> KeyFrames = new List<KeyFrame>();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public BxlanPaiTagEntry(byte target, byte curveType)
|
|
|
|
|
{
|
|
|
|
|
AnimationTarget = target;
|
|
|
|
|
CurveType = (CurveType)curveType;
|
|
|
|
|
}
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
|
|
|
|
public BxlanPaiTagEntry(FileReader reader, BxlanHeader header)
|
|
|
|
|
{
|
|
|
|
|
long startPos = reader.Position;
|
|
|
|
|
Index = reader.ReadByte();
|
|
|
|
|
AnimationTarget = reader.ReadByte();
|
|
|
|
|
CurveType = reader.ReadEnum<CurveType>(true);
|
|
|
|
|
reader.ReadByte(); //padding
|
|
|
|
|
var KeyFrameCount = reader.ReadUInt16();
|
|
|
|
|
reader.ReadUInt16(); //Padding
|
|
|
|
|
uint keyFrameOffset = reader.ReadUInt32();
|
|
|
|
|
|
|
|
|
|
reader.SeekBegin(startPos + keyFrameOffset);
|
|
|
|
|
for (int i = 0; i < KeyFrameCount; i++)
|
|
|
|
|
KeyFrames.Add(new KeyFrame(reader, CurveType));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write(FileWriter writer, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
long startPos = writer.Position;
|
|
|
|
|
|
|
|
|
|
writer.Write(Index);
|
|
|
|
|
writer.Write(AnimationTarget);
|
|
|
|
|
writer.Write(CurveType, true);
|
|
|
|
|
writer.Write((byte)0); //padding
|
|
|
|
|
writer.Write((ushort)KeyFrames.Count);
|
|
|
|
|
writer.Write((ushort)0); //padding
|
|
|
|
|
writer.Write(0); //key offset
|
|
|
|
|
|
|
|
|
|
if (KeyFrames.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteUint32Offset(startPos + 8, startPos);
|
|
|
|
|
for (int i = 0; i < KeyFrames.Count; i++)
|
|
|
|
|
KeyFrames[i].Write(writer, CurveType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum BorderType : byte
|
|
|
|
|
{
|
|
|
|
|
Standard = 0,
|
|
|
|
|
DeleteBorder = 1,
|
|
|
|
|
RenderTwoCycles = 2,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public enum LineAlign : byte
|
|
|
|
|
{
|
|
|
|
|
Unspecified = 0,
|
|
|
|
|
Left = 1,
|
|
|
|
|
Center = 2,
|
|
|
|
|
Right = 3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public enum CurveType : byte
|
|
|
|
|
{
|
|
|
|
|
Constant,
|
|
|
|
|
Step,
|
|
|
|
|
Hermite,
|
2019-09-19 00:23:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class KeyFrame
|
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
[DisplayName("Slope"), CategoryAttribute("Key Frame")]
|
|
|
|
|
public float Slope { get; set; }
|
2019-09-19 00:23:27 +02:00
|
|
|
|
[DisplayName("Frame"), CategoryAttribute("Key Frame")]
|
|
|
|
|
public float Frame { get; set; }
|
|
|
|
|
[DisplayName("Value"), CategoryAttribute("Key Frame")]
|
|
|
|
|
public float Value { get; set; }
|
|
|
|
|
|
2019-10-20 18:57:48 +02:00
|
|
|
|
public KeyFrame(float frame)
|
|
|
|
|
{
|
|
|
|
|
Frame = frame;
|
|
|
|
|
Value = 0;
|
|
|
|
|
Slope = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public KeyFrame(FileReader reader, CurveType curveType)
|
2019-09-19 00:23:27 +02:00
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
switch (curveType)
|
2019-09-19 00:23:27 +02:00
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
case CurveType.Hermite:
|
|
|
|
|
Frame = reader.ReadSingle();
|
2019-09-19 00:23:27 +02:00
|
|
|
|
Value = reader.ReadSingle();
|
2019-09-28 23:27:48 +02:00
|
|
|
|
Slope = reader.ReadSingle();
|
2019-09-19 00:23:27 +02:00
|
|
|
|
break;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
default:
|
|
|
|
|
Frame = reader.ReadSingle();
|
|
|
|
|
Value = reader.ReadInt16();
|
|
|
|
|
reader.ReadInt16(); //padding
|
2019-09-19 00:23:27 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public void Write(FileWriter writer, CurveType curveType)
|
2019-09-19 00:23:27 +02:00
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
switch (curveType)
|
2019-09-19 00:23:27 +02:00
|
|
|
|
{
|
2019-09-28 23:27:48 +02:00
|
|
|
|
case CurveType.Hermite:
|
|
|
|
|
writer.Write(Frame);
|
2019-09-19 00:23:27 +02:00
|
|
|
|
writer.Write(Value);
|
2019-09-28 23:27:48 +02:00
|
|
|
|
writer.Write(Slope);
|
2019-09-19 00:23:27 +02:00
|
|
|
|
break;
|
2019-09-28 23:27:48 +02:00
|
|
|
|
default:
|
|
|
|
|
writer.Write(Frame);
|
2019-09-19 00:23:27 +02:00
|
|
|
|
writer.Write((ushort)Value);
|
2019-09-28 23:27:48 +02:00
|
|
|
|
writer.Write((ushort)0);
|
2019-09-19 00:23:27 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-10 00:37:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlytHeader : LayoutHeader
|
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public System.Windows.Forms.TreeNode MaterialFolder;
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public System.Windows.Forms.TreeNode TextureFolder;
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public System.Windows.Forms.TreeNode FontFolder;
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public Dictionary<string, BasePane> PaneLookup = new Dictionary<string, BasePane>();
|
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public BasePane RootPane { get; set; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public BasePane RootGroup { get; set; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public virtual Dictionary<string, STGenericTexture> GetTextures { get; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public virtual List<string> Textures { get; }
|
2019-09-10 00:37:33 +02:00
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
public virtual List<string> Fonts { get; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public virtual List<BxlytMaterial> Materials { get;}
|
2019-09-28 23:27:48 +02:00
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public virtual short AddMaterial(BxlytMaterial material, ushort index) { return -1; }
|
|
|
|
|
public virtual short AddMaterial(BxlytMaterial material) { return -1; }
|
|
|
|
|
public virtual List<int> AddMaterial(List<BxlytMaterial> materials) { return new List<int>(); }
|
|
|
|
|
|
|
|
|
|
public virtual void TryRemoveMaterial(BxlytMaterial material) { }
|
|
|
|
|
public virtual void TryRemoveMaterial(List<BxlytMaterial> materials) { }
|
|
|
|
|
|
2019-10-17 00:17:16 +02:00
|
|
|
|
public virtual BxlytMaterial CreateNewMaterial(string name)
|
|
|
|
|
{
|
|
|
|
|
return new BxlytMaterial();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual BxlytMaterial GetMaterial(ushort index)
|
|
|
|
|
{
|
|
|
|
|
return new BxlytMaterial();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 23:18:35 +02:00
|
|
|
|
public void RemoveTextureReferences(string texture)
|
|
|
|
|
{
|
2020-02-12 01:19:23 +01:00
|
|
|
|
foreach (var mat in Materials)
|
2019-10-18 23:18:35 +02:00
|
|
|
|
mat.TryRemoveTexture(texture);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public BxlytMaterial SearchMaterial(string name)
|
|
|
|
|
{
|
2020-02-12 01:19:23 +01:00
|
|
|
|
for (int i = 0; i < Materials.Count; i++)
|
2019-09-28 23:27:48 +02:00
|
|
|
|
{
|
2020-02-12 01:19:23 +01:00
|
|
|
|
if (Materials[i].Name == name)
|
|
|
|
|
return Materials[i];
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public virtual int AddFont(string name)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void RemoveTexture(string name)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual int AddTexture(string name)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public void AddPaneToTable(BasePane pane)
|
|
|
|
|
{
|
|
|
|
|
if (!PaneLookup.ContainsKey(pane.Name))
|
|
|
|
|
PaneLookup.Add(pane.Name, pane);
|
|
|
|
|
}
|
2019-10-06 00:37:28 +02:00
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
public void AddPane(BasePane pane, string parent)
|
|
|
|
|
{
|
|
|
|
|
if (PaneLookup.ContainsKey(parent))
|
|
|
|
|
AddPane(pane, PaneLookup[parent]);
|
|
|
|
|
else
|
|
|
|
|
throw new Exception($"Failed to find parent pane! [{parent}]");
|
|
|
|
|
}
|
2019-10-06 00:37:28 +02:00
|
|
|
|
|
|
|
|
|
public void AddPane(BasePane pane, BasePane parent)
|
|
|
|
|
{
|
|
|
|
|
if (!PaneLookup.ContainsKey(pane.Name))
|
|
|
|
|
PaneLookup.Add(pane.Name, pane);
|
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
pane.Parent = parent;
|
2019-10-06 00:37:28 +02:00
|
|
|
|
parent.Childern.Add(pane);
|
|
|
|
|
parent.NodeWrapper.Nodes.Add(pane.NodeWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public void RemovePanes(List<BasePane> panes, BasePane rootPane)
|
2019-10-06 00:37:28 +02:00
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
Console.WriteLine("RemovePanes num " + panes.Count);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < panes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"RemovePanes {panes[i].Name} {panes[i]}");
|
|
|
|
|
|
|
|
|
|
//We need to remove any materials that the material referenced
|
|
|
|
|
if (panes[i] is IPicturePane)
|
|
|
|
|
TryRemoveMaterial(((IPicturePane)panes[i]).Material);
|
|
|
|
|
if (panes[i] is ITextPane)
|
|
|
|
|
TryRemoveMaterial(((ITextPane)panes[i]).Material);
|
|
|
|
|
if (panes[i] is IWindowPane)
|
|
|
|
|
{
|
|
|
|
|
var wnd = panes[i] as IWindowPane;
|
|
|
|
|
|
|
|
|
|
List<BxlytMaterial> materials = new List<BxlytMaterial>();
|
|
|
|
|
var matC = wnd.Content.Material;
|
|
|
|
|
materials.Add(matC);
|
|
|
|
|
foreach (var windowFrame in wnd.WindowFrames)
|
|
|
|
|
materials.Add(windowFrame.Material);
|
|
|
|
|
|
|
|
|
|
TryRemoveMaterial(materials);
|
|
|
|
|
materials.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<BasePane> topMostPanes = new List<BasePane>();
|
|
|
|
|
GetTopMostPanes(panes, topMostPanes, rootPane);
|
|
|
|
|
|
|
|
|
|
foreach (var pane in topMostPanes)
|
|
|
|
|
{
|
|
|
|
|
pane.Parent.NodeWrapper.Nodes.Remove(pane.NodeWrapper);
|
|
|
|
|
pane.Parent.Childern.Remove(pane);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-06 00:37:28 +02:00
|
|
|
|
for (int i = 0; i < panes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (PaneLookup.ContainsKey(panes[i].Name))
|
|
|
|
|
PaneLookup.Remove(panes[i].Name);
|
2019-10-14 03:02:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-06 00:37:28 +02:00
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
//Loop through each pane in the heiarchy until it finds the first set of panes
|
|
|
|
|
//The topmost panes are only going to be removed for adding with redo to be easier
|
|
|
|
|
private void GetTopMostPanes(List<BasePane> panes, List<BasePane> topMost, BasePane root)
|
|
|
|
|
{
|
|
|
|
|
foreach (var child in root.Childern)
|
|
|
|
|
{
|
|
|
|
|
if (panes.Contains(child))
|
|
|
|
|
topMost.Add(child);
|
|
|
|
|
}
|
2019-10-06 00:37:28 +02:00
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
if (topMost.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var child in root.Childern)
|
|
|
|
|
GetTopMostPanes(panes, topMost, child);
|
2019-10-06 00:37:28 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-10 00:37:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 23:17:12 +01:00
|
|
|
|
public class BxlytMaterial
|
2019-09-05 22:24:03 +02:00
|
|
|
|
{
|
2019-10-14 03:02:39 +02:00
|
|
|
|
//Setup some enable booleans
|
|
|
|
|
//These determine wether to switch to default values or not
|
|
|
|
|
//While i could null out the instances of each, it's best to keep those intact
|
|
|
|
|
//incase the settings get renabled, which keeps the previous data
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public bool EnableAlphaCompare { get; set; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public bool EnableBlend { get; set; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public bool EnableBlendLogic { get; set; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public bool EnableIndParams { get; set; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public bool EnableFontShadowParams { get; set; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public TreeNodeCustom NodeWrapper;
|
|
|
|
|
|
2019-10-18 23:18:35 +02:00
|
|
|
|
public bool TryRemoveTexture(string name)
|
|
|
|
|
{
|
|
|
|
|
int removeIndex = -1;
|
|
|
|
|
for (int i = 0; i < TextureMaps?.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (TextureMaps[i].Name == name)
|
|
|
|
|
removeIndex = i;
|
|
|
|
|
}
|
2019-10-18 23:23:14 +02:00
|
|
|
|
|
2019-10-18 23:18:35 +02:00
|
|
|
|
if (removeIndex != -1)
|
|
|
|
|
{
|
2019-10-18 23:23:14 +02:00
|
|
|
|
TextureMaps = TextureMaps.RemoveAt(removeIndex);
|
2019-10-18 23:18:35 +02:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 23:17:12 +01:00
|
|
|
|
public virtual BxlytMaterial Clone()
|
|
|
|
|
{
|
|
|
|
|
return (BxlytMaterial)this.MemberwiseClone();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public void RemoveNodeWrapper()
|
|
|
|
|
{
|
2019-10-30 00:04:34 +01:00
|
|
|
|
if (NodeWrapper != null && NodeWrapper.Parent != null)
|
2019-10-14 03:02:39 +02:00
|
|
|
|
{
|
|
|
|
|
var parent = NodeWrapper.Parent;
|
|
|
|
|
parent.Nodes.Remove(NodeWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 22:30:10 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes any texture coordinate references when a texture coordinate is removed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public virtual bool RemoveTexCoordSources(int index)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public virtual void AddTexture(string texture)
|
|
|
|
|
{
|
|
|
|
|
int index = ParentLayout.AddTexture(texture);
|
|
|
|
|
BxlytTextureRef textureRef = new BxlytTextureRef();
|
|
|
|
|
textureRef.ID = (short)index;
|
|
|
|
|
textureRef.Name = texture;
|
|
|
|
|
TextureMaps = TextureMaps.AddToArray(textureRef);
|
|
|
|
|
TextureTransforms = TextureTransforms.AddToArray(new BxlytTextureTransform());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DisplayName("Texture Transforms"), CategoryAttribute("Texture")]
|
|
|
|
|
public BxlytTextureTransform[] TextureTransforms { get; set; }
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public MaterialAnimController animController = new MaterialAnimController();
|
|
|
|
|
|
2019-09-05 22:24:03 +02:00
|
|
|
|
[DisplayName("Name"), CategoryAttribute("General")]
|
|
|
|
|
public virtual string Name { get; set; }
|
2019-09-08 21:15:42 +02:00
|
|
|
|
|
2019-10-14 03:02:39 +02:00
|
|
|
|
[Browsable(false)]
|
2020-02-12 01:19:23 +01:00
|
|
|
|
[YamlIgnore]
|
2019-10-14 03:02:39 +02:00
|
|
|
|
public BxlytHeader ParentLayout;
|
|
|
|
|
|
|
|
|
|
public void SetName(string oldName, string newName)
|
|
|
|
|
{
|
|
|
|
|
if (Name == null) return;
|
|
|
|
|
|
|
|
|
|
Name = Name.Replace(oldName, newName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DisplayName("Black Color"), CategoryAttribute("Color")]
|
|
|
|
|
public virtual STColor8 WhiteColor { get; set; } = STColor8.White;
|
|
|
|
|
|
|
|
|
|
[DisplayName("White Color"), CategoryAttribute("Color")]
|
|
|
|
|
public virtual STColor8 BlackColor { get; set; } = STColor8.Black;
|
|
|
|
|
|
|
|
|
|
[DisplayName("Blend Mode"), CategoryAttribute("Blend")]
|
|
|
|
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
|
|
|
public BxlytBlendMode BlendMode { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Blend Mode Logic"), CategoryAttribute("Blend")]
|
|
|
|
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
|
|
|
public BxlytBlendMode BlendModeLogic { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Alpha Compare"), CategoryAttribute("Alpha")]
|
|
|
|
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
|
|
|
public BxlytAlphaCompare AlphaCompare { get; set; }
|
|
|
|
|
|
2020-02-03 23:17:49 +01:00
|
|
|
|
[DisplayName("Alpha Interpolation"), CategoryAttribute("Alpha")]
|
|
|
|
|
public virtual bool AlphaInterpolation { get; set; }
|
2019-09-20 00:02:10 +02:00
|
|
|
|
|
2019-09-11 00:42:48 +02:00
|
|
|
|
[DisplayName("Texture Maps"), CategoryAttribute("Texture")]
|
|
|
|
|
public BxlytTextureRef[] TextureMaps { get; set; }
|
2019-10-17 00:17:16 +02:00
|
|
|
|
|
|
|
|
|
[DisplayName("Tev Stages"), CategoryAttribute("Tev")]
|
|
|
|
|
public BxlytTevStage[] TevStages { get; set; }
|
2020-02-15 22:30:10 +01:00
|
|
|
|
|
|
|
|
|
[DisplayName("Texture Coordinate Params"), CategoryAttribute("Texture")]
|
|
|
|
|
public BxlytTexCoordGen[] TexCoordGens { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Projection Texture Coord Parameters"), CategoryAttribute("Texture")]
|
|
|
|
|
public ProjectionTexGenParam[] ProjTexGenParams { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlytTexCoordGen
|
|
|
|
|
{
|
|
|
|
|
public TexGenMatrixType Matrix { get; set; }
|
|
|
|
|
public TexGenType Source { get; set; }
|
2019-10-17 00:17:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlytTevStage
|
|
|
|
|
{
|
|
|
|
|
public TevMode ColorMode { get; set; }
|
|
|
|
|
public TevMode AlphaMode { get; set; }
|
2019-09-05 22:24:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public class MaterialAnimController
|
|
|
|
|
{
|
|
|
|
|
public Dictionary<LMCTarget, float> MaterialColors = new Dictionary<LMCTarget, float>();
|
|
|
|
|
public Dictionary<LTPTarget, string> TexturePatterns = new Dictionary<LTPTarget, string>();
|
|
|
|
|
public Dictionary<LTSTarget, float> TextureSRTS = new Dictionary<LTSTarget, float>();
|
|
|
|
|
public Dictionary<LIMTarget, float> IndTextureSRTS = new Dictionary<LIMTarget, float>();
|
|
|
|
|
|
|
|
|
|
public void ResetAnim()
|
|
|
|
|
{
|
|
|
|
|
MaterialColors.Clear();
|
|
|
|
|
TexturePatterns.Clear();
|
|
|
|
|
TextureSRTS.Clear();
|
|
|
|
|
IndTextureSRTS.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlytTextureTransform
|
|
|
|
|
{
|
|
|
|
|
public Vector2F Translate { get; set; }
|
|
|
|
|
public float Rotate { get; set; }
|
|
|
|
|
public Vector2F Scale { get; set; }
|
2019-10-14 03:02:39 +02:00
|
|
|
|
|
|
|
|
|
public BxlytTextureTransform()
|
|
|
|
|
{
|
|
|
|
|
Translate = new Vector2F(0,0);
|
|
|
|
|
Scale = new Vector2F(1, 1);
|
|
|
|
|
Rotate = 0;
|
|
|
|
|
}
|
2020-02-12 01:19:23 +01:00
|
|
|
|
|
|
|
|
|
public BxlytTextureTransform(FileReader reader)
|
|
|
|
|
{
|
|
|
|
|
Translate = reader.ReadVec2SY();
|
|
|
|
|
Rotate = reader.ReadSingle();
|
|
|
|
|
Scale = reader.ReadVec2SY();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Write(FileWriter writer)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(Translate);
|
|
|
|
|
writer.Write(Rotate);
|
|
|
|
|
writer.Write(Scale);
|
|
|
|
|
}
|
2019-09-28 23:27:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BxlytIndTextureTransform
|
|
|
|
|
{
|
|
|
|
|
public float Rotation { get; set; }
|
|
|
|
|
public float ScaleX { get; set; }
|
|
|
|
|
public float ScaleY { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 01:56:41 +02:00
|
|
|
|
public class SectionCommon
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
2019-09-08 21:15:42 +02:00
|
|
|
|
[Browsable(false)]
|
2019-09-01 19:02:48 +02:00
|
|
|
|
public virtual string Signature { get; }
|
2019-08-29 22:33:23 +02:00
|
|
|
|
|
2019-09-08 21:15:42 +02:00
|
|
|
|
internal uint SectionSize { get; set; }
|
|
|
|
|
internal long StartPosition { get; set; }
|
2019-08-29 22:33:23 +02:00
|
|
|
|
internal byte[] Data { get; set; }
|
|
|
|
|
|
2019-09-01 23:21:36 +02:00
|
|
|
|
public SectionCommon()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SectionCommon(string signature)
|
|
|
|
|
{
|
|
|
|
|
Signature = signature;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-10 00:37:33 +02:00
|
|
|
|
public virtual void Write(FileWriter writer, LayoutHeader header)
|
2019-08-29 22:33:23 +02:00
|
|
|
|
{
|
|
|
|
|
if (Data != null)
|
|
|
|
|
writer.Write(Data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public class PerCharacterTransform
|
|
|
|
|
{
|
|
|
|
|
public float CurveTimeOffset { get; set; }
|
|
|
|
|
public float CurveWidth { get; set; }
|
|
|
|
|
public byte LoopType { get; set; }
|
|
|
|
|
public byte VerticalOrigin { get; set; }
|
|
|
|
|
public byte HasAnimInfo { get; set; }
|
|
|
|
|
public byte padding { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual void Read(FileReader reader, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
CurveTimeOffset = reader.ReadSingle();
|
|
|
|
|
CurveWidth = reader.ReadSingle();
|
|
|
|
|
LoopType = reader.ReadByte();
|
|
|
|
|
VerticalOrigin = reader.ReadByte();
|
|
|
|
|
HasAnimInfo = reader.ReadByte();
|
|
|
|
|
padding = reader.ReadByte();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Write(FileWriter writer, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(CurveTimeOffset);
|
|
|
|
|
writer.Write(CurveWidth);
|
|
|
|
|
writer.Write(LoopType);
|
|
|
|
|
writer.Write(VerticalOrigin);
|
|
|
|
|
writer.Write(HasAnimInfo);
|
|
|
|
|
writer.Write(padding);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public class CustomRectangle
|
|
|
|
|
{
|
|
|
|
|
public int LeftPoint;
|
|
|
|
|
public int RightPoint;
|
|
|
|
|
public int TopPoint;
|
|
|
|
|
public int BottomPoint;
|
|
|
|
|
|
2019-10-27 02:28:56 +02:00
|
|
|
|
public OpenTK.Vector2 TopLeftPoint;
|
|
|
|
|
public OpenTK.Vector2 TopRightPoint;
|
|
|
|
|
public OpenTK.Vector2 BottomLeftPoint;
|
|
|
|
|
public OpenTK.Vector2 BottomRightPoint;
|
|
|
|
|
|
2020-02-15 00:25:08 +01:00
|
|
|
|
public CustomRectangle() { }
|
|
|
|
|
|
2019-10-27 02:28:56 +02:00
|
|
|
|
public CustomRectangle(OpenTK.Vector2 topLeft, OpenTK.Vector2 topRight,
|
|
|
|
|
OpenTK.Vector2 bottomLeft, OpenTK.Vector2 bottomRight)
|
|
|
|
|
{
|
|
|
|
|
TopLeftPoint = topLeft;
|
|
|
|
|
TopRightPoint = topRight;
|
|
|
|
|
BottomLeftPoint = bottomLeft;
|
|
|
|
|
BottomRightPoint = bottomRight;
|
|
|
|
|
|
|
|
|
|
LeftPoint = (int)topLeft.X;
|
|
|
|
|
RightPoint = (int)topRight.X;
|
|
|
|
|
TopPoint = (int)topLeft.Y;
|
|
|
|
|
BottomPoint = (int)bottomRight.Y;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 22:33:23 +02:00
|
|
|
|
public CustomRectangle(int left, int right, int top, int bottom)
|
|
|
|
|
{
|
|
|
|
|
LeftPoint = left;
|
|
|
|
|
RightPoint = right;
|
|
|
|
|
TopPoint = top;
|
|
|
|
|
BottomPoint = bottom;
|
2019-10-27 02:28:56 +02:00
|
|
|
|
|
|
|
|
|
TopLeftPoint = new OpenTK.Vector2(left,top);
|
|
|
|
|
TopRightPoint = new OpenTK.Vector2(right, top);
|
|
|
|
|
BottomLeftPoint = new OpenTK.Vector2(left, bottom);
|
|
|
|
|
BottomRightPoint = new OpenTK.Vector2(right, bottom);
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
2019-09-03 01:48:47 +02:00
|
|
|
|
|
2019-10-05 21:32:48 +02:00
|
|
|
|
public CustomRectangle RotateZ(float rotate)
|
|
|
|
|
{
|
2019-10-27 02:28:56 +02:00
|
|
|
|
var topLeft = RotateZPoint(TopLeftPoint.X, TopLeftPoint.Y, rotate).Xy;
|
|
|
|
|
var topRight = RotateZPoint(TopRightPoint.X, TopRightPoint.Y, rotate).Xy;
|
|
|
|
|
var bottomLeft = RotateZPoint(BottomLeftPoint.X, BottomLeftPoint.Y, rotate).Xy;
|
|
|
|
|
var bottomRight = RotateZPoint(BottomRightPoint.X, BottomRightPoint.Y, rotate).Xy;
|
2019-10-05 21:32:48 +02:00
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
return new CustomRectangle(
|
2019-10-27 02:28:56 +02:00
|
|
|
|
topLeft,
|
|
|
|
|
topRight,
|
|
|
|
|
bottomLeft,
|
|
|
|
|
bottomRight);
|
2019-10-06 03:15:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-27 02:28:56 +02:00
|
|
|
|
private OpenTK.Vector3 RotateZPoint(float p1, float p2, float rotate)
|
2019-10-06 03:15:19 +02:00
|
|
|
|
{
|
2019-10-27 02:28:56 +02:00
|
|
|
|
var rotatioZ = OpenTK.Matrix4.CreateRotationZ(OpenTK.MathHelper.DegreesToRadians(rotate));
|
|
|
|
|
return OpenTK.Vector3.TransformPosition(new OpenTK.Vector3(p1, p2, 0), rotatioZ);
|
2019-10-06 03:15:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 23:48:52 +02:00
|
|
|
|
public CustomRectangle GetTransformedRectangle(BasePane parent, Vector3F Transform, Vector3F Rotate, Vector2F scale)
|
2019-10-06 03:15:19 +02:00
|
|
|
|
{
|
2019-10-27 02:28:56 +02:00
|
|
|
|
var sca = new OpenTK.Vector2(scale.X, scale.Y);
|
|
|
|
|
var pos = new OpenTK.Vector2(Transform.X, Transform.Y);
|
|
|
|
|
|
2019-10-06 03:15:19 +02:00
|
|
|
|
var rect = this.RotateZ(Rotate.Z);
|
|
|
|
|
rect = new CustomRectangle(
|
2019-10-27 02:28:56 +02:00
|
|
|
|
(rect.TopLeftPoint * sca) + pos,
|
|
|
|
|
(rect.TopRightPoint * sca) + pos,
|
|
|
|
|
(rect.BottomLeftPoint * sca) + pos,
|
|
|
|
|
(rect.BottomRightPoint * sca) + pos);
|
2019-10-05 19:25:28 +02:00
|
|
|
|
|
|
|
|
|
if (parent != null)
|
|
|
|
|
return parent.TransformParent(rect);
|
|
|
|
|
else
|
|
|
|
|
return rect;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 23:48:52 +02:00
|
|
|
|
public int Width
|
2019-09-03 01:48:47 +02:00
|
|
|
|
{
|
|
|
|
|
get { return LeftPoint - RightPoint; }
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 23:48:52 +02:00
|
|
|
|
public int Height
|
2019-09-03 01:48:47 +02:00
|
|
|
|
{
|
|
|
|
|
get { return TopPoint - BottomPoint; }
|
|
|
|
|
}
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|
2019-08-31 00:53:45 +02:00
|
|
|
|
|
2020-02-12 01:19:23 +01:00
|
|
|
|
public class CNT1 : SectionCommon
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public CNT1(FileReader reader, Cafe.Header header)
|
|
|
|
|
{
|
|
|
|
|
uint paneNamesOffset = 0;
|
|
|
|
|
uint paneCount = 0;
|
|
|
|
|
uint animCount = 0;
|
|
|
|
|
uint controlUserNameOffset = 0;
|
|
|
|
|
uint paneParamNamesOffset = 0;
|
|
|
|
|
uint animParamNamesOffset = 0;
|
|
|
|
|
|
|
|
|
|
if (header.VersionMajor < 3)
|
|
|
|
|
{
|
|
|
|
|
paneNamesOffset = reader.ReadUInt32();
|
|
|
|
|
paneCount = reader.ReadUInt32();
|
|
|
|
|
animCount = reader.ReadUInt32();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
controlUserNameOffset = reader.ReadUInt32();
|
|
|
|
|
paneNamesOffset = reader.ReadUInt32();
|
|
|
|
|
paneCount = reader.ReadUInt16();
|
|
|
|
|
animCount = reader.ReadUInt16();
|
|
|
|
|
paneParamNamesOffset = reader.ReadUInt32();
|
|
|
|
|
animParamNamesOffset = reader.ReadUInt32();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Name = reader.ReadZeroTerminatedString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Write(FileWriter writer, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class GroupPane : BasePane
|
|
|
|
|
{
|
|
|
|
|
public override string Signature { get; } = "grp1";
|
|
|
|
|
|
|
|
|
|
public List<string> Panes { get; set; } = new List<string>();
|
|
|
|
|
|
|
|
|
|
private bool displayInEditor = true;
|
|
|
|
|
internal override bool DisplayInEditor
|
|
|
|
|
{
|
|
|
|
|
get { return displayInEditor; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
displayInEditor = value;
|
|
|
|
|
for (int i = 0; i < Panes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var pane = SearchPane(Panes[i]);
|
|
|
|
|
if (pane != null)
|
|
|
|
|
pane.DisplayInEditor = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GroupPane() : base()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class FNL1 : SectionCommon
|
|
|
|
|
{
|
|
|
|
|
public List<string> Fonts { get; set; }
|
|
|
|
|
|
|
|
|
|
public FNL1()
|
|
|
|
|
{
|
|
|
|
|
Fonts = new List<string>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FNL1(FileReader reader, BxlytHeader header) : base() {
|
|
|
|
|
Fonts = StringList.Read(reader, header);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Write(FileWriter writer, LayoutHeader header) {
|
|
|
|
|
StringList.Write(Fonts, writer, header);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TXL1 : SectionCommon
|
|
|
|
|
{
|
|
|
|
|
public List<string> Textures { get; set; }
|
|
|
|
|
|
|
|
|
|
public TXL1()
|
|
|
|
|
{
|
|
|
|
|
Textures = new List<string>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TXL1(FileReader reader, BxlytHeader header) : base() {
|
|
|
|
|
Textures = StringList.Read(reader, header);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Write(FileWriter writer, LayoutHeader header) {
|
|
|
|
|
StringList.Write(Textures, writer, header);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class StringList
|
|
|
|
|
{
|
|
|
|
|
public static List<string> Read(FileReader reader, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
List<string> values = new List<string>();
|
|
|
|
|
|
|
|
|
|
ushort count = reader.ReadUInt16();
|
|
|
|
|
reader.Seek(2); //padding
|
|
|
|
|
|
|
|
|
|
long pos = reader.Position;
|
|
|
|
|
if (header is BRLYT.Header)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
uint offset = reader.ReadUInt32();
|
|
|
|
|
reader.ReadUInt32(); //padding
|
|
|
|
|
using (reader.TemporarySeek(offset + pos, SeekOrigin.Begin)) {
|
|
|
|
|
values.Add(reader.ReadZeroTerminatedString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
uint[] offsets = reader.ReadUInt32s(count);
|
|
|
|
|
for (int i = 0; i < offsets.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
reader.SeekBegin(offsets[i] + pos);
|
|
|
|
|
values.Add(reader.ReadZeroTerminatedString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Write(List<string> values,
|
|
|
|
|
FileWriter writer, LayoutHeader header)
|
|
|
|
|
{
|
|
|
|
|
writer.Write((ushort)values.Count);
|
|
|
|
|
writer.Write((ushort)0);
|
|
|
|
|
|
|
|
|
|
//Fill empty spaces for offsets later
|
|
|
|
|
long pos = writer.Position;
|
|
|
|
|
|
|
|
|
|
if (header is BRLYT.Header)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(new uint[values.Count * 2]);
|
|
|
|
|
|
|
|
|
|
//Save offsets and strings
|
|
|
|
|
for (int i = 0; i < values.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteUint32Offset(pos + (i * 8), pos);
|
|
|
|
|
writer.WriteString(values[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
writer.Write(new uint[values.Count]);
|
|
|
|
|
|
|
|
|
|
//Save offsets and strings
|
|
|
|
|
for (int i = 0; i < values.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteUint32Offset(pos + (i * 4), pos);
|
|
|
|
|
writer.WriteString(values[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LayoutInfo : SectionCommon
|
|
|
|
|
{
|
|
|
|
|
public bool DrawFromCenter { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Canvas Width"), CategoryAttribute("Layout")]
|
|
|
|
|
public float Width { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Canvas Height"), CategoryAttribute("Layout")]
|
|
|
|
|
public float Height { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Layout Name"), CategoryAttribute("Layout")]
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public LayoutInfo()
|
|
|
|
|
{
|
|
|
|
|
DrawFromCenter = false;
|
|
|
|
|
Width = 0;
|
|
|
|
|
Height = 0;
|
|
|
|
|
Name = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public class LayoutControlDocked : Toolbox.Library.Forms.STUserControl
|
|
|
|
|
{
|
|
|
|
|
public DockContent DockContent;
|
2019-09-10 00:37:33 +02:00
|
|
|
|
|
2019-09-28 23:27:48 +02:00
|
|
|
|
public DockPane Pane => DockContent?.Pane;
|
|
|
|
|
}
|
2019-09-10 00:37:33 +02:00
|
|
|
|
|
2019-08-31 00:53:45 +02:00
|
|
|
|
public class LayoutDocked : DockContent
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2019-08-29 22:33:23 +02:00
|
|
|
|
}
|