Skip to content

Commit

Permalink
Improving JSON consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-rosso committed Nov 2, 2018
1 parent d9596a4 commit 517e001
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 71 deletions.
63 changes: 31 additions & 32 deletions lib/nima/actor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,37 @@ import "readers/stream_reader.dart";

const Map<String, int> BlockTypesMap =
{
"Unknown": BlockTypes.Unknown,
"Nodes": BlockTypes.Components,
"ActorNode": BlockTypes.ActorNode,
"ActorBone": BlockTypes.ActorBone,
"ActorRootBone": BlockTypes.ActorRootBone,
"ActorImage": BlockTypes.ActorImage,
"View": BlockTypes.View,
"Animation": BlockTypes.Animation,
"Animations": BlockTypes.Animations,
"Atlases": BlockTypes.Atlases,
"Atlas": BlockTypes.Atlas,
"ActorIKTarget": BlockTypes.ActorIKTarget,
"ActorEvent": BlockTypes.ActorEvent,
"CustomIntProperty": BlockTypes.CustomIntProperty,
"CustomFloatProperty": BlockTypes.CustomFloatProperty,
"CustomStringProperty": BlockTypes.CustomStringProperty,
"CustomBooleanProperty": BlockTypes.CustomBooleanProperty,
"ActorColliderRectangle": BlockTypes.ActorColliderRectangle,
"ActorColliderTriangle": BlockTypes.ActorColliderTriangle,
"ActorColliderCircle": BlockTypes.ActorColliderCircle,
"ActorColliderPolygon": BlockTypes.ActorColliderPolygon,
"ActorColliderLine": BlockTypes.ActorColliderLine,
"ActorImageSequence": BlockTypes.ActorImageSequence,
"ActorNodeSolo": BlockTypes.ActorNodeSolo,
"JellyComponent": BlockTypes.JellyComponent,
"ActorJellyBone": BlockTypes.ActorJellyBone,
"ActorIKConstraint": BlockTypes.ActorIKConstraint,
"ActorDistanceConstraint": BlockTypes.ActorDistanceConstraint,
"ActorTranslationConstraint": BlockTypes.ActorTranslationConstraint,
"ActorRotationConstraint": BlockTypes.ActorRotationConstraint,
"ActorScaleConstraint": BlockTypes.ActorScaleConstraint,
"ActorTransformConstraint": BlockTypes.ActorTransformConstraint
"unknown": BlockTypes.Unknown,
"nodes": BlockTypes.Components,
"node": BlockTypes.ActorNode,
"bone": BlockTypes.ActorBone,
"rootBone": BlockTypes.ActorRootBone,
"image": BlockTypes.ActorImage,
"view": BlockTypes.View,
"animation": BlockTypes.Animation,
"animations": BlockTypes.Animations,
"atlases": BlockTypes.Atlases,
"atlas": BlockTypes.Atlas,
"event": BlockTypes.ActorEvent,
"customInt": BlockTypes.CustomIntProperty,
"customFloat": BlockTypes.CustomFloatProperty,
"customString": BlockTypes.CustomStringProperty,
"customBoolean": BlockTypes.CustomBooleanProperty,
"rectangleCollider": BlockTypes.ActorColliderRectangle,
"triangleCollider": BlockTypes.ActorColliderTriangle,
"circleCollider": BlockTypes.ActorColliderCircle,
"polygonCollider": BlockTypes.ActorColliderPolygon,
"lineCollider": BlockTypes.ActorColliderLine,
"imageSequence": BlockTypes.ActorImageSequence,
"solo": BlockTypes.ActorNodeSolo,
"jelly": BlockTypes.JellyComponent,
"jellyBone": BlockTypes.ActorJellyBone,
"ikConstraint": BlockTypes.ActorIKConstraint,
"distanceConstraint": BlockTypes.ActorDistanceConstraint,
"translationConstraint": BlockTypes.ActorTranslationConstraint,
"rotationConstraint": BlockTypes.ActorRotationConstraint,
"scaleConstraint": BlockTypes.ActorScaleConstraint,
"transformConstraint": BlockTypes.ActorTransformConstraint
};

