Block icon rework / Dynamic icon generation / Tech tree tweaks
This commit is contained in:
@@ -12,6 +12,7 @@ import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.StatCategory;
|
||||
@@ -25,7 +26,7 @@ public class ContentDisplay{
|
||||
table.table(title -> {
|
||||
int size = 8 * 6;
|
||||
|
||||
title.addImage(Core.atlas.find("block-icon-" + block.name)).size(size);
|
||||
title.addImage(recipe.result.icon(Icon.large)).size(size);
|
||||
title.add("[accent]" + block.formalName).padLeft(5);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.scene.ui.Image;
|
||||
import io.anuke.arc.scene.ui.layout.Stack;
|
||||
|
||||
public class ImageStack extends Stack{
|
||||
|
||||
public ImageStack(TextureRegion... regions){
|
||||
for(TextureRegion region : regions){
|
||||
add(new Image(region));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,16 @@ import io.anuke.arc.math.geom.Rectangle;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.event.InputEvent;
|
||||
import io.anuke.arc.scene.event.InputListener;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.content.TechTree;
|
||||
import io.anuke.mindustry.content.TechTree.TechNode;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.Recipe.RecipeVisibility;
|
||||
import io.anuke.mindustry.ui.TreeLayout;
|
||||
import io.anuke.mindustry.ui.TreeLayout.TreeNode;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
|
||||
public class TechTreeDialog extends FloatingDialog{
|
||||
private TreeLayout layout;
|
||||
@@ -31,9 +33,11 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
layout.gapBetweenLevels = 60f;
|
||||
layout.gapBetweenNodes = 40f;
|
||||
layout.layout(new TechTreeNode(TechTree.root, null));
|
||||
|
||||
cont.add(new View()).grow();
|
||||
|
||||
double total = Vars.content.recipes().count(r -> r.visibility == RecipeVisibility.all);
|
||||
if(total > nodes.size) Log.err("Recipe tree coverage: {0}%", (int)(nodes.size / total * 100));
|
||||
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
@@ -95,10 +99,8 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
for(TechTreeNode node : nodes){
|
||||
Draw.drawable("content-background", node.x + offsetX - node.width/2f, node.y + offsetY - node.height/2f, node.width, node.height);
|
||||
|
||||
Content content = node.node.content;
|
||||
TextureRegion region = content instanceof Block ? ((Block)content).getEditorIcon() :
|
||||
((UnlockableContent)content).getContentIcon();
|
||||
Draw.rect(region, node.x + offsetX, node.y + offsetY, 8*3, 8*3);
|
||||
TextureRegion region = node.node.block == null ? Blocks.core.icon(Icon.medium) : node.node.block.icon(Icon.medium);
|
||||
Draw.rect(region, node.x + offsetX, node.y + offsetY - 0.5f, region.getWidth(), region.getHeight());
|
||||
}
|
||||
|
||||
ScissorStack.popScissors();
|
||||
|
||||
@@ -23,8 +23,8 @@ import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.type.Category;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.ImageStack;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
|
||||
@@ -144,7 +144,7 @@ public class PlacementFragment extends Fragment{
|
||||
if(!ulock){
|
||||
button.replaceImage(new Image("icon-locked"));
|
||||
}else{
|
||||
button.replaceImage(new ImageStack(recipe.result.getCompactIcon()));
|
||||
button.replaceImage(new Image(recipe.result.icon(Icon.medium)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@ public class PlacementFragment extends Fragment{
|
||||
if(lastDisplay != null){ //show selected recipe
|
||||
topTable.table(header -> {
|
||||
header.left();
|
||||
header.add(new ImageStack(lastDisplay.getCompactIcon())).size(8 * 4);
|
||||
header.add(new Image(lastDisplay.icon(Icon.medium))).size(8 * 4);
|
||||
header.labelWrap(() ->
|
||||
!data.isUnlocked(Recipe.getByResult(lastDisplay)) ? Core.bundle.get("blocks.unknown") : lastDisplay.formalName)
|
||||
.left().width(190f).padLeft(5);
|
||||
@@ -210,7 +210,7 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
}else if(tileDisplayBlock() != null){ //show selected tile
|
||||
lastDisplay = tileDisplayBlock();
|
||||
topTable.add(new ImageStack(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
|
||||
topTable.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
|
||||
topTable.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user