Search in sources :

Example 6 with EQUIMENT_SLOT

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;
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) LegendaryItem(delta.games.lotro.lore.items.legendary.LegendaryItem) Item(delta.games.lotro.lore.items.Item) ItemsManager(delta.games.lotro.lore.items.ItemsManager) CharacterData(delta.games.lotro.character.CharacterData) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) ArrayList(java.util.ArrayList) CharacterClass(delta.games.lotro.common.CharacterClass) HashSet(java.util.HashSet)

Example 7 with EQUIMENT_SLOT

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);
                    }
                }
            }
        }
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) CharacterEquipment(delta.games.lotro.character.CharacterEquipment) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) EssencesSet(delta.games.lotro.lore.items.essences.EssencesSet) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 8 with EQUIMENT_SLOT

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;
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) MouseListener(java.awt.event.MouseListener) Insets(java.awt.Insets) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) JLayeredPane(javax.swing.JLayeredPane) JButton(javax.swing.JButton) Dimension(java.awt.Dimension)

Example 9 with EQUIMENT_SLOT

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);
            }
        }
    }
}
Also used : JMenuItem(javax.swing.JMenuItem) Item(delta.games.lotro.lore.items.Item) ItemsStash(delta.games.lotro.character.storage.ItemsStash) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) List(java.util.List) Component(java.awt.Component)

Example 10 with EQUIMENT_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;
}
Also used : EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) ItemChoiceTableColumnsManager(delta.games.lotro.gui.items.ItemChoiceTableColumnsManager) List(java.util.List) TypedProperties(delta.common.utils.misc.TypedProperties) Preferences(delta.common.utils.misc.Preferences) CharacterClass(delta.games.lotro.common.CharacterClass)

Aggregations

EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)12 Item (delta.games.lotro.lore.items.Item)7 CharacterEquipment (delta.games.lotro.character.CharacterEquipment)5 CharacterClass (delta.games.lotro.common.CharacterClass)4 CharacterData (delta.games.lotro.character.CharacterData)3 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)3 JMenuItem (javax.swing.JMenuItem)3 SlotContents (delta.games.lotro.character.CharacterEquipment.SlotContents)2 ItemsStash (delta.games.lotro.character.storage.ItemsStash)2 Race (delta.games.lotro.common.Race)2 Dimension (java.awt.Dimension)2 List (java.util.List)2 ImageIcon (javax.swing.ImageIcon)2 JButton (javax.swing.JButton)2 Preferences (delta.common.utils.misc.Preferences)1 TypedProperties (delta.common.utils.misc.TypedProperties)1 CharacterFile (delta.games.lotro.character.CharacterFile)1 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)1 STAT (delta.games.lotro.character.stats.STAT)1 ItemChoiceTableColumnsManager (delta.games.lotro.gui.items.ItemChoiceTableColumnsManager)1