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);
}
}
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);
}
}
}
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);
}
}
}
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!");
}
}
}
Aggregations