Search in sources :

Example 16 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class TraitPoints method save.

/**
 * Save the trait points status for a character.
 * @param character Targeted character.
 * @param status Status to save.
 * @return <code>true</code> if it succeeds, <code>false</code> otherwise.
 */
public boolean save(CharacterFile character, TraitPointsStatus status) {
    File toFile = getStatusFile(character);
    TraitPointsStatusXMLWriter writer = new TraitPointsStatusXMLWriter();
    boolean ok = writer.write(toFile, status, EncodingNames.UTF_8);
    return ok;
}
Also used : TraitPointsStatusXMLWriter(delta.games.lotro.stats.traitPoints.io.xml.TraitPointsStatusXMLWriter) CharacterFile(delta.games.lotro.character.CharacterFile) File(java.io.File)

Example 17 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CharactersSelectorPanelController method itemStateChanged.

@Override
public void itemStateChanged(ItemEvent e) {
    JCheckBox source = (JCheckBox) e.getItemSelectable();
    for (Map.Entry<String, JCheckBox> entry : _checkboxes.entrySet()) {
        JCheckBox cb = entry.getValue();
        if (cb == source) {
            String id = entry.getKey();
            boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
            CharacterFile toon = _toonsMap.get(id);
            if (selected) {
                _selectedToons.add(toon);
            } else {
                _selectedToons.remove(toon);
            }
            broadcastToonSelectionChange(id, selected);
            break;
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) HashMap(java.util.HashMap) Map(java.util.Map) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 18 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CharacterDataWindowController method eventOccurred.

/**
 * Handle character events.
 * @param event Source event.
 */
@Override
public void eventOccurred(CharacterEvent event) {
    CharacterEventType type = event.getType();
    if (type == CharacterEventType.CHARACTER_DATA_UPDATED) {
        CharacterData data = event.getToonData();
        if (data == _data) {
            // Compute new stats
            CharacterStatsComputer computer = new CharacterStatsComputer();
            BasicStatsSet stats = computer.getStats(data);
            BasicStatsSet toonStats = _data.getStats();
            toonStats.clear();
            toonStats.setStats(stats);
            // Update stats display
            _statsController.update();
            // Update buffs display
            _buffsController.update();
        }
    }
    if (type == CharacterEventType.CHARACTER_SUMMARY_UPDATED) {
        CharacterFile toonFile = event.getToonFile();
        if (toonFile == _toonFile) {
            // Update sex
            _attrsController.updateSexDisplay();
        }
    }
}
Also used : CharacterEventType(delta.games.lotro.character.events.CharacterEventType) CharacterData(delta.games.lotro.character.CharacterData) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 19 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CharactersSelectorPanelController method refresh.

/**
 * Refresh the managed panel (to synchronize with new/removed toons).
 */
public void refresh() {
    if (_panel != null) {
        _panel.removeAll();
        GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0);
        int nbItems = _toons.size();
        int[] size = getGridSize(nbItems);
        for (CharacterFile toon : _toons) {
            String toonID = toon.getIdentifier();
            JCheckBox cb = _checkboxes.get(toonID);
            if (cb == null) {
                cb = buildToonCheckbox(toon);
            }
            if (cb != null) {
                _panel.add(cb, c);
                c.gridy++;
                if (size[1] == c.gridy) {
                    c.gridx++;
                    c.gridy = 0;
                }
            }
        }
        _panel.revalidate();
        _panel.repaint();
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 20 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class MainTestShowCharacterLog method main.

/**
 * Basic main method for test.
 * @param args Not used.
 */
public static void main(String[] args) {
    LotroTestUtils utils = new LotroTestUtils();
    CharacterFile toon = utils.getToonByName("Glumlug");
    CharacterLog log = toon.getLastCharacterLog();
    if (log != null) {
        CharacterLogWindowController controller = new CharacterLogWindowController(toon);
        controller.show();
    }
}
Also used : LotroTestUtils(delta.games.lotro.character.log.LotroTestUtils) CharacterFile(delta.games.lotro.character.CharacterFile) CharacterLog(delta.games.lotro.character.log.CharacterLog)

Aggregations

CharacterFile (delta.games.lotro.character.CharacterFile)42 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)13 ArrayList (java.util.ArrayList)11 CharactersManager (delta.games.lotro.character.CharactersManager)9 JPanel (javax.swing.JPanel)6 CharacterData (delta.games.lotro.character.CharacterData)5 CharacterLog (delta.games.lotro.character.log.CharacterLog)5 Preferences (delta.common.utils.misc.Preferences)4 TypedProperties (delta.common.utils.misc.TypedProperties)4 CraftingStatus (delta.games.lotro.character.crafting.CraftingStatus)3 CharacterEventType (delta.games.lotro.character.events.CharacterEventType)3 File (java.io.File)3 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)2 TableColumnController (delta.common.ui.swing.tables.TableColumnController)2 CharacterInfosManager (delta.games.lotro.character.CharacterInfosManager)2 CharacterSummary (delta.games.lotro.character.CharacterSummary)2 ProfessionStatus (delta.games.lotro.character.crafting.ProfessionStatus)2 CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)2 Profession (delta.games.lotro.lore.crafting.Profession)2 GridBagConstraints (java.awt.GridBagConstraints)2