Search in sources :

Example 1 with TabInfo

use of pcgen.cdom.content.TabInfo in project pcgen by PCGen.

the class ModifyfeatchoiceToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Ability ability, String value) {
    StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
    List<CDOMReference<Ability>> refs = new ArrayList<>();
    ReferenceManufacturer<Ability> rm = context.getReferenceContext().getManufacturer(ABILITY_CLASS, AbilityCategory.FEAT);
    while (tok.hasMoreTokens()) {
        String token = tok.nextToken();
        CDOMReference<Ability> ref = TokenUtilities.getTypeOrPrimitive(rm, token);
        if (ref == null) {
            return ParseResult.INTERNAL_ERROR;
        }
        refs.add(ref);
    }
    ReferenceChoiceSet<Ability> rcs = new ReferenceChoiceSet<>(refs);
    ModifyChoiceDecorator gfd = new ModifyChoiceDecorator(rcs);
    ChoiceSet<CNAbility> cs = new ChoiceSet<>(getTokenName(), gfd);
    TabInfo ti = context.getReferenceContext().silentlyGetConstructedCDOMObject(TabInfo.class, Tab.ABILITIES.toString());
    String singularName = ti.getResolvedName();
    if (singularName.endsWith("s")) {
        singularName = singularName.substring(0, singularName.length() - 1);
    }
    cs.setTitle("Select a " + singularName + " to modify");
    TransitionChoice<CNAbility> tc = new ConcreteTransitionChoice<>(cs, FormulaFactory.ONE);
    tc.setRequired(false);
    context.getObjectContext().put(ability, ObjectKey.MODIFY_CHOICE, tc);
    tc.setChoiceActor(this);
    return ParseResult.SUCCESS;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) ConcreteTransitionChoice(pcgen.cdom.base.ConcreteTransitionChoice) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ChoiceSet(pcgen.cdom.base.ChoiceSet) ArrayList(java.util.ArrayList) CNAbility(pcgen.cdom.content.CNAbility) StringTokenizer(java.util.StringTokenizer) TabInfo(pcgen.cdom.content.TabInfo) ModifyChoiceDecorator(pcgen.cdom.choiceset.ModifyChoiceDecorator) CDOMReference(pcgen.cdom.base.CDOMReference) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet)

Example 2 with TabInfo

use of pcgen.cdom.content.TabInfo in project pcgen by PCGen.

the class GameModeFileLoader method addDefaultTabInfo.

public static void addDefaultTabInfo(GameMode gameMode) {
    LoadContext context = gameMode.getModeContext();
    for (final Tab aTab : Tab.values()) {
        TabInfo ti = context.getReferenceContext().silentlyGetConstructedCDOMObject(TabInfo.class, aTab.toString());
        if (ti == null) {
            ti = context.getReferenceContext().constructCDOMObject(TabInfo.class, aTab.toString());
            ti.setTabName(aTab.label());
        }
    }
}
Also used : Tab(pcgen.util.enumeration.Tab) LoadContext(pcgen.rules.context.LoadContext) TabInfo(pcgen.cdom.content.TabInfo)

Aggregations

TabInfo (pcgen.cdom.content.TabInfo)2 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 ChoiceSet (pcgen.cdom.base.ChoiceSet)1 ConcreteTransitionChoice (pcgen.cdom.base.ConcreteTransitionChoice)1 ModifyChoiceDecorator (pcgen.cdom.choiceset.ModifyChoiceDecorator)1 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)1 CNAbility (pcgen.cdom.content.CNAbility)1 Ability (pcgen.core.Ability)1 LoadContext (pcgen.rules.context.LoadContext)1 Tab (pcgen.util.enumeration.Tab)1