Search in sources :

Example 1 with ClassFacade

use of pcgen.facade.core.ClassFacade in project pcgen by PCGen.

the class CharacterFacadeImpl method removeCharacterLevels.

/**
	 * @see pcgen.core.facade.CharacterFacade#removeCharacterLevels(int)
	 */
@Override
public void removeCharacterLevels(int levels) {
    for (int i = levels; i > 0 && !pcClassLevels.isEmpty(); i--) {
        ClassFacade classFacade = charLevelsFacade.getClassTaken(pcClassLevels.getElementAt(pcClassLevels.getSize() - 1));
        pcClassLevels.removeElement(pcClassLevels.getSize() - 1);
        if (classFacade instanceof PCClass) {
            Logging.log(Logging.INFO, charDisplay.getName() + ": Removing level " + //$NON-NLS-1$
            (pcClassLevels.getSize() + 1) + " in class " + //$NON-NLS-1$
            classFacade);
            theCharacter.incrementClassLevel(-1, (PCClass) classFacade);
        }
        charLevelsFacade.removeLastLevel();
    }
    // Clean up the class list 
    for (Iterator<ClassFacade> iterator = pcClasses.iterator(); iterator.hasNext(); ) {
        ClassFacade classFacade = iterator.next();
        boolean stillPresent = false;
        for (CharacterLevelFacade charLevel : pcClassLevels) {
            if (charLevelsFacade.getClassTaken(charLevel) == classFacade) {
                stillPresent = true;
                break;
            }
        }
        if (!stillPresent) {
            iterator.remove();
        }
    }
    postLevellingUpdates();
}
Also used : CharacterLevelFacade(pcgen.facade.core.CharacterLevelFacade) ClassFacade(pcgen.facade.core.ClassFacade) PCClass(pcgen.core.PCClass)

Example 2 with ClassFacade

use of pcgen.facade.core.ClassFacade in project pcgen by PCGen.

the class QualifiedSpellTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean focus) {
    Object obj = ((DefaultMutableTreeNode) value).getUserObject();
    if (//$NON-NLS-1$
    "".equals(obj)) {
        //$NON-NLS-1$
        obj = LanguageBundle.getString("in_none");
    }
    super.getTreeCellRendererComponent(tree, obj, sel, expanded, leaf, row, focus);
    if (obj instanceof SpellNode) {
        SpellNode spellNode = (SpellNode) obj;
        SpellFacade spell = spellNode.getSpell();
        ClassFacade pcClass = spellNode.getSpellcastingClass();
        if (!character.isQualifiedFor(spell, pcClass)) {
            setForeground(UIPropertyContext.getNotQualifiedColor());
        }
    }
    if (obj instanceof InfoFacade && ((InfoFacade) obj).isNamePI()) {
        setFont(FontManipulation.bold_italic(getFont()));
    } else {
        setFont(FontManipulation.plain(getFont()));
    }
    return this;
}
Also used : SpellNode(pcgen.facade.core.SpellSupportFacade.SpellNode) ClassFacade(pcgen.facade.core.ClassFacade) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) InfoFacade(pcgen.facade.core.InfoFacade) SpellFacade(pcgen.facade.core.SpellFacade)

Example 3 with ClassFacade

use of pcgen.facade.core.ClassFacade in project pcgen by PCGen.

the class ClassLevelTableModel method getValueAt.

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    if (rowIndex == levels.getSize()) {
        return null;
    }
    switch(columnIndex) {
        case 0:
            return rowIndex + 1;
        case 1:
            return levels.getHPGained(levels.getElementAt(rowIndex));
        case 2:
            ClassFacade c = levels.getClassTaken(levels.getElementAt(rowIndex));
            String classKey = c.getKeyName();
            if (finalLevelMap.get(classKey) == rowIndex) {
                return c.toString() + " (" + character.getClassLevel(c) + ")";
            }
            return c.toString();
        default:
            return null;
    }
}
Also used : ClassFacade(pcgen.facade.core.ClassFacade)

Example 4 with ClassFacade

use of pcgen.facade.core.ClassFacade in project pcgen by PCGen.

the class ClassInfoHandler method valueChanged.

