diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 0dc46e60d8..62f0b8777f 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -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 diff --git a/core/src/io/anuke/mindustry/ui/ItemDisplay.java b/core/src/io/anuke/mindustry/ui/ItemDisplay.java new file mode 100644 index 0000000000..4530d606f0 --- /dev/null +++ b/core/src/io/anuke/mindustry/ui/ItemDisplay.java @@ -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); + } +} diff --git a/core/src/io/anuke/mindustry/ui/ItemImage.java b/core/src/io/anuke/mindustry/ui/ItemImage.java index 709c2903c2..130916cb26 100644 --- a/core/src/io/anuke/mindustry/ui/ItemImage.java +++ b/core/src/io/anuke/mindustry/ui/ItemImage.java @@ -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); + } } } diff --git a/core/src/io/anuke/mindustry/ui/LiquidDisplay.java b/core/src/io/anuke/mindustry/ui/LiquidDisplay.java new file mode 100644 index 0000000000..f639dfe1c5 --- /dev/null +++ b/core/src/io/anuke/mindustry/ui/LiquidDisplay.java @@ -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); + } +} diff --git a/core/src/io/anuke/mindustry/ui/dialogs/UnlocksDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/UnlocksDialog.java index 4d9411c4df..8b46947740 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/UnlocksDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/UnlocksDialog.java @@ -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){ diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 18ca4d6ddd..5e0287463a 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -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 diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java index f0232c5cf3..212a71168b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -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 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("/"); } diff --git a/core/src/io/anuke/mindustry/world/meta/StatValue.java b/core/src/io/anuke/mindustry/world/meta/StatValue.java index ef3e51acef..93726003ae 100644 --- a/core/src/io/anuke/mindustry/world/meta/StatValue.java +++ b/core/src/io/anuke/mindustry/world/meta/StatValue.java @@ -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 addImageWithToolTip(Table table, UnlockableContent item){ - - // Create a table cell with a new image as provided by the item - Cell 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); - }})); - } } diff --git a/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java b/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java index 669f5baa2c..0f917dda71 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java @@ -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 filter; @@ -27,10 +27,7 @@ public class ItemFilterValue implements StatValue{ for(int i = 0; i < list.size; i++){ Item item = list.get(i); - Cell 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("/"); diff --git a/core/src/io/anuke/mindustry/world/meta/values/ItemListValue.java b/core/src/io/anuke/mindustry/world/meta/values/ItemListValue.java index 7cb237296f..22e37ea7bd 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/ItemListValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/ItemListValue.java @@ -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 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); } } } diff --git a/core/src/io/anuke/mindustry/world/meta/values/ItemValue.java b/core/src/io/anuke/mindustry/world/meta/values/ItemValue.java index 269c537dc5..2b54142976 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/ItemValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/ItemValue.java @@ -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)); } } diff --git a/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java b/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java index 9dc6a6bd0b..7c5d638be9 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java @@ -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 filter; @@ -26,10 +25,7 @@ public class LiquidFilterValue implements StatValue{ } for(int i = 0; i < list.size; i++){ - Liquid item = list.get(i); - - Cell 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("/"); diff --git a/core/src/io/anuke/mindustry/world/meta/values/LiquidValue.java b/core/src/io/anuke/mindustry/world/meta/values/LiquidValue.java index d4d6734511..0dcc6c03c7 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/LiquidValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/LiquidValue.java @@ -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 imageCell = StatValue.addImageWithToolTip(table, liquid); - imageCell.size(8 * 3); + table.add(new LiquidDisplay(liquid)); } }