use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.
the class AbilityChooserTab method initComponents.
private void initComponents() {
setOrientation(VERTICAL_SPLIT);
availableTreeViewPanel.setDefaultRenderer(Boolean.class, new BooleanRenderer());
availableTreeViewPanel.setTreeCellRenderer(qualifiedRenderer);
selectedTreeViewPanel.setTreeCellRenderer(abilityRenderer);
FilterBar<CharacterFacade, AbilityFacade> filterBar = new FilterBar<>();
filterBar.addDisplayableFilter(new SearchFilterPanel());
//$NON-NLS-1$
qFilterButton.setText(LanguageBundle.getString("in_igQualFilter"));
filterBar.addDisplayableFilter(qFilterButton);
JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTreeViewPanel, filterBar);
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
addButton.setHorizontalTextPosition(SwingConstants.LEADING);
box.add(addButton);
box.add(Box.createHorizontalStrut(5));
box.setBorder(new EmptyBorder(0, 0, 5, 0));
availPanel.add(box, BorderLayout.SOUTH);
JPanel selPanel = new JPanel(new BorderLayout());
selPanel.add(new JScrollPane(selectedTreeViewPanel), BorderLayout.CENTER);
AbilityTreeTableModel.initializeTreeTable(selectedTreeViewPanel);
box = Box.createHorizontalBox();
box.add(Box.createHorizontalStrut(5));
box.add(removeButton);
box.add(Box.createHorizontalGlue());
box.setBorder(new EmptyBorder(0, 0, 5, 0));
selPanel.add(box, BorderLayout.SOUTH);
FlippingSplitPane topPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, availPanel, selPanel, "abilityTop");
setTopComponent(topPane);
FilterButton<CharacterFacade, AbilityCategoryFacade> gainedFilterButton = new FilterButton<>("AbilityGained", true);
//$NON-NLS-1$
gainedFilterButton.setText(LanguageBundle.getString("in_gained"));
gainedFilterButton.setEnabled(true);
gainedFilterButton.setFilter(new Filter<CharacterFacade, AbilityCategoryFacade>() {
@Override
public boolean accept(CharacterFacade context, AbilityCategoryFacade element) {
return context.getActiveAbilityCategories().containsElement(element);
}
});
categoryBar.addDisplayableFilter(gainedFilterButton);
JPanel filterPanel = new JPanel(new BorderLayout());
filterPanel.add(categoryBar, BorderLayout.NORTH);
filterPanel.add(new JScrollPane(categoryTable), BorderLayout.CENTER);
FlippingSplitPane bottomPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, "abilityBottom");
bottomPane.setLeftComponent(filterPanel);
bottomPane.setRightComponent(infoPane);
setBottomComponent(bottomPane);
}
use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.
the class CharacterAbilities method addElement.
private void addElement(Map<AbilityCategoryFacade, DefaultListFacade<AbilityFacade>> workingAbilityListMap, CNAbilitySelection cnas) {
CNAbility cas = cnas.getCNAbility();
Ability ability = cas.getAbility();
if (!ability.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
// Filter out hidden abilities
return;
}
AbilityCategoryFacade cat = (AbilityCategoryFacade) cas.getAbilityCategory();
DefaultListFacade<AbilityFacade> listFacade = workingAbilityListMap.get(cat);
if (listFacade == null) {
listFacade = new DefaultListFacade<>();
workingAbilityListMap.put(cat, listFacade);
}
if (!listFacade.containsElement(ability)) {
listFacade.addElement(ability);
}
}
use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method recalcCasterLevelDetails.
private void recalcCasterLevelDetails() {
// Metamagic
int levelAdjust = 0;
for (AbilityFacade feat : selMetamagicFeats) {
levelAdjust += ((Ability) feat).getSafe(IntegerKey.ADD_SPELL_LEVEL);
}
// Limit Caster level
int minClassLevel = 1;
int maxClassLevel = 20;
PCClass aClass;
InfoFacade castingClass = pcClass.get();
if (castingClass instanceof PCClass) {
aClass = (PCClass) castingClass;
} else if (castingClass instanceof Domain) {
// TODO We should not be hardcoding the link between cleric and domains
aClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, "Cleric");
} else {
Logging.errorPrint("Found Casting Class in recalc that was not a Class or Domain: " + castingClass.getClass());
return;
}
if (aClass != null) {
minClassLevel = character.getSpellSupport(aClass).getMinLevelForSpellLevel(spellLevel.get() + levelAdjust, true);
minClassLevel = Math.max(1, minClassLevel);
if (aClass.hasMaxLevel()) {
maxClassLevel = aClass.getSafe(IntegerKey.LEVEL_LIMIT);
}
}
updateAvailCasterLevels(minClassLevel, maxClassLevel);
int currCasterLevel = casterLevel.get() == null ? 0 : casterLevel.get();
if (currCasterLevel < minClassLevel) {
casterLevel.set(minClassLevel);
} else if (currCasterLevel > maxClassLevel) {
casterLevel.set(maxClassLevel);
}
}
use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method setSelectedMetamagicFeats.
@Override
public void setSelectedMetamagicFeats(Object[] newFeats) {
List<AbilityFacade> chosenFeats = new ArrayList<>();
for (Object choice : newFeats) {
if (choice instanceof AbilityFacade) {
chosenFeats.add((AbilityFacade) choice);
}
}
selMetamagicFeats.setContents(chosenFeats);
recalcCasterLevelDetails();
}
use of pcgen.facade.core.AbilityFacade in project pcgen by PCGen.
the class DataSet method initLists.
private void initLists() {
List<Race> raceList = new ArrayList<>(context.getReferenceContext().getConstructedCDOMObjects(Race.class));
raceList.sort(new RaceComparator());
for (Race race : raceList) {
if (race.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
races.addElement(race);
}
}
List<PCClass> classList = new ArrayList<>(context.getReferenceContext().getConstructedCDOMObjects(PCClass.class));
classList.sort(new PCClassComparator());
for (PCClass pcClass : classList) {
if (pcClass.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
classes.addElement(pcClass);
}
}
for (Skill skill : context.getReferenceContext().getConstructedCDOMObjects(Skill.class)) {
if (skill.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
skills.addElement(skill);
}
}
for (Deity deity : context.getReferenceContext().getConstructedCDOMObjects(Deity.class)) {
deities.addElement(deity);
}
for (PCTemplate template : context.getReferenceContext().getConstructedCDOMObjects(PCTemplate.class)) {
if (template.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
templates.addElement(template);
}
}
for (Kit kit : context.getReferenceContext().getConstructedCDOMObjects(Kit.class)) {
kits.addElement(kit);
}
for (PCAlignment alignment : context.getReferenceContext().getOrderSortedCDOMObjects(PCAlignment.class)) {
alignments.addElement(alignment);
}
for (PCStat stat : context.getReferenceContext().getOrderSortedCDOMObjects(PCStat.class)) {
stats.addElement(stat);
}
// new AbilityCategoryComparator());
for (AbilityCategory category : gameMode.getAllAbilityCategories()) {
if (category.isVisibleTo(View.VISIBLE_DISPLAY)) {
// categories.addElement(category);
List<Ability> abList = new ArrayList<>(Globals.getContext().getReferenceContext().getManufacturer(Ability.class, category).getAllObjects());
Globals.sortPObjectListByName(abList);
DefaultListFacade<AbilityFacade> abilityList = new DefaultListFacade<>(abList);
for (Iterator<AbilityFacade> iterator = abilityList.iterator(); iterator.hasNext(); ) {
AbilityFacade facade = iterator.next();
if (facade instanceof Ability) {
Ability ability = (Ability) facade;
if (!(ability.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY))) {
iterator.remove();
}
}
}
abilityMap.put(category, abilityList);
}
}
Map<String, BodyStructure> structMap = new HashMap<>(SystemCollections.getUnmodifiableBodyStructureList().size() + 3);
for (String name : SystemCollections.getUnmodifiableBodyStructureList()) {
// TODO i18n the display name and correct the DataSetTest
String displayName = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
final BodyStructure bodyStructure = new BodyStructure(displayName);
bodyStructures.addElement(bodyStructure);
structMap.put(name, bodyStructure);
}
Set<Type> typesWithDesignatedSlots = buildSlottedTypeList();
bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_EQUIPPED, true, typesWithDesignatedSlots));
bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_CARRIED, true));
bodyStructures.addElement(new BodyStructure(Constants.EQUIP_LOCATION_NOTCARRIED, true));
for (EquipSlot es : SystemCollections.getUnmodifiableEquipSlotList()) {
if (structMap.containsKey(es.getBodyStructureName())) {
structMap.get(es.getBodyStructureName()).addEquipSlot(es);
}
}
for (Equipment eq : context.getReferenceContext().getConstructedCDOMObjects(Equipment.class)) {
if (eq.getSafe(ObjectKey.VISIBILITY).isVisibleTo(View.VISIBLE_DISPLAY)) {
equipment.addElement(eq);
}
}
for (String xpTableName : gameMode.getXPTableNames()) {
xpTableNames.addElement(xpTableName);
}
for (String characterType : gameMode.getCharacterTypeList()) {
characterTypes.addElement(characterType);
}
for (SizeAdjustment size : context.getReferenceContext().getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER)) {
sizes.addElement(size);
}
createGearBuySellSchemes();
}
Aggregations