java.lang.Objectcom.realtime.crossfire.jxclient.items.AbstractItemView
com.realtime.crossfire.jxclient.items.InventoryView
public class InventoryView
Provides a view of all items in the current player's inventory.
If no player object is known an empty inventory view is generated.
| Field Summary | |
|---|---|
private java.util.Comparator<CfItem> |
comparator
The Comparator for sorting. |
private int |
currentPlayerTag
The tag of the current player object or -1. |
private java.util.List<CfItem> |
items
The items in the inventory ordered by comparator. |
private ItemSet |
itemSet
The ItemSet to monitor. |
private ItemSetListener |
itemSetListener
The ItemSetListener attached to itemSet to track the
current player object. |
private DoubleMapping |
mapping
Maps external index to original index. |
private ItemListener |
playerInventoryListener
The ItemListener attached to the current player object. |
| Constructor Summary | |
|---|---|
InventoryView(ItemSet itemSet,
java.util.Comparator<CfItem> comparator)
Creates a new instance. |
|
| Method Summary | |
|---|---|
private int |
findInsertionIndex(CfItem item)
Returns the insertion index of a CfItem. |
CfItem |
getItem(int index)
Returns the CfItem in a given slot. |
int |
getSize()
Returns the number of items. |
private void |
setCurrentPlayerTag(int currentPlayerTag)
Updates the current player object. |
| Methods inherited from class com.realtime.crossfire.jxclient.items.AbstractItemView |
|---|
addLocationListener, addLocationsListener, addModified, addModifiedRange, removeLocationListener, removeLocationsListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
@NotNull private final java.util.Comparator<CfItem> comparator
Comparator for sorting.
private int currentPlayerTag
-1.
@NotNull private final java.util.List<CfItem> items
comparator.
@NotNull private final ItemSet itemSet
ItemSet to monitor.
@NotNull private final ItemSetListener itemSetListener
ItemSetListener attached to itemSet to track the
current player object.
@NotNull private final DoubleMapping mapping
@NotNull private final ItemListener playerInventoryListener
ItemListener attached to the current player object.
| Constructor Detail |
|---|
public InventoryView(@NotNull
ItemSet itemSet,
@NotNull
java.util.Comparator<CfItem> comparator)
itemSet - the item set to monitorcomparator - the comparator for sorting| Method Detail |
|---|
private int findInsertionIndex(@NotNull
CfItem item)
CfItem.
item - the item to insert into the inventory
@Nullable public CfItem getItem(int index)
CfItem in a given slot.
index - the slot index
null if the slot is emptypublic int getSize()
private void setCurrentPlayerTag(int currentPlayerTag)
currentPlayerTag - the tag of the player object or -1