Merged current master into branch (with manual changes)

This commit is contained in:
Timmeey86
2018-11-30 21:33:09 +01:00
102 changed files with 1684 additions and 1604 deletions

View File

@@ -45,7 +45,7 @@ public class Pathfinder{
}
public void update(){
if(Net.client()) return;
if(Net.client() || paths == null) return;
for(Team team : Team.all){
if(state.teams.isActive(team)){

View File

@@ -10,9 +10,9 @@ import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.Waves;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Events;
import io.anuke.ucore.util.Structs;
import io.anuke.ucore.util.GridBits;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Structs;
import java.io.DataInput;
import java.io.DataOutput;

View File

@@ -14,7 +14,7 @@ public class AmmoTypes implements ContentList{
bulletDenseBig, bulletPyratiteBig, bulletThoriumBig,
shock, bombExplosive, bombIncendiary, bombOil, shellCarbide, flamerThermite, weaponMissile, weaponMissileSwarm, bulletMech,
healBlaster, bulletGlaive,
/*flakCopper, */flakExplosive, flakPlastic, flakSurge,
flakExplosive, flakPlastic, flakSurge,
missileExplosive, missileIncindiary, missileSurge,
artilleryDense, artilleryPlastic, artilleryHoming, artilleryIncindiary, artilleryExplosive, unitArtillery,
basicFlame, lancerLaser, lightning, meltdownLaser, burstLaser,

View File

@@ -43,7 +43,6 @@ public class UnitTypes implements ContentList{
speed = 0.2f;
maxVelocity = 0.8f;
range = 50f;
healSpeed = 0.22f;
health = 60;
}};
@@ -115,6 +114,7 @@ public class UnitTypes implements ContentList{
}};
phantom = new UnitType("phantom", Phantom.class, Phantom::new){{
weapon = Weapons.healBlasterDrone2;
isFlying = true;
drag = 0.01f;
mass = 2f;
@@ -125,7 +125,6 @@ public class UnitTypes implements ContentList{
health = 220;
buildPower = 0.9f;
minePower = 1.1f;
healSpeed = 0.5f;
toMine = ObjectSet.with(Items.lead, Items.copper, Items.titanium);
}};
}

View File

@@ -8,7 +8,7 @@ import io.anuke.mindustry.type.Weapon;
public class Weapons implements ContentList{
public static Weapon blaster, blasterSmall, glaiveBlaster, droneBlaster, healBlaster, healBlasterDrone, chainBlaster, shockgun,
sapper, swarmer, bomber, bomberTrident, flakgun, flamethrower, missiles, artillery, laserBurster;
sapper, swarmer, bomber, bomberTrident, flakgun, flamethrower, missiles, artillery, laserBurster, healBlasterDrone2;
@Override
public void load(){
@@ -179,6 +179,16 @@ public class Weapons implements ContentList{
recoil = 2f;
ammo = AmmoTypes.healBlaster;
}};
healBlasterDrone2 = new Weapon("heal-blaster"){{
length = 1.5f;
reload = 20f;
width = 0.5f;
roundrobin = true;
ejectEffect = Fx.none;
recoil = 2f;
ammo = AmmoTypes.healBlaster;
}};
}
@Override

View File

@@ -135,13 +135,13 @@ public class CraftingBlocks extends BlockList implements ContentList{
melter = new PowerCrafter("melter"){{
health = 200;
outputLiquid = Liquids.lava;
outputLiquidAmount = 0.75f;
itemCapacity = 50;
outputLiquidAmount = 1f;
itemCapacity = 20;
craftTime = 10f;
hasLiquids = hasPower = true;
consumes.powerDirect(0.1f);
consumes.item(Items.stone, 2);
consumes.item(Items.stone, 1);
}};
separator = new Separator("separator"){{

View File

@@ -90,8 +90,11 @@ public class DebugBlocks extends BlockList implements ContentList{
@Override
public void update(Tile tile){
SorterEntity entity = tile.entity();
if(entity.sortItem == null) return;
entity.items.set(entity.sortItem, 1);
tryDump(tile, entity.sortItem);
entity.items.set(entity.sortItem, 0);
}
@Override
@@ -142,8 +145,8 @@ public class DebugBlocks extends BlockList implements ContentList{
if(!control.unlocks.isUnlocked(items.get(i))) continue;
final int f = i;
ImageButton button = cont.addImageButton("liquid-icon-" + items.get(i).name, "toggle", 24,
() -> Call.setLiquidSourceLiquid(null, tile, items.get(f))).size(38, 42).padBottom(-5.1f).group(group).get();
ImageButton button = cont.addImageButton("liquid-icon-" + items.get(i).name, "clear-toggle", 24,
() -> Call.setLiquidSourceLiquid(null, tile, items.get(f))).size(38).group(group).get();
button.setChecked(entity.source.id == f);
if(i % 4 == 3){

View File

@@ -19,8 +19,8 @@ public class PowerBlocks extends BlockList implements ContentList{
}};
thermalGenerator = new LiquidHeatGenerator("thermal-generator"){{
maxLiquidGenerate = 4f;
powerProduction = 8f;
maxLiquidGenerate = 2f;
powerProduction = 4f;
generateEffect = BlockFx.redgeneratespark;
size = 2;
}};

View File

@@ -53,7 +53,6 @@ public class Control extends Module{
private Throwable error;
public Control(){
saves = new Saves();
unlocks = new Unlocks();
@@ -373,7 +372,7 @@ public class Control extends Module{
}
}
if(Inputs.keyTap("screenshot")){
if(Inputs.keyTap("screenshot") && !ui.chatfrag.chatOpen()){
renderer.takeMapScreenshot();
}

View File

@@ -79,7 +79,9 @@ public class NetServer extends Module{
public NetServer(){
Events.on(WorldLoadEvent.class, event -> {
connections.clear();
if(!headless){
connections.clear();
}
});
Net.handleServer(Connect.class, (id, connect) -> {
@@ -596,14 +598,18 @@ public class NetServer extends Module{
}
void sync(){
try{
//iterate through each player
for(Player player : connections.values()){
for(int i = 0; i < playerGroup.size(); i ++){
Player player = playerGroup.all().get(i);
if(player.isLocal) continue;
NetConnection connection = player.con;
if(!connection.isConnected()){
//player disconnected, ignore them
if(!connection.isConnected() || !connections.containsKey(connection.id)){
//player disconnected, call d/c event
onDisconnect(player);
return;
}

View File

@@ -32,9 +32,22 @@ public abstract class Platform {
dialog.setFillParent(true);
dialog.content().top();
dialog.content().defaults().height(65f);
TextField[] use = {null};
dialog.content().addImageButton("icon-copy", "clear", 16*3, () -> use[0].copy())
.visible(() -> !use[0].getSelection().isEmpty()).width(65f);
dialog.content().addImageButton("icon-paste", "clear", 16*3, () ->
use[0].paste(Gdx.app.getClipboard().getContents(), false))
.visible(() -> Gdx.app.getClipboard() != null && Gdx.app.getClipboard().getContents() != null && !Gdx.app.getClipboard().getContents().isEmpty()).width(65f);
TextField to = dialog.content().addField(field.getText(), t-> {}).pad(15).width(250f).get();
to.setMaxLength(maxLength);
to.keyDown(Keys.ENTER, () -> dialog.content().find("okb").fireClick());
use[0] = to;
dialog.content().addButton("$text.ok", () -> {
field.clearText();
field.appendText(to.getText());

View File

@@ -30,8 +30,8 @@ public class World extends Module{
public final Sectors sectors = new Sectors();
public final WorldGenerator generator = new WorldGenerator();
public final BlockIndexer indexer = new BlockIndexer();
public final Pathfinder pathfinder = new Pathfinder();
public final WaveSpawner spawner = new WaveSpawner();
public final Pathfinder pathfinder = new Pathfinder();
private Map currentMap;
private Sector currentSector;

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
@@ -58,7 +59,9 @@ public class MapEditorDialog extends Dialog implements Disposable{
private ButtonGroup<ImageButton> blockgroup;
public MapEditorDialog(){
super("$text.mapeditor", "dialog");
super("", "dialog");
background("dark");
editor = new MapEditor();
view = new MapView(editor);
@@ -227,6 +230,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
});
}
@Override
protected void drawBackground(Batch batch, float parentAlpha, float x, float y){
drawDefaultBackground(batch, parentAlpha, x, y);
}
private void save(){
String name = editor.getTags().get("name", "");
@@ -352,7 +360,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
table(cont -> {
cont.left();
cont.table("button", mid -> {
cont.table(mid -> {
mid.top();
Table tools = new Table().top();
@@ -360,7 +368,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
ButtonGroup<ImageButton> group = new ButtonGroup<>();
Consumer<EditorTool> addTool = tool -> {
ImageButton button = new ImageButton("icon-" + tool.name(), "toggle");
ImageButton button = new ImageButton("icon-" + tool.name(), "clear-toggle");
button.clicked(() -> view.setTool(tool));
button.resizeImage(16 * 2f);
button.update(() -> button.setChecked(view.getTool() == tool));
@@ -368,21 +376,21 @@ public class MapEditorDialog extends Dialog implements Disposable{
if(tool == EditorTool.pencil)
button.setChecked(true);
tools.add(button).padBottom(-5.1f);
tools.add(button);
};
tools.defaults().size(size, size + 4f).padBottom(-5.1f);
tools.defaults().size(size, size);
tools.addImageButton("icon-menu-large", 16 * 2f, menu::show);
tools.addImageButton("icon-menu-large", "clear", 16 * 2f, menu::show);
ImageButton grid = tools.addImageButton("icon-grid", "toggle", 16 * 2f, () -> view.setGrid(!view.isGrid())).get();
ImageButton grid = tools.addImageButton("icon-grid", "clear-toggle", 16 * 2f, () -> view.setGrid(!view.isGrid())).get();
addTool.accept(EditorTool.zoom);
tools.row();
ImageButton undo = tools.addImageButton("icon-undo", 16 * 2f, () -> view.undo()).get();
ImageButton redo = tools.addImageButton("icon-redo", 16 * 2f, () -> view.redo()).get();
ImageButton undo = tools.addImageButton("icon-undo", "clear", 16 * 2f, () -> view.undo()).get();
ImageButton redo = tools.addImageButton("icon-redo", "clear", 16 * 2f, () -> view.redo()).get();
addTool.accept(EditorTool.pick);
@@ -404,7 +412,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
addTool.accept(EditorTool.fill);
addTool.accept(EditorTool.elevation);
ImageButton rotate = tools.addImageButton("icon-arrow-16", 16 * 2f, () -> editor.setDrawRotation((editor.getDrawRotation() + 1) % 4)).get();
ImageButton rotate = tools.addImageButton("icon-arrow-16", "clear", 16 * 2f, () -> editor.setDrawRotation((editor.getDrawRotation() + 1) % 4)).get();
rotate.getImage().update(() -> {
rotate.getImage().setRotation(editor.getDrawRotation() * 90);
rotate.getImage().setOrigin(Align.center);
@@ -412,8 +420,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
tools.row();
tools.table("button", t -> t.add("$text.editor.teams"))
.colspan(3).height(40).width(size * 3f);
tools.table("underline", t -> t.add("$text.editor.teams"))
.colspan(3).height(40).width(size * 3f).padBottom(3);
tools.row();
@@ -422,14 +430,14 @@ public class MapEditorDialog extends Dialog implements Disposable{
int i = 0;
for(Team team : Team.all){
ImageButton button = new ImageButton("white", "toggle");
button.margin(4f, 4f, 10f, 4f);
ImageButton button = new ImageButton("white", "clear-toggle-partial");
button.margin(4f);
button.getImageCell().grow();
button.getStyle().imageUpColor = team.color;
button.clicked(() -> editor.setDrawTeam(team));
button.update(() -> button.setChecked(editor.getDrawTeam() == team));
teamgroup.add(button);
tools.add(button).padBottom(-5.1f);
tools.add(button);
if(i++ % 3 == 2) tools.row();
}
@@ -438,7 +446,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
mid.row();
mid.table("button", t -> {
mid.table("underline", t -> {
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f]));
@@ -450,28 +458,27 @@ public class MapEditorDialog extends Dialog implements Disposable{
mid.row();
mid.table("button", t -> t.add("$text.editor.elevation"))
mid.table("underline", t -> t.add("$text.editor.elevation"))
.colspan(3).height(40).width(size * 3f);
mid.row();
mid.table("button", t -> {
mid.table("underline", t -> {
t.margin(0);
t.addImageButton("icon-arrow-left", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() - 1))
t.addImageButton("icon-arrow-left", "clear-partial", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() - 1))
.disabled(b -> editor.getDrawElevation() <= -1).size(size);
t.label(() -> editor.getDrawElevation() == -1 ? "$text.editor.slope" : (editor.getDrawElevation() + ""))
.size(size).get().setAlignment(Align.center, Align.center);
t.addImageButton("icon-arrow-right", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() + 1))
t.addImageButton("icon-arrow-right", "clear-partial", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() + 1))
.disabled(b -> editor.getDrawElevation() >= 63).size(size);
}).colspan(3).height(size).padTop(-5).width(size * 3f);
}).colspan(3).height(size).width(size * 3f);
}).margin(0).left().growY();
cont.table("button", t -> t.add(view).grow())
.margin(5).marginBottom(10).grow();
cont.table(t -> t.add(view).grow()).grow();
cont.table(this::addBlockSelection).right().growY();
@@ -525,7 +532,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
private void addBlockSelection(Table table){
Table content = new Table();
pane = new ScrollPane(content, "volume");
pane = new ScrollPane(content);
pane.setFadeScrollBars(false);
pane.setOverscroll(true, false);
ButtonGroup<ImageButton> group = new ButtonGroup<>();
@@ -552,7 +559,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
stack.add(new Image(region));
}
ImageButton button = new ImageButton("white", "toggle");
ImageButton button = new ImageButton("white", "clear-toggle");
button.clicked(() -> editor.setDrawBlock(block));
button.resizeImage(8 * 4f);
button.getImageCell().setActor(stack);
@@ -560,7 +567,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
button.getImage().remove();
button.update(() -> button.setChecked(editor.getDrawBlock() == block));
group.add(button);
content.add(button).pad(4f).size(53f, 58f);
content.add(button).size(60f);
if(i++ % 3 == 2){
content.row();
@@ -569,9 +576,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
group.getButtons().get(2).setChecked(true);
Table extra = new Table("button");
extra.labelWrap(() -> editor.getDrawBlock().formalName).width(220f).center();
table.add(extra).growX();
table.table("underline", extra -> extra.labelWrap(() -> editor.getDrawBlock().formalName).width(220f).center()).growX();
table.row();
table.add(pane).growY().fillX();
}

View File

@@ -4,11 +4,9 @@ import com.badlogic.gdx.utils.Scaling;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.ui.BorderImage;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.ScrollPane.ScrollPaneStyle;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Table;
@@ -69,7 +67,6 @@ public class MapLoadDialog extends FloatingDialog{
}
if(world.maps.all().size == 0){
pane.setStyle(Core.skin.get("clear", ScrollPaneStyle.class));
table.add("$text.maps.none").center();
}else{
content().add("$text.editor.loadmap");

View File

@@ -74,6 +74,11 @@ public class MapRenderer implements Disposable{
for(int y = 0; y < chunks[0].length; y++){
IndexedRenderer mesh = chunks[x][y];
if(mesh == null){
chunks[x][y] = new IndexedRenderer(chunksize * chunksize * 2);
mesh = chunks[x][y];
}
mesh.getTransformMatrix().setToTranslation(tx, ty, 0).scl(tw / (width * tilesize),
th / (height * tilesize), 1f);
mesh.setProjectionMatrix(Core.batch.getProjectionMatrix());

View File

@@ -270,8 +270,8 @@ public class MapView extends Element implements GestureListener{
Graphics.beginClip(x, y, width, height);
Draw.color(Color.LIGHT_GRAY);
Lines.stroke(-2f);
Draw.color(Palette.remove);
Lines.stroke(2f);
Lines.rect(centerx - sclwidth / 2 - 1, centery - sclheight / 2 - 1, sclwidth + 2, sclheight + 2);
editor.renderer().draw(centerx - sclwidth / 2, centery - sclheight / 2, sclwidth, sclheight);
Draw.reset();

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.entities.traits;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Queue;
import io.anuke.mindustry.Vars;
@@ -229,7 +230,7 @@ public interface BuilderTrait extends Entity{
}
if(!current.initialized){
Events.fire(new BuildSelectEvent(tile, unit.getTeam(), this, current.breaking));
Gdx.app.postRunnable(() -> Events.fire(new BuildSelectEvent(tile, unit.getTeam(), this, current.breaking)));
current.initialized = true;
}
}

View File

@@ -97,7 +97,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
}
public boolean isCommanded(){
return !isWave && world.indexer.getAllied(team, BlockFlag.comandCenter).size != 0;
return !isWave && world.indexer.getAllied(team, BlockFlag.comandCenter).size != 0 && world.indexer.getAllied(team, BlockFlag.comandCenter).first().entity instanceof CommandCenterEntity;
}
public UnitCommand getCommand(){

View File

@@ -41,7 +41,7 @@ public class UnitType extends UnlockableContent{
public float carryWeight = 1f;
public int itemCapacity = 30;
public ObjectSet<Item> toMine = ObjectSet.with(Items.lead, Items.copper);
public float buildPower = 0.3f, minePower = 0.7f, healSpeed = 2f;
public float buildPower = 0.3f, minePower = 0.7f;
public Weapon weapon = Weapons.blaster;
public float weaponOffsetX, weaponOffsetY;
public Color trailColor = Color.valueOf("ffa665");

View File

@@ -1,8 +1,6 @@
package io.anuke.mindustry.game;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.game.EventType.UnlockEvent;
import io.anuke.mindustry.type.ContentType;
@@ -67,27 +65,8 @@ public class Unlocks{
save();
}
/**Loads 'legacy' unlocks. Will be removed in final release.*/
public void tryLoadLegacy(){
try{
ObjectMap<String, ObjectMap<ContentType, Array<String>>> sets = Settings.getObject("content-sets", ObjectMap.class, ObjectMap::new);
for(Entry<ContentType, Array<String>> entry : sets.get("root").entries()){
unlocked.put(entry.key, new ObjectSet<>());
unlocked.get(entry.key).addAll(entry.value);
}
}catch(Throwable t){
t.printStackTrace();
}
Settings.prefs().remove("content-sets");
Settings.save();
}
public void load(){
unlocked = Settings.getObject("unlockset", ObjectMap.class, ObjectMap::new);
if(Settings.has("content-sets")){
tryLoadLegacy();
}
}
public void save(){

View File

@@ -17,6 +17,8 @@ public class Version{
public static int number;
/**Build number, e.g. '43'. set to '-1' for custom builds.*/
public static int build = 0;
/**Revision number. Used for hotfixes. Does not affect server compatibility.*/
public static int revision = 0;
public static void init(){
try{
@@ -28,7 +30,18 @@ public class Version{
type = map.get("type");
number = Integer.parseInt(map.get("number"));
modifier = map.get("modifier");
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
if(map.get("build").contains(".")){
String[] split = map.get("build").split("\\.");
try{
build = Integer.parseInt(split[0]);
revision = Integer.parseInt(split[1]);
}catch(Throwable e){
e.printStackTrace();
build = -1;
}
}else{
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
}
}catch(IOException e){
throw new RuntimeException(e);
}

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.graphics;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.blocks.Blocks;
@@ -12,16 +13,21 @@ import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockBar;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
import static io.anuke.mindustry.Vars.*;
public class OverlayRenderer{
private static final float indicatorLength = 14f;
private static final Rectangle rect = new Rectangle();
private float buildFadeTime;
public void drawBottom(){
@@ -45,6 +51,21 @@ public class OverlayRenderer{
public void drawTop(){
for(Player player : playerGroup.all()){
if(Settings.getBool("indicators") && player != players[0] && player.getTeam() == players[0].getTeam()){
if(!rect.setSize(Core.camera.viewportWidth * Core.camera.zoom * 0.9f, Core.camera.viewportHeight * Core.camera.zoom * 0.9f)
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
Tmp.v1.set(player.x, player.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
Draw.color(player.getTeam().color);
Lines.stroke(2f);
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 4f);
Draw.reset();
}
}
}
for(Player player : players){
if(player.isDead()) continue; //dead players don't draw

View File

@@ -45,6 +45,7 @@ public class MobileInput extends InputHandler implements GestureListener{
//gesture data
private Vector2 vector = new Vector2();
private boolean canPan;
private boolean zoomed = false;
/** Set of completed guides. */
private ObjectSet<String> guides = new ObjectSet<>();
@@ -241,8 +242,10 @@ public class MobileInput extends InputHandler implements GestureListener{
if(tile != null){
if(!request.remove){
rotation = request.rotation;
Recipe before = recipe;
recipe = request.recipe;
tryPlaceBlock(tile.x, tile.y);
recipe = before;
}else{
tryBreakBlock(tile.x, tile.y);
}
@@ -650,7 +653,7 @@ public class MobileInput extends InputHandler implements GestureListener{
@Override
public boolean pan(float x, float y, float deltaX, float deltaY){
if(ui.hasMouse()) return false;
if(!canPan) return false;
//can't pan in line mode with one finger or while dropping items!
if((lineMode && !Gdx.input.isTouched(1)) || droppingItem){
@@ -704,6 +707,7 @@ public class MobileInput extends InputHandler implements GestureListener{
@Override
public boolean touchDown(float x, float y, int pointer, int button){
canPan = !ui.hasMouse();
return false;
}

View File

@@ -356,13 +356,12 @@ public class Net{
Gdx.net.sendHttpRequest(req, new HttpResponseListener(){
@Override
public void handleHttpResponse(HttpResponse httpResponse){
String result = httpResponse.getResultAsString();
Gdx.app.postRunnable(() -> listener.accept(result));
listener.accept(httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t){
Gdx.app.postRunnable(() -> failure.accept(t));
failure.accept(t);
}
@Override

View File

@@ -298,7 +298,7 @@ public class NetworkIO{
int maxlen = 32;
String host = (headless ? "Server" : players[0].name);
String map = world.getMap().name;
String map = world.getMap() == null ? "None" : world.getMap().name;
host = host.substring(0, Math.min(host.length(), maxlen));
map = map.substring(0, Math.min(map.length(), maxlen));

View File

@@ -22,7 +22,7 @@ public class MenuButton extends TextButton{
table(t -> {
t.addImage(icon).size(14 * 3);
t.update(() -> t.setBackground(getClickListener().isOver() || getClickListener().isVisualPressed() ? "button-over" : "button"));
t.update(() -> t.setBackground(getClickListener().isVisualPressed() ? "button-down" : getClickListener().isOver() ? "button-over" : "button"));
}).size(s - 5, s);

View File

@@ -16,10 +16,9 @@ import static io.anuke.mindustry.Vars.*;
public class Minimap extends Table{
public Minimap(){
super("button");
super("pane");
margin(5);
marginBottom(10);
TextureRegion r = new TextureRegion();

View File

@@ -42,14 +42,14 @@ public class AboutDialog extends FloatingDialog{
float w = UIUtils.portrait() ? 330f : 600f;
Table in = new Table();
ScrollPane pane = new ScrollPane(in, "clear");
ScrollPane pane = new ScrollPane(in);
for(LinkEntry link : Links.getLinks()){
if((ios || OS.isMac) && bannedItems.contains(link.name)){ //because Apple doesn't like me mentioning things
continue;
}
Table table = new Table("button");
Table table = new Table("underline-2");
table.margin(0);
table.table(img -> {
img.addImage("white").height(h - 5).width(40f).color(link.color);
@@ -58,7 +58,7 @@ public class AboutDialog extends FloatingDialog{
}).expandY();
table.table(i -> {
i.background("button");
i.background("button-edge-3");
i.addImage("icon-" + link.name).size(14 * 3f);
}).size(h - 5, h);
@@ -108,7 +108,7 @@ public class AboutDialog extends FloatingDialog{
dialog.content().row();
dialog.content().add("$text.contributors");
dialog.content().row();
dialog.content().pane("clear", new Table(){{
dialog.content().pane(new Table(){{
int i = 0;
left();
for(Contributor c : contributors){

View File

@@ -24,7 +24,7 @@ public class AdminsDialog extends FloatingDialog{
Table table = new Table();
ScrollPane pane = new ScrollPane(table, "clear");
ScrollPane pane = new ScrollPane(table);
pane.setFadeScrollBars(false);
if(netServer.admins.getAdmins().size == 0){
@@ -41,17 +41,10 @@ public class AdminsDialog extends FloatingDialog{
ui.showConfirm("$text.confirm", "$text.confirmunadmin", () -> {
netServer.admins.unAdminPlayer(info.id);
playerGroup.forEach(player -> {
if(player.uuid.equals(info.id)){
if(player != null && player.uuid != null && player.uuid.equals(info.id)){
player.isAdmin = false;
}
});
/*
for(Player player : playerGroup.all()){
if(player.con != null){
player.isAdmin = false;
break;
}
}*/
setup();
});
}).size(h).pad(-14f);

View File

@@ -25,7 +25,7 @@ public class BansDialog extends FloatingDialog{
Table table = new Table();
ScrollPane pane = new ScrollPane(table, "clear");
ScrollPane pane = new ScrollPane(table);
pane.setFadeScrollBars(false);
if(netServer.admins.getBanned().size == 0){

View File

@@ -38,7 +38,7 @@ public class ChangelogDialog extends FloatingDialog{
void setup(){
Table table = new Table();
ScrollPane pane = new ScrollPane(table, "clear");
ScrollPane pane = new ScrollPane(table);
content().clear();
content().add(pane).grow();
@@ -60,7 +60,7 @@ public class ChangelogDialog extends FloatingDialog{
desc = desc.replace("Android", "Mobile");
Table in = new Table("clear");
Table in = new Table("underline");
in.top().left().margin(10);
in.add("[accent]" + info.name + "[LIGHT_GRAY] | " + info.date);

View File

@@ -25,10 +25,10 @@ public class ColorPickDialog extends Dialog{
for(int i = 0; i < playerColors.length; i++){
Color color = playerColors[i];
ImageButton button = table.addImageButton("white", "toggle", 34, () -> {
ImageButton button = table.addImageButton("white", "clear-toggle", 34, () -> {
cons.accept(color);
hide();
}).size(44, 48).pad(0).padBottom(-5.1f).get();
}).size(48).get();
button.setChecked(players[0].color.equals(color));
button.getStyle().imageUpColor = color;

View File

@@ -20,7 +20,7 @@ public class ContentInfoDialog extends FloatingDialog{
content.displayInfo(table);
ScrollPane pane = new ScrollPane(table, "clear-black");
ScrollPane pane = new ScrollPane(table);
content().add(pane);
show();

View File

@@ -23,7 +23,7 @@ import static io.anuke.mindustry.Vars.*;
public class CustomGameDialog extends FloatingDialog{
public CustomGameDialog(){
super("$text.level.select");
super("$text.customgame");
addCloseButton();
shown(this::setup);
@@ -35,7 +35,7 @@ public class CustomGameDialog extends FloatingDialog{
Table maps = new Table();
maps.marginRight(14);
ScrollPane pane = new ScrollPane(maps, "clear-black");
ScrollPane pane = new ScrollPane(maps);
pane.setFadeScrollBars(false);
int maxwidth = (Gdx.graphics.getHeight() > Gdx.graphics.getHeight() ? 2 : 4);
@@ -52,7 +52,7 @@ public class CustomGameDialog extends FloatingDialog{
if(mode.hidden) continue;
modes.addButton("$mode." + mode.name() + ".name", "toggle", () -> state.mode = mode)
.update(b -> b.setChecked(state.mode == mode)).group(group).size(140f, 54f).padBottom(-5);
.update(b -> b.setChecked(state.mode == mode)).group(group).size(140f, 54f);
if(i++ % 2 == 1) modes.row();
}
selmode.add(modes);
@@ -139,7 +139,7 @@ public class CustomGameDialog extends FloatingDialog{
d.setFillParent(false);
Table table = new Table();
table.defaults().pad(1f);
ScrollPane pane = new ScrollPane(table, "clear");
ScrollPane pane = new ScrollPane(table);
pane.setFadeScrollBars(false);
table.row();
for(GameMode mode : GameMode.values()){

View File

@@ -34,13 +34,13 @@ public class HostDialog extends FloatingDialog{
ui.listfrag.rebuild();
}).grow().pad(8).get().setMaxLength(40);
ImageButton button = t.addImageButton("white", 40, () -> {
ImageButton button = t.addImageButton("white", "clear-full", 40, () -> {
new ColorPickDialog().show(color -> {
player.color.set(color);
Settings.putInt("color-0", Color.rgba8888(color));
Settings.save();
});
}).size(50f, 54f).get();
}).size(54f).get();
button.update(() -> button.getStyle().imageUpColor = player.color);
}).width(w).height(70f).pad(4).colspan(3);

View File

@@ -100,7 +100,7 @@ public class JoinDialog extends FloatingDialog{
if(!buttons[0].childrenPressed()){
connect(server.ip, server.port);
}
}).width(targetWidth()).height(150f).pad(4f).get();
}).width(targetWidth()).height(155f).pad(4f).get();
button.getLabel().setWrap(true);
@@ -156,10 +156,10 @@ public class JoinDialog extends FloatingDialog{
versionString = Bundles.get("text.server.outdated");
}else if(host.version < Version.build && Version.build != -1){
versionString = Bundles.get("text.server.outdated") + "\n" +
Bundles.format("text.server.version", host.version);
Bundles.format("text.server.version", host.version, "");
}else if(host.version > Version.build && Version.build != -1){
versionString = Bundles.get("text.server.outdated.client") + "\n" +
Bundles.format("text.server.version", host.version);
Bundles.format("text.server.version", host.version, "");
}else{
versionString = Bundles.format("text.server.version", host.version, host.versionType);
}
@@ -194,7 +194,7 @@ public class JoinDialog extends FloatingDialog{
hosts.row();
hosts.add(local).width(w);
ScrollPane pane = new ScrollPane(hosts, "clear");
ScrollPane pane = new ScrollPane(hosts);
pane.setFadeScrollBars(false);
pane.setScrollingDisabled(true, false);
@@ -210,19 +210,19 @@ public class JoinDialog extends FloatingDialog{
Settings.save();
}).grow().pad(8).get().setMaxLength(maxNameLength);
ImageButton button = t.addImageButton("white", 40, () -> {
ImageButton button = t.addImageButton("white", "clear-full", 40, () -> {
new ColorPickDialog().show(color -> {
player.color.set(color);
Settings.putInt("color-0", Color.rgba8888(color));
Settings.save();
});
}).size(50f, 54f).get();
}).size(54f).get();
button.update(() -> button.getStyle().imageUpColor = player.color);
}).width(w).height(70f).pad(4);
content().row();
content().add(pane).width(w + 38).pad(0);
content().row();
content().addCenteredImageTextButton("$text.server.add", "icon-add", "clear", 14 * 3, () -> {
content().addCenteredImageTextButton("$text.server.add", "icon-add", 14 * 3, () -> {
renaming = null;
add.show();
}).marginLeft(6).width(w).height(80f).update(button -> {
@@ -258,7 +258,7 @@ public class JoinDialog extends FloatingDialog{
local.background("button");
local.add("$text.hosts.none").pad(10f);
local.add().growX();
local.addImageButton("icon-loading", 16 * 2f, this::refreshLocal).pad(-10f).padLeft(0).padTop(-6).size(70f, 74f);
local.addImageButton("icon-loading", 16 * 2f, this::refreshLocal).pad(-12f).padLeft(0).size(70f);
}else{
local.background((Drawable) null);
}

View File

@@ -24,7 +24,7 @@ public class LanguageDialog extends FloatingDialog{
private void setup(){
Table langs = new Table();
langs.marginRight(24f).marginLeft(24f);
ScrollPane pane = new ScrollPane(langs, "clear");
ScrollPane pane = new ScrollPane(langs);
pane.setFadeScrollBars(false);
ButtonGroup<TextButton> group = new ButtonGroup<>();
@@ -38,7 +38,7 @@ public class LanguageDialog extends FloatingDialog{
Log.info("Setting locale: {0}", loc.toString());
ui.showInfo("$text.language.restart");
});
langs.add(button).group(group).update(t -> t.setChecked(loc.equals(getLocale()))).size(400f, 50f).row();
langs.add(button).group(group).update(t -> t.setChecked(loc.equals(getLocale()))).size(400f, 50f).pad(2).row();
}
content().add(pane);

View File

@@ -45,7 +45,7 @@ public class LoadDialog extends FloatingDialog{
content().clear();
slots = new Table();
pane = new ScrollPane(slots, "clear-black");
pane = new ScrollPane(slots);
pane.setFadeScrollBars(false);
pane.setScrollingDisabled(true, false);
@@ -146,7 +146,7 @@ public class LoadDialog extends FloatingDialog{
if(!valids){
slots.row();
slots.addButton("$text.save.none", "clear", () -> {
slots.addButton("$text.save.none", () -> {
}).disabled(true).fillX().margin(20f).minWidth(340f).height(80f).pad(4f);
}
@@ -154,7 +154,7 @@ public class LoadDialog extends FloatingDialog{
if(ios) return;
slots.addImageTextButton("$text.save.import", "icon-add", "clear", 14 * 3, () -> {
slots.addImageTextButton("$text.save.import", "icon-add", 14 * 3, () -> {
Platform.instance.showFileChooser(Bundles.get("text.save.import"), "Mindustry Save", file -> {
if(SaveIO.isSaveValid(file)){
try{

View File

@@ -4,8 +4,8 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Scaling;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.io.MapIO;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.maps.MapMeta;
import io.anuke.mindustry.maps.MapTileData;
import io.anuke.mindustry.ui.BorderImage;
@@ -73,7 +73,7 @@ public class MapsDialog extends FloatingDialog{
Table maps = new Table();
maps.marginRight(24);
ScrollPane pane = new ScrollPane(maps, "clear-black");
ScrollPane pane = new ScrollPane(maps);
pane.setFadeScrollBars(false);
int maxwidth = 4;
@@ -88,7 +88,7 @@ public class MapsDialog extends FloatingDialog{
TextButton button = maps.addButton("", "clear", () -> showMapInfo(map)).width(mapsize).pad(8).get();
button.clearChildren();
button.margin(6);
button.margin(9);
button.add(map.meta.tags.get("name", map.name)).growX().center().get().setEllipsis(true);
button.row();
button.addImage("white").growX().pad(4).color(Color.GRAY);
@@ -116,12 +116,12 @@ public class MapsDialog extends FloatingDialog{
table.stack(new Image(map.texture).setScaling(Scaling.fit), new BorderImage(map.texture).setScaling(Scaling.fit)).size(mapsize);
table.table("clear", desc -> {
table.table("flat", desc -> {
desc.top();
Table t = new Table();
t.margin(6);
ScrollPane pane = new ScrollPane(t, "clear-black");
ScrollPane pane = new ScrollPane(t);
desc.add(pane).grow();
t.top();
@@ -146,7 +146,7 @@ public class MapsDialog extends FloatingDialog{
table.row();
table.addImageTextButton("$text.editor.openin", "icon-load-map", "clear", 16 * 2, () -> {
table.addImageTextButton("$text.editor.openin", "icon-load-map", 16 * 2, () -> {
try{
Vars.ui.editor.beginEditMap(map.stream.get());
dialog.hide();
@@ -155,15 +155,15 @@ public class MapsDialog extends FloatingDialog{
e.printStackTrace();
ui.showError("$text.error.mapnotfound");
}
}).fillX().height(50f).marginLeft(6);
}).fillX().height(54f).marginLeft(10);
table.addImageTextButton("$text.delete", "icon-trash-16", "clear", 16 * 2, () -> {
table.addImageTextButton("$text.delete", "icon-trash-16", 16 * 2, () -> {
ui.showConfirm("$text.confirm", Bundles.format("text.map.delete", map.name), () -> {
world.maps.removeMap(map);
dialog.hide();
setup();
});
}).fillX().height(50f).marginLeft(6).disabled(!map.custom).touchable(map.custom ? Touchable.enabled : Touchable.disabled);
}).fillX().height(54f).marginLeft(10).disabled(!map.custom).touchable(map.custom ? Touchable.enabled : Touchable.disabled);
dialog.show();
}

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Input.Keys;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.net.Net;
import io.anuke.ucore.scene.style.Drawable;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles;
@@ -29,13 +30,9 @@ public class PausedDialog extends FloatingDialog{
void rebuild(){
missionTable.clear();
if(world.getSector() != null && !world.getSector().complete){
missionTable.add("[LIGHT_GRAY]" + Bundles.format("text.mission", ""));
missionTable.row();
missionTable.table(t -> {
world.getSector().currentMission().display(t);
});
missionTable.row();
missionTable.background((Drawable) null);
if(world.getSector() != null){
missionTable.background("underline");
missionTable.add(Bundles.format("text.sector", world.getSector().x + ", " + world.getSector().y));
}
}
@@ -47,31 +44,26 @@ public class PausedDialog extends FloatingDialog{
}
});
content().table(t -> missionTable = t).colspan(mobile ? 3 : 1);
content().table(t -> missionTable = t).colspan(mobile ? 3 : 2);
content().row();
if(!mobile){
content().defaults().width(220).height(50);
float dw = 210f;
content().defaults().width(dw).height(50).pad(5f);
content().addButton("$text.back", () -> {
hide();
});
content().addButton("$text.back", this::hide).colspan(2).width(dw*2 + 20f);
content().row();
content().addButton("$text.unlocks", ui.unlocks::show);
content().row();
content().addButton("$text.settings", ui.settings::show);
content().row();
content().addButton("$text.savegame", save::show).disabled(s -> world.getSector() != null);
content().row();
content().addButton("$text.loadgame", load::show).disabled(b -> Net.active());
content().row();
content().addButton("$text.hostserver", ui.host::show).disabled(b -> Net.active());
content().addButton("$text.hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw*2 + 20f);
content().row();
@@ -81,7 +73,7 @@ public class PausedDialog extends FloatingDialog{
runExitSave();
hide();
});
});
}).colspan(2).width(dw + 10f);
}else{
content().defaults().size(120f).pad(5);

View File

@@ -22,7 +22,7 @@ public class SaveDialog extends LoadDialog{
public void addSetup(){
slots.row();
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14 * 3, () ->
slots.addImageTextButton("$text.save.new", "icon-add",14 * 3, () ->
ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {
ui.loadGraphics("$text.saving", () -> {
control.saves.addSave(text);

View File

@@ -95,7 +95,7 @@ public class SettingsMenuDialog extends SettingsDialog{
prefs.clearChildren();
prefs.add(menu);
ScrollPane pane = new ScrollPane(prefs, "clear");
ScrollPane pane = new ScrollPane(prefs);
pane.addCaptureListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button){
@@ -148,21 +148,21 @@ public class SettingsMenuDialog extends SettingsDialog{
dialog.setFillParent(false);
dialog.content().defaults().size(230f, 60f).pad(3);
dialog.addCloseButton();
dialog.content().addButton("$text.settings.clearsectors", "clear", () -> {
dialog.content().addButton("$text.settings.clearsectors", () -> {
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
world.sectors.clear();
dialog.hide();
});
});
dialog.content().row();
dialog.content().addButton("$text.settings.clearunlocks", "clear", () -> {
dialog.content().addButton("$text.settings.clearunlocks", () -> {
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
control.unlocks.reset();
dialog.hide();
});
});
dialog.content().row();
dialog.content().addButton("$text.settings.clearall", "clear", () -> {
dialog.content().addButton("$text.settings.clearall", () -> {
ui.showConfirm("$text.confirm", "$text.settings.clearall.confirm", () -> {
Map<String, Object> map = new HashMap<>();
for(String value : Settings.prefs().get().keySet()){
@@ -208,6 +208,7 @@ public class SettingsMenuDialog extends SettingsDialog{
}
graphics.checkPref("fps", false);
graphics.checkPref("indicators", true);
graphics.checkPref("lasers", true);
graphics.checkPref("minimap", !mobile); //minimap is disabled by default on mobile devices
}

View File

@@ -32,7 +32,7 @@ public class UnlocksDialog extends FloatingDialog{
Table table = new Table();
table.margin(20);
ScrollPane pane = new ScrollPane(table, "clear-black");
ScrollPane pane = new ScrollPane(table);
Array<Content>[] allContent = content.getContentMap();
@@ -65,9 +65,8 @@ public class UnlocksDialog extends FloatingDialog{
if(control.unlocks.isUnlocked(unlock)){
image.clicked(() -> Vars.ui.content.show(unlock));
image.addListener(new Tooltip<>(new Table("clear"){{
image.addListener(new Tooltip<>(new Table("button"){{
add(unlock.localizedName());
margin(4);
}}));
}

View File

@@ -11,6 +11,7 @@ import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.EventType.StateChangeEvent;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Packets.AdminAction;
import io.anuke.mindustry.type.Recipe;
@@ -23,9 +24,13 @@ import io.anuke.ucore.scene.Element;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.*;
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.TextButton;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Mathf;
@@ -59,10 +64,10 @@ public class HudFragment extends Fragment{
select.left();
select.defaults().size(dsize).left();
menu = select.addImageButton("icon-menu", isize, ui.paused::show).get();
flip = select.addImageButton("icon-arrow-up", isize, this::toggleMenus).get();
menu = select.addImageButton("icon-menu", "clear", isize, ui.paused::show).get();
flip = select.addImageButton("icon-arrow-up", "clear", isize, this::toggleMenus).get();
select.addImageButton("icon-pause", isize, () -> {
select.addImageButton("icon-pause", "clear", isize, () -> {
if(Net.active()){
ui.listfrag.toggle();
}else{
@@ -77,7 +82,7 @@ public class HudFragment extends Fragment{
}
}).get();
select.addImageButton("icon-settings", isize, () -> {
select.addImageButton("icon-settings", "clear", isize, () -> {
if(Net.active() && mobile){
if(ui.chatfrag.chatOpen()){
ui.chatfrag.hide();
@@ -94,9 +99,13 @@ public class HudFragment extends Fragment{
i.getStyle().imageUp = Core.skin.getDrawable("icon-unlocks");
}
}).get();
select.addImage("blank").color(Palette.accent).width(6f).fillY();
});
cont.row();
cont.addImage("blank").height(6f).color(Palette.accent).fillX();
cont.row();
}
cont.update(() -> {
@@ -106,7 +115,7 @@ public class HudFragment extends Fragment{
});
Stack stack = new Stack();
TextButton waves = new TextButton("");
TextButton waves = new TextButton("", "wave");
Table btable = new Table().margin(0);
stack.add(waves);
@@ -116,7 +125,7 @@ public class HudFragment extends Fragment{
addWaveTable(waves);
addPlayButton(btable);
cont.add(stack).width(dsize * 4);
cont.add(stack).width(dsize * 4 + 6f);
cont.row();
@@ -145,12 +154,12 @@ public class HudFragment extends Fragment{
//paused table
parent.fill(t -> {
t.top().visible(() -> state.is(State.paused) && !Net.active());
t.table("clear", top -> top.add("$text.paused").pad(6).get().setFontScale(1.5f));
t.table("button", top -> top.add("$text.paused").pad(6f));
});
parent.fill(t -> {
t.visible(() -> netServer.isWaitingForPlayers() && !state.is(State.menu));
t.table("clear", c -> c.margin(10).add("$text.waiting.players"));
t.table("button", c -> c.add("$text.waiting.players"));
});
//'core is under attack' table
@@ -188,7 +197,7 @@ public class HudFragment extends Fragment{
return coreAttackOpacity > 0;
});
t.table("clear", top -> top.add("$text.coreattack").pad(6)
t.table("button", top -> top.add("$text.coreattack").pad(2)
.update(label -> label.setColor(Hue.mix(Color.ORANGE, Color.SCARLET, Mathf.absin(Timers.time(), 2f, 1f)))));
});
@@ -342,7 +351,7 @@ public class HudFragment extends Fragment{
if(shown){
shown = false;
blockfrag.toggle(dur, in);
wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + dsize) - wavetable.getTranslation().y, dur, in));
wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + Unit.dp.scl(dsize) + Unit.dp.scl(6)) - wavetable.getTranslation().y, dur, in));
infolabel.actions(Actions.translateBy(0, (wavetable.getHeight()) - wavetable.getTranslation().y, dur, in));
}else{
shown = true;
@@ -361,8 +370,6 @@ public class HudFragment extends Fragment{
table.clearChildren();
table.setTouchable(Touchable.enabled);
table.background("button");
table.labelWrap(() ->
world.getSector() == null ?
(state.enemies() > 0 && state.mode.disableWaveTimer ?
@@ -386,7 +393,7 @@ public class HudFragment extends Fragment{
}
private void addPlayButton(Table table){
table.right().addImageButton("icon-play", 30f, () -> {
table.right().addImageButton("icon-play", "right", 30f, () -> {
if(Net.client() && players[0].isAdmin){
Call.onAdminRequest(players[0], AdminAction.wave);
}else{

View File

@@ -43,7 +43,8 @@ public class MenuFragment extends Fragment{
}
//version info
parent.fill(c -> c.bottom().left().add(Strings.formatArgs("Mindustry v{0} {1}-{2} {3}", Version.number, Version.modifier, Version.type, (Version.build == -1 ? "custom build" : "build " + Version.build)))
parent.fill(c -> c.bottom().left().add(Strings.formatArgs("Mindustry v{0} {1}-{2} {3}{4}", Version.number, Version.modifier, Version.type,
(Version.build == -1 ? "custom build" : "build " + Version.build), Version.revision == 0 ? "" : "." + Version.revision))
.visible(() -> state.is(State.menu)));
}

View File

@@ -106,7 +106,7 @@ public class PlacementFragment extends Fragment{
};
//top table with hover info
frame.table("clear", top -> {
frame.table("button-edge-2", top -> {
topTable = top;
top.add(new Table()).growX().update(topTable -> {
if((tileDisplayBlock() == null && lastDisplay == getSelected()) ||
@@ -160,16 +160,16 @@ public class PlacementFragment extends Fragment{
topTable.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
}
});
top.row();
top.addImage("blank").growX().color(Palette.accent).height(3f);
}).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled);
frame.row();
frame.table("clear", blocksSelect -> {
frame.addImage("blank").color(Palette.accent).colspan(3).height(3*2).growX();
frame.row();
frame.table("pane-2", blocksSelect -> {
blocksSelect.margin(4).marginTop(0);
blocksSelect.table(blocks -> blockTable = blocks).grow();
blocksSelect.row();
blocksSelect.table(input::buildUI).growX();
}).fillY().bottom().touchable(Touchable.enabled);
frame.addImage("blank").width(3f).fillY().color(Palette.accent);
frame.table(categories -> {
categories.defaults().size(50f);

View File

@@ -45,13 +45,13 @@ public class PlayerListFragment extends Fragment{
}
});
cont.table("pane", pane -> {
cont.table("button", pane -> {
pane.label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" : "text.players", playerGroup.size()));
pane.row();
pane.pane("clear", content).grow().get().setScrollingDisabled(true, false);
pane.pane(content).grow().get().setScrollingDisabled(true, false);
pane.row();
pane.table("pane", menu -> {
pane.table(menu -> {
menu.defaults().growX().height(50f).fillY();
menu.addButton("$text.server.bans", ui.bans::show).disabled(b -> Net.client());
@@ -70,12 +70,14 @@ public class PlayerListFragment extends Fragment{
float h = 74f;
playerGroup.all().sort((p1, p2) -> p1.getTeam().compareTo(p2.getTeam()));
playerGroup.forEach(player -> {
NetConnection connection = player.con;
if(connection == null && Net.server() && !player.isLocal) return;
Table button = new Table("button");
Table button = new Table();
button.left();
button.margin(5).marginBottom(10);
@@ -102,19 +104,19 @@ public class PlayerListFragment extends Fragment{
if((Net.server() || players[0].isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
button.add().growY();
float bs = (h + 14) / 2f;
float bs = (h) / 2f;
button.table(t -> {
t.defaults().size(bs - 1, bs + 3);
t.defaults().size(bs);
t.addImageButton("icon-ban", 14 * 2,
() -> ui.showConfirm("$text.confirm", "$text.confirmban", () -> Call.onAdminRequest(player, AdminAction.ban))).padBottom(-5.1f);
t.addImageButton("icon-cancel", 16 * 2,
() -> ui.showConfirm("$text.confirm", "$text.confirmkick", () -> Call.onAdminRequest(player, AdminAction.kick))).padBottom(-5.1f);
t.addImageButton("icon-ban", "clear-partial", 14 * 2,
() -> ui.showConfirm("$text.confirm", "$text.confirmban", () -> Call.onAdminRequest(player, AdminAction.ban)));
t.addImageButton("icon-cancel", "clear-partial", 16 * 2,
() -> ui.showConfirm("$text.confirm", "$text.confirmkick", () -> Call.onAdminRequest(player, AdminAction.kick)));
t.row();
t.addImageButton("icon-admin", "toggle", 14 * 2, () -> {
t.addImageButton("icon-admin", "clear-toggle", 14 * 2, () -> {
if(Net.client()) return;
String id = player.uuid;
@@ -130,15 +132,15 @@ public class PlayerListFragment extends Fragment{
.touchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled)
.checked(player.isAdmin);
t.addImageButton("icon-zoom-small", 14 * 2, () -> ui.showError("Currently unimplemented.")/*Call.onAdminRequest(player, AdminAction.trace)*/);
}).padRight(12).padTop(-5).padLeft(0).padBottom(-10).size(bs + 10f, bs);
t.addImageButton("icon-zoom-small", "clear-partial", 14 * 2, () -> ui.showError("Currently unimplemented.")/*Call.onAdminRequest(player, AdminAction.trace)*/);
}).padRight(12).size(bs + 10f, bs);
}
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14);
content.row();
content.addImage("blank").height(3f).color(state.mode.isPvp ? player.getTeam().color : Palette.accent).growX();
content.row();
});
content.marginBottom(5);

View File

@@ -387,10 +387,11 @@ public class Block extends BaseBlock {
tempColor.set(Palette.darkFlame);
if(hasItems){
float scaling = inventoryScaling(tile);
for(Item item : content.items()){
int amount = tile.entity.items.get(item);
explosiveness += item.explosiveness * amount;
flammability += item.flammability * amount;
explosiveness += item.explosiveness * amount * scaling;
flammability += item.flammability * amount * scaling;
if(item.flammability * amount > 0.5){
units++;
@@ -416,7 +417,7 @@ public class Block extends BaseBlock {
float splash = Mathf.clamp(amount / 4f, 0f, 10f);
for(int i = 0; i < Mathf.clamp(amount / 5, 0, 30); i++){
Timers.run(i / 2, () -> {
Timers.run(i / 2f, () -> {
Tile other = world.tile(tile.x + Mathf.range(size / 2), tile.y + Mathf.range(size / 2));
if(other != null){
Puddle.deposit(other, liquid, splash);
@@ -432,6 +433,11 @@ public class Block extends BaseBlock {
}
}
/**Returns scaled # of inventories in this block.*/
public float inventoryScaling(Tile tile){
return 1f;
}
/**
* Returns the flammability of the tile. Used for fire calculations.
* Takes flammability of floor liquid into account.

View File

@@ -4,43 +4,32 @@ import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.type.Item;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.function.Supplier;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.style.TextureRegionDrawable;
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.*;
import static io.anuke.mindustry.Vars.content;
import static io.anuke.mindustry.Vars.control;
public interface SelectionTrait{
default void buildItemTable(Table table, Supplier<Item> holder, Consumer<Item> consumer){
buildItemTable(table, false, holder, consumer);
}
default void buildItemTable(Table table, boolean nullItem, Supplier<Item> holder, Consumer<Item> consumer){
Array<Item> items = content.items();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
group.setMinCheckCount(0);
Table cont = new Table();
cont.defaults().size(38, 42).padBottom(-5.1f);
cont.defaults().size(38);
int i = 0;
if(nullItem){
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> consumer.accept(null)).group(group).get();
button.getStyle().imageUp = new TextureRegionDrawable(Draw.region("icon-nullitem"));
button.setChecked(holder.get() == null);
i ++;
}
for(Item item : items){
if(!control.unlocks.isUnlocked(item)) continue;
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> consumer.accept(item))
.group(group).get();
ImageButton button = cont.addImageButton("white", "clear-toggle", 24, () -> {}).group(group).get();
button.changed(() -> consumer.accept(button.isChecked() ? item : null));
button.getStyle().imageUp = new TextureRegionDrawable(item.region);
button.setChecked(holder.get() == item);

View File

@@ -40,15 +40,15 @@ public class Sorter extends Block implements SelectionTrait{
@Override
public void playerPlaced(Tile tile){
if(lastItem != null){
threads.runDelay(() -> Call.setSorterItem(null, tile, lastItem));
}
threads.runDelay(() -> Call.setSorterItem(null, tile, lastItem));
}
@Remote(targets = Loc.both, called = Loc.both, forward = true)
public static void setSorterItem(Player player, Tile tile, Item item){
SorterEntity entity = tile.entity();
if(entity != null) entity.sortItem = item;
if(entity != null){
entity.sortItem = item;
}
}
@Override
@@ -56,6 +56,7 @@ public class Sorter extends Block implements SelectionTrait{
super.draw(tile);
SorterEntity entity = tile.entity();
if(entity.sortItem == null) return;
Draw.color(entity.sortItem.color);
Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f);
@@ -130,16 +131,17 @@ public class Sorter extends Block implements SelectionTrait{
}
public static class SorterEntity extends TileEntity{
public Item sortItem = content.item(0);
public Item sortItem;
@Override
public void writeConfig(DataOutput stream) throws IOException{
stream.writeByte(sortItem.id);
stream.writeByte(sortItem == null ? -1 : sortItem.id);
}
@Override
public void readConfig(DataInput stream) throws IOException{
sortItem = content.items().get(stream.readByte());
byte b = stream.readByte();
sortItem = b == -1 ? null : content.items().get(b);
}
}
}

View File

@@ -66,7 +66,7 @@ public class PowerNode extends PowerBlock{
@Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void unlinkPowerNodes(Player player, Tile tile, Tile other){
if(tile.entity.power == null) return;
if(tile.entity.power == null || other.entity == null || other.entity.power == null) return;
TileEntity entity = tile.entity();
@@ -248,23 +248,10 @@ public class PowerNode extends PowerBlock{
x2 += t2.x;
y2 += t2.y;
float space = Vector2.dst(x1, y1, x2, y2);
float scl = 4f, mag = 2f, tscl = 4f, segscl = 3f;
Draw.color(Palette.powerLight, Palette.power, Mathf.absin(Timers.time(), 8f, 1f));
Lines.stroke(2f);
Lines.line(x1, y1, x2, y2);
int segments = Mathf.ceil(space / segscl);
Draw.color(Palette.power, Palette.powerLight, Mathf.absin(Timers.time(), 5f, 1f));
Lines.stroke(1f);
for(int i = 0; i < segments; i++){
float f1 = (float)i / segments;
float f2 = (float)(i+1) / segments;
t1.trns(angle1 + 90f, Mathf.lerp(Mathf.sin(tile.entity.id * 124f + Timers.time()/tscl + f1 * space, scl, mag), 0f, Math.abs(f1 - 0.5f)*2f));
t2.trns(angle1 + 90f, Mathf.lerp(Mathf.sin(tile.entity.id * 124f + Timers.time()/tscl + f2 * space, scl, mag), 0f, Math.abs(f2 - 0.5f)*2f));
Lines.line(x1 + (x2 - x1) * f1 + t1.x, y1 + (y2 - y1) * f1 + t1.y,
x1 + (x2 - x1) * f2 + t2.x, y1 + (y2 - y1) * f2 + t2.y);
}
}
}

View File

@@ -65,7 +65,7 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
@Override
public void buildTable(Tile tile, Table table){
SortedUnloaderEntity entity = tile.entity();
buildItemTable(table, true, () -> entity.sortItem, item -> Call.setSortedUnloaderItem(null, tile, item));
buildItemTable(table, () -> entity.sortItem, item -> Call.setSortedUnloaderItem(null, tile, item));
}
@Override

View File

@@ -89,6 +89,12 @@ public abstract class StorageBlock extends Block{
}
}
@Override
public float inventoryScaling(Tile tile){
StorageEntity entity = tile.entity();
return 1f / entity.graph.getTiles().size;
}
@Override
public TileEntity newEntity(){
return new StorageEntity();

View File

@@ -3,7 +3,6 @@ package io.anuke.mindustry.world.blocks.storage;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockGroup;
public abstract class Unloader extends Block{
protected final int timerUnload = timers++;
@@ -13,7 +12,6 @@ public abstract class Unloader extends Block{
update = true;
solid = true;
health = 70;
group = BlockGroup.transportation;
hasItems = true;
}
@@ -24,6 +22,5 @@ public abstract class Unloader extends Block{
}
@Override
public void setBars(){
}
public void setBars(){}
}

View File

@@ -84,12 +84,12 @@ public class CommandCenter extends Block{
Table buttons = new Table();
for(UnitCommand cmd : UnitCommand.values()){
buttons.addImageButton("command-" + cmd.name(), "toggle", 8*3, () -> threads.run(() -> Call.onCommandCenterSet(players[0], tile, cmd))).size(40f, 44f)
.checked(entity.command == cmd).group(group);
buttons.addImageButton("command-" + cmd.name(), "clear-toggle", 8*3, () -> threads.run(() -> Call.onCommandCenterSet(players[0], tile, cmd)))
.size(38f).checked(entity.command == cmd).group(group);
}
table.add(buttons);
table.row();
table.table("button", t -> t.label(() -> entity.command.localized()).center().growX()).growX().padTop(-5);
table.table("pane", t -> t.label(() -> entity.command.localized()).center().growX()).growX();
}
@Remote(called = Loc.server, forward = true, targets = Loc.both)

View File

@@ -33,7 +33,7 @@ public abstract class Consume{
}
public void build(Table table){
Table t = new Table("clear");
Table t = new Table("flat");
t.margin(4);
buildTooltip(t);