22 package com.realtime.crossfire.jxclient.gui.item;
39 import java.awt.Color;
40 import java.awt.Dimension;
42 import java.awt.Graphics;
43 import java.awt.Image;
44 import org.jetbrains.annotations.NotNull;
45 import org.jetbrains.annotations.Nullable;
138 public void shortcutAdded(
final int index, @NotNull
final Shortcut shortcut) {
145 public void shortcutRemoved(
final int index, @NotNull
final Shortcut shortcut) {
168 public void faceUpdated(@NotNull
final Face face) {
192 public GUIItemShortcut(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final String
name, @Nullable
final Color castColor, @Nullable
final Image castImage, @Nullable
final Color invokeColor, @Nullable
final Image invokeImage,
final int index, @NotNull
final FacesManager facesManager, @NotNull
final Shortcuts shortcuts, @NotNull
final Font font, @NotNull
final CurrentSpellManager currentSpellManager) {
193 super(tooltipManager, elementListener, name);
203 this.shortcuts.addShortcutsListener(shortcutsListener);
204 this.facesManager.addFacesManagerListener(facesManagerListener);
225 if (this.shortcut == shortcut) {
229 if (this.shortcut != null) {
230 this.shortcut.removeShortcutListener(shortcutListener);
233 if (this.shortcut != null) {
248 if (shortcut != null) {
255 final ShortcutSpell shortcutSpell = (ShortcutSpell)shortcut;
270 final ShortcutSpell shortcutSpell = (ShortcutSpell)shortcut;
299 super.paintComponent(g);
301 g.setColor(BACKGROUND_COLOR);
302 g.fillRect(0, 0, getWidth(), getHeight());
305 if (tmpShortcut == null) {
317 public void visit(@NotNull
final ShortcutSpell shortcutSpell) {
321 g.fillRect(0, 0, getWidth(), getHeight());
323 g.drawImage(facesManager.
getOriginalImageIcon(shortcutSpell.getSpell().getFaceNum(), null).getImage(), 0, 0, null);
326 g.drawImage(image, 0, 0, null);
331 tmpShortcut.
visit(visitor);
333 g.setColor(Color.YELLOW);
334 g.drawString(
"F"+(index+1), 1, 1+font.getSize());
361 return new Dimension(32, 32);
Listener for GUIElement related events.
Dimension getPreferredSize()
ImageIcon getOriginalImageIcon(int faceNum, @Nullable boolean[] isUnknownImage)
Returns the "original" face for a face ID.
boolean canScroll(final int distance)
Returns whether scrolling is possible.the distance to scroll whether scrolling is possible ...
final TooltipManager tooltipManager
The TooltipManager to update.
final ShortcutsListener shortcutsListener
The ShortcutsListener attached to shortcuts.
void setCast(final boolean cast)
Sets whether the spell should be "cast" or "invoked".
final GUIElementListener elementListener
The GUIElementListener to notify.
void setChanged()
Records that the contents have changed and must be repainted.
final Font font
The Font for displaying the key that activates the shortcut.
abstract void visit(@NotNull final ShortcutVisitor visitor)
Calls a ShortcutVisitor's.
final CurrentSpellManager currentSpellManager
The CurrentSpellManager for tracking the active spell.
final Image invokeImage
The overlay image for shortcuts that /invoke a spell.
Spell getCurrentSpell()
Returns the currently selected spell object.
GUIItemShortcut(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final Color castColor, @Nullable final Image castImage, @Nullable final Color invokeColor, @Nullable final Image invokeImage, final int index, @NotNull final FacesManager facesManager, @NotNull final Shortcuts shortcuts, @NotNull final Font font, @NotNull final CurrentSpellManager currentSpellManager)
Creates a new instance.
void paintComponent(@NotNull final Graphics g)
A GUIElement representing an in-game object.
final Color invokeColor
The background color for shortcuts that /invoke a spell.
abstract void execute()
Executes the shortcut.
Manages image information ("faces") needed to display the map view, items, and spell icons...
static final Color BACKGROUND_COLOR
The background color of this item.
final FacesManager facesManager
The FacesManager instance for looking up faces.
void setSpellShortcut(final int index, @NotNull final String spellName, final boolean cast)
Sets a Shortcut to a spell.
void dispose()
Releases all allocated resources.
final FacesManagerListener facesManagerListener
The FacesManagerListener registered to detect updated faces.
final String name
The name of this element.
abstract boolean displaysFace(final Face face)
Returns whether this shortcut displays the given face.
abstract String getTooltipText()
Returns the current tooltip text.
final ShortcutListener shortcutListener
The ShortcutListener attached to shortcut.
void setShortcut(@Nullable final Shortcut shortcut)
Updates shortcut and registers/de-registers shortcutListener.
Helper functions for keyboard modifiers.
Manages the currently selected spell.
Describes a Crossfire spell.
Displays a shortcut command.
void resetScroll()
Resets the scroll index to the default value.
Interface for listeners interested in FacesManager events.
void setTooltipText(@Nullable final String tooltipText)
Sets the tooltip text to show when the mouse is inside this element.the text to show ornull to disab...
final int index
The shortcut index.
Interface for listeners for Shortcut changes.
Dimension getMinimumSize()
static final int CTRL
The mask for "ctrl".
Interface for visitors of Shortcut instances.
final Shortcuts shortcuts
The Shortcuts instance for looking up Shortcuts.
Interface for listeners for Shortcut changes.
boolean isCast()
Returns whether the spell should be "cast" or "invoked".
void button3Clicked(final int modifiers)
final Image castImage
The overlay image for shortcuts that /cast a spell.
static final int NONE
The mask for "no modifier".
void button1Clicked(final int modifiers)
static final int MASK
The mask for all used modifiers.
void button2Clicked(final int modifiers)
Abstract base class for shortcut commands.
void updateTooltipText()
Updates the tooltip text to reflect current settings.
static final long serialVersionUID
The serial version UID.
A Shortcut that casts a spell.
A Shortcut that executes a Crossfire command.
static Dimension getMinimumSizeInt()
Returns the minimal size to display this component.
void scroll(final int distance)
Scrolls the element.the distance to scroll
void removeFacesManagerListener(@NotNull FacesManagerListener facesManagerListener)
Removes a FacesManagerListener to be notified about updated faces.
Manages a list of Shortcuts.
void addShortcutListener(@NotNull final ShortcutListener listener)
Registers a shortcut listener.
final Color castColor
The background color for shortcuts that /cast a spell.
void removeShortcutsListener(@NotNull final ShortcutsListener listener)
Removes a ShortcutsListener.
static final String DEFAULT_TOOLTIP_TEXT
The default tooltip text for empty slots.
Shortcut shortcut
The currently monitored Shortcut instance.
Maintains a mapping of face numbers to face data.