Search in sources :

Example 1 with StatFacade

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

the class CharacterFacadeImpl method refreshRollMethod.

@Override
public void refreshRollMethod() {
    if (!canChangePurchasePool()) {
        return;
    }
    GameMode game = (GameMode) dataSet.getGameMode();
    rollMethodRef.set(game.getRollMethod());
    if (SettingsHandler.getGame().isPurchaseStatMode()) {
        int availablePool = RollingMethods.roll(SettingsHandler.getGame().getPurchaseModeMethodPoolFormula());
        theCharacter.setPointBuyPoints(availablePool);
        // Make sure all scores are within the valid range
        for (StatFacade stat : statScoreMap.keySet()) {
            WriteableReferenceFacade<Number> score = statScoreMap.get(stat);
            if (score.get().intValue() < SettingsHandler.getGame().getPurchaseScoreMin(theCharacter) && stat instanceof PCStat) {
                setStatToPurchaseNeutral((PCStat) stat, score);
            }
        }
    }
    hpRef.set(theCharacter.hitPoints());
    updateScorePurchasePool(false);
}
Also used : GameMode(pcgen.core.GameMode) StatFacade(pcgen.facade.core.StatFacade) PCStat(pcgen.core.PCStat)

Example 2 with StatFacade

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

the class StatTableModel method install.

public void install() {
    table.setModel(this);
    table.setDefaultRenderer(Object.class, renderer);
    TableColumn abilityColumn = table.getColumn(ABILITY_COLUMN_ID);
    int columnIndex = abilityColumn.getModelIndex();
    int maxWidth = 0;
    for (StatFacade aStat : stats) {
        Component cell = renderer.getTableCellRendererComponent(table, aStat, false, false, -1, columnIndex);
        maxWidth = Math.max(maxWidth, cell.getPreferredSize().width);
    }
    //we add some extra spacing to prevent ellipses from showing
    abilityColumn.setPreferredWidth(maxWidth + 4);
    TableColumn column = table.getColumn(EDITABLE_COLUMN_ID);
    column.setCellRenderer(new TableCellUtilities.SpinnerRenderer());
    column.setCellEditor(editor);
    Dimension size = table.getPreferredSize();
    size.width = table.getTableHeader().getPreferredSize().width;
    JScrollPane scrollPane = (JScrollPane) table.getParent().getParent();
    //we want to add room for the vertical scroll bar so it doesn't
    //overlap with the table when it shows
    int vbarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
    size.width += vbarWidth;
    table.setPreferredScrollableViewportSize(size);
    //because of the extra viewport size in the table it will
    //always look a bit off center, adding a row header to
    //the scroll pane fixes this
    scrollPane.setRowHeaderView(Box.createHorizontalStrut(vbarWidth));
    for (StatFacade aStat : stats) {
        character.getScoreBaseRef(aStat).addReferenceListener(this);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) StatFacade(pcgen.facade.core.StatFacade) Dimension(java.awt.Dimension) JComponent(javax.swing.JComponent) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn) TableCellUtilities(pcgen.gui2.util.table.TableCellUtilities)

Example 3 with StatFacade

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

the class CharacterFacadeImpl method initForCharacter.

/**
	 * 
	 */
