Death to unit.dp
This commit is contained in:
@@ -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());
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user