public boolean addSlot(Stitcher.Holder par1StitchHolder) { if (this.holder != null) { return false; } else { int i = par1StitchHolder.getWidth(); int j = par1StitchHolder.getHeight(); if (i <= this.width && j <= this.height) { if (i == this.width && j == this.height) { this.holder = par1StitchHolder; return true; } else { if (this.subSlots == null) { this.subSlots = new ArrayList(1); this.subSlots.add(new Stitcher.Slot(this.originX, this.originY, i, j)); int k = this.width - i; int l = this.height - j; if (l > 0 && k > 0) { int i1 = Math.max(this.height, k); int j1 = Math.max(this.width, l); if (i1 >= j1) { this.subSlots.add(new Stitcher.Slot(this.originX, this.originY + j, i, l)); this.subSlots.add( new Stitcher.Slot(this.originX + i, this.originY, k, this.height)); } else { this.subSlots.add(new Stitcher.Slot(this.originX + i, this.originY, k, j)); this.subSlots.add( new Stitcher.Slot(this.originX, this.originY + j, this.width, l)); } } else if (k == 0) { this.subSlots.add(new Stitcher.Slot(this.originX, this.originY + j, i, l)); } else if (l == 0) { this.subSlots.add(new Stitcher.Slot(this.originX + i, this.originY, k, j)); } } Iterator iterator = this.subSlots.iterator(); Stitcher.Slot slot; do { if (!iterator.hasNext()) { return false; } slot = (Stitcher.Slot) iterator.next(); } while (!slot.addSlot(par1StitchHolder)); return true; } } else { return false; } } }
/** Gets the slot and all its subslots */ public void getAllStitchSlots(List par1List) { if (this.holder != null) { par1List.add(this); } else if (this.subSlots != null) { Iterator iterator = this.subSlots.iterator(); while (iterator.hasNext()) { Stitcher.Slot slot = (Stitcher.Slot) iterator.next(); slot.getAllStitchSlots(par1List); } } }
public List getStichSlots() { ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.stitchSlots.iterator(); while (iterator.hasNext()) { Stitcher.Slot slot = (Stitcher.Slot) iterator.next(); slot.getAllStitchSlots(arraylist); } ArrayList arraylist1 = Lists.newArrayList(); Iterator iterator1 = arraylist.iterator(); while (iterator1.hasNext()) { Stitcher.Slot slot1 = (Stitcher.Slot) iterator1.next(); Stitcher.Holder holder = slot1.getStitchHolder(); TextureAtlasSprite textureatlassprite = holder.getAtlasSprite(); textureatlassprite.initSprite( this.currentWidth, this.currentHeight, slot1.getOriginX(), slot1.getOriginY(), holder.isRotated()); arraylist1.add(textureatlassprite); } return arraylist1; }
/** Expand stitched texture in order to make space for specified tile */ private boolean expandAndAllocateSlot(Stitcher.Holder par1StitchHolder) { int i = Math.min(par1StitchHolder.getWidth(), par1StitchHolder.getHeight()); boolean flag = this.currentWidth == 0 && this.currentHeight == 0; boolean flag1; int j; if (this.forcePowerOf2) { j = MathHelper.roundUpToPowerOfTwo(this.currentWidth); int k = MathHelper.roundUpToPowerOfTwo(this.currentHeight); int l = MathHelper.roundUpToPowerOfTwo(this.currentWidth + i); int i1 = MathHelper.roundUpToPowerOfTwo(this.currentHeight + i); boolean flag2 = l <= this.maxWidth; boolean flag3 = i1 <= this.maxHeight; if (!flag2 && !flag3) { return false; } boolean flag4 = j != l; boolean flag5 = k != i1; if (flag4 ^ flag5) { flag1 = flag5 && flag3; // Forge: Bug fix: Attempt to fill all downward space before expanding // width } else { flag1 = flag2 && j <= k; } } else { boolean flag6 = this.currentWidth + i <= this.maxWidth; boolean flag7 = this.currentHeight + i <= this.maxHeight; if (!flag6 && !flag7) { return false; } flag1 = flag6 && (flag || this.currentWidth <= this.currentHeight); } j = Math.max(par1StitchHolder.getWidth(), par1StitchHolder.getHeight()); if (MathHelper.roundUpToPowerOfTwo((flag1 ? this.currentHeight : this.currentWidth) + j) > (flag1 ? this.maxHeight : this.maxWidth)) { return false; } else { Stitcher.Slot slot; if (flag1) { if (par1StitchHolder.getWidth() > par1StitchHolder.getHeight()) { par1StitchHolder.rotate(); } if (this.currentHeight == 0) { this.currentHeight = par1StitchHolder.getHeight(); } slot = new Stitcher.Slot( this.currentWidth, 0, par1StitchHolder.getWidth(), this.currentHeight); this.currentWidth += par1StitchHolder.getWidth(); } else { slot = new Stitcher.Slot( 0, this.currentHeight, this.currentWidth, par1StitchHolder.getHeight()); this.currentHeight += par1StitchHolder.getHeight(); } slot.addSlot(par1StitchHolder); this.stitchSlots.add(slot); return true; } }