Merge branch 'master' into crater

# Conflicts:
#	core/assets/sprites/sprites.atlas
#	core/assets/sprites/sprites.png
#	core/assets/sprites/sprites2.png
#	core/assets/sprites/sprites3.png
This commit is contained in:
Patrick 'Quezler' Mounier
2020-04-23 21:10:48 +02:00
140 changed files with 6579 additions and 6547 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
return (Float.isNaN(result) || Float.isInfinite(result)) ? 1f : Mathf.clamp(result, 0.0001f, 60f / 10f);
});
batch = new SpriteBatch();
batch = new SortedSpriteBatch();
assets = new AssetManager();
assets.setLoader(Texture.class, "." + mapExtension, new MapPreviewLoader());
+1 -1
View File
@@ -988,7 +988,7 @@ public class Blocks implements ContentList{
consumes.power(1.75f);
}};
massConveyor = new MassConveyor("mass-conveyor"){{
massConveyor = new PayloadConveyor("mass-conveyor"){{
requirements(Category.distribution, ItemStack.with(Items.copper, 1));
}};
+4 -4
View File
@@ -193,7 +193,7 @@ public class Control implements ApplicationListener, Loadable{
public void loadAsync(){
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
Core.input.setCatch(KeyCode.BACK, true);
Core.input.setCatch(KeyCode.back, true);
data.load();
@@ -400,9 +400,9 @@ public class Control implements ApplicationListener, Loadable{
}).pad(10f).expand().center();
dialog.buttons.defaults().size(200f, 60f);
dialog.buttons.addButton("$uiscale.cancel", exit);
dialog.buttons.button("$uiscale.cancel", exit);
dialog.buttons.addButton("$ok", () -> {
dialog.buttons.button("$ok", () -> {
Core.settings.put("uiscalechanged", false);
settings.save();
dialog.hide();
@@ -494,7 +494,7 @@ public class Control implements ApplicationListener, Loadable{
Time.update();
}
if(!scene.hasDialog() && !scene.root.getChildren().isEmpty() && !(scene.root.getChildren().peek() instanceof Dialog) && Core.input.keyTap(KeyCode.BACK)){
if(!scene.hasDialog() && !scene.root.getChildren().isEmpty() && !(scene.root.getChildren().peek() instanceof Dialog) && Core.input.keyTap(KeyCode.back)){
platform.hide();
}
}
+34 -71
View File
@@ -25,7 +25,7 @@ public class Renderer implements ApplicationListener{
public final LightRenderer lights = new LightRenderer();
public final Pixelator pixelator = new Pixelator();
public FrameBuffer effectBuffer = new FrameBuffer(2, 2);
public FrameBuffer effectBuffer = new FrameBuffer();
private Bloom bloom;
private FxProcessor fx = new FxProcessor();
private Color clearColor = new Color(0f, 0f, 0f, 1f);
@@ -181,91 +181,56 @@ public class Renderer implements ApplicationListener{
graphics.clear(clearColor);
if(!graphics.isHidden() && (Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")) && (effectBuffer.getWidth() != graphics.getWidth() || effectBuffer.getHeight() != graphics.getHeight())){
//TODO 'animated water' is a bad name for this setting
if(Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")){
effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
}
Draw.proj(camera);
beginFx();
drawBackground();
blocks.floor.checkChanges();
blocks.floor.drawFloor();
Groups.drawFloor();
Groups.drawFloorOver();
blocks.processBlocks();
blocks.drawShadows();
Draw.color();
blocks.floor.beginDraw();
blocks.floor.drawLayer(CacheLayer.walls);
blocks.floor.endDraw();
Draw.sort(true);
blocks.drawBlocks(Layer.block);
if(state.rules.drawFog){
blocks.drawFog();
}
//TODO fx
blocks.drawDestroyed();
Draw.draw(Layer.background, this::drawBackground);
Draw.draw(Layer.floor, blocks.floor::drawFloor);
Draw.draw(Layer.block - 1, blocks::drawShadows);
Draw.draw(Layer.block, () -> {
blocks.floor.beginDraw();
blocks.floor.drawLayer(CacheLayer.walls);
blocks.floor.endDraw();
});
Draw.shader(Shaders.blockbuild, true);
blocks.drawBlocks(Layer.placement);
Draw.shader();
blocks.drawBlocks(Layer.overlay);
Groups.drawGroundShadows();
Groups.drawGroundUnder();
Groups.drawGround();
blocks.drawBlocks(Layer.turret);
blocks.drawBlocks(Layer.power);
blocks.drawBlocks(Layer.lights);
overlays.drawBottom();
Groups.drawFlyingShadows();
Groups.drawFlying();
Draw.flush();
if(bloom != null){
bloom.capture();
}
Groups.drawBullets();
Groups.drawEffects();
Draw.flush();
if(bloom != null){
bloom.render();
}
Groups.drawOverlays();
overlays.drawTop();
Groups.drawWeather();
endFx();
if(!pixelator.enabled()){
Groups.drawNames();
}
Draw.drawRange(Layer.blockBuilding, () -> Draw.shader(Shaders.blockbuild, false), Draw::shader);
if(state.rules.lighting){
lights.draw();
Draw.draw(Layer.light, lights::draw);
}
drawLanding();
if(state.rules.drawDarkness){
Draw.draw(Layer.darkness, blocks::drawDarkness);
}
Draw.color();
if(bloom != null){
Draw.draw(Layer.bullet - 0.001f, bloom::capture);
Draw.draw(Layer.effect + 0.001f, bloom::render);
}
Draw.draw(Layer.plans, overlays::drawBottom);
Draw.draw(Layer.overlayUI, overlays::drawTop);
Draw.draw(Layer.space, this::drawLanding);
blocks.drawBlocks();
Groups.draw.draw(Drawc::draw);
Draw.reset();
Draw.flush();
Draw.sort(false);
}
private void drawBackground(){
@@ -322,8 +287,6 @@ public class Renderer implements ApplicationListener{
}
public void takeMapScreenshot(){
Groups.drawGroundShadows();
int w = world.width() * tilesize, h = world.height() * tilesize;
int memory = w * h * 4 / 1024 / 1024;
+35 -30
View File
@@ -129,7 +129,7 @@ public class UI implements ApplicationListener, Loadable{
Core.scene.act();
Core.scene.draw();
if(Core.input.keyTap(KeyCode.MOUSE_LEFT) && Core.scene.getKeyboardFocus() instanceof TextField){
if(Core.input.keyTap(KeyCode.mouseLeft) && Core.scene.getKeyboardFocus() instanceof TextField){
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
if(!(e instanceof TextField)){
Core.scene.setKeyboardFocus(null);
@@ -249,23 +249,23 @@ public class UI implements ApplicationListener, Loadable{
new Dialog(titleText){{
cont.margin(30).add(dtext).padRight(6f);
TextFieldFilter filter = inumeric ? TextFieldFilter.digitsOnly : (f, c) -> true;
TextField field = cont.addField(def, t -> {}).size(330f, 50f).get();
TextField field = cont.field(def, t -> {}).size(330f, 50f).get();
field.setFilter((f, c) -> field.getText().length() < textLength && filter.acceptChar(f, c));
buttons.defaults().size(120, 54).pad(4);
buttons.addButton("$ok", () -> {
buttons.button("$ok", () -> {
confirmed.get(field.getText());
hide();
}).disabled(b -> field.getText().isEmpty());
buttons.addButton("$cancel", this::hide);
keyDown(KeyCode.ENTER, () -> {
buttons.button("$cancel", this::hide);
keyDown(KeyCode.enter, () -> {
String text = field.getText();
if(!text.isEmpty()){
confirmed.get(text);
hide();
}
});
keyDown(KeyCode.ESCAPE, this::hide);
keyDown(KeyCode.BACK, this::hide);
keyDown(KeyCode.escape, this::hide);
keyDown(KeyCode.back, this::hide);
show();
Core.scene.setKeyboardFocus(field);
field.setCursorPosition(def.length());
@@ -328,6 +328,7 @@ public class UI implements ApplicationListener, Loadable{
Vec2 v = Core.camera.project(worldx, worldy);
t.setPosition(v.x, v.y, Align.center);
});
table.act(0f);
//make sure it's at the back
Core.scene.root.addChildAt(0, table);
}
@@ -336,7 +337,7 @@ public class UI implements ApplicationListener, Loadable{
new Dialog(""){{
getCell(cont).growX();
cont.margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
buttons.button("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}
@@ -346,11 +347,11 @@ public class UI implements ApplicationListener, Loadable{
cont.margin(15f);
cont.add("$error.title");
cont.row();
cont.addImage().width(300f).pad(2).height(4f).color(Color.scarlet);
cont.image().width(300f).pad(2).height(4f).color(Color.scarlet);
cont.row();
cont.add(text).pad(2f).growX().wrap().get().setAlignment(Align.center);
cont.row();
cont.addButton("$ok", this::hide).size(120, 50).pad(4);
cont.button("$ok", this::hide).size(120, 50).pad(4);
}}.show();
}
@@ -367,15 +368,15 @@ public class UI implements ApplicationListener, Loadable{
cont.margin(15);
cont.add("$error.title").colspan(2);
cont.row();
cont.addImage().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
cont.image().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
cont.row();
cont.add((text.startsWith("$") ? Core.bundle.get(text.substring(1)) : text) + (message == null ? "" : "\n[lightgray](" + message + ")")).colspan(2).wrap().growX().center().get().setAlignment(Align.center);
cont.row();
Collapser col = new Collapser(base -> base.pane(t -> t.margin(14f).add(Strings.parseException(exc, true)).color(Color.lightGray).left()), true);
cont.addButton("$details", Styles.togglet, col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().right();
cont.addButton("$ok", this::hide).size(110, 50).fillX().left();
cont.button("$details", Styles.togglet, col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().right();
cont.button("$ok", this::hide).size(110, 50).fillX().left();
cont.row();
cont.add(col).colspan(2).pad(2);
}}.show();
@@ -389,7 +390,7 @@ public class UI implements ApplicationListener, Loadable{
cont.margin(15);
cont.add("$error.title").colspan(2);
cont.row();
cont.addImage().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
cont.image().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
cont.row();
cont.add(text).colspan(2).wrap().growX().center().get().setAlignment(Align.center);
cont.row();
@@ -401,14 +402,14 @@ public class UI implements ApplicationListener, Loadable{
Collapser col = new Collapser(base -> base.pane(t -> t.margin(14f).add(details).color(Color.lightGray).left()), true);
cont.add(btext).right();
cont.addButton("$details", Styles.togglet, col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().left();
cont.button("$details", Styles.togglet, col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().left();
cont.row();
cont.add(col).colspan(2).pad(2);
cont.row();
}
//}).colspan(2);
cont.addButton("$ok", this::hide).size(300, 50).fillX().colspan(2);
cont.button("$ok", this::hide).size(300, 50).fillX().colspan(2);
}}.show();
}
@@ -419,18 +420,18 @@ public class UI implements ApplicationListener, Loadable{
public void showText(String titleText, String text, int align){
new Dialog(titleText){{
cont.row();
cont.addImage().width(400f).pad(2).colspan(2).height(4f).color(Pal.accent);
cont.image().width(400f).pad(2).colspan(2).height(4f).color(Pal.accent);
cont.row();
cont.add(text).width(400f).wrap().get().setAlignment(align, align);
cont.row();
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
buttons.button("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}
public void showInfoText(String titleText, String text){
new Dialog(titleText){{
cont.margin(15).add(text).width(400f).wrap().left().get().setAlignment(Align.left, Align.left);
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
buttons.button("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}
@@ -438,8 +439,8 @@ public class UI implements ApplicationListener, Loadable{
new Dialog(titleText){{
cont.margin(10).add(text);
titleTable.row();
titleTable.addImage().color(Pal.accent).height(3f).growX().pad(2f);
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
titleTable.image().color(Pal.accent).height(3f).growX().pad(2f);
buttons.button("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}
@@ -452,8 +453,8 @@ public class UI implements ApplicationListener, Loadable{
dialog.cont.add(text).width(mobile ? 400f : 500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.buttons.defaults().size(200f, 54f).pad(2f);
dialog.setFillParent(false);
dialog.buttons.addButton("$cancel", dialog::hide);
dialog.buttons.addButton("$ok", () -> {
dialog.buttons.button("$cancel", dialog::hide);
dialog.buttons.button("$ok", () -> {
dialog.hide();
confirmed.run();
});
@@ -464,8 +465,12 @@ public class UI implements ApplicationListener, Loadable{
}
});
}
dialog.keyDown(KeyCode.ESCAPE, dialog::hide);
dialog.keyDown(KeyCode.BACK, dialog::hide);
dialog.keyDown(KeyCode.enter, () -> {
dialog.hide();
confirmed.run();
});
dialog.keyDown(KeyCode.escape, dialog::hide);
dialog.keyDown(KeyCode.back, dialog::hide);
dialog.show();
}
@@ -474,16 +479,16 @@ public class UI implements ApplicationListener, Loadable{
dialog.cont.add(text).width(mobile ? 400f : 500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.buttons.defaults().size(200f, 54f).pad(2f);
dialog.setFillParent(false);
dialog.buttons.addButton(no, () -> {
dialog.buttons.button(no, () -> {
dialog.hide();
denied.run();
});
dialog.buttons.addButton(yes, () -> {
dialog.buttons.button(yes, () -> {
dialog.hide();
confirmed.run();
});
dialog.keyDown(KeyCode.ESCAPE, dialog::hide);
dialog.keyDown(KeyCode.BACK, dialog::hide);
dialog.keyDown(KeyCode.escape, dialog::hide);
dialog.keyDown(KeyCode.back, dialog::hide);
dialog.show();
}
@@ -492,7 +497,7 @@ public class UI implements ApplicationListener, Loadable{
dialog.cont.add(text).width(500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.buttons.defaults().size(200f, 54f).pad(2f);
dialog.setFillParent(false);
dialog.buttons.addButton("$ok", () -> {
dialog.buttons.button("$ok", () -> {
dialog.hide();
confirmed.run();
});
+28 -28
View File
@@ -66,28 +66,28 @@ public class MapEditorDialog extends Dialog implements Disposable{
menu.cont.table(t -> {
t.defaults().size(swidth, 60f).padBottom(5).padRight(5).padLeft(5);
t.addImageTextButton("$editor.savemap", Icon.save, this::save);
t.button("$editor.savemap", Icon.save, this::save);
t.addImageTextButton("$editor.mapinfo", Icon.pencil, () -> {
t.button("$editor.mapinfo", Icon.pencil, () -> {
infoDialog.show();
menu.hide();
});
t.row();
t.addImageTextButton("$editor.generate", Icon.terrain, () -> {
t.button("$editor.generate", Icon.terrain, () -> {
generateDialog.show(generateDialog::applyToEditor);
menu.hide();
});
t.addImageTextButton("$editor.resize", Icon.resize, () -> {
t.button("$editor.resize", Icon.resize, () -> {
resizeDialog.show();
menu.hide();
});
t.row();
t.addImageTextButton("$editor.import", Icon.download, () -> createDialog("$editor.import",
t.button("$editor.import", Icon.download, () -> createDialog("$editor.import",
"$editor.importmap", "$editor.importmap.description", Icon.download, (Runnable)loadDialog::show,
"$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() ->
platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> {
@@ -114,7 +114,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
})))
);
t.addImageTextButton("$editor.export", Icon.upload, () -> createDialog("$editor.export",
t.button("$editor.export", Icon.upload, () -> createDialog("$editor.export",
"$editor.exportfile", "$editor.exportfile.description", Icon.file,
(Runnable)() -> platform.export(editor.getTags().get("name", "unknown"), mapExtension, file -> MapIO.writeMap(file, editor.createMap(file))),
"$editor.exportimage", "$editor.exportimage.description", Icon.fileImage,
@@ -128,7 +128,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
menu.cont.row();
if(steam){
menu.cont.addImageTextButton("$editor.publish.workshop", Icon.link, () -> {
menu.cont.button("$editor.publish.workshop", Icon.link, () -> {
Map builtin = maps.all().find(m -> m.name().equals(editor.getTags().get("name", "").trim()));
if(editor.getTags().containsKey("steamid") && builtin != null && !builtin.custom){
@@ -161,11 +161,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
menu.cont.row();
}
menu.cont.addImageTextButton("$editor.ingame", Icon.right, this::playtest).padTop(!steam ? -3 : 1).size(swidth * 2f + 10, 60f);
menu.cont.button("$editor.ingame", Icon.right, this::playtest).padTop(!steam ? -3 : 1).size(swidth * 2f + 10, 60f);
menu.cont.row();
menu.cont.addImageTextButton("$quit", Icon.exit, () -> {
menu.cont.button("$quit", Icon.exit, () -> {
tryExit();
menu.hide();
}).size(swidth * 2f + 10, 60f);
@@ -321,14 +321,14 @@ public class MapEditorDialog extends Dialog implements Disposable{
Drawable iconname = (Drawable)arguments[i + 2];
Runnable listenable = (Runnable)arguments[i + 3];
TextButton button = dialog.cont.addButton(name, () -> {
TextButton button = dialog.cont.button(name, () -> {
listenable.run();
dialog.hide();
menu.hide();
}).left().margin(0).get();
button.clearChildren();
button.addImage(iconname).padLeft(10);
button.image(iconname).padLeft(10);
button.table(t -> {
t.add(name).growX().wrap();
t.row();
@@ -419,7 +419,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
button.clicked(l -> {
if(!mobile){
//desktop: rightclick
l.setButton(KeyCode.MOUSE_RIGHT);
l.setButton(KeyCode.mouseRight);
}
}, e -> {
//need to double tap
@@ -438,7 +438,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
int mode = i;
String name = tool.altModes[i];
table.addButton(b -> {
table.button(b -> {
b.left();
b.marginLeft(6);
b.setStyle(Styles.clearTogglet);
@@ -481,16 +481,16 @@ public class MapEditorDialog extends Dialog implements Disposable{
tools.defaults().size(size, size);
tools.addImageButton(Icon.menu, Styles.cleari, menu::show);
tools.button(Icon.menu, Styles.cleari, menu::show);
ImageButton grid = tools.addImageButton(Icon.grid, Styles.clearTogglei, () -> view.setGrid(!view.isGrid())).get();
ImageButton grid = tools.button(Icon.grid, Styles.clearTogglei, () -> view.setGrid(!view.isGrid())).get();
addTool.get(EditorTool.zoom);
tools.row();
ImageButton undo = tools.addImageButton(Icon.undo, Styles.cleari, editor::undo).get();
ImageButton redo = tools.addImageButton(Icon.redo, Styles.cleari, editor::redo).get();
ImageButton undo = tools.button(Icon.undo, Styles.cleari, editor::undo).get();
ImageButton redo = tools.button(Icon.redo, Styles.cleari, editor::redo).get();
addTool.get(EditorTool.pick);
@@ -512,7 +512,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
addTool.get(EditorTool.fill);
addTool.get(EditorTool.spray);
ImageButton rotate = tools.addImageButton(Icon.right, Styles.cleari, () -> editor.rotation = (editor.rotation + 1) % 4).get();
ImageButton rotate = tools.button(Icon.right, Styles.cleari, () -> editor.rotation = (editor.rotation + 1) % 4).get();
rotate.getImage().update(() -> {
rotate.getImage().setRotation(editor.rotation * 90);
rotate.getImage().setOrigin(Align.center);
@@ -576,14 +576,14 @@ public class MapEditorDialog extends Dialog implements Disposable{
if(Core.input.ctrl()){
//alt mode select
for(int i = 0; i < view.getTool().altModes.length + 1; i++){
if(Core.input.keyTap(KeyCode.valueOf("NUM_" + (i + 1)))){
if(Core.input.keyTap(KeyCode.valueOf("num" + (i + 1)))){
view.getTool().mode = i - 1;
}
}
}else{
//tool select
for(int i = 0; i < EditorTool.values().length; i++){
if(Core.input.keyTap(KeyCode.valueOf("NUM_" + (i + 1)))){
if(Core.input.keyTap(KeyCode.valueOf("num" + (i + 1)))){
view.setTool(EditorTool.values()[i]);
break;
}
@@ -591,28 +591,28 @@ public class MapEditorDialog extends Dialog implements Disposable{
}
if(Core.input.keyTap(KeyCode.ESCAPE)){
if(Core.input.keyTap(KeyCode.escape)){
if(!menu.isShown()){
menu.show();
}
}
if(Core.input.keyTap(KeyCode.R)){
if(Core.input.keyTap(KeyCode.r)){
editor.rotation = Mathf.mod(editor.rotation + 1, 4);
}
if(Core.input.keyTap(KeyCode.E)){
if(Core.input.keyTap(KeyCode.e)){
editor.rotation = Mathf.mod(editor.rotation - 1, 4);
}
//ctrl keys (undo, redo, save)
if(Core.input.ctrl()){
if(Core.input.keyTap(KeyCode.Z)){
if(Core.input.keyTap(KeyCode.z)){
editor.undo();
}
//more undocumented features, fantastic
if(Core.input.keyTap(KeyCode.T)){
if(Core.input.keyTap(KeyCode.t)){
//clears all 'decoration' from the map
for(int x = 0; x < editor.width(); x++){
@@ -633,15 +633,15 @@ public class MapEditorDialog extends Dialog implements Disposable{
editor.flushOp();
}
if(Core.input.keyTap(KeyCode.Y)){
if(Core.input.keyTap(KeyCode.y)){
editor.redo();
}
if(Core.input.keyTap(KeyCode.S)){
if(Core.input.keyTap(KeyCode.s)){
save();
}
if(Core.input.keyTap(KeyCode.G)){
if(Core.input.keyTap(KeyCode.g)){
view.setGrid(!view.isGrid());
}
}
@@ -66,27 +66,27 @@ public class MapGenerateDialog extends FloatingDialog{
shown(this::setup);
addCloseButton();
if(applied){
buttons.addButton("$editor.apply", () -> {
buttons.button("$editor.apply", () -> {
ui.loadAnd(() -> {
apply();
hide();
});
}).size(160f, 64f);
}else{
buttons.addButton("$settings.reset", () -> {
buttons.button("$settings.reset", () -> {
filters.set(maps.readFilters(""));
rebuildFilters();
update();
}).size(160f, 64f);
}
buttons.addButton("$editor.randomize", () -> {
buttons.button("$editor.randomize", () -> {
for(GenerateFilter filter : filters){
filter.randomize();
}
update();
}).size(160f, 64f);
buttons.addImageTextButton("$add", Icon.add, this::showAdd).height(64f).width(140f);
buttons.button("$add", Icon.add, this::showAdd).height(64f).width(140f);
if(!applied){
hidden(this::apply);
@@ -234,24 +234,24 @@ public class MapGenerateDialog extends FloatingDialog{
t.table(b -> {
ImageButtonStyle style = Styles.cleari;
b.defaults().size(50f);
b.addImageButton(Icon.refresh, style, () -> {
b.button(Icon.refresh, style, () -> {
filter.randomize();
update();
});
b.addImageButton(Icon.upOpen, style, () -> {
b.button(Icon.upOpen, style, () -> {
int idx = filters.indexOf(filter);
filters.swap(idx, Math.max(0, idx - 1));
rebuildFilters();
update();
});
b.addImageButton(Icon.downOpen, style, () -> {
b.button(Icon.downOpen, style, () -> {
int idx = filters.indexOf(filter);
filters.swap(idx, Math.min(filters.size - 1, idx + 1));
rebuildFilters();
update();
});
b.addImageButton(Icon.trash, style, () -> {
b.button(Icon.trash, style, () -> {
filters.remove(filter);
rebuildFilters();
update();
@@ -293,7 +293,7 @@ public class MapGenerateDialog extends FloatingDialog{
if((!applied && filter.isBuffered()) || (filter.isPost() && applied)) continue;
selection.cont.addButton(filter.name(), () -> {
selection.cont.button(filter.name(), () -> {
filters.add(filter);
rebuildFilters();
update();
@@ -302,7 +302,7 @@ public class MapGenerateDialog extends FloatingDialog{
if(++i % 2 == 0) selection.cont.row();
}
selection.cont.addButton("$filter.defaultores", () -> {
selection.cont.button("$filter.defaultores", () -> {
maps.addDefaultOres(filters);
rebuildFilters();
update();
+6 -6
View File
@@ -35,7 +35,7 @@ public class MapInfoDialog extends FloatingDialog{
t.add("$editor.mapname").padRight(8).left();
t.defaults().padTop(15);
TextField name = t.addField(tags.get("name", ""), text -> {
TextField name = t.field(tags.get("name", ""), text -> {
tags.put("name", text);
}).size(400, 55f).get();
name.setMessageText("$unknown");
@@ -43,14 +43,14 @@ public class MapInfoDialog extends FloatingDialog{
t.row();
t.add("$editor.description").padRight(8).left();
TextArea description = t.addArea(tags.get("description", ""), Styles.areaField, text -> {
TextArea description = t.area(tags.get("description", ""), Styles.areaField, text -> {
tags.put("description", text);
}).size(400f, 140f).get();
t.row();
t.add("$editor.author").padRight(8).left();
TextField author = t.addField(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> {
TextField author = t.field(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> {
tags.put("author", text);
Core.settings.put("mapAuthor", text);
Core.settings.save();
@@ -59,21 +59,21 @@ public class MapInfoDialog extends FloatingDialog{
t.row();
t.add("$editor.rules").padRight(8).left();
t.addButton("$edit", () -> {
t.button("$edit", () -> {
ruleInfo.show(Vars.state.rules, () -> Vars.state.rules = new Rules());
hide();
}).left().width(200f);
t.row();
t.add("$editor.waves").padRight(8).left();
t.addButton("$edit", () -> {
t.button("$edit", () -> {
waveInfo.show();
hide();
}).left().width(200f);
t.row();
t.add("$editor.generation").padRight(8).left();
t.addButton("$edit", () -> {
t.button("$edit", () -> {
generate.show(Vars.maps.readFilters(editor.getTags().get("genfilters", "")),
filters -> editor.getTags().put("genfilters", JsonIO.write(filters)));
hide();
+1 -1
View File
@@ -28,7 +28,7 @@ public class MapLoadDialog extends FloatingDialog{
});
buttons.defaults().size(200f, 50f);
buttons.addButton("$cancel", this::hide);
buttons.button("$cancel", this::hide);
buttons.add(button);
}
@@ -22,7 +22,7 @@ public class MapResizeDialog extends FloatingDialog{
for(boolean w : Mathf.booleans){
table.add(w ? "$width" : "$height").padRight(8f);
table.defaults().height(60f).padTop(8);
table.addButton("<", () -> {
table.button("<", () -> {
if(w)
width = move(width, -1);
else
@@ -31,7 +31,7 @@ public class MapResizeDialog extends FloatingDialog{
table.table(Tex.button, t -> t.label(() -> (w ? width : height) + "")).width(200);
table.addButton(">", () -> {
table.button(">", () -> {
if(w)
width = move(width, 1);
else
@@ -45,8 +45,8 @@ public class MapResizeDialog extends FloatingDialog{
});
buttons.defaults().size(200f, 50f);
buttons.addButton("$cancel", this::hide);
buttons.addButton("$ok", () -> {
buttons.button("$cancel", this::hide);
buttons.button("$ok", () -> {
cons.get(width, height);
hide();
});
+1 -1
View File
@@ -38,7 +38,7 @@ public class MapSaveDialog extends FloatingDialog{
});
buttons.defaults().size(200f, 50f).pad(2f);
buttons.addButton("$cancel", this::hide);
buttons.button("$cancel", this::hide);
TextButton button = new TextButton("$save");
button.clicked(() -> {
+8 -8
View File
@@ -72,11 +72,11 @@ public class MapView extends Element implements GestureListener{
return false;
}
if(!mobile && button != KeyCode.MOUSE_LEFT && button != KeyCode.MOUSE_MIDDLE){
if(!mobile && button != KeyCode.mouseLeft && button != KeyCode.mouseMiddle){
return true;
}
if(button == KeyCode.MOUSE_MIDDLE){
if(button == KeyCode.mouseMiddle){
lastTool = tool;
tool = EditorTool.zoom;
}
@@ -102,7 +102,7 @@ public class MapView extends Element implements GestureListener{
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, KeyCode button){
if(!mobile && button != KeyCode.MOUSE_LEFT && button != KeyCode.MOUSE_MIDDLE){
if(!mobile && button != KeyCode.mouseLeft && button != KeyCode.mouseMiddle){
return;
}
@@ -117,7 +117,7 @@ public class MapView extends Element implements GestureListener{
editor.flushOp();
if(button == KeyCode.MOUSE_MIDDLE && lastTool != null){
if(button == KeyCode.mouseMiddle && lastTool != null){
tool = lastTool;
lastTool = null;
}
@@ -172,26 +172,26 @@ public class MapView extends Element implements GestureListener{
public void act(float delta){
super.act(delta);
if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) && !Core.input.keyDown(KeyCode.CONTROL_LEFT)){
if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) && !Core.input.keyDown(KeyCode.controlLeft)){
float ax = Core.input.axis(Binding.move_x);
float ay = Core.input.axis(Binding.move_y);
offsetx -= ax * 15f / zoom;
offsety -= ay * 15f / zoom;
}
if(Core.input.keyTap(KeyCode.SHIFT_LEFT)){
if(Core.input.keyTap(KeyCode.shiftLeft)){
lastTool = tool;
tool = EditorTool.pick;
}
if(Core.input.keyRelease(KeyCode.SHIFT_LEFT) && lastTool != null){
if(Core.input.keyRelease(KeyCode.shiftLeft) && lastTool != null){
tool = lastTool;
lastTool = null;
}
if(Core.scene.getScrollFocus() != this) return;
zoom += Core.input.axis(KeyCode.SCROLL) / 10f * zoom;
zoom += Core.input.axis(KeyCode.scroll) / 10f * zoom;
clampZoom();
}
+20 -20
View File
@@ -42,24 +42,24 @@ public class WaveInfoDialog extends FloatingDialog{
});
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK){
if(key == KeyCode.escape || key == KeyCode.back){
Core.app.post(this::hide);
}
});
addCloseButton();
buttons.addButton("$waves.edit", () -> {
buttons.button("$waves.edit", () -> {
FloatingDialog dialog = new FloatingDialog("$waves.edit");
dialog.addCloseButton();
dialog.setFillParent(false);
dialog.cont.defaults().size(210f, 64f);
dialog.cont.addButton("$waves.copy", () -> {
dialog.cont.button("$waves.copy", () -> {
ui.showInfoFade("$waves.copied");
Core.app.setClipboardText(maps.writeWaves(groups));
dialog.hide();
}).disabled(b -> groups == null);
dialog.cont.row();
dialog.cont.addButton("$waves.load", () -> {
dialog.cont.button("$waves.load", () -> {
try{
groups = maps.readWaves(Core.app.getClipboardText());
buildGroups();
@@ -70,7 +70,7 @@ public class WaveInfoDialog extends FloatingDialog{
dialog.hide();
}).disabled(b -> Core.app.getClipboardText() == null || Core.app.getClipboardText().isEmpty());
dialog.cont.row();
dialog.cont.addButton("$settings.reset", () -> ui.showConfirm("$confirm", "$settings.clear.confirm", () -> {
dialog.cont.button("$settings.reset", () -> ui.showConfirm("$confirm", "$settings.clear.confirm", () -> {
groups = JsonIO.copy(defaultWaves.get());
buildGroups();
dialog.hide();
@@ -86,7 +86,7 @@ public class WaveInfoDialog extends FloatingDialog{
cont.stack(new Table(Tex.clear, main -> {
main.pane(t -> table = t).growX().growY().padRight(8f).get().setScrollingDisabled(true, false);
main.row();
main.addButton("$add", () -> {
main.button("$add", () -> {
if(groups == null) groups = new Array<>();
groups.add(new SpawnGroup(lastType));
buildGroups();
@@ -101,7 +101,7 @@ public class WaveInfoDialog extends FloatingDialog{
cont.table(Tex.clear, m -> {
m.add("$waves.preview").color(Color.lightGray).growX().center().get().setAlignment(Align.center, Align.center);
m.row();
m.addButton("-", () -> {
m.button("-", () -> {
}).update(t -> {
if(t.getClickListener().isPressed()){
updateTimer += Time.delta();
@@ -115,7 +115,7 @@ public class WaveInfoDialog extends FloatingDialog{
m.row();
m.pane(t -> preview = t).grow().get().setScrollingDisabled(true, true);
m.row();
m.addButton("+", () -> {
m.button("+", () -> {
}).update(t -> {
if(t.getClickListener().isPressed()){
updateTimer += Time.delta();
@@ -140,22 +140,22 @@ public class WaveInfoDialog extends FloatingDialog{
for(SpawnGroup group : groups){
table.table(Tex.button, t -> {
t.margin(0).defaults().pad(3).padLeft(5f).growX().left();
t.addButton(b -> {
t.button(b -> {
b.left();
b.addImage(group.type.icon(mindustry.ui.Cicon.medium)).size(32f).padRight(3);
b.image(group.type.icon(mindustry.ui.Cicon.medium)).size(32f).padRight(3);
b.add(group.type.localizedName).color(Pal.accent);
}, () -> showUpdate(group)).pad(-6f).padBottom(0f);
t.row();
t.table(spawns -> {
spawns.addField("" + (group.begin + 1), TextFieldFilter.digitsOnly, text -> {
spawns.field("" + (group.begin + 1), TextFieldFilter.digitsOnly, text -> {
if(Strings.canParsePostiveInt(text)){
group.begin = Strings.parseInt(text) - 1;
updateWaves();
}
}).width(100f);
spawns.add("$waves.to").padLeft(4).padRight(4);
spawns.addField(group.end == never ? "" : (group.end + 1) + "", TextFieldFilter.digitsOnly, text -> {
spawns.field(group.end == never ? "" : (group.end + 1) + "", TextFieldFilter.digitsOnly, text -> {
if(Strings.canParsePostiveInt(text)){
group.end = Strings.parseInt(text) - 1;
updateWaves();
@@ -168,7 +168,7 @@ public class WaveInfoDialog extends FloatingDialog{
t.row();
t.table(p -> {
p.add("$waves.every").padRight(4);
p.addField(group.spacing + "", TextFieldFilter.digitsOnly, text -> {
p.field(group.spacing + "", TextFieldFilter.digitsOnly, text -> {
if(Strings.canParsePostiveInt(text) && Strings.parseInt(text) > 0){
group.spacing = Strings.parseInt(text);
updateWaves();
@@ -179,7 +179,7 @@ public class WaveInfoDialog extends FloatingDialog{
t.row();
t.table(a -> {
a.addField(group.unitAmount + "", TextFieldFilter.digitsOnly, text -> {
a.field(group.unitAmount + "", TextFieldFilter.digitsOnly, text -> {
if(Strings.canParsePostiveInt(text)){
group.unitAmount = Strings.parseInt(text);
updateWaves();
@@ -187,7 +187,7 @@ public class WaveInfoDialog extends FloatingDialog{
}).width(80f);
a.add(" + ");
a.addField(Strings.fixed(Math.max((Mathf.zero(group.unitScaling) ? 0 : 1f / group.unitScaling), 0), 2), TextFieldFilter.floatsOnly, text -> {
a.field(Strings.fixed(Math.max((Mathf.zero(group.unitScaling) ? 0 : 1f / group.unitScaling), 0), 2), TextFieldFilter.floatsOnly, text -> {
if(Strings.canParsePositiveFloat(text)){
group.unitScaling = 1f / Strings.parseFloat(text);
updateWaves();
@@ -197,10 +197,10 @@ public class WaveInfoDialog extends FloatingDialog{
});
t.row();
t.addCheck("$waves.boss", b -> group.effect = (b ? StatusEffects.boss : null)).padTop(4).update(b -> b.setChecked(group.effect == StatusEffects.boss));
t.check("$waves.boss", b -> group.effect = (b ? StatusEffects.boss : null)).padTop(4).update(b -> b.setChecked(group.effect == StatusEffects.boss));
t.row();
t.addButton("$waves.remove", () -> {
t.button("$waves.remove", () -> {
groups.remove(group);
table.getCell(t).pad(0f);
t.remove();
@@ -222,9 +222,9 @@ public class WaveInfoDialog extends FloatingDialog{
dialog.cont.pane(p -> {
int i = 0;
for(UnitType type : content.units()){
p.addButton(t -> {
p.button(t -> {
t.left();
t.addImage(type.icon(mindustry.ui.Cicon.medium)).size(40f).padRight(2f);
t.image(type.icon(mindustry.ui.Cicon.medium)).size(40f).padRight(2f);
t.add(type.localizedName);
}, () -> {
lastType = type;
@@ -257,7 +257,7 @@ public class WaveInfoDialog extends FloatingDialog{
for(int j = 0; j < spawned.length; j++){
if(spawned[j] > 0){
UnitType type = content.getByID(ContentType.unit, j);
table.addImage(type.icon(Cicon.medium)).size(8f * 4f).padRight(4);
table.image(type.icon(Cicon.medium)).size(8f * 4f).padRight(4);
table.add(spawned[j] + "x").color(Color.lightGray).padRight(6);
table.row();
}
+5
View File
@@ -34,4 +34,9 @@ class AllDefs{
class sync{
}
@GroupDef(Drawc.class)
class draw{
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ public class Effects{
Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y);
if(view.overlaps(pos)){
Effectc entity = effect.ground ? GroundEffectEntity.create() : StandardEffectEntity.create();
Effectc entity = EffectEntity.create();
entity.effect(effect);
entity.rotation(rotation);
entity.data(data);
@@ -23,7 +23,7 @@ import java.util.*;
import static mindustry.Vars.*;
@Component
abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
abstract class BuilderComp implements Unitc{
static final Vec2[] vecs = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
@Import float x, y, rotation;
@@ -197,8 +197,12 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
}
@Override
public void drawFlying(){
public void draw(){
if(!isBuilding()) return;
//TODO check correctness
Draw.z(Layer.flyingUnit);
BuildRequest request = buildRequest();
Tile tile = world.tile(request.x, request.y);
@@ -1,5 +1,6 @@
package mindustry.entities.def;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
@@ -11,7 +12,7 @@ import static mindustry.Vars.*;
@EntityDef(value = {Bulletc.class}, pooled = true)
@Component
abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc, DrawLayerBulletsc{
abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{
Object data;
BulletType type;
float damage;
@@ -109,6 +110,8 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Override
public void draw(){
Draw.z(Layer.bullet);
type.draw(this);
//TODO refactor
renderer.lights.add(x(), y(), 16f, Pal.powerLight, 0.3f);
@@ -8,14 +8,14 @@ import mindustry.gen.*;
@EntityDef(value = {Decalc.class}, pooled = true)
@Component
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc, DrawLayerFloorc{
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
@Import float x, y, rotation;
Color color = new Color(1, 1, 1, 1);
TextureRegion region;
@Override
public void drawFloor(){
public void draw(){
Draw.color(color);
Draw.alpha(1f - Mathf.curve(fin(), 0.98f));
Draw.rect(region, x, y, rotation);
@@ -6,4 +6,8 @@ import mindustry.gen.*;
@Component
abstract class DrawComp implements Posc{
abstract float clipSize();
void draw(){
}
}
@@ -1,17 +1,22 @@
package mindustry.entities.def;
import arc.graphics.*;
import arc.graphics.g2d.*;
import mindustry.annotations.Annotations.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
@EntityDef(value = {Effectc.class, Childc.class}, pooled = true)
@Component
abstract class EffectComp implements Posc, Drawc, Timedc, Rotc, Childc{
Color color = new Color(Color.white);
Effect effect;
Object data;
void draw(){
@Override
public void draw(){
Draw.z(Layer.effect);
effect.render(id(), color, time(), rotation(), x(), y(), data);
}
@@ -1,14 +0,0 @@
package mindustry.entities.def;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@EntityDef(value = {GroundEffectc.class, Childc.class}, pooled = true)
@Component
abstract class GroundEffectComp implements Effectc, DrawLayerFloorOverc{
@Override
public void drawFloorOver(){
draw();
}
}
@@ -6,7 +6,7 @@ import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@Component
abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc, Unitc, Legsc, ElevationMovec{
abstract class LegsComp implements Posc, Flyingc, Hitboxc, Unitc, Legsc, ElevationMovec{
@Import float x, y;
float baseRotation;
@@ -18,9 +18,4 @@ abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc
baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed));
walkTime += Time.delta()*len/1f;
}
@Override
public void drawGroundUnder(){
type().drawLegs(this);
}
}
@@ -17,7 +17,7 @@ import mindustry.world.*;
import static mindustry.Vars.*;
@Component
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{
@Import float x, y, rotation;
transient float mineTimer;
@@ -80,7 +80,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
}
@Override
public void drawGround(){
public void draw(){
if(!mining()) return;
float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f);
float swingScl = 12f, swingMag = tilesize / 8f;
@@ -13,6 +13,7 @@ import mindustry.core.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.net.Administration.*;
import mindustry.net.*;
import mindustry.net.Packets.*;
@@ -23,7 +24,7 @@ import static mindustry.Vars.*;
@EntityDef(value = {Playerc.class}, serialize = false)
@Component
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Drawc{
@NonNull @ReadOnly Unitc unit = Nulls.unit;
@ReadOnly Team team = Team.sharded;
@@ -58,6 +59,12 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
}
}
@Override
public float clipSize(){
return 20;
}
@Override
public void update(){
if(unit.dead()){
clearUnit();
@@ -130,7 +137,10 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc{
con.kick(reason);
}
void drawName(){
@Override
public void draw(){
Draw.z(Layer.playerName);
BitmapFont font = Fonts.def;
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
final float nameHeight = 11;
@@ -10,6 +10,7 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.world.*;
@@ -18,7 +19,7 @@ import static mindustry.entities.Puddles.maxLiquid;
@EntityDef(value = {Puddlec.class}, pooled = true)
@Component
abstract class PuddleComp implements Posc, DrawLayerFloorOverc, Puddlec{
abstract class PuddleComp implements Posc, Puddlec{
private static final int maxGeneration = 2;
private static final Color tmp = new Color();
private static final Rect rect = new Rect();
@@ -89,7 +90,9 @@ abstract class PuddleComp implements Posc, DrawLayerFloorOverc, Puddlec{
}
@Override
public void drawFloorOver(){
public void draw(){
Draw.z(Layer.debris - 1);
seeds = id();
boolean onLiquid = tile.floor().isLiquid;
float f = Mathf.clamp(amount / (maxLiquid / 1.5f));
@@ -1,14 +0,0 @@
package mindustry.entities.def;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@EntityDef(value = {StandardEffectc.class, Childc.class}, pooled = true)
@Component
abstract class StandardEffectComp implements Effectc, DrawLayerEffectsc{
@Override
public void drawEffects(){
draw();
}
}
@@ -615,12 +615,6 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
}
}
public void drawLayer(){
}
public void drawLayer2(){
}
public void drawCracks(){
if(!damaged() || block.size > Block.maxCrackSize) return;
int id = pos();
@@ -824,7 +818,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
l.clearChildren();
for(Item item : content.items()){
if(items.flownBits() != null && items.flownBits().get(item.id)){
l.addImage(item.icon(Cicon.small)).padRight(3f);
l.image(item.icon(Cicon.small)).padRight(3f);
l.label(() -> items.getFlowRate(item) < 0 ? "..." : Strings.fixed(items.getFlowRate(item), 1) + ps).color(Color.lightGray);
l.row();
}
@@ -845,7 +839,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
table.row();
table.table(l -> {
l.left();
l.addImage(() -> liquids.current().icon(Cicon.small)).padRight(3f);
l.image(() -> liquids.current().icon(Cicon.small)).padRight(3f);
l.label(() -> liquids.getFlowRate() < 0 ? "..." : Strings.fixed(liquids.getFlowRate(), 2) + ps).color(Color.lightGray);
});
}
+2 -28
View File
@@ -18,8 +18,7 @@ import mindustry.world.blocks.environment.*;
import static mindustry.Vars.*;
@Component
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc,
DrawLayerGroundc, DrawLayerFlyingc, DrawLayerGroundShadowsc, DrawLayerFlyingShadowsc, Syncc{
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, Syncc{
@Import float x, y, rotation, elevation;
private UnitController controller;
@@ -172,32 +171,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
@Override
public void draw(){
type.drawEngine(this);
type.drawBody(this);
type.drawWeapons(this);
if(type.drawCell) type.drawCell(this);
if(type.drawItems) type.drawItems(this);
type.drawLight(this);
}
@Override
public void drawFlyingShadows(){
if(isFlying()) type.drawShadow(this);
}
@Override
public void drawGroundShadows(){
type.drawOcclusion(this);
}
@Override
public void drawFlying(){
if(isFlying()) draw();
}
@Override
public void drawGround(){
if(isGrounded()) draw();
type.draw(this);
}
@Override
+1 -1
View File
@@ -81,7 +81,7 @@ public class Rules{
public boolean canGameOver = true;
/** Whether to draw shadows of blocks at map edges and static blocks.
* Do not change unless you know exactly what you are doing.*/
public boolean drawFog = true;
public boolean drawDarkness = true;
/** Starting items put in cores */
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
/** Blocks that cannot be placed. */
+20 -1
View File
@@ -51,7 +51,9 @@ public class Schematics implements Loadable{
private OptimizedByteArrayOutputStream out = new OptimizedByteArrayOutputStream(1024);
private Array<Schematic> all = new Array<>();
private OrderedMap<Schematic, FrameBuffer> previews = new OrderedMap<>();
private ObjectSet<Schematic> errored = new ObjectSet<>();
private FrameBuffer shadowBuffer;
private Texture errorTexture;
private long lastClearTime;
public Schematics(){
@@ -59,6 +61,9 @@ public class Schematics implements Loadable{
previews.each((schem, m) -> m.dispose());
previews.clear();
shadowBuffer.dispose();
if(errorTexture != null){
errorTexture.dispose();
}
});
Events.on(ContentReloadEvent.class, event -> {
@@ -66,6 +71,12 @@ public class Schematics implements Loadable{
previews.clear();
load();
});
Events.on(ClientLoadEvent.class, event -> {
Pixmap pixmap = Core.atlas.getPixmap("error").crop();
errorTexture = new Texture(pixmap);
pixmap.dispose();
});
}
@Override
@@ -163,7 +174,15 @@ public class Schematics implements Loadable{
}
public Texture getPreview(Schematic schematic){
return getBuffer(schematic).getTexture();
if(errored.contains(schematic)) return errorTexture;
try{
return getBuffer(schematic).getTexture();
}catch(Throwable t){
Log.err(t);
errored.add(schematic);
return errorTexture;
}
}
public boolean hasPreview(Schematic schematic){
+38 -99
View File
@@ -14,6 +14,7 @@ import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.power.*;
import static arc.Core.camera;
import static mindustry.Vars.*;
@@ -25,23 +26,18 @@ public class BlockRenderer implements Disposable{
public final FloorRenderer floor = new FloorRenderer();
private Array<BlockRequest> requests = new Array<>(true, initialRequests, BlockRequest.class);
private Array<Tile> requests = new Array<>(false, initialRequests, Tile.class);
private int lastCamX, lastCamY, lastRangeX, lastRangeY;
private int requestidx = 0;
private int iterateidx = 0;
private float brokenFade = 0f;
private FrameBuffer shadows = new FrameBuffer(2, 2);
private FrameBuffer fog = new FrameBuffer(2, 2);
private FrameBuffer shadows = new FrameBuffer();
private FrameBuffer fog = new FrameBuffer();
private Array<Tilec> outArray2 = new Array<>();
private Array<Tile> shadowEvents = new Array<>();
private boolean displayStatus = false;
public BlockRenderer(){
for(int i = 0; i < requests.size; i++){
requests.set(i, new BlockRequest());
}
Events.on(WorldLoadEvent.class, event -> {
shadowEvents.clear();
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
@@ -98,7 +94,7 @@ public class BlockRenderer implements Disposable{
});
}
public void drawFog(){
public void drawDarkness(){
float ww = world.width() * tilesize, wh = world.height() * tilesize;
float x = camera.position.x + tilesize / 2f, y = camera.position.y + tilesize / 2f;
float u = (x - camera.width / 2f) / ww,
@@ -178,7 +174,6 @@ public class BlockRenderer implements Disposable{
/** Process all blocks to draw. */
public void processBlocks(){
displayStatus = Core.settings.getBool("blockstatus");
iterateidx = 0;
int avgx = (int)(camera.position.x / tilesize);
int avgy = (int)(camera.position.y / tilesize);
@@ -190,7 +185,7 @@ public class BlockRenderer implements Disposable{
return;
}
requestidx = 0;
requests.clear();
int minx = Math.max(avgx - rangex - expandr, 0);
int miny = Math.max(avgy - rangey - expandr, 0);
@@ -204,29 +199,14 @@ public class BlockRenderer implements Disposable{
Block block = tile.block();
if(block != Blocks.air && tile.isCenter() && block.cacheLayer == CacheLayer.normal){
if(!expanded){
addRequest(tile, Layer.block);
}
if(state.rules.lighting && tile.block().synthetic()){
addRequest(tile, Layer.lights);
}
if(block.expanded || !expanded){
requests.add(tile);
}
if(block.layer != null){
addRequest(tile, block.layer);
}
if(block.layer2 != null){
addRequest(tile, block.layer2);
}
if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){
for(Tilec other : tile.entity.getPowerConnections(outArray2)){
if(other.block().layer == Layer.power){
addRequest(other.tile(), Layer.power);
}
if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){
for(Tilec other : tile.entity.getPowerConnections(outArray2)){
if(other.block() instanceof PowerNode){ //TODO need a generic way to render connections!
requests.add(other.tile());
}
}
}
@@ -234,68 +214,44 @@ public class BlockRenderer implements Disposable{
}
}
Sort.instance().sort(requests.items, 0, requestidx);
lastCamX = avgx;
lastCamY = avgy;
lastRangeX = rangex;
lastRangeY = rangey;
}
public void drawBlocks(Layer stopAt){
int startIdx = iterateidx;
for(; iterateidx < requestidx; iterateidx++){
BlockRequest request = requests.get(iterateidx);
public void drawBlocks(){
drawDestroyed();
if(request.layer.ordinal() > stopAt.ordinal()){
break;
}
for(int i = 0; i < requests.size; i++){
Tile tile = requests.items[i];
Block block = tile.block();
Tilec entity = tile.entity;
if(request.layer == Layer.power){
if(iterateidx - startIdx > 0 && request.tile.pos() == requests.get(iterateidx - 1).tile.pos()){
continue;
Draw.z(Layer.block);
if(block != Blocks.air){
block.drawBase(tile);
if(entity != null){
if(entity.damaged()){
entity.drawCracks();
}
if(entity.team() != player.team()){
entity.drawTeam();
}
entity.drawLight();
if(displayStatus && block.consumes.any()){
entity.drawStatus();
}
}
}
Block block = request.tile.block();
boolean isEnd = (request.layer == Layer.block && block.layer == null) || request.layer == block.layer;
if(request.layer == Layer.block){
block.drawBase(request.tile);
if(request.tile.entity != null && request.tile.entity.damaged()){
request.tile.entity.drawCracks();
}
if(block.synthetic() && request.tile.entity != null && request.tile.team() != player.team()){
request.tile.entity.drawTeam();
}
}else if(request.layer == Layer.lights && request.tile.entity != null){
request.tile.entity.drawLight();
}else if(request.layer == block.layer){
block.drawLayer(request.tile);
}else if(request.layer == block.layer2){
block.drawLayer2(request.tile);
}
if(isEnd && request.tile.entity != null && displayStatus && block.consumes.any()){
request.tile.entity.drawStatus();
}
}
}
private void addRequest(Tile tile, Layer layer){
if(requestidx >= requests.size){
requests.add(new BlockRequest());
}
BlockRequest r = requests.get(requestidx);
if(r == null){
requests.set(requestidx, r = new BlockRequest());
}
r.tile = tile;
r.layer = layer;
requestidx++;
}
@Override
public void dispose(){
shadows.dispose();
@@ -303,21 +259,4 @@ public class BlockRenderer implements Disposable{
shadows = fog = null;
floor.dispose();
}
private class BlockRequest implements Comparable<BlockRequest>{
Tile tile;
Layer layer;
@Override
public int compareTo(BlockRequest other){
int compare = layer.compareTo(other.layer);
return (compare != 0) ? compare : Integer.compare(tile.pos(), other.tile.pos());
}
@Override
public String toString(){
return tile.block().name + ":" + layer.toString();
}
}
}
+6 -6
View File
@@ -1,14 +1,14 @@
package mindustry.graphics;
import arc.Core;
import arc.graphics.Color;
import arc.graphics.g2d.Draw;
import arc.graphics.gl.Shader;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.graphics.gl.*;
import static arc.Core.camera;
import static mindustry.Vars.renderer;
public enum CacheLayer{
//TODO water animation breaks when tar/slag is present
water{
@Override
public void begin(){
@@ -81,7 +81,7 @@ public enum CacheLayer{
renderer.effectBuffer.end();
Draw.shader(shader);
Draw.rect(Draw.wrap(renderer.effectBuffer.getTexture()), camera.position.x, camera.position.y, camera.width, -camera.height);
Draw.rect(renderer.effectBuffer);
Draw.shader();
renderer.blocks.floor.beginc();
+66 -13
View File
@@ -1,16 +1,69 @@
package mindustry.graphics;
public enum Layer{
/** Base block layer. */
block,
/** for placement */
placement,
/** First overlay. Stuff like conveyor items. */
overlay,
/** "High" blocks, like turrets. */
turret,
/** Power lasers. */
power,
/** Extra layer that's always on top.*/
lights
/** Stores constants for sorting layers. Values should be stored in increments of 10. */
public class Layer{
public static final float
//background, which may be planets or an image or nothing at all
background = -10,
//floor tiles
floor = 0,
//scorch marks on the floor
scorch = 10,
//things such as spent casings or rubble
debris = 20,
//base block layer - most blocks go here
block = 30,
//things drawn over blocks (intermediate layer)
blockOver = 35,
//blocks currently in progress *shaders used* TODO perhaps put shaders into their own category
blockBuilding = 40,
//ground units
groundUnit = 50,
//turrets
turret = 60,
//power lines
power = 70,
//darkness over block clusters
darkness = 80,
//building plans
plans = 85,
//flying units
flyingUnit = 90,
//bullets *bloom begin*
bullet = 100,
//effects *bloom end*
effect = 110,
//overlaied UI, like block config guides
overlayUI = 120,
//weather effects, e.g. rain and snow TODO draw before overlay UI?
weather = 130,
//light rendering *shaders used*
light = 140,
//names of players in the game
playerName = 150,
//space effects, currently only the land and launch effects
space = 160
;
}
@@ -17,7 +17,7 @@ public class LightRenderer{
private static final int scaling = 4;
private float[] vertices = new float[24];
private FrameBuffer buffer = new FrameBuffer(2, 2);
private FrameBuffer buffer = new FrameBuffer();
private Array<Runnable> lights = new Array<>();
public void add(Runnable run){
@@ -185,9 +185,7 @@ public class LightRenderer{
return;
}
if(buffer.getWidth() != Core.graphics.getWidth()/scaling || buffer.getHeight() != Core.graphics.getHeight()/scaling){
buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling);
}
buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling);
Draw.color();
buffer.begin(Color.clear);
@@ -203,7 +201,7 @@ public class LightRenderer{
Draw.color();
Shaders.light.ambient.set(state.rules.ambientLight);
Draw.shader(Shaders.light);
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
Draw.rect(buffer);
Draw.shader();
lights.clear();
+5 -7
View File
@@ -6,13 +6,12 @@ import arc.graphics.Texture.*;
import arc.graphics.g2d.*;
import arc.graphics.gl.*;
import arc.util.*;
import mindustry.gen.*;
import static arc.Core.*;
import static mindustry.Vars.renderer;
public class Pixelator implements Disposable{
private FrameBuffer buffer = new FrameBuffer(2, 2);
private FrameBuffer buffer = new FrameBuffer();
{
buffer.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
@@ -34,19 +33,18 @@ public class Pixelator implements Disposable{
int w = (int)(Core.camera.width * renderer.landScale());
int h = (int)(Core.camera.height * renderer.landScale());
if(!graphics.isHidden() && (buffer.getWidth() != w || buffer.getHeight() != h)){
buffer.resize(w, h);
}
buffer.resize(w, h);
buffer.begin();
renderer.draw();
buffer.end();
Draw.blend(Blending.disabled);
Draw.rect(Draw.wrap(buffer.getTexture()), Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
Draw.rect(buffer);
Draw.blend();
Groups.drawNames();
//TODO set all of this up
//Groups.drawNames();
Core.camera.position.set(px, py);
renderer.setScale(pre);
+49 -49
View File
@@ -7,55 +7,55 @@ import arc.input.InputDevice.DeviceType;
import arc.input.KeyCode;
public enum Binding implements KeyBind{
move_x(new Axis(KeyCode.A, KeyCode.D), "general"),
move_y(new Axis(KeyCode.S, KeyCode.W)),
mouse_move(KeyCode.MOUSE_BACK),
dash(KeyCode.SHIFT_LEFT),
control(KeyCode.SHIFT_LEFT),
select(KeyCode.MOUSE_LEFT),
deselect(KeyCode.MOUSE_RIGHT),
break_block(KeyCode.MOUSE_RIGHT),
clear_building(KeyCode.Q),
pause_building(KeyCode.E),
rotate(new Axis(KeyCode.SCROLL)),
rotateplaced(KeyCode.R),
diagonal_placement(KeyCode.CONTROL_LEFT),
pick(KeyCode.MOUSE_MIDDLE),
schematic_select(KeyCode.F),
schematic_flip_x(KeyCode.Z),
schematic_flip_y(KeyCode.X),
schematic_menu(KeyCode.T),
category_prev(KeyCode.COMMA),
category_next(KeyCode.PERIOD),
block_select_left(KeyCode.LEFT),
block_select_right(KeyCode.RIGHT),
block_select_up(KeyCode.UP),
block_select_down(KeyCode.DOWN),
block_select_01(KeyCode.NUM_1),
block_select_02(KeyCode.NUM_2),
block_select_03(KeyCode.NUM_3),
block_select_04(KeyCode.NUM_4),
block_select_05(KeyCode.NUM_5),
block_select_06(KeyCode.NUM_6),
block_select_07(KeyCode.NUM_7),
block_select_08(KeyCode.NUM_8),
block_select_09(KeyCode.NUM_9),
block_select_10(KeyCode.NUM_0),
zoom(new Axis(KeyCode.SCROLL), "view"),
menu(Core.app.getType() == ApplicationType.Android ? KeyCode.BACK : KeyCode.ESCAPE),
fullscreen(KeyCode.F11),
pause(KeyCode.SPACE),
minimap(KeyCode.M),
toggle_menus(KeyCode.C),
screenshot(KeyCode.P),
toggle_power_lines(KeyCode.F5),
toggle_block_status(KeyCode.F6),
player_list(KeyCode.TAB, "multiplayer"),
chat(KeyCode.ENTER),
chat_history_prev(KeyCode.UP),
chat_history_next(KeyCode.DOWN),
chat_scroll(new Axis(KeyCode.SCROLL)),
console(KeyCode.F8),
move_x(new Axis(KeyCode.a, KeyCode.d), "general"),
move_y(new Axis(KeyCode.s, KeyCode.w)),
mouse_move(KeyCode.mouseBack),
dash(KeyCode.shiftLeft),
control(KeyCode.shiftLeft),
select(KeyCode.mouseLeft),
deselect(KeyCode.mouseRight),
break_block(KeyCode.mouseRight),
clear_building(KeyCode.q),
pause_building(KeyCode.e),
rotate(new Axis(KeyCode.scroll)),
rotateplaced(KeyCode.r),
diagonal_placement(KeyCode.controlLeft),
pick(KeyCode.mouseMiddle),
schematic_select(KeyCode.f),
schematic_flip_x(KeyCode.z),
schematic_flip_y(KeyCode.x),
schematic_menu(KeyCode.t),
category_prev(KeyCode.comma),
category_next(KeyCode.period),
block_select_left(KeyCode.left),
block_select_right(KeyCode.right),
block_select_up(KeyCode.up),
block_select_down(KeyCode.down),
block_select_01(KeyCode.num1),
block_select_02(KeyCode.num2),
block_select_03(KeyCode.num3),
block_select_04(KeyCode.num4),
block_select_05(KeyCode.num5),
block_select_06(KeyCode.num6),
block_select_07(KeyCode.num7),
block_select_08(KeyCode.num8),
block_select_09(KeyCode.num9),
block_select_10(KeyCode.num0),
zoom(new Axis(KeyCode.scroll), "view"),
menu(Core.app.getType() == ApplicationType.Android ? KeyCode.back : KeyCode.escape),
fullscreen(KeyCode.f11),
pause(KeyCode.space),
minimap(KeyCode.m),
toggle_menus(KeyCode.c),
screenshot(KeyCode.p),
toggle_power_lines(KeyCode.f5),
toggle_block_status(KeyCode.f6),
player_list(KeyCode.tab, "multiplayer"),
chat(KeyCode.enter),
chat_history_prev(KeyCode.up),
chat_history_next(KeyCode.down),
chat_scroll(new Axis(KeyCode.scroll)),
console(KeyCode.f8),
;
private final KeybindValue defaultValue;
+4 -4
View File
@@ -72,7 +72,7 @@ public class DesktopInput extends InputHandler{
Core.keybinds.get(Binding.schematic_flip_y).key.toString())).style(Styles.outlineLabel);
b.row();
b.table(a -> {
a.addImageTextButton("$schematic.add", Icon.save, this::showSchematicSave).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
a.button("$schematic.add", Icon.save, this::showSchematicSave).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
});
}).margin(6f);
});
@@ -182,7 +182,7 @@ public class DesktopInput extends InputHandler{
}
//TODO this is for debugging, remove later
if(Core.input.keyTap(KeyCode.Q) && !player.dead()){
if(Core.input.keyTap(KeyCode.q) && !player.dead()){
Fx.commandSend.at(player);
Units.nearby(player.team(), player.x(), player.y(), 200f, u -> {
if(u.isAI()){
@@ -302,11 +302,11 @@ public class DesktopInput extends InputHandler{
@Override
public void buildPlacementUI(Table table){
table.addImage().color(Pal.gray).height(4f).colspan(4).growX();
table.image().color(Pal.gray).height(4f).colspan(4).growX();
table.row();
table.left().margin(0f).defaults().size(48f).left();
table.addImageButton(Icon.paste, Styles.clearPartiali, () -> {
table.button(Icon.paste, Styles.clearPartiali, () -> {
ui.schematics.show();
});
}
+11 -12
View File
@@ -14,7 +14,6 @@ import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.entities.units.*;
@@ -175,23 +174,23 @@ public class MobileInput extends InputHandler implements GestureListener{
@Override
public void buildPlacementUI(Table table){
table.addImage().color(Pal.gray).height(4f).colspan(4).growX();
table.image().color(Pal.gray).height(4f).colspan(4).growX();
table.row();
table.left().margin(0f).defaults().size(48f);
table.addImageButton(Icon.hammer, Styles.clearTogglePartiali, () -> {
table.button(Icon.hammer, Styles.clearTogglePartiali, () -> {
mode = mode == breaking ? block == null ? none : placing : breaking;
lastBlock = block;
}).update(l -> l.setChecked(mode == breaking)).name("breakmode");
//diagonal swap button
table.addImageButton(Icon.diagonal, Styles.clearTogglePartiali, () -> {
table.button(Icon.diagonal, Styles.clearTogglePartiali, () -> {
Core.settings.put("swapdiagonal", !Core.settings.getBool("swapdiagonal"));
Core.settings.save();
}).update(l -> l.setChecked(Core.settings.getBool("swapdiagonal")));
//rotate button
table.addImageButton(Icon.right, Styles.clearTogglePartiali, () -> {
table.button(Icon.right, Styles.clearTogglePartiali, () -> {
if(block != null && block.rotate){
rotation = Mathf.mod(rotation + 1, 4);
}else{
@@ -210,7 +209,7 @@ public class MobileInput extends InputHandler implements GestureListener{
});
//confirm button
table.addImageButton(Icon.ok, Styles.clearPartiali, () -> {
table.button(Icon.ok, Styles.clearPartiali, () -> {
for(BuildRequest request : selectRequests){
Tile tile = request.tile();
@@ -249,7 +248,7 @@ public class MobileInput extends InputHandler implements GestureListener{
group.fill(t -> {
t.bottom().left().visible(() -> (player.builder().isBuilding() || block != null || mode == breaking || !selectRequests.isEmpty()) && !schem.get());
t.addImageTextButton("$cancel", Icon.cancel, () -> {
t.button("$cancel", Icon.cancel, () -> {
player.builder().clearBuilding();
selectRequests.clear();
mode = none;
@@ -265,15 +264,15 @@ public class MobileInput extends InputHandler implements GestureListener{
ImageButtonStyle style = Styles.clearPartiali;
b.addImageButton(Icon.save, style, this::showSchematicSave).disabled(f -> lastSchematic == null || lastSchematic.file != null);
b.addImageButton(Icon.cancel, style, () -> {
b.button(Icon.save, style, this::showSchematicSave).disabled(f -> lastSchematic == null || lastSchematic.file != null);
b.button(Icon.cancel, style, () -> {
selectRequests.clear();
});
b.row();
b.addImageButton(Icon.flipX, style, () -> flipRequests(selectRequests, true));
b.addImageButton(Icon.flipY, style, () -> flipRequests(selectRequests, false));
b.button(Icon.flipX, style, () -> flipRequests(selectRequests, true));
b.button(Icon.flipY, style, () -> flipRequests(selectRequests, false));
b.row();
b.addImageButton(Icon.rotate, style, () -> rotateRequests(selectRequests, 1));
b.button(Icon.rotate, style, () -> rotateRequests(selectRequests, 1));
}).margin(4f);
});
@@ -63,7 +63,7 @@ public abstract class FilterOption{
table.label(() -> Core.bundle.get("filter.option." + name) + ": " + (int)getter.get());
}
table.row();
Slider slider = table.addSlider(min, max, step, setter).growX().get();
Slider slider = table.slider(min, max, step, setter).growX().get();
slider.setValue(getter.get());
if(updateEditorOnChange){
slider.changed(changed);
@@ -88,7 +88,7 @@ public abstract class FilterOption{
@Override
public void build(Table table){
table.addButton(b -> b.addImage(supplier.get().icon(Cicon.small)).update(i -> ((TextureRegionDrawable)i.getDrawable())
table.button(b -> b.image(supplier.get().icon(Cicon.small)).update(i -> ((TextureRegionDrawable)i.getDrawable())
.setRegion(supplier.get() == Blocks.air ? Icon.block.getRegion() : supplier.get().icon(Cicon.small))).size(8 * 3), () -> {
FloatingDialog dialog = new FloatingDialog("");
dialog.setFillParent(false);
@@ -96,7 +96,7 @@ public abstract class FilterOption{
for(Block block : Vars.content.blocks()){
if(!filter.get(block)) continue;
dialog.cont.addImage(block == Blocks.air ? Icon.block.getRegion() : block.icon(Cicon.medium)).size(8 * 4).pad(3).get().clicked(() -> {
dialog.cont.image(block == Blocks.air ? Icon.block.getRegion() : block.icon(Cicon.medium)).size(8 * 4).pad(3).get().clicked(() -> {
consumer.get(block);
dialog.hide();
changed.run();
+5 -5
View File
@@ -386,7 +386,7 @@ public class Mods implements Loadable{
cont.margin(15);
cont.add("$error.title");
cont.row();
cont.addImage().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
cont.image().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
cont.row();
cont.add("$mod.errors").wrap().growX().center().get().setAlignment(Align.center);
cont.row();
@@ -394,18 +394,18 @@ public class Mods implements Loadable{
mods.each(m -> m.enabled() && m.hasContentErrors(), m -> {
p.add(m.name).color(Pal.accent).left();
p.row();
p.addImage().fillX().pad(4).color(Pal.accent);
p.image().fillX().pad(4).color(Pal.accent);
p.row();
p.table(d -> {
d.left().marginLeft(15f);
for(Content c : m.erroredContent){
d.add(c.minfo.sourceFile.nameWithoutExtension()).left().padRight(10);
d.addImageTextButton("$details", Icon.downOpen, Styles.transt, () -> {
d.button("$details", Icon.downOpen, Styles.transt, () -> {
new Dialog(""){{
setFillParent(true);
cont.pane(e -> e.add(c.minfo.error)).grow();
cont.row();
cont.addImageTextButton("$ok", Icon.left, this::hide).size(240f, 60f);
cont.button("$ok", Icon.left, this::hide).size(240f, 60f);
}}.show();
}).size(190f, 50f).left().marginLeft(6);
d.row();
@@ -416,7 +416,7 @@ public class Mods implements Loadable{
});
cont.row();
cont.addButton("$ok", this::hide).size(300, 50);
cont.button("$ok", this::hide).size(300, 50);
}}.show();
}
}
+1 -1
View File
@@ -105,7 +105,7 @@ public class BeControl{
});
dialog.cont.add(new Bar(() -> length[0] == 0 ? Core.bundle.get("be.updating") : (int)(progress[0] * length[0]) / 1024/ 1024 + "/" + length[0]/1024/1024 + " MB", () -> Pal.accent, () -> progress[0])).width(400f).height(70f);
dialog.buttons.addImageTextButton("$cancel", Icon.cancel, () -> {
dialog.buttons.button("$cancel", Icon.cancel, () -> {
cancel[0] = true;
dialog.hide();
}).size(210f, 64f);
+21
View File
@@ -114,6 +114,27 @@ public class UnitType extends UnlockableContent{
//region drawing
public void draw(Unitc unit){
if(unit.isFlying()){
Draw.z(Layer.darkness);
drawShadow(unit);
}
Draw.z(Mathf.lerp(Layer.groundUnit, Layer.flyingUnit, unit.elevation()));
if(unit instanceof Legsc){
drawLegs((Legsc)unit);
}
drawOcclusion(unit);
drawEngine(unit);
drawBody(unit);
drawWeapons(unit);
if(drawCell) drawCell(unit);
if(drawItems) drawItems(unit);
drawLight(unit);
}
public void drawShadow(Unitc unit){
Draw.color(shadowColor);
Draw.rect(region, unit.x() + shadowTX * unit.elevation(), unit.y() + shadowTY * unit.elevation(), unit.rotation() - 90);
+5 -2
View File
@@ -1,9 +1,11 @@
package mindustry.type;
import arc.func.*;
import arc.graphics.g2d.*;
import mindustry.annotations.Annotations.*;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.graphics.*;
public abstract class Weather extends MappableContent{
protected float duration = 100f;
@@ -39,7 +41,7 @@ public abstract class Weather extends MappableContent{
@EntityDef(value = {Weatherc.class}, pooled = true, isFinal = false)
@Component
abstract class WeatherComp implements Posc, DrawLayerWeatherc{
abstract class WeatherComp implements Posc, Drawc{
Weather weather;
void init(Weather weather){
@@ -47,7 +49,8 @@ public abstract class Weather extends MappableContent{
}
@Override
public void drawWeather(){
public void draw(){
Draw.z(Layer.weather);
weather.draw();
}
+12 -12
View File
@@ -17,13 +17,13 @@ public class ContentDisplay{
table.table(title -> {
int size = 8 * 6;
title.addImage(block.icon(Cicon.xlarge)).size(size);
title.image(block.icon(Cicon.xlarge)).size(size);
title.add("[accent]" + block.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
@@ -31,7 +31,7 @@ public class ContentDisplay{
table.add(block.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
}
@@ -65,13 +65,13 @@ public class ContentDisplay{
public static void displayItem(Table table, Item item){
table.table(title -> {
title.addImage(item.icon(Cicon.xlarge)).size(8 * 6);
title.image(item.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + item.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
@@ -79,7 +79,7 @@ public class ContentDisplay{
table.add(item.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
@@ -99,13 +99,13 @@ public class ContentDisplay{
public static void displayLiquid(Table table, Liquid liquid){
table.table(title -> {
title.addImage(liquid.icon(Cicon.xlarge)).size(8 * 6);
title.image(liquid.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + liquid.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
@@ -113,7 +113,7 @@ public class ContentDisplay{
table.add(liquid.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
@@ -133,13 +133,13 @@ public class ContentDisplay{
public static void displayUnit(Table table, UnitType unit){
table.table(title -> {
title.addImage(unit.icon(Cicon.xlarge)).size(8 * 6);
title.image(unit.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + unit.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
@@ -147,7 +147,7 @@ public class ContentDisplay{
table.add(unit.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.image().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
+2 -3
View File
@@ -3,7 +3,6 @@ package mindustry.ui;
import arc.graphics.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import mindustry.core.GameState.*;
import mindustry.gen.*;
import mindustry.type.*;
@@ -33,14 +32,14 @@ public class ItemsDisplay extends Table{
for(Item item : content.items()){
if(item.type == ItemType.material && data.isUnlocked(item)){
t.label(() -> format(item)).left();
t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4);
t.image(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4);
t.add(item.localizedName).color(Color.lightGray).left();
t.row();
}
}
}).get().setScrollingDisabled(true, false), false).setDuration(0.3f);
c.addImageTextButton("$launcheditems", Icon.downOpen, Styles.clearTogglet, col::toggle).update(t -> {
c.button("$launcheditems", Icon.downOpen, Styles.clearTogglet, col::toggle).update(t -> {
t.setText(state.isMenu() ? "$launcheditems" : "$launchinfo");
t.setChecked(col.isCollapsed());
((Image)t.getChildren().get(1)).setDrawable(col.isCollapsed() ? Icon.upOpen : Icon.downOpen);
@@ -48,14 +48,14 @@ public class AboutDialog extends FloatingDialog{
Table table = new Table(Tex.underline);
table.margin(0);
table.table(img -> {
img.addImage().height(h - 5).width(40f).color(link.color);
img.image().height(h - 5).width(40f).color(link.color);
img.row();
img.addImage().height(5).width(40f).color(link.color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
img.image().height(5).width(40f).color(link.color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
}).expandY();
table.table(i -> {
i.background(Tex.buttonEdge3);
i.addImage(link.icon);
i.image(link.icon);
}).size(h - 5, h);
table.table(inset -> {
@@ -64,7 +64,7 @@ public class AboutDialog extends FloatingDialog{
inset.labelWrap(link.description).width(w - 100f).color(Color.lightGray).growX();
}).padLeft(8);
table.addImageButton(Icon.link, () -> {
table.button(Icon.link, () -> {
if(link.name.equals("wiki")) Events.fire(Trigger.openWiki);
if(!Core.net.openURI(link.link)){
@@ -82,7 +82,7 @@ public class AboutDialog extends FloatingDialog{
addCloseButton();
buttons.addButton("$credits", this::showCredits).size(200f, 64f);
buttons.button("$credits", this::showCredits).size(200f, 64f);
if(Core.graphics.isPortrait()){
for(Cell<?> cell : buttons.getCells()){
@@ -98,7 +98,7 @@ public class AboutDialog extends FloatingDialog{
dialog.cont.add("$credits.text").fillX().wrap().get().setAlignment(Align.center);
dialog.cont.row();
if(!contributors.isEmpty()){
dialog.cont.addImage().color(Pal.accent).fillX().height(3f).pad(3f);
dialog.cont.image().color(Pal.accent).fillX().height(3f).pad(3f);
dialog.cont.row();
dialog.cont.add("$contributors");
dialog.cont.row();
@@ -38,7 +38,7 @@ public class AdminsDialog extends FloatingDialog{
res.labelWrap("[LIGHT_GRAY]" + info.lastName).width(w - h - 24f);
res.add().growX();
res.addImageButton(Icon.cancel, () -> {
res.button(Icon.cancel, () -> {
ui.showConfirm("$confirm", "$confirmunadmin", () -> {
netServer.admins.unAdminPlayer(info.id);
Groups.player.each(player -> {
@@ -39,7 +39,7 @@ public class BansDialog extends FloatingDialog{
res.labelWrap("IP: [LIGHT_GRAY]" + info.lastIP + "\n[]Name: [LIGHT_GRAY]" + info.lastName).width(w - h - 24f);
res.add().growX();
res.addImageButton(Icon.cancel, () -> {
res.button(Icon.cancel, () -> {
ui.showConfirm("$confirm", "$confirmunban", () -> {
netServer.admins.unbanPlayerID(info.id);
setup();
@@ -38,24 +38,24 @@ public class ColorPicker extends FloatingDialog{
t.defaults().padBottom(4);
t.add("R").color(Pal.remove);
t.addSlider(0f, 1f, 0.01f, current.r, current::r).width(w);
t.slider(0f, 1f, 0.01f, current.r, current::r).width(w);
t.row();
t.add("G").color(Color.lime);
t.addSlider(0f, 1f, 0.01f, current.g, current::g).width(w);
t.slider(0f, 1f, 0.01f, current.g, current::g).width(w);
t.row();
t.add("B").color(Color.royal);
t.addSlider(0f, 1f, 0.01f, current.b, current::b).width(w);
t.slider(0f, 1f, 0.01f, current.b, current::b).width(w);
t.row();
if(alpha){
t.add("A");
t.addSlider(0f, 1f, 0.01f, current.a, current::a).width(w);
t.slider(0f, 1f, 0.01f, current.a, current::a).width(w);
t.row();
}
});
buttons.clear();
addCloseButton();
buttons.addImageTextButton("$ok", Icon.ok, () -> {
buttons.button("$ok", Icon.ok, () -> {
cons.get(current);
hide();
});
@@ -17,10 +17,10 @@ public class ControlsDialog extends KeybindDialog{
@Override
public void addCloseButton(){
buttons.addImageTextButton("$back", Icon.left, this::hide).size(230f, 64f);
buttons.button("$back", Icon.left, this::hide).size(230f, 64f);
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK)
if(key == KeyCode.escape || key == KeyCode.back)
hide();
});
}
@@ -62,14 +62,14 @@ public class CustomGameDialog extends FloatingDialog{
for(Gamemode mode : Gamemode.all){
TextureRegionDrawable icon = Vars.ui.getIcon("mode" + Strings.capitalize(mode.name()) + "Small");
if(mode.valid(map) && Core.atlas.isFound(icon.getRegion())){
t.addImage(icon).size(16f).pad(4f);
t.image(icon).size(16f).pad(4f);
}
}
}).left();
image.row();
image.add(map.name()).pad(1f).growX().wrap().left().get().setEllipsis(true);
image.row();
image.addImage(Tex.whiteui, Pal.gray).growX().pad(3).height(4f);
image.image(Tex.whiteui, Pal.gray).growX().pad(3).height(4f);
image.row();
image.add(img).size(images);
@@ -35,12 +35,12 @@ public class CustomRulesDialog extends FloatingDialog{
banDialog.addCloseButton();
banDialog.shown(this::rebuildBanned);
banDialog.buttons.addImageTextButton("$addall", Icon.add, () -> {
banDialog.buttons.button("$addall", Icon.add, () -> {
rules.bannedBlocks.addAll(content.blocks().select(Block::isBuildable));
rebuildBanned();
}).size(180, 64f);
banDialog.buttons.addImageTextButton("$clear", Icon.trash, () -> {
banDialog.buttons.button("$clear", Icon.trash, () -> {
rules.bannedBlocks.clear();
rebuildBanned();
}).size(180, 64f);
@@ -69,10 +69,10 @@ public class CustomRulesDialog extends FloatingDialog{
for(Block block : array){
t.table(Tex.underline, b -> {
b.left().margin(4f);
b.addImage(block.icon(Cicon.medium)).size(Cicon.medium.size).padRight(3);
b.image(block.icon(Cicon.medium)).size(Cicon.medium.size).padRight(3);
b.add(block.localizedName).color(Color.lightGray).padLeft(3).growX().left().wrap();
b.addImageButton(Icon.cancel, Styles.clearPartiali, () -> {
b.button(Icon.cancel, Styles.clearPartiali, () -> {
rules.bannedBlocks.remove(block);
rebuildBanned();
}).size(70f).pad(-4f).padLeft(0f);
@@ -84,14 +84,14 @@ public class CustomRulesDialog extends FloatingDialog{
}
}).get().setScrollYForce(previousScroll);
banDialog.cont.row();
banDialog.cont.addImageTextButton("$add", Icon.add, () -> {
banDialog.cont.button("$add", Icon.add, () -> {
FloatingDialog dialog = new FloatingDialog("$add");
dialog.cont.pane(t -> {
t.left().margin(14f);
int[] i = {0};
content.blocks().each(b -> !rules.bannedBlocks.contains(b) && b.isBuildable(), b -> {
int cols = mobile && Core.graphics.isPortrait() ? 4 : 12;
t.addImageButton(new TextureRegionDrawable(b.icon(Cicon.medium)), Styles.cleari, () -> {
t.button(new TextureRegionDrawable(b.icon(Cicon.medium)), Styles.cleari, () -> {
rules.bannedBlocks.add(b);
rebuildBanned();
dialog.hide();
@@ -118,7 +118,7 @@ public class CustomRulesDialog extends FloatingDialog{
cont.clear();
cont.pane(m -> main = m).get().setScrollingDisabled(true, false);
main.margin(10f);
main.addButton("$settings.reset", () -> {
main.button("$settings.reset", () -> {
rules = resetter.get();
setup();
requestKeyboard();
@@ -145,7 +145,7 @@ public class CustomRulesDialog extends FloatingDialog{
number("$rules.deconstructrefundmultiplier", false, f -> rules.deconstructRefundMultiplier = f, () -> rules.deconstructRefundMultiplier, () -> !rules.infiniteResources);
number("$rules.blockhealthmultiplier", f -> rules.blockHealthMultiplier = f, () -> rules.blockHealthMultiplier);
main.addButton("$configure",
main.button("$configure",
() -> loadoutDialog.show(Blocks.coreShard.itemCapacity, rules.loadout,
() -> {
rules.loadout.clear();
@@ -154,7 +154,7 @@ public class CustomRulesDialog extends FloatingDialog{
)).left().width(300f);
main.row();
main.addButton("$bannedblocks", banDialog::show).left().width(300f);
main.button("$bannedblocks", banDialog::show).left().width(300f);
main.row();
title("$rules.title.player");
@@ -176,7 +176,7 @@ public class CustomRulesDialog extends FloatingDialog{
number("$rules.solarpowermultiplier", f -> rules.solarPowerMultiplier = f, () -> rules.solarPowerMultiplier);
check("$rules.lighting", b -> rules.lighting = b, () -> rules.lighting);
main.addButton(b -> {
main.button(b -> {
b.left();
b.table(Tex.pane, in -> {
in.stack(new Image(Tex.alphaBg), new Image(Tex.whiteui){{
@@ -197,7 +197,7 @@ public class CustomRulesDialog extends FloatingDialog{
t.left();
t.add(text).left().padRight(5)
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
Vars.platform.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.get(Strings.parseFloat(s)))
Vars.platform.addDialog(t.field((integer ? (int)prov.get() : prov.get()) + "", s -> cons.get(Strings.parseFloat(s)))
.padRight(100f)
.update(a -> a.setDisabled(!condition.get()))
.valid(Strings::canParsePositiveFloat).width(120f).left().get());
@@ -210,14 +210,14 @@ public class CustomRulesDialog extends FloatingDialog{
}
void check(String text, Boolc cons, Boolp prov, Boolp condition){
main.addCheck(text, cons).checked(prov.get()).update(a -> a.setDisabled(!condition.get())).padRight(100f).get().left();
main.check(text, cons).checked(prov.get()).update(a -> a.setDisabled(!condition.get())).padRight(100f).get().left();
main.row();
}
void title(String text){
main.add(text).color(Pal.accent).padTop(20).padRight(100f).padBottom(-3);
main.row();
main.addImage().color(Pal.accent).height(3f).padRight(100f).padBottom(20);
main.image().color(Pal.accent).height(3f).padRight(100f).padBottom(20);
main.row();
}
}
@@ -9,7 +9,6 @@ import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.*;
import mindustry.core.GameState.*;
import mindustry.ctype.*;
import mindustry.ctype.ContentType;
import mindustry.gen.*;
@@ -46,7 +45,7 @@ public class DatabaseDialog extends FloatingDialog{
table.add("$content." + type.name() + ".name").growX().left().color(Pal.accent);
table.row();
table.addImage().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
table.image().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
table.row();
table.table(list -> {
list.left();
@@ -69,7 +68,7 @@ public class DatabaseDialog extends FloatingDialog{
if(unlocked(unlock)){
image.clicked(() -> {
if(Core.input.keyDown(KeyCode.SHIFT_LEFT) && Fonts.getUnicode(unlock.name) != 0){
if(Core.input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(unlock.name) != 0){
Core.app.setClipboardText((char)Fonts.getUnicode(unlock.name) + "");
ui.showInfoFade("$copied");
}else{
@@ -23,14 +23,14 @@ public class DiscordDialog extends Dialog{
t.background(Tex.button).margin(0);
t.table(img -> {
img.addImage().height(h - 5).width(40f).color(color);
img.image().height(h - 5).width(40f).color(color);
img.row();
img.addImage().height(5).width(40f).color(color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
img.image().height(5).width(40f).color(color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
}).expandY();
t.table(i -> {
i.background(Tex.button);
i.addImage(Icon.discord);
i.image(Icon.discord);
}).size(h).left();
t.add("$discord").color(Pal.accent).growX().padLeft(10f);
@@ -38,11 +38,11 @@ public class DiscordDialog extends Dialog{
buttons.defaults().size(150f, 50);
buttons.addButton("$back", this::hide);
buttons.addButton("$copylink", () -> {
buttons.button("$back", this::hide);
buttons.button("$copylink", () -> {
Core.app.setClipboardText(discordURL);
});
buttons.addButton("$openlink", () -> {
buttons.button("$openlink", () -> {
if(!Core.net.openURI(discordURL)){
ui.showErrorMessage("$linkfail");
Core.app.setClipboardText(discordURL);
@@ -20,7 +20,7 @@ public class FloatingDialog extends Dialog{
setFillParent(true);
this.title.setAlignment(Align.center);
titleTable.row();
titleTable.addImage(Tex.whiteui, Pal.accent)
titleTable.image(Tex.whiteui, Pal.accent)
.growX().height(3f).pad(4f);
hidden(() -> {
@@ -56,10 +56,10 @@ public class FloatingDialog extends Dialog{
@Override
public void addCloseButton(){
buttons.defaults().size(210f, 64f);
buttons.addImageTextButton("$back", Icon.left, this::hide).size(210f, 64f);
buttons.button("$back", Icon.left, this::hide).size(210f, 64f);
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK){
if(key == KeyCode.escape || key == KeyCode.back){
Core.app.post(this::hide);
}
});
@@ -37,7 +37,7 @@ public class GameOverDialog extends FloatingDialog{
if(state.rules.pvp){
cont.add(Core.bundle.format("gameover.pvp", winner.localized())).pad(6);
buttons.addButton("$menu", () -> {
buttons.button("$menu", () -> {
hide();
logic.reset();
}).size(130f, 60f);
@@ -71,7 +71,7 @@ public class GameOverDialog extends FloatingDialog{
if(state.stats.itemsDelivered.get(item, 0) > 0){
t.table(items -> {
items.add(" [LIGHT_GRAY]" + state.stats.itemsDelivered.get(item, 0));
items.addImage(item.icon(Cicon.small)).size(8 * 3).pad(4);
items.image(item.icon(Cicon.small)).size(8 * 3).pad(4);
}).left();
t.row();
}
@@ -86,13 +86,13 @@ public class GameOverDialog extends FloatingDialog{
}).pad(12);
if(state.isCampaign()){
buttons.addButton("$continue", () -> {
buttons.button("$continue", () -> {
hide();
logic.reset();
ui.planet.show();
}).size(130f, 60f);
}else{
buttons.addButton("$menu", () -> {
buttons.button("$menu", () -> {
hide();
logic.reset();
}).size(130f, 60f);
@@ -22,14 +22,14 @@ public class HostDialog extends FloatingDialog{
cont.table(t -> {
t.add("$name").padRight(10);
t.addField(Core.settings.getString("name"), text -> {
t.field(Core.settings.getString("name"), text -> {
player.name(text);
Core.settings.put("name", text);
Core.settings.save();
ui.listfrag.rebuild();
}).grow().pad(8).get().setMaxLength(40);
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
ImageButton button = t.button(Tex.whiteui, Styles.clearFulli, 40, () -> {
new PaletteDialog().show(color -> {
player.color().set(color);
Core.settings.put("color-0", color.rgba());
@@ -43,7 +43,7 @@ public class HostDialog extends FloatingDialog{
cont.add().width(65f);
cont.addButton("$host", () -> {
cont.button("$host", () -> {
if(Core.settings.getString("name").trim().isEmpty()){
ui.showInfo("$noname");
return;
@@ -52,7 +52,7 @@ public class HostDialog extends FloatingDialog{
runHost();
}).width(w).height(70f);
cont.addButton("?", () -> ui.showInfo("$host.info")).size(65f, 70f).padLeft(6f);
cont.button("?", () -> ui.showInfo("$host.info")).size(65f, 70f).padLeft(6f);
shown(() -> {
if(!steam){
+19 -19
View File
@@ -41,13 +41,13 @@ public class JoinDialog extends FloatingDialog{
buttons.add().growX().width(-1);
if(!steam){
buttons.addButton("?", () -> ui.showInfo("$join.info")).size(60f, 64f).width(-1);
buttons.button("?", () -> ui.showInfo("$join.info")).size(60f, 64f).width(-1);
}
add = new FloatingDialog("$joingame.title");
add.cont.add("$joingame.ip").padRight(5f).left();
TextField field = add.cont.addField(Core.settings.getString("ip"), text -> {
TextField field = add.cont.field(Core.settings.getString("ip"), text -> {
Core.settings.put("ip", text);
Core.settings.save();
}).size(320f, 54f).get();
@@ -56,8 +56,8 @@ public class JoinDialog extends FloatingDialog{
add.cont.row();
add.buttons.defaults().size(140f, 60f).pad(4f);
add.buttons.addButton("$cancel", add::hide);
add.buttons.addButton("$ok", () -> {
add.buttons.button("$cancel", add::hide);
add.buttons.button("$ok", () -> {
if(renaming == null){
Server server = new Server();
server.setIP(Core.settings.getString("ip"));
@@ -81,7 +81,7 @@ public class JoinDialog extends FloatingDialog{
}
});
keyDown(KeyCode.F5, this::refreshAll);
keyDown(KeyCode.f5, this::refreshAll);
shown(() -> {
setup();
@@ -111,7 +111,7 @@ public class JoinDialog extends FloatingDialog{
//why are java lambdas this bad
TextButton[] buttons = {null};
TextButton button = buttons[0] = remote.addButton("[accent]" + server.displayIP(), Styles.cleart, () -> {
TextButton button = buttons[0] = remote.button("[accent]" + server.displayIP(), Styles.cleart, () -> {
if(!buttons[0].childrenPressed()){
if(server.lastHost != null){
safeConnect(server.ip, server.port, server.lastHost.version);
@@ -129,26 +129,26 @@ public class JoinDialog extends FloatingDialog{
inner.add(button.getLabel()).growX();
inner.addImageButton(Icon.upOpen, Styles.emptyi, () -> {
inner.button(Icon.upOpen, Styles.emptyi, () -> {
moveRemote(server, -1);
}).margin(3f).padTop(6f).top().right();
inner.addImageButton(Icon.downOpen, Styles.emptyi, () -> {
inner.button(Icon.downOpen, Styles.emptyi, () -> {
moveRemote(server, +1);
}).margin(3f).pad(2).padTop(6f).top().right();
inner.addImageButton(Icon.refresh, Styles.emptyi, () -> {
inner.button(Icon.refresh, Styles.emptyi, () -> {
refreshServer(server);
}).margin(3f).pad(2).padTop(6f).top().right();
inner.addImageButton(Icon.pencil, Styles.emptyi, () -> {
inner.button(Icon.pencil, Styles.emptyi, () -> {
renaming = server;
add.show();
}).margin(3f).pad(2).padTop(6f).top().right();
inner.addImageButton(Icon.trash, Styles.emptyi, () -> {
inner.button(Icon.trash, Styles.emptyi, () -> {
ui.showConfirm("$confirm", "$server.delete", () -> {
servers.remove(server, true);
saveServers();
@@ -262,7 +262,7 @@ public class JoinDialog extends FloatingDialog{
cont.table(t -> {
t.add("$name").padRight(10);
if(!steam){
t.addField(Core.settings.getString("name"), text -> {
t.field(Core.settings.getString("name"), text -> {
player.name(text);
Core.settings.put("name", text);
Core.settings.save();
@@ -271,7 +271,7 @@ public class JoinDialog extends FloatingDialog{
t.add(player.name()).update(l -> l.setColor(player.color())).grow().pad(8);
}
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
ImageButton button = t.button(Tex.whiteui, Styles.clearFulli, 40, () -> {
new PaletteDialog().show(color -> {
player.color().set(color);
Core.settings.put("color-0", color.rgba8888());
@@ -283,7 +283,7 @@ public class JoinDialog extends FloatingDialog{
cont.row();
cont.add(pane).width(w + 38).pad(0);
cont.row();
cont.addCenteredImageTextButton("$server.add", Icon.add, () -> {
cont.buttonCenter("$server.add", Icon.add, () -> {
renaming = null;
add.show();
}).marginLeft(10).width(w).height(80f).update(button -> {
@@ -310,13 +310,13 @@ public class JoinDialog extends FloatingDialog{
hosts.table(name -> {
name.add(label).pad(10).growX().left().color(Pal.accent);
name.addImageButton(Icon.downOpen, Styles.emptyi, () -> {
name.button(Icon.downOpen, Styles.emptyi, () -> {
coll.toggle(false);
Core.settings.putSave("collapsed-" + label, coll.isCollapsed());
}).update(i -> i.getStyle().imageUp = (!coll.isCollapsed() ? Icon.upOpen : Icon.downOpen)).size(40f).right().padRight(10f);
}).growX();
hosts.row();
hosts.addImage().growX().pad(5).padLeft(10).padRight(10).height(3).color(Pal.accent);
hosts.image().growX().pad(5).padLeft(10).padRight(10).height(3).color(Pal.accent);
hosts.row();
hosts.add(coll).width(targetWidth());
hosts.row();
@@ -350,7 +350,7 @@ public class JoinDialog extends FloatingDialog{
local.background(Tex.button);
local.add("$hosts.none").pad(10f);
local.add().growX();
local.addImageButton(Icon.refresh, this::refreshLocal).pad(-12f).padLeft(0).size(70f);
local.button(Icon.refresh, this::refreshLocal).pad(-12f).padLeft(0).size(70f);
}else{
local.background(null);
}
@@ -366,7 +366,7 @@ public class JoinDialog extends FloatingDialog{
local.row();
TextButton button = local.addButton("", Styles.cleart, () -> safeConnect(host.address, host.port, host.version))
TextButton button = local.button("", Styles.cleart, () -> safeConnect(host.address, host.port, host.version))
.width(w).pad(5f).get();
button.clearChildren();
buildServer(host, button);
@@ -378,7 +378,7 @@ public class JoinDialog extends FloatingDialog{
global.row();
TextButton button = global.addButton("", Styles.cleart, () -> safeConnect(host.address, host.port, host.version))
TextButton button = global.button("", Styles.cleart, () -> safeConnect(host.address, host.port, host.version))
.width(w).pad(5f).get();
button.clearChildren();
buildServer(host, button);
@@ -70,25 +70,25 @@ public class LoadDialog extends FloatingDialog{
t.right();
t.defaults().size(40f);
t.addImageButton(Icon.save, Styles.emptytogglei, () -> {
t.button(Icon.save, Styles.emptytogglei, () -> {
slot.setAutosave(!slot.isAutosave());
}).checked(slot.isAutosave()).right();
t.addImageButton(Icon.trash, Styles.emptyi, () -> {
t.button(Icon.trash, Styles.emptyi, () -> {
ui.showConfirm("$confirm", "$save.delete.confirm", () -> {
slot.delete();
setup();
});
}).right();
t.addImageButton(Icon.pencil, Styles.emptyi, () -> {
t.button(Icon.pencil, Styles.emptyi, () -> {
ui.showTextInput("$save.rename", "$save.rename.text", slot.getName(), text -> {
slot.setName(text);
setup();
});
}).right();
t.addImageButton(Icon.export, Styles.emptyi, () -> platform.export("save-" + slot.getName(), saveExtension, slot::exportFile)).right();
t.button(Icon.export, Styles.emptyi, () -> platform.export("save-" + slot.getName(), saveExtension, slot::exportFile)).right();
}).padRight(-10).growX();
}).growX().colspan(2);
@@ -142,13 +142,13 @@ public class LoadDialog extends FloatingDialog{
if(!valids){
slots.row();
slots.addButton("$save.none", () -> {
slots.button("$save.none", () -> {
}).disabled(true).fillX().margin(20f).minWidth(340f).height(80f).pad(4f);
}
slots.row();
slots.addImageTextButton("$save.import", Icon.add, () -> {
slots.button("$save.import", Icon.add, () -> {
platform.showFileChooser(true, saveExtension, file -> {
if(SaveIO.isSaveValid(file)){
try{
@@ -26,7 +26,7 @@ public class LoadoutDialog extends FloatingDialog{
setFillParent(true);
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK){
if(key == KeyCode.escape || key == KeyCode.back){
Core.app.post(this::hide);
}
});
@@ -42,9 +42,9 @@ public class LoadoutDialog extends FloatingDialog{
}
});
buttons.addImageTextButton("$back", Icon.left, this::hide).size(210f, 64f);
buttons.button("$back", Icon.left, this::hide).size(210f, 64f);
buttons.addImageTextButton("$settings.reset", Icon.refresh, () -> {
buttons.button("$settings.reset", Icon.refresh, () -> {
resetter.run();
reseed();
updater.run();
@@ -73,17 +73,17 @@ public class LoadoutDialog extends FloatingDialog{
for(ItemStack stack : stacks){
items.table(Tex.pane, t -> {
t.margin(4).marginRight(8).left();
t.addButton("-", Styles.cleart, () -> {
t.button("-", Styles.cleart, () -> {
stack.amount = Math.max(stack.amount - step(stack.amount), 0);
updater.run();
}).size(bsize);
t.addButton("+", Styles.cleart, () -> {
t.button("+", Styles.cleart, () -> {
stack.amount = Math.min(stack.amount + step(stack.amount), capacity);
updater.run();
}).size(bsize);
t.addImageButton(Icon.pencil, Styles.cleari, () -> ui.showTextInput("$configure", stack.item.localizedName, 10, stack.amount + "", true, str -> {
t.button(Icon.pencil, Styles.cleari, () -> ui.showTextInput("$configure", stack.item.localizedName, 10, stack.amount + "", true, str -> {
if(Strings.canParsePostiveInt(str)){
int amount = Strings.parseInt(str);
if(amount >= 0 && amount <= capacity){
@@ -95,7 +95,7 @@ public class LoadoutDialog extends FloatingDialog{
ui.showInfo(Core.bundle.format("configure.invalid", capacity));
})).size(bsize);
t.addImage(stack.item.icon(Cicon.small)).size(8 * 3).padRight(4).padLeft(4);
t.image(stack.item.icon(Cicon.small)).size(8 * 3).padRight(4).padLeft(4);
t.label(() -> stack.amount + "").left().width(90f);
}).pad(2).left().fillX();
@@ -56,18 +56,18 @@ public class MapPlayDialog extends FloatingDialog{
for(Gamemode mode : Gamemode.values()){
if(mode.hidden) continue;
modes.addButton(mode.toString(), Styles.togglet, () -> {
modes.button(mode.toString(), Styles.togglet, () -> {
selectedGamemode = mode;
rules = map.applyRules(mode);
}).update(b -> b.setChecked(selectedGamemode == mode)).size(140f, 54f).disabled(!mode.valid(map));
if(i++ % 2 == 1) modes.row();
}
selmode.add(modes);
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
selmode.button("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
cont.add(selmode);
cont.row();
cont.addImageTextButton("$customize", Icon.settings, () -> dialog.show(rules, () -> rules = map.applyRules(selectedGamemode))).width(230);
cont.button("$customize", Icon.settings, () -> dialog.show(rules, () -> rules = map.applyRules(selectedGamemode))).width(230);
cont.row();
cont.add(new BorderImage(map.safeTexture(), 3f)).size(mobile && !Core.graphics.isPortrait() ? 150f : 250f).get().setScaling(Scaling.fit);
//only maps with survival are valid for high scores
@@ -79,7 +79,7 @@ public class MapPlayDialog extends FloatingDialog{
buttons.clearChildren();
addCloseButton();
buttons.addImageTextButton("$play", Icon.play, () -> {
buttons.button("$play", Icon.play, () -> {
control.playMap(map, rules);
hide();
ui.custom.hide();
@@ -103,7 +103,7 @@ public class MapPlayDialog extends FloatingDialog{
}
d.cont.add(pane);
d.buttons.addButton("$ok", d::hide).size(110, 50).pad(10f);
d.buttons.button("$ok", d::hide).size(110, 50).pad(10f);
d.show();
}
}
@@ -26,7 +26,7 @@ public class MapsDialog extends FloatingDialog{
buttons.remove();
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK){
if(key == KeyCode.escape || key == KeyCode.back){
Core.app.post(this::hide);
}
});
@@ -44,13 +44,13 @@ public class MapsDialog extends FloatingDialog{
buttons.clearChildren();
if(Core.graphics.isPortrait()){
buttons.addImageTextButton("$back", Icon.left, this::hide).size(210f*2f, 64f).colspan(2);
buttons.button("$back", Icon.left, this::hide).size(210f*2f, 64f).colspan(2);
buttons.row();
}else{
buttons.addImageTextButton("$back", Icon.left, this::hide).size(210f, 64f);
buttons.button("$back", Icon.left, this::hide).size(210f, 64f);
}
buttons.addImageTextButton("$editor.newmap", Icon.add, () -> {
buttons.button("$editor.newmap", Icon.add, () -> {
ui.showTextInput("$editor.newmap", "$editor.mapname", "", text -> {
Runnable show = () -> ui.loadAnd(() -> {
hide();
@@ -67,7 +67,7 @@ public class MapsDialog extends FloatingDialog{
});
}).size(210f, 64f);
buttons.addImageTextButton("$editor.importmap", Icon.upload, () -> {
buttons.button("$editor.importmap", Icon.upload, () -> {
platform.showFileChooser(true, mapExtension, file -> {
ui.loadAnd(() -> {
maps.tryCatchMapError(() -> {
@@ -134,12 +134,12 @@ public class MapsDialog extends FloatingDialog{
maps.row();
}
TextButton button = maps.addButton("", Styles.cleart, () -> showMapInfo(map)).width(mapsize).pad(8).get();
TextButton button = maps.button("", Styles.cleart, () -> showMapInfo(map)).width(mapsize).pad(8).get();
button.clearChildren();
button.margin(9);
button.add(map.name()).width(mapsize - 18f).center().get().setEllipsis(true);
button.row();
button.addImage().growX().pad(4).color(Pal.gray);
button.image().growX().pad(4).color(Pal.gray);
button.row();
button.stack(new Image(map.safeTexture()).setScaling(Scaling.fit), new BorderImage(map.safeTexture()).setScaling(Scaling.fit)).size(mapsize - 20f);
button.row();
@@ -192,7 +192,7 @@ public class MapsDialog extends FloatingDialog{
table.row();
table.addImageTextButton("$editor.openin", Icon.export, () -> {
table.button("$editor.openin", Icon.export, () -> {
try{
Vars.ui.editor.beginEditMap(map.file);
dialog.hide();
@@ -203,7 +203,7 @@ public class MapsDialog extends FloatingDialog{
}
}).fillX().height(54f).marginLeft(10);
table.addImageTextButton(map.workshop && steam ? "$view.workshop" : "$delete", map.workshop && steam ? Icon.link : Icon.trash, () -> {
table.button(map.workshop && steam ? "$view.workshop" : "$delete", map.workshop && steam ? Icon.link : Icon.trash, () -> {
if(map.workshop && steam){
platform.viewListing(map);
}else{
@@ -28,7 +28,7 @@ public class MinimapDialog extends FloatingDialog{
cont.clear();
cont.table(Tex.pane,t -> {
t.addRect((x, y, width, height) -> {
t.rect((x, y, width, height) -> {
if(renderer.minimap.getRegion() == null) return;
Draw.color(Color.white);
Draw.alpha(parentAlpha);
+14 -14
View File
@@ -23,7 +23,7 @@ public class ModsDialog extends FloatingDialog{
super("$mods");
addCloseButton();
buttons.addImageTextButton("$mods.guide", Icon.link, () -> Core.net.openURI(modGuideURL)).size(210, 64f);
buttons.button("$mods.guide", Icon.link, () -> Core.net.openURI(modGuideURL)).size(210, 64f);
shown(this::setup);
@@ -66,7 +66,7 @@ public class ModsDialog extends FloatingDialog{
TextButtonStyle style = Styles.clearPartialt;
float margin = 12f;
buttons.addImageTextButton("$mod.import", Icon.add, style, () -> {
buttons.button("$mod.import", Icon.add, style, () -> {
FloatingDialog dialog = new FloatingDialog("$mod.import");
TextButtonStyle bstyle = Styles.cleart;
@@ -75,7 +75,7 @@ public class ModsDialog extends FloatingDialog{
t.defaults().size(300f, 70f);
t.margin(12f);
t.addImageTextButton("$mod.import.file", Icon.file, bstyle, () -> {
t.button("$mod.import.file", Icon.file, bstyle, () -> {
dialog.hide();
platform.showFileChooser(true, "zip", file -> {
@@ -91,7 +91,7 @@ public class ModsDialog extends FloatingDialog{
t.row();
t.addImageTextButton("$mod.import.github", Icon.github, bstyle, () -> {
t.button("$mod.import.github", Icon.github, bstyle, () -> {
dialog.hide();
ui.showTextInput("$mod.import.github", "", 64, "Anuken/ExampleMod", text -> {
@@ -131,10 +131,10 @@ public class ModsDialog extends FloatingDialog{
dialog.show();
}).margin(margin);
buttons.addImageTextButton("$mods.reload", Icon.refresh, style, this::reload).margin(margin);
buttons.button("$mods.reload", Icon.refresh, style, this::reload).margin(margin);
if(!mobile){
buttons.addImageTextButton("$mods.openfolder", Icon.link, style, () -> Core.app.openFolder(modDirectory.absolutePath())).margin(margin);
buttons.button("$mods.openfolder", Icon.link, style, () -> Core.app.openFolder(modDirectory.absolutePath())).margin(margin);
}
}).width(w);
@@ -151,11 +151,11 @@ public class ModsDialog extends FloatingDialog{
if(!mod.enabled() && !anyDisabled && mods.list().size > 0){
anyDisabled = true;
table.row();
table.addImage().growX().height(4f).pad(6f).color(Pal.gray);
table.image().growX().height(4f).pad(6f).color(Pal.gray);
table.row();
}
table.addButton(t -> {
table.button(t -> {
t.top().left();
t.margin(12f);
@@ -176,26 +176,26 @@ public class ModsDialog extends FloatingDialog{
Fonts.def.draw(letter, x + width/2f, y + height/2f, Align.center);
}
}
}.border(Pal.accent)).size(h - 8f).padTop(-8f).padLeft(-8f).padRight(6f);
}.border(Pal.accent)).size(h - 8f).padTop(-8f).padLeft(-8f).padRight(2f);
t.defaults().left().top();
t.table(title -> {
title.left();
title.add("" + mod.meta.displayName() + "\n[lightgray]v" + mod.meta.version + (mod.enabled() ? "" : "\n" + Core.bundle.get("mod.disabled") + "")).growX();
title.add("" + mod.meta.displayName() + "\n[lightgray]v" + mod.meta.version + (mod.enabled() ? "" : "\n" + Core.bundle.get("mod.disabled") + "")).wrap().width(170f).growX();
title.add().growX();
title.addImageTextButton(mod.enabled() ? "$mod.disable" : "$mod.enable", mod.enabled() ? Icon.downOpen : Icon.upOpen, Styles.transt, () -> {
title.button(mod.enabled() ? "$mod.disable" : "$mod.enable", mod.enabled() ? Icon.downOpen : Icon.upOpen, Styles.transt, () -> {
mods.setEnabled(mod, !mod.enabled());
setup();
}).height(50f).margin(8f).width(130f).disabled(!mod.isSupported());
if(steam && !mod.hasSteamID()){
title.addImageButton(Icon.download, Styles.clearTransi, () -> {
title.button(Icon.download, Styles.clearTransi, () -> {
platform.publish(mod);
}).size(50f);
}
title.addImageButton(mod.hasSteamID() ? Icon.link : Icon.trash, Styles.clearPartiali, () -> {
title.button(mod.hasSteamID() ? Icon.link : Icon.trash, Styles.clearPartiali, () -> {
if(!mod.hasSteamID()){
ui.showConfirm("$confirm", "$mod.remove.confirm", () -> {
mods.removeMod(mod);
@@ -250,7 +250,7 @@ public class ModsDialog extends FloatingDialog{
dialog.addCloseButton();
if(!mobile){
dialog.buttons.addImageTextButton("$mods.openfolder", Icon.link, () -> Core.app.openFolder(mod.file.absolutePath()));
dialog.buttons.button("$mods.openfolder", Icon.link, () -> Core.app.openFolder(mod.file.absolutePath()));
}
//TODO improve this menu later
@@ -25,7 +25,7 @@ public class PaletteDialog extends Dialog{
for(int i = 0; i < playerColors.length; i++){
Color color = playerColors[i];
ImageButton button = table.addImageButton(Tex.whiteui, Styles.clearTogglei, 34, () -> {
ImageButton button = table.button(Tex.whiteui, Styles.clearTogglei, 34, () -> {
cons.get(color);
hide();
}).size(48).get();
@@ -38,7 +38,7 @@ public class PaletteDialog extends Dialog{
}
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK)
if(key == KeyCode.escape || key == KeyCode.back)
hide();
});
+15 -15
View File
@@ -18,7 +18,7 @@ public class PausedDialog extends FloatingDialog{
shown(this::rebuild);
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK){
if(key == KeyCode.escape || key == KeyCode.back){
hide();
}
});
@@ -37,26 +37,26 @@ public class PausedDialog extends FloatingDialog{
float dw = 220f;
cont.defaults().width(dw).height(55).pad(5f);
cont.addImageTextButton("$back", Icon.left, this::hide).colspan(2).width(dw * 2 + 20f);
cont.button("$back", Icon.left, this::hide).colspan(2).width(dw * 2 + 20f);
cont.row();
if(state.isCampaign()){
cont.addImageTextButton("$techtree", Icon.tree, ui.tech::show);
cont.button("$techtree", Icon.tree, ui.tech::show);
}else{
cont.addImageTextButton("$database", Icon.book, ui.database::show);
cont.button("$database", Icon.book, ui.database::show);
}
cont.addImageTextButton("$settings", Icon.settings, ui.settings::show);
cont.button("$settings", Icon.settings, ui.settings::show);
if(!state.rules.tutorial){
if(!state.isCampaign() && !state.isEditor()){
cont.row();
cont.addImageTextButton("$savegame", Icon.save, save::show);
cont.addImageTextButton("$loadgame", Icon.upload, load::show).disabled(b -> net.active());
cont.button("$savegame", Icon.save, save::show);
cont.button("$loadgame", Icon.upload, load::show).disabled(b -> net.active());
}
cont.row();
cont.addImageTextButton("$hostserver", Icon.host, () -> {
cont.button("$hostserver", Icon.host, () -> {
if(net.server() && steam){
platform.inviteFriends();
}else{
@@ -71,26 +71,26 @@ public class PausedDialog extends FloatingDialog{
cont.row();
cont.addImageTextButton("$quit", Icon.exit, this::showQuitConfirm).colspan(2).width(dw + 20f).update(s -> s.setText(control.saves.getCurrent() != null && control.saves.getCurrent().isAutosave() ? "$save.quit" : "$quit"));
cont.button("$quit", Icon.exit, this::showQuitConfirm).colspan(2).width(dw + 20f).update(s -> s.setText(control.saves.getCurrent() != null && control.saves.getCurrent().isAutosave() ? "$save.quit" : "$quit"));
}else{
cont.defaults().size(130f).pad(5);
cont.addRowImageTextButton("$back", Icon.play, this::hide);
cont.addRowImageTextButton("$settings", Icon.settings, ui.settings::show);
cont.buttonRow("$back", Icon.play, this::hide);
cont.buttonRow("$settings", Icon.settings, ui.settings::show);
if(!state.isCampaign() && !state.isEditor()){
cont.addRowImageTextButton("$save", Icon.save, save::show);
cont.buttonRow("$save", Icon.save, save::show);
cont.row();
cont.addRowImageTextButton("$load", Icon.download, load::show).disabled(b -> net.active());
cont.buttonRow("$load", Icon.download, load::show).disabled(b -> net.active());
}else{
cont.row();
}
cont.addRowImageTextButton("$hostserver.mobile", Icon.host, ui.host::show).disabled(b -> net.active());
cont.buttonRow("$hostserver.mobile", Icon.host, ui.host::show).disabled(b -> net.active());
cont.addRowImageTextButton("$quit", Icon.exit, this::showQuitConfirm).update(s -> {
cont.buttonRow("$quit", Icon.exit, this::showQuitConfirm).update(s -> {
s.setText(control.saves.getCurrent() != null && control.saves.getCurrent().isAutosave() ? "$save.quit" : "$quit");
s.getLabelCell().growX().wrap();
});
@@ -92,7 +92,7 @@ public class PlanetDialog extends FloatingDialog{
float bmargin = 6f;
//TODO names
buttons.addImageTextButton("$back", Icon.left, style, this::hide).margin(bmargin);
buttons.button("$back", Icon.left, style, this::hide).margin(bmargin);
//buttons.addImageTextButton("Tech", Icon.tree, style, () -> ui.tech.show()).margin(bmargin);
//buttons.addImageTextButton("Launch", Icon.upOpen, style, this::hide).margin(bmargin);
//buttons.addImageTextButton("Database", Icon.book, style, () -> ui.database.show()).margin(bmargin);
@@ -163,7 +163,7 @@ public class PlanetDialog extends FloatingDialog{
cont.clear();
titleTable.remove();
cont.addRect((x, y, w, h) -> render()).grow();
cont.rect((x, y, w, h) -> render()).grow();
}
private void render(){
@@ -341,7 +341,7 @@ public class PlanetDialog extends FloatingDialog{
//TODO add strings to bundle after prototyping is done
stable.add("[accent]" + selected.id).row();
stable.addImage().color(Pal.accent).fillX().height(3f).pad(3f).row();
stable.image().color(Pal.accent).fillX().height(3f).pad(3f).row();
stable.add(selected.save != null ? selected.save.getPlayTime() : "[lightgray]Unexplored").row();
stable.add("Resources:").row();
@@ -350,14 +350,14 @@ public class PlanetDialog extends FloatingDialog{
int idx = 0;
int max = 5;
for(UnlockableContent c : selected.data.resources){
t.addImage(c.icon(Cicon.small)).padRight(3);
t.image(c.icon(Cicon.small)).padRight(3);
if(++idx % max == 0) t.row();
}
}).fillX().row();
stable.row();
stable.addButton("Launch", Styles.transt, () -> {
stable.button("Launch", Styles.transt, () -> {
if(selected != null){
if(selected.is(SectorAttribute.naval)){
ui.showInfo("You need a naval loadout to launch here.");
@@ -3,7 +3,6 @@ package mindustry.ui.dialogs;
import arc.Core;
import arc.scene.ui.TextButton;
import arc.util.Time;
import mindustry.core.GameState.State;
import mindustry.game.Saves.SaveSlot;
import mindustry.gen.*;
@@ -23,7 +22,7 @@ public class SaveDialog extends LoadDialog{
public void addSetup(){
slots.row();
slots.addImageTextButton("$save.new", Icon.add, () ->
slots.button("$save.new", Icon.add, () ->
ui.showTextInput("$save", "$save.newslot", 30, "", text -> {
ui.loadAnd("$saving", () -> {
control.saves.addSave(text);
@@ -31,7 +31,7 @@ public class SchematicsDialog extends FloatingDialog{
shouldPause = true;
addCloseButton();
buttons.addImageTextButton("$schematic.import", Icon.download, this::showImport);
buttons.button("$schematic.import", Icon.download, this::showImport);
shown(this::setup);
onResize(this::setup);
}
@@ -45,8 +45,8 @@ public class SchematicsDialog extends FloatingDialog{
cont.table(s -> {
s.left();
s.addImage(Icon.zoom);
s.addField(search, res -> {
s.image(Icon.zoom);
s.field(search, res -> {
search = res;
rebuildPane[0].run();
}).growX();
@@ -69,7 +69,7 @@ public class SchematicsDialog extends FloatingDialog{
if(!search.isEmpty() && !s.name().toLowerCase().contains(search.toLowerCase())) continue;
Button[] sel = {null};
sel[0] = t.addButton(b -> {
sel[0] = t.button(b -> {
b.top();
b.margin(0f);
b.table(buttons -> {
@@ -78,15 +78,15 @@ public class SchematicsDialog extends FloatingDialog{
ImageButtonStyle style = Styles.clearPartiali;
buttons.addImageButton(Icon.info, style, () -> {
buttons.button(Icon.info, style, () -> {
showInfo(s);
});
buttons.addImageButton(Icon.download, style, () -> {
buttons.button(Icon.download, style, () -> {
showExport(s);
});
buttons.addImageButton(Icon.pencil, style, () -> {
buttons.button(Icon.pencil, style, () -> {
ui.showTextInput("$schematic.rename", "$name", s.name(), res -> {
Schematic replacement = schematics.all().find(other -> other.name().equals(res) && other != s);
if(replacement != null){
@@ -102,9 +102,9 @@ public class SchematicsDialog extends FloatingDialog{
});
if(s.hasSteamID()){
buttons.addImageButton(Icon.link, style, () -> platform.viewListing(s));
buttons.button(Icon.link, style, () -> platform.viewListing(s));
}else{
buttons.addImageButton(Icon.trash, style, () -> {
buttons.button(Icon.trash, style, () -> {
if(s.mod != null){
ui.showInfo(Core.bundle.format("mod.item.remove", s.mod.meta.displayName()));
}else{
@@ -160,7 +160,7 @@ public class SchematicsDialog extends FloatingDialog{
TextButtonStyle style = Styles.cleart;
t.defaults().size(280f, 60f).left();
t.row();
t.addImageTextButton("$schematic.copy.import", Icon.copy, style, () -> {
t.button("$schematic.copy.import", Icon.copy, style, () -> {
dialog.hide();
try{
Schematic s = Schematics.readBase64(Core.app.getClipboardText());
@@ -174,7 +174,7 @@ public class SchematicsDialog extends FloatingDialog{
}
}).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null || !Core.app.getClipboardText().startsWith(schematicBaseStart));
t.row();
t.addImageTextButton("$schematic.importfile", Icon.download, style, () -> platform.showFileChooser(true, schematicExtension, file -> {
t.button("$schematic.importfile", Icon.download, style, () -> platform.showFileChooser(true, schematicExtension, file -> {
dialog.hide();
try{
@@ -189,7 +189,7 @@ public class SchematicsDialog extends FloatingDialog{
})).marginLeft(12f);
t.row();
if(steam){
t.addImageTextButton("$schematic.browseworkshop", Icon.book, style, () -> {
t.button("$schematic.browseworkshop", Icon.book, style, () -> {
dialog.hide();
platform.openWorkshop();
}).marginLeft(12f);
@@ -209,18 +209,18 @@ public class SchematicsDialog extends FloatingDialog{
TextButtonStyle style = Styles.cleart;
t.defaults().size(280f, 60f).left();
if(steam && !s.hasSteamID()){
t.addImageTextButton("$schematic.shareworkshop", Icon.book, style,
t.button("$schematic.shareworkshop", Icon.book, style,
() -> platform.publish(s)).marginLeft(12f);
t.row();
dialog.hide();
}
t.addImageTextButton("$schematic.copy", Icon.copy, style, () -> {
t.button("$schematic.copy", Icon.copy, style, () -> {
dialog.hide();
ui.showInfoFade("$copied");
Core.app.setClipboardText(schematics.writeBase64(s));
}).marginLeft(12f);
t.row();
t.addImageTextButton("$schematic.exportfile", Icon.export, style, () -> {
t.button("$schematic.exportfile", Icon.export, style, () -> {
dialog.hide();
platform.export(s.name(), schematicExtension, file -> Schematics.write(s, file));
}).marginLeft(12f);
@@ -312,7 +312,7 @@ public class SchematicsDialog extends FloatingDialog{
cont.table(r -> {
int i = 0;
for(ItemStack s : arr){
r.addImage(s.item.icon(Cicon.small)).left();
r.image(s.item.icon(Cicon.small)).left();
r.label(() -> {
Tilec core = player.closestCore();
if(core == null || state.rules.infiniteResources || core.items().has(s.item, s.amount)) return "[lightgray]" + s.amount + "";
@@ -84,7 +84,7 @@ public class SettingsMenuDialog extends SettingsDialog{
t.defaults().size(270f, 60f).left();
TextButtonStyle style = Styles.cleart;
t.addImageTextButton("$settings.cleardata", Icon.trash, style, () -> ui.showConfirm("$confirm", "$settings.clearall.confirm", () -> {
t.button("$settings.cleardata", Icon.trash, style, () -> ui.showConfirm("$confirm", "$settings.clearall.confirm", () -> {
ObjectMap<String, Object> map = new ObjectMap<>();
for(String value : Core.settings.keys()){
if(value.contains("usid") || value.contains("uuid")){
@@ -104,7 +104,7 @@ public class SettingsMenuDialog extends SettingsDialog{
t.row();
t.addImageTextButton("$data.export", Icon.download, style, () -> {
t.button("$data.export", Icon.download, style, () -> {
if(ios){
Fi file = Core.files.local("mindustry-data-export.zip");
try{
@@ -128,7 +128,7 @@ public class SettingsMenuDialog extends SettingsDialog{
t.row();
t.addImageTextButton("$data.import", Icon.download, style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
t.button("$data.import", Icon.download, style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
try{
data.importData(file);
Core.app.exit();
@@ -146,7 +146,7 @@ public class SettingsMenuDialog extends SettingsDialog{
if(!mobile){
t.row();
t.addImageTextButton("$data.openfolder", Icon.folder, style, () -> Core.app.openFolder(Core.settings.getDataDirectory().absolutePath()));
t.button("$data.openfolder", Icon.folder, style, () -> Core.app.openFolder(Core.settings.getDataDirectory().absolutePath()));
}
});
@@ -185,20 +185,20 @@ public class SettingsMenuDialog extends SettingsDialog{
TextButtonStyle style = Styles.cleart;
menu.defaults().size(300f, 60f);
menu.addButton("$settings.game", style, () -> visible(0));
menu.button("$settings.game", style, () -> visible(0));
menu.row();
menu.addButton("$settings.graphics", style, () -> visible(1));
menu.button("$settings.graphics", style, () -> visible(1));
menu.row();
menu.addButton("$settings.sound", style, () -> visible(2));
menu.button("$settings.sound", style, () -> visible(2));
menu.row();
menu.addButton("$settings.language", style, ui.language::show);
menu.button("$settings.language", style, ui.language::show);
if(!mobile || Core.settings.getBool("keyboard")){
menu.row();
menu.addButton("$settings.controls", style, ui.controls::show);
menu.button("$settings.controls", style, ui.controls::show);
}
menu.row();
menu.addButton("$settings.data", style, () -> dataDialog.show());
menu.button("$settings.data", style, () -> dataDialog.show());
}
void addSettings(){
@@ -256,7 +256,7 @@ public class SettingsMenuDialog extends SettingsDialog{
game.pref(new Setting(){
@Override
public void add(SettingsTable table){
table.addButton("$tutorial.retake", () -> {
table.button("$tutorial.retake", () -> {
hide();
control.playTutorial();
}).size(220f, 60f).pad(6).left();
@@ -378,7 +378,7 @@ public class SettingsMenuDialog extends SettingsDialog{
@Override
public void addCloseButton(){
buttons.addImageTextButton("$back", Icon.leftOpen, () -> {
buttons.button("$back", Icon.leftOpen, () -> {
if(prefs.getChildren().first() != menu){
back();
}else{
@@ -387,7 +387,7 @@ public class SettingsMenuDialog extends SettingsDialog{
}).size(230f, 64f);
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK){
if(key == KeyCode.escape || key == KeyCode.back){
if(prefs.getChildren().first() != menu){
back();
}else{
@@ -63,7 +63,7 @@ public class TechTreeDialog extends FloatingDialog{
addCloseButton();
buttons.addImageTextButton("$database", Icon.book, () -> {
buttons.button("$database", Icon.book, () -> {
hide();
ui.database.show();
}).size(210f, 64f);
@@ -343,7 +343,7 @@ public class TechTreeDialog extends FloatingDialog{
infoTable.table(b -> {
b.margin(0).left().defaults().left();
b.addImageButton(Icon.info, Styles.cleari, () -> ui.content.show(node.block)).growY().width(50f);
b.button(Icon.info, Styles.cleari, () -> ui.content.show(node.block)).growY().width(50f);
b.add().grow();
b.table(desc -> {
desc.left().defaults().left();
@@ -355,7 +355,7 @@ public class TechTreeDialog extends FloatingDialog{
for(ItemStack req : node.requirements){
t.table(list -> {
list.left();
list.addImage(req.item.icon(Cicon.small)).size(8 * 3).padRight(3);
list.image(req.item.icon(Cicon.small)).size(8 * 3).padRight(3);
list.add(req.item.localizedName).color(Color.lightGray);
list.label(() -> " " + Math.min(data.getItem(req.item), req.amount) + " / " + req.amount)
.update(l -> l.setColor(data.has(req.item, req.amount) ? Color.lightGray : Color.scarlet));
@@ -370,7 +370,7 @@ public class TechTreeDialog extends FloatingDialog{
if(mobile && locked(node)){
b.row();
b.addImageTextButton("$research", Icon.ok, Styles.nodet, () -> unlock(node))
b.button("$research", Icon.ok, Styles.nodet, () -> unlock(node))
.disabled(i -> !data.hasItems(node.requirements)).growX().height(44f).colspan(3);
}
});
@@ -46,7 +46,7 @@ public class ZoneInfoDialog extends FloatingDialog{
if(i++ % 2 == 0){
iteminfo.row();
}
iteminfo.addImage(stack.item.icon(Cicon.small)).size(8 * 3).padRight(1);
iteminfo.image(stack.item.icon(Cicon.small)).size(8 * 3).padRight(1);
iteminfo.add(stack.amount + "").color(Color.lightGray).padRight(5);
}
};
@@ -55,7 +55,7 @@ public class ZoneInfoDialog extends FloatingDialog{
cont.pane(cont -> {
if(zone.locked()){
cont.addImage(Icon.lock);
cont.image(Icon.lock);
cont.row();
cont.add("$locked").padBottom(6);
cont.row();
@@ -70,9 +70,9 @@ public class ZoneInfoDialog extends FloatingDialog{
r.add("$complete").colspan(2).left();
r.row();
for(Objective o : zones){
r.addImage(Icon.terrain).padRight(4);
r.image(Icon.terrain).padRight(4);
r.add(o.display()).color(Color.lightGray);
r.addImage(o.complete() ? Icon.ok : Icon.cancel, o.complete() ? Color.lightGray : Color.scarlet).padLeft(3);
r.image(o.complete() ? Icon.ok : Icon.cancel, o.complete() ? Color.lightGray : Color.scarlet).padLeft(3);
r.row();
}
});
@@ -86,9 +86,9 @@ public class ZoneInfoDialog extends FloatingDialog{
r.add("$research.list").colspan(2).left();
r.row();
for(Unlock blocko : blocks){
r.addImage(blocko.block.icon(Cicon.small)).size(8 * 3).padRight(5);
r.image(blocko.block.icon(Cicon.small)).size(8 * 3).padRight(5);
r.add(blocko.block.localizedName).color(Color.lightGray).left();
r.addImage(blocko.block.unlocked() ? Icon.ok : Icon.cancel, blocko.block.unlocked() ? Color.lightGray : Color.scarlet).padLeft(3);
r.image(blocko.block.unlocked() ? Icon.ok : Icon.cancel, blocko.block.unlocked() ? Color.lightGray : Color.scarlet).padLeft(3);
r.row();
}
@@ -99,7 +99,7 @@ public class ZoneInfoDialog extends FloatingDialog{
}else{
cont.add(zone.localizedName).color(Pal.accent).growX().center();
cont.row();
cont.addImage().color(Pal.accent).height(3).pad(6).growX();
cont.image().color(Pal.accent).height(3).pad(6).growX();
cont.row();
cont.table(desc -> {
desc.left().defaults().left().width(Core.graphics.isPortrait() ? 350f : 500f);
@@ -115,7 +115,7 @@ public class ZoneInfoDialog extends FloatingDialog{
t.left();
int i = 0;
for(Item item : zone.resources){
r.addImage(item.icon(Cicon.small)).size(8 * 3);
r.image(item.icon(Cicon.small)).size(8 * 3);
if(++i % 4 == 0){
r.row();
}
@@ -143,13 +143,13 @@ public class ZoneInfoDialog extends FloatingDialog{
});
cont.row();
cont.addButton(zone.canConfigure() ? "$configure" : Core.bundle.format("configure.locked", zone.configureObjective.display()),
cont.button(zone.canConfigure() ? "$configure" : Core.bundle.format("configure.locked", zone.configureObjective.display()),
() -> loadout.show(zone.loadout.findCore().itemCapacity, zone.getStartingItems(), zone::resetStartingItems, zone::updateLaunchCost, rebuildItems)
).fillX().pad(3).disabled(b -> !zone.canConfigure());
cont.row();
Button button = cont.addButton(zone.locked() ? "$uncover" : "$launch", () -> {
Button button = cont.button(zone.locked() ? "$uncover" : "$launch", () -> {
if(!data.isUnlocked(zone)){
Sounds.unlock.play();
data.unlockContent(zone);
@@ -14,7 +14,6 @@ import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.core.GameState.*;
import mindustry.entities.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
@@ -27,11 +26,13 @@ import static mindustry.Vars.*;
public class BlockInventoryFragment extends Fragment{
private final static float holdWithdraw = 20f;
private final static float holdShrink = 120f;
private Table table = new Table();
private Tilec tile;
private float holdTime = 0f;
private float holdTime = 0f, emptyTime;
private boolean holding;
private float[] shrinkHoldTimes = new float[content.items().size];
private Item lastItem;
{
@@ -99,9 +100,15 @@ public class BlockInventoryFragment extends Fragment{
table.touchable(Touchable.enabled);
table.update(() -> {
if(state.isMenu() || tile == null || !tile.isValid() || !tile.block().isAccessible() || tile.items().total() == 0){
if(state.isMenu() || tile == null || !tile.isValid() || !tile.block().isAccessible() || emptyTime >= holdShrink){
hide();
}else{
if(tile.items().total() == 0){
emptyTime += Time.delta();
}else{
emptyTime = 0f;
}
if(holding && lastItem != null){
holdTime += Time.delta();
@@ -117,12 +124,21 @@ public class BlockInventoryFragment extends Fragment{
updateTablePosition();
if(tile.block().hasItems){
boolean dirty = false;
if(shrinkHoldTimes.length != content.items().size) shrinkHoldTimes = new float[content.items().size];
for(int i = 0; i < content.items().size; i++){
boolean has = tile.items().has(content.item(i));
if(has != container.contains(i)){
rebuild(false);
boolean had = container.contains(i);
if(has){
shrinkHoldTimes[i] = 0f;
dirty |= !had;
}else if(had){
shrinkHoldTimes[i] += Time.delta();
dirty |= shrinkHoldTimes[i] >= holdShrink;
}
}
if(dirty) rebuild(false);
}
}
});
@@ -57,12 +57,12 @@ public class HudFragment extends Fragment{
ImageButtonStyle style = Styles.clearTransi;
select.addImageButton(Icon.menu, style, ui.paused::show);
flip = select.addImageButton(Icon.upOpen, style, this::toggleMenus).get();
select.button(Icon.menu, style, ui.paused::show);
flip = select.button(Icon.upOpen, style, this::toggleMenus).get();
select.addImageButton(Icon.paste, style, ui.schematics::show);
select.button(Icon.paste, style, ui.schematics::show);
select.addImageButton(Icon.pause, style, () -> {
select.button(Icon.pause, style, () -> {
if(net.active()){
ui.listfrag.toggle();
}else{
@@ -77,7 +77,7 @@ public class HudFragment extends Fragment{
}
});
select.addImageButton(Icon.chat, style,() -> {
select.button(Icon.chat, style,() -> {
if(net.active() && mobile){
if(ui.chatfrag.shown()){
ui.chatfrag.hide();
@@ -97,7 +97,7 @@ public class HudFragment extends Fragment{
}
});
select.addImage().color(Pal.gray).width(4f).fillY();
select.image().color(Pal.gray).width(4f).fillY();
float size = Scl.scl(dsize);
Array<Element> children = new Array<>(select.getChildren());
@@ -122,7 +122,7 @@ public class HudFragment extends Fragment{
}
cont.row();
cont.addImage().height(4f).color(Pal.gray).fillX();
cont.image().height(4f).color(Pal.gray).fillX();
cont.row();
}
@@ -164,7 +164,7 @@ public class HudFragment extends Fragment{
teams.left();
int i = 0;
for(Team team : Team.base()){
ImageButton button = teams.addImageButton(Tex.whiteui, Styles.clearTogglePartiali, 40f, () -> Call.setPlayerTeamEditor(player, team))
ImageButton button = teams.button(Tex.whiteui, Styles.clearTogglePartiali, 40f, () -> Call.setPlayerTeamEditor(player, team))
.size(50f).margin(6f).get();
button.getImageCell().grow();
button.getStyle().imageUpColor = team.color;
@@ -261,7 +261,7 @@ public class HudFragment extends Fragment{
setDisabled(() -> !control.tutorial.canNext());
}},
new Table(f -> {
f.left().addImageButton(Icon.left, Styles.emptyi, () -> {
f.left().button(Icon.left, Styles.emptyi, () -> {
control.tutorial.prevSentence();
}).width(44f).growY().visible(() -> control.tutorial.canPrev());
}));
@@ -340,7 +340,7 @@ public class HudFragment extends Fragment{
}
});
table.margin(12);
table.addImage(Icon.ok).pad(3);
table.image(Icon.ok).pad(3);
table.add(text).wrap().width(280f).get().setAlignment(Align.center, Align.center);
table.pack();
@@ -441,7 +441,7 @@ public class HudFragment extends Fragment{
lastUnlockLayout.add(image);
}else{ //else, add a specific icon to denote no more space
lastUnlockLayout.addImage(Icon.add);
lastUnlockLayout.image(Icon.add);
}
lastUnlockLayout.pack();
@@ -486,13 +486,13 @@ public class HudFragment extends Fragment{
dialog.cont.add("$launch.confirm").width(500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.buttons.defaults().size(200f, 54f).pad(2f);
dialog.setFillParent(false);
dialog.buttons.addButton("$cancel", dialog::hide);
dialog.buttons.addButton("$ok", () -> {
dialog.buttons.button("$cancel", dialog::hide);
dialog.buttons.button("$ok", () -> {
dialog.hide();
Call.launchZone();
});
dialog.keyDown(KeyCode.ESCAPE, dialog::hide);
dialog.keyDown(KeyCode.BACK, dialog::hide);
dialog.keyDown(KeyCode.escape, dialog::hide);
dialog.keyDown(KeyCode.back, dialog::hide);
dialog.show();
}
@@ -597,7 +597,7 @@ public class HudFragment extends Fragment{
}
private void addPlayButton(Table table){
table.right().addImageButton(Icon.play, Styles.righti, 30f, () -> {
table.right().button(Icon.play, Styles.righti, 30f, () -> {
if(net.client() && player.admin()){
Call.onAdminRequest(player, AdminAction.wave);
}else if(inLaunchWave()){
@@ -22,16 +22,16 @@ public class LoadingFragment extends Fragment{
t.visible(false);
t.touchable(Touchable.enabled);
t.add().height(133f).row();
t.addImage().growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.image().growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.row();
t.add("$loading").name("namelabel").pad(10f);
t.row();
t.addImage().growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.image().growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.row();
bar = t.add(new Bar()).pad(3).size(500f, 40f).visible(false).get();
t.row();
button = t.addButton("$cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
button = t.button("$cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
table = t;
});
}
@@ -57,10 +57,10 @@ public class MenuFragment extends Fragment{
//info icon
if(mobile){
parent.fill(c -> c.bottom().left().addButton("", Styles.infot, ui.about::show).size(84, 45));
parent.fill(c -> c.bottom().right().addButton("", Styles.discordt, ui.discord::show).size(84, 45));
parent.fill(c -> c.bottom().left().button("", Styles.infot, ui.about::show).size(84, 45));
parent.fill(c -> c.bottom().right().button("", Styles.discordt, ui.discord::show).size(84, 45));
}else if(becontrol.active()){
parent.fill(c -> c.bottom().right().addImageTextButton("$be.check", Icon.refresh, () -> {
parent.fill(c -> c.bottom().right().button("$be.check", Icon.refresh, () -> {
ui.loadfrag.show();
becontrol.checkUpdate(result -> {
ui.loadfrag.hide();
@@ -219,7 +219,7 @@ public class MenuFragment extends Fragment{
for(Buttoni b : buttons){
if(b == null) continue;
Button[] out = {null};
out[0] = t.addImageTextButton(b.text, b.icon, Styles.clearToggleMenut, () -> {
out[0] = t.button(b.text, b.icon, Styles.clearToggleMenut, () -> {
if(currentMenu == out[0]){
currentMenu = null;
fadeOutMenu();
@@ -100,7 +100,7 @@ public class MinimapFragment extends Fragment{
t.row();
t.add().growY();
t.row();
t.addImageTextButton("$back", Icon.leftOpen, () -> shown = false).size(220f, 60f).pad(10f);
t.button("$back", Icon.leftOpen, () -> shown = false).size(220f, 60f).pad(10f);
});
}
@@ -205,9 +205,9 @@ public class PlacementFragment extends Fragment{
blockTable.row();
}
ImageButton button = blockTable.addImageButton(new TextureRegionDrawable(block.icon(Cicon.medium)), Styles.selecti, () -> {
ImageButton button = blockTable.button(new TextureRegionDrawable(block.icon(Cicon.medium)), Styles.selecti, () -> {
if(unlocked(block)){
if(Core.input.keyDown(KeyCode.SHIFT_LEFT) && Fonts.getUnicode(block.name) != 0){
if(Core.input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(block.name) != 0){
Core.app.setClipboardText((char)Fonts.getUnicode(block.name) + "");
ui.showInfoFade("$copied");
}else{
@@ -290,7 +290,7 @@ public class PlacementFragment extends Fragment{
.left().width(190f).padLeft(5);
header.add().growX();
if(unlocked(lastDisplay)){
header.addButton("?", Styles.clearPartialt, () -> {
header.button("?", Styles.clearPartialt, () -> {
ui.content.show(lastDisplay);
Events.fire(new BlockInfoEvent());
}).size(8 * 5).padTop(-5).padRight(-5).right().grow().name("blockinfo");
@@ -304,7 +304,7 @@ public class PlacementFragment extends Fragment{
for(ItemStack stack : lastDisplay.requirements){
req.table(line -> {
line.left();
line.addImage(stack.item.icon(Cicon.small)).size(8 * 2);
line.image(stack.item.icon(Cicon.small)).size(8 * 2);
line.add(stack.item.localizedName).maxWidth(140f).fillX().color(Color.lightGray).padLeft(2).left().get().setEllipsis(true);
line.labelWrap(() -> {
Tilec core = player.closestCore();
@@ -324,7 +324,7 @@ public class PlacementFragment extends Fragment{
if(state.rules.bannedBlocks.contains(lastDisplay) || !player.isBuilder()){
topTable.row();
topTable.table(b -> {
b.addImage(Icon.cancel).padRight(2).color(Color.scarlet);
b.image(Icon.cancel).padRight(2).color(Color.scarlet);
b.add(!player.isBuilder() ? "$unit.nobuild" : "$banned");
b.left();
}).padTop(2).left();
@@ -350,7 +350,7 @@ public class PlacementFragment extends Fragment{
});
}).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled);
frame.row();
frame.addImage().color(Pal.gray).colspan(3).height(4).growX();
frame.image().color(Pal.gray).colspan(3).height(4).growX();
frame.row();
frame.table(Tex.pane2, blocksSelect -> {
blocksSelect.margin(4).marginTop(0);
@@ -390,11 +390,11 @@ public class PlacementFragment extends Fragment{
if(f++ % 2 == 0) categories.row();
if(categoryEmpty[cat.ordinal()]){
categories.addImage(Styles.black6);
categories.image(Styles.black6);
continue;
}
categories.addImageButton(ui.getIcon(cat.name()), Styles.clearToggleTransi, () -> {
categories.button(ui.getIcon(cat.name()), Styles.clearToggleTransi, () -> {
currentCategory = cat;
if(control.input.block != null){
control.input.block = getSelectedBlock(currentCategory);
@@ -44,7 +44,7 @@ public class PlayerListFragment extends Fragment{
cont.table(Tex.buttonTrans, pane -> {
pane.label(() -> Core.bundle.format(Groups.player.size() == 1 ? "players.single" : "players", Groups.player.size()));
pane.row();
sField = pane.addField(null, text -> {
sField = pane.field(null, text -> {
rebuild();
}).grow().pad(8).get();
sField.setMaxLength(maxNameLength);
@@ -57,9 +57,9 @@ public class PlayerListFragment extends Fragment{
pane.table(menu -> {
menu.defaults().growX().height(50f).fillY();
menu.addButton("$server.bans", ui.bans::show).disabled(b -> net.client());
menu.addButton("$server.admins", ui.admins::show).disabled(b -> net.client());
menu.addButton("$close", this::toggle);
menu.button("$server.bans", ui.bans::show).disabled(b -> net.client());
menu.button("$server.admins", ui.admins::show).disabled(b -> net.client());
menu.button("$close", this::toggle);
}).margin(0f).pad(10f).growX();
}).touchable(Touchable.enabled).margin(14f);
@@ -105,7 +105,7 @@ public class PlayerListFragment extends Fragment{
button.labelWrap("[#" + user.color().toString().toUpperCase() + "]" + user.name()).width(170f).pad(10);
button.add().grow();
button.addImage(Icon.admin).visible(() -> user.admin() && !(!user.isLocal() && net.server())).padRight(5).get().updateVisibility();
button.image(Icon.admin).visible(() -> user.admin() && !(!user.isLocal() && net.server())).padRight(5).get().updateVisibility();
if((net.server() || player.admin()) && !user.isLocal() && (!user.admin() || net.server())){
button.add().growY();
@@ -115,14 +115,14 @@ public class PlayerListFragment extends Fragment{
button.table(t -> {
t.defaults().size(bs);
t.addImageButton(Icon.hammer, Styles.clearPartiali,
t.button(Icon.hammer, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", Core.bundle.format("confirmban", user.name()), () -> Call.onAdminRequest(user, AdminAction.ban)));
t.addImageButton(Icon.cancel, Styles.clearPartiali,
t.button(Icon.cancel, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.onAdminRequest(user, AdminAction.kick)));
t.row();
t.addImageButton(Icon.admin, Styles.clearTogglePartiali, () -> {
t.button(Icon.admin, Styles.clearTogglePartiali, () -> {
if(net.client()) return;
String id = user.uuid();
@@ -137,19 +137,19 @@ public class PlayerListFragment extends Fragment{
.touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled)
.checked(user.admin());
t.addImageButton(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace));
t.button(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace));
}).padRight(12).size(bs + 10f, bs);
}else if(!user.isLocal() && !user.admin() && net.client() && Groups.player.size() >= 3 && player.team() == user.team()){ //votekick
button.add().growY();
button.addImageButton(Icon.hammer, Styles.clearPartiali,
button.button(Icon.hammer, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", Core.bundle.format("confirmvotekick", user.name()), () -> Call.sendChatMessage("/votekick " + user.name()))).size(h);
}
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14);
content.row();
content.addImage().height(4f).color(state.rules.pvp ? user.team().color : Pal.gray).growX();
content.image().height(4f).color(state.rules.pvp ? user.team().color : Pal.gray).growX();
content.row();
});
-12
View File
@@ -90,10 +90,6 @@ public class Block extends UnlockableContent{
public CacheLayer cacheLayer = CacheLayer.normal;
/** Special flag; if false, floor will be drawn under this block even if it is cached. */
public boolean fillsTile = true;
/** Layer to draw extra stuff on. */
public Layer layer = null;
/** Extra layer to draw extra extra stuff on. */
public Layer layer2 = null;
/** whether this block can be replaced in all cases */
public boolean alwaysReplace = false;
/** The block group. Unless {@link #canReplace} is overriden, blocks in the same group can replace each other. */
@@ -204,14 +200,6 @@ public class Block extends UnlockableContent{
return sum / size / size;
}
public void drawLayer(Tile tile){
if(tile.entity != null) tile.entity.drawLayer();
}
public void drawLayer2(Tile tile){
if(tile.entity != null) tile.entity.drawLayer2();
}
/** Drawn when you are placing a block. */
public void drawPlace(int x, int y, int rotation, boolean valid){
}
+12 -14
View File
@@ -36,7 +36,6 @@ public class BuildBlock extends Block{
this.size = size;
update = true;
health = 20;
layer = Layer.placement;
consumesTap = true;
solidifes = true;
buildBlocks[size - 1] = this;
@@ -180,23 +179,22 @@ public class BuildBlock extends Block{
if(Core.atlas.isFound(previous.icon(Cicon.full))){
Draw.rect(previous.icon(Cicon.full), x, y, previous.rotate ? tile.rotation() * 90 : 0);
}
}
@Override
public void drawLayer(){
Shaders.blockbuild.color = Pal.accent;
Draw.draw(Layer.blockBuilding, () -> {
Shaders.blockbuild.color = Pal.accent;
Block target = cblock == null ? previous : cblock;
Block target = cblock == null ? previous : cblock;
if(target == null) return;
if(target != null){
for(TextureRegion region : target.getGeneratedIcons()){
Shaders.blockbuild.region = region;
Shaders.blockbuild.progress = progress;
for(TextureRegion region : target.getGeneratedIcons()){
Shaders.blockbuild.region = region;
Shaders.blockbuild.progress = progress;
Draw.rect(region, x, y, target.rotate ? tile.rotation() * 90 : 0);
Draw.flush();
}
Draw.rect(region, x, y, target.rotate ? tile.rotation() * 90 : 0);
Draw.flush();
}
}
});
}
public boolean construct(Unitc builder, @Nullable Tilec core, float amount, boolean configured){
@@ -26,7 +26,7 @@ public class ItemSelection{
for(T item : items){
if(!data.isUnlocked(item) && state.isCampaign()) continue;
ImageButton button = cont.addImageButton(Tex.whiteui, Styles.clearToggleTransi, 24, () -> control.input.frag.config.hideConfig()).group(group).get();
ImageButton button = cont.button(Tex.whiteui, Styles.clearToggleTransi, 24, () -> control.input.frag.config.hideConfig()).group(group).get();
button.changed(() -> consumer.get(button.isChecked() ? item : null));
button.getStyle().imageUp = new TextureRegionDrawable(item.icon(Cicon.small));
button.update(() -> button.setChecked(holder.get() == item));
@@ -40,7 +40,7 @@ public class ItemSelection{
if(i % 4 != 0){
int remaining = 4 - (i % 4);
for(int j = 0; j < remaining; j++){
cont.addImage(Styles.black6);
cont.image(Styles.black6);
}
}
@@ -22,21 +22,11 @@ public class ShockMine extends Block{
destructible = true;
solid = false;
targetable = false;
layer = Layer.overlay;
rebuildable = false;
}
public class ShockMineEntity extends TileEntity{
@Override
public void drawLayer(){
super.draw();
Draw.color(team.color);
Draw.alpha(0.22f);
Fill.rect(x, y, 2f, 2f);
Draw.color();
}
@Override
public void drawTeam(){
//no
@@ -44,7 +34,11 @@ public class ShockMine extends Block{
@Override
public void draw(){
//nope
super.draw();
Draw.color(team.color);
Draw.alpha(0.22f);
Fill.rect(x, y, 2f, 2f);
Draw.color();
}
@Override
@@ -50,8 +50,8 @@ public class LiquidTurret extends Turret{
public class LiquidTurretEntity extends TurretEntity{
@Override
public void drawLayer(){
super.drawLayer();
public void draw(){
super.draw();
if(Core.atlas.isFound(reg(liquidRegion))){
Draw.color(liquids.current().color);
@@ -68,7 +68,6 @@ public abstract class Turret extends Block{
priority = TargetPriority.turret;
update = true;
solid = true;
layer = Layer.turret;
group = BlockGroup.turrets;
flags = EnumSet.of(BlockFlag.turret);
outlineIcon = true;
@@ -127,10 +126,9 @@ public abstract class Turret extends Block{
public void draw(){
Draw.rect(baseRegion, x, y);
Draw.color();
}
@Override
public void drawLayer(){
Draw.z(Layer.turret);
tr2.trns(rotation, -recoil);
drawer.get(this);
@@ -10,8 +10,8 @@ import arc.util.ArcAnnotate.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.content.*;
import mindustry.gen.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
@@ -36,7 +36,6 @@ public class Conveyor extends Block implements Autotiler{
super(name);
rotate = true;
update = true;
layer = Layer.overlay;
group = BlockGroup.transportation;
hasItems = true;
itemCapacity = 4;
@@ -129,6 +128,19 @@ public class Conveyor extends Block implements Autotiler{
int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0;
Draw.rect(regions[Mathf.clamp(blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], x, y,
tilesize * blendsclx, tilesize * blendscly, rotation * 90);
//TODO is clustering necessary? does it create garbage?
Draw.z(Layer.blockOver);
for(int i = 0; i < len; i++){
Item item = ids[i];
tr1.trns(rotation * 90, tilesize, 0);
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
Draw.rect(item.icon(Cicon.medium),
(tile.x * tilesize + tr1.x * ys[i] + tr2.x),
(tile.y * tilesize + tr1.y * ys[i] + tr2.y), itemSize, itemSize);
}
}
@Override
@@ -152,21 +164,6 @@ public class Conveyor extends Block implements Autotiler{
}
}
@Override
public void drawLayer(){
byte rotation = tile.rotation();
for(int i = 0; i < len; i++){
Item item = ids[i];
tr1.trns(rotation * 90, tilesize, 0);
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
Draw.rect(item.icon(Cicon.medium),
(tile.x * tilesize + tr1.x * ys[i] + tr2.x),
(tile.y * tilesize + tr1.y * ys[i] + tr2.y), itemSize, itemSize);
}
}
@Override
public void unitOn(Unitc unit){
if(clogHeat > 0.5f){
@@ -29,7 +29,6 @@ public class CraterConveyor extends Block implements Autotiler{
rotate = true;
update = true;
layer = Layer.overlay;
group = BlockGroup.transportation;
hasItems = true;
itemCapacity = 8;
@@ -87,13 +86,32 @@ public class CraterConveyor extends Block implements Autotiler{
@Override
public void draw(){
draw(blendbit1);
if(blendbit2 == 0) return;
draw(blendbit2);
}
Draw.rect(regions[Mathf.clamp(blendbit1, 0, regions.length - 1)], x, y, tilesize * blendsclx, tilesize * blendscly, rotation() * 90);
if(blendbit2 != 0) Draw.rect(regions[Mathf.clamp(blendbit2, 0, regions.length - 1)], x, y, tilesize * blendsclx, tilesize * blendscly, rotation() * 90);;
private void draw(int bit){
Draw.rect(regions[Mathf.clamp(bit, 0, regions.length - 1)], x, y, tilesize * blendsclx, tilesize * blendscly, rotation() * 90);
Draw.z(Layer.blockOver);
if(link == -1) return;
// offset
Tile from = world.tile(link);
Tmp.v1.set(from);
Tmp.v2.set(tile);
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interpolation.linear);
// fixme
float a = (from.rotation()%4) * 90;
float b = (tile.rotation()%4) * 90;
if((from.rotation()%4) == 3 && (tile.rotation()%4) == 0) a = -1 * 90;
if((from.rotation()%4) == 0 && (tile.rotation()%4) == 3) a = 4 * 90;
// crater
Draw.rect(regions[7], Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interpolation.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
// item
float size = itemSize * Mathf.lerp(Math.min((float)items.total() / itemCapacity, 1), 1f, 0.4f);
Drawf.shadow(Tmp.v1.x, Tmp.v1.y, size * 1.2f);
Draw.rect(items.first().icon(Cicon.medium), Tmp.v1.x, Tmp.v1.y, size, size, 0);
}
@Override
@@ -157,31 +175,6 @@ public class CraterConveyor extends Block implements Autotiler{
}
}
@Override
public void drawLayer(){
if(link == -1) return;
// offset
Tile from = world.tile(link);
Tmp.v1.set(from);
Tmp.v2.set(tile);
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interpolation.linear);
// fixme
float a = (from.rotation()%4) * 90;
float b = (tile.rotation()%4) * 90;
if((from.rotation()%4) == 3 && (tile.rotation()%4) == 0) a = -1 * 90;
if((from.rotation()%4) == 0 && (tile.rotation()%4) == 3) a = 4 * 90;
// crater
Draw.rect(regions[7], Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interpolation.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
// item
float size = itemSize * Mathf.lerp(Math.min((float)items.total() / itemCapacity, 1), 1f, 0.4f);
Drawf.shadow(Tmp.v1.x, Tmp.v1.y, size * 1.2f);
Draw.rect(items.first().icon(Cicon.medium), Tmp.v1.x, Tmp.v1.y, size, size, 0);
}
@Override
public int getMaximumAccepted(Item item){
return Mathf.round(super.getMaximumAccepted(item) * timeScale); // increased item capacity while boosted
@@ -4,6 +4,7 @@ import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import mindustry.graphics.*;
import mindustry.world.*;
import static mindustry.Vars.*;
@@ -17,7 +18,11 @@ public class ExtendingItemBridge extends ItemBridge{
public class ExtendingItemBridgeEntity extends ItemBridgeEntity{
@Override
public void drawLayer(){
public void draw(){
super.draw();
Draw.z(Layer.power);
Tile other = world.tile(link);
if(!linkValid(tile, other)) return;
@@ -32,7 +32,6 @@ public class ItemBridge extends Block{
update = true;
solid = true;
hasPower = true;
layer = Layer.power;
expanded = true;
itemCapacity = 10;
configurable = true;
@@ -230,7 +229,11 @@ public class ItemBridge extends Block{
}
@Override
public void drawLayer(){
public void draw(){
super.draw();
Draw.z(Layer.power);
Tile other = world.tile(link);
if(!linkValid(tile, other)) return;
@@ -37,10 +37,9 @@ public class MassDriver extends Block{
solid = true;
configurable = true;
hasItems = true;
layer = Layer.turret;
hasPower = true;
outlineIcon = true;
//point2 is relative
//point2 is relative
config(Point2.class, (tile, point) -> ((MassDriverEntity)tile).link = Point2.pack(point.x + tile.tileX(), point.y + tile.tileY()));
config(Integer.class, (tile, point) -> ((MassDriverEntity)tile).link = point);
}
@@ -187,10 +186,9 @@ public class MassDriver extends Block{
@Override
public void draw(){
Draw.rect(baseRegion, x, y);
}
@Override
public void drawLayer(){
Draw.z(Layer.turret);
Draw.rect(region,
x + Angles.trnsx(rotation + 180f, reload * knockback),
y + Angles.trnsy(rotation + 180f, reload * knockback), rotation - 90);
@@ -17,15 +17,14 @@ import mindustry.world.blocks.payloads.*;
import static mindustry.Vars.*;
//TODO rename
public class MassConveyor extends Block{
public class PayloadConveyor extends Block{
public float moveTime = 70f;
public TextureRegion topRegion, edgeRegion;
public Interpolation interp = Interpolation.pow5;
public MassConveyor(String name){
public PayloadConveyor(String name){
super(name);
layer = Layer.overlay;
size = 3;
rotate = true;
update = true;
@@ -57,7 +56,7 @@ public class MassConveyor extends Block{
}
}
public class MassConveyorEntity extends TileEntity{
public class PayloadConveyorEntity extends TileEntity{
public @Nullable Payload item;
public float progress, itemRotation, animation;
public @Nullable Tilec next;
@@ -87,7 +86,7 @@ public class MassConveyor extends Block{
progress = Time.time() % moveTime;
//TODO DEBUG
if(Core.input.keyTap(KeyCode.G) && world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y) == this){
if(Core.input.keyTap(KeyCode.g) && world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y) == this){
item = new UnitPayload((Mathf.chance(0.5) ? UnitTypes.wraith : UnitTypes.dagger).create(Team.sharded));
itemRotation = rotation() * 90;
animation = 0f;
@@ -161,14 +160,8 @@ public class MassConveyor extends Block{
Draw.rect(edgeRegion, x, y, i * 90);
}
}
}
@Override
public void drawLayer(){
//fract:
//0: arriving
//0.5: middle
//1: leaving
Draw.z(Layer.blockOver);
if(animation > fract()){
animation = Mathf.lerp(animation, 0.8f, 0.15f);
@@ -177,7 +170,7 @@ public class MassConveyor extends Block{
animation = Math.max(animation, fract());
float fract = animation;
float rot = Mathf.slerp(itemRotation, rotation() * 90, fract);
rot = Mathf.slerp(itemRotation, rotation() * 90, fract);
if(fract < 0.5f){
Tmp.v1.trns(itemRotation + 180, (0.5f - fract) * tilesize * size);
@@ -11,15 +11,12 @@ public class TreeBlock extends Block{
public TreeBlock(String name){
super(name);
solid = true;
layer = Layer.power;
expanded = true;
}
@Override
public void drawBase(Tile tile){}
@Override
public void drawLayer(Tile tile){
public void drawBase(Tile tile){
Draw.z(Layer.power + 1);
Draw.rect(region, tile.worldx(), tile.worldy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90);
}
}
@@ -102,24 +102,26 @@ public class BlockForge extends Block{
}
if(recipe != null){
TextureRegion region = recipe.icon(Cicon.full);
Draw.draw(Layer.blockOver, () -> {
TextureRegion region = recipe.icon(Cicon.full);
Shaders.build.region = region;
Shaders.build.progress = progress / recipe.buildCost;
Shaders.build.color.set(Pal.accent);
Shaders.build.color.a = heat;
Shaders.build.time = -time / 20f;
Shaders.build.region = region;
Shaders.build.progress = progress / recipe.buildCost;
Shaders.build.color.set(Pal.accent);
Shaders.build.color.a = heat;
Shaders.build.time = -time / 20f;
Draw.shader(Shaders.build);
Draw.rect(region, x, y);
Draw.shader();
Draw.shader(Shaders.build);
Draw.rect(region, x, y);
Draw.shader();
Draw.color(Pal.accent);
Draw.alpha(heat);
Draw.color(Pal.accent);
Draw.alpha(heat);
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
Draw.reset();
Draw.reset();
});
}
}
@@ -2,9 +2,8 @@ package mindustry.world.blocks.legacy;
import arc.util.io.*;
import mindustry.gen.*;
import mindustry.world.*;
public class LegacyCommandCenter extends Block{
public class LegacyCommandCenter extends LegacyBlock{
public LegacyCommandCenter(String name){
super(name);
@@ -2,9 +2,8 @@ package mindustry.world.blocks.legacy;
import arc.util.io.*;
import mindustry.gen.*;
import mindustry.world.*;
public class LegacyUnitFactory extends Block{
public class LegacyUnitFactory extends LegacyBlock{
public LegacyUnitFactory(String name){
super(name);
@@ -87,7 +87,7 @@ public class MessageBlock extends Block{
@Override
public void buildConfiguration(Table table){
table.addImageButton(Icon.pencil, () -> {
table.button(Icon.pencil, () -> {
if(mobile){
Core.input.getTextInput(new TextInput(){{
text = message;
@@ -112,7 +112,7 @@ public class MessageBlock extends Block{
return true;
});
a.setMaxLength(maxTextLength);
dialog.buttons.addButton("$ok", () -> {
dialog.buttons.button("$ok", () -> {
tile.configure(a.getText());
dialog.hide();
}).size(130f, 60f);
@@ -49,7 +49,7 @@ public class LightBlock extends Block{
@Override
public void buildConfiguration(Table table){
table.addImageButton(Icon.pencil, () -> {
table.button(Icon.pencil, () -> {
ui.picker.show(Tmp.c1.set(color).a(0.5f), false, res -> {
color = res.rgba();
lastColor = color;
@@ -33,7 +33,6 @@ public class PowerNode extends PowerBlock{
public PowerNode(String name){
super(name);
expanded = true;
layer = Layer.power;
configurable = true;
consumesPower = false;
outputsPower = false;
@@ -372,10 +371,12 @@ public class PowerNode extends PowerBlock{
}
@Override
public void drawLayer(){
public void draw(){
super.draw();
if(Core.settings.getInt("lasersopacity") == 0) return;
Tilec entity = tile.ent();
Draw.z(Layer.power);
for(int i = 0; i < power.links.size; i++){
Tilec link = world.ent(power.links.get(i));
@@ -57,7 +57,6 @@ public class Drill extends Block{
super(name);
update = true;
solid = true;
layer = Layer.overlay;
group = BlockGroup.drills;
hasLiquids = true;
liquidCapacity = 5f;
@@ -139,7 +138,7 @@ public class Drill extends Block{
for(int i = 0; i < list.size; i++){
Block item = list.get(i);
l.addImage(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.add(item.localizedName).left().padLeft(1).padRight(4);
if(i % 5 == 4){
l.row();
@@ -3,7 +3,6 @@ package mindustry.world.blocks.production;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
@@ -20,7 +19,6 @@ public class Pump extends LiquidBlock{
public Pump(String name){
super(name);
layer = Layer.overlay;
group = BlockGroup.liquids;
floating = true;
}

Some files were not shown because too many files have changed in this diff Show More