Search in sources :

Example 6 with CharacterData

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

the class CharacterFileWindowController method exportCharacterData.

private void exportCharacterData() {
    GenericTableController<CharacterData> controller = _toonsTable.getTableController();
    CharacterData data = controller.getSelectedItem();
    if (data != null) {
        FileChooserController ctrl = new FileChooserController("export", "Export character...");
        File toFile = ctrl.chooseFile(getWindow(), "Export");
        if (toFile != null) {
            boolean doIt = true;
            if (!toFile.getName().toLowerCase().endsWith(".xml")) {
                toFile = new File(toFile.getParentFile(), toFile.getName() + ".xml");
            }
            if (toFile.exists()) {
                doIt = false;
                int result = GuiFactory.showQuestionDialog(getFrame(), "Do you really want to overwrite the selected file?", "Overwrite?", JOptionPane.YES_NO_OPTION);
                if (result == JOptionPane.OK_OPTION) {
                    doIt = true;
                }
            }
            if (doIt) {
                File sourceFile = data.getFile();
                boolean ok = FileCopy.copy(sourceFile, toFile);
                Window window = getWindow();
                if (ok) {
                    GuiFactory.showInformationDialog(window, "Export OK!", "OK!");
                } else {
                    GuiFactory.showErrorDialog(window, "Export failed!", "Error!");
                }
            }
        }
    }
}
Also used : Window(java.awt.Window) CharacterData(delta.games.lotro.character.CharacterData) FileChooserController(delta.games.lotro.utils.gui.filechooser.FileChooserController) CharacterFile(delta.games.lotro.character.CharacterFile) File(java.io.File)

Example 7 with CharacterData

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

the class CharacterFileWindowController method actionPerformed.

/**
 * Handle button actions.
 * @param e Source event.
 */
@Override
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if (LOG_COMMAND.equals(command)) {
        // Show log
        String serverName = _toon.getServerName();
        String toonName = _toon.getName();
        String id = CharacterLogWindowController.getIdentifier(serverName, toonName);
        WindowController controller = _windowsManager.getWindow(id);
        if (controller == null) {
            controller = new CharacterLogWindowController(_toon);
            _windowsManager.registerWindow(controller);
            controller.getWindow().setLocationRelativeTo(getFrame());
        }
        controller.bringToFront();
    } else if (REPUTATION_COMMAND.equals(command)) {
        // Reputation
        CharacterReputationDialogController controller = new CharacterReputationDialogController(this, _toon);
        controller.editModal();
    } else if (LEVEL_COMMAND.equals(command)) {
        // Level history
        LevelHistoryEditionDialogController controller = new LevelHistoryEditionDialogController(this, _toon);
        controller.editModal();
    } else if (CRAFTING_COMMAND.equals(command)) {
        // Crafting
        CraftingWindowController controller = new CraftingWindowController(this, _toon);
        controller.editModal();
    } else if (STASH_COMMAND.equals(command)) {
        showStash();
    } else if (TRAIT_POINTS_COMMAND.equals(command)) {
        editTraitPoints();
    } else if (NEW_TOON_DATA_ID.equals(command)) {
        startNewCharacterData();
    } else if (CLONE_TOON_DATA_ID.equals(command)) {
        cloneCharacterData();
    } else if (EXPORT_TOON_DATA_ID.equals(command)) {
        exportCharacterData();
    } else if (REMOVE_TOON_DATA_ID.equals(command)) {
        removeCharacterData();
    } else if (GenericTableController.DOUBLE_CLICK.equals(command)) {
        CharacterData data = (CharacterData) e.getSource();
        showCharacterData(data);
    }
}
Also used : CharacterLogWindowController(delta.games.lotro.gui.log.CharacterLogWindowController) CraftingWindowController(delta.games.lotro.gui.stats.crafting.CraftingWindowController) LevelHistoryEditionDialogController(delta.games.lotro.gui.stats.levelling.LevelHistoryEditionDialogController) CharacterData(delta.games.lotro.character.CharacterData) CharacterReputationDialogController(delta.games.lotro.gui.stats.reputation.CharacterReputationDialogController) CraftingWindowController(delta.games.lotro.gui.stats.crafting.CraftingWindowController) WindowController(delta.common.ui.swing.windows.WindowController) DefaultWindowController(delta.common.ui.swing.windows.DefaultWindowController) StashWindowController(delta.games.lotro.gui.character.stash.StashWindowController) TraitPointsEditionWindowController(delta.games.lotro.gui.stats.traitPoints.TraitPointsEditionWindowController) CharacterLogWindowController(delta.games.lotro.gui.log.CharacterLogWindowController)

