Search in sources :

Example 1 with SingleEssenceEditionController

use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.

the class AllEssencesEditionPanelController method essenceUpdated.

/**
 * Invoked when an essence has been updated.
 * @param source Source controller.
 */
@Override
public void essenceUpdated(SingleEssenceEditionController source) {
    for (SingleItemEssencesEditionController itemEssences : _editors) {
        List<SingleEssenceEditionController> essenceCtrls = itemEssences.getEssenceControllers();
        int index = essenceCtrls.indexOf(source);
        if (index != -1) {
            Item item = itemEssences.getItem();
            EssencesSet essences = item.getEssences();
            if (essences == null) {
                essences = new EssencesSet(essenceCtrls.size());
                item.setEssences(essences);
            }
            essences.setEssence(index, source.getEssence());
            refreshToon();
            break;
        }
    }
}
Also used : SingleEssenceEditionController(delta.games.lotro.gui.items.essences.SingleEssenceEditionController) Item(delta.games.lotro.lore.items.Item) EssencesSet(delta.games.lotro.lore.items.essences.EssencesSet)

Example 2 with SingleEssenceEditionController

use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.

the class SingleItemEssencesEditionController method dispose.

/**
 * Release all managed resources.
 */
public void dispose() {
    // Data
    _item = null;
    // Controllers
    _parent = null;
    if (_controllers != null) {
        for (SingleEssenceEditionController controller : _controllers) {
            controller.dispose();
        }
        _controllers.clear();
        _controllers = null;
    }
    _iconController = null;
    // UI
    _itemName = null;
}
Also used : SingleEssenceEditionController(delta.games.lotro.gui.items.essences.SingleEssenceEditionController)

Example 3 with SingleEssenceEditionController

use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.

the class SingleItemEssencesEditionController method setItem.

/**
 * Set the managed item.
 * @param item Item to set.
 */
public void setItem(Item item) {
    _item = item;
    _controllers.clear();
    String label = "-";
    if (item != null) {
        // Label
        label = item.getName();
        // Essences
        EssencesSet essences = item.getEssences();
        int nbEssences = 0;
        if (essences != null) {
            nbEssences = essences.getSize();
        }
        int nbEssenceSlots = item.getEssenceSlots();
        int size = Math.max(nbEssences, nbEssenceSlots);
        for (int i = 0; i < size; i++) {
            SingleEssenceEditionController controller = new SingleEssenceEditionController(_parent, 2);
            Item essence = null;
            if (essences != null) {
                essence = essences.getEssence(i);
            }
            controller.setEssence(essence);
            _controllers.add(controller);
        }
    }
    _iconController.setItem(item);
    _icon.setIcon(_iconController.getIcon());
    _icon.setToolTipText(_iconController.getTooltip());
    _itemName.setText(label, 2);
}
Also used : SingleEssenceEditionController(delta.games.lotro.gui.items.essences.SingleEssenceEditionController) Item(delta.games.lotro.lore.items.Item) EssencesSet(delta.games.lotro.lore.items.essences.EssencesSet)

Example 4 with SingleEssenceEditionController

use of delta.games.lotro.gui.items.essences.SingleEssenceEditionController in project lotro-companion by dmorcellet.

the class AllEssencesEditionPanelController method update.

/**
 * Update UI.
 */
public void update() {
    clearEditors();
    initEditors();
    _panel.removeAll();
    int nbEssencesColumns = getEssencesCount();
    // Headers
    int nbColumns = nbEssencesColumns + 2;
    int columnIndex = 0;
    for (int i = 0; i < nbColumns; i++) {
        int columnSpan = (i > 1) ? 3 : 1;
        GridBagConstraints c = new GridBagConstraints(columnIndex, 0, columnSpan, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
        String text = "";
        if (i == 1)
            text = "Name";
        else if (i > 1)
            text = "Slot #" + (i - 1);
        JLabel label = GuiFactory.buildLabel(text);
        _panel.add(label, c);
        columnIndex += columnSpan;
    }
    // Item lines
    int rowIndex = 1;
    for (SingleItemEssencesEditionController controller : _editors) {
        columnIndex = 0;
        // Icon
        JLabel icon = controller.getItemIcon();
        GridBagConstraints c = new GridBagConstraints(columnIndex, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0);
        _panel.add(icon, c);
        columnIndex++;
        // Label
        JPanel label = controller.getItemLabel();
        c = new GridBagConstraints(columnIndex, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 10), 0, 0);
        _panel.add(label, c);
        columnIndex++;
        // Essences
        List<SingleEssenceEditionController> essenceEditors = controller.getEssenceControllers();
        int nbEssences = essenceEditors.size();
        for (int i = 0; i < nbEssencesColumns; i++) {
            if (i < nbEssences) {
                SingleEssenceEditionController essenceEditor = essenceEditors.get(i);
                essenceEditor.setListener(this);
                JButton essenceButton = essenceEditor.getEssenceButton();
                c = new GridBagConstraints(columnIndex, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
                _panel.add(essenceButton, c);
                JPanel essenceLabel = essenceEditor.getEssenceNameLabel();
                c = new GridBagConstraints(columnIndex + 1, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
                _panel.add(essenceLabel, c);
                JButton deleteButton = essenceEditor.getDeleteButton();
                c = new GridBagConstraints(columnIndex + 2, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
                _panel.add(deleteButton, c);
            }
            columnIndex += 3;
        }
        rowIndex++;
    }
}
Also used : SingleEssenceEditionController(delta.games.lotro.gui.items.essences.SingleEssenceEditionController) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel)

Aggregations

SingleEssenceEditionController (delta.games.lotro.gui.items.essences.SingleEssenceEditionController)4 Item (delta.games.lotro.lore.items.Item)2 EssencesSet (delta.games.lotro.lore.items.essences.EssencesSet)2 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1