mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-12 03:37:27 +07:00
Replaced tooltips with names
This commit is contained in:
parent
0efaa11553
commit
d862498516
@ -497,7 +497,7 @@ text.mech.ability = [LIGHT_GRAY]Ability\: {0}
|
||||
text.liquid.heatcapacity = [LIGHT_GRAY]Heat Capacity\: {0}
|
||||
text.liquid.viscosity = [LIGHT_GRAY]Viscosity\: {0}
|
||||
text.liquid.temperature = [LIGHT_GRAY]Temperature\: {0}
|
||||
block.constructing = {0}\n[LIGHT_GRAY](Constructing)
|
||||
block.constructing = {0} [LIGHT_GRAY](Constructing)
|
||||
block.spawn.name = Enemy Spawn
|
||||
block.core.name = Core
|
||||
block.metalfloor.name = Metal Floor
|
||||
|
18
core/src/io/anuke/mindustry/ui/ItemDisplay.java
Normal file
18
core/src/io/anuke/mindustry/ui/ItemDisplay.java
Normal file
@ -0,0 +1,18 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
/**An item image with text.*/
|
||||
public class ItemDisplay extends Table{
|
||||
|
||||
public ItemDisplay(Item item){
|
||||
this(item, 0);
|
||||
}
|
||||
|
||||
public ItemDisplay(Item item, int amount){
|
||||
add(new ItemImage(new ItemStack(item, amount))).size(8*3);
|
||||
add(item.localizedName()).padLeft(4);
|
||||
}
|
||||
}
|
@ -18,10 +18,12 @@ public class ItemImage extends Stack{
|
||||
}
|
||||
|
||||
public ItemImage(ItemStack stack){
|
||||
Table t = new Table().left().bottom();
|
||||
t.add(stack.amount + "");
|
||||
|
||||
add(new Image(stack.item.region));
|
||||
add(t);
|
||||
|
||||
if(stack.amount != 0){
|
||||
Table t = new Table().left().bottom();
|
||||
t.add(stack.amount + "");
|
||||
add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
core/src/io/anuke/mindustry/ui/LiquidDisplay.java
Normal file
14
core/src/io/anuke/mindustry/ui/LiquidDisplay.java
Normal file
@ -0,0 +1,14 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
/**An ItemDisplay, but for liquids.*/
|
||||
public class LiquidDisplay extends Table{
|
||||
|
||||
public LiquidDisplay(Liquid liquid){
|
||||
add(new Image(liquid.getContentIcon())).size(8*3);
|
||||
add(liquid.localizedName()).padLeft(3);
|
||||
}
|
||||
}
|
@ -6,10 +6,10 @@ import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.event.HandCursorListener;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.utils.UIUtils;
|
||||
|
||||
@ -65,7 +65,10 @@ public class UnlocksDialog extends FloatingDialog{
|
||||
|
||||
if(control.unlocks.isUnlocked(unlock)){
|
||||
image.clicked(() -> Vars.ui.content.show(unlock));
|
||||
StatValue.addToolTip(image, unlock);
|
||||
image.addListener(new Tooltip<>(new Table("clear"){{
|
||||
add(unlock.localizedName());
|
||||
margin(4);
|
||||
}}));
|
||||
}
|
||||
|
||||
if((++count) % maxWidth == 0){
|
||||
|
@ -89,7 +89,7 @@ public class PlacementFragment extends Fragment{
|
||||
topTable.table(header -> {
|
||||
header.left();
|
||||
header.add(new ImageStack(lastDisplay.getCompactIcon())).size(8*4);
|
||||
header.labelWrap(lastDisplay.formalName).left().width(150f).padLeft(5);
|
||||
header.labelWrap(lastDisplay.formalName).left().width(200f).padLeft(5);
|
||||
}).growX().left();
|
||||
topTable.row();
|
||||
//add requirement table
|
||||
|
@ -16,14 +16,11 @@ import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
@ -135,8 +132,9 @@ public class Drill extends Block{
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Item item = list.get(i);
|
||||
Cell<Image> imageCell = table.addImage(item.name + "1").size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
|
||||
StatValue.addToolTip(imageCell.getElement(), item);
|
||||
|
||||
table.addImage(item.name + "1").size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
|
||||
table.add(item.localizedName());
|
||||
if(i != list.size - 1){
|
||||
table.add("/");
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
package io.anuke.mindustry.world.meta;
|
||||
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
/**
|
||||
@ -16,34 +11,4 @@ public interface StatValue{
|
||||
* For example, a stat that is just text would add label to the table.
|
||||
*/
|
||||
void display(Table table);
|
||||
|
||||
/**
|
||||
* This method adds an icon image together with a tool tip which contains the name of the item.
|
||||
* @param table the table to add the image cell to.
|
||||
* @param item The item which provides the tool tip content.
|
||||
* @return the image cell which was created. The cell is not yet sized or padded.
|
||||
*/
|
||||
static Cell<Image> addImageWithToolTip(Table table, UnlockableContent item){
|
||||
|
||||
// Create a table cell with a new image as provided by the item
|
||||
Cell<Image> imageCell = table.addImage(item.getContentIcon());
|
||||
|
||||
// Retrieve the image and add a tool tip with the item's name
|
||||
addToolTip(imageCell.getElement(), item);
|
||||
|
||||
// Return the table cell for further processing (sizing, padding, ...)
|
||||
return imageCell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tool tip containing the item's localized name to the given element.
|
||||
* @param element The element to assign the tool tip to.
|
||||
* @param item The item which provides the tool tip content.
|
||||
*/
|
||||
static void addToolTip(Element element, UnlockableContent item){
|
||||
element.addListener(new Tooltip<>(new Table("clear"){{
|
||||
add(item.localizedName());
|
||||
margin(4);
|
||||
}}));
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ package io.anuke.mindustry.world.meta.values;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.ui.ItemDisplay;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class ItemFilterValue implements StatValue{
|
||||
private final Predicate<Item> filter;
|
||||
@ -27,10 +27,7 @@ public class ItemFilterValue implements StatValue{
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Item item = list.get(i);
|
||||
|
||||
Cell<Image> imageCell = table.addImage(item.region);
|
||||
imageCell.size(8 * 3).padRight(2).padLeft(2);
|
||||
|
||||
StatValue.addToolTip(imageCell.getElement(), item);
|
||||
table.add(new ItemDisplay(item)).padRight(5);
|
||||
|
||||
if(i != list.size - 1){
|
||||
table.add("/");
|
||||
|
@ -3,11 +3,8 @@ package io.anuke.mindustry.world.meta.values;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.ui.ItemDisplay;
|
||||
import io.anuke.mindustry.world.meta.ContentStatValue;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class ItemListValue implements ContentStatValue{
|
||||
@ -41,17 +38,11 @@ public class ItemListValue implements ContentStatValue{
|
||||
public void display(Table table){
|
||||
if(items != null){
|
||||
for(Item item : items){
|
||||
Cell<Image> imageCell = table.addImage(item.region);
|
||||
imageCell.size(8 * 3).padRight(5);
|
||||
|
||||
StatValue.addToolTip(imageCell.getElement(), item);
|
||||
table.add(new ItemDisplay(item));
|
||||
}
|
||||
}else{
|
||||
for(ItemStack stack : stacks){
|
||||
ItemImage image = new ItemImage(stack);
|
||||
table.add(image).size(8 * 3).padRight(5);
|
||||
|
||||
StatValue.addToolTip(image, stack.item);
|
||||
new ItemDisplay(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,8 @@ package io.anuke.mindustry.world.meta.values;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.ui.ItemDisplay;
|
||||
import io.anuke.mindustry.world.meta.ContentStatValue;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class ItemValue implements ContentStatValue{
|
||||
@ -22,9 +21,6 @@ public class ItemValue implements ContentStatValue{
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
//TODO better implementation, quantity support
|
||||
ItemImage image = new ItemImage(item);
|
||||
table.add(image).size(8 * 3);
|
||||
StatValue.addToolTip(image, item.item);
|
||||
table.add(new ItemDisplay(item.item, item.amount));
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,12 @@ package io.anuke.mindustry.world.meta.values;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.ui.LiquidDisplay;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class LiquidFilterValue implements StatValue{
|
||||
private final Predicate<Liquid> filter;
|
||||
@ -26,10 +25,7 @@ public class LiquidFilterValue implements StatValue{
|
||||
}
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Liquid item = list.get(i);
|
||||
|
||||
Cell<Image> imageCell = StatValue.addImageWithToolTip(table, item);
|
||||
imageCell.size(8 * 3).padRight(2).padLeft(2).padTop(2).padBottom(2);
|
||||
table.add(new LiquidDisplay(list.get(i))).padRight(5);
|
||||
|
||||
if(i != list.size - 1){
|
||||
table.add("/");
|
||||
|
@ -2,10 +2,8 @@ package io.anuke.mindustry.world.meta.values;
|
||||
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.ui.LiquidDisplay;
|
||||
import io.anuke.mindustry.world.meta.ContentStatValue;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class LiquidValue implements ContentStatValue{
|
||||
@ -22,7 +20,6 @@ public class LiquidValue implements ContentStatValue{
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
Cell<Image> imageCell = StatValue.addImageWithToolTip(table, liquid);
|
||||
imageCell.size(8 * 3);
|
||||
table.add(new LiquidDisplay(liquid));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user