Skip to content

Commit

Permalink
add clipping mask node
Browse files Browse the repository at this point in the history
  • Loading branch information
0ceal0t committed Aug 6, 2024
1 parent 02b9089 commit e61f2a9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.IO;
using VfxEditor.Parsing.Int;
using VfxEditor.UldFormat.PartList;

namespace VfxEditor.UldFormat.Component.Node.Data {
public class ClippingMaskNodeData : UldGenericData {
private readonly ParsedIntSelect<UldPartList> PartListId;
private readonly ParsedUIntPicker<UldPartItem> PartId;

public ClippingMaskNodeData() {
PartListId = new( "Part List", 0,
() => Plugin.UldManager.File.PartsSplitView,
( UldPartList item ) => ( int )item.Id.Value,
( UldPartList item, int _ ) => item.GetText()
);
PartId = new( "Part",
() => PartListId.Selected?.Parts,
( UldPartItem item, int idx ) => item.GetText( idx ),
null
);
}

public override void Read( BinaryReader reader ) {
PartListId.Read( reader );
PartId.Read( reader );
}

public override void Write( BinaryWriter writer ) {
PartListId.Write( writer );
PartId.Write( writer );
}

public override void Draw() {
PartListId.Draw();
PartId.Draw();
PartId.Selected?.DrawImage( false );
}
}
}
22 changes: 12 additions & 10 deletions VFXEditor/Formats/UldFormat/Component/Node/UldNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum NodeType : int {
NineGrid = 4,
Counter = 5,
Collision = 8,
ClippingMask = 10,
}

[Flags]
Expand Down Expand Up @@ -78,9 +79,9 @@ public class UldNode : UldWorkspaceItem, IItemWithData<UldGenericData> {
);

// need to wait until all components are initialized, so store this until then
private readonly long DelayedPosition;
private readonly int DelayedSize;
private readonly int DelayedNodeType;
private readonly long _Position;
private readonly int _Size;
private readonly int _Type;

public UldNode( uint id, List<UldComponent> components, UldWorkspaceItem parent, SelectView<UldNode> nodeView ) : base( id ) {
Parent = parent;
Expand Down Expand Up @@ -154,22 +155,22 @@ public UldNode( BinaryReader reader, List<UldComponent> components, UldWorkspace
Parsed.ForEach( x => x.Read( reader ) );
TimelineId.Read( reader );

DelayedPosition = reader.BaseStream.Position;
DelayedSize = ( int )( pos + size - reader.BaseStream.Position ) - 12;
DelayedNodeType = nodeType;
_Position = reader.BaseStream.Position;
_Size = ( int )( pos + size - reader.BaseStream.Position ) - 12;
_Type = nodeType;

reader.BaseStream.Position = pos + size;
}

// Needs to be initialized later since it depends on component list being filled
public void InitData( BinaryReader reader ) {
reader.BaseStream.Position = DelayedPosition;
reader.BaseStream.Position = _Position;

UpdateData();
if( Data == null && DelayedNodeType > 1 ) {
Dalamud.Log( $"Unknown node type {DelayedNodeType} / {DelayedSize} @ {reader.BaseStream.Position:X8}" );
if( Data == null && _Type > 1 ) {
Dalamud.Log( $"Unknown node type {_Type} / {_Size} @ {reader.BaseStream.Position:X8}" );
}
if( Data is BaseNodeData custom ) custom.Read( reader, DelayedSize );
if( Data is BaseNodeData custom ) custom.Read( reader, _Size );
else Data?.Read( reader );
}

Expand Down Expand Up @@ -230,6 +231,7 @@ public void UpdateData() {
NodeType.NineGrid => new NineGridNodeData(),
NodeType.Counter => new CounterNodeData(),
NodeType.Collision => new CollisionNodeData(),
NodeType.ClippingMask => new ClippingMaskNodeData(),
_ => null
};
}
Expand Down

0 comments on commit e61f2a9

Please sign in to comment.