use of main.swing.generic.misc.PointComp in project Eidolons by IDemiurge.
the class PointView method stateChanged.
@Override
public void stateChanged(ChangeEvent e) {
// subtract points from attr/mast? only down to X!
int newValue = (int) ((PointComp) e.getSource()).getValue();
PARAMETER param = ((PointComp) e.getSource()).getParam();
int oldValue = getBufferType().getIntParam(param);
int mod = newValue - oldValue;
int cost = PointMaster.getPointCost(Math.max(newValue, oldValue), hero, param);
if (mod < 0 || !checkCost(cost * mod)) {
((PointComp) e.getSource()).removeChangeListener(this);
((PointComp) e.getSource()).setValue(oldValue);
((PointComp) e.getSource()).addChangeListener(this);
return;
}
// CharacterCreator.getHeroManager().modifyHeroParam(hero, param, mod);
getBufferType().modifyParameter(param, mod);
modifyPool(-mod, cost);
}
use of main.swing.generic.misc.PointComp in project Eidolons by IDemiurge.
the class PointView method updateValuePanel.
private void updateValuePanel() {
for (PARAMETER p : compMap.keySet()) {
if (!getBufferType().getParam(p).equals(hero.getParam(p))) {
Component comp = compMap.get(p);
if (!editable) {
((JLabel) comp).setText(hero.getParam(p));
} else {
((PointComp) comp).removeChangeListener(this);
((PointComp) comp).setValue(hero.getIntParam(p));
((PointComp) comp).addChangeListener(this);
}
}
}
}
use of main.swing.generic.misc.PointComp in project Eidolons by IDemiurge.
the class PointView method addValueComponent.
private void addValueComponent(PARAMETER value, int i, G_Panel valPanel) {
String name = value.getName();
if (editable && attributes) {
name = name.replace(StringMaster.getWellFormattedString(StringMaster.BASE), "");
}
JLabel lbl = new JLabel(name + ": ");
valPanel.add(lbl, "id lbl" + i + ", sg lbls");
if (editable) {
PointComp pc = new PointComp(getBufferType().getIntParam(value), attributes);
// set minimum
pc.setParam(value);
pc.setFont(font);
pc.addChangeListener(this);
valPanel.add(pc, ((i % columns == 0) ? ",wrap" : ""));
compMap.put(value, pc);
} else {
JLabel comp = new JLabel(getBufferType().getParam(value));
comp.setFont(font);
valPanel.add(comp, ((i % columns == 0) ? ",wrap" : ""));
compMap.put(value, comp);
}
}