Search in sources :

Example 1 with CustomEquipResult

use of pcgen.facade.core.UIDelegate.CustomEquipResult in project pcgen by PCGen.

the class CharacterFacadeImpl method openCustomizer.

private Equipment openCustomizer(Equipment aEq) {
    if (aEq == null) {
        return null;
    }
    Equipment newEquip = aEq.clone();
    if (!newEquip.containsKey(ObjectKey.BASE_ITEM)) {
        newEquip.put(ObjectKey.BASE_ITEM, CDOMDirectSingleRef.getRef(aEq));
    }
    List<VarModifier<?>> modifiers = newEquip.getListFor(ListKey.MODIFY);
    if (modifiers != null) {
        for (VarModifier<?> vm : modifiers) {
            theCharacter.addModifier(vm, newEquip, newEquip);
        }
    }
    for (EquipmentHead head : newEquip.getEquipmentHeads()) {
        modifiers = head.getListFor(ListKey.MODIFY);
        if (modifiers != null) {
            for (VarModifier<?> vm : modifiers) {
                theCharacter.addModifier(vm, head, head);
            }
        }
    }
    EquipmentBuilderFacadeImpl builder = new EquipmentBuilderFacadeImpl(newEquip, theCharacter, delegate);
    CustomEquipResult result = delegate.showCustomEquipDialog(this, builder);
    if (newEquip != null && result != CustomEquipResult.CANCELLED) {
        dataSet.addEquipment(newEquip);
    }
    //TODO if this is returning null, then the SolverManager needs to destroy the unused channels :/
    return result == CustomEquipResult.PURCHASE ? newEquip : null;
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead) Equipment(pcgen.core.Equipment) VarModifier(pcgen.cdom.content.VarModifier) CustomEquipResult(pcgen.facade.core.UIDelegate.CustomEquipResult)

Aggregations

VarModifier (pcgen.cdom.content.VarModifier)1 EquipmentHead (pcgen.cdom.inst.EquipmentHead)1 Equipment (pcgen.core.Equipment)1 CustomEquipResult (pcgen.facade.core.UIDelegate.CustomEquipResult)1