More character support, made menus collapsible
This commit is contained in:
@@ -10,7 +10,6 @@ import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.I18NBundle;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.io.BundleUtil;
|
||||
import io.anuke.mindustry.io.PlatformFunction;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
@@ -32,6 +31,7 @@ public class Mindustry extends ModuleCore {
|
||||
@Override public void openLink(String link){ }
|
||||
@Override public void addDialog(TextField field){}
|
||||
};
|
||||
public static boolean externalBundle = false;
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
@@ -46,10 +46,18 @@ public class Mindustry extends ModuleCore {
|
||||
public void loadBundle(){
|
||||
I18NBundle.setExceptionOnMissingKey(false);
|
||||
|
||||
FileHandle handle = Gdx.files.internal("bundles/bundle");
|
||||
if(externalBundle){
|
||||
FileHandle handle = Gdx.files.local("bundle");
|
||||
|
||||
Locale locale = Locale.ENGLISH;
|
||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||
}else{
|
||||
FileHandle handle = Gdx.files.internal("bundles/bundle");
|
||||
|
||||
Locale locale = Locale.getDefault();
|
||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||
}
|
||||
|
||||
Locale locale = Locale.getDefault();
|
||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||
|
||||
//always initialize blocks in this order, otherwise there are ID errors
|
||||
Block[] blockClasses = {
|
||||
@@ -67,7 +75,6 @@ public class Mindustry extends ModuleCore {
|
||||
@Override
|
||||
public void postInit(){
|
||||
Vars.control.reset();
|
||||
BundleUtil.buildBundle(Gdx.files.absolute("/home/anuke/bundle_en_US.properties"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,7 @@ import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class Vars{
|
||||
public static final boolean testAndroid = false;
|
||||
public static final boolean testAndroid = true;
|
||||
//shorthand for whether or not this is running on android
|
||||
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
|
||||
//shorthand for whether or not this is running on GWT
|
||||
|
||||
@@ -3,19 +3,12 @@ package io.anuke.mindustry.core;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.badlogic.gdx.Application.ApplicationType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Buttons;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.controllers.Controller;
|
||||
import com.badlogic.gdx.controllers.ControllerAdapter;
|
||||
import com.badlogic.gdx.controllers.Controllers;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.I18NBundle;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
@@ -30,7 +23,6 @@ import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.input.AndroidInput;
|
||||
import io.anuke.mindustry.input.DesktopInput;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.io.BundleUtil;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
@@ -84,11 +76,6 @@ public class Control extends Module{
|
||||
if(Mindustry.args.contains("-debug", false))
|
||||
Vars.debug = true;
|
||||
|
||||
FileHandle handle = Gdx.files.internal("bundles/bundle");
|
||||
|
||||
Locale locale = Locale.getDefault();
|
||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||
|
||||
Inputs.useControllers(false);
|
||||
|
||||
log("Total blocks loaded: " + Block.getAllBlocks().size);
|
||||
@@ -442,7 +429,7 @@ public class Control extends Module{
|
||||
addItem(Item.stone, 40);
|
||||
|
||||
if(debug){
|
||||
Arrays.fill(items, 2000000);
|
||||
Arrays.fill(items, 999900);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ public class Renderer extends RendererModule{
|
||||
|
||||
//draw placement box
|
||||
if((player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android)
|
||||
&& control.input.drawPlace()) || (player.placeMode.delete && Inputs.keyDown("area_delete_mode"))){
|
||||
&& control.input.drawPlace())){
|
||||
|
||||
player.placeMode.draw(control.input.getBlockX(), control.input.getBlockY(), control.input.getBlockEndX(), control.input.getBlockEndY());
|
||||
|
||||
|
||||
@@ -58,8 +58,7 @@ public class UI extends SceneModule{
|
||||
MapEditor editor;
|
||||
boolean wasPaused = false;
|
||||
|
||||
private Fragment blockfrag = new BlocksFragment(),
|
||||
menufrag = new MenuFragment(),
|
||||
private Fragment menufrag = new MenuFragment(),
|
||||
toolfrag = new ToolFragment(),
|
||||
hudfrag = new HudFragment(),
|
||||
placefrag = new PlacementFragment(),
|
||||
@@ -291,8 +290,6 @@ public class UI extends SceneModule{
|
||||
build.begin(scene);
|
||||
|
||||
weaponfrag.build();
|
||||
|
||||
blockfrag.build();
|
||||
|
||||
hudfrag.build();
|
||||
|
||||
|
||||
@@ -95,11 +95,11 @@ public class BlockRenderer{
|
||||
}
|
||||
|
||||
if(block.expanded || !expanded){
|
||||
if(block.layer != null){
|
||||
if(block.layer != null && block.isLayer(tile)){
|
||||
addRequest(tile, block.layer);
|
||||
}
|
||||
|
||||
if(block.layer2 != null){
|
||||
if(block.layer2 != null && block.isLayer2(tile)){
|
||||
addRequest(tile, block.layer2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ public class AndroidInput extends InputHandler{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(placing && pointer == 0 && !player.placeMode.pan && player.recipe != null){
|
||||
if(placing && pointer == 0 && !player.placeMode.pan && !breaking()){
|
||||
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||
}else if(pointer == 0 && !player.breakMode.pan && player.recipe == null && drawPlace()){
|
||||
}else if(pointer == 0 && !player.breakMode.pan && breaking() && drawPlace()){
|
||||
player.breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||
}
|
||||
placing = false;
|
||||
@@ -64,7 +64,7 @@ public class AndroidInput extends InputHandler{
|
||||
lmousex = screenX;
|
||||
lmousey = screenY;
|
||||
|
||||
if((!player.placeMode.pan || player.recipe == null) && pointer == 0){
|
||||
if((!player.placeMode.pan || breaking()) && pointer == 0){
|
||||
mousex = screenX;
|
||||
mousey = screenY;
|
||||
}
|
||||
@@ -184,4 +184,8 @@ public class AndroidInput extends InputHandler{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean breaking(){
|
||||
return player.recipe == null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,4 +151,9 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyDown(int keycode) {
|
||||
return super.keyDown(keycode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,8 @@ public abstract class InputHandler extends InputAdapter{
|
||||
int worldy = dy + offsety + y;
|
||||
if(!(worldx == x && worldy == y)){
|
||||
Tile toplace = world.tile(worldx, worldy);
|
||||
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
|
||||
if(toplace != null)
|
||||
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
|
||||
}
|
||||
|
||||
if(effects) Effects.effect(Fx.place, worldx * Vars.tilesize, worldy * Vars.tilesize);
|
||||
@@ -201,6 +202,8 @@ public abstract class InputHandler extends InputAdapter{
|
||||
}
|
||||
|
||||
if(effects && sound) Sounds.play("place");
|
||||
|
||||
result.placed(tile);
|
||||
}
|
||||
|
||||
public void breakBlock(int x, int y, boolean sound){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.io;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@@ -19,13 +18,11 @@ import io.anuke.ucore.scene.ui.SettingsDialog.SettingsTable.Setting;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BundleUtil {
|
||||
public class BundleGen {
|
||||
private static FileHandle file;
|
||||
|
||||
public static void buildBundle(FileHandle file){
|
||||
BundleUtil.file = file;
|
||||
BundleGen.file = file;
|
||||
|
||||
file.writeString("", false);
|
||||
write("about.text=" + join(Vars.aboutText));
|
||||
@@ -233,7 +233,7 @@ public class MapEditorDialog extends Dialog{
|
||||
|
||||
ImageButton undo = tools.addIButton("icon-undo", 16*2f, () -> view.undo()).get();
|
||||
ImageButton redo = tools.addIButton("icon-redo", 16*2f, () -> view.redo()).get();
|
||||
ImageButton grid = tools.addIButton("toggle", "icon-grid", 16*2f, () -> view.setGrid(!view.isGrid())).get();
|
||||
tools.addIButton("toggle", "icon-grid", 16*2f, () -> view.setGrid(!view.isGrid())).get();
|
||||
|
||||
undo.setDisabled(() -> !view.getStack().canUndo());
|
||||
redo.setDisabled(() -> !view.getStack().canRedo());
|
||||
|
||||
@@ -10,8 +10,10 @@ import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Recipe;
|
||||
import io.anuke.mindustry.resource.Section;
|
||||
@@ -28,11 +30,14 @@ import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Value;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
public class BlocksFragment implements Fragment{
|
||||
private Table desctable;
|
||||
private Table desctable, itemtable, blocks;
|
||||
private Stack stack = new Stack();
|
||||
private Array<String> statlist = new Array<>();
|
||||
private boolean shown = true;
|
||||
|
||||
@@ -42,15 +47,25 @@ public class BlocksFragment implements Fragment{
|
||||
abottom();
|
||||
aright();
|
||||
|
||||
visible(() -> !GameState.is(State.menu));
|
||||
visible(() -> !GameState.is(State.menu) && shown);
|
||||
|
||||
Table blocks = new table(){{
|
||||
blocks = new table(){{
|
||||
|
||||
new table("button") {{
|
||||
visible(() -> player.recipe != null);
|
||||
desctable = get();
|
||||
fillX();
|
||||
}}.end().uniformX();
|
||||
itemtable = new Table("button");
|
||||
itemtable.setVisible(() -> player.recipe == null);
|
||||
|
||||
desctable = new Table("button");
|
||||
desctable.setVisible(() -> player.recipe != null);
|
||||
desctable.update(() -> {
|
||||
if(player.recipe == null && desctable.getChildren().size != 0){
|
||||
desctable.clear();
|
||||
}
|
||||
});
|
||||
|
||||
stack.add(itemtable);
|
||||
stack.add(desctable);
|
||||
|
||||
add(stack).fillX().uniformX();
|
||||
|
||||
row();
|
||||
|
||||
@@ -83,7 +98,7 @@ public class BlocksFragment implements Fragment{
|
||||
}
|
||||
});
|
||||
button.setName("sectionbutton" + sec.name());
|
||||
add(button).growX().height(54).padTop(sec.ordinal() <= 2 ? -10 : -5);
|
||||
add(button).growX().height(54).padRight(-1).padTop(sec.ordinal() <= 2 ? -10 : -5);
|
||||
button.getImageCell().size(40).padBottom(4).padTop(2);
|
||||
group.add(button);
|
||||
|
||||
@@ -110,7 +125,7 @@ public class BlocksFragment implements Fragment{
|
||||
}
|
||||
});
|
||||
|
||||
table.add(image).size(size + 8).pad(2);
|
||||
table.add(image).size(size + 8);
|
||||
image.getImageCell().size(size);
|
||||
|
||||
image.update(() -> {
|
||||
@@ -146,35 +161,17 @@ public class BlocksFragment implements Fragment{
|
||||
visible(() -> !GameState.is(State.menu) && shown);
|
||||
|
||||
}}.end().get();
|
||||
|
||||
row();
|
||||
|
||||
ImageButton buttons[] = new ImageButton[2];
|
||||
float size = 46f;
|
||||
|
||||
float t = 0.2f;
|
||||
Interpolation ip = Interpolation.pow3Out;
|
||||
|
||||
//TODO fix glitch when resizing
|
||||
buttons[0] = new imagebutton("icon-arrow-down", 10*2, () -> {
|
||||
if(blocks.getActions().size != 0) return;
|
||||
blocks.actions(Actions.translateBy(0, -blocks.getHeight(), t, ip), Actions.call(() -> shown = false));
|
||||
buttons[0].actions(Actions.fadeOut(t));
|
||||
buttons[1].actions(Actions.fadeIn(t));
|
||||
}).padBottom(-5).visible(() -> shown).height(size).uniformX().fillX()
|
||||
.update(i -> i.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up")).get();
|
||||
|
||||
buttons[1] = new imagebutton("icon-arrow-up", 10*2, () -> {
|
||||
if(blocks.getActions().size != 0) return;
|
||||
blocks.actions(Actions.translateBy(0, blocks.getHeight(), t, ip));
|
||||
shown = true;
|
||||
buttons[0].actions(Actions.fadeIn(t));
|
||||
buttons[1].actions(Actions.fadeOut(t));
|
||||
}).touchable(() -> shown ? Touchable.disabled : Touchable.enabled).size(size).padBottom(-5).padLeft(-size).get();
|
||||
|
||||
buttons[1].getColor().a = 0f;
|
||||
}}.end();
|
||||
}
|
||||
|
||||
public void toggle(boolean show, float t, Interpolation ip){
|
||||
if(!show){
|
||||
blocks.actions(Actions.translateBy(0, -blocks.getHeight() - stack.getHeight(), t, ip), Actions.call(() -> shown = false));
|
||||
}else{
|
||||
shown = true;
|
||||
blocks.actions(Actions.translateBy(0, -blocks.getTranslation().y, t, ip));
|
||||
}
|
||||
}
|
||||
|
||||
void updateRecipe(){
|
||||
Recipe recipe = player.recipe;
|
||||
@@ -197,7 +194,7 @@ public class BlocksFragment implements Fragment{
|
||||
header.addImage(region).size(8*5).padTop(4);
|
||||
Label nameLabel = new Label(recipe.result.formalName);
|
||||
nameLabel.setWrap(true);
|
||||
header.add(nameLabel).padLeft(2).width(130f);
|
||||
header.add(nameLabel).padLeft(2).width(120f);
|
||||
|
||||
//extra info
|
||||
if(recipe.result.fullDescription != null){
|
||||
@@ -288,4 +285,40 @@ public class BlocksFragment implements Fragment{
|
||||
desctable.add(label).width(200).padTop(4).padBottom(2);
|
||||
|
||||
}
|
||||
|
||||
public void updateItems(){
|
||||
|
||||
itemtable.clear();
|
||||
itemtable.left();
|
||||
|
||||
if(control.getMode().infiniteResources){
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] items = Item.values();
|
||||
|
||||
for(int i = 0; i < control.getItems().length; i ++){
|
||||
int amount = control.getItems()[i];
|
||||
if(amount == 0) continue;
|
||||
String formatted = amount > 99999999 ? "inf" : format(amount);
|
||||
Image image = new Image(Draw.region("icon-" + items[i].name()));
|
||||
Label label = new Label(formatted);
|
||||
label.setFontScale(fontscale*1.5f);
|
||||
itemtable.add(image).size(8*3);
|
||||
itemtable.add(label).expandX().left();
|
||||
if(i % 2 == 1 && i > 0) itemtable.row();
|
||||
}
|
||||
}
|
||||
|
||||
String format(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 + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,14 @@ import static io.anuke.mindustry.Vars.*;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.GameMode;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
@@ -20,16 +22,21 @@ import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.Label;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class HudFragment implements Fragment{
|
||||
private Table itemtable, respawntable;
|
||||
private Cell<Table> itemcell;
|
||||
private ImageButton menu, flip, pause;
|
||||
private Table respawntable;
|
||||
private Table wavetable;
|
||||
private boolean shown = true;
|
||||
private BlocksFragment blockfrag = new BlocksFragment();
|
||||
|
||||
public void build(){
|
||||
|
||||
//menu at top left
|
||||
new table(){{
|
||||
atop();
|
||||
@@ -37,41 +44,50 @@ public class HudFragment implements Fragment{
|
||||
|
||||
new table(){{
|
||||
left();
|
||||
defaults().size(68).left();
|
||||
float dsize = 58;
|
||||
defaults().size(dsize).left();
|
||||
float isize = 40;
|
||||
|
||||
new imagebutton("icon-menu", isize, ()->{
|
||||
ui.showMenu();
|
||||
});
|
||||
|
||||
new imagebutton("icon-settings", isize, ()->{
|
||||
ui.showPrefs();
|
||||
});
|
||||
|
||||
new imagebutton("icon-pause", isize, ()->{
|
||||
menu = new imagebutton("icon-menu", isize, ()->{
|
||||
ui.showMenu();
|
||||
}).get();
|
||||
|
||||
flip = new imagebutton("icon-arrow-up", isize, ()->{
|
||||
if(wavetable.getActions().size != 0) return;
|
||||
|
||||
float dur = 0.3f;
|
||||
Interpolation in = Interpolation.pow3Out;
|
||||
|
||||
flip.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
|
||||
|
||||
if(shown){
|
||||
blockfrag.toggle(false, dur, in);
|
||||
wavetable.actions(Actions.translateBy(0, wavetable.getHeight() + dsize, dur, in), Actions.call(() -> shown = false));
|
||||
}else{
|
||||
shown = true;
|
||||
blockfrag.toggle(true, dur, in);
|
||||
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
|
||||
}
|
||||
|
||||
}).get();
|
||||
|
||||
pause = new imagebutton("icon-pause", isize, ()->{
|
||||
GameState.set(GameState.is(State.paused) ? State.playing : State.paused);
|
||||
}){{
|
||||
get().update(()->{
|
||||
get().getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause");
|
||||
});
|
||||
}};
|
||||
}).update(i -> i.getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause")).get();
|
||||
|
||||
}}.end();
|
||||
|
||||
|
||||
row();
|
||||
|
||||
new table(){{
|
||||
get().setTouchable(Touchable.enabled);
|
||||
touchable(Touchable.enabled);
|
||||
visible(() -> shown);
|
||||
addWaveTable();
|
||||
}}.fillX().end();
|
||||
|
||||
row();
|
||||
|
||||
itemtable = new table("button").end().top().left().fillX().size(-1).get();
|
||||
itemtable.setTouchable(Touchable.enabled);
|
||||
itemtable.setVisible(()-> !control.getMode().infiniteResources);
|
||||
itemcell = get().getCell(itemtable);
|
||||
|
||||
get().setVisible(()->!GameState.is(State.menu));
|
||||
visible(()->!GameState.is(State.menu));
|
||||
|
||||
Label fps = new Label(()->(Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") : ""));
|
||||
row();
|
||||
@@ -79,7 +95,7 @@ public class HudFragment implements Fragment{
|
||||
|
||||
}}.end();
|
||||
|
||||
//ui table
|
||||
//tutorial ui table
|
||||
new table(){{
|
||||
control.getTutorial().buildUI(this);
|
||||
|
||||
@@ -95,28 +111,11 @@ public class HudFragment implements Fragment{
|
||||
new label("[orange]< "+ Bundles.get("text.paused") + " >").scale(0.75f).pad(6);
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
//wave table...
|
||||
new table(){{
|
||||
|
||||
if(!Vars.android){
|
||||
atop();
|
||||
aright();
|
||||
}else{
|
||||
abottom();
|
||||
aleft();
|
||||
}
|
||||
|
||||
//addWaveTable();
|
||||
|
||||
visible(()->!GameState.is(State.menu));
|
||||
}}.end();
|
||||
|
||||
//respawn background table
|
||||
new table("white"){{
|
||||
respawntable = get();
|
||||
respawntable.setColor(Color.CLEAR);
|
||||
|
||||
}}.end();
|
||||
|
||||
//respawn table
|
||||
@@ -148,6 +147,8 @@ public class HudFragment implements Fragment{
|
||||
new label("[red]DEBUG MODE").scale(0.5f).left();
|
||||
}}.end();
|
||||
}
|
||||
|
||||
blockfrag.build();
|
||||
}
|
||||
|
||||
private String getEnemiesRemaining() {
|
||||
@@ -159,12 +160,12 @@ public class HudFragment implements Fragment{
|
||||
private void addWaveTable(){
|
||||
float uheight = 66f;
|
||||
|
||||
new table("button"){{
|
||||
wavetable = new table("button"){{
|
||||
aleft();
|
||||
new table(){{
|
||||
aleft();
|
||||
|
||||
new label(() -> Bundles.format("text.wave", control.getWave())).scale(fontscale*1.5f).left();
|
||||
new label(() -> Bundles.format("text.wave", control.getWave())).scale(fontscale*1.5f).left().padLeft(-6);
|
||||
|
||||
row();
|
||||
|
||||
@@ -172,15 +173,15 @@ public class HudFragment implements Fragment{
|
||||
getEnemiesRemaining() :
|
||||
(control.getTutorial().active() || Vars.control.getMode().toggleWaves) ? "$text.waiting"
|
||||
: Bundles.format("text.wave.waiting", (int) (control.getWaveCountdown() / 60f)))
|
||||
.minWidth(140).left();
|
||||
.minWidth(140).padLeft(-6).padRight(-12).left();
|
||||
|
||||
margin(12f);
|
||||
margin(10f);
|
||||
get().marginLeft(6);
|
||||
}}.left().end();
|
||||
|
||||
playButton(uheight);
|
||||
}}.height(uheight).fillX().expandX().end();
|
||||
|
||||
}}.height(uheight).fillX().expandX().end().get();
|
||||
wavetable.getParent().getParent().swapActor(wavetable.getParent(), menu.getParent());
|
||||
}
|
||||
|
||||
private void playButton(float uheight){
|
||||
@@ -196,36 +197,12 @@ public class HudFragment implements Fragment{
|
||||
l.setTouchable(!paused ? Touchable.enabled : Touchable.disabled);
|
||||
});
|
||||
}
|
||||
|
||||
public void updateItems(){
|
||||
|
||||
itemtable.clear();
|
||||
itemtable.left();
|
||||
|
||||
if(control.getMode().infiniteResources){
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] items = Item.values();
|
||||
|
||||
for(int i = 0; i < control.getItems().length; i ++){
|
||||
int amount = control.getItems()[i];
|
||||
if(amount == 0) continue;
|
||||
String formatted = Mindustry.platforms.format(amount);
|
||||
if(amount > 99999999){
|
||||
formatted = "inf";
|
||||
}
|
||||
Image image = new Image(Draw.region("icon-" + items[i].name()));
|
||||
Label label = new Label(formatted);
|
||||
label.setFontScale(fontscale*1.5f);
|
||||
itemtable.add(image).size(8*3);
|
||||
itemtable.add(label).left();
|
||||
itemtable.row();
|
||||
}
|
||||
public void updateItems(){
|
||||
blockfrag.updateItems();
|
||||
}
|
||||
|
||||
public void fadeRespawn(boolean in){
|
||||
|
||||
respawntable.addAction(Actions.color(in ? new Color(0, 0, 0, 0.3f) : Color.CLEAR, 0.3f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,105 +3,141 @@ package io.anuke.mindustry.ui.fragments;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.*;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class PlacementFragment implements Fragment{
|
||||
boolean shown = false;
|
||||
Table breaktable, next;
|
||||
|
||||
public void build(){
|
||||
if(android){
|
||||
//placement table
|
||||
|
||||
float s = 50f;
|
||||
|
||||
new table(){{
|
||||
visible(()->player.recipe != null && !GameState.is(State.menu));
|
||||
visible(() -> !GameState.is(State.menu));
|
||||
|
||||
abottom();
|
||||
aleft();
|
||||
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
new table(){{
|
||||
visible(() -> player.recipe != null);
|
||||
touchable(Touchable.enabled);
|
||||
|
||||
|
||||
aleft();
|
||||
new label("$text.placemode");
|
||||
row();
|
||||
|
||||
|
||||
new table("pane"){{
|
||||
margin(5f);
|
||||
aleft();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
defaults().size(54, 58).pad(0);
|
||||
|
||||
for(PlaceMode mode : PlaceMode.values()){
|
||||
if(!mode.shown || mode.delete) continue;
|
||||
|
||||
defaults().padBottom(-5.5f);
|
||||
|
||||
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
||||
control.getInput().resetCursor();
|
||||
player.placeMode = mode;
|
||||
}).group(group);
|
||||
}
|
||||
|
||||
row();
|
||||
|
||||
Color color = Color.GRAY;//Colors.get("accent"); //Color.valueOf("4d4d4d")
|
||||
|
||||
|
||||
defaults().size(s, s + 4).padBottom(-5.5f);
|
||||
|
||||
Color color = Color.GRAY;
|
||||
|
||||
new imagebutton("icon-cancel", 14*3, ()->{
|
||||
player.recipe = null;
|
||||
}).imageColor(color)
|
||||
.visible(()->player.recipe != null);
|
||||
|
||||
new button("", ()->{}).get().setTouchable(Touchable.disabled);;
|
||||
|
||||
.visible(()->player.recipe != null);
|
||||
|
||||
for(PlaceMode mode : PlaceMode.values()){
|
||||
if(!mode.shown || mode.delete) continue;
|
||||
|
||||
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
||||
control.getInput().resetCursor();
|
||||
player.placeMode = mode;
|
||||
}).group(group);
|
||||
}
|
||||
|
||||
new imagebutton("icon-arrow", 14*3, ()->{
|
||||
player.rotation = Mathf.mod(player.rotation + 1, 4);
|
||||
}).imageColor(color).visible(() -> player.recipe != null).update(image ->{
|
||||
image.getImage().setRotation(player.rotation*90);
|
||||
image.getImage().setOrigin(Align.center);
|
||||
});
|
||||
|
||||
}}.left().end();
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
new table(){{
|
||||
visible(()->player.recipe == null && !GameState.is(State.menu));
|
||||
abottom();
|
||||
aleft();
|
||||
|
||||
new label("$text.breakmode");
|
||||
|
||||
}}.padBottom(-5).left().end();
|
||||
}}.left().end();
|
||||
|
||||
row();
|
||||
|
||||
new table("pane"){{
|
||||
margin(5f);
|
||||
touchable(Touchable.enabled);
|
||||
aleft();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
defaults().size(54, 58).pad(0);
|
||||
|
||||
for(PlaceMode mode : PlaceMode.values()){
|
||||
if(!mode.shown || !mode.delete) continue;
|
||||
|
||||
defaults().padBottom(-5.5f);
|
||||
|
||||
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
||||
control.getInput().resetCursor();
|
||||
player.breakMode = mode;
|
||||
}){{
|
||||
group.add(get());
|
||||
}};
|
||||
}
|
||||
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
new table(){{
|
||||
abottom();
|
||||
aleft();
|
||||
|
||||
height(s+5+4);
|
||||
|
||||
next = new table("pane"){{
|
||||
margin(5f);
|
||||
|
||||
defaults().padBottom(-5.5f);
|
||||
|
||||
new imagebutton("icon-arrow-right", 10 * 3, () -> {
|
||||
float dur = 0.3f;
|
||||
Interpolation in = Interpolation.pow3Out;
|
||||
if(breaktable.getActions().size != 0) return;
|
||||
|
||||
breaktable.getParent().swapActor(breaktable, next);
|
||||
|
||||
if(shown){
|
||||
breaktable.actions(Actions.translateBy(-breaktable.getWidth() - 5, 0, dur, in), Actions.call(() -> shown = false));
|
||||
}else{
|
||||
shown = true;
|
||||
breaktable.actions(Actions.translateBy(-breaktable.getTranslation().x - 5, 0, dur, in));
|
||||
}
|
||||
}).size(s, s+4);
|
||||
|
||||
}}.end().get();
|
||||
|
||||
breaktable = new table("pane"){{
|
||||
visible(() -> shown);
|
||||
margin(5f);
|
||||
marginLeft(0f);
|
||||
touchable(Touchable.enabled);
|
||||
aleft();
|
||||
|
||||
defaults().size(s, s+4);
|
||||
|
||||
for(PlaceMode mode : PlaceMode.values()){
|
||||
if(!mode.shown || !mode.delete) continue;
|
||||
|
||||
defaults().padBottom(-5.5f);
|
||||
|
||||
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
||||
control.getInput().resetCursor();
|
||||
player.breakMode = mode;
|
||||
player.placeMode = mode;
|
||||
}).group(group);
|
||||
}
|
||||
|
||||
}}.end().get();
|
||||
|
||||
breaktable.getParent().swapActor(breaktable, next);
|
||||
|
||||
breaktable.getTranslation().set(-breaktable.getPrefWidth(), 0);
|
||||
|
||||
}}.end().get();
|
||||
|
||||
//one.getParent().swapActor(one, two);
|
||||
|
||||
}}.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class WeaponFragment implements Fragment{
|
||||
String description = weapon.description;
|
||||
|
||||
tiptable.background("button");
|
||||
tiptable.add("weapon."+weapon.name()+".name", 0.5f).left().padBottom(3f);
|
||||
tiptable.add("$weapon."+weapon.name()+".name", 0.5f).left().padBottom(3f);
|
||||
|
||||
tiptable.row();
|
||||
tiptable.row();
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Block{
|
||||
/**whether you can break this with rightclick*/
|
||||
public boolean breakable;
|
||||
/**whether this block can be drowned in*/
|
||||
public boolean liquid;
|
||||
public boolean liquid;
|
||||
/**time it takes to break*/
|
||||
public float breaktime = 18;
|
||||
/**tile entity health*/
|
||||
@@ -91,12 +91,15 @@ public class Block{
|
||||
this.id = lastid++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isLayer(Tile tile){return true;}
|
||||
public boolean isLayer2(Tile tile){return true;}
|
||||
public void drawLayer(Tile tile){}
|
||||
public void drawLayer2(Tile tile){}
|
||||
public void drawSelect(Tile tile){}
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){}
|
||||
public void postInit(){}
|
||||
public void placed(Tile tile){}
|
||||
|
||||
public void getStats(Array<String> list){
|
||||
list.add("[gray]size: " + width + "x" + height);
|
||||
@@ -124,6 +127,7 @@ public class Block{
|
||||
}
|
||||
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
if(tile.entity == null) return;
|
||||
tile.entity.addItem(item, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,11 @@ public class Conveyor extends Block{
|
||||
(Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed && acceptItem(Item.stone, tile, null) ? "" : "move"),
|
||||
tile.worldx(), tile.worldy(), rotation * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayer(Tile tile){
|
||||
return tile.<ConveyorEntity>entity().convey.size > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Tile tile){
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Junction extends Block{
|
||||
Tile to = tile.getNearby()[dir];
|
||||
|
||||
Timers.run(15, ()->{
|
||||
if(to == null || to.entity == null) return;
|
||||
if(to == null) return;
|
||||
to.block().handleItem(item, to, tile);
|
||||
});
|
||||
|
||||
|
||||
@@ -21,11 +21,13 @@ import io.anuke.ucore.util.Mathf;
|
||||
public class Teleporter extends Block implements Configurable{
|
||||
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.FOREST, Color.PURPLE, Color.GOLD, Color.PINK};
|
||||
public static final int colors = colorArray.length;
|
||||
|
||||
private static Array<Tile> removal = new Array<>();
|
||||
private static Array<Tile> returns = new Array<>();
|
||||
|
||||
private static ObjectSet<Tile>[] teleporters = new ObjectSet[colors];
|
||||
|
||||
private static byte lastColor = 0;
|
||||
|
||||
private Array<Tile> removal = new Array<>();
|
||||
private Array<Tile> returns = new Array<>();
|
||||
|
||||
static{
|
||||
for(int i = 0; i < colors; i ++){
|
||||
teleporters[i] = new ObjectSet<>();
|
||||
@@ -38,6 +40,11 @@ public class Teleporter extends Block implements Configurable{
|
||||
solid = true;
|
||||
health = 80;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placed(Tile tile){
|
||||
tile.<TeleporterEntity>entity().color = lastColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
@@ -70,12 +77,14 @@ public class Teleporter extends Block implements Configurable{
|
||||
|
||||
table.addIButton("icon-arrow-left", 10*3, ()->{
|
||||
entity.color = (byte)Mathf.mod(entity.color - 1, colors);
|
||||
lastColor = entity.color;
|
||||
});
|
||||
|
||||
table.add().size(40f);
|
||||
|
||||
table.addIButton("icon-arrow-right", 10*3, ()->{
|
||||
entity.color = (byte)Mathf.mod(entity.color + 1, colors);
|
||||
lastColor = entity.color;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,7 +109,7 @@ public class Teleporter extends Block implements Configurable{
|
||||
return new TeleporterEntity();
|
||||
}
|
||||
|
||||
static Array<Tile> findLinks(Tile tile){
|
||||
private Array<Tile> findLinks(Tile tile){
|
||||
TeleporterEntity entity = tile.entity();
|
||||
|
||||
removal.clear();
|
||||
|
||||
@@ -52,14 +52,17 @@ public class Drill extends Block{
|
||||
tryDump(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayer(Tile tile){
|
||||
return tile.floor() != resource && resource != null && !(resource.drops.equals(tile.floor().drops));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Tile tile){
|
||||
if(tile.floor() != resource && resource != null && !(resource.drops.equals(tile.floor().drops))){
|
||||
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
|
||||
Draw.rect("cross", tile.worldx(), tile.worldy());
|
||||
Draw.color();
|
||||
}
|
||||
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
|
||||
Draw.rect("cross", tile.worldx(), tile.worldy());
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -91,11 +91,7 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
LiquidPowerEntity entity = tile.entity();
|
||||
|
||||
if(liquid != generateLiquid){
|
||||
return false;
|
||||
}
|
||||
|
||||
return entity.liquidAmount + amount < liquidCapacity && (entity.liquid == liquid || entity.liquidAmount <= 0.01f);
|
||||
return liquid == generateLiquid && entity.liquidAmount + amount < liquidCapacity && (entity.liquid == liquid || entity.liquidAmount <= 0.01f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
||||
@@ -18,11 +19,16 @@ import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class NuclearReactor extends LiquidItemPowerGenerator{
|
||||
//TODO possibly proken
|
||||
public class NuclearReactor extends LiquidPowerGenerator{
|
||||
protected final int timerFuel = timers++;
|
||||
|
||||
|
||||
protected Item generateItem;
|
||||
protected int itemInput = 5;
|
||||
protected int itemCapacity = 30;
|
||||
protected Color coolColor = new Color(1, 1, 1, 0f);
|
||||
protected Color hotColor = Color.valueOf("ff9575a3");
|
||||
protected int fuelUseTime = 140; //time to consume 1 fuel
|
||||
@@ -44,6 +50,12 @@ public class NuclearReactor extends LiquidItemPowerGenerator{
|
||||
explosive = true;
|
||||
powerCapacity = 80f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[powerinfo]Input Item: " + generateItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
@@ -139,18 +151,26 @@ public class NuclearReactor extends LiquidItemPowerGenerator{
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
super.drawSelect(tile);
|
||||
|
||||
|
||||
NuclearReactorEntity entity = tile.entity();
|
||||
Vector2 offset = getPlaceOffset();
|
||||
|
||||
Vars.renderer.drawBar(Color.GREEN, tile.worldx() + offset.x, tile.worldy() + 6 +
|
||||
offset.y + height*Vars.tilesize/2f, (float)entity.getItem(generateItem) / itemCapacity);
|
||||
Draw.reset();
|
||||
|
||||
float fract = entity.heat;
|
||||
if(fract > 0)
|
||||
fract = Mathf.clamp(fract + 0.2f, 0.24f, 1f);
|
||||
|
||||
Vector2 offset = getPlaceOffset();
|
||||
|
||||
Vars.renderer.drawBar(Color.ORANGE, tile.worldx() + offset.x,
|
||||
tile.worldy() + Vars.tilesize * height/2f + 10 + offset.y, fract);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return item == generateItem && tile.entity.getItem(generateItem) < itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
|
||||
@@ -49,14 +49,17 @@ public class Pump extends LiquidBlock{
|
||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayer(Tile tile) {
|
||||
return tile.floor().liquidDrop == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Tile tile){
|
||||
if(tile.floor().liquidDrop == null){
|
||||
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
|
||||
Draw.rect("cross", tile.worldx(), tile.worldy());
|
||||
Draw.color();
|
||||
}
|
||||
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
|
||||
Draw.rect("cross", tile.worldx(), tile.worldy());
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user