Added block description panel, disabled deselecting, updated uCore
This commit is contained in:
@@ -23,10 +23,10 @@ import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.graphics.Atlas;
|
||||
import io.anuke.ucore.modules.RendererModule;
|
||||
import io.anuke.ucore.modules.ControlModule;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Control extends RendererModule{
|
||||
public class Control extends ControlModule{
|
||||
public int rangex = 10, rangey = 10;
|
||||
public float targetzoom = 1f;
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.graphics.Cache;
|
||||
import io.anuke.ucore.graphics.Caches;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.ucore.util.*;
|
||||
import io.anuke.ucore.util.GridMap;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class Renderer{
|
||||
private static int chunksize = 32;
|
||||
@@ -110,7 +112,7 @@ public class Renderer{
|
||||
|
||||
public static void renderPixelOverlay(){
|
||||
|
||||
if(player.recipe != null && (!ui.hasMouse() || android)){
|
||||
if(player.recipe != null && Inventory.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android)){
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ import static io.anuke.ucore.scene.actions.Actions.*;
|
||||
import com.badlogic.gdx.Application.ApplicationType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.Timer.Task;
|
||||
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
@@ -20,21 +19,18 @@ import io.anuke.mindustry.input.AndroidInput;
|
||||
import io.anuke.mindustry.resource.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.function.Listenable;
|
||||
import io.anuke.ucore.function.VisibilityProvider;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.graphics.Textures;
|
||||
import io.anuke.ucore.modules.SceneModule;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Scene;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.*;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.layout.*;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class UI extends SceneModule{
|
||||
Table itemtable, weapontable, tools, loadingtable;
|
||||
Table itemtable, weapontable, tools, loadingtable, desctable;
|
||||
SettingsDialog prefs;
|
||||
KeybindDialog keys;
|
||||
Dialog about, menu, restart, tutorial, levels, upgrades, load;
|
||||
@@ -62,6 +58,10 @@ public class UI extends SceneModule{
|
||||
|
||||
Textures.load("sprites/");
|
||||
Textures.repeatWrap("conveyort", Gdx.app.getType() == ApplicationType.WebGL ? "back-web" : "back");
|
||||
|
||||
Colors.put("description", Color.WHITE);
|
||||
Colors.put("turretinfo", Color.ORANGE);
|
||||
Colors.put("missingitems", Color.SCARLET);
|
||||
}
|
||||
|
||||
void drawBackground(){
|
||||
@@ -114,7 +114,6 @@ public class UI extends SceneModule{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
//TODO just move these dialogs to different files
|
||||
|
||||
load = new LoadDialog();
|
||||
|
||||
@@ -146,19 +145,17 @@ public class UI extends SceneModule{
|
||||
|
||||
tutorial = new TutorialDialog();
|
||||
|
||||
restart = new Dialog("The core was destroyed.", "dialog"){
|
||||
public Dialog show(Scene scene){
|
||||
super.show(scene);
|
||||
restart.content().clearChildren();
|
||||
if(control.isHighScore()){
|
||||
restart.content().add("[YELLOW]New highscore!").pad(6);
|
||||
restart.content().row();
|
||||
}
|
||||
restart.content().add("You lasted until wave [GREEN]" + control.getWave() + "[].").pad(6);
|
||||
restart.pack();
|
||||
return this;
|
||||
restart = new Dialog("The core was destroyed.", "dialog");
|
||||
|
||||
restart.shown(()->{
|
||||
restart.content().clearChildren();
|
||||
if(control.isHighScore()){
|
||||
restart.content().add("[YELLOW]New highscore!").pad(6);
|
||||
restart.content().row();
|
||||
}
|
||||
};
|
||||
restart.content().add("You lasted until wave [GREEN]" + control.getWave() + "[].").pad(6);
|
||||
restart.pack();
|
||||
});
|
||||
|
||||
restart.getButtonTable().addButton("Back to menu", ()->{
|
||||
restart.hide();
|
||||
@@ -179,10 +176,16 @@ public class UI extends SceneModule{
|
||||
new table(){{
|
||||
abottom();
|
||||
aright();
|
||||
|
||||
new table("button"){{
|
||||
visible(()->player.recipe != null);
|
||||
desctable = get();
|
||||
fillX();
|
||||
}}.end().uniformX();
|
||||
|
||||
row();
|
||||
|
||||
new table(){{
|
||||
|
||||
get().background("button");
|
||||
new table("button"){{
|
||||
|
||||
int rows = 3;
|
||||
int maxcol = 0;
|
||||
@@ -202,12 +205,18 @@ public class UI extends SceneModule{
|
||||
recipes.clear();
|
||||
Recipe.getBy(sec, recipes);
|
||||
|
||||
Table table = new Table();
|
||||
|
||||
ImageButton button = new ImageButton("icon-"+sec.name(), "toggle");
|
||||
button.clicked(()->{
|
||||
if(!table.isVisible() && player.recipe != null){
|
||||
player.recipe = null;
|
||||
}
|
||||
});
|
||||
add(button).fill().height(54).padTop(-10).units(Unit.dp);
|
||||
button.getImageCell().size(40).padBottom(4).units(Unit.dp);
|
||||
group.add(button);
|
||||
|
||||
Table table = new Table();
|
||||
table.pad(4);
|
||||
|
||||
int i = 0;
|
||||
@@ -216,8 +225,10 @@ public class UI extends SceneModule{
|
||||
ImageButton image = new ImageButton(Draw.region(r.result.name()), "select");
|
||||
|
||||
image.clicked(()->{
|
||||
if(Inventory.hasItems(r.requirements))
|
||||
if(Inventory.hasItems(r.requirements)){
|
||||
player.recipe = r;
|
||||
updateRecipe();
|
||||
}
|
||||
});
|
||||
|
||||
table.add(image).size(size+8).pad(4).units(Unit.dp);
|
||||
@@ -236,67 +247,6 @@ public class UI extends SceneModule{
|
||||
table.row();
|
||||
|
||||
i++;
|
||||
|
||||
Table tiptable = new Table();
|
||||
|
||||
Listenable run = ()->{
|
||||
tiptable.clearChildren();
|
||||
|
||||
String description = r.result.description();
|
||||
|
||||
tiptable.background("button");
|
||||
tiptable.add("[PURPLE]" + r.result.name(), 0.75f*fontscale*2f).left().padBottom(2f).units(Unit.dp);
|
||||
|
||||
ItemStack[] req = r.requirements;
|
||||
for(ItemStack s : req){
|
||||
tiptable.row();
|
||||
int amount = Math.min(Inventory.getAmount(s.item), s.amount);
|
||||
tiptable.add(
|
||||
(amount >= s.amount ? "[YELLOW]" : "[RED]")
|
||||
+s.item + ": " + amount + " / " +s.amount, fontscale).left();
|
||||
}
|
||||
|
||||
tiptable.row();
|
||||
tiptable.add().size(10).units(Unit.px);
|
||||
tiptable.row();
|
||||
tiptable.add("[scarlet]Health: " + r.result.health).left();
|
||||
tiptable.row();
|
||||
tiptable.add().size(6).units(Unit.px);
|
||||
tiptable.row();
|
||||
tiptable.add("[ORANGE]" + description).left();
|
||||
tiptable.pad(Unit.dp.inPixels(10f));
|
||||
};
|
||||
|
||||
run.listen();
|
||||
|
||||
Tooltip tip = new Tooltip(tiptable, run){
|
||||
public void enter (InputEvent event, float x, float y, int pointer, Element fromActor) {
|
||||
if(tooltip != this)
|
||||
hideTooltip();
|
||||
Element actor = event.getListenerActor();
|
||||
if (fromActor != null && fromActor.isDescendantOf(actor)) return;
|
||||
setContainerPosition(actor, x, y);
|
||||
manager.enter(this);
|
||||
run.listen();
|
||||
|
||||
tooltip = this;
|
||||
|
||||
if(android){
|
||||
|
||||
Timer.schedule(new Task(){
|
||||
@Override
|
||||
public void run(){
|
||||
hide();
|
||||
}
|
||||
}, 1.5f);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tip.setInstant(true);
|
||||
|
||||
image.addListener(tip);
|
||||
}
|
||||
|
||||
//additional padding
|
||||
@@ -336,18 +286,19 @@ public class UI extends SceneModule{
|
||||
atop();
|
||||
aleft();
|
||||
|
||||
defaults().size(60).units(Unit.dp);
|
||||
defaults().size(66).units(Unit.dp);
|
||||
|
||||
new button("M", ()->{
|
||||
|
||||
//TODO menu buttons!
|
||||
new imagebutton("icon-menu", 40, ()->{
|
||||
showMenu();
|
||||
});
|
||||
|
||||
new button("P", ()->{
|
||||
|
||||
new imagebutton("icon-settings", 40, ()->{
|
||||
prefs.show();
|
||||
});
|
||||
|
||||
new button("S", ()->{
|
||||
|
||||
new imagebutton("icon-pause", 40, ()->{
|
||||
//TODO pause
|
||||
});
|
||||
|
||||
row();
|
||||
@@ -370,7 +321,7 @@ public class UI extends SceneModule{
|
||||
new table(){{
|
||||
get().background("button");
|
||||
|
||||
new label(()->"[YELLOW]Wave " + control.getWave()).scale(fontscale*2f).left();
|
||||
new label(()->"[orange]Wave " + control.getWave()).scale(fontscale*2f).left();
|
||||
|
||||
row();
|
||||
|
||||
@@ -385,9 +336,8 @@ public class UI extends SceneModule{
|
||||
}}.end();
|
||||
|
||||
|
||||
//if(Gdx.app.getType() != ApplicationType.Android){
|
||||
//+- table
|
||||
//TODO refactor to make this less messy
|
||||
//TODO refactor to make this less messy?
|
||||
new table(){{
|
||||
aleft();
|
||||
abottom();
|
||||
@@ -408,7 +358,6 @@ public class UI extends SceneModule{
|
||||
|
||||
get().setVisible(play);
|
||||
}}.end();
|
||||
//}
|
||||
|
||||
//menu table
|
||||
new table(){{
|
||||
@@ -472,7 +421,6 @@ public class UI extends SceneModule{
|
||||
}
|
||||
|
||||
new table(){{
|
||||
//atop();
|
||||
new table(){{
|
||||
get().background("button");
|
||||
|
||||
@@ -528,6 +476,55 @@ public class UI extends SceneModule{
|
||||
build.end();
|
||||
}
|
||||
|
||||
void updateRecipe(){
|
||||
Recipe recipe = player.recipe;
|
||||
desctable.clear();
|
||||
|
||||
desctable.defaults().left();
|
||||
desctable.left();
|
||||
desctable.pad(12);
|
||||
|
||||
desctable.add(recipe.result.formalName);
|
||||
desctable.row();
|
||||
desctable.addImage(Draw.region(recipe.result.name)).size(8*5).padTop(4);
|
||||
desctable.row();
|
||||
|
||||
desctable.add().pad(2);
|
||||
|
||||
Table requirements = new Table();
|
||||
|
||||
desctable.row();
|
||||
|
||||
desctable.add(requirements);
|
||||
desctable.left();
|
||||
|
||||
for(ItemStack stack : recipe.requirements){
|
||||
ItemStack fs = stack;
|
||||
requirements.addImage(Draw.region("icon-"+stack.item.name())).size(8*3);
|
||||
Label reqlabel = new Label("");
|
||||
|
||||
reqlabel.update(()->{
|
||||
int current = Inventory.getAmount(fs.item);
|
||||
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
|
||||
|
||||
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
|
||||
|
||||
reqlabel.setText(text);
|
||||
});
|
||||
|
||||
requirements.add(reqlabel);
|
||||
requirements.row();
|
||||
}
|
||||
|
||||
desctable.row();
|
||||
|
||||
if(recipe.result.description() != null){
|
||||
Label label = new Label(recipe.result.description());
|
||||
label.setWrap(true);
|
||||
desctable.add(label).width(170).padTop(4);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWeapons(){
|
||||
weapontable.clearChildren();
|
||||
|
||||
|
||||
@@ -36,10 +36,7 @@ public class Input{
|
||||
|
||||
player.rotation %= 4;
|
||||
|
||||
if(player.recipe != null && !Inventory.hasItems(player.recipe.requirements)){
|
||||
player.recipe = null;
|
||||
Cursors.restoreCursor();
|
||||
}
|
||||
//TODO restore cursor when requirements are back
|
||||
|
||||
for(int i = 0; i < 9; i ++)
|
||||
if(Inputs.keyUp(Keys.valueOf(""+(i+1))) && i < control.getWeapons().size){
|
||||
@@ -48,7 +45,8 @@ public class Input{
|
||||
}
|
||||
|
||||
if(Inputs.buttonUp(Buttons.LEFT) && player.recipe != null &&
|
||||
World.validPlace(World.tilex(), World.tiley(), player.recipe.result) && !ui.hasMouse()){
|
||||
World.validPlace(World.tilex(), World.tiley(), player.recipe.result) && !ui.hasMouse() &&
|
||||
Inventory.hasItems(player.recipe.requirements)){
|
||||
Tile tile = World.tile(World.tilex(), World.tiley());
|
||||
|
||||
if(tile == null)
|
||||
@@ -64,9 +62,8 @@ public class Input{
|
||||
for(ItemStack stack : player.recipe.requirements){
|
||||
Inventory.removeItem(stack);
|
||||
}
|
||||
|
||||
|
||||
if(!Inventory.hasItems(player.recipe.requirements)){
|
||||
player.recipe = null;
|
||||
Cursors.restoreCursor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ import io.anuke.ucore.entities.Entity;
|
||||
*/
|
||||
public class SaveIO{
|
||||
/**Save file version ID. Should be incremented every breaking release.*/
|
||||
private static final int fileVersionID = 4;
|
||||
private static final int fileVersionID = 5;
|
||||
|
||||
private static FormatProvider provider = null;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package io.anuke.mindustry.resource;
|
||||
|
||||
public enum Item{
|
||||
stone, iron, coal, steel, titanium;
|
||||
stone, iron, coal, steel, titanium, hypanium;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class Block{
|
||||
protected static TextureRegion temp = new TextureRegion();
|
||||
|
||||
public final String name;
|
||||
public String formalName;
|
||||
public boolean solid, update, rotate, breakable;
|
||||
public int health = 40;
|
||||
public String shadow = "shadow";
|
||||
@@ -38,6 +39,7 @@ public class Block{
|
||||
blocks.add(this);
|
||||
|
||||
this.name = name;
|
||||
this.formalName = name;
|
||||
this.solid = false;
|
||||
this.id = lastid++;
|
||||
}
|
||||
@@ -51,7 +53,7 @@ public class Block{
|
||||
}
|
||||
|
||||
public String description(){
|
||||
return "[no description]";
|
||||
return null;
|
||||
}
|
||||
|
||||
public String errorMessage(Tile tile){
|
||||
|
||||
@@ -95,17 +95,27 @@ public class Blocks{
|
||||
solid = true;
|
||||
update = true;
|
||||
health = 50;
|
||||
formalName = "stone wall";
|
||||
}},
|
||||
|
||||
ironwall = new Block("ironwall"){{
|
||||
solid = true;
|
||||
update = true;
|
||||
health = 80;
|
||||
formalName = "iron wall";
|
||||
}},
|
||||
|
||||
steelwall = new Block("steelwall"){{
|
||||
solid = true;
|
||||
update = true;
|
||||
health = 100;
|
||||
health = 110;
|
||||
formalName = "steel wall";
|
||||
}},
|
||||
|
||||
titaniumwall = new Block("titaniumwall"){{
|
||||
solid = true;
|
||||
update = true;
|
||||
health = 140;
|
||||
formalName = "titanium wall";
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Conveyor extends Block{
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Moves Items";
|
||||
return "Moves items.";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,6 +40,7 @@ public class ProductionBlocks{
|
||||
steelconveyor = new Conveyor("steelconveyor"){{
|
||||
update = true;
|
||||
speed = 0.04f;
|
||||
formalName = "steel conveyor";
|
||||
}},
|
||||
|
||||
router = new Block("router"){
|
||||
@@ -131,29 +132,47 @@ public class ProductionBlocks{
|
||||
}
|
||||
},
|
||||
|
||||
crucible = new Crafter("crucible"){
|
||||
{
|
||||
health = 90;
|
||||
requirements = new Item[]{Item.titanium, Item.steel};
|
||||
result = Item.hypanium;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Takes in steel + titanium, outputs hypanium.";
|
||||
}
|
||||
},
|
||||
|
||||
stonedrill = new Drill("stonedrill"){{
|
||||
resource = Blocks.stone;
|
||||
result = Item.stone;
|
||||
formalName = "stone drill";
|
||||
}},
|
||||
|
||||
irondrill = new Drill("irondrill"){{
|
||||
resource = Blocks.iron;
|
||||
result = Item.iron;
|
||||
formalName = "iron drill";
|
||||
}},
|
||||
|
||||
coaldrill = new Drill("coaldrill"){{
|
||||
resource = Blocks.coal;
|
||||
result = Item.coal;
|
||||
formalName = "coal drill";
|
||||
}},
|
||||
|
||||
titaniumdrill = new Drill("titaniumdrill"){{
|
||||
resource = Blocks.titanium;
|
||||
result = Item.titanium;
|
||||
formalName = "titanium drill";
|
||||
}},
|
||||
|
||||
omnidrill = new Drill("omnidrill"){
|
||||
{
|
||||
time = 4;
|
||||
formalName = "omnidrill";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,6 +64,6 @@ public class RepairTurret extends Turret{
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "[green]Range: " + (int)range + "\n[orange]Heals nearby tiles.";
|
||||
return "[turretinfo]Range: " + (int)range + "\n[description]Heals nearby tiles.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Turret extends Block{
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "[green]Ammo: "+(ammo==null ? "N/A" : ammo.name())+"\nRange: " + (int)range + "\nDamage: " + bullet.damage;
|
||||
return "[turretinfo]Ammo: "+(ammo==null ? "N/A" : ammo.name())+"\nRange: " + (int)range + "\nDamage: " + bullet.damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ public class WeaponBlocks{
|
||||
|
||||
turret = new Turret("turret"){
|
||||
{
|
||||
formalName = "turret";
|
||||
range = 50;
|
||||
reload = 10f;
|
||||
bullet = BulletType.stone;
|
||||
@@ -21,6 +22,7 @@ public class WeaponBlocks{
|
||||
|
||||
doubleturret = new Turret("doubleturret"){
|
||||
{
|
||||
formalName = "double turret";
|
||||
range = 40;
|
||||
reload = 13f;
|
||||
bullet = BulletType.stone;
|
||||
@@ -42,6 +44,7 @@ public class WeaponBlocks{
|
||||
|
||||
machineturret = new Turret("machineturret"){
|
||||
{
|
||||
formalName = "gattling turret";
|
||||
range = 65;
|
||||
reload = 7f;
|
||||
bullet = BulletType.iron;
|
||||
@@ -52,6 +55,7 @@ public class WeaponBlocks{
|
||||
|
||||
shotgunturret = new Turret("shotgunturret"){
|
||||
{
|
||||
formalName = "splitter turret";
|
||||
range = 50;
|
||||
reload = 30f;
|
||||
bullet = BulletType.iron;
|
||||
@@ -73,6 +77,7 @@ public class WeaponBlocks{
|
||||
|
||||
flameturret = new Turret("flameturret"){
|
||||
{
|
||||
formalName = "flamer turret";
|
||||
range = 35f;
|
||||
reload = 5f;
|
||||
bullet = BulletType.flame;
|
||||
@@ -83,6 +88,7 @@ public class WeaponBlocks{
|
||||
|
||||
sniperturret = new Turret("sniperturret"){
|
||||
{
|
||||
formalName = "railgun turret";
|
||||
range = 120;
|
||||
reload = 60f;
|
||||
bullet = BulletType.sniper;
|
||||
@@ -93,6 +99,7 @@ public class WeaponBlocks{
|
||||
|
||||
repairturret = new RepairTurret("repairturret"){
|
||||
{
|
||||
formalName = "heal turret";
|
||||
range = 30;
|
||||
reload = 40f;
|
||||
health = 60;
|
||||
@@ -101,6 +108,7 @@ public class WeaponBlocks{
|
||||
|
||||
megarepairturret = new RepairTurret("megarepairturret"){
|
||||
{
|
||||
formalName = "heal turret II";
|
||||
range = 50;
|
||||
reload = 20f;
|
||||
health = 90;
|
||||
|
||||
Reference in New Issue
Block a user