@@ -24,8 +24,10 @@ public final class SpriteEntity extends Message<SpriteEntity, SpriteEntity.Build
24
24
25
25
public static final String DEFAULT_IMAGEKEY = "" ;
26
26
27
+ public static final String DEFAULT_MATTEKEY = "" ;
28
+
27
29
/**
28
- * 元件所对应的位图键名, 如果 imageKey 含有 .vector 后缀,该 sprite 为矢量图层。
30
+ * 元件所对应的位图键名, 如果 imageKey 含有 .vector 后缀,该 sprite 为矢量图层 含有 .matte 后缀,该 sprite 为遮罩图层 。
29
31
*/
30
32
@ WireField (
31
33
tag = 1 ,
@@ -43,21 +45,32 @@ public final class SpriteEntity extends Message<SpriteEntity, SpriteEntity.Build
43
45
)
44
46
public final List <FrameEntity > frames ;
45
47
46
- public SpriteEntity (String imageKey , List <FrameEntity > frames ) {
47
- this (imageKey , frames , ByteString .EMPTY );
48
+ /**
49
+ * 被遮罩图层的 matteKey 对应的是其遮罩图层的 imageKey.
50
+ */
51
+ @ WireField (
52
+ tag = 3 ,
53
+ adapter = "com.squareup.wire.ProtoAdapter#STRING"
54
+ )
55
+ public final String matteKey ;
56
+
57
+ public SpriteEntity (String imageKey , List <FrameEntity > frames , String matteKey ) {
58
+ this (imageKey , frames , matteKey , ByteString .EMPTY );
48
59
}
49
60
50
- public SpriteEntity (String imageKey , List <FrameEntity > frames , ByteString unknownFields ) {
61
+ public SpriteEntity (String imageKey , List <FrameEntity > frames , String matteKey , ByteString unknownFields ) {
51
62
super (ADAPTER , unknownFields );
52
63
this .imageKey = imageKey ;
53
64
this .frames = Internal .immutableCopyOf ("frames" , frames );
65
+ this .matteKey = matteKey ;
54
66
}
55
67
56
68
@ Override
57
69
public Builder newBuilder () {
58
70
Builder builder = new Builder ();
59
71
builder .imageKey = imageKey ;
60
72
builder .frames = Internal .copyOf ("frames" , frames );
73
+ builder .matteKey = matteKey ;
61
74
builder .addUnknownFields (unknownFields ());
62
75
return builder ;
63
76
}
@@ -69,7 +82,8 @@ public boolean equals(Object other) {
69
82
SpriteEntity o = (SpriteEntity ) other ;
70
83
return unknownFields ().equals (o .unknownFields ())
71
84
&& Internal .equals (imageKey , o .imageKey )
72
- && frames .equals (o .frames );
85
+ && frames .equals (o .frames )
86
+ && Internal .equals (matteKey , o .matteKey );
73
87
}
74
88
75
89
@ Override
@@ -79,6 +93,7 @@ public int hashCode() {
79
93
result = unknownFields ().hashCode ();
80
94
result = result * 37 + (imageKey != null ? imageKey .hashCode () : 0 );
81
95
result = result * 37 + frames .hashCode ();
96
+ result = result * 37 + (matteKey != null ? matteKey .hashCode () : 0 );
82
97
super .hashCode = result ;
83
98
}
84
99
return result ;
@@ -89,6 +104,7 @@ public String toString() {
89
104
StringBuilder builder = new StringBuilder ();
90
105
if (imageKey != null ) builder .append (", imageKey=" ).append (imageKey );
91
106
if (!frames .isEmpty ()) builder .append (", frames=" ).append (frames );
107
+ if (matteKey != null ) builder .append (", matteKey=" ).append (matteKey );
92
108
return builder .replace (0 , 2 , "SpriteEntity{" ).append ('}' ).toString ();
93
109
}
94
110
@@ -97,12 +113,14 @@ public static final class Builder extends Message.Builder<SpriteEntity, Builder>
97
113
98
114
public List <FrameEntity > frames ;
99
115
116
+ public String matteKey ;
117
+
100
118
public Builder () {
101
119
frames = Internal .newMutableList ();
102
120
}
103
121
104
122
/**
105
- * 元件所对应的位图键名, 如果 imageKey 含有 .vector 后缀,该 sprite 为矢量图层。
123
+ * 元件所对应的位图键名, 如果 imageKey 含有 .vector 后缀,该 sprite 为矢量图层 含有 .matte 后缀,该 sprite 为遮罩图层 。
106
124
*/
107
125
public Builder imageKey (String imageKey ) {
108
126
this .imageKey = imageKey ;
@@ -118,9 +136,17 @@ public Builder frames(List<FrameEntity> frames) {
118
136
return this ;
119
137
}
120
138
139
+ /**
140
+ * 被遮罩图层的 matteKey 对应的是其遮罩图层的 imageKey.
141
+ */
142
+ public Builder matteKey (String matteKey ) {
143
+ this .matteKey = matteKey ;
144
+ return this ;
145
+ }
146
+
121
147
@ Override
122
148
public SpriteEntity build () {
123
- return new SpriteEntity (imageKey , frames , super .buildUnknownFields ());
149
+ return new SpriteEntity (imageKey , frames , matteKey , super .buildUnknownFields ());
124
150
}
125
151
}
126
152
@@ -133,13 +159,15 @@ private static final class ProtoAdapter_SpriteEntity extends ProtoAdapter<Sprite
133
159
public int encodedSize (SpriteEntity value ) {
134
160
return (value .imageKey != null ? ProtoAdapter .STRING .encodedSizeWithTag (1 , value .imageKey ) : 0 )
135
161
+ FrameEntity .ADAPTER .asRepeated ().encodedSizeWithTag (2 , value .frames )
162
+ + (value .matteKey != null ? ProtoAdapter .STRING .encodedSizeWithTag (3 , value .matteKey ) : 0 )
136
163
+ value .unknownFields ().size ();
137
164
}
138
165
139
166
@ Override
140
167
public void encode (ProtoWriter writer , SpriteEntity value ) throws IOException {
141
168
if (value .imageKey != null ) ProtoAdapter .STRING .encodeWithTag (writer , 1 , value .imageKey );
142
169
FrameEntity .ADAPTER .asRepeated ().encodeWithTag (writer , 2 , value .frames );
170
+ if (value .matteKey != null ) ProtoAdapter .STRING .encodeWithTag (writer , 3 , value .matteKey );
143
171
writer .writeBytes (value .unknownFields ());
144
172
}
145
173
@@ -151,6 +179,7 @@ public SpriteEntity decode(ProtoReader reader) throws IOException {
151
179
switch (tag ) {
152
180
case 1 : builder .imageKey (ProtoAdapter .STRING .decode (reader )); break ;
153
181
case 2 : builder .frames .add (FrameEntity .ADAPTER .decode (reader )); break ;
182
+ case 3 : builder .matteKey (ProtoAdapter .STRING .decode (reader )); break ;
154
183
default : {
155
184
FieldEncoding fieldEncoding = reader .peekFieldEncoding ();
156
185
Object value = fieldEncoding .rawProtoAdapter ().decode (reader );
0 commit comments