 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.shortcuts;
30 import java.nio.file.Path;
31 import java.util.Collections;
32 import java.util.EnumMap;
33 import java.util.Iterator;
35 import java.util.Map.Entry;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
43 public class Shortcuts implements Iterable<Shortcut> {
74 @SuppressWarnings(
"FieldCanBeLocal")
78 public void spellAdded(
final int index) {
79 for (
final Entry<ShortcutSlot, Shortcut> e :
shortcuts.entrySet()) {
80 final Shortcut shortcut = e.getValue();
81 if (shortcut !=
null) {
88 public void spellRemoved(
final int index) {
89 for (
final Entry<ShortcutSlot, Shortcut> e :
shortcuts.entrySet()) {
90 final Shortcut shortcut = e.getValue();
91 if (shortcut !=
null) {
117 if (shortcut !=
null) {
119 listener.shortcutRemoved(shortcutSlot, shortcut);
144 final String command2 = command.trim();
145 @Nullable
final Spell spell;
146 if (command2.isEmpty()) {
148 }
else if (command2.startsWith(
"cast ")) {
150 }
else if (command2.startsWith(
"invoke ")) {
157 if (oldShortcut !=
null) {
159 listener.shortcutRemoved(shortcutSlot, oldShortcut);
163 final Shortcut newShortcut = command2.isEmpty() ? null :
new Shortcut(command2, spell);
164 shortcuts.put(shortcutSlot, newShortcut);
165 if (newShortcut !=
null) {
167 listener.shortcutAdded(shortcutSlot, newShortcut);
171 if (saveChanges &&
file !=
null) {
Path file
The backing file.
void dispose()
Releases all allocated resources.
Iterator< Shortcut > iterator()
String getCommand()
Returns the command to execute.
final EventListenerList2< ShortcutsListener > listeners
The listeners to be notified.
Shortcuts(@NotNull final SpellsManager spellsManager)
Creates a new instance.
A slot in the shortcuts bar.
Path getFile()
Returns the backing file.
Shortcut getShortcut(@NotNull final ShortcutSlot shortcutSlot)
Returns a shortcut.
final SpellsManagerListener spellsManagerListener
The SpellsManagerListener used to detect spell changes.
final SpellsManager spellsManager
The SpellsManager instance to watch.
void addShortcutsListener(@NotNull final ShortcutsListener listener)
Adds a ShortcutsListener.
A list of event listeners.
Manages all known spells.
Spell getSpell(@NotNull final String spellName)
Returns a Spell instance by partial spell name.
void removeShortcutsListener(@NotNull final ShortcutsListener listener)
Removes a ShortcutsListener.
Describes a Crossfire spell.
void setShortcutString(@NotNull final ShortcutSlot shortcutSlot, @NotNull final String command, final boolean saveChanges)
Sets a slot.
Interface for listeners interested in SpellsManager events.
void clearShortcuts()
Clears all defined shortcuts.
void setFile(@Nullable final Path file)
Sets the backing file.
Abstract base class for shortcut commands.
Interface for listeners for Shortcut changes.
static void saveShortcuts(@NotNull final Path file, @NotNull final Iterable< Shortcut > shortcuts)
Save all shortcut info to the backing file.
Manages a list of Shortcuts.
final Map< ShortcutSlot, Shortcut > shortcuts
The shortcuts.