Core database content icon click support
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
package mindustry.ui;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class ItemImage extends Stack{
|
||||
|
||||
public ItemImage(TextureRegion region, int amount){
|
||||
|
||||
add(new Table(o -> {
|
||||
o.left();
|
||||
o.add(new Image(region)).size(32f).scaling(Scaling.fit);
|
||||
}));
|
||||
|
||||
if(amount != 0){
|
||||
add(new Table(t -> {
|
||||
t.left().bottom();
|
||||
t.add(amount >= 1000 ? UI.formatAmount(amount) : amount + "").style(Styles.outlineLabel);
|
||||
t.pack();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemImage(ItemStack stack){
|
||||
this(stack.item.uiIcon, stack.amount);
|
||||
}
|
||||
|
||||
public ItemImage(PayloadStack stack){
|
||||
this(stack.item.uiIcon, stack.amount);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.ConstructBlock.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -465,7 +466,7 @@ public class PlacementFragment{
|
||||
for(int i = 0; i < counts.length; i++){
|
||||
if(counts[i] > 0){
|
||||
var type = content.unit(i);
|
||||
unitlist.add(new ItemImage(type.uiIcon, counts[i])).tooltip(type.localizedName).pad(4).with(b -> {
|
||||
unitlist.add(StatValues.stack(type, counts[i])).tooltip(type.localizedName).pad(4).with(b -> {
|
||||
var listener = new ClickListener();
|
||||
|
||||
//left click -> select
|
||||
|
||||
Reference in New Issue
Block a user