Search in sources :

Example 1 with FactionStatus

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

the class CharacterReputationDialogController method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    // +/- buttons
    Object source = event.getSource();
    for (FactionEditionPanelController editor : _editors.values()) {
        if (source == editor.getMinusButton()) {
            Faction faction = editor.getFaction();
            _data.updateFaction(faction, false);
            updateFactionDisplay(editor);
            _deedsDisplay.update();
            _rewardsDisplay.update();
        } else if (source == editor.getPlusButton()) {
            Faction faction = editor.getFaction();
            _data.updateFaction(faction, true);
            updateFactionDisplay(editor);
            _deedsDisplay.update();
            _rewardsDisplay.update();
        } else if (source == editor.getEditButton()) {
            Faction faction = editor.getFaction();
            FactionStatus status = _data.getOrCreateFactionStat(faction);
            FactionEditionDialogController edit = new FactionEditionDialogController(this, status);
            edit.show(true);
            updateFactionDisplay(editor);
            _deedsDisplay.update();
            _rewardsDisplay.update();
        }
    }
}
Also used : FactionEditionDialogController(delta.games.lotro.gui.stats.reputation.form.FactionEditionDialogController) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) Faction(delta.games.lotro.lore.reputation.Faction)

Example 2 with FactionStatus

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

the class CharacterReputationDialogController method updateFactionDisplay.

private void updateFactionDisplay(FactionEditionPanelController editor) {
    Faction faction = editor.getFaction();
    FactionLevel current;
    FactionStatus factionStatus = _data.getFactionStatus(faction);
    if (factionStatus != null) {
        current = factionStatus.getFactionLevel();
    } else {
        current = faction.getInitialLevel();
    }
    editor.setFactionLevel(current);
}
Also used : FactionLevel(delta.games.lotro.lore.reputation.FactionLevel) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) Faction(delta.games.lotro.lore.reputation.Faction)

Example 3 with FactionStatus

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

the class ReputationSynopsisTableController method buildFactionStatusCellRenderer.

/**
 * Build a cell renderer for a faction status.
 * @return A renderer.
 */
public static TableCellRenderer buildFactionStatusCellRenderer() {
    final JLabel label = GuiFactory.buildLabel("");
    TableCellRenderer renderer = new TableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            FactionStatus status = (FactionStatus) value;
            configureFactionLabel(label, status);
            return label;
        }
    };
    return renderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JTable(javax.swing.JTable) JLabel(javax.swing.JLabel) FactionStatus(delta.games.lotro.character.reputation.FactionStatus)

Example 4 with FactionStatus

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

the class CraftingSynopsisTableController method buildGuildColumn.

private TableColumnController<CraftingSynopsisItem, FactionStatus> buildGuildColumn() {
    CellDataProvider<CraftingSynopsisItem, FactionStatus> cell = new CellDataProvider<CraftingSynopsisItem, FactionStatus>() {

        @Override
        public FactionStatus getData(CraftingSynopsisItem item) {
            return item.getGuildFaction();
        }
    };
    String columnName = "Guild";
    String id = columnName;
    TableColumnController<CraftingSynopsisItem, FactionStatus> column = new TableColumnController<CraftingSynopsisItem, FactionStatus>(id, columnName, FactionStatus.class, cell);
    // Header cell renderer
    JPanel panel = buildGuildPanel();
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(panel);
    column.setHeaderCellRenderer(headerRenderer);
    // Cell renderer
    TableCellRenderer renderer = ReputationSynopsisTableController.buildFactionStatusCellRenderer();
    column.setCellRenderer(renderer);
    // Init widths
    column.setMinWidth(150);
    column.setPreferredWidth(200);
    column.setMaxWidth(300);
    // Comparator
    final FactionLevelComparator factionLevelComparator = new FactionLevelComparator();
    Comparator<FactionStatus> statsComparator = new Comparator<FactionStatus>() {

        @Override
        public int compare(FactionStatus data1, FactionStatus data2) {
            return factionLevelComparator.compare(data1.getFactionLevel(), data2.getFactionLevel());
        }
    };
    column.setComparator(statsComparator);
    return column;
}
Also used : FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) ProfessionComparator(delta.games.lotro.lore.crafting.ProfessionComparator) Comparator(java.util.Comparator)

Example 5 with FactionStatus

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

the class ReputationSynopsisTableController method buildCharacterColumn.

private TableColumnController<Faction, FactionStatus> buildCharacterColumn(CharacterFile character) {
    final CharacterFile toon = character;
    CellDataProvider<Faction, FactionStatus> cell = new CellDataProvider<Faction, FactionStatus>() {

        @Override
        public FactionStatus getData(Faction item) {
            ReputationStatus status = toon.getReputation();
            return status.getOrCreateFactionStat(item);
        }
    };
    String id = character.getIdentifier();
    TableColumnController<Faction, FactionStatus> column = new TableColumnController<Faction, FactionStatus>(id, "Faction", FactionStatus.class, cell);
    // Cell renderer
    TableCellRenderer renderer = buildFactionStatusCellRenderer();
    column.setCellRenderer(renderer);
    // Header renderer
    JPanel headerPanel = buildToonHeaderPanel(character);
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(headerPanel);
    column.setHeaderCellRenderer(headerRenderer);
    int minWidth = headerPanel.getPreferredSize().width;
    column.setMinWidth(minWidth);
    column.setPreferredWidth(minWidth);
    // Comparator
    final FactionLevelComparator factionLevelComparator = new FactionLevelComparator();
    Comparator<FactionStatus> statsComparator = new Comparator<FactionStatus>() {

        @Override
        public int compare(FactionStatus data1, FactionStatus data2) {
            return factionLevelComparator.compare(data1.getFactionLevel(), data2.getFactionLevel());
        }
    };
    column.setComparator(statsComparator);
    return column;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JPanel(javax.swing.JPanel) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CharacterFile(delta.games.lotro.character.CharacterFile) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) Comparator(java.util.Comparator) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) ReputationStatus(delta.games.lotro.character.reputation.ReputationStatus) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) Faction(delta.games.lotro.lore.reputation.Faction)

Aggregations

FactionStatus (delta.games.lotro.character.reputation.FactionStatus)5 Faction (delta.games.lotro.lore.reputation.Faction)3 TableCellRenderer (javax.swing.table.TableCellRenderer)3 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)2 TableColumnController (delta.common.ui.swing.tables.TableColumnController)2 FactionLevelComparator (delta.games.lotro.lore.reputation.FactionLevelComparator)2 Comparator (java.util.Comparator)2 JPanel (javax.swing.JPanel)2 CharacterFile (delta.games.lotro.character.CharacterFile)1 ReputationStatus (delta.games.lotro.character.reputation.ReputationStatus)1 FactionEditionDialogController (delta.games.lotro.gui.stats.reputation.form.FactionEditionDialogController)1 ProfessionComparator (delta.games.lotro.lore.crafting.ProfessionComparator)1 FactionLevel (delta.games.lotro.lore.reputation.FactionLevel)1 JLabel (javax.swing.JLabel)1 JTable (javax.swing.JTable)1 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1