private void initForCharacter() {
    // Calculate any active bonuses
    theCharacter.preparePCForOutput();
    todoManager = new TodoManager();
    infoFactory = new Gui2InfoFactory(theCharacter);
    characterAbilities = new CharacterAbilities(theCharacter, delegate, dataSet, todoManager);
    descriptionFacade = new DescriptionFacadeImpl(theCharacter);
    spellSupportFacade = new SpellSupportFacadeImpl(theCharacter, delegate, dataSet, todoManager, this);
    name = new DefaultReferenceFacade<>(charDisplay.getName());
    file = new DefaultReferenceFacade<>(new File(charDisplay.getFileName()));
    companionSupportFacade = new CompanionSupportFacadeImpl(theCharacter, todoManager, name, file, this);
    availTempBonuses = new DefaultListFacade<>();
    refreshAvailableTempBonuses();
    appliedTempBonuses = new DefaultListFacade<>();
    buildAppliedTempBonusList();
    kitList = new DefaultListFacade<>();
    refreshKitList();
    statScoreMap = new HashMap<>();
    for (StatFacade stat : dataSet.getStats()) {
        if (stat instanceof PCStat) {
            statScoreMap.put(stat, ChannelCompatibility.getStatScore(theCharacter.getCharID(), (PCStat) stat));
        } else {
            statScoreMap.put(stat, new DefaultReferenceFacade<>());
        }
    }
    File portraitFile = null;
    if (!StringUtils.isEmpty(charDisplay.getPortraitPath())) {
        portraitFile = new File(charDisplay.getPortraitPath());
    }
    portrait = new DefaultReferenceFacade<>(portraitFile);
    cropRect = new RectangleReference(charDisplay.getPortraitThumbnailRect());
    characterType = new DefaultReferenceFacade<>(charDisplay.getCharacterType());
    previewSheet = new DefaultReferenceFacade<>(charDisplay.getPreviewSheet());
    skillFilter = new DefaultReferenceFacade<>(charDisplay.getSkillFilter());
    tabName = new DefaultReferenceFacade<>(charDisplay.getTabName());
    playersName = new DefaultReferenceFacade<>(charDisplay.getPlayersName());
    race = new DefaultReferenceFacade<>(charDisplay.getRace());
    raceList = new DefaultListFacade<>();
    if (charDisplay.getRace() != null && charDisplay.getRace() != Globals.s_EMPTYRACE) {
        raceList.addElement(charDisplay.getRace());
    }
    handedness = new DefaultReferenceFacade<>();
    gender = new DefaultReferenceFacade<>();
    availHands = new DefaultListFacade<>();
    availGenders = new DefaultListFacade<>();
    for (Handed handed : Handed.values()) {
        availHands.addElement(handed);
    }
    for (Gender gender : Gender.values()) {
        availGenders.addElement(gender);
    }
    if (charDisplay.getRace() != null) {
        for (HandedFacade handsFacade : availHands) {
            if (handsFacade.equals(charDisplay.getHandedObject())) {
                handedness.set(handsFacade);
                break;
            }
        }
        for (GenderFacade pcGender : availGenders) {
            if (pcGender.equals(charDisplay.getGenderObject())) {
                gender.set(pcGender);
                break;
            }
        }
    }
    alignment = new DefaultReferenceFacade<>(charDisplay.getPCAlignment());
    age = new DefaultReferenceFacade<>(charDisplay.getAge());
    ageCategory = new DefaultReferenceFacade<>();
    updateAgeCategoryForAge();
    currentXP = new DefaultReferenceFacade<>(charDisplay.getXP());
    xpListener = new XPListener();
    FacetLibrary.getFacet(XPFacet.class).addDataFacetChangeListener(xpListener);
    xpForNextlevel = new DefaultReferenceFacade<>(charDisplay.minXPForNextECL());
    xpTableName = new DefaultReferenceFacade<>(charDisplay.getXPTableName());
    hpRef = new DefaultReferenceFacade<>(theCharacter.hitPoints());
    skinColor = new DefaultReferenceFacade<>(charDisplay.getSafeStringFor(PCStringKey.SKINCOLOR));
    hairColor = new DefaultReferenceFacade<>(charDisplay.getSafeStringFor(PCStringKey.HAIRCOLOR));
    eyeColor = new DefaultReferenceFacade<>(charDisplay.getSafeStringFor(PCStringKey.EYECOLOR));
    weightRef = new DefaultReferenceFacade<>();
    heightRef = new DefaultReferenceFacade<>();
    refreshHeightWeight();
    purchasedEquip = new EquipmentListFacadeImpl(theCharacter.getEquipmentMasterList());
    autoEquipListener = new AutoEquipListener();
    FacetLibrary.getFacet(AutoEquipmentFacet.class).addDataFacetChangeListener(autoEquipListener);
    carriedWeightRef = new DefaultReferenceFacade<>();
    loadRef = new DefaultReferenceFacade<>();
    weightLimitRef = new DefaultReferenceFacade<>();
    equipSet = new DefaultReferenceFacade<>();
    equipmentSets = new DefaultListFacade<>();
    initEquipSet();
    GameMode game = (GameMode) dataSet.getGameMode();
    rollMethodRef = new DefaultReferenceFacade<>(game.getRollMethod());
    charLevelsFacade = new CharacterLevelsFacadeImpl(theCharacter, delegate, todoManager, dataSet, this);
    pcClasses = new ArrayList<>();
    pcClassLevels = new DefaultListFacade<>();
    refreshClassLevelModel();
    charLevelsFacade.addHitPointListener(this);
    deity = new DefaultReferenceFacade<>(charDisplay.getDeity());
    domains = new DefaultListFacade<>();
    maxDomains = new DefaultReferenceFacade<>(theCharacter.getMaxCharacterDomains());
    remainingDomains = new DefaultReferenceFacade<>(theCharacter.getMaxCharacterDomains() - domains.getSize());
    availDomains = new DefaultListFacade<>();
    buildAvailableDomainsList();
    templates = new DefaultListFacade<>(charDisplay.getDisplayVisibleTemplateList());
    templateListener = new TemplateListener();
    FacetLibrary.getFacet(TemplateFacet.class).addDataFacetChangeListener(templateListener);
    initTodoList();
    statTotalLabelText = new DefaultReferenceFacade<>();
    statTotalText = new DefaultReferenceFacade<>();
    modTotalLabelText = new DefaultReferenceFacade<>();
    modTotalText = new DefaultReferenceFacade<>();
    updateScorePurchasePool(false);
    languages = new DefaultListFacade<>();
    numBonusLang = new DefaultReferenceFacade<>(0);
    numSkillLang = new DefaultReferenceFacade<>(0);
    refreshLanguageList();
    langListener = new LanguageListener();
    FacetLibrary.getFacet(LanguageFacet.class).addDataFacetChangeListener(langListener);
    purchasedEquip.addListListener(spellSupportFacade);
    purchasedEquip.addEquipmentListListener(spellSupportFacade);
    fundsRef = new DefaultReferenceFacade<>(theCharacter.getGold());
    wealthRef = new DefaultReferenceFacade<>(theCharacter.totalValue());
    gearBuySellSchemeRef = new DefaultReferenceFacade<>(findGearBuySellRate());
    allowDebt = false;
}
Also used : StatFacade(pcgen.facade.core.StatFacade) GenderFacade(pcgen.facade.core.GenderFacade) TemplateFacet(pcgen.cdom.facet.model.TemplateFacet) Handed(pcgen.cdom.enumeration.Handed) Gender(pcgen.cdom.enumeration.Gender) HandedFacade(pcgen.facade.core.HandedFacade) XPFacet(pcgen.cdom.facet.fact.XPFacet) GameMode(pcgen.core.GameMode) PCStat(pcgen.core.PCStat) File(java.io.File) LanguageFacet(pcgen.cdom.facet.model.LanguageFacet) AutoEquipmentFacet(pcgen.cdom.facet.AutoEquipmentFacet)

