Search in sources :

Example 1 with ScalingRule

use of delta.games.lotro.lore.items.stats.ScalingRule in project lotro-companion by dmorcellet.

the class ItemEditionPanelController method configureScaling.

private void configureScaling(Item item) {
    ScalingRule rule = Scaling.getScalingRule(item);
    if (rule != null) {
        // Min level
        List<Integer> minLevels = rule.getRequiredLevels();
        for (Integer minLevel : minLevels) {
            _minLevel.addItem(minLevel, minLevel.toString());
        }
        ItemSelectionListener<Integer> listenerRequiredLevel = new ItemSelectionListener<Integer>() {

            @Override
            public void itemSelected(Integer requiredLevel) {
                selectRequiredLevel(requiredLevel);
            }
        };
        _minLevel.addListener(listenerRequiredLevel);
        // Item level
        List<Integer> itemLevels = rule.getItemLevels();
        for (Integer itemLevel : itemLevels) {
            _itemLevel.addItem(itemLevel, itemLevel.toString());
        }
        ItemSelectionListener<Integer> listener = new ItemSelectionListener<Integer>() {

            @Override
            public void itemSelected(Integer itemLevel) {
                selectItemLevel(itemLevel);
            }
        };
        _itemLevel.addListener(listener);
    } else {
        // Min level
        _minLevel.addEmptyItem("");
        Integer minLevel = item.getMinLevel();
        if (minLevel != null) {
            _minLevel.addItem(minLevel, minLevel.toString());
        }
        // Item level
        _itemLevel.addEmptyItem("");
        Integer itemLevel = item.getItemLevel();
        if (itemLevel != null) {
            _itemLevel.addItem(itemLevel, itemLevel.toString());
        }
    }
}
Also used : ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener) ScalingRule(delta.games.lotro.lore.items.stats.ScalingRule)

Example 2 with ScalingRule

use of delta.games.lotro.lore.items.stats.ScalingRule in project lotro-companion by dmorcellet.

the class ItemEditionPanelController method selectItemLevel.

private void selectItemLevel(Integer itemLevel) {
    if (itemLevel != null) {
        ScalingRule rule = Scaling.getScalingRule(_item);
        if (rule != null) {
            Item item = ItemFactory.clone(_item);
            Scaling.scaleToItemLevel(item, itemLevel.intValue());
            BasicStatsSet stats = item.getStats();
            _stats.initFromStats(stats);
            if (item instanceof Armour) {
                Armour armour = (Armour) item;
                int armourValue = armour.getArmourValue();
                _armourValue.setValue(Integer.valueOf(armourValue));
            }
            Integer requiredLevel = rule.getRequiredLevel(itemLevel.intValue());
            if (requiredLevel != null) {
                _minLevel.selectItem(requiredLevel);
            }
        }
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) Armour(delta.games.lotro.lore.items.Armour) ScalingRule(delta.games.lotro.lore.items.stats.ScalingRule) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Aggregations

ScalingRule (delta.games.lotro.lore.items.stats.ScalingRule)2 ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)1 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)1 Armour (delta.games.lotro.lore.items.Armour)1 Item (delta.games.lotro.lore.items.Item)1