use of main.swing.generic.components.panels.G_ListPanel in project Eidolons by IDemiurge.
the class UnitGroupMaster method chooseUnit.
private static ObjType chooseUnit(ObjType factionType, int power, int max_power) {
Map<ObjType, Integer> pool = initPool(factionType);
List<ObjType> available = new ArrayList<>();
for (ObjType l : pool.keySet()) {
if (getUnitCost(l, factionType) > power) {
continue;
}
if (l.getIntParam(PARAMS.POWER) > max_power) {
continue;
}
available.add(l);
}
if (available.isEmpty()) {
return null;
}
// chooseUnit();
Map<String, String> map = new HashMap<>();
for (ObjType type : pool.keySet()) {
map.put(type.getName(), "Cost: " + pool.get(type) + "; Power: " + type.getIntParam(PARAMS.POWER));
}
ListChooser.setDecorator(new Decorator() {
@Override
public void addComponents(G_Panel panel) {
G_ListPanel<ObjType> list = // new CustomList<>(getUnitList());
new G_ListPanel<ObjType>(getUnitList()) {
@Override
public void setInts() {
wrap = 1;
minItems = max;
rowsVisible = 1;
layoutOrientation = JList.HORIZONTAL_WRAP;
}
@Override
public boolean isVertical() {
return false;
}
};
list.setPanelSize(new Dimension(300, 120));
panel.add(list, "pos tp.x decor_info.y2");
WrappedTextComp textComp = new WrappedTextComp(null) {
@Override
protected Color getColor() {
return Color.black;
}
@Override
public synchronized List<String> getTextLines() {
List<String> list = new ArrayList<>();
list.add(UnitGroupMaster.getRemainingPower() + " points remaining");
list.add("Size contraints: between " + min + " and " + max);
return list;
}
};
textComp.setDefaultSize(new Dimension(300, 120));
panel.add(textComp, "id decor_info, pos tp.x tp.y2");
}
});
ListChooser.setTooltipMapForComponent(map);
ListChooser.setSortingDisabled(true);
return ListChooser.chooseType_(available, DC_TYPE.UNITS);
// gui - a list per ally
}
Aggregations