use of delta.games.lotro.lore.items.essences.EssencesSet in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method getItem.
/**
* Get the current value of the edited item.
* @return An item.
*/
public Item getItem() {
// Name
_item.setName(_name.getText());
// Slot
_item.setEquipmentLocation(_slot.getSelectedItem());
// Stats
BasicStatsSet stats = _item.getStats();
stats.clear();
stats.setStats(_stats.getStats());
// Item level
_item.setItemLevel(_itemLevel.getSelectedItem());
// Minimum level
_item.setMinLevel(_minLevel.getSelectedItem());
// Description
_item.setDescription(_description.getText());
// Birth name
_item.setBirthName(_birthName.getText());
// Crafter name
_item.setCrafterName(_crafterName.getText());
// User comments
String userComments = _userComments.getText();
if (userComments.length() > 0) {
_item.setProperty(ItemConstants.USER_COMMENT, userComments);
} else {
_item.removeProperty(ItemConstants.USER_COMMENT);
}
// Binding
_item.setBinding(_binding.getSelectedItem());
// Unicity
_item.setUnique(_unique.isSelected());
// Durability
_item.setDurability(_durability.getValue());
// Sturdiness
_item.setSturdiness(_sturdiness.getSelectedItem());
// Stack max
_item.setStackMax(_stackMax.getValue());
// Quality
_item.setQuality(_quality.getSelectedItem());
// Essences
List<Item> selectedEssences = _essencesEditor.getEssences();
EssencesSet essences = null;
if (selectedEssences.size() > 0) {
essences = new EssencesSet(selectedEssences.size());
for (int i = 0; i < selectedEssences.size(); i++) {
essences.setEssence(i, selectedEssences.get(i));
}
}
_item.setEssences(essences);
// Armour specifics
if (_item instanceof Armour) {
Armour armour = (Armour) _item;
Integer armourValue = _armourValue.getValue();
if (armourValue != null) {
armour.setArmourValue(armourValue.intValue());
}
armour.setArmourType(_armourType.getSelectedItem());
}
// Weapon specifics
if (_item instanceof Weapon) {
Weapon weapon = (Weapon) _item;
Integer minDamage = _minDamage.getValue();
if (minDamage != null) {
weapon.setMinDamage(minDamage.intValue());
}
Integer maxDamage = _maxDamage.getValue();
if (maxDamage != null) {
weapon.setMaxDamage(maxDamage.intValue());
}
Float dps = _dps.getValue();
if (dps != null) {
weapon.setDPS(dps.floatValue());
}
weapon.setDamageType(_damageType.getSelectedItem());
weapon.setWeaponType(_weaponType.getSelectedItem());
}
// Legendary specifics
if (_item instanceof Legendary) {
Legendary legendary = (Legendary) _item;
_relicsEditor.getData(legendary.getLegendaryAttrs());
}
return _item;
}
use of delta.games.lotro.lore.items.essences.EssencesSet 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;
}
}
}
use of delta.games.lotro.lore.items.essences.EssencesSet 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);
}
use of delta.games.lotro.lore.items.essences.EssencesSet 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);
}
}
}
}
}
}
Aggregations