v0.6.0: adjusted wndbag to be a bit more flexible for future use
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
@@ -80,7 +81,8 @@ public class WndBag extends WndTabbed {
|
|||||||
protected static final int COLS_P = 4;
|
protected static final int COLS_P = 4;
|
||||||
protected static final int COLS_L = 6;
|
protected static final int COLS_L = 6;
|
||||||
|
|
||||||
protected static final int SLOT_SIZE = 28;
|
protected static final int SLOT_WIDTH = 28;
|
||||||
|
protected static final int SLOT_HEIGHT = 28;
|
||||||
protected static final int SLOT_MARGIN = 1;
|
protected static final int SLOT_MARGIN = 1;
|
||||||
|
|
||||||
protected static final int TITLE_HEIGHT = 12;
|
protected static final int TITLE_HEIGHT = 12;
|
||||||
@@ -111,10 +113,10 @@ public class WndBag extends WndTabbed {
|
|||||||
lastBag = bag;
|
lastBag = bag;
|
||||||
|
|
||||||
nCols = ShatteredPixelDungeon.landscape() ? COLS_L : COLS_P;
|
nCols = ShatteredPixelDungeon.landscape() ? COLS_L : COLS_P;
|
||||||
nRows = (Belongings.BACKPACK_SIZE + 4 + 1) / nCols + ((Belongings.BACKPACK_SIZE + 4 + 1) % nCols > 0 ? 1 : 0);
|
nRows = (int)Math.ceil((Belongings.BACKPACK_SIZE + 4 + 1) / (float)nCols);
|
||||||
|
|
||||||
int slotsWidth = SLOT_SIZE * nCols + SLOT_MARGIN * (nCols - 1);
|
int slotsWidth = SLOT_WIDTH * nCols + SLOT_MARGIN * (nCols - 1);
|
||||||
int slotsHeight = SLOT_SIZE * nRows + SLOT_MARGIN * (nRows - 1);
|
int slotsHeight = SLOT_HEIGHT * nRows + SLOT_MARGIN * (nRows - 1);
|
||||||
|
|
||||||
RenderedText txtTitle = PixelScene.renderText( title != null ? title : Messages.titleCase( bag.name() ), 9 );
|
RenderedText txtTitle = PixelScene.renderText( title != null ? title : Messages.titleCase( bag.name() ), 9 );
|
||||||
txtTitle.hardlight( TITLE_COLOR );
|
txtTitle.hardlight( TITLE_COLOR );
|
||||||
@@ -202,8 +204,8 @@ public class WndBag extends WndTabbed {
|
|||||||
|
|
||||||
protected void placeItem( final Item item ) {
|
protected void placeItem( final Item item ) {
|
||||||
|
|
||||||
int x = col * (SLOT_SIZE + SLOT_MARGIN);
|
int x = col * (SLOT_WIDTH + SLOT_MARGIN);
|
||||||
int y = TITLE_HEIGHT + row * (SLOT_SIZE + SLOT_MARGIN);
|
int y = TITLE_HEIGHT + row * (SLOT_HEIGHT + SLOT_MARGIN);
|
||||||
|
|
||||||
add( new ItemButton( item ).setPos( x, y ) );
|
add( new ItemButton( item ).setPos( x, y ) );
|
||||||
|
|
||||||
@@ -329,12 +331,13 @@ public class WndBag extends WndTabbed {
|
|||||||
bg.visible = false;
|
bg.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
width = height = SLOT_SIZE;
|
width = SLOT_WIDTH;
|
||||||
|
height = SLOT_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createChildren() {
|
protected void createChildren() {
|
||||||
bg = new ColorBlock( SLOT_SIZE, SLOT_SIZE, NORMAL );
|
bg = new ColorBlock( SLOT_WIDTH, SLOT_HEIGHT, NORMAL );
|
||||||
add( bg );
|
add( bg );
|
||||||
|
|
||||||
super.createChildren();
|
super.createChildren();
|
||||||
|
|||||||
Reference in New Issue
Block a user