New place menu
BIN
core/assets-raw/sprites/ui/icons-category/icon-crafting.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-defense.png
Normal file
After Width: | Height: | Size: 273 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-distribution.png
Normal file
After Width: | Height: | Size: 204 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-liquid.png
Normal file
After Width: | Height: | Size: 266 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-power.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-production.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-turret.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-units.png
Normal file
After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 102 KiB |
@ -5,8 +5,7 @@ Color: {
|
|||||||
gray: {a: 1, b: 0.32, g: 0.32, r: 0.32 },
|
gray: {a: 1, b: 0.32, g: 0.32, r: 0.32 },
|
||||||
lightgray: {a: 1, b: 0.65, g: 0.65, r: 0.65 }
|
lightgray: {a: 1, b: 0.65, g: 0.65, r: 0.65 }
|
||||||
orange: {hex: "FFA500"},
|
orange: {hex: "FFA500"},
|
||||||
accent: {hex: "f4ba6e"},
|
accent: {hex: "ffd37f"}
|
||||||
accentDark: {hex: "f4ba6e"},
|
|
||||||
},
|
},
|
||||||
TintedDrawable: {
|
TintedDrawable: {
|
||||||
dialogDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.9} },
|
dialogDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.9} },
|
||||||
@ -15,8 +14,8 @@ TintedDrawable: {
|
|||||||
chatfield: {name: white, color: {r: 0, g: 0, b: 0, a: 0.2}},
|
chatfield: {name: white, color: {r: 0, g: 0, b: 0, a: 0.2}},
|
||||||
clear: {name: white, color: {r: 0.1, g: 0.1, b: 0.1, a: 0.75}},
|
clear: {name: white, color: {r: 0.1, g: 0.1, b: 0.1, a: 0.75}},
|
||||||
none: {name: white, color: {r: 0, g: 0, b: 0, a: 0}},
|
none: {name: white, color: {r: 0, g: 0, b: 0, a: 0}},
|
||||||
clear-over: {name: white, color: {r: 1, g: 1, b: 1, a: 0.2} },
|
clear-over: {name: white, color: { hex: "#ffd37f82" } },
|
||||||
clear-down: {name: white, color: {r: 1, g: 1, b: 1, a: 0.4} }
|
clear-down: {name: white, color: { hex: "#ffd37fff" } }
|
||||||
},
|
},
|
||||||
ButtonStyle: {
|
ButtonStyle: {
|
||||||
default: {down: button-down, up: button },
|
default: {down: button-down, up: button },
|
||||||
@ -40,6 +39,7 @@ ImageButtonStyle: {
|
|||||||
toggle: {checked: button-down, down: button-down, up: button, imageDisabledColor: gray, imageUpColor: white },
|
toggle: {checked: button-down, down: button-down, up: button, imageDisabledColor: gray, imageUpColor: white },
|
||||||
select: {checked: button-select, up: none },
|
select: {checked: button-select, up: none },
|
||||||
clear: {down: clear-down, up: clear, over: clear-over},
|
clear: {down: clear-down, up: clear, over: clear-over},
|
||||||
|
clear-toggle: {down: clear-down, checked: clear-down, up: clear, over: clear-over},
|
||||||
},
|
},
|
||||||
ScrollPaneStyle: {
|
ScrollPaneStyle: {
|
||||||
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
||||||
|
@ -52,18 +52,18 @@ public class Recipes implements ContentList{
|
|||||||
.setDependencies(Items.blastCompound);
|
.setDependencies(Items.blastCompound);
|
||||||
|
|
||||||
//TURRETS
|
//TURRETS
|
||||||
new Recipe(weapon, TurretBlocks.duo, new ItemStack(Items.copper, 40)).setAlwaysUnlocked(true);
|
new Recipe(turret, TurretBlocks.duo, new ItemStack(Items.copper, 40)).setAlwaysUnlocked(true);
|
||||||
new Recipe(weapon, TurretBlocks.arc, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 30), new ItemStack(Items.silicon, 20));
|
new Recipe(turret, TurretBlocks.arc, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 30), new ItemStack(Items.silicon, 20));
|
||||||
new Recipe(weapon, TurretBlocks.hail, new ItemStack(Items.copper, 60), new ItemStack(Items.densealloy, 35));
|
new Recipe(turret, TurretBlocks.hail, new ItemStack(Items.copper, 60), new ItemStack(Items.densealloy, 35));
|
||||||
new Recipe(weapon, TurretBlocks.lancer, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 100), new ItemStack(Items.silicon, 90));
|
new Recipe(turret, TurretBlocks.lancer, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 100), new ItemStack(Items.silicon, 90));
|
||||||
new Recipe(weapon, TurretBlocks.wave, new ItemStack(Items.densealloy, 60), new ItemStack(Items.titanium, 70), new ItemStack(Items.lead, 150));
|
new Recipe(turret, TurretBlocks.wave, new ItemStack(Items.densealloy, 60), new ItemStack(Items.titanium, 70), new ItemStack(Items.lead, 150));
|
||||||
new Recipe(weapon, TurretBlocks.salvo, new ItemStack(Items.copper, 210), new ItemStack(Items.densealloy, 190), new ItemStack(Items.thorium, 130));
|
new Recipe(turret, TurretBlocks.salvo, new ItemStack(Items.copper, 210), new ItemStack(Items.densealloy, 190), new ItemStack(Items.thorium, 130));
|
||||||
new Recipe(weapon, TurretBlocks.swarmer, new ItemStack(Items.densealloy, 70), new ItemStack(Items.titanium, 70), new ItemStack(Items.plastanium, 90), new ItemStack(Items.silicon, 60));
|
new Recipe(turret, TurretBlocks.swarmer, new ItemStack(Items.densealloy, 70), new ItemStack(Items.titanium, 70), new ItemStack(Items.plastanium, 90), new ItemStack(Items.silicon, 60));
|
||||||
new Recipe(weapon, TurretBlocks.ripple, new ItemStack(Items.copper, 300), new ItemStack(Items.densealloy, 220), new ItemStack(Items.thorium, 120));
|
new Recipe(turret, TurretBlocks.ripple, new ItemStack(Items.copper, 300), new ItemStack(Items.densealloy, 220), new ItemStack(Items.thorium, 120));
|
||||||
new Recipe(weapon, TurretBlocks.cyclone, new ItemStack(Items.copper, 400), new ItemStack(Items.densealloy, 400), new ItemStack(Items.surgealloy, 200), new ItemStack(Items.plastanium, 150));
|
new Recipe(turret, TurretBlocks.cyclone, new ItemStack(Items.copper, 400), new ItemStack(Items.densealloy, 400), new ItemStack(Items.surgealloy, 200), new ItemStack(Items.plastanium, 150));
|
||||||
new Recipe(weapon, TurretBlocks.fuse, new ItemStack(Items.copper, 450), new ItemStack(Items.densealloy, 450), new ItemStack(Items.surgealloy, 250));
|
new Recipe(turret, TurretBlocks.fuse, new ItemStack(Items.copper, 450), new ItemStack(Items.densealloy, 450), new ItemStack(Items.surgealloy, 250));
|
||||||
new Recipe(weapon, TurretBlocks.spectre, new ItemStack(Items.copper, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 500), new ItemStack(Items.plastanium, 350), new ItemStack(Items.thorium, 500));
|
new Recipe(turret, TurretBlocks.spectre, new ItemStack(Items.copper, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 500), new ItemStack(Items.plastanium, 350), new ItemStack(Items.thorium, 500));
|
||||||
new Recipe(weapon, TurretBlocks.meltdown, new ItemStack(Items.copper, 500), new ItemStack(Items.lead, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 650), new ItemStack(Items.silicon, 650));
|
new Recipe(turret, TurretBlocks.meltdown, new ItemStack(Items.copper, 500), new ItemStack(Items.lead, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 650), new ItemStack(Items.silicon, 650));
|
||||||
|
|
||||||
//DISTRIBUTION
|
//DISTRIBUTION
|
||||||
new Recipe(distribution, DistributionBlocks.conveyor, new ItemStack(Items.copper, 1)).setAlwaysUnlocked(true);
|
new Recipe(distribution, DistributionBlocks.conveyor, new ItemStack(Items.copper, 1)).setAlwaysUnlocked(true);
|
||||||
|
@ -28,6 +28,7 @@ import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
|
|||||||
import io.anuke.ucore.scene.ui.TooltipManager;
|
import io.anuke.ucore.scene.ui.TooltipManager;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static io.anuke.ucore.scene.actions.Actions.*;
|
import static io.anuke.ucore.scene.actions.Actions.*;
|
||||||
@ -293,4 +294,16 @@ public class UI extends SceneModule{
|
|||||||
dialog.keyDown(Keys.BACK, dialog::hide);
|
dialog.keyDown(Keys.BACK, dialog::hide);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String formatAmount(int number){
|
||||||
|
if(number >= 1000000){
|
||||||
|
return Strings.toFixed(number / 1000000f, 1) + "[gray]mil[]";
|
||||||
|
}else if(number >= 10000){
|
||||||
|
return number / 1000 + "[gray]k[]";
|
||||||
|
}else if(number >= 1000){
|
||||||
|
return Strings.toFixed(number / 1000f, 1) + "[gray]k[]";
|
||||||
|
}else{
|
||||||
|
return number + "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
14
core/src/io/anuke/mindustry/ui/ImageStack.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||||
|
|
||||||
|
public class ImageStack extends Stack{
|
||||||
|
|
||||||
|
public ImageStack(TextureRegion... regions){
|
||||||
|
for(TextureRegion region : regions){
|
||||||
|
add(new Image(region));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,183 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.type.Category;
|
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.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||||
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
|
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class BlocksFragment extends Fragment{
|
public class BlocksFragment extends Fragment{
|
||||||
|
final int rowWidth = 3;
|
||||||
|
|
||||||
|
Category currentCategory = Category.turret;
|
||||||
|
Block hovered;
|
||||||
|
Block lastDisplay;
|
||||||
|
Tile hoverTile;
|
||||||
|
Table blockTable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
parent.fill(frame -> {
|
InputHandler input = control.input(0);
|
||||||
frame.bottom().left();
|
|
||||||
for(int i = 0; i < Category.values().length; i++){
|
|
||||||
|
|
||||||
}
|
parent.fill(frame -> {
|
||||||
|
//rebuilds the top table with the selected recipe
|
||||||
|
|
||||||
|
//rebuilds the category table with the correct recipes
|
||||||
|
Runnable rebuildCategory = () -> {
|
||||||
|
blockTable.clear();
|
||||||
|
blockTable.top().margin(5);
|
||||||
|
|
||||||
|
//blockTable.add(currentCategory.name()).colspan(rowWidth).growX(); //TODO localize
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
|
group.setMinCheckCount(0);
|
||||||
|
|
||||||
|
for(Recipe recipe : content.recipes()){
|
||||||
|
if(recipe.category != currentCategory) continue;
|
||||||
|
|
||||||
|
if(index++ % rowWidth == 0){
|
||||||
|
blockTable.row();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageButton button = blockTable.addImageButton("blank", "select", 8*4,
|
||||||
|
() -> input.recipe = input.recipe == recipe ? null : recipe)
|
||||||
|
.size(50f).group(group).update(b -> b.setChecked(input.recipe == recipe)).get();
|
||||||
|
|
||||||
|
button.replaceImage(new ImageStack(recipe.result.getCompactIcon()));
|
||||||
|
|
||||||
|
button.hovered(() -> hovered = recipe.result);
|
||||||
|
|
||||||
|
button.exited(() -> {
|
||||||
|
if(hovered == recipe.result){
|
||||||
|
hovered = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
frame.bottom().left().visible(() -> !state.is(State.menu));
|
||||||
|
|
||||||
|
frame.table("clear", top -> {
|
||||||
|
top.add(new Table()).growX().update(topTable -> {
|
||||||
|
if((tileDisplayBlock() == null && lastDisplay == getSelected()) ||
|
||||||
|
(tileDisplayBlock() != null && lastDisplay == tileDisplayBlock())) return;
|
||||||
|
|
||||||
|
topTable.clear();
|
||||||
|
topTable.top().left().margin(5);
|
||||||
|
|
||||||
|
lastDisplay = getSelected();
|
||||||
|
|
||||||
|
if(lastDisplay != null){ //show selected recipe
|
||||||
|
topTable.table(header -> {
|
||||||
|
header.left();
|
||||||
|
header.add(new ImageStack(lastDisplay.getCompactIcon())).size(8*4);
|
||||||
|
header.labelWrap(lastDisplay.formalName).left().width(150f).padLeft(5);
|
||||||
|
}).growX().left();
|
||||||
|
topTable.row();
|
||||||
|
//add requirement table
|
||||||
|
topTable.table(req -> {
|
||||||
|
req.top().left();
|
||||||
|
|
||||||
|
for(ItemStack stack : Recipe.getByResult(lastDisplay).requirements){
|
||||||
|
req.table(line -> {
|
||||||
|
line.left();
|
||||||
|
line.addImage(stack.item.region).size(8*2);
|
||||||
|
line.add(stack.item.localizedName()).padLeft(2).left().get().setFontScale(0.5f);
|
||||||
|
line.labelWrap(() -> {
|
||||||
|
TileEntity core = players[0].getClosestCore();
|
||||||
|
if(core == null || state.mode.infiniteResources) return "*/*";
|
||||||
|
|
||||||
|
int amount = core.items.get(stack.item);
|
||||||
|
String color = (amount < stack.amount / 2f ? "[red]" : amount < stack.amount ? "[accent]" : "[white]");
|
||||||
|
|
||||||
|
return color + ui.formatAmount(amount) + "[white]/" + stack.amount;
|
||||||
|
}).padLeft(5).get().setFontScale(0.5f);
|
||||||
|
}).left();
|
||||||
|
req.row();
|
||||||
|
}
|
||||||
|
}).growX().left().margin(3);
|
||||||
|
|
||||||
|
}else if(tileDisplayBlock() != null){ //show selected tile
|
||||||
|
lastDisplay = tileDisplayBlock();
|
||||||
|
topTable.add(new ImageStack(lastDisplay.getDisplayIcon(hoverTile))).size(8*4);
|
||||||
|
topTable.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(150f).padLeft(5);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
top.row();
|
||||||
|
top.addImage("blank").growX().color(Palette.accent).height(3f);
|
||||||
|
}).colspan(2).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null);
|
||||||
|
frame.row();
|
||||||
|
frame.table(categories -> {
|
||||||
|
categories.defaults().size(45f);
|
||||||
|
|
||||||
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
|
|
||||||
|
for(Category cat : Category.values()){
|
||||||
|
categories.addImageButton("icon-" + cat.name(), "clear-toggle", 16*2, () -> {
|
||||||
|
currentCategory = cat;
|
||||||
|
rebuildCategory.run();
|
||||||
|
}).group(group);
|
||||||
|
|
||||||
|
categories.row();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
frame.table("clear", blocks -> blockTable = blocks).fillY().bottom();
|
||||||
|
|
||||||
|
rebuildCategory.run();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Returns the currently displayed block in the top box.*/
|
||||||
|
Block getSelected(){
|
||||||
|
Block toDisplay = null;
|
||||||
|
|
||||||
|
//setup hovering tile
|
||||||
|
if(!ui.hasMouse()){
|
||||||
|
Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
||||||
|
if(tile != null){
|
||||||
|
hoverTile = tile.target();
|
||||||
|
}else{
|
||||||
|
hoverTile = null;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hoverTile = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//block currently selected
|
||||||
|
if(control.input(0).recipe != null){
|
||||||
|
toDisplay = control.input(0).recipe.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//block hovered on in build menu
|
||||||
|
if(hovered != null){
|
||||||
|
toDisplay = hovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
return toDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Returns the block currently being hovered over in the world.*/
|
||||||
|
Block tileDisplayBlock(){
|
||||||
|
return hoverTile == null ? null : hoverTile.block().synthetic() ? hoverTile.block() : hoverTile.floor() instanceof OreBlock ? hoverTile.floor() : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**Rebuilds the whole placement menu, attempting to preserve previous state.*/
|
/**Rebuilds the whole placement menu, attempting to preserve previous state.*/
|
||||||
void rebuild(){
|
void rebuild(){
|
||||||
|
|
||||||
|
@ -199,12 +199,6 @@ public class HudFragment extends Fragment{
|
|||||||
t.add("$text.saveload");
|
t.add("$text.saveload");
|
||||||
});
|
});
|
||||||
|
|
||||||
//tapped block indicator
|
|
||||||
parent.fill(t -> {
|
|
||||||
t.bottom().visible(() -> !state.is(State.menu));
|
|
||||||
t.add(new SelectionTable());
|
|
||||||
});
|
|
||||||
|
|
||||||
blockfrag.build(Core.scene.getRoot());
|
blockfrag.build(Core.scene.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|