Search in sources :

Example 1 with CharacterInfosManager

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

the class CharacterFileWindowController method startNewCharacterData.

private void startNewCharacterData() {
    CharacterInfosManager infos = _toon.getInfosManager();
    CharacterData lastInfos = infos.getLastCharacterDescription();
    CharacterData newInfos = new CharacterData();
    CharacterSummary newSummary;
    if (lastInfos != null) {
        newSummary = new CharacterSummary(lastInfos.getSummary());
    } else {
        newSummary = new CharacterSummary(_toon.getSummary());
    }
    newInfos.setSummary(newSummary);
    newInfos.setDate(Long.valueOf(System.currentTimeMillis()));
    // Compute stats
    CharacterStatsComputer computer = new CharacterStatsComputer();
    newInfos.getStats().setStats(computer.getStats(newInfos));
    boolean ok = _toon.getInfosManager().writeNewCharacterData(newInfos);
    if (ok) {
        CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_ADDED, _toon, newInfos);
        EventsManager.invokeEvent(event);
        showCharacterData(newInfos);
    }
}
Also used : CharacterSummary(delta.games.lotro.character.CharacterSummary) CharacterEvent(delta.games.lotro.character.events.CharacterEvent) CharacterData(delta.games.lotro.character.CharacterData) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) CharacterInfosManager(delta.games.lotro.character.CharacterInfosManager)

Example 2 with CharacterInfosManager

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

the class CharacterFileWindowController method cloneCharacterData.

private void cloneCharacterData() {
    GenericTableController<CharacterData> controller = _toonsTable.getTableController();
    CharacterData data = controller.getSelectedItem();
    if (data != null) {
        // Build new configuration
        CharacterData newInfos = new CharacterData(data);
        newInfos.setDate(Long.valueOf(System.currentTimeMillis()));
        // Register new configuration
        CharacterInfosManager infos = _toon.getInfosManager();
        boolean ok = infos.writeNewCharacterData(newInfos);
        if (ok) {
            CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_ADDED, _toon, newInfos);
            EventsManager.invokeEvent(event);
        }
    }
}
Also used : CharacterEvent(delta.games.lotro.character.events.CharacterEvent) CharacterData(delta.games.lotro.character.CharacterData) CharacterInfosManager(delta.games.lotro.character.CharacterInfosManager)

Example 3 with CharacterInfosManager

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

the class MainTestEquipmentLoading method main.

/**
 * Basic main method for test.
 * @param args Not used.
 */
public static void main(String[] args) {
    LotroTestUtils utils = new LotroTestUtils();
    // List<CharacterFile> toons=utils.getAllFiles();
    CharacterFile toon = utils.getMainToon();
    // for(CharacterFile toon : toons)
    {
        String name = toon.getName();
        System.out.println("Loading toon [" + name + "]");
        CharacterInfosManager manager = new CharacterInfosManager(toon);
        CharacterData infos = manager.getLastCharacterDescription();
        if (infos != null) {
            EquipmentPanelController ctrl = new EquipmentPanelController(null, toon, infos);
            JPanel panel = ctrl.getPanel();
            JFrame frame = new JFrame("Equipment for " + toon.getName());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // Create and set up the content pane.
            frame.setContentPane(panel);
            // Display the window.
            frame.pack();
            frame.setVisible(true);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) EquipmentPanelController(delta.games.lotro.gui.character.gear.EquipmentPanelController) CharacterData(delta.games.lotro.character.CharacterData) LotroTestUtils(delta.games.lotro.character.log.LotroTestUtils) JFrame(javax.swing.JFrame) CharacterInfosManager(delta.games.lotro.character.CharacterInfosManager) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 4 with CharacterInfosManager

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

the class ToonsManagementController method importToon.

private void importToon() {
    FileChooserController ctrl = new FileChooserController("import", "Import character...");
    Window window = _parentController.getWindow();
    File fromFile = ctrl.chooseFile(window, "Import");
    if (fromFile != null) {
        CharacterXMLParser parser = new CharacterXMLParser();
        CharacterData data = new CharacterData();
        boolean ok = parser.parseXML(fromFile, data);
        if (ok) {
            CharactersManager manager = CharactersManager.getInstance();
            CharacterFile toon = manager.getToonById(data.getServer(), data.getName());
            if (toon != null) {
                CharacterInfosManager infos = toon.getInfosManager();
                ok = infos.writeNewCharacterData(data);
                if (ok) {
                    CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_ADDED, toon, data);
                    EventsManager.invokeEvent(event);
                }
            } else {
                CharacterFile newFile = manager.addToon(data);
                ok = (newFile != null);
            }
            if (ok) {
                GuiFactory.showInformationDialog(window, "Import OK!", "OK!");
            } else {
                GuiFactory.showErrorDialog(window, "Import failed!", "Error!");
            }
        } else {
            GuiFactory.showErrorDialog(window, "Import failed (bad XML file)!", "Error!");
        }
    }
}
Also used : Window(java.awt.Window) CharactersManager(delta.games.lotro.character.CharactersManager) CharacterEvent(delta.games.lotro.character.events.CharacterEvent) CharacterData(delta.games.lotro.character.CharacterData) FileChooserController(delta.games.lotro.utils.gui.filechooser.FileChooserController) CharacterXMLParser(delta.games.lotro.character.io.xml.CharacterXMLParser) CharacterInfosManager(delta.games.lotro.character.CharacterInfosManager) CharacterFile(delta.games.lotro.character.CharacterFile) File(java.io.File) CharacterFile(delta.games.lotro.character.CharacterFile)

Aggregations

CharacterData (delta.games.lotro.character.CharacterData)4 CharacterInfosManager (delta.games.lotro.character.CharacterInfosManager)4 CharacterEvent (delta.games.lotro.character.events.CharacterEvent)3 CharacterFile (delta.games.lotro.character.CharacterFile)2 CharacterSummary (delta.games.lotro.character.CharacterSummary)1 CharactersManager (delta.games.lotro.character.CharactersManager)1 CharacterXMLParser (delta.games.lotro.character.io.xml.CharacterXMLParser)1 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)1 CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)1 EquipmentPanelController (delta.games.lotro.gui.character.gear.EquipmentPanelController)1 FileChooserController (delta.games.lotro.utils.gui.filechooser.FileChooserController)1 Window (java.awt.Window)1 File (java.io.File)1 JFrame (javax.swing.JFrame)1 JPanel (javax.swing.JPanel)1