@Override
public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {
        TreePath path;
        if (e.getSource() == availableTable.getSelectionModel()) {
            path = availableTable.getTree().getSelectionPath();
        } else {
            path = selectedTable.getTree().getSelectionPath();
        }
        if (path == null) {
            return;
        }
        ClassFacade c = null;
        DefaultMutableTreeNode treenode = (DefaultMutableTreeNode) path.getLastPathComponent();
        Object[] objs = treenode.getUserObjectPath();
        for (Object object : objs) {
            if (object instanceof ClassFacade) {
                c = (ClassFacade) object;
                break;
            }
        }
        if (c != null) {
            text = character.getSpellSupport().getClassInfo(c);
            classPane.setText(text);
        }
    }
}
Also used : ClassFacade(pcgen.facade.core.ClassFacade) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 5 with ClassFacade

use of pcgen.facade.core.ClassFacade in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

@Override
public String getHTMLInfo(InfoFacade facade) {
    if (facade == null) {
        return EMPTY_STRING;
    }
    // Use a more detailed info if we can
    if (facade instanceof AbilityFacade) {
        return getHTMLInfo((AbilityFacade) facade);
    }
    if (facade instanceof ClassFacade) {
        return getHTMLInfo((ClassFacade) facade, null);
    }
    if (facade instanceof DeityFacade) {
        return getHTMLInfo((DeityFacade) facade);
    }
    if (facade instanceof DomainFacade) {
        return getHTMLInfo((DomainFacade) facade);
    }
    if (facade instanceof EquipmentFacade) {
        return getHTMLInfo((EquipmentFacade) facade);
    }
    if (facade instanceof KitFacade) {
        return getHTMLInfo((KitFacade) facade);
    }
    if (facade instanceof RaceFacade) {
        return getHTMLInfo((RaceFacade) facade);
    }
    if (facade instanceof SkillFacade) {
        return getHTMLInfo((SkillFacade) facade);
    }
    if (facade instanceof SpellFacade) {
        return getHTMLInfo((SpellFacade) facade);
    }
    if (facade instanceof TempBonusFacade) {
        return getHTMLInfo((TempBonusFacade) facade);
    }
    if (facade instanceof TemplateFacade) {
        return getHTMLInfo((TemplateFacade) facade);
    }
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
    infoText.appendTitleElement(facade.toString());
    infoText.appendLineBreak();
    if (!facade.getType().isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nElement("in_irInfoType", facade.getType());
        infoText.appendLineBreak();
    }
    infoText.appendI18nElement(//$NON-NLS-1$
    "in_itmInfoLabelTextSource", facade.getSource());
    return infoText.toString();
}
Also used : DomainFacade(pcgen.facade.core.DomainFacade) EquipmentFacade(pcgen.facade.core.EquipmentFacade) ClassFacade(pcgen.facade.core.ClassFacade) KitFacade(pcgen.facade.core.KitFacade) TempBonusFacade(pcgen.facade.core.TempBonusFacade) AbilityFacade(pcgen.facade.core.AbilityFacade) SkillFacade(pcgen.facade.core.SkillFacade) DeityFacade(pcgen.facade.core.DeityFacade) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) RaceFacade(pcgen.facade.core.RaceFacade) SpellFacade(pcgen.facade.core.SpellFacade) TemplateFacade(pcgen.facade.core.TemplateFacade)

Aggregations

ClassFacade (pcgen.facade.core.ClassFacade)8 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 PCClass (pcgen.core.PCClass)2 SpellFacade (pcgen.facade.core.SpellFacade)2 BorderLayout (java.awt.BorderLayout)1 Box (javax.swing.Box)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 EmptyBorder (javax.swing.border.EmptyBorder)1 TreePath (javax.swing.tree.TreePath)1 AbilityFacade (pcgen.facade.core.AbilityFacade)1 CharacterLevelFacade (pcgen.facade.core.CharacterLevelFacade)1 DeityFacade (pcgen.facade.core.DeityFacade)1 DomainFacade (pcgen.facade.core.DomainFacade)1 EquipmentFacade (pcgen.facade.core.EquipmentFacade)1 InfoFacade (pcgen.facade.core.InfoFacade)1 KitFacade (pcgen.facade.core.KitFacade)1 RaceFacade (pcgen.facade.core.RaceFacade)1 SkillFacade (pcgen.facade.core.SkillFacade)1 SpellNode (pcgen.facade.core.SpellSupportFacade.SpellNode)1