use of delta.games.lotro.lore.items.Armour in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method build.
private JPanel build() {
JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
// Main data line
{
JPanel panelLine = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(panelLine, c);
c.gridy++;
// Icon
_icon = GuiFactory.buildIconLabel(null);
panelLine.add(_icon);
// Name
_name = GuiFactory.buildTextField("");
_name.setFont(_name.getFont().deriveFont(16f).deriveFont(Font.BOLD));
_name.setColumns(25);
panelLine.add(_name);
// Slot
_slot = buildSlotCombo();
panelLine.add(_slot.getComboBox());
// Unicity
_unique = GuiFactory.buildCheckbox("Unique");
panelLine.add(_unique);
}
// Armour specifics line
if (_item instanceof Armour) {
_armourPanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(_armourPanel, c);
c.gridy++;
_armourPanel.setVisible(true);
// Armour
JTextField armourValue = GuiFactory.buildTextField("");
_armourValue = new IntegerEditionController(armourValue);
_armourValue.setValueRange(Integer.valueOf(0), Integer.valueOf(50000));
_armourPanel.add(GuiFactory.buildLabel("Armour:"));
_armourPanel.add(_armourValue.getTextField());
// Armour Type
_armourType = ItemUiTools.buildArmourTypeCombo();
_armourPanel.add(GuiFactory.buildLabel("Armour Type:"));
_armourPanel.add(_armourType.getComboBox());
}
// Weapon specifics line
if (_item instanceof Weapon) {
_weaponPanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(_weaponPanel, c);
c.gridy++;
_weaponPanel.setVisible(false);
// Weapon type
_weaponType = ItemUiTools.buildWeaponTypeCombo();
_weaponPanel.add(GuiFactory.buildLabel("Type:"));
_weaponPanel.add(_weaponType.getComboBox());
// Damage
JTextField minDamage = GuiFactory.buildTextField("");
_minDamage = new IntegerEditionController(minDamage, 3);
_minDamage.setValueRange(Integer.valueOf(0), Integer.valueOf(10000));
_weaponPanel.add(GuiFactory.buildLabel("Damage:"));
_weaponPanel.add(_minDamage.getTextField());
_weaponPanel.add(GuiFactory.buildLabel("-"));
JTextField maxDamage = GuiFactory.buildTextField("");
_maxDamage = new IntegerEditionController(maxDamage, 3);
_maxDamage.setValueRange(Integer.valueOf(0), Integer.valueOf(10000));
_weaponPanel.add(_maxDamage.getTextField());
// Damage type
_damageType = buildDamageTypeCombo();
_weaponPanel.add(_damageType.getComboBox());
// DPS
JTextField dps = GuiFactory.buildTextField("");
_dps = new FloatEditionController(dps);
_dps.setValueRange(Float.valueOf(0), Float.valueOf(1000));
_weaponPanel.add(GuiFactory.buildLabel("DPS:"));
_weaponPanel.add(_dps.getTextField());
}
// Level and binding line
{
JPanel panelLine = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(panelLine, c);
c.gridy++;
// Item level
_itemLevel = new ComboBoxController<Integer>(true, Integer.class);
panelLine.add(GuiFactory.buildLabel("Item level:"));
panelLine.add(_itemLevel.getComboBox());
// Minimum level
_minLevel = new ComboBoxController<Integer>(true, Integer.class);
panelLine.add(GuiFactory.buildLabel("Required level:"));
panelLine.add(_minLevel.getComboBox());
// Binding
_binding = buildBindingCombo();
panelLine.add(GuiFactory.buildLabel("Binding:"));
panelLine.add(_binding.getComboBox());
}
// Durability/sturdiness/quality line
{
JPanel panelLine = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(panelLine, c);
c.gridy++;
// Durability
JTextField durability = GuiFactory.buildTextField("");
_durability = new IntegerEditionController(durability, 3);
_durability.setValueRange(Integer.valueOf(1), Integer.valueOf(150));
panelLine.add(GuiFactory.buildLabel("Durability:"));
panelLine.add(_durability.getTextField());
// Sturdiness
_sturdiness = buildSturdinessCombo();
panelLine.add(GuiFactory.buildLabel("Sturdiness:"));
panelLine.add(_sturdiness.getComboBox());
// Quality
_quality = ItemUiTools.buildQualityCombo();
panelLine.add(GuiFactory.buildLabel("Quality:"));
panelLine.add(_quality.getComboBox());
// Stack max
JTextField stackMax = GuiFactory.buildTextField("");
_stackMax = new IntegerEditionController(stackMax);
_stackMax.setValueRange(Integer.valueOf(1), Integer.valueOf(1000));
panelLine.add(GuiFactory.buildLabel("Stack:"));
panelLine.add(_stackMax.getTextField());
}
// Contextual data line
{
JPanel panelLine = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(panelLine, c);
c.gridy++;
// Birth name
_birthName = GuiFactory.buildTextField("");
_birthName.setColumns(20);
panelLine.add(GuiFactory.buildLabel("Name:"));
panelLine.add(_birthName);
// Crafter name
_crafterName = GuiFactory.buildTextField("");
_crafterName.setColumns(20);
panelLine.add(GuiFactory.buildLabel("Crafter:"));
panelLine.add(_crafterName);
}
// User comments
{
_userComments = GuiFactory.buildTextField("");
_userComments.setColumns(40);
JPanel panelLine = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(panelLine, c);
c.gridy++;
panelLine.add(GuiFactory.buildLabel("Comments:"));
panelLine.add(_userComments);
}
// Tabbed pane at the bottom
// Description
JPanel descriptionPanel = GuiFactory.buildBackgroundPanel(new BorderLayout());
_description = GuiFactory.buildTextArea("", false);
_description.setColumns(40);
_description.setLineWrap(true);
descriptionPanel.add(_description, BorderLayout.CENTER);
// Stats
_stats = new StatsEditionPanelController();
// Essences
_essencesEditor = new EssencesEditionPanelController(_parent);
// Tabbed pane assembly
JTabbedPane tabbedPane = GuiFactory.buildTabbedPane();
tabbedPane.add("Stats", _stats.getPanel());
tabbedPane.add("Description", descriptionPanel);
tabbedPane.add("Essences", _essencesEditor.getPanel());
// Legendary specifics
// - relics
JPanel relicsPanel = null;
if (_item instanceof Legendary) {
Legendary legItem = (Legendary) _item;
LegendaryAttrs attrs = new LegendaryAttrs(legItem.getLegendaryAttrs());
_relicsEditor = new RelicsEditionPanelController(_parent, attrs);
relicsPanel = _relicsEditor.getPanel();
tabbedPane.add("Relics", relicsPanel);
}
JPanel ret = GuiFactory.buildBackgroundPanel(new BorderLayout());
ret.add(panel, BorderLayout.NORTH);
ret.add(tabbedPane, BorderLayout.CENTER);
_panel = ret;
setItem();
return ret;
}
use of delta.games.lotro.lore.items.Armour 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.Armour in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method setItem.
/**
* Set the item to display.
*/
private void setItem() {
String name = _item.getName();
_parent.setTitle(name);
// Icon
String iconId = _item.getProperty(ItemPropertyNames.ICON_ID);
String backgroundIconId = _item.getProperty(ItemPropertyNames.BACKGROUND_ICON_ID);
ImageIcon icon = LotroIconsManager.getItemIcon(iconId, backgroundIconId);
_icon.setIcon(icon);
// Name
_name.setText(name);
// Slot
_slot.selectItem(_item.getEquipmentLocation());
// Stats
_stats.initFromStats(_item.getStats());
// Configure scaling
configureScaling(_item);
// Item level
Integer itemLevel = _item.getItemLevel();
_itemLevel.selectItem(itemLevel);
// Minimum level
Integer minLevel = _item.getMinLevel();
_minLevel.selectItem(minLevel);
// Description
_description.setText(_item.getDescription());
// Birth name
_birthName.setText(_item.getBirthName());
// Crafter name
_crafterName.setText(_item.getCrafterName());
// User comments
String userComments = _item.getProperty(ItemConstants.USER_COMMENT);
if (userComments == null)
userComments = "";
_userComments.setText(userComments);
// Binding
_binding.selectItem(_item.getBinding());
// Unicity
_unique.setSelected(_item.isUnique());
// Durability
_durability.setValue(_item.getDurability());
// Sturdiness
_sturdiness.selectItem(_item.getSturdiness());
// Stack max
_stackMax.setValue(_item.getStackMax());
// Quality
_quality.selectItem(_item.getQuality());
// Armour specifics
if (_item instanceof Armour) {
Armour armour = (Armour) _item;
_armourValue.setValue(Integer.valueOf(armour.getArmourValue()));
_armourType.selectItem(armour.getArmourType());
}
// Weapon specifics
if (_item instanceof Weapon) {
Weapon weapon = (Weapon) _item;
_minDamage.setValue(Integer.valueOf(weapon.getMinDamage()));
_maxDamage.setValue(Integer.valueOf(weapon.getMaxDamage()));
_dps.setValue(Float.valueOf(weapon.getDPS()));
_weaponType.selectItem(weapon.getWeaponType());
_damageType.selectItem(weapon.getDamageType());
}
// Essences
_essencesEditor.initFromItem(_item);
}
use of delta.games.lotro.lore.items.Armour in project lotro-companion by dmorcellet.
the class ItemFilterConfiguration method initFromItems.
/**
* Init from a collection of items.
* @param items Items to use.
*/
public void initFromItems(List<Item> items) {
_armourTypes.clear();
_shieldTypes.clear();
_weaponTypes.clear();
for (Item item : items) {
// Armour
if (item instanceof Armour) {
Armour weapon = (Armour) item;
ArmourType type = weapon.getArmourType();
if (type != null) {
if (type.isShield()) {
_shieldTypes.add(type);
} else {
_armourTypes.add(type);
}
}
}
// Weapon
if (item instanceof Weapon) {
Weapon weapon = (Weapon) item;
WeaponType type = weapon.getWeaponType();
if (type != null) {
_weaponTypes.add(type);
}
}
}
}
use of delta.games.lotro.lore.items.Armour in project lotro-tools by dmorcellet.
the class LotroPlanItemsDbLoader method buildItemFromLine.
private Item buildItemFromLine(LotroPlanTable table, String line) {
String[] fieldsTrimmed = StringSplitter.split(line.trim(), '\t');
if (line.startsWith("#")) {
System.out.println("Ignored: " + line);
return null;
}
if (fieldsTrimmed.length < 2) {
_section = line.trim();
System.out.println("Section: " + _section);
return null;
}
String[] fields = StringSplitter.split(line, '\t');
// Item level
int itemLevel = NumericTools.parseInt(fields[LotroPlanTable.ITEM_LEVEL_INDEX], -1);
// Stats
ItemStatsProvider provider = table.loadStats(fields);
BasicStatsSet stats = provider.getStats(itemLevel);
FixedDecimalsInteger armorStat = stats.getStat(STAT.ARMOUR);
Item item = null;
Armour armour = null;
if (armorStat != null) {
armour = new Armour();
item = armour;
armour.setArmourValue(armorStat.intValue());
stats.removeStat(STAT.ARMOUR);
} else {
item = new Item();
}
// ID
String idStr = "";
int notesIndex = table.getNotesIndex();
if (fields.length >= notesIndex) {
idStr = fields[notesIndex].trim();
}
int id = 0;
if (idStr.startsWith("ID:")) {
idStr = idStr.substring(3).trim();
}
id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
item.setIdentifier(id);
}
// Name
String name = fields[LotroPlanTable.NAME_INDEX];
if (name.startsWith("(")) {
int index = name.indexOf(')');
idStr = name.substring(1, index).trim();
id = NumericTools.parseInt(idStr, -1);
item.setIdentifier(id);
name = name.substring(index + 1).trim();
}
if (name.endsWith(":")) {
name = name.substring(0, name.length() - 1);
}
name = name.replace(' ', ' ');
if (name.endsWith("s)")) {
name = name.substring(0, name.length() - 2);
int index = name.lastIndexOf('(');
int nbSlots = NumericTools.parseInt(name.substring(index + 1), 0);
name = name.substring(0, index).trim();
item.setEssenceSlots(nbSlots);
}
if (name.endsWith(")")) {
String newName = name.substring(0, name.length() - 1);
int index = newName.lastIndexOf('(');
String valueStr = newName.substring(index + 1);
int minLevel;
if ("TBD".equals(valueStr)) {
minLevel = -1;
} else {
minLevel = NumericTools.parseInt(valueStr, -1);
name = newName.substring(0, index).trim();
}
if (minLevel > 0) {
item.setMinLevel(Integer.valueOf(minLevel));
}
}
name = name.trim();
item.setName(name);
// Item level
if (itemLevel != -1) {
item.setItemLevel(Integer.valueOf(itemLevel));
}
// Stats
item.getStats().setStats(stats);
String slices = provider.toPersistableString();
int nbSlices = ((SlicesBasedItemStatsProvider) provider).getSlices();
if (nbSlices > 0) {
item.setProperty(ItemPropertyNames.FORMULAS, slices);
}
// Slot
EquipmentLocation slot = null;
if ("Head".equals(_section))
slot = EquipmentLocation.HEAD;
else if ("Shoulders".equals(_section))
slot = EquipmentLocation.SHOULDER;
else if ("Chest".equals(_section))
slot = EquipmentLocation.CHEST;
else if ("Hands".equals(_section))
slot = EquipmentLocation.HAND;
else if ("Legs".equals(_section))
slot = EquipmentLocation.LEGS;
else if ("Feet".equals(_section))
slot = EquipmentLocation.FEET;
else if ("Shields".equals(_section))
slot = EquipmentLocation.OFF_HAND;
else if ("Ears".equals(_section))
slot = EquipmentLocation.EAR;
else if ("Neck".equals(_section))
slot = EquipmentLocation.NECK;
else if ("Wrists".equals(_section))
slot = EquipmentLocation.WRIST;
else if ("Fingers".equals(_section))
slot = EquipmentLocation.FINGER;
else if ("Pockets".equals(_section))
slot = EquipmentLocation.POCKET;
if (slot == null) {
int categoryIndex = table.getCategoryIndex();
if ((categoryIndex > 0) && (fields.length >= categoryIndex)) {
String category = fields[categoryIndex];
slot = getSlotFromCategory(category);
}
}
// Class requirement
String classRequirementStr = "";
int classesIndex = table.getClassesIndex();
if ((classesIndex != -1) && (fields.length >= classesIndex)) {
classRequirementStr = fields[classesIndex].trim();
}
CharacterClass classRequirement = getClassRequirement(classRequirementStr);
if (classRequirement != null) {
item.setRequiredClass(classRequirement);
}
if ("Burglar Signals".equals(_section)) {
item.setSubCategory("Burglar:Signal");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.BURGLAR);
} else if ("Captain Standards".equals(_section)) {
item.setSubCategory("Captain:Standard");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.CAPTAIN);
} else if ("Hunter Tomes".equals(_section)) {
String subCategory = "Tome";
if (name.contains("Wind-rider"))
subCategory = "Wind-rider";
if (name.contains("Whisper-draw"))
subCategory = "Whisper-draw";
item.setSubCategory("Hunter:" + subCategory);
slot = EquipmentLocation.CLASS_SLOT;
item.setRequiredClass(CharacterClass.HUNTER);
} else if ("Lore-master Brooches".equals(_section)) {
item.setSubCategory("Lore-master:Stickpin");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.LORE_MASTER);
} else if ("Minstrel Instruments".equals(_section)) {
item.setSubCategory("Instrument");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.MINSTREL);
} else if ("Rune-keeper Chisels".equals(_section)) {
String subCategory = "Other";
if (name.contains("Riffler"))
subCategory = "Riffler";
if (name.contains("Chisel"))
subCategory = "Chisel";
item.setSubCategory("Rune-keeper:" + subCategory);
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.RUNE_KEEPER);
} else if ("Warden Carvings".equals(_section)) {
item.setSubCategory("Warden:Carving");
slot = EquipmentLocation.CLASS_SLOT;
item.setRequiredClass(CharacterClass.WARDEN);
}
if (slot != null) {
item.setEquipmentLocation(slot);
}
return item;
}
Aggregations