mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-22 12:38:12 +07:00
BeltGrid will no longer allow non poti item types
BeltGrid will no longer allow non poti item types Added support for ItemGrid to reject an item type
This commit is contained in:
parent
8010dd9c4e
commit
df40ff5acd
@ -6,6 +6,8 @@ import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.utils.SnapshotArray;
|
||||
import com.riiablo.item.Item;
|
||||
import com.riiablo.item.Type;
|
||||
import com.riiablo.screen.GameScreen;
|
||||
|
||||
public class BeltGrid extends ItemGrid {
|
||||
@ -28,6 +30,11 @@ public class BeltGrid extends ItemGrid {
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean accept(Item item) {
|
||||
return item != null && item.type.is(Type.POTI);
|
||||
}
|
||||
|
||||
public void setRows(int rows) {
|
||||
if (this.rows != rows) {
|
||||
this.rows = rows;
|
||||
|
@ -120,6 +120,10 @@ public class ItemGrid extends Group {
|
||||
return store;
|
||||
}
|
||||
|
||||
protected boolean accept(Item item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void mouseMoved() {
|
||||
swap = null;
|
||||
blocked = true;
|
||||
@ -188,12 +192,12 @@ public class ItemGrid extends Group {
|
||||
|
||||
switch (hits.size) {
|
||||
case 0:
|
||||
blocked = false;
|
||||
blocked = !accept(cursor);
|
||||
swap = null;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
blocked = false;
|
||||
blocked = !accept(cursor);
|
||||
swap = (StoredItem) hits.first();
|
||||
break;
|
||||
|
||||
@ -207,8 +211,13 @@ public class ItemGrid extends Group {
|
||||
protected void drawChildren(Batch batch, float parentAlpha) {
|
||||
super.drawChildren(batch, parentAlpha);
|
||||
mouseMoved();
|
||||
if (Riiablo.cursor.getItem() != null && clickListener.isOver()) {
|
||||
Item cursor = Riiablo.cursor.getItem();
|
||||
if (cursor != null && clickListener.isOver()) {
|
||||
PaletteIndexedBatch b = (PaletteIndexedBatch) batch;
|
||||
if (!accept(cursor)) {
|
||||
b.setBlendMode(BlendMode.SOLID, backgroundColorR);
|
||||
b.draw(fill, coords.x, coords.y, itemSize.x, itemSize.y);
|
||||
} else {
|
||||
switch (hits.size) {
|
||||
case 0:
|
||||
b.setBlendMode(BlendMode.SOLID, backgroundColorG);
|
||||
@ -230,6 +239,7 @@ public class ItemGrid extends Group {
|
||||
b.flush();
|
||||
clipEnd();
|
||||
}
|
||||
}
|
||||
b.resetBlendMode();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user