22 package com.realtime.crossfire.jxclient.gui.item;
35 import java.awt.Image;
36 import javax.swing.SwingUtilities;
37 import org.jetbrains.annotations.NotNull;
89 private final Object
sync =
new Object();
109 public void locationChanged() {
138 public GUIItemInventory(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final CommandQueue commandQueue,
final String
name, @NotNull
final ItemPainter itemPainter,
final int index, @NotNull
final CrossfireServerConnection crossfireServerConnection, @NotNull
final FacesManager facesManager, @NotNull
final FloorView floorView, @NotNull
final ItemView inventoryView,
final int size) {
139 super(tooltipManager, elementListener, name, itemPainter, facesManager);
144 defaultIndex =
index;
167 synchronized (
sync) {
168 return index >= -distance;
172 synchronized (
sync) {
173 return index+distance < inventoryView.
getSize();
184 synchronized (
sync) {
262 crossfireServerConnection.
drawInfo(
"This item is locked. To drop it, first unlock by SHIFT+left-clicking on it.", 3);
280 if (this.selected == selected) {
301 synchronized (
sync) {
311 synchronized (
sync) {
312 if (this.index == index) {
316 if (this.index >= 0) {
320 if (this.index >= 0) {
333 synchronized (
sync) {
Listener for GUIElement related events.
boolean isLocked()
Returns whether this item is locked.
int index
The inventory slot index.
ImageIcon getOriginalImageIcon(int faceNum, @Nullable boolean[] isUnknownImage)
Returns the "original" face for a face ID.
void sendMove(final int to, final int tag)
Sends a "move" command to the server.
final TooltipManager tooltipManager
The TooltipManager to update.
final ItemView inventoryView
The inventory view to watch.
A GUIItem for displaying inventory objects.
Interface for listeners interested in changed items.
final GUIElementListener elementListener
The GUIElementListener to notify.
boolean canScroll(final int distance)
Returns whether scrolling is possible.the distance to scroll whether scrolling is possible ...
static final int SHIFT
The mask for "shift".
void sendLock(boolean val, int tag)
Sends a "lock" command to the server.
final FloorView floorView
The FloorView to use.
final Object sync
The object used for synchronization on index.
GUIItemInventory(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final CommandQueue commandQueue, final String name, @NotNull final ItemPainter itemPainter, final int index, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final FacesManager facesManager, @NotNull final FloorView floorView, @NotNull final ItemView inventoryView, final int size)
Creates a new instance.
void resetScroll()
Resets the scroll index to the default value.
final Runnable locationListenerEdt
Called from locationListener but runs on the EDT.
Interface for listeners for changes of item locations.
void sendMark(int tag)
Sends a "mark" command to the server.
void setItemNoListeners(@Nullable final CfItem item)
Sets the current item instance without registering listeners for updates.
Manages image information ("faces") needed to display the map view, items, and spell icons...
A GUIElement instance representing an in-game item.
void scroll(final int distance)
Scrolls the element.the distance to scroll
void drawInfo(@NotNull String message, int color)
Pretends that a drawinfo message has been received.
final String name
The name of this element.
void setIndexNoListeners(final int index)
void dispose()
Releases all allocated resources.
void button1Clicked(final int modifiers)
Helper functions for keyboard modifiers.
final CrossfireServerConnection crossfireServerConnection
The server instance.
boolean selected
If set, paint the element in "selected" state.
void setSelected(final boolean selected)
CfItem getItem()
Returns the current item instance.
void setChanged()
Records that the contents have changed and must be repainted.
void setIndex(final int index)
Set the inventory slot to display.
int getSize()
Returns the number of items.
int getTag()
Returns the tag.
void addLocationListener(int index, @NotNull LocationListener locationListener)
Adds a LocationListener to be notified when the item displayed in a floor slot has changed...
static final int CTRL
The mask for "ctrl".
Image getFace(@NotNull final CfItem item)
void removeLocationListener(int index, @NotNull LocationListener locationListener)
Removes a LocationListener to be notified when the item displayed in a floor slot has changed...
final LocationListener locationListener
The ItemListener used to detect items added to or removed from this inventory slot.
static final int NONE
The mask for "no modifier".
void button3Clicked(final int modifiers)
void setItem(@Nullable final CfItem item)
Sets the current item instance.
static final int MASK
The mask for all used modifiers.
CfItem item
The current item instance.
final ItemPainter itemPainter
The ItemPainter for painting the icon.
static final long serialVersionUID
The serial version UID.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
CfItem getItem(int index)
Returns the CfItem in a given slot.
Maintains the pending (ncom) commands sent to the server.
void sendApply(int tag)
Sends an "apply" command to the server.
void sendExamine(int tag)
Sends an "examine" command to the server.
The representation of a Crossfire Item, client-side.
final FacesManager facesManager
The FacesManager instance to use.
void button2Clicked(final int modifiers)
final int defaultIndex
The default scroll index.
Paints Crossfire item images.
final CommandQueue commandQueue
The command queue for sending commands.
int getCurrentFloor()
Returns the current floor location.
boolean isActive()
Returns whether a GUI element is active.
Provides a view to all items comprising the current floor view.
void updateTooltipText()
Updates the tooltip text for the current item.
Maintains a mapping of face numbers to face data.