private void populateSkillsTable() { TableLayout tableSkills = (TableLayout) findViewById(R.id.tableSkills); tableSkills.setShrinkAllColumns(false); tableSkills.setStretchAllColumns(false); tableSkills.removeAllViews(); skillEditorFactory.resetEditors(); Map<String, SkillCategoryEditor> categoryEditors = new HashMap<String, SkillCategoryEditor>(); for (ISkill skill : investigator.getSkills().list()) { if (skill.isCategory()) { SkillCategoryEditor editor = skillEditorFactory.newSkillCategoryEditor( this, investigator.getSkills(), (SkillCategory) skill); categoryEditors.put(skill.getName(), editor); editor.addOnSkillChangedListener(this); tableSkills.addView(editor); } else { Skill sk = (Skill) skill; if (sk.isAdded()) continue; SkillEditor editor = skillEditorFactory.newSkillEditor(investigator.getSkills(), sk); editor.addOnSkillChangedListener(this); tableSkills.addView(editor); } } skillChanged(null); }
// This sucks but it's pretty straightforward for now private void calculateDynamicSkills(Attribute attribute, boolean updateEditor) { ISkill sk = null; if (attribute.getName().equals("DEX")) { sk = investigator.getSkills().get("Dodge"); if (sk != null) sk.setBaseValue(attribute.getTotal() * 2); } else if (attribute.getName().equals("EDU")) { sk = investigator.getSkills().get("Own Language"); if (sk != null) sk.setBaseValue(Math.min(99, attribute.getTotal() * 5)); } if (updateEditor && sk != null) { BaseSkillEditor editor = findSkillEditor(sk); editor.updateBaseValue(); } }
@Override public void skillChanged(ISkill skill) { TextView tv = (TextView) findViewById(R.id.messageSkills); int pointsOccupationalUsed = investigator.getSkills().getOccupationalPoints(); int pointsPersonalUsed = investigator.getSkills().getPersonalPoints(); int pointsOccupationalAvail = investigator.getAvailableOccupationalPoints(); int pointsPersonalAvail = investigator.getAvailablePersonalPoints(); StringBuffer buffer = new StringBuffer(); buffer.append("Occ. skills: " + pointsOccupationalUsed + "/" + pointsOccupationalAvail); buffer.append(" "); buffer.append("Pers. skills: " + pointsPersonalUsed + "/" + pointsPersonalAvail); tv.setText(buffer.toString()); if (pointsPersonalUsed > pointsPersonalAvail || pointsOccupationalUsed > pointsOccupationalAvail) { tv.setTextColor(Color.RED); } else if (pointsPersonalUsed < pointsPersonalAvail || pointsOccupationalUsed < pointsOccupationalAvail) { tv.setTextColor(Color.BLUE); } else { tv.setTextColor(Color.GREEN); } }