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