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);
}
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);
}
}
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;
}
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);
}
Aggregations