use of pcgen.facade.util.DefaultListFacade 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();
}
use of pcgen.facade.util.DefaultListFacade in project pcgen by PCGen.
the class FacadeFactory method initCampaigns.
private static void initCampaigns() {
for (final CampaignFacade campaign : campaigns) {
campaignMap.put(campaign.getName(), campaign);
ListFacade<GameModeFacade> gameModeList = campaign.getGameModes();
for (GameModeFacade gameModeFacade : gameModeList) {
if (!campaignListMap.containsKey(gameModeFacade)) {
campaignListMap.put(gameModeFacade, new DefaultListFacade<>());
}
DefaultListFacade<CampaignFacade> campaignList = campaignListMap.get(gameModeFacade);
if (campaignList.containsElement(campaign)) {
String sourceUri = ((CDOMObject) campaign).getSourceURI().toString();
Logging.errorPrint("Campaign " + sourceUri + " lists GAMEMODE:" + gameModeFacade + " multiple times.");
} else {
campaignList.addElement(campaign);
}
}
if (campaign.showInMenu() && !gameModeList.isEmpty()) {
GameModeFacade game = gameModeList.getElementAt(0);
ListFacade<CampaignFacade> list = new DefaultListFacade<>(Collections.singleton(campaign));
quickSources.addElement(new BasicSourceSelectionFacade(campaign.getName(), list, game));
}
}
}
use of pcgen.facade.util.DefaultListFacade in project pcgen by PCGen.
the class CompanionSupportFacadeImplTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
uiDelegate = new MockUIDelegate();
todoManager = new TodoManager();
ListFacade<CampaignFacade> campaigns = new DefaultListFacade<>();
dataSetFacade = new DataSet(Globals.getContext(), SettingsHandler.getGame(), campaigns);
masterRace = TestHelper.makeRace("Wood Elf");
companionRace = TestHelper.makeRace("Weasel");
CDOMReference<Race> race = new CDOMDirectSingleRef<>(companionRace);
CDOMSingleRef<CompanionList> ref = new CDOMSimpleSingleRef<>(CompanionList.class, companionList.getKeyName());
FollowerOption option = new FollowerOption(race, ref);
masterRace.addToListFor(ListKey.COMPANIONLIST, option);
}
use of pcgen.facade.util.DefaultListFacade in project pcgen by PCGen.
the class CharacterAbilities method rebuildAbilityLists.
/**
* Rebuild the ability lists for the character to include the character's
* current abilities.
*/
synchronized void rebuildAbilityLists() {
Map<AbilityCategoryFacade, DefaultListFacade<AbilityFacade>> workingAbilityListMap = new LinkedHashMap<>();
DefaultListFacade<AbilityCategoryFacade> workingActiveCategories = new DefaultListFacade<>();
for (AbilityCategoryFacade category : dataSetFacade.getAbilities().getKeys()) {
AbilityCategory cat = (AbilityCategory) category;
for (CNAbility cna : theCharacter.getPoolAbilities(cat)) {
addCategorisedAbility(cna, workingAbilityListMap);
}
// deal with visibility
boolean visible = cat.isVisibleTo(theCharacter, View.VISIBLE_DISPLAY);
if (visible && !workingActiveCategories.containsElement(cat)) {
int index = getCatIndex(cat, workingActiveCategories);
workingActiveCategories.addElement(index, cat);
}
if (!visible && workingActiveCategories.containsElement(cat)) {
workingActiveCategories.removeElement(cat);
// updateAbilityCategoryTodo(cat);
}
if (visible) {
adviseSelectionChangeLater(cat);
}
}
// Update map contents
for (AbilityCategoryFacade category : workingAbilityListMap.keySet()) {
DefaultListFacade<AbilityFacade> workingListFacade = workingAbilityListMap.get(category);
DefaultListFacade<AbilityFacade> masterListFacade = abilityListMap.get(category);
if (masterListFacade == null) {
abilityListMap.put(category, workingListFacade);
} else {
masterListFacade.updateContentsNoOrder(workingListFacade.getContents());
}
updateAbilityCategoryTodo((AbilityCategory) category);
}
Set<AbilityCategoryFacade> origCats = new HashSet<>(abilityListMap.keySet());
for (AbilityCategoryFacade category : origCats) {
if (!workingAbilityListMap.containsKey(category)) {
if (workingActiveCategories.containsElement(category)) {
abilityListMap.get(category).clearContents();
} else {
abilityListMap.remove(category);
}
updateAbilityCategoryTodo((AbilityCategory) category);
}
}
activeCategories.updateContents(workingActiveCategories.getContents());
}
use of pcgen.facade.util.DefaultListFacade in project pcgen by PCGen.
the class CharacterFacadeImpl method deleteCustomEquipment.
@Override
public void deleteCustomEquipment(EquipmentFacade eqFacade) {
if (eqFacade == null || !(eqFacade instanceof Equipment)) {
return;
}
Equipment itemToBeDeleted = (Equipment) eqFacade;
if (!itemToBeDeleted.isType(Constants.TYPE_CUSTOM)) {
return;
}
if (!delegate.showWarningConfirm(LanguageBundle.getString(//$NON-NLS-1$
"in_igDeleteCustomWarnTitle"), //$NON-NLS-1$
LanguageBundle.getFormattedString(//$NON-NLS-1$
"in_igDeleteCustomWarning", itemToBeDeleted))) {
return;
}
removePurchasedEquipment(itemToBeDeleted, Integer.MAX_VALUE, false);
Globals.getContext().getReferenceContext().forget(itemToBeDeleted);
if (dataSet.getEquipment() instanceof DefaultListFacade<?>) {
((DefaultListFacade<EquipmentFacade>) dataSet.getEquipment()).removeElement(itemToBeDeleted);
}
}
Aggregations