Example 8 with CharacterData

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

the class CharacterFileWindowController method removeCharacterData.

private void removeCharacterData() {
    GenericTableController<CharacterData> controller = _toonsTable.getTableController();
    CharacterData data = controller.getSelectedItem();
    if (data != null) {
        // Check deletion
        String serverName = data.getServer();
        String toonName = data.getName();
        int result = GuiFactory.showQuestionDialog(getFrame(), "Do you really want to delete this configuration of " + toonName + "@" + serverName + "?", "Delete?", JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.OK_OPTION) {
            String id = CharacterDataWindowController.getIdentifier(data);
            WindowController windowController = _windowsManager.getWindow(id);
            if (windowController != null) {
                windowController.dispose();
            }
            boolean ok = _toon.getInfosManager().remove(data);
            if (ok) {
                CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_REMOVED, _toon, data);
                EventsManager.invokeEvent(event);
            }
        }
    }
}
Also used : CharacterEvent(delta.games.lotro.character.events.CharacterEvent) CharacterData(delta.games.lotro.character.CharacterData) CraftingWindowController(delta.games.lotro.gui.stats.crafting.CraftingWindowController) WindowController(delta.common.ui.swing.windows.WindowController) DefaultWindowController(delta.common.ui.swing.windows.DefaultWindowController) StashWindowController(delta.games.lotro.gui.character.stash.StashWindowController) TraitPointsEditionWindowController(delta.games.lotro.gui.stats.traitPoints.TraitPointsEditionWindowController) CharacterLogWindowController(delta.games.lotro.gui.log.CharacterLogWindowController)

Example 9 with CharacterData

use of delta.games.lotro.character.CharacterData 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 10 with CharacterData

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

the class AllEssencesEditionWindowController 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 == _toon) {
            _editionController.update();
            getWindow().pack();
        }
    }
}
Also used : CharacterEventType(delta.games.lotro.character.events.CharacterEventType) CharacterData(delta.games.lotro.character.CharacterData)

Aggregations

CharacterData (delta.games.lotro.character.CharacterData)31 CharacterGenerationTools (delta.games.lotro.character.stats.CharacterGenerationTools)8 JFrame (javax.swing.JFrame)7 CharacterFile (delta.games.lotro.character.CharacterFile)6 CharacterGeneratorMeva (delta.games.lotro.character.stats.CharacterGeneratorMeva)6 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)5 CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)5 CharacterInfosManager (delta.games.lotro.character.CharacterInfosManager)4 CharacterEvent (delta.games.lotro.character.events.CharacterEvent)4 CharacterEventType (delta.games.lotro.character.events.CharacterEventType)4 DefaultWindowController (delta.common.ui.swing.windows.DefaultWindowController)3 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)3 CharacterClass (delta.games.lotro.common.CharacterClass)3 File (java.io.File)3 JPanel (javax.swing.JPanel)3 WindowController (delta.common.ui.swing.windows.WindowController)2 CharacterEquipment (delta.games.lotro.character.CharacterEquipment)2 CharactersManager (delta.games.lotro.character.CharactersManager)2 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)2 CharacterGeneratorGiswald (delta.games.lotro.character.stats.CharacterGeneratorGiswald)2