use of delta.games.lotro.common.CharacterClass 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;
}
use of delta.games.lotro.common.CharacterClass in project lotro-companion by dmorcellet.
the class CharacterSummaryPanelController method buildPanel.
private JPanel buildPanel() {
JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0);
// Grab data
CharacterClass cClass = null;
Race race = null;
CharacterSex sex = null;
if (_summary != null) {
cClass = _summary.getCharacterClass();
race = _summary.getRace();
sex = _summary.getCharacterSex();
}
// Class
ImageIcon classIcon = LotroIconsManager.getClassIcon(cClass, LotroIconsManager.COMPACT_SIZE);
panel.add(GuiFactory.buildIconLabel(classIcon), c);
// Character icon
ImageIcon characterIcon = LotroIconsManager.getCharacterIcon(race, sex);
c.gridx = 1;
_characterIconLabel = GuiFactory.buildIconLabel(characterIcon);
panel.add(_characterIconLabel, c);
// Name
_nameLabel = GuiFactory.buildLabel("", 28.0f);
c.gridx = 2;
c.anchor = GridBagConstraints.CENTER;
c.weightx = 1.0;
c.fill = GridBagConstraints.BOTH;
panel.add(_nameLabel, c);
// Level
_levelLabel = GuiFactory.buildLabel("", 32.0f);
c.gridx = 3;
c.weightx = 0.0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
panel.add(_levelLabel, c);
c.gridx = 4;
JButton edit = GuiFactory.buildButton("Edit...");
ActionListener al = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
editSummary();
}
};
edit.addActionListener(al);
panel.add(edit, c);
update();
return panel;
}
use of delta.games.lotro.common.CharacterClass in project lotro-companion by dmorcellet.
the class TraitPointsRegistryXMLWriter method write.
/**
* Write a trait points registry to the given XML stream.
* @param hd XML output stream.
* @param point Trait point to write.
* @throws Exception
*/
private void write(TransformerHandler hd, TraitPoint point) throws Exception {
AttributesImpl attrs = new AttributesImpl();
// Identifier
String id = point.getId();
if (id != null) {
attrs.addAttribute("", "", TraitPointsRegistryXMLConstants.TRAIT_POINT_ID_ATTR, CDATA, id);
}
// Category
String category = point.getCategory();
if (category != null) {
attrs.addAttribute("", "", TraitPointsRegistryXMLConstants.TRAIT_POINT_CATEGORY_ATTR, CDATA, category);
}
// Label
String label = point.getLabel();
if (label != null) {
attrs.addAttribute("", "", TraitPointsRegistryXMLConstants.TRAIT_POINT_LABEL_ATTR, CDATA, label);
}
// Required class
Set<CharacterClass> requiredClasses = point.getRequiredClasses();
if (!requiredClasses.isEmpty()) {
String classes = buildClassRequirement(requiredClasses);
attrs.addAttribute("", "", TraitPointsRegistryXMLConstants.TRAIT_POINT_REQUIRED_CLASSES_ATTR, CDATA, classes);
}
hd.startElement("", "", TraitPointsRegistryXMLConstants.TRAIT_POINT_TAG, attrs);
hd.endElement("", "", TraitPointsRegistryXMLConstants.TRAIT_POINT_TAG);
}
use of delta.games.lotro.common.CharacterClass in project lotro-companion by dmorcellet.
the class TraitPointsRegistryXMLWriter method buildClassRequirement.
private String buildClassRequirement(Set<CharacterClass> classes) {
StringBuilder sb = new StringBuilder();
int index = 0;
for (CharacterClass characterClass : classes) {
if (index > 0) {
sb.append(',');
}
String key = characterClass.getKey();
sb.append(key);
index++;
}
return sb.toString();
}
use of delta.games.lotro.common.CharacterClass in project lotro-companion by dmorcellet.
the class ReputationSynopsisTableController method buildToonHeaderPanel.
private JPanel buildToonHeaderPanel(CharacterFile toon) {
JPanel panel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
// Class icon
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0);
ImageIcon classIcon = null;
CharacterSummary summary = toon.getSummary();
if (summary != null) {
CharacterClass cClass = summary.getCharacterClass();
classIcon = LotroIconsManager.getClassIcon(cClass, LotroIconsManager.COMPACT_SIZE);
}
JLabel classLabel;
if (classIcon != null) {
classLabel = new JLabel(classIcon);
} else {
classLabel = new JLabel("(class)");
}
panel.add(classLabel, c);
// Toon name
String name = toon.getName();
JLabel nameLabel = GuiFactory.buildLabel(name, 16.0f);
c = new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 2, 2), 0, 0);
panel.add(nameLabel, c);
return panel;
}
Aggregations