Change Vanguard to use list view by default

This commit is contained in:
drdev
2014-06-28 04:33:17 +00:00
parent a911e33c44
commit 4173bacca3
5 changed files with 22 additions and 15 deletions

View File

@@ -61,6 +61,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
private final List<Integer> selectedIndices = new ArrayList<Integer>(); private final List<Integer> selectedIndices = new ArrayList<Integer>();
private int columnCount = 4; private int columnCount = 4;
private float scrollHeight = 0;
private ColumnDef pileBy = null; private ColumnDef pileBy = null;
private GroupDef groupBy = null; private GroupDef groupBy = null;
private ItemInfo focalItem; private ItemInfo focalItem;
@@ -529,6 +530,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
group.setBounds(groupX, groupY, groupWidth, y - groupY); group.setBounds(groupX, groupY, groupWidth, y - groupY);
y += PADDING; y += PADDING;
} }
scrollHeight = y;
if (forRefresh) { //refresh ordered items if needed if (forRefresh) { //refresh ordered items if needed
int index = 0; int index = 0;
@@ -551,7 +553,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override @Override
protected float getScrollHeight() { protected float getScrollHeight() {
return groups.get(groups.size() - 1).getBottom() + PADDING; return scrollHeight;
} }
@Override @Override
@@ -776,8 +778,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
ItemInfo itemInfo = orderedItems.get(selectedIndices.get(0)); ItemInfo itemInfo = orderedItems.get(selectedIndices.get(0));
Vector2 screenPos = itemInfo.group.getScreenPosition(); Vector2 screenPos = itemInfo.group.getScreenPosition();
Vector2 relPos = itemInfo.group.getChildRelativePosition(itemInfo); Vector2 relPos = itemInfo.group.getChildRelativePosition(itemInfo);
return new Rectangle(screenPos.x + relPos.x - SEL_BORDER_SIZE, return new Rectangle(screenPos.x + relPos.x - SEL_BORDER_SIZE + itemInfo.group.getLeft(),
screenPos.y + relPos.y - itemInfo.group.getTop() - SEL_BORDER_SIZE, screenPos.y + relPos.y - SEL_BORDER_SIZE,
itemInfo.getWidth() + 2 * SEL_BORDER_SIZE, itemInfo.getHeight() + 2 * SEL_BORDER_SIZE); itemInfo.getWidth() + 2 * SEL_BORDER_SIZE, itemInfo.getHeight() + 2 * SEL_BORDER_SIZE);
} }
@@ -849,7 +851,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
if (items.isEmpty()) { return; } if (items.isEmpty()) { return; }
final float visibleTop = getScrollValue(); final float visibleTop = getScrollValue();
final float visibleBottom = visibleTop + getHeight(); final float visibleBottom = visibleTop + getScroller().getHeight();
for (ItemInfo itemInfo : items) { for (ItemInfo itemInfo : items) {
if (itemInfo.getBottom() < visibleTop) { if (itemInfo.getBottom() < visibleTop) {
continue; continue;
@@ -890,8 +892,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
//provide special override for this function to account for special ItemInfo positioning logic //provide special override for this function to account for special ItemInfo positioning logic
@Override @Override
public Vector2 getChildRelativePosition(FDisplayObject child) { protected Vector2 getChildRelativePosition(FDisplayObject child, float offsetX, float offsetY) {
return new Vector2(child.getLeft() - getScrollLeft(), child.getTop() - getScrollValue()); return new Vector2(child.getLeft() - getScrollLeft() + offsetX - getLeft(), child.getTop() - getScrollValue() + offsetY - getTop());
} }
} }
private class Pile extends FDisplayObject { private class Pile extends FDisplayObject {

View File

@@ -49,14 +49,19 @@ public abstract class ItemView<T extends InventoryItem> {
@Override @Override
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) { protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
onResize(visibleWidth, visibleHeight); onResize(visibleWidth, visibleHeight);
//scroll selection into view whenever view height changes
if (visibleHeight != heightBackup) {
heightBackup = visibleHeight;
scrollSelectionIntoView();
}
return new ScrollBounds(visibleWidth, ItemView.this.getScrollHeight()); return new ScrollBounds(visibleWidth, ItemView.this.getScrollHeight());
} }
protected void setScrollPositionsAfterLayout(float scrollLeft0, float scrollTop0) {
if (getHeight() != heightBackup) {
heightBackup = getHeight();
scrollSelectionIntoView(); //scroll selection into view whenever view height changes
}
else {
super.setScrollPositionsAfterLayout(scrollLeft0, scrollTop0);
}
}
@Override @Override
public boolean tap(float x, float y, int count) { public boolean tap(float x, float y, int count) {
return ItemView.this.tap(x, y, count); return ItemView.this.tap(x, y, count);

View File

@@ -104,11 +104,11 @@ public abstract class FContainer extends FDisplayObject {
} }
} }
public Vector2 getChildRelativePosition(FDisplayObject child) { public final Vector2 getChildRelativePosition(FDisplayObject child) {
return getChildRelativePosition(child, 0, 0); return getChildRelativePosition(child, 0, 0);
} }
private Vector2 getChildRelativePosition(FDisplayObject child, float offsetX, float offsetY) { protected Vector2 getChildRelativePosition(FDisplayObject child, float offsetX, float offsetY) {
for (FDisplayObject c : children) { //check direct children first for (FDisplayObject c : children) { //check direct children first
if (child == c) { if (child == c) {
return new Vector2(c.getLeft() + offsetX, c.getTop() + offsetY); return new Vector2(c.getLeft() + offsetX, c.getTop() + offsetY);

View File

@@ -130,7 +130,7 @@ public abstract class FScrollPane extends FContainer {
} }
@Override @Override
protected final void doLayout(float width, float height) { protected void doLayout(float width, float height) {
scrollBounds = layoutAndGetScrollBounds(width, height); scrollBounds = layoutAndGetScrollBounds(width, height);
scrollBounds.increaseWidthTo(width); //ensure scroll bounds extends at least to visible bounds scrollBounds.increaseWidthTo(width); //ensure scroll bounds extends at least to visible bounds
scrollBounds.increaseHeightTo(height); scrollBounds.increaseHeightTo(height);

View File

@@ -67,7 +67,7 @@ public enum ItemManagerConfig {
SCHEME_DECKS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, false, SCHEME_DECKS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, false,
null, null, 3, 0), null, null, 3, 0),
VANGUARDS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, true, VANGUARDS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, true,
null, null, 3, 1), null, null, 3, 0),
DRAFT_DECKS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, false, DRAFT_DECKS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, false,
null, null, 3, 0), null, null, 3, 0),
SEALED_DECKS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, false, SEALED_DECKS(SColumnUtil.getDecksDefaultColumns(true, false), false, false, false,