UI cleanup

This commit is contained in:
Anuken
2019-01-19 17:45:33 -05:00
parent 4fb0c246db
commit 093043750b
10 changed files with 733 additions and 716 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 966 KiB

After

Width:  |  Height:  |  Size: 963 KiB

View File

@ -37,6 +37,7 @@ TextButtonStyle: {
}, },
ImageButtonStyle: { ImageButtonStyle: {
default: {down: button-down, up: button, over: button-over, imageDisabledColor: gray, imageUpColor: white }, default: {down: button-down, up: button, over: button-over, imageDisabledColor: gray, imageUpColor: white },
node: {down: content-background-over, up: content-background, over: content-background-over},
right: {over: button-right-over, down: button-right-down, up: button-right}, right: {over: button-right-over, down: button-right-down, up: button-right},
empty: { imageDownColor: accent, imageUpColor: white}, empty: { imageDownColor: accent, imageUpColor: white},
emptytoggle: {imageCheckedColor: white, imageDownColor: white, imageUpColor: gray}, emptytoggle: {imageCheckedColor: white, imageDownColor: white, imageUpColor: gray},

View File

@ -88,6 +88,8 @@ public class MinimapRenderer implements Disposable{
} }
Draw.color(); Draw.color();
ScissorStack.popScissors();
} }
public TextureRegion getRegion(){ public TextureRegion getRegion(){

View File

@ -93,7 +93,7 @@ public class Recipe extends UnlockableContent{
@Override @Override
public void displayInfo(Table table){ public void displayInfo(Table table){
ContentDisplay.displayRecipe(table, this); ContentDisplay.displayBlock(table, result);
} }
@Override @Override

View File

@ -10,7 +10,6 @@ import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.type.Mech; import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Block.Icon; import io.anuke.mindustry.world.Block.Icon;
import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.BlockStat;
@ -20,13 +19,12 @@ import io.anuke.mindustry.world.meta.StatValue;
public class ContentDisplay{ public class ContentDisplay{
public static void displayRecipe(Table table, Recipe recipe){ public static void displayBlock(Table table, Block block){
Block block = recipe.result;
table.table(title -> { table.table(title -> {
int size = 8 * 6; int size = 8 * 6;
title.addImage(recipe.result.icon(Icon.large)).size(size); title.addImage(block.icon(Icon.large)).size(size);
title.add("[accent]" + block.formalName).padLeft(5); title.add("[accent]" + block.formalName).padLeft(5);
}); });

View File

@ -2,17 +2,18 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.collection.Array; import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.ObjectSet; import io.anuke.arc.collection.ObjectSet;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.graphics.g2d.ScissorStack; import io.anuke.arc.graphics.g2d.ScissorStack;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.input.KeyCode; import io.anuke.arc.input.KeyCode;
import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Rectangle;
import io.anuke.arc.scene.Element; import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.event.InputEvent; import io.anuke.arc.scene.event.InputEvent;
import io.anuke.arc.scene.event.InputListener; import io.anuke.arc.scene.event.InputListener;
import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.util.Align;
import io.anuke.arc.util.Log; import io.anuke.arc.util.Log;
import io.anuke.arc.util.Structs; import io.anuke.arc.util.Structs;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.content.TechTree; import io.anuke.mindustry.content.TechTree;
import io.anuke.mindustry.content.TechTree.TechNode; import io.anuke.mindustry.content.TechTree.TechNode;
@ -36,10 +37,11 @@ public class TechTreeDialog extends FloatingDialog{
layout.gapBetweenLevels = 60f; layout.gapBetweenLevels = 60f;
layout.gapBetweenNodes = 40f; layout.gapBetweenNodes = 40f;
layout.layout(new TechTreeNode(TechTree.root, null)); layout.layout(new TechTreeNode(TechTree.root, null));
cont.add(new View()).grow(); cont.add(new View()).grow();
{ //debug code { //debug code; TODO remove
ObjectSet<Recipe> used = new ObjectSet<>(); ObjectSet<Recipe> used = new ObjectSet<Recipe>().select(t -> true);
for(TechTreeNode node : nodes){ for(TechTreeNode node : nodes){
if(node.node.block != null) used.add(Recipe.getByResult(node.node.block)); if(node.node.block != null) used.add(Recipe.getByResult(node.node.block));
} }
@ -73,11 +75,26 @@ public class TechTreeDialog extends FloatingDialog{
} }
} }
class View extends Element{ class View extends Group{
float panX = 0, panY = 0; float panX = 0, panY = 0;
Rectangle clip = new Rectangle(); Rectangle clip = new Rectangle();
boolean moved = false;
{ {
for(TechTreeNode node : nodes){
ImageButton button = new ImageButton(node.node.block == null ? Blocks.core.icon(Icon.medium) : node.node.block.icon(Icon.medium), "node");
button.clicked(() -> {
if(moved) return;
Vars.ui.content.show(Recipe.getByResult(node.node.block == null ? Blocks.conveyor : node.node.block));
});
button.tapped(() -> {
moved = false;
});
button.setSize(nodeSize, nodeSize);
button.update(() -> button.setPosition(node.x + panX + width/2f, node.y + panY + height/2f - 0.5f, Align.center));
addChild(button);
}
addListener(new InputListener(){ addListener(new InputListener(){
float lastX, lastY; float lastX, lastY;
@Override @Override
@ -86,6 +103,7 @@ public class TechTreeDialog extends FloatingDialog{
panY -= lastY - my; panY -= lastY - my;
lastX = mx; lastX = mx;
lastY = my; lastY = my;
moved = true;
} }
@Override @Override
@ -113,6 +131,9 @@ public class TechTreeDialog extends FloatingDialog{
} }
} }
super.draw();
/*
Draw.color(); Draw.color();
for(TechTreeNode node : nodes){ for(TechTreeNode node : nodes){
@ -120,7 +141,7 @@ public class TechTreeDialog extends FloatingDialog{
TextureRegion region = node.node.block == null ? Blocks.core.icon(Icon.medium) : node.node.block.icon(Icon.medium); 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()); Draw.rect(region, node.x + offsetX, node.y + offsetY - 0.5f, region.getWidth(), region.getHeight());
} }*/
ScissorStack.popScissors(); ScissorStack.popScissors();
} }

View File

@ -19,18 +19,6 @@ public class MenuFragment extends Fragment{
@Override @Override
public void build(Group parent){ public void build(Group parent){
if(true){
parent.fill(t -> {
t.add("do not play the bleeding edge").get().setFontScale(2f);
t.row();
t.add("none of it is playable yet");
t.row();
t.add("something usable will be released 'soon' (TM)").get().setFontScale(0.5f);
});
return;
}
parent.fill(c -> { parent.fill(c -> {
container = c; container = c;
container.visible(() -> state.is(State.menu)); container.visible(() -> state.is(State.menu));

View File

@ -78,7 +78,6 @@ class Image {
} }
void drawScaled(Image image){ void drawScaled(Image image){
//graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics.drawImage(image.image.getScaledInstance(width(), height(), java.awt.Image.SCALE_AREA_AVERAGING), 0, 0, width(), height(), null); graphics.drawImage(image.image.getScaledInstance(width(), height(), java.awt.Image.SCALE_AREA_AVERAGING), 0, 0, width(), height(), null);
} }