Death to unit.dp
This commit is contained in:
@@ -34,11 +34,11 @@ public class Vars{
|
||||
//save file directory
|
||||
public static final FileHandle saveDirectory = Gdx.files.local("mindustry-saves/");
|
||||
//scale of the font
|
||||
public static float fontscale = Math.max(Unit.dp.inPixels(1f)/2f, 0.5f);
|
||||
public static float fontscale = Math.max(Unit.dp.scl(1f)/2f, 0.5f);
|
||||
//camera zoom displayed on startup
|
||||
public static final int baseCameraScale = Math.round(Unit.dp.inPixels(4));
|
||||
public static final int baseCameraScale = Math.round(Unit.dp.scl(4));
|
||||
//how much the zoom changes every zoom button press
|
||||
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
|
||||
public static final int zoomScale = Math.round(Unit.dp.scl(1));
|
||||
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
|
||||
public static boolean debug = false;
|
||||
//whether the player can clip through walls
|
||||
|
||||
@@ -16,6 +16,7 @@ import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.effect.Shaders;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
import io.anuke.mindustry.world.Layer;
|
||||
import io.anuke.mindustry.world.SpawnPoint;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -257,7 +258,7 @@ public class Renderer extends RendererModule{
|
||||
}
|
||||
|
||||
float angle = Angles.angle(camera.position.x, camera.position.y, enemy.x, enemy.y);
|
||||
Angles.translation(angle, Unit.dp.inPixels(20f));
|
||||
Angles.translation(angle, Unit.dp.scl(20f));
|
||||
Draw.rect("enemyarrow", camera.position.x + Angles.x(), camera.position.y + Angles.y(), angle);
|
||||
}
|
||||
Draw.color();
|
||||
@@ -546,6 +547,9 @@ public class Renderer extends RendererModule{
|
||||
Draw.dashCircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace);
|
||||
}
|
||||
|
||||
if(player.breakMode == PlaceMode.holdDelete)
|
||||
player.breakMode.draw(tilex, tiley, 0, 0);
|
||||
|
||||
}else if(player.breakMode.delete && control.input.drawPlace() && player.recipe == null){ //TODO test!
|
||||
player.breakMode.draw(control.input.getBlockX(), control.input.getBlockY(),
|
||||
control.input.getBlockEndX(), control.input.getBlockEndY());
|
||||
@@ -632,7 +636,7 @@ public class Renderer extends RendererModule{
|
||||
}
|
||||
|
||||
public void clampScale(){
|
||||
targetscale = Mathf.clamp(targetscale, Math.round(Unit.dp.inPixels(2)), Math.round(Unit.dp.inPixels((5))));
|
||||
targetscale = Mathf.clamp(targetscale, Math.round(Unit.dp.scl(2)), Math.round(Unit.dp.scl((5))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Tutorial{
|
||||
atop();
|
||||
margin(12);
|
||||
|
||||
info = new label(()->stage.text).pad(10f).padBottom(5f).width(340f).units(Unit.dp).colspan(2).get();
|
||||
info = new label(()->stage.text).pad(10f).padBottom(5f).width(340f).colspan(2).get();
|
||||
info.setWrap(true);
|
||||
|
||||
row();
|
||||
@@ -62,8 +62,8 @@ public class Tutorial{
|
||||
|
||||
}}.end();
|
||||
|
||||
prev.pad(Unit.dp.inPixels(16));
|
||||
next.pad(Unit.dp.inPixels(16));
|
||||
prev.pad(Unit.dp.scl(16));
|
||||
next.pad(Unit.dp.scl(16));
|
||||
|
||||
prev.setDisabled(()->!canMove(false) || !stage.canBack);
|
||||
next.setDisabled(()->!stage.canForward);
|
||||
|
||||
@@ -123,13 +123,13 @@ public class UI extends SceneModule{
|
||||
Draw.color();
|
||||
|
||||
TextureRegion back = Draw.region("background");
|
||||
float backscl = Unit.dp.inPixels(5f);
|
||||
float backscl = Unit.dp.scl(5f);
|
||||
|
||||
Draw.alpha(0.7f);
|
||||
Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2 +240f, h/2 - back.getRegionHeight()*backscl/2 + 250f,
|
||||
back.getRegionWidth()*backscl, back.getRegionHeight()*backscl);
|
||||
|
||||
float logoscl = (int)Unit.dp.inPixels(7);
|
||||
float logoscl = (int)Unit.dp.scl(7);
|
||||
TextureRegion logo = skin.getRegion("logotext");
|
||||
float logow = logo.getRegionWidth()*logoscl;
|
||||
float logoh = logo.getRegionHeight()*logoscl;
|
||||
@@ -177,14 +177,14 @@ public class UI extends SceneModule{
|
||||
+ "[]Please report the exact circumstances under which this error occured to the developer: "
|
||||
+ "\n[ORANGE]anukendev@gmail.com[]"){{
|
||||
setWrap(true);
|
||||
}}).width(600f).units(Unit.dp).pad(10f);
|
||||
gameerror.buttons().addButton("OK", gameerror::hide).size(200f, 50).units(Unit.dp);
|
||||
}}).width(600f).pad(10f);
|
||||
gameerror.buttons().addButton("OK", gameerror::hide).size(200f, 50);
|
||||
//gameerror.setFillParent(true);
|
||||
|
||||
discord = new Dialog("Discord", "dialog");
|
||||
discord.content().pad(Unit.dp.inPixels(12f));
|
||||
discord.content().pad(Unit.dp.scl(12f));
|
||||
discord.content().add("Join the mindustry discord!\n[orange]" + Vars.discordURL);
|
||||
discord.buttons().defaults().size(200f, 50).units(Unit.dp);
|
||||
discord.buttons().defaults().size(200f, 50);
|
||||
discord.buttons().addButton("Open link", () -> Mindustry.platforms.openLink(Vars.discordURL));
|
||||
discord.buttons().addButton("Back", discord::hide);
|
||||
|
||||
@@ -255,7 +255,7 @@ public class UI extends SceneModule{
|
||||
prefs.content().row();
|
||||
prefs.content().addButton("Controls", () -> {
|
||||
keys.show(scene);
|
||||
}).size(300f, 50f).pad(5f).units(Unit.dp);
|
||||
}).size(300f, 50f).pad(5f);
|
||||
}
|
||||
|
||||
keys = new MindustryKeybindDialog();
|
||||
@@ -275,7 +275,7 @@ public class UI extends SceneModule{
|
||||
restart.content().add("[YELLOW]New highscore!").pad(6);
|
||||
restart.content().row();
|
||||
}
|
||||
restart.content().add("You lasted until wave [GREEN]" + control.getWave() + "[].").pad(12).units(Unit.dp).get();
|
||||
restart.content().add("You lasted until wave [GREEN]" + control.getWave() + "[].").pad(12).get();
|
||||
restart.pack();
|
||||
});
|
||||
|
||||
@@ -283,7 +283,7 @@ public class UI extends SceneModule{
|
||||
restart.hide();
|
||||
GameState.set(State.menu);
|
||||
control.reset();
|
||||
}).size(200, 50).pad(3).units(Unit.dp);
|
||||
}).size(200, 50).pad(3);
|
||||
|
||||
build.begin(scene);
|
||||
|
||||
@@ -300,14 +300,14 @@ public class UI extends SceneModule{
|
||||
loadingtable = new table("loadDim"){{
|
||||
get().setTouchable(Touchable.enabled);
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().units(Unit.dp).get().setColor(Colors.get("accent"));
|
||||
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
|
||||
row();
|
||||
new label("[accent]Loading..."){{
|
||||
get().setName("namelabel");
|
||||
}}.pad(10).units(Unit.dp);
|
||||
}}.pad(10);
|
||||
row();
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().units(Unit.dp).get().setColor(Colors.get("accent"));
|
||||
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
|
||||
}}.end().get();
|
||||
|
||||
loadingtable.setVisible(false);
|
||||
@@ -367,11 +367,11 @@ public class UI extends SceneModule{
|
||||
|
||||
public void showError(String text){
|
||||
new Dialog("[crimson]An error has occured", "dialog"){{
|
||||
content().pad(Unit.dp.inPixels(15));
|
||||
content().pad(Unit.dp.scl(15));
|
||||
content().add(text);
|
||||
getButtonTable().addButton("OK", ()->{
|
||||
hide();
|
||||
}).size(90, 50).pad(4).units(Unit.dp);
|
||||
}).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
@@ -472,8 +472,8 @@ public class UI extends SceneModule{
|
||||
|
||||
public void showConfirm(String title, String text, Listenable confirmed){
|
||||
FloatingDialog dialog = new FloatingDialog(title);
|
||||
dialog.content().add(text).pad(4f).units(Unit.dp);
|
||||
dialog.buttons().defaults().size(200f, 54f).pad(2f).units(Unit.dp);
|
||||
dialog.content().add(text).pad(4f);
|
||||
dialog.buttons().defaults().size(200f, 54f).pad(2f);
|
||||
dialog.buttons().addButton("Cancel", dialog::hide);
|
||||
dialog.buttons().addButton("OK", () -> {
|
||||
dialog.hide();
|
||||
|
||||
@@ -121,7 +121,7 @@ public class AndroidInput extends InputHandler{
|
||||
public void update(){
|
||||
enableHold = player.breakMode == PlaceMode.holdDelete;
|
||||
|
||||
if(enableHold && player.recipe != null && Gdx.input.isTouched(0) && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.inPixels(50))
|
||||
if(enableHold && Gdx.input.isTouched(0) && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.scl(50))
|
||||
&& !ui.hasMouse()){
|
||||
warmup += Timers.delta();
|
||||
|
||||
|
||||
@@ -83,9 +83,9 @@ public class GestureHandler extends GestureAdapter{
|
||||
initzoom = initialDistance;
|
||||
}
|
||||
|
||||
if(Math.abs(distance - initzoom) > Unit.dp.inPixels(100f) && !zoomed){
|
||||
if(Math.abs(distance - initzoom) > Unit.dp.scl(100f) && !zoomed){
|
||||
int amount = (distance > initzoom ? 1 : -1);
|
||||
renderer.scaleCamera(Math.round(Unit.dp.inPixels(amount)));
|
||||
renderer.scaleCamera(Math.round(Unit.dp.scl(amount)));
|
||||
initzoom = distance;
|
||||
zoomed = true;
|
||||
return true;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class MapEditor{
|
||||
public static final int[] validMapSizes = {128, 256, 512};
|
||||
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15};
|
||||
public static final int maxSpawnpoints = 15;
|
||||
public static final Format format = Format.RGBA8888;
|
||||
|
||||
private Pixmap[] brushPixmaps = new Pixmap[brushSizes.length];
|
||||
|
||||
@@ -33,7 +34,7 @@ public class MapEditor{
|
||||
public MapEditor(){
|
||||
for(int i = 0; i < brushSizes.length; i ++){
|
||||
int s = brushSizes[i];
|
||||
brushPixmaps[i] = new Pixmap(s*2-1, s*2-1, Format.RGB888);
|
||||
brushPixmaps[i] = new Pixmap(s*2-1, s*2-1, format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ public class MapEditor{
|
||||
this.map = map;
|
||||
this.brushSize = 1;
|
||||
if(map.pixmap == null){
|
||||
pixmap = new Pixmap(256, 256, Format.RGB888);
|
||||
pixmap = new Pixmap(256, 256, format);
|
||||
pixmap.setColor(ColorMapper.getColor(drawBlock));
|
||||
pixmap.fill();
|
||||
texture = new Texture(pixmap);
|
||||
|
||||
@@ -152,16 +152,16 @@ public class MapEditorDialog extends Dialog{
|
||||
public void build(){
|
||||
|
||||
new table(){{
|
||||
float isize = Unit.dp.inPixels(16*2f);
|
||||
float isize = Unit.dp.scl(16*2f);
|
||||
aleft();
|
||||
|
||||
new table(){{
|
||||
|
||||
defaults().growY().width(130f).units(Unit.dp).padBottom(-6);
|
||||
defaults().growY().width(130f).padBottom(-6);
|
||||
|
||||
new imagebutton("icon-terrain", isize, () -> {
|
||||
dialog.show();
|
||||
}).text("generate").units(Unit.dp);
|
||||
}).text("generate");
|
||||
|
||||
row();
|
||||
|
||||
@@ -220,14 +220,14 @@ public class MapEditorDialog extends Dialog{
|
||||
for(EditorTool tool : EditorTool.values()){
|
||||
ImageButton button = new ImageButton("icon-" + tool.name(), "toggle");
|
||||
button.clicked(() -> view.setTool(tool));
|
||||
button.resizeImage(Unit.dp.inPixels(16*2f));
|
||||
button.resizeImage(Unit.dp.scl(16*2f));
|
||||
group.add(button);
|
||||
|
||||
tools.add(button).size(80f, 85f).padBottom(-6f).units(Unit.dp);
|
||||
tools.add(button).size(80f, 85f).padBottom(-6f);
|
||||
if(i++ % 2 == 1) tools.row();
|
||||
}
|
||||
|
||||
add(tools).units(Unit.dp).width(160f).padBottom(-6);
|
||||
add(tools).width(160f).padBottom(-6);
|
||||
|
||||
row();
|
||||
|
||||
@@ -239,7 +239,7 @@ public class MapEditorDialog extends Dialog{
|
||||
});
|
||||
new label(() -> "Brush size: " + MapEditor.brushSizes[(int)slider.getValue()]).left();
|
||||
row();
|
||||
add(slider).growX().padTop(4f).units(Unit.dp);
|
||||
add(slider).growX().padTop(4f);
|
||||
}}.growX().end();
|
||||
|
||||
row();
|
||||
@@ -312,16 +312,16 @@ public class MapEditorDialog extends Dialog{
|
||||
|
||||
ImageButton button = new ImageButton(Draw.hasRegion(block.name) ? Draw.region(block.name) : Draw.region(block.name + "1"), "toggle");
|
||||
button.clicked(() -> editor.setDrawBlock(block));
|
||||
button.resizeImage(Unit.dp.inPixels(8*4f));
|
||||
button.resizeImage(Unit.dp.scl(8*4f));
|
||||
group.add(button);
|
||||
content.add(button).pad(4f).size(53f, 58f).units(Unit.dp);
|
||||
content.add(button).pad(4f).size(53f, 58f);
|
||||
|
||||
if(i++ % 2 == 1){
|
||||
content.row();
|
||||
}
|
||||
}
|
||||
|
||||
content.padLeft(Unit.dp.inPixels(-5f));
|
||||
content.padLeft(Unit.dp.scl(-5f));
|
||||
|
||||
group.getButtons().get(2).setChecked(true);
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
image.setScaling(Scaling.fit);
|
||||
Table preft = new Table();
|
||||
preft.left();
|
||||
preft.pad(Unit.dp.inPixels(4f)).padRight(Unit.dp.inPixels(25f));
|
||||
preft.pad(Unit.dp.scl(4f)).padRight(Unit.dp.scl(25f));
|
||||
|
||||
for(GenPref pref : editor.getFilter().getPrefs().values()){
|
||||
CheckBox box = new CheckBox(pref.name);
|
||||
box.setChecked(pref.enabled);
|
||||
box.changed(() -> pref.enabled = box.isChecked());
|
||||
preft.add(box).pad(4f).units(Unit.dp).left();
|
||||
preft.add(box).pad(4f).left();
|
||||
preft.row();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
|
||||
content().add(pane).fillY();
|
||||
|
||||
buttons().defaults().size(170f, 50f).units(Unit.dp).pad(4f);
|
||||
buttons().defaults().size(170f, 50f).pad(4f);
|
||||
buttons().addButton("Back", () -> hide());
|
||||
buttons().addButton("Randomize", () ->{
|
||||
editor.getFilter().randomize();
|
||||
|
||||
@@ -23,8 +23,8 @@ public class MapLoadDialog extends FloatingDialog{
|
||||
int i = 0;
|
||||
|
||||
Table table = new Table();
|
||||
table.defaults().size(200f, 90f).units(Unit.dp).pad(4f);
|
||||
table.pad(Unit.dp.inPixels(10f));
|
||||
table.defaults().size(200f, 90f).pad(4f);
|
||||
table.pad(Unit.dp.scl(10f));
|
||||
|
||||
ScrollPane pane = new ScrollPane(table, "horizontal");
|
||||
pane.setFadeScrollBars(false);
|
||||
@@ -33,10 +33,10 @@ public class MapLoadDialog extends FloatingDialog{
|
||||
if(!map.visible) continue;
|
||||
|
||||
TextButton button = new TextButton(map.name, "toggle");
|
||||
button.add(new BorderImage(map.texture, 2f)).size(Unit.dp.inPixels(16*4f));
|
||||
button.add(new BorderImage(map.texture, 2f)).size(Unit.dp.scl(16*4f));
|
||||
button.getCells().reverse();
|
||||
button.clicked(() -> selected = map);
|
||||
button.getLabelCell().grow().left().padLeft(5f).units(Unit.dp);
|
||||
button.getLabelCell().grow().left().padLeft(5f);
|
||||
group.add(button);
|
||||
table.add(button);
|
||||
if(++i % maxcol == 0) table.row();
|
||||
@@ -55,7 +55,7 @@ public class MapLoadDialog extends FloatingDialog{
|
||||
}
|
||||
});
|
||||
|
||||
buttons().defaults().size(200f, 50f).units(Unit.dp);
|
||||
buttons().defaults().size(200f, 50f);
|
||||
buttons().addButton("Cancel", this::hide);
|
||||
buttons().add(button);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import io.anuke.ucore.function.BiConsumer;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class MapResizeDialog extends FloatingDialog{
|
||||
int width, height;
|
||||
@@ -43,7 +42,7 @@ public class MapResizeDialog extends FloatingDialog{
|
||||
});
|
||||
group.add(button);
|
||||
if(i == idx) button.setChecked(true);
|
||||
table.add(button).size(100f, 54f).pad(2f).units(Unit.dp);
|
||||
table.add(button).size(100f, 54f).pad(2f);
|
||||
}
|
||||
|
||||
table.row();
|
||||
@@ -57,7 +56,7 @@ public class MapResizeDialog extends FloatingDialog{
|
||||
|
||||
});
|
||||
|
||||
buttons().defaults().size(200f, 50f).units(Unit.dp);
|
||||
buttons().defaults().size(200f, 50f);
|
||||
buttons().addButton("Cancel", this::hide);
|
||||
buttons().addButton("Resize", () -> {
|
||||
cons.accept(width, height);
|
||||
|
||||
@@ -6,7 +6,6 @@ import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class MapSaveDialog extends FloatingDialog{
|
||||
private TextField field;
|
||||
@@ -33,7 +32,7 @@ public class MapSaveDialog extends FloatingDialog{
|
||||
content().add(field).size(220f, 48f);
|
||||
});
|
||||
|
||||
buttons().defaults().size(200f, 50f).pad(2f).units(Unit.dp);
|
||||
buttons().defaults().size(200f, 50f).pad(2f);
|
||||
buttons().addButton("Cancel", this::hide);
|
||||
|
||||
TextButton button = new TextButton("Save");
|
||||
|
||||
@@ -124,7 +124,7 @@ public class MapView extends Element implements GestureListener{
|
||||
if(pop) ScissorStack.popScissors();
|
||||
|
||||
Draw.color(Colors.get("accent"));
|
||||
Draw.thick(Unit.dp.inPixels(3f));
|
||||
Draw.thick(Unit.dp.scl(3f));
|
||||
Draw.linerect(x + width/2 - size/2, y + height/2 - size/2, size, size);
|
||||
Draw.reset();
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class MapView extends Element implements GestureListener{
|
||||
public boolean zoom(float initialDistance, float distance){
|
||||
if(!active()) return false;
|
||||
float nzoom = distance - initialDistance;
|
||||
zoom += nzoom / 2000f / Unit.dp.inPixels(1f) * zoom;
|
||||
zoom += nzoom / 2000f / Unit.dp.scl(1f) * zoom;
|
||||
clampZoom();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class BorderImage extends Image{
|
||||
float scaleY = getScaleY();
|
||||
|
||||
Draw.color(Colors.get("accent"));
|
||||
Draw.thick(Unit.dp.inPixels(thickness));
|
||||
Draw.thick(Unit.dp.scl(thickness));
|
||||
Draw.linerect(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
@@ -22,7 +19,6 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class FileChooser extends FloatingDialog{
|
||||
|
||||
private Table files;
|
||||
private FileHandle homeDirectory = Gdx.files.absolute(Gdx.files.getExternalStoragePath());
|
||||
private FileHandle directory = homeDirectory;
|
||||
@@ -48,7 +44,7 @@ public class FileChooser extends FloatingDialog{
|
||||
|
||||
private void setupWidgets(){
|
||||
getCell(content()).maxWidth(Gdx.graphics.getWidth()/2);
|
||||
content().pad(-Unit.dp.inPixels(10));
|
||||
content().pad(-Unit.dp.scl(10));
|
||||
|
||||
Table content = new Table();
|
||||
|
||||
@@ -91,7 +87,7 @@ public class FileChooser extends FloatingDialog{
|
||||
|
||||
Table icontable = new Table();
|
||||
|
||||
float isize = Unit.dp.inPixels(14*2);
|
||||
float isize = Unit.dp.scl(14*2);
|
||||
|
||||
ImageButton up = new ImageButton("icon-folder-parent");
|
||||
up.resizeImage(isize);
|
||||
@@ -162,20 +158,12 @@ public class FileChooser extends FloatingDialog{
|
||||
}
|
||||
|
||||
private FileHandle[] getFileNames(){
|
||||
FileHandle[] handles = directory.list(new FileFilter(){
|
||||
@Override
|
||||
public boolean accept(File file){
|
||||
return !file.getName().startsWith(".");
|
||||
}
|
||||
});
|
||||
FileHandle[] handles = directory.list(file -> !file.getName().startsWith("."));
|
||||
|
||||
Arrays.sort(handles, new Comparator<FileHandle>(){
|
||||
@Override
|
||||
public int compare(FileHandle a, FileHandle b){
|
||||
if(a.isDirectory() && !b.isDirectory()) return -1;
|
||||
if( !a.isDirectory() && b.isDirectory()) return 1;
|
||||
return a.name().compareTo(b.name());
|
||||
}
|
||||
Arrays.sort(handles, (a, b) ->{
|
||||
if(a.isDirectory() && !b.isDirectory()) return -1;
|
||||
if( !a.isDirectory() && b.isDirectory()) return 1;
|
||||
return a.name().compareTo(b.name());
|
||||
});
|
||||
return handles;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ public class FloatingDialog extends Dialog{
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().addImage("white", Colors.get("accent"))
|
||||
.growX().height(3f).pad(4f).units(Unit.dp);
|
||||
.growX().height(3f).pad(4f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.inPixels(30f), ()->{
|
||||
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.scl(30f), ()->{
|
||||
hide();
|
||||
}).size(230f, 64f).units(Unit.dp);
|
||||
}).size(230f, 64f);
|
||||
|
||||
keyDown(key->{
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
|
||||
@@ -41,14 +41,14 @@ public class LevelDialog extends FloatingDialog{
|
||||
|
||||
Table selmode = new Table();
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
selmode.add("Gamemode: ").padRight(10f).units(Unit.dp);
|
||||
selmode.add("Gamemode: ").padRight(10f);
|
||||
|
||||
for(GameMode mode : GameMode.values()){
|
||||
TextButton b = Elements.newButton(mode.toString(), "toggle", ()->{
|
||||
Vars.control.setMode(mode);
|
||||
});
|
||||
group.add(b);
|
||||
selmode.add(b).size(130f, 54f).units(Unit.dp);
|
||||
selmode.add(b).size(130f, 54f);
|
||||
}
|
||||
|
||||
content().add(selmode);
|
||||
@@ -64,10 +64,10 @@ public class LevelDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
Table inset = new Table("pane-button");
|
||||
inset.add("[accent]"+map.name).pad(3f).units(Unit.dp);
|
||||
inset.add("[accent]"+map.name).pad(3f);
|
||||
inset.row();
|
||||
inset.label((() -> "High Score: [accent]" + Settings.getInt("hiscore" + map.name)))
|
||||
.pad(3f).units(Unit.dp);
|
||||
.pad(3f);
|
||||
inset.pack();
|
||||
|
||||
float images = 154f;
|
||||
@@ -79,7 +79,7 @@ public class LevelDialog extends FloatingDialog{
|
||||
|
||||
ImageButton image = new ImageButton(new TextureRegion(map.texture), "togglemap");
|
||||
image.row();
|
||||
image.add(inset).width(images+6).units(Unit.dp);
|
||||
image.add(inset).width(images+6);
|
||||
TextButton[] delete = new TextButton[1];
|
||||
if(map.custom){
|
||||
image.row();
|
||||
@@ -89,7 +89,7 @@ public class LevelDialog extends FloatingDialog{
|
||||
reload();
|
||||
Core.scene.setScrollFocus(pane);
|
||||
});
|
||||
}).width(images+16).units(Unit.dp).padBottom(-10f).grow().get();
|
||||
}).width(images+16).padBottom(-10f).grow().get();
|
||||
}
|
||||
image.clicked(()->{
|
||||
if(delete[0] != null && delete[0].getClickListener().isOver()){
|
||||
@@ -99,14 +99,14 @@ public class LevelDialog extends FloatingDialog{
|
||||
hide();
|
||||
Vars.control.playMap(selectedMap);
|
||||
});
|
||||
image.getImageCell().size(images).units(Unit.dp);
|
||||
image.getImageCell().size(images);
|
||||
|
||||
stack.add(back);
|
||||
stack.add(image);
|
||||
|
||||
maps.add(stack).width(170).top().pad(4f).units(Unit.dp);
|
||||
maps.add(stack).width(170).top().pad(4f);
|
||||
|
||||
maps.padRight(Unit.dp.inPixels(26));
|
||||
maps.padRight(Unit.dp.scl(26));
|
||||
|
||||
i ++;
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ public class LoadDialog extends FloatingDialog{
|
||||
pane = new ScrollPane(slots);
|
||||
pane.setFadeScrollBars(false);
|
||||
|
||||
slots.padRight(Unit.dp.inPixels(24));
|
||||
slots.padRight(Unit.dp.scl(24));
|
||||
|
||||
for(int i = 0; i < Vars.saveSlots; i++){
|
||||
final int slot = i;
|
||||
|
||||
TextButton button = new TextButton("[accent]Slot " + (i + 1));
|
||||
button.pad(Unit.dp.inPixels(12));
|
||||
button.pad(Unit.dp.scl(12));
|
||||
button.getLabelCell().top().left().growX();
|
||||
|
||||
button.row();
|
||||
@@ -63,11 +63,11 @@ public class LoadDialog extends FloatingDialog{
|
||||
button.add(info).padBottom(3).padTop(7);
|
||||
button.row();
|
||||
//button.addImage("white", Color.GRAY)
|
||||
//.growX().height(3f).pad(4f).units(Unit.dp);
|
||||
//.growX().height(3f).pad(4f);
|
||||
button.row();
|
||||
modifyButton(button, slot);
|
||||
|
||||
slots.add(button).size(404, 104).pad(4).units(Unit.dp);
|
||||
slots.add(button).size(404, 104).pad(4);
|
||||
slots.row();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
});
|
||||
|
||||
if(!Vars.android){
|
||||
content().defaults().width(220).height(50).units(Unit.dp);
|
||||
content().defaults().width(220).height(50);
|
||||
|
||||
content().addButton("Back", () -> {
|
||||
hide();
|
||||
@@ -63,7 +63,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
}){
|
||||
{
|
||||
for(Cell<?> cell : getButtonTable().getCells())
|
||||
cell.pad(3).size(180, 44).units(Unit.dp);
|
||||
cell.pad(3).size(180, 44);
|
||||
}
|
||||
}.show();
|
||||
});
|
||||
@@ -73,8 +73,8 @@ public class MenuDialog extends FloatingDialog{
|
||||
|
||||
PressGroup group = new PressGroup();
|
||||
|
||||
content().defaults().size(120f).pad(5).units(Unit.dp);
|
||||
float isize = Unit.dp.inPixels(14f*4);
|
||||
content().defaults().size(120f).pad(5);
|
||||
float isize = Unit.dp.scl(14f*4);
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> {
|
||||
hide();
|
||||
@@ -94,7 +94,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
GameState.set(State.menu);
|
||||
}){{
|
||||
for(Cell<?> cell : getButtonTable().getCells())
|
||||
cell.pad(3).size(180, 44).units(Unit.dp);
|
||||
cell.pad(3).size(180, 44);
|
||||
}}.show();
|
||||
}).text("Quit").padTop(4f);
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ public class MindustryKeybindDialog extends KeybindDialog{
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().add(new Image("white"))
|
||||
.growX().height(3f).pad(4f).units(Unit.dp).get().setColor(Colors.get("accent"));
|
||||
.growX().height(3f).pad(4f).get().setColor(Colors.get("accent"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.inPixels(30f), ()->{
|
||||
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.scl(30f), ()->{
|
||||
hide();
|
||||
}).size(230f, 64f).units(Unit.dp);
|
||||
}).size(230f, 64f);
|
||||
|
||||
keyDown(key->{
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
|
||||
@@ -16,7 +16,7 @@ public class MindustrySettingsDialog extends SettingsDialog{
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().add(new Image("white"))
|
||||
.growX().height(3f).pad(4f).units(Unit.dp).get().setColor(Colors.get("accent"));
|
||||
.growX().height(3f).pad(4f).get().setColor(Colors.get("accent"));
|
||||
|
||||
content().remove();
|
||||
buttons().remove();
|
||||
@@ -32,9 +32,9 @@ public class MindustrySettingsDialog extends SettingsDialog{
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.inPixels(30f), ()->{
|
||||
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.scl(30f), ()->{
|
||||
hide();
|
||||
}).size(230f, 64f).units(Unit.dp);
|
||||
}).size(230f, 64f);
|
||||
|
||||
keyDown(key->{
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
|
||||
@@ -8,7 +8,6 @@ import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
//TODO unified save/load dialogs
|
||||
public class SaveDialog extends LoadDialog{
|
||||
@@ -27,7 +26,7 @@ public class SaveDialog extends LoadDialog{
|
||||
{
|
||||
content().pad(16);
|
||||
for(Cell<?> cell : getButtonTable().getCells())
|
||||
cell.size(110, 45).pad(4).units(Unit.dp);
|
||||
cell.size(110, 45).pad(4);
|
||||
}
|
||||
}.show();
|
||||
}else{
|
||||
|
||||
@@ -69,8 +69,8 @@ public class BlocksFragment implements Fragment{
|
||||
}
|
||||
});
|
||||
button.setName("sectionbutton" + sec.name());
|
||||
add(button).growX().height(54).padTop(sec.ordinal() <= 2 ? -10 : -5).units(Unit.dp);
|
||||
button.getImageCell().size(40).padBottom(4).padTop(2).units(Unit.dp);
|
||||
add(button).growX().height(54).padTop(sec.ordinal() <= 2 ? -10 : -5);
|
||||
button.getImageCell().size(40).padBottom(4).padTop(2);
|
||||
group.add(button);
|
||||
|
||||
if(sec.ordinal() % 3 == 2 && sec.ordinal() > 0){
|
||||
@@ -96,8 +96,8 @@ public class BlocksFragment implements Fragment{
|
||||
}
|
||||
});
|
||||
|
||||
table.add(image).size(size+8).pad(2).units(Unit.dp);
|
||||
image.getImageCell().size(size).units(Unit.dp);
|
||||
table.add(image).size(size+8).pad(2);
|
||||
image.getImageCell().size(size);
|
||||
|
||||
image.update(()->{
|
||||
|
||||
@@ -143,7 +143,7 @@ public class BlocksFragment implements Fragment{
|
||||
|
||||
desctable.defaults().left();
|
||||
desctable.left();
|
||||
desctable.pad(Unit.dp.inPixels(12));
|
||||
desctable.pad(Unit.dp.scl(12));
|
||||
|
||||
Table header = new Table();
|
||||
|
||||
@@ -154,10 +154,10 @@ public class BlocksFragment implements Fragment{
|
||||
TextureRegion region = Draw.hasRegion(recipe.result.name() + "-icon") ?
|
||||
Draw.region(recipe.result.name() + "-icon") : Draw.region(recipe.result.name());
|
||||
|
||||
header.addImage(region).size(8*5).padTop(4).units(Unit.dp);
|
||||
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).units(Unit.dp);
|
||||
header.add(nameLabel).padLeft(2).width(130f);
|
||||
|
||||
//extra info
|
||||
if(recipe.result.fullDescription != null){
|
||||
@@ -173,16 +173,16 @@ public class BlocksFragment implements Fragment{
|
||||
|
||||
FloatingDialog d = new FloatingDialog("Block Info");
|
||||
Table table = new Table();
|
||||
table.defaults().pad(1f).units(Unit.dp);
|
||||
table.defaults().pad(1f);
|
||||
ScrollPane pane = new ScrollPane(table, "clear");
|
||||
pane.setFadeScrollBars(false);
|
||||
Table top = new Table();
|
||||
top.left();
|
||||
top.add(new Image(Draw.region(recipe.result.name))).size(8*5 * recipe.result.width).units(Unit.dp);
|
||||
top.add("[accent]"+recipe.result.formalName).padLeft(6f).units(Unit.dp);
|
||||
top.add(new Image(Draw.region(recipe.result.name))).size(8*5 * recipe.result.width);
|
||||
top.add("[accent]"+recipe.result.formalName).padLeft(6f);
|
||||
table.add(top).fill().left();
|
||||
table.row();
|
||||
table.add(desclabel).width(600).units(Unit.dp);
|
||||
table.add(desclabel).width(600);
|
||||
table.row();
|
||||
|
||||
d.content().add(pane).grow();
|
||||
@@ -200,14 +200,14 @@ public class BlocksFragment implements Fragment{
|
||||
d.buttons().addButton("OK", ()->{
|
||||
if(!wasPaused) GameState.set(State.playing);
|
||||
d.hide();
|
||||
}).size(110, 50).pad(10f).units(Unit.dp);
|
||||
}).size(110, 50).pad(10f);
|
||||
|
||||
d.show();
|
||||
}).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2).units(Unit.dp);
|
||||
}).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
|
||||
}
|
||||
|
||||
|
||||
desctable.add().pad(2).units(Unit.dp);
|
||||
desctable.add().pad(2);
|
||||
|
||||
Table requirements = new Table();
|
||||
|
||||
@@ -218,7 +218,7 @@ public class BlocksFragment implements Fragment{
|
||||
|
||||
for(ItemStack stack : recipe.requirements){
|
||||
ItemStack fs = stack;
|
||||
requirements.addImage(Draw.region("icon-"+stack.item.name())).size(8*3).units(Unit.dp);
|
||||
requirements.addImage(Draw.region("icon-"+stack.item.name())).size(8*3);
|
||||
Label reqlabel = new Label("");
|
||||
|
||||
reqlabel.update(()->{
|
||||
@@ -239,7 +239,7 @@ public class BlocksFragment implements Fragment{
|
||||
Label label = new Label("[health]health: " + recipe.result.health + (recipe.result.description == null ?
|
||||
"" : ("\n[]" + recipe.result.description)));
|
||||
label.setWrap(true);
|
||||
desctable.add(label).width(200).padTop(4).padBottom(2).units(Unit.dp);
|
||||
desctable.add(label).width(200).padTop(4).padBottom(2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class HudFragment implements Fragment{
|
||||
|
||||
new table(){{
|
||||
left();
|
||||
defaults().size(68).units(Unit.dp).left();
|
||||
float isize = Unit.dp.inPixels(40);
|
||||
defaults().size(68).left();
|
||||
float isize = Unit.dp.scl(40);
|
||||
|
||||
new imagebutton("icon-menu", isize, ()->{
|
||||
ui.showMenu();
|
||||
@@ -92,7 +92,7 @@ public class HudFragment implements Fragment{
|
||||
atop();
|
||||
|
||||
new table("pane"){{
|
||||
new label("[orange]< paused >").scale(Unit.dp.inPixels(0.75f)).pad(6).units(Unit.dp);
|
||||
new label("[orange]< paused >").scale(Unit.dp.scl(0.75f)).pad(6);
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
@@ -169,22 +169,22 @@ public class HudFragment implements Fragment{
|
||||
new label(()-> control.getEnemiesRemaining() > 0 ?
|
||||
control.getEnemiesRemaining() + printEnemiesRemaining() :
|
||||
(control.getTutorial().active() || Vars.control.getMode() == GameMode.sandbox) ? "waiting..." : "Wave in " + (int) (control.getWaveCountdown() / 60f))
|
||||
.minWidth(140).units(Unit.dp).left();
|
||||
.minWidth(140).left();
|
||||
|
||||
margin(12f);
|
||||
get().padLeft(6);
|
||||
}}.left().end();
|
||||
|
||||
playButton(uheight);
|
||||
}}.height(uheight).units(Unit.dp).fillX().expandX().end();
|
||||
}}.height(uheight).fillX().expandX().end();
|
||||
|
||||
}
|
||||
|
||||
private void playButton(float uheight){
|
||||
new imagebutton("icon-play", Unit.dp.inPixels(30f), ()->{
|
||||
new imagebutton("icon-play", Unit.dp.scl(30f), ()->{
|
||||
Vars.control.runWave();
|
||||
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36)
|
||||
.padLeft(-10f).width(40f).units(Unit.dp).update(l->{
|
||||
.padLeft(-10f).width(40f).update(l->{
|
||||
boolean vis = Vars.control.getMode() == GameMode.sandbox && Vars.control.getEnemiesRemaining() <= 0;
|
||||
boolean paused = GameState.is(State.paused) || !vis;
|
||||
|
||||
@@ -215,7 +215,7 @@ public class HudFragment implements Fragment{
|
||||
Image image = new Image(Draw.region("icon-" + items[i]));
|
||||
Label label = new Label(formatted);
|
||||
label.setFontScale(fontscale*1.5f);
|
||||
itemtable.add(image).size(8*3).units(Unit.dp);
|
||||
itemtable.add(image).size(8*3);
|
||||
itemtable.add(label).left();
|
||||
itemtable.row();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MenuFragment implements Fragment{
|
||||
PressGroup group = new PressGroup();
|
||||
|
||||
float scale = 4f;
|
||||
defaults().size(100*scale, 21*scale).pad(-10f).units(Unit.dp);
|
||||
defaults().size(100*scale, 21*scale).pad(-10f);
|
||||
|
||||
add(new MenuButton("text-play", group, ui::showLevels));
|
||||
row();
|
||||
@@ -46,7 +46,7 @@ public class MenuFragment implements Fragment{
|
||||
if(!gwt){
|
||||
add(new MenuButton("text-exit", group, Gdx.app::exit));
|
||||
}
|
||||
get().pad(Unit.dp.inPixels(16));
|
||||
get().pad(Unit.dp.scl(16));
|
||||
}}.end();
|
||||
|
||||
visible(()->GameState.is(State.menu));
|
||||
@@ -54,8 +54,8 @@ public class MenuFragment implements Fragment{
|
||||
}else{
|
||||
new table(){{
|
||||
new table(){{
|
||||
defaults().size(120f).pad(5).units(Unit.dp);
|
||||
float isize = Unit.dp.inPixels(14f*4);
|
||||
defaults().size(120f).pad(5);
|
||||
float isize = Unit.dp.scl(14f*4);
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("Play").padTop(4f);
|
||||
|
||||
@@ -84,11 +84,11 @@ public class MenuFragment implements Fragment{
|
||||
new table(){{
|
||||
atop().aright();
|
||||
if(Mindustry.hasDiscord){
|
||||
new imagebutton("icon-discord", Unit.dp.inPixels(30f), ()->{
|
||||
new imagebutton("icon-discord", Unit.dp.scl(30f), ()->{
|
||||
ui.showDiscord();
|
||||
}).margin(14);
|
||||
}
|
||||
new imagebutton("icon-info", Unit.dp.inPixels(30f), ()->{
|
||||
new imagebutton("icon-info", Unit.dp.scl(30f), ()->{
|
||||
ui.showAbout();
|
||||
}).margin(14);
|
||||
}}.end().visible(()->GameState.is(State.menu));
|
||||
|
||||
@@ -33,8 +33,8 @@ public class PlacementFragment implements Fragment{
|
||||
|
||||
new table("pane"){{
|
||||
visible(() -> player.recipe != null && player.recipe.result.rotate);
|
||||
add(image).size(40f).units(Unit.dp);
|
||||
}}.size(54f).units(Unit.dp).end();
|
||||
add(image).size(40f);
|
||||
}}.size(54f).end();
|
||||
|
||||
row();*/
|
||||
|
||||
@@ -50,31 +50,31 @@ public class PlacementFragment implements Fragment{
|
||||
aleft();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
defaults().size(54, 58).pad(0).units(Unit.dp);
|
||||
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", Unit.dp.inPixels(10*3), ()->{
|
||||
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.scl(10*3), ()->{
|
||||
control.getInput().resetCursor();
|
||||
player.placeMode = mode;
|
||||
}).group(group).units(Unit.dp);
|
||||
}).group(group);
|
||||
}
|
||||
|
||||
row();
|
||||
|
||||
Color color = Color.GRAY;//Colors.get("accent"); //Color.valueOf("4d4d4d")
|
||||
|
||||
new imagebutton("icon-cancel", Unit.dp.inPixels(14*3), ()->{
|
||||
new imagebutton("icon-cancel", Unit.dp.scl(14*3), ()->{
|
||||
player.recipe = null;
|
||||
}).imageColor(color)
|
||||
.visible(()->player.recipe != null);
|
||||
|
||||
new button("", ()->{}).get().setTouchable(Touchable.disabled);;
|
||||
|
||||
new imagebutton("icon-arrow", Unit.dp.inPixels(14*3), ()->{
|
||||
new imagebutton("icon-arrow", Unit.dp.scl(14*3), ()->{
|
||||
player.rotation = Mathf.mod(player.rotation + 1, 4);
|
||||
}).imageColor(color).visible(() -> player.recipe != null).update(image ->{
|
||||
image.getImage().setRotation(player.rotation*90);
|
||||
@@ -99,7 +99,7 @@ public class PlacementFragment implements Fragment{
|
||||
aleft();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
defaults().size(54, 58).pad(0).units(Unit.dp);
|
||||
defaults().size(54, 58).pad(0);
|
||||
|
||||
int d = 0;
|
||||
|
||||
@@ -108,12 +108,12 @@ public class PlacementFragment implements Fragment{
|
||||
|
||||
defaults().padBottom(d < 2 ? -5.5f : 0);
|
||||
|
||||
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.inPixels(10*3), ()->{
|
||||
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.scl(10*3), ()->{
|
||||
control.getInput().resetCursor();
|
||||
player.breakMode = mode;
|
||||
}){{
|
||||
group.add(get());
|
||||
}}.units(Unit.dp);
|
||||
}};
|
||||
}
|
||||
|
||||
}}.end();
|
||||
|
||||
@@ -17,16 +17,16 @@ public class ToolFragment implements Fragment{
|
||||
|
||||
public void build(){
|
||||
tools = new Table();
|
||||
tools.addIButton("icon-cancel", Unit.dp.inPixels(42), ()->{
|
||||
tools.addIButton("icon-cancel", Unit.dp.scl(42), ()->{
|
||||
player.recipe = null;
|
||||
});
|
||||
|
||||
tools.addIButton("icon-rotate", Unit.dp.inPixels(42), ()->{
|
||||
tools.addIButton("icon-rotate", Unit.dp.scl(42), ()->{
|
||||
player.rotation ++;
|
||||
player.rotation %= 4;
|
||||
});
|
||||
|
||||
tools.addIButton("icon-check", Unit.dp.inPixels(42), ()->{
|
||||
tools.addIButton("icon-check", Unit.dp.scl(42), ()->{
|
||||
player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY());
|
||||
});
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class Sorter extends Junction implements Configurable{
|
||||
public void buildTable(Tile tile, Table table){
|
||||
SorterEntity entity = tile.entity();
|
||||
|
||||
table.addIButton("icon-arrow-left", Unit.dp.inPixels(10*3), ()->{
|
||||
table.addIButton("icon-arrow-left", Unit.dp.scl(10*3), ()->{
|
||||
int color = entity.sortItem.ordinal();
|
||||
|
||||
color --;
|
||||
@@ -103,9 +103,9 @@ public class Sorter extends Junction implements Configurable{
|
||||
entity.sortItem = Item.values()[color];
|
||||
});
|
||||
|
||||
table.add().size(40f).units(Unit.dp);
|
||||
table.add().size(40f);
|
||||
|
||||
table.addIButton("icon-arrow-right", Unit.dp.inPixels(10*3), ()->{
|
||||
table.addIButton("icon-arrow-right", Unit.dp.scl(10*3), ()->{
|
||||
int color = entity.sortItem.ordinal();
|
||||
|
||||
color ++;
|
||||
|
||||
@@ -69,13 +69,13 @@ public class Teleporter extends Block implements Configurable{
|
||||
public void buildTable(Tile tile, Table table){
|
||||
TeleporterEntity entity = tile.entity();
|
||||
|
||||
table.addIButton("icon-arrow-left", Unit.dp.inPixels(10*3), ()->{
|
||||
table.addIButton("icon-arrow-left", Unit.dp.scl(10*3), ()->{
|
||||
entity.color = (byte)Mathf.mod(entity.color - 1, colors);
|
||||
});
|
||||
|
||||
table.add().size(40f).units(Unit.dp);
|
||||
table.add().size(40f);
|
||||
|
||||
table.addIButton("icon-arrow-right", Unit.dp.inPixels(10*3), ()->{
|
||||
table.addIButton("icon-arrow-right", Unit.dp.scl(10*3), ()->{
|
||||
entity.color = (byte)Mathf.mod(entity.color + 1, colors);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user