|
209 | 209 | // WIDGET //
|
210 | 210 | ////////////
|
211 | 211 |
|
212 |
| - parser.widgetAttributes = function(widget, json){ |
| 212 | + parser.widgetAttributes = function(widget, json) { |
213 | 213 | widget.setCascadeColorEnabled(true);
|
214 | 214 | widget.setCascadeOpacityEnabled(true);
|
215 | 215 |
|
|
219 | 219 | setContentSize(widget, json["Size"]);
|
220 | 220 |
|
221 | 221 | var name = json["Name"];
|
222 |
| - if(name) |
| 222 | + if (name) |
223 | 223 | widget.setName(name);
|
224 | 224 |
|
225 | 225 | var actionTag = json["ActionTag"] || 0;
|
226 | 226 | widget.setActionTag(actionTag);
|
227 | 227 | widget.setUserObject(new ccs.ActionTimelineData(actionTag));
|
228 | 228 |
|
229 | 229 | var rotationSkewX = json["RotationSkewX"];
|
230 |
| - if(rotationSkewX) |
| 230 | + if (rotationSkewX) |
231 | 231 | widget.setRotationX(rotationSkewX);
|
232 | 232 |
|
233 | 233 | var rotationSkewY = json["RotationSkewY"];
|
234 |
| - if(rotationSkewY) |
| 234 | + if (rotationSkewY) |
235 | 235 | widget.setRotationY(rotationSkewY);
|
236 | 236 |
|
237 | 237 | //var rotation = json["Rotation"];
|
238 | 238 |
|
239 | 239 | var flipX = json["FlipX"];
|
240 |
| - if(flipX) |
| 240 | + if (flipX) |
241 | 241 | widget.setFlippedX(true);
|
242 | 242 |
|
243 | 243 | var flipY = json["FlipY"];
|
244 |
| - if(flipY) |
| 244 | + if (flipY) |
245 | 245 | widget.setFlippedY(true);
|
246 | 246 |
|
247 | 247 | var zOrder = json["zOrder"];
|
248 |
| - if(zOrder != null) |
| 248 | + if (zOrder != null) |
249 | 249 | widget.setLocalZOrder(zOrder);
|
250 | 250 |
|
251 | 251 | //var visible = json["Visible"];
|
|
254 | 254 | widget.setVisible(visible);
|
255 | 255 |
|
256 | 256 | var alpha = json["Alpha"];
|
257 |
| - if(alpha != null) |
| 257 | + if (alpha != null) |
258 | 258 | widget.setOpacity(alpha);
|
259 | 259 |
|
260 | 260 | widget.setTag(json["Tag"] || 0);
|
|
265 | 265 | // -- var frameEvent = json["FrameEvent"];
|
266 | 266 |
|
267 | 267 | var callBackType = json["CallBackType"];
|
268 |
| - if(callBackType != null) |
| 268 | + if (callBackType != null) |
269 | 269 | widget.setCallbackType(callBackType);
|
270 | 270 |
|
271 | 271 | var callBackName = json["CallBackName"];
|
272 |
| - if(callBackName) |
| 272 | + if (callBackName) |
273 | 273 | widget.setCallbackName(callBackName);
|
274 | 274 |
|
275 | 275 | var position = json["Position"];
|
276 |
| - if(position != null) |
| 276 | + if (position != null) |
277 | 277 | widget.setPosition(position["X"] || 0, position["Y"] || 0);
|
278 | 278 |
|
279 | 279 | var scale = json["Scale"];
|
280 |
| - if(scale != null){ |
| 280 | + if (scale != null) { |
281 | 281 | var scaleX = getParam(scale["ScaleX"], 1);
|
282 | 282 | var scaleY = getParam(scale["ScaleY"], 1);
|
283 | 283 | widget.setScaleX(scaleX);
|
284 | 284 | widget.setScaleY(scaleY);
|
285 | 285 | }
|
286 | 286 |
|
287 | 287 | var anchorPoint = json["AnchorPoint"];
|
288 |
| - if(anchorPoint != null) |
| 288 | + if (anchorPoint != null) |
289 | 289 | widget.setAnchorPoint(anchorPoint["ScaleX"] || 0, anchorPoint["ScaleY"] || 0);
|
290 | 290 |
|
291 | 291 | var color = json["CColor"];
|
292 |
| - if(color != null) |
| 292 | + if (color != null) |
293 | 293 | widget.setColor(getColor(color));
|
294 | 294 |
|
295 |
| - if(widget instanceof ccui.Layout){ |
296 |
| - var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); |
297 |
| - |
298 |
| - var positionXPercentEnabled = json["PositionPercentXEnable"] || false; |
299 |
| - var positionYPercentEnabled = json["PositionPercentYEnable"] || false; |
300 |
| - var positionXPercent = 0, |
301 |
| - positionYPercent = 0, |
302 |
| - PrePosition = json["PrePosition"]; |
303 |
| - if(PrePosition != null){ |
304 |
| - positionXPercent = PrePosition["X"] || 0; |
305 |
| - positionYPercent = PrePosition["Y"] || 0; |
306 |
| - } |
307 |
| - var sizeXPercentEnable = json["PercentWidthEnable"] || false; |
308 |
| - var sizeYPercentEnable = json["PercentHeightEnable"] || false; |
309 |
| - var sizeXPercent = 0, |
310 |
| - sizeYPercent = 0, |
311 |
| - PreSize = json["PreSize"]; |
312 |
| - if(PrePosition != null){ |
313 |
| - sizeXPercent = PreSize["X"] || 0; |
314 |
| - sizeYPercent = PreSize["Y"] || 0; |
315 |
| - } |
316 |
| - var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; |
317 |
| - var stretchVerticalEnabled = json["StretchHeightEnable"] || false; |
318 |
| - var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; |
319 |
| - var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; |
320 |
| - var leftMargin = json["LeftMargin"] || 0; |
321 |
| - var rightMargin = json["RightMargin"] || 0; |
322 |
| - var topMargin = json["TopMargin"] || 0; |
323 |
| - var bottomMargin = json["BottomMargin"] || 0; |
324 |
| - |
325 |
| - layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); |
326 |
| - layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); |
327 |
| - layoutComponent.setPositionPercentX(positionXPercent); |
328 |
| - layoutComponent.setPositionPercentY(positionYPercent); |
329 |
| - layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); |
330 |
| - layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); |
331 |
| - layoutComponent.setPercentWidth(sizeXPercent); |
332 |
| - layoutComponent.setPercentHeight(sizeYPercent); |
333 |
| - layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); |
334 |
| - layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); |
335 |
| - |
336 |
| - var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; |
337 |
| - if (horizontalEdge == "LeftEdge"){ |
338 |
| - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; |
339 |
| - }else if (horizontalEdge == "RightEdge"){ |
340 |
| - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; |
341 |
| - }else if (horizontalEdge == "BothEdge"){ |
342 |
| - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; |
343 |
| - } |
344 |
| - layoutComponent.setHorizontalEdge(horizontalEdgeType); |
345 |
| - |
346 |
| - var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; |
347 |
| - if (verticalEdge == "TopEdge"){ |
348 |
| - verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; |
349 |
| - }else if (verticalEdge == "BottomEdge"){ |
350 |
| - verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; |
351 |
| - }else if (verticalEdge == "BothEdge"){ |
352 |
| - verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; |
353 |
| - } |
354 |
| - layoutComponent.setVerticalEdge(verticalEdgeType); |
| 295 | + var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); |
355 | 296 |
|
356 |
| - layoutComponent.setTopMargin(topMargin); |
357 |
| - layoutComponent.setBottomMargin(bottomMargin); |
358 |
| - layoutComponent.setLeftMargin(leftMargin); |
359 |
| - layoutComponent.setRightMargin(rightMargin); |
| 297 | + var positionXPercentEnabled = json["PositionPercentXEnable"] || false; |
| 298 | + var positionYPercentEnabled = json["PositionPercentYEnable"] || false; |
| 299 | + var positionXPercent = 0, |
| 300 | + positionYPercent = 0, |
| 301 | + PrePosition = json["PrePosition"]; |
| 302 | + if (PrePosition != null) { |
| 303 | + positionXPercent = PrePosition["X"] || 0; |
| 304 | + positionYPercent = PrePosition["Y"] || 0; |
| 305 | + } |
| 306 | + var sizeXPercentEnable = json["PercentWidthEnable"] || false; |
| 307 | + var sizeYPercentEnable = json["PercentHeightEnable"] || false; |
| 308 | + var sizeXPercent = 0, |
| 309 | + sizeYPercent = 0, |
| 310 | + PreSize = json["PreSize"]; |
| 311 | + if (PrePosition != null) { |
| 312 | + sizeXPercent = PreSize["X"] || 0; |
| 313 | + sizeYPercent = PreSize["Y"] || 0; |
| 314 | + } |
| 315 | + var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; |
| 316 | + var stretchVerticalEnabled = json["StretchHeightEnable"] || false; |
| 317 | + var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; |
| 318 | + var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; |
| 319 | + var leftMargin = json["LeftMargin"] || 0; |
| 320 | + var rightMargin = json["RightMargin"] || 0; |
| 321 | + var topMargin = json["TopMargin"] || 0; |
| 322 | + var bottomMargin = json["BottomMargin"] || 0; |
| 323 | + |
| 324 | + layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); |
| 325 | + layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); |
| 326 | + layoutComponent.setPositionPercentX(positionXPercent); |
| 327 | + layoutComponent.setPositionPercentY(positionYPercent); |
| 328 | + layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); |
| 329 | + layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); |
| 330 | + layoutComponent.setPercentWidth(sizeXPercent); |
| 331 | + layoutComponent.setPercentHeight(sizeYPercent); |
| 332 | + layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); |
| 333 | + layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); |
| 334 | + |
| 335 | + var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; |
| 336 | + if (horizontalEdge == "LeftEdge") { |
| 337 | + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; |
| 338 | + } else if (horizontalEdge == "RightEdge") { |
| 339 | + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; |
| 340 | + } else if (horizontalEdge == "BothEdge") { |
| 341 | + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; |
| 342 | + } |
| 343 | + layoutComponent.setHorizontalEdge(horizontalEdgeType); |
| 344 | + |
| 345 | + var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; |
| 346 | + if (verticalEdge == "TopEdge") { |
| 347 | + verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; |
| 348 | + } else if (verticalEdge == "BottomEdge") { |
| 349 | + verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; |
| 350 | + } else if (verticalEdge == "BothEdge") { |
| 351 | + verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; |
360 | 352 | }
|
| 353 | + layoutComponent.setVerticalEdge(verticalEdgeType); |
361 | 354 |
|
| 355 | + layoutComponent.setTopMargin(topMargin); |
| 356 | + layoutComponent.setBottomMargin(bottomMargin); |
| 357 | + layoutComponent.setLeftMargin(leftMargin); |
| 358 | + layoutComponent.setRightMargin(rightMargin); |
362 | 359 | };
|
363 | 360 |
|
364 | 361 | /**
|
|
0 commit comments