use of pcgen.facade.core.LanguageFacade in project pcgen by PCGen.
the class CharacterFacadeImpl method refreshLanguageList.
/**
* Regenerate the character's list of languages.
*/
void refreshLanguageList() {
long startTime = new Date().getTime();
List<Language> sortedLanguages = new ArrayList<>(charDisplay.getLanguageSet());
Collections.sort(sortedLanguages);
languages.updateContents(sortedLanguages);
autoLanguagesCache = null;
boolean allowBonusLangAfterFirst = Globals.checkRule(RuleConstants.INTBONUSLANG);
boolean atFirstLvl = theCharacter.getTotalLevels() <= 1;
int bonusLangMax = theCharacter.getBonusLanguageCount();
currBonusLangs = new ArrayList<>();
CNAbility a = theCharacter.getBonusLanguageAbility();
List<String> currBonusLangNameList = theCharacter.getAssociationList(a);
for (LanguageFacade langFacade : languages) {
Language lang = (Language) langFacade;
if (currBonusLangNameList.contains(lang.getKeyName())) {
currBonusLangs.add(lang);
}
}
int bonusLangRemain = bonusLangMax - currBonusLangs.size();
if (!allowBonusLangAfterFirst && !atFirstLvl) {
bonusLangRemain = 0;
}
numBonusLang.set(bonusLangRemain);
if (bonusLangRemain > 0) {
if (allowBonusLangAfterFirst) {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoBonusLanguage", 110));
todoManager.removeTodo("in_sumTodoBonusLanguageFirstOnly");
} else {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoBonusLanguageFirstOnly", 110));
todoManager.removeTodo("in_sumTodoBonusLanguage");
}
} else {
todoManager.removeTodo("in_sumTodoBonusLanguage");
todoManager.removeTodo("in_sumTodoBonusLanguageFirstOnly");
}
int numSkillLangSelected = 0;
int skillLangMax = 0;
//TODO: Need to cope with multiple skill languages
SkillFacade speakLangSkill = dataSet.getSpeakLanguageSkill();
if (speakLangSkill != null) {
Skill skill = (Skill) speakLangSkill;
List<String> langList = theCharacter.getAssociationList(skill);
numSkillLangSelected = langList.size();
skillLangMax = SkillRankControl.getTotalRank(theCharacter, skill).intValue();
}
int skillLangRemain = skillLangMax - numSkillLangSelected;
numSkillLang.set(skillLangRemain);
if (skillLangRemain > 0) {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoSkillLanguage", 112));
} else {
todoManager.removeTodo("in_sumTodoSkillLanguage");
}
if (skillLangRemain < 0) {
todoManager.addTodo(new TodoFacadeImpl(Tab.SUMMARY, "Languages", "in_sumTodoSkillLanguageTooMany", 112));
} else {
todoManager.removeTodo("in_sumTodoSkillLanguageTooMany");
}
long endTime = new Date().getTime();
Logging.log(Logging.DEBUG, "refreshLanguageList took " + (endTime - startTime) + " ms.");
}
use of pcgen.facade.core.LanguageFacade in project pcgen by PCGen.
the class LanguageChooserFacadeImpl method commit.
/**
* @see pcgen.core.facade.LanguageChooserFacade#commit()
*/
@Override
@SuppressWarnings("unchecked")
public void commit() {
ChoiceManagerList<Language> choiceManager = ChooserUtilities.getChoiceManager(source, theCharacter);
List<Language> selected = new ArrayList<>(selectedList.getSize());
for (LanguageFacade langFacade : selectedList) {
selected.add((Language) langFacade);
}
choiceManager.applyChoices(theCharacter, selected);
// Update list on character facade
pcFacade.refreshLanguageList();
}
Aggregations