mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
UI cleanup
This commit is contained in:
BIN
core/assets-raw/sprites/ui/content-background-over.9.png
Normal file
BIN
core/assets-raw/sprites/ui/content-background-over.9.png
Normal file
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 |
@ -37,6 +37,7 @@ TextButtonStyle: {
|
||||
},
|
||||
ImageButtonStyle: {
|
||||
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},
|
||||
empty: { imageDownColor: accent, imageUpColor: white},
|
||||
emptytoggle: {imageCheckedColor: white, imageDownColor: white, imageUpColor: gray},
|
||||
|
@ -88,6 +88,8 @@ public class MinimapRenderer implements Disposable{
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
|
||||
ScissorStack.popScissors();
|
||||
}
|
||||
|
||||
public TextureRegion getRegion(){
|
||||
|
@ -93,7 +93,7 @@ public class Recipe extends UnlockableContent{
|
||||
|
||||
@Override
|
||||
public void displayInfo(Table table){
|
||||
ContentDisplay.displayRecipe(table, this);
|
||||
ContentDisplay.displayBlock(table, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,6 @@ import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
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;
|
||||
@ -20,13 +19,12 @@ import io.anuke.mindustry.world.meta.StatValue;
|
||||
|
||||
public class ContentDisplay{
|
||||
|
||||
public static void displayRecipe(Table table, Recipe recipe){
|
||||
Block block = recipe.result;
|
||||
public static void displayBlock(Table table, Block block){
|
||||
|
||||
table.table(title -> {
|
||||
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);
|
||||
});
|
||||
|
||||
|
@ -2,17 +2,18 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
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.ScissorStack;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
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.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.Structs;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.content.TechTree;
|
||||
import io.anuke.mindustry.content.TechTree.TechNode;
|
||||
@ -36,10 +37,11 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
layout.gapBetweenLevels = 60f;
|
||||
layout.gapBetweenNodes = 40f;
|
||||
layout.layout(new TechTreeNode(TechTree.root, null));
|
||||
|
||||
cont.add(new View()).grow();
|
||||
|
||||
{ //debug code
|
||||
ObjectSet<Recipe> used = new ObjectSet<>();
|
||||
{ //debug code; TODO remove
|
||||
ObjectSet<Recipe> used = new ObjectSet<Recipe>().select(t -> true);
|
||||
for(TechTreeNode node : nodes){
|
||||
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;
|
||||
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(){
|
||||
float lastX, lastY;
|
||||
@Override
|
||||
@ -86,6 +103,7 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
panY -= lastY - my;
|
||||
lastX = mx;
|
||||
lastY = my;
|
||||
moved = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,6 +131,9 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
}
|
||||
}
|
||||
|
||||
super.draw();
|
||||
|
||||
/*
|
||||
Draw.color();
|
||||
|
||||
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);
|
||||
Draw.rect(region, node.x + offsetX, node.y + offsetY - 0.5f, region.getWidth(), region.getHeight());
|
||||
}
|
||||
}*/
|
||||
|
||||
ScissorStack.popScissors();
|
||||
}
|
||||
|
@ -19,18 +19,6 @@ public class MenuFragment extends Fragment{
|
||||
|
||||
@Override
|
||||
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 -> {
|
||||
container = c;
|
||||
container.visible(() -> state.is(State.menu));
|
||||
|
@ -78,7 +78,6 @@ class 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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user