use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.
the class PlaceTooltip method updateAct.
@Override
public void updateAct(float delta) {
clearChildren();
TextureRegion r = TextureCache.getOrCreateR(place.getImagePath());
ValueContainer container = new ValueContainer(r, place.getName());
float size = GdxMaster.adjustSize(128);
if (size < r.getRegionHeight() && size < r.getRegionWidth())
container.overrideImageSize(size, size);
add(container);
setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
// return ;
if (place.getRoutes().isEmpty()) {
return;
}
row();
TablePanel<ValueContainer> routesInfo = new TablePanel<>();
routesInfo.defaults().space(5);
add(routesInfo);
routesInfo.addListener(new ClickListener() {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
if (toActor == routesInfo)
return;
if (toActor == null) {
if (getWidth() >= x)
return;
if (getWidth() >= y)
return;
}
if (GdxMaster.getAncestors(toActor).contains(routesInfo))
return;
if (!checkActorExitRemoves(toActor))
return;
super.exit(event, x, y, pointer, toActor);
GuiEventManager.trigger(MapEvent.ROUTES_PANEL_HOVER_OFF);
}
});
int i = 0;
for (Route sub : place.getRoutes()) {
// reverse pic pos
TextureRegion tex = TextureCache.getOrCreateR(sub.getImagePath());
ValueContainer routeInfo = new ValueContainer(tex, sub.getName(), sub.getLength() + " leagues");
routeInfo.setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
routesInfo.add(routeInfo).left().padLeft(5).uniform(true, false);
routeInfo.setUserObject(sub);
routeInfo.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
// getTapCount()
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
return super.touchDown(event, x, y, pointer, button);
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
super.exit(event, x, y, pointer, toActor);
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, null);
}
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
super.enter(event, x, y, pointer, fromActor);
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
}
});
if (i % 2 == 1)
routesInfo.row();
i++;
}
}
use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.
the class EmitterPalette method init.
public void init() {
clear();
setSize(GdxMaster.getWidth() - 300, 256);
// int columns = (int) (getWidth() / 64);
defaults().padLeft(200).top().right().width(GdxMaster.getWidth() - 300);
Map<String, List<File>> presets = new LinkedHashMap<>();
List<File> subfolders = FileManager.getFilesFromDirectory(PathFinder.getSfxPath(), true);
subfolders.forEach(file -> {
if (!file.isDirectory()) {
MapMaster.addToListMap(presets, "main", file);
} else
presets.put(file.getName(), FileManager.getFilesFromDirectory(file.getPath(), false));
});
LabelStyle style = StyleHolder.getSizedLabelStyle(FONT.MAIN, 15);
for (String sub : presets.keySet()) {
HorizontalFlowGroup table = new HorizontalFlowGroup(0);
table.setWidth(getWidth() - 100);
boolean bg = presets.get(sub).size() < 55;
for (File preset : presets.get(sub)) {
// textButton?
ValueContainer label = new ValueContainer(new Label(preset.getName(), style));
NinePatch patch = NinePatchFactory.getTooltip();
patch.scale(0.7f, 0.7f);
if (bg)
label.setBackground(new NinePatchDrawable(patch));
label.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (Gdx.input.isKeyPressed(Keys.SHIFT_LEFT)) {
// EmitterMaster.
}
EditorManager.setMode(MAP_EDITOR_MOUSE_MODE.EMITTER);
if (selectedLabel != null)
selectedLabel.setColor(1, 1, 1, 1);
if (sub.equals("main"))
selected = preset.getName();
else
selected = StrPathBuilder.build(sub, preset.getName());
selectedLabel = label;
label.setColor(1, 0.3f, 0.8f, 1);
return super.touchDown(event, x, y, pointer, button);
}
});
table.addActor(label);
}
addTab(table, sub);
}
}
use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.
the class TooltipFactory method addPropStringToValues.
protected void addPropStringToValues(BattleFieldObject hero, List<ValueContainer> values, PROPERTY v) {
String value = hero.getValue(v);
value = StringMaster.getWellFormattedString(value);
value = value.replace(";", ", ");
final ValueContainer valueContainer = new ValueContainer(v.getDisplayedName(), value);
valueContainer.setNameAlignment(Align.left);
valueContainer.setValueAlignment(Align.right);
values.add(valueContainer);
}
use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.
the class RadialManager method addSimpleTooltip.
public static void addSimpleTooltip(RadialValueContainer el, String name) {
ValueTooltip tooltip = new ValueTooltip();
tooltip.setUserObject(Arrays.asList(new ValueContainer(name, "")));
for (com.badlogic.gdx.scenes.scene2d.EventListener sub : el.getListeners()) {
if (!(sub instanceof ClickListener))
el.removeListener(sub);
}
el.addListener(tooltip.getController());
}
use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.
the class UnitDataSource method getWeaponDetail.
private List<ValueContainer> getWeaponDetail(DC_WeaponObj weapon) {
List<ValueContainer> result = new ArrayList<>();
if (weapon != null) {
for (DC_UnitAction el : weapon.getOrCreateAttackActions()) {
final ValueContainer valueContainer = new ValueContainer(getOrCreateR(el.getImagePath()));
AttackTooltip toolTip = AttackTooltipFactory.createAttackTooltip(el);
valueContainer.addListener(toolTip.getController());
result.add(valueContainer);
}
}
return result;
}
Aggregations