Example 4 with StatFacade

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

the class InfoPaneHandler method registerListeners.

/**
	 * Register with the things we want to be notified of changes about. 
	 */
private void registerListeners() {
    character.getRaceRef().addReferenceListener(this);
    character.getGenderRef().addReferenceListener(this);
    character.getAlignmentRef().addReferenceListener(this);
    for (StatFacade stat : character.getDataSet().getStats()) {
        character.getScoreBaseRef(stat).addReferenceListener(this);
    }
    character.getCharacterLevelsFacade().addListListener(this);
    character.getHandedRef().addReferenceListener(this);
    character.getAgeRef().addReferenceListener(this);
}
Also used : StatFacade(pcgen.facade.core.StatFacade)

Aggregations

StatFacade (pcgen.facade.core.StatFacade)4 GameMode (pcgen.core.GameMode)2 PCStat (pcgen.core.PCStat)2 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 File (java.io.File)1 JComponent (javax.swing.JComponent)1 JScrollPane (javax.swing.JScrollPane)1 TableColumn (javax.swing.table.TableColumn)1 Gender (pcgen.cdom.enumeration.Gender)1 Handed (pcgen.cdom.enumeration.Handed)1 AutoEquipmentFacet (pcgen.cdom.facet.AutoEquipmentFacet)1 XPFacet (pcgen.cdom.facet.fact.XPFacet)1 LanguageFacet (pcgen.cdom.facet.model.LanguageFacet)1 TemplateFacet (pcgen.cdom.facet.model.TemplateFacet)1 GenderFacade (pcgen.facade.core.GenderFacade)1 HandedFacade (pcgen.facade.core.HandedFacade)1 TableCellUtilities (pcgen.gui2.util.table.TableCellUtilities)1