protected Tooltip<?> parseTooltipFromAction(final LmlParser parser, final Actor actor, final String rawAttributeData) { final ActorConsumer<?, Actor> action = parser.parseAction(rawAttributeData, actor); if (action == null) { parser.throwErrorIfStrict( "Cannot create tooltip with unknown action ID: " + rawAttributeData + " for actor: " + action); return null; } final Object result = action.consume(actor); if (result instanceof Tooltip<?>) { // Found an action and its result is a tooltip. Attaching directly. return (Tooltip<?>) result; } else if (result instanceof Actor) { // Found an action and its result is an actor. Converting to a tooltip: return new Tooltip<Actor>((Actor) result, parser.getData().getDefaultTooltipManager()); } // Found an action and its result is a different object. Converting to string and constructing tooltip: return new TextTooltip(Nullables.toString(result), parser.getData().getDefaultTooltipManager(), parser.getData().getDefaultSkin()); }
/** @param skin used to construct table. * @param tooltipManager used to construct tooltip. * @return a new TooltipTable instance with a fully initiated tooltip accessible with {@link #getTooltip()} * method. */ public static TooltipTable create(final Skin skin, final TooltipManager tooltipManager) { final Tooltip<TooltipTable> tooltip = new Tooltip<TooltipTable>(null, tooltipManager); final TooltipTable content = new TooltipTable(skin, tooltip); tooltip.setActor(content); return content; }
public void setTooltip(Tooltip<Table> tooltip) { this.tooltip = tooltip; }
public void createTooltipTable(){ this.setSkin(skin); this.background(skin.getDrawable("black-rectangle-hover")); tooltip = new Tooltip<Table>(this); setManager(this.getTooltip().getManager()); this.getTooltip().getManager().instant(); this.getTooltip().getManager().offsetX = 0; this.getTooltip().getManager().offsetY = 0; this.getTooltip().getManager().animations = false; this.getTooltip().setInstant(true); // labels for tooltip Label towerNameLbl = new Label(towerName, skin , "fontVeraRg24" , "white"); towerNameLbl.setColor(Assets.greenColor); Label fireRateText = new Label("Fire rate:", skin , "default-font" , "white"); Label fireRateLbl = new Label(String.format("%.1f/S",fireRate) , skin , "default-font" , "white"); Label damageText = new Label("Damage:", skin , "default-font" , "white"); Label damageLbl = new Label(String.format("%.0f",damage),skin , "default-font" , "white"); Label rangeText = new Label("Range:", skin , "default-font" , "white"); Label rangeLbl = new Label(String.format("%.0f",range) ,skin , "default-font" , "white"); Label descriptionLbl = new Label(description , skin , "default-font" , "white"); descriptionLbl.setColor(Assets.greenColor); descriptionLbl.setWrap(true); Label specialText = new Label("Special:", skin , "default-font" , "white"); Label specialLbl = new Label(special,skin , "default-font" , "white"); Label priceText = new Label("Price:", skin , "default-font" , "white"); Label priceLbl = new Label( String.format( "%.0f" , price ),skin , "default-font" , "white"); // Add labels to tooltip table this.defaults().grow(); this.add(towerNameLbl).align(Align.left); this.row(); this.add(fireRateText).align(Align.left); this.add(fireRateLbl).align(Align.right); this.row(); this.add(damageText).align(Align.left); this.add(damageLbl).align(Align.right); this.row(); this.add(rangeText).align(Align.left); this.add(rangeLbl).align(Align.right); this.row(); this.add(specialText).align(Align.left); this.add(specialLbl).align(Align.right); this.row(); this.add(descriptionLbl).align(Align.left).colspan(2); this.row(); this.add(priceText).align(Align.left); this.add(priceLbl).align(Align.right); this.pad(8); this.align(Align.left); }
public Tooltip<Table> getTooltip(){ return tooltip; }
@Override public void process(final LmlParser parser, final LmlTag tag, final TooltipTable actor, final String rawAttributeData) { final Tooltip<TooltipTable> tooltip = actor.getTooltip(); tooltip.setInstant(parser.parseBoolean(rawAttributeData, tooltip)); }
@Override public void process(final LmlParser parser, final LmlTag tag, final TooltipTable actor, final String rawAttributeData) { final Tooltip<TooltipTable> tooltip = actor.getTooltip(); tooltip.setAlways(parser.parseBoolean(rawAttributeData, tooltip)); }
/** @return managed instance of tooltip. */ public Tooltip<TooltipTable> getTooltip() { return tooltip; }
/** @param skin used to construct table children (for example: labels out of plain text). * @param tooltip will be represented by this table. */ public TooltipTable(final Skin skin, final Tooltip<TooltipTable> tooltip) { super(skin); this.tooltip = tooltip; }
/** @return tooltip represented by this table. */ public Tooltip<TooltipTable> getTooltip() { return tooltip; }