class BlockTypes
Expand Down
2 changes: 1 addition & 1 deletion lib/nima/actor_ik_constraint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ActorIKConstraint extends ActorTargetedConstraint
ActorTargetedConstraint.read(actor, reader, component);
component._invertDirection = reader.readBool("isInverted");

reader.openArray("InfluencedBones");
reader.openArray("bones");
int numInfluencedBones = reader.readUint8Length();
if(numInfluencedBones > 0)
{
Expand Down
10 changes: 5 additions & 5 deletions lib/nima/actor_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class ActorImage extends ActorNode
node.drawOrder = reader.readUint16("drawOrder");
node._textureIndex = reader.readUint8("atlas");

reader.openArray("ConnectedBones");
reader.openArray("bones");
int numConnectedBones = reader.readUint8Length();
if(numConnectedBones != 0)
{
Expand Down Expand Up @@ -348,7 +348,7 @@ class ActorImage extends ActorNode

if(node._textureIndex != -1)
{
reader.openArray("FrameAssets");
reader.openArray("frames");
int frameAssetCount = reader.readUint16Length();
// node._sequenceFrames = [];
Float32List uvs = new Float32List(node._vertexCount*2*frameAssetCount);
Expand All @@ -374,11 +374,11 @@ class ActorImage extends ActorNode
int offset = uvStride;
for(int i = 1; i < frameAssetCount; i++)
{
reader.openObject("frameAsset");
reader.openObject("frame");

SequenceFrame frame = new SequenceFrame(reader.readUint8("atlasId"), offset*4);
SequenceFrame frame = new SequenceFrame(reader.readUint8("atlas"), offset*4);
node._sequenceFrames.add(frame);
reader.readFloat32ArrayOffset(uvs, uvStride, offset, "frameUV");
reader.readFloat32ArrayOffset(uvs, uvStride, offset, "uv");
offset += uvStride;

reader.closeObject();
Expand Down
2 changes: 1 addition & 1 deletion lib/nima/actor_jelly_bone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ActorJellyBone extends ActorBoneBase
// of the Jelly Bone are controlled by the Jelly Controller and are unnecessary for serialization.
ActorComponent.read(actor, reader, node);
node.opacity = reader.readFloat32("opacity");
node.collapsedVisibility = reader.readBool("isCollapsedVisibility");
node.collapsedVisibility = reader.readBool("isCollapsed");
return node;
}
}
2 changes: 1 addition & 1 deletion lib/nima/actor_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class ActorNode extends ActorComponent

if(actor.version >= 13)
{
node._isCollapsedVisibility = reader.readBool("isCollapsedVisibility");
node._isCollapsedVisibility = reader.readBool("isCollapsed");
}

return node;
Expand Down
12 changes: 5 additions & 7 deletions lib/nima/animation/actor_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ class PropertyAnimation
break;
}

propertyReader.openArray("KeyFrames");
propertyReader.openArray("frames");
int keyFrameCount = propertyReader.readUint16Length();
propertyAnimation._keyFrames = new List<KeyFrame>(keyFrameCount);
KeyFrame lastKeyFrame;
for(int i = 0; i < keyFrameCount; i++)
{
propertyReader.openObject("KeyFrame");
propertyReader.openObject("frame");
KeyFrame frame = keyFrameReader(propertyReader, component);
propertyAnimation._keyFrames[i] = frame;
if(lastKeyFrame != null)
Expand Down Expand Up @@ -203,19 +203,17 @@ class ComponentAnimation

static ComponentAnimation read(StreamReader reader, List<ActorComponent> components)
{
reader.openObject("node");
reader.openObject("component");
ComponentAnimation componentAnimation = new ComponentAnimation();

componentAnimation._componentIndex = reader.readId("nodeIndex");
reader.openArray("Properties");
componentAnimation._componentIndex = reader.readId("component");
int numProperties = reader.readUint16Length();

componentAnimation._properties = new List<PropertyAnimation>(numProperties);
for(int i = 0; i < numProperties; i++)
{
componentAnimation._properties[i] = PropertyAnimation.read(reader, components[componentAnimation._componentIndex]);
}
reader.closeArray();
reader.closeObject();

return componentAnimation;
Expand Down Expand Up @@ -418,7 +416,7 @@ class ActorAnimation
animation._isLooping = reader.readBool("isLooping");


reader.openArray("KeyedNodes");
reader.openArray("keyed");
int numKeyedComponents = reader.readUint16Length();
//animation._components = new ComponentAnimation[numKeyedComponents];

Expand Down
4 changes: 2 additions & 2 deletions lib/nima/animation/keyframe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ class KeyFrameDrawOrder extends KeyFrame
{
DrawOrderIndex drawOrder = new DrawOrderIndex();
reader.openObject("frame");
drawOrder.nodeIdx = reader.readId("index");
drawOrder.order = reader.readId("nodeId");
drawOrder.nodeIdx = reader.readId("component");
drawOrder.order = reader.readUint16("order");
frame._orderedNodes[i] = drawOrder;
reader.closeObject();
}
Expand Down
38 changes: 19 additions & 19 deletions lib/nima/animation/property_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ class PropertyTypes

const Map<String, int> PropertyTypesMap =
{
"Unknown": PropertyTypes.Unknown,
"PosX": PropertyTypes.PosX,
"PosY": PropertyTypes.PosY,
"ScaleX": PropertyTypes.ScaleX,
"ScaleY": PropertyTypes.ScaleY,
"Rotation": PropertyTypes.Rotation,
"Opacity": PropertyTypes.Opacity,
"DrawOrder": PropertyTypes.DrawOrder,
"Length": PropertyTypes.Length,
"VertexDeform": PropertyTypes.VertexDeform,
"ConstraintStrength": PropertyTypes.ConstraintStrength,
"Trigger": PropertyTypes.Trigger,
"IntProperty": PropertyTypes.IntProperty,
"FloatProperty": PropertyTypes.FloatProperty,
"StringProperty": PropertyTypes.StringProperty,
"BooleanProperty": PropertyTypes.BooleanProperty,
"CollisionEnabled": PropertyTypes.CollisionEnabled,
"Sequence": PropertyTypes.Sequence,
"ActiveChildIndex": PropertyTypes.ActiveChildIndex
"unknown": PropertyTypes.Unknown,
"posX": PropertyTypes.PosX,
"posY": PropertyTypes.PosY,
"scaleX": PropertyTypes.ScaleX,
"scaleY": PropertyTypes.ScaleY,
"rotation": PropertyTypes.Rotation,
"opacity": PropertyTypes.Opacity,
"drawOrder": PropertyTypes.DrawOrder,
"length": PropertyTypes.Length,
"vertices": PropertyTypes.VertexDeform,
"strength": PropertyTypes.ConstraintStrength,
"trigger": PropertyTypes.Trigger,
"intValue": PropertyTypes.IntProperty,
"floatValue": PropertyTypes.FloatProperty,
"stringValue": PropertyTypes.StringProperty,
"boolValue": PropertyTypes.BooleanProperty,
"isCollisionEnabled": PropertyTypes.CollisionEnabled,
"sequence": PropertyTypes.Sequence,
"activeChild": PropertyTypes.ActiveChildIndex
};
6 changes: 3 additions & 3 deletions lib/nima/animation/value_time_curve_interpolator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ class ValueTimeCurveInterpolator extends KeyFrameInterpolator
case InterpolationTypes.Mirrored:
case InterpolationTypes.Asymmetric:
case InterpolationTypes.Disconnected:
vtci._inFactor = reader.readFloat64("clampedInFactor");
vtci._inFactor = reader.readFloat64("inFactor");
vtci._inValue = reader.readFloat32("inValue");
vtci._outFactor = reader.readFloat64("clampedOutFactor");
vtci._outFactor = reader.readFloat64("outFactor");
vtci._outValue = reader.readFloat32("outValue");
return vtci;

case InterpolationTypes.Hold:
vtci._inFactor = reader.readFloat64("clampedInFactor");
vtci._inFactor = reader.readFloat64("inFactor");
vtci._inValue = reader.readFloat32("inValue");
vtci._outFactor = 0.0;
vtci._outValue = 0.0;
Expand Down

0 comments on commit 517e001

Please sign in to comment.