use of delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT in project lotro-tools by dmorcellet.
the class ItemNormalization method filterItems.
/**
* Filter items that are accessible within LotroCompanion.
* @param items List to filter.
* @return a list that contains the filtered items.
*/
private List<Item> filterItems(List<Item> items) {
ItemsManager manager = new ItemsManager(items);
Set<Integer> selectedIds = new HashSet<Integer>();
// Iterate on classes then on slots to find all reachable items
for (CharacterClass cClass : CharacterClass.ALL_CLASSES) {
CharacterData c = new CharacterData();
c.setCharacterClass(cClass);
c.setLevel(105);
for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
List<Item> selectedItems = manager.getItems(c, slot);
for (Item selectedItem : selectedItems) {
selectedIds.add(Integer.valueOf(selectedItem.getIdentifier()));
}
}
}
// Essences
List<Item> essences = manager.getEssences();
for (Item essence : essences) {
selectedIds.add(Integer.valueOf(essence.getIdentifier()));
}
// Build final list
List<Item> selectedItems = new ArrayList<Item>();
for (Item item : items) {
if (selectedIds.contains(Integer.valueOf(item.getIdentifier()))) {
selectedItems.add(item);
}
}
return selectedItems;
}
use of delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT in project lotro-companion by dmorcellet.
the class EssencesSummary method update.
/**
* Update counts.
*/
public void update() {
_count.clear();
_essencesCount = 0;
_slotsCount = 0;
_stats.clear();
CharacterEquipment equipment = _toon.getEquipment();
for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
Item item = equipment.getItemForSlot(slot);
if (item != null) {
EssencesSet essences = item.getEssences();
int nbSlots = item.getEssenceSlots();
int nbEssences = (essences != null) ? essences.getSize() : 0;
int slotsCount = Math.max(nbSlots, nbEssences);
// Increment total essence slot count
_slotsCount += slotsCount;
if (essences != null) {
for (int i = 0; i < nbEssences; i++) {
Item essence = essences.getEssence(i);
if (essence != null) {
// Increment by-essence count
Integer essenceId = Integer.valueOf(essence.getIdentifier());
EssenceCount count = _count.get(essenceId);
if (count == null) {
count = new EssenceCount(essence);
_count.put(essenceId, count);
}
count.increment();
// Increment essences count
_essencesCount++;
BasicStatsSet essenceStats = essence.getStats();
_stats.addStats(essenceStats);
}
}
}
}
}
}
use of delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT in project lotro-companion by dmorcellet.
the class EquipmentPanelController method buildPanel.
private JPanel buildPanel() {
JPanel panel = GuiFactory.buildPanel(null);
_layeredPane = new JLayeredPane();
panel.add(_layeredPane, BorderLayout.CENTER);
Dimension d = computeDimensions();
panel.setPreferredSize(d);
panel.setMinimumSize(d);
_layeredPane.setSize(d);
MouseListener listener = buildRightClickListener();
for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
// Position for item
Dimension position = _iconPositions.get(slot);
// Add object icon
// - icon controller
EquipmentSlotIconController iconController = new EquipmentSlotIconController(slot);
_icons.put(slot, iconController);
ImageIcon icon = iconController.getIcon();
// - button
JButton button = new JButton(icon);
button.setBorderPainted(false);
button.setMargin(new Insets(0, 0, 0, 0));
button.setBounds(position.width, position.height, ICON_SIZE, ICON_SIZE);
_layeredPane.add(button, ICONS_DEPTH);
_buttons.put(slot, button);
button.setActionCommand(SLOT_SEED + slot.name());
button.addActionListener(this);
button.addMouseListener(listener);
button.setToolTipText("");
}
updateIcons();
return panel;
}
use of delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT in project lotro-companion by dmorcellet.
the class EquipmentPanelController method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if (cmd.startsWith(SLOT_SEED)) {
cmd = cmd.substring(SLOT_SEED.length());
// Straight click
EQUIMENT_SLOT slot = EQUIMENT_SLOT.valueOf(cmd);
if (slot != null) {
Item currentItem = getItemForSlot(slot);
if (currentItem != null) {
handleEditItem(slot);
} else {
List<Item> items = ItemsManager.getInstance().getAllItems();
handleChooseItem(slot, items);
}
}
} else {
// From contextual menu
Component invoker = _contextMenu.getInvoker();
EQUIMENT_SLOT slot = findSlotForButton(invoker);
if (slot != null) {
if (EDIT_COMMAND.equals(cmd)) {
handleEditItem(slot);
} else if (CHOOSE_COMMAND.equals(cmd)) {
List<Item> items = ItemsManager.getInstance().getAllItems();
handleChooseItem(slot, items);
} else if (CHOOSE_FROM_STASH_COMMAND.equals(cmd)) {
ItemsStash stash = _toon.getStash();
List<Item> items = stash.getAll();
handleChooseItem(slot, items);
} else if (REMOVE_COMMAND.equals(cmd)) {
handleRemoveItem(slot);
} else if (COPY_TO_STASH_COMMAND.equals(cmd)) {
handleCopyToStash(slot);
}
}
}
}
use of delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT in project lotro-companion by dmorcellet.
the class CharacterPreferencesManager method getUserProperties.
/**
* Get the preferences for a character.
* @param toonFile Character file.
* @param id Identifier of the preferences set.
* @return Some properties or <code>null</code> if not managed.
*/
public static TypedProperties getUserProperties(CharacterFile toonFile, String id) {
TypedProperties props = null;
if (id.startsWith(ItemChoiceWindowController.ITEM_CHOOSER_PROPERTIES_ID)) {
if (toonFile != null) {
Preferences prefs = toonFile.getPreferences();
props = prefs.getPreferences(id);
List<String> columnIds = props.getStringList(ItemChoiceWindowController.COLUMNS_PROPERTY);
if (columnIds == null) {
String slotKey = id.substring(id.indexOf("#") + 1);
EQUIMENT_SLOT slot = EQUIMENT_SLOT.valueOf(slotKey);
CharacterClass characterClass = toonFile.getSummary().getCharacterClass();
ItemChoiceTableColumnsManager mgr = new ItemChoiceTableColumnsManager();
columnIds = mgr.getItemChoiceColumns(characterClass, slot);
props.setStringList(ItemChoiceWindowController.COLUMNS_PROPERTY, columnIds);
prefs.savePreferences(props);
}
}
} else if (ItemChoiceWindowController.ESSENCE_CHOOSER_PROPERTIES_ID.equals(id)) {
Preferences prefs = toonFile.getPreferences();
props = prefs.getPreferences(id);
List<String> columnIds = props.getStringList(ItemChoiceWindowController.COLUMNS_PROPERTY);
if (columnIds == null) {
CharacterClass characterClass = toonFile.getSummary().getCharacterClass();
ItemChoiceTableColumnsManager mgr = new ItemChoiceTableColumnsManager();
columnIds = mgr.getEssenceChoiceColumns(characterClass);
props.setStringList(ItemChoiceWindowController.COLUMNS_PROPERTY, columnIds);
prefs.savePreferences(props);
}
}
return props;
}
Aggregations