Crossfire JXClient, Trunk
Public Member Functions | Private Member Functions | Private Attributes | List of all members
com.realtime.crossfire.jxclient.items.InventoryView Class Reference
Inheritance diagram for com.realtime.crossfire.jxclient.items.InventoryView:
Inheritance graph
Collaboration diagram for com.realtime.crossfire.jxclient.items.InventoryView:
Collaboration graph

Public Member Functions

CfItem getItem (final int index)
 
int getSize ()
 
 InventoryView (@NotNull final ItemSet itemSet, @NotNull final Comparator< CfItem > comparator)
 
void setFilter (@NotNull final InventoryFilter filter)
 
- Public Member Functions inherited from com.realtime.crossfire.jxclient.items.AbstractItemView
void addLocationListener (final int index, @NotNull final LocationListener locationListener)
 
void addLocationsListener (@NotNull final LocationsListener locationsListener)
 
void removeLocationListener (final int index, @NotNull final LocationListener locationListener)
 
void removeLocationsListener (@NotNull final LocationsListener locationsListener)
 

Private Member Functions

void doRebuildInventory ()
 
int findInsertionIndex (@NotNull final CfItem item)
 
void run ()
 
void setCurrentPlayerTag (final int currentPlayerTag)
 

Private Attributes

long changeTimestamp = System.currentTimeMillis()
 
final Comparator< CfItemcomparator
 
int currentPlayerTag
 
InventoryFilter filter = InventoryFilter.ALL
 
final CfItemListener itemModifiedListener = () -> setCurrentPlayerTag(currentPlayerTag)
 
final List< CfItemitems = new ArrayList<>()
 
final ItemSet itemSet
 
final ItemSetListener itemSetListener
 
final ItemListener playerInventoryListener
 
final Object sync = new Object()
 

Additional Inherited Members

- Protected Member Functions inherited from com.realtime.crossfire.jxclient.items.AbstractItemView
 AbstractItemView ()
 
void addModified (final int index)
 
void addModifiedRange (final int firstIndex, final int lastIndex)
 

Detailed Description

Provides a view of all items in the current player's inventory.

If no player object is known an empty inventory view is generated.

Author
Andreas Kirschbaum

Definition at line 38 of file InventoryView.java.

Constructor & Destructor Documentation

◆ InventoryView()

com.realtime.crossfire.jxclient.items.InventoryView.InventoryView ( @NotNull final ItemSet  itemSet,
@NotNull final Comparator< CfItem comparator 
)

Member Function Documentation

◆ doRebuildInventory()

void com.realtime.crossfire.jxclient.items.InventoryView.doRebuildInventory ( )
private

◆ findInsertionIndex()

int com.realtime.crossfire.jxclient.items.InventoryView.findInsertionIndex ( @NotNull final CfItem  item)
private

Returns the insertion index of a CfItem.

Parameters
itemthe item to insert into the inventory
Returns
the index to insert at

Definition at line 267 of file InventoryView.java.

References com.realtime.crossfire.jxclient.items.InventoryView.comparator, com.realtime.crossfire.jxclient.items.InventoryView.filter, com.realtime.crossfire.jxclient.items.InventoryView.items, and com.realtime.crossfire.jxclient.items.InventoryFilter.matches.

Referenced by com.realtime.crossfire.jxclient.items.InventoryView.doRebuildInventory().

Here is the caller graph for this function:

◆ getItem()

CfItem com.realtime.crossfire.jxclient.items.InventoryView.getItem ( final int  index)

Returns the CfItem in a given slot.

Parameters
indexthe slot index
Returns
the item or
null
if the slot is empty

Implements com.realtime.crossfire.jxclient.items.ItemView.

Definition at line 252 of file InventoryView.java.

References com.realtime.crossfire.jxclient.items.InventoryView.items.

◆ getSize()

int com.realtime.crossfire.jxclient.items.InventoryView.getSize ( )

Returns the number of items.

Returns
the number of items

Implements com.realtime.crossfire.jxclient.items.ItemView.

Definition at line 244 of file InventoryView.java.

References com.realtime.crossfire.jxclient.items.InventoryView.items.

◆ run()

void com.realtime.crossfire.jxclient.items.InventoryView.run ( )
private

Updates the inventory contents asynchronously.

Definition at line 187 of file InventoryView.java.

References com.realtime.crossfire.jxclient.items.InventoryView.changeTimestamp, and com.realtime.crossfire.jxclient.items.InventoryView.sync.

◆ setCurrentPlayerTag()

void com.realtime.crossfire.jxclient.items.InventoryView.setCurrentPlayerTag ( final int  currentPlayerTag)
private

◆ setFilter()

void com.realtime.crossfire.jxclient.items.InventoryView.setFilter ( @NotNull final InventoryFilter  filter)

Member Data Documentation

◆ changeTimestamp

long com.realtime.crossfire.jxclient.items.InventoryView.changeTimestamp = System.currentTimeMillis()
private

The timestamp when the inventory contents may have changed.

Definition at line 61 of file InventoryView.java.

Referenced by com.realtime.crossfire.jxclient.items.InventoryView.run(), and com.realtime.crossfire.jxclient.items.InventoryView.setCurrentPlayerTag().

◆ comparator

final Comparator<CfItem> com.realtime.crossfire.jxclient.items.InventoryView.comparator
private

◆ currentPlayerTag

int com.realtime.crossfire.jxclient.items.InventoryView.currentPlayerTag
private

◆ filter

InventoryFilter com.realtime.crossfire.jxclient.items.InventoryView.filter = InventoryFilter.ALL
private

◆ itemModifiedListener

final CfItemListener com.realtime.crossfire.jxclient.items.InventoryView.itemModifiedListener = () -> setCurrentPlayerTag(currentPlayerTag)
private

The CfItemListener attached to all items in items.

Definition at line 137 of file InventoryView.java.

Referenced by com.realtime.crossfire.jxclient.items.InventoryView.doRebuildInventory().

◆ items

final List<CfItem> com.realtime.crossfire.jxclient.items.InventoryView.items = new ArrayList<>()
private

◆ itemSet

final ItemSet com.realtime.crossfire.jxclient.items.InventoryView.itemSet
private

◆ itemSetListener

final ItemSetListener com.realtime.crossfire.jxclient.items.InventoryView.itemSetListener
private
Initial value:
= new ItemSetListener() {
@Override
public void playerChanged(@Nullable final CfItem player) {
setCurrentPlayerTag(player == null ? -1 : player.getTag());
}
@Override
public void openContainerChanged(final int tag) {
}
}

The ItemSetListener attached to itemSet to track the current player object.

Definition at line 82 of file InventoryView.java.

Referenced by com.realtime.crossfire.jxclient.items.InventoryView.InventoryView().

◆ playerInventoryListener

final ItemListener com.realtime.crossfire.jxclient.items.InventoryView.playerInventoryListener
private

The ItemListener attached to the current player object.

Definition at line 100 of file InventoryView.java.

Referenced by com.realtime.crossfire.jxclient.items.InventoryView.setCurrentPlayerTag().

◆ sync

final Object com.realtime.crossfire.jxclient.items.InventoryView.sync = new Object()
private

The documentation for this class was generated from the following file:
com.realtime.crossfire.jxclient.items.InventoryView.setCurrentPlayerTag
void setCurrentPlayerTag(final int currentPlayerTag)
Definition: InventoryView.java:167