use of eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer in project Eidolons by IDemiurge.
the class AttackTooltipFactory method createAttackTooltip.
public static AttackTooltip createAttackTooltip(DC_UnitAction el, boolean precalc, boolean costs, boolean additionalInfo, boolean combatMode, DC_Obj target) {
Pair<PARAMS, PARAMS> pair = ACTION_TOOLTIPS_PARAMS_MAP.get(ACTION_TOOLTIP_HEADER_KEY);
String name = ActionTooltipMaster.getStringForTableValue(ACTION_TOOLTIP_HEADER_KEY, el);
final String leftImage = ActionTooltipMaster.getIconPathForTableRow(pair.getLeft());
final String rightImage = ActionTooltipMaster.getIconPathForTableRow(pair.getRight());
MultiValueContainer head = new MultiValueContainer(name, leftImage, rightImage);
VALUE[] baseKeys = ACTION_TOOLTIP_BASE_KEYS;
final List<MultiValueContainer> base = extractActionValues(el, baseKeys);
baseKeys = ACTION_TOOLTIP_RANGE_KEYS;
final List<MultiValueContainer> range = extractActionValues(el, baseKeys);
List /*<List<MultiValueContainer>>*/
textsList = new ArrayList<>();
for (PARAMS[] params : ACTION_TOOLTIP_PARAMS_TEXT) {
textsList.add(Arrays.stream(params).map(p -> {
String textForTableValue = ActionTooltipMaster.getTextForTableValue(p, el);
textForTableValue = TextWrapper.wrapWithNewLine(textForTableValue, 50);
if (StringUtils.isEmpty(textForTableValue)) {
return null;
} else {
return new MultiValueContainer(textForTableValue, "");
}
}).filter(Objects::nonNull).collect(Collectors.toList()));
}
AttackTooltip toolTip = new AttackTooltip(el);
ValueContainer precalcRow = createPrecalcRow(precalc, el, target);
toolTip.setUserObject(new ActionTooltipSource() {
@Override
public MultiValueContainer getHead() {
return head;
}
@Override
public List<MultiValueContainer> getBase() {
return base;
}
@Override
public List<MultiValueContainer> getRange() {
return range;
}
@Override
public List<List<ValueContainer>> getText() {
return textsList;
}
@Override
public CostTableSource getCostsSource() {
return () -> ActionCostSourceImpl.getActionCostList(el);
}
@Override
public ValueContainer getPrecalcRow() {
return precalcRow;
}
});
return toolTip;
}
use of eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer in project Eidolons by IDemiurge.
the class AttackTooltipFactory method extractActionValues.
private static List<MultiValueContainer> extractActionValues(DC_UnitAction el, VALUE[] baseKeys) {
List<MultiValueContainer> list = new ArrayList<>();
Pair<PARAMS, PARAMS> pair;
for (VALUE key : baseKeys) {
pair = ACTION_TOOLTIPS_PARAMS_MAP.get(key);
String name = ActionTooltipMaster.getStringForTableValue(key, el);
String imagePath = ActionTooltipMaster.getIconPathForTableRow(key);
final String leftVal = ActionTooltipMaster.getValueForTableParam(pair.getLeft(), el);
final String rightVal = ActionTooltipMaster.getValueForTableParam(pair.getRight(), el);
MultiValueContainer mvc;
if (!ImageManager.isImage(imagePath)) {
mvc = new MultiValueContainer(name, leftVal, rightVal);
} else {
mvc = new MultiValueContainer(TextureCache.getOrCreateR(imagePath), name, leftVal, rightVal);
}
list.add(mvc);
}
return list;
}
use of eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer in project Eidolons by IDemiurge.
the class AttackTooltip method updateAct.
@Override
public void updateAct(float delta) {
clear();
TablePanel left = new TablePanel();
final ActionTooltipSource source = (ActionTooltipSource) getUserObject();
final MultiValueContainer valueContainer = source.getHead();
final List<Container<Label>> values = valueContainer.getValues();
final TextureRegion leftImage = getOrCreateR(values.get(0).getActor().getText().toString());
final TextureRegion rightImage = getOrCreateR(values.get(1).getActor().getText().toString());
baseTable = new TablePanel();
baseTable.addElement(null).expand(0, 0).fill(false);
baseTable.addElement(new ValueContainer(valueContainer.getName(), ""));
baseTable.addElement(new ValueContainer(leftImage));
baseTable.addElement(new ValueContainer(rightImage));
baseTable.row();
ValueContainer precalcRow = source.getPrecalcRow();
if (precalcRow != null) {
Label label = new Label("Est.", StyleHolder.getDefaultLabelStyle());
baseTable.addElement(label);
baseTable.addElement(precalcRow);
baseTable.row();
}
List<MultiValueContainer> list = source.getBase();
for (Object o : list) {
MultiValueContainer container = (MultiValueContainer) o;
final List<ValueContainer> separated = container.separate();
separated.forEach(el -> {
baseTable.addElement(el);
});
baseTable.row();
}
rangeTable = new TablePanel();
list = source.getRange();
for (Object o : list) {
MultiValueContainer container = (MultiValueContainer) o;
final List<ValueContainer> separated = container.separate();
separated.forEach(el -> {
rangeTable.addElement(el);
});
rangeTable.row();
}
List<List<ValueContainer>> listText = source.getText();
for (List<ValueContainer> valueContainers : listText) {
TablePanel panel = new TablePanel();
textTables.add(panel);
for (ValueContainer container : valueContainers) {
// container.wrapNames();
panel.addElement(container);
panel.row();
}
}
left.addElement(baseTable).width(282).pad(0, 0, 3, 0);
left.row();
left.addElement(rangeTable).width(282).pad(0, 0, 3, 0);
left.row();
textTables.forEach(el -> {
left.addElement(el).width(282).pad(0, 0, 3, 0);
left.row();
});
addElement(left);
CostsPanel costsPanel = new CostsPanel();
costsPanel.setUserObject(source.getCostsSource());
addElement(costsPanel);
}
Aggregations