Added zone class / Dialog method inline
This commit is contained in:
17
core/src/io/anuke/mindustry/content/Zones.java
Normal file
17
core/src/io/anuke/mindustry/content/Zones.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package io.anuke.mindustry.content;
|
||||
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
|
||||
public class Zones implements ContentList{
|
||||
public Zone wasteland;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
|
||||
wasteland = new Zone("wasteland"){{
|
||||
deployCost = new ItemStack[]{new ItemStack(Items.copper, 2)};
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,7 @@ import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.game.MappableContent;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.LegacyColorMapper;
|
||||
@@ -38,39 +35,21 @@ public class ContentLoader{
|
||||
private MappableContent[][] temporaryMapper;
|
||||
private ObjectSet<Consumer<Content>> initialization = new ObjectSet<>();
|
||||
private ContentList[] content = {
|
||||
//effects
|
||||
new Fx(),
|
||||
|
||||
//items
|
||||
new Items(),
|
||||
|
||||
//status effects
|
||||
new StatusEffects(),
|
||||
|
||||
//liquids
|
||||
new Liquids(),
|
||||
|
||||
//bullets
|
||||
new Bullets(),
|
||||
|
||||
//weapons
|
||||
new Weapons(),
|
||||
|
||||
//mechs
|
||||
new Mechs(),
|
||||
|
||||
//units
|
||||
new UnitTypes(),
|
||||
|
||||
//blocks
|
||||
new Blocks(),
|
||||
new Recipes(),
|
||||
new Zones(),
|
||||
|
||||
//not really a content class, but this makes initialization easier
|
||||
//these are not really content classes, but this makes initialization easier
|
||||
new ColorMapper(),
|
||||
new LegacyColorMapper(),
|
||||
|
||||
//recipes
|
||||
new Recipes(),
|
||||
};
|
||||
|
||||
/**Creates all content types.*/
|
||||
@@ -237,6 +216,10 @@ public class ContentLoader{
|
||||
return (BulletType) getByID(ContentType.bullet, id);
|
||||
}
|
||||
|
||||
public Array<Zone> zones(){
|
||||
return getBy(ContentType.zone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers sync IDs for all types of sync entities.
|
||||
* Do not register units here!
|
||||
|
||||
@@ -16,7 +16,6 @@ import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Saves;
|
||||
@@ -28,8 +27,6 @@ import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.input.MobileInput;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -254,12 +251,12 @@ public class Control implements ApplicationListener{
|
||||
|
||||
Time.run(5f, () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("WARNING!");
|
||||
dialog.buttons().addButton("$ok", () -> {
|
||||
dialog.buttons.addButton("$ok", () -> {
|
||||
dialog.hide();
|
||||
Core.settings.put("4.0-warning-2", true);
|
||||
Core.settings.save();
|
||||
}).size(100f, 60f);
|
||||
dialog.content().add("Reminder: The alpha version you are about to play is very unstable, and is [accent]not representative of the final 4.0 release.[]\n\n " +
|
||||
dialog.cont.add("Reminder: The alpha version you are about to play is very unstable, and is [accent]not representative of the final 4.0 release.[]\n\n " +
|
||||
"\nThere is currently[scarlet] no sound implemented[]; this is intentional.\n" +
|
||||
"All current art and UI is temporary, and will be re-drawn before release. " +
|
||||
"\n\n[accent]Saves and maps may be corrupted without warning between updates.").wrap().width(400f);
|
||||
|
||||
@@ -225,19 +225,19 @@ public class UI implements ApplicationListener{
|
||||
}));
|
||||
}
|
||||
|
||||
public void showTextInput(String title, String text, String def, TextFieldFilter filter, Consumer<String> confirmed){
|
||||
new Dialog(title, "dialog"){{
|
||||
content().margin(30).add(text).padRight(6f);
|
||||
TextField field = content().addField(def, t -> {
|
||||
public void showTextInput(String titleText, String text, String def, TextFieldFilter filter, Consumer<String> confirmed){
|
||||
new Dialog(titleText, "dialog"){{
|
||||
cont.margin(30).add(text).padRight(6f);
|
||||
TextField field = cont.addField(def, t -> {
|
||||
}).size(170f, 50f).get();
|
||||
field.setTextFieldFilter((f, c) -> field.getText().length() < 12 && filter.acceptChar(f, c));
|
||||
Platform.instance.addDialog(field);
|
||||
buttons().defaults().size(120, 54).pad(4);
|
||||
buttons().addButton("$ok", () -> {
|
||||
buttons.defaults().size(120, 54).pad(4);
|
||||
buttons.addButton("$ok", () -> {
|
||||
confirmed.accept(field.getText());
|
||||
hide();
|
||||
}).disabled(b -> field.getText().isEmpty());
|
||||
buttons().addButton("$cancel", this::hide);
|
||||
buttons.addButton("$cancel", this::hide);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
@@ -255,17 +255,17 @@ public class UI implements ApplicationListener{
|
||||
|
||||
public void showInfo(String info){
|
||||
new Dialog("", "dialog"){{
|
||||
getCell(content()).growX();
|
||||
content().margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons().addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
getCell(cont).growX();
|
||||
cont.margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showInfo(String info, Runnable clicked){
|
||||
new Dialog("", "dialog"){{
|
||||
getCell(content()).growX();
|
||||
content().margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons().addButton("$ok", () -> {
|
||||
getCell(cont).growX();
|
||||
cont.margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons.addButton("$ok", () -> {
|
||||
clicked.run();
|
||||
hide();
|
||||
}).size(90, 50).pad(4);
|
||||
@@ -274,25 +274,25 @@ public class UI implements ApplicationListener{
|
||||
|
||||
public void showError(String text){
|
||||
new Dialog("$error.title", "dialog"){{
|
||||
content().margin(15).add(text).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons().addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
cont.margin(15).add(text).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showText(String title, String text){
|
||||
new Dialog(title, "dialog"){{
|
||||
content().margin(15).add(text).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons().addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
public void showText(String titleText, String text){
|
||||
new Dialog(titleText, "dialog"){{
|
||||
cont.margin(15).add(text).width(400f).wrap().get().setAlignment(Align.center, Align.center);
|
||||
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showConfirm(String title, String text, Runnable confirmed){
|
||||
FloatingDialog dialog = new FloatingDialog(title);
|
||||
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
||||
dialog.buttons().defaults().size(200f, 54f).pad(2f);
|
||||
dialog.cont.add(text).width(400f).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.addButton("$cancel", dialog::hide);
|
||||
dialog.buttons.addButton("$ok", () -> {
|
||||
dialog.hide();
|
||||
confirmed.run();
|
||||
});
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
float isize = 16 * 2f;
|
||||
float swidth = 180f;
|
||||
|
||||
menu.content().table(t -> {
|
||||
menu.cont.table(t -> {
|
||||
t.defaults().size(swidth, 60f).padBottom(5).padRight(5).padLeft(5);
|
||||
|
||||
t.addImageTextButton("$editor.savemap", "icon-floppy-16", isize, this::save).size(swidth * 2f + 10, 60f).colspan(2);
|
||||
@@ -140,9 +140,9 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
t.row();
|
||||
});
|
||||
|
||||
menu.content().row();
|
||||
menu.cont.row();
|
||||
|
||||
menu.content().addImageTextButton("$quit", "icon-back", isize, () -> {
|
||||
menu.cont.addImageTextButton("$quit", "icon-back", isize, () -> {
|
||||
tryExit();
|
||||
menu.hide();
|
||||
}).padTop(-5).size(swidth * 2f + 10, 60f);
|
||||
@@ -249,7 +249,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
float h = 90f;
|
||||
|
||||
dialog.content().defaults().size(360f, h).padBottom(5).padRight(5).padLeft(5);
|
||||
dialog.cont.defaults().size(360f, h).padBottom(5).padRight(5).padLeft(5);
|
||||
|
||||
for(int i = 0; i < arguments.length; i += 4){
|
||||
String name = (String) arguments[i];
|
||||
@@ -257,7 +257,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
String iconname = (String) arguments[i + 2];
|
||||
Runnable listenable = (Runnable) arguments[i + 3];
|
||||
|
||||
TextButton button = dialog.content().addButton(name, () -> {
|
||||
TextButton button = dialog.cont.addButton(name, () -> {
|
||||
listenable.run();
|
||||
dialog.hide();
|
||||
menu.hide();
|
||||
@@ -273,7 +273,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
button.row();
|
||||
|
||||
dialog.content().row();
|
||||
dialog.cont.row();
|
||||
}
|
||||
|
||||
dialog.addCloseButton();
|
||||
@@ -316,7 +316,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
public void updateSelectedBlock(){
|
||||
Block block = editor.getDrawBlock();
|
||||
for(int j = 0; j < content.blocks().size; j++){
|
||||
for(int j = 0; j < Vars.content.blocks().size; j++){
|
||||
if(block.id == j && j < blockgroup.getButtons().size){
|
||||
blockgroup.getButtons().get(j).setChecked(true);
|
||||
break;
|
||||
|
||||
@@ -28,42 +28,42 @@ public class MapInfoDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
ObjectMap<String, String> tags = editor.getTags();
|
||||
|
||||
content().add("$editor.name").padRight(8).left();
|
||||
cont.add("$editor.name").padRight(8).left();
|
||||
|
||||
content().defaults().padTop(15);
|
||||
cont.defaults().padTop(15);
|
||||
|
||||
name = content().addField(tags.get("name", ""), text -> {
|
||||
name = cont.addField(tags.get("name", ""), text -> {
|
||||
tags.put("name", text);
|
||||
}).size(400, 55f).get();
|
||||
name.setMessageText("$unknown");
|
||||
|
||||
content().row();
|
||||
cont.row();
|
||||
|
||||
content().add("$editor.description").padRight(8).left();
|
||||
cont.add("$editor.description").padRight(8).left();
|
||||
|
||||
description = content().addArea(tags.get("description", ""), "textarea", text -> {
|
||||
description = cont.addArea(tags.get("description", ""), "textarea", text -> {
|
||||
tags.put("description", text);
|
||||
}).size(400f, 140f).get();
|
||||
|
||||
content().row();
|
||||
cont.row();
|
||||
|
||||
content().add("$editor.author").padRight(8).left();
|
||||
cont.add("$editor.author").padRight(8).left();
|
||||
|
||||
author = content().addField(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> {
|
||||
author = cont.addField(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> {
|
||||
tags.put("author", text);
|
||||
Core.settings.put("mapAuthor", text);
|
||||
Core.settings.save();
|
||||
}).size(400, 55f).get();
|
||||
author.setMessageText("$unknown");
|
||||
|
||||
content().row();
|
||||
cont.row();
|
||||
|
||||
content().add().padRight(8).left();
|
||||
content().addCheck("$editor.oregen", enabled -> {
|
||||
cont.add().padRight(8).left();
|
||||
cont.addCheck("$editor.oregen", enabled -> {
|
||||
tags.put("oregen", enabled ? "1" : "0");
|
||||
}).update(c -> c.setChecked(!tags.get("oregen", "0").equals("0"))).left();
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ public class MapLoadDialog extends FloatingDialog{
|
||||
}
|
||||
});
|
||||
|
||||
buttons().defaults().size(200f, 50f);
|
||||
buttons().addButton("$cancel", this::hide);
|
||||
buttons().add(button);
|
||||
buttons.defaults().size(200f, 50f);
|
||||
buttons.addButton("$cancel", this::hide);
|
||||
buttons.add(button);
|
||||
}
|
||||
|
||||
public void rebuild(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
if(world.maps.all().size > 0){
|
||||
selected = world.maps.all().first();
|
||||
}
|
||||
@@ -69,11 +69,11 @@ public class MapLoadDialog extends FloatingDialog{
|
||||
if(world.maps.all().size == 0){
|
||||
table.add("$maps.none").center();
|
||||
}else{
|
||||
content().add("$editor.loadmap");
|
||||
cont.add("$editor.loadmap");
|
||||
}
|
||||
|
||||
content().row();
|
||||
content().add(pane);
|
||||
cont.row();
|
||||
cont.add(pane);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MapResizeDialog extends FloatingDialog{
|
||||
public MapResizeDialog(MapEditor editor, BiConsumer<Integer, Integer> cons){
|
||||
super("$editor.resizemap");
|
||||
shown(() -> {
|
||||
content().clear();
|
||||
cont.clear();
|
||||
MapTileData data = editor.getMap();
|
||||
width = data.width();
|
||||
height = data.height();
|
||||
@@ -47,14 +47,14 @@ public class MapResizeDialog extends FloatingDialog{
|
||||
|
||||
table.row();
|
||||
}
|
||||
content().row();
|
||||
content().add(table);
|
||||
cont.row();
|
||||
cont.add(table);
|
||||
|
||||
});
|
||||
|
||||
buttons().defaults().size(200f, 50f);
|
||||
buttons().addButton("$cancel", this::hide);
|
||||
buttons().addButton("$editor.resize", () -> {
|
||||
buttons.defaults().size(200f, 50f);
|
||||
buttons.addButton("$cancel", this::hide);
|
||||
buttons.addButton("$editor.resize", () -> {
|
||||
cons.accept(width, height);
|
||||
hide();
|
||||
});
|
||||
|
||||
@@ -22,8 +22,8 @@ public class MapSaveDialog extends FloatingDialog{
|
||||
Platform.instance.addDialog(field);
|
||||
|
||||
shown(() -> {
|
||||
content().clear();
|
||||
content().label(() -> {
|
||||
cont.clear();
|
||||
cont.label(() -> {
|
||||
Map map = world.maps.getByName(field.getText());
|
||||
if(map != null){
|
||||
if(map.custom){
|
||||
@@ -34,13 +34,13 @@ public class MapSaveDialog extends FloatingDialog{
|
||||
}
|
||||
return "";
|
||||
}).colspan(2);
|
||||
content().row();
|
||||
content().add("$editor.mapname").padRight(14f);
|
||||
content().add(field).size(220f, 48f);
|
||||
cont.row();
|
||||
cont.add("$editor.mapname").padRight(14f);
|
||||
cont.add(field).size(220f, 48f);
|
||||
});
|
||||
|
||||
buttons().defaults().size(200f, 50f).pad(2f);
|
||||
buttons().addButton("$cancel", this::hide);
|
||||
buttons.defaults().size(200f, 50f).pad(2f);
|
||||
buttons.addButton("$cancel", this::hide);
|
||||
|
||||
TextButton button = new TextButton("$save");
|
||||
button.clicked(() -> {
|
||||
@@ -50,7 +50,7 @@ public class MapSaveDialog extends FloatingDialog{
|
||||
}
|
||||
});
|
||||
button.setDisabled(this::invalid);
|
||||
buttons().add(button);
|
||||
buttons.add(button);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.game.EventType.UnlockEvent;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
|
||||
/**Stores player unlocks. Clientside only.*/
|
||||
public class GlobalData{
|
||||
@@ -25,6 +26,22 @@ public class GlobalData{
|
||||
items.getAndIncrement(item, 0, amount);
|
||||
}
|
||||
|
||||
public boolean hasItems(ItemStack[] stacks){
|
||||
for(ItemStack stack : stacks){
|
||||
if(items.get(stack.item, 0) < stack.amount){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeItems(ItemStack[] stacks){
|
||||
for(ItemStack stack : stacks){
|
||||
items.getAndIncrement(stack.item, 0, -stack.amount);
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
|
||||
public ObjectIntMap<Item> items(){
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ public abstract class MappableContent extends Content {
|
||||
* Returns the unqiue name of this piece of content.
|
||||
* The name only needs to be unique for all content of this type.
|
||||
* Do not use IDs for names! Make sure this string stays constant with each update unless removed.
|
||||
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).
|
||||
*/
|
||||
public abstract String getContentName();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BlockRenderer{
|
||||
private final static int initialRequests = 32 * 32;
|
||||
private final static int expandr = 6;
|
||||
private final static boolean disableShadows = false;
|
||||
private final static Color shadowColor = new Color(0, 0, 0, 0.15f);
|
||||
private final static Color shadowColor = new Color(0, 0, 0, 0.19f);
|
||||
|
||||
public final FloorRenderer floor = new FloorRenderer();
|
||||
|
||||
|
||||
@@ -197,10 +197,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(!guides.contains(type) && !Core.settings.getBool(type, false)){
|
||||
FloatingDialog dialog = new FloatingDialog("$" + type + ".title");
|
||||
dialog.addCloseButton();
|
||||
dialog.content().left();
|
||||
dialog.content().add("$" + type).growX().wrap();
|
||||
dialog.content().row();
|
||||
dialog.content().addCheck("$showagain", false, checked -> {
|
||||
dialog.cont.left();
|
||||
dialog.cont.add("$" + type).growX().wrap();
|
||||
dialog.cont.row();
|
||||
dialog.cont.addCheck("$showagain", false, checked -> {
|
||||
Core.settings.put(type, checked);
|
||||
Core.settings.save();
|
||||
}).growX().left().get().left();
|
||||
|
||||
@@ -12,5 +12,6 @@ public enum ContentType {
|
||||
status,
|
||||
unit,
|
||||
weather,
|
||||
effect
|
||||
effect,
|
||||
zone
|
||||
}
|
||||
|
||||
42
core/src/io/anuke/mindustry/type/Zone.java
Normal file
42
core/src/io/anuke/mindustry/type/Zone.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package io.anuke.mindustry.type;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
|
||||
public class Zone extends UnlockableContent{
|
||||
public final String name;
|
||||
public ItemStack[] deployCost = {};
|
||||
|
||||
public Zone(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(){
|
||||
return true;
|
||||
}
|
||||
|
||||
//neither of these are implemented, as zones are not displayed in a normal fashion... yet
|
||||
@Override
|
||||
public void displayInfo(Table table){}
|
||||
|
||||
@Override
|
||||
public TextureRegion getContentIcon(){ return null; }
|
||||
|
||||
@Override
|
||||
public String getContentName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String localizedName(){
|
||||
return Core.bundle.get("zone."+name+".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentType getContentType(){
|
||||
return ContentType.zone;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import io.anuke.mindustry.io.Contributors;
|
||||
import io.anuke.mindustry.io.Contributors.Contributor;
|
||||
import io.anuke.mindustry.ui.Links;
|
||||
import io.anuke.mindustry.ui.Links.LinkEntry;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.layout.Cell;
|
||||
@@ -35,8 +34,8 @@ public class AboutDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
content().clear();
|
||||
buttons().clear();
|
||||
cont.clear();
|
||||
buttons.clear();
|
||||
|
||||
float h = UIUtils.portrait() ? 90f : 80f;
|
||||
float w = UIUtils.portrait() ? 330f : 600f;
|
||||
@@ -80,18 +79,18 @@ public class AboutDialog extends FloatingDialog{
|
||||
|
||||
shown(() -> Time.run(1f, () -> Core.scene.setScrollFocus(pane)));
|
||||
|
||||
content().add(pane).growX();
|
||||
cont.add(pane).growX();
|
||||
|
||||
addCloseButton();
|
||||
|
||||
buttons().addButton("$credits", this::showCredits).size(200f, 64f);
|
||||
buttons.addButton("$credits", this::showCredits).size(200f, 64f);
|
||||
|
||||
if(!ios && !OS.isMac){
|
||||
buttons().addButton("$changelog.title", ui.changelog::show).size(200f, 64f);
|
||||
buttons.addButton("$changelog.title", ui.changelog::show).size(200f, 64f);
|
||||
}
|
||||
|
||||
if(UIUtils.portrait()){
|
||||
for(Cell<?> cell : buttons().getCells()){
|
||||
for(Cell<?> cell : buttons.getCells()){
|
||||
cell.width(140f);
|
||||
}
|
||||
}
|
||||
@@ -101,14 +100,14 @@ public class AboutDialog extends FloatingDialog{
|
||||
public void showCredits(){
|
||||
FloatingDialog dialog = new FloatingDialog("$credits");
|
||||
dialog.addCloseButton();
|
||||
dialog.content().add("$credits.text");
|
||||
dialog.content().row();
|
||||
dialog.cont.add("$credits.text");
|
||||
dialog.cont.row();
|
||||
if(!contributors.isEmpty()){
|
||||
dialog.content().addImage("blank").color(Palette.accent).fillX().height(3f).pad(3f);
|
||||
dialog.content().row();
|
||||
dialog.content().add("$contributors");
|
||||
dialog.content().row();
|
||||
dialog.content().pane(new Table(){{
|
||||
dialog.cont.addImage("blank").color(Palette.accent).fillX().height(3f).pad(3f);
|
||||
dialog.cont.row();
|
||||
dialog.cont.add("$contributors");
|
||||
dialog.cont.row();
|
||||
dialog.cont.pane(new Table(){{
|
||||
int i = 0;
|
||||
left();
|
||||
for(Contributor c : contributors){
|
||||
|
||||
@@ -18,7 +18,7 @@ public class AdminsDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
float w = 400f, h = 80f;
|
||||
|
||||
@@ -53,6 +53,6 @@ public class AdminsDialog extends FloatingDialog{
|
||||
table.row();
|
||||
}
|
||||
|
||||
content().add(pane);
|
||||
cont.add(pane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BansDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
float w = 400f, h = 80f;
|
||||
|
||||
@@ -49,6 +49,6 @@ public class BansDialog extends FloatingDialog{
|
||||
table.row();
|
||||
}
|
||||
|
||||
content().add(pane);
|
||||
cont.add(pane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ChangelogDialog extends FloatingDialog{
|
||||
|
||||
addCloseButton();
|
||||
|
||||
content().add("$changelog.loading");
|
||||
cont.add("$changelog.loading");
|
||||
|
||||
if(!ios && !OS.isMac){
|
||||
Changelogs.getChangelog(result -> {
|
||||
@@ -39,8 +39,8 @@ public class ChangelogDialog extends FloatingDialog{
|
||||
Table table = new Table();
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
|
||||
content().clear();
|
||||
content().add(pane).grow();
|
||||
cont.clear();
|
||||
cont.add(pane).grow();
|
||||
|
||||
if(versions == null){
|
||||
table.add("$changelog.error");
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ColorPickDialog extends Dialog{
|
||||
|
||||
private void build(){
|
||||
Table table = new Table();
|
||||
content().add(table);
|
||||
cont.add(table);
|
||||
|
||||
for(int i = 0; i < playerColors.length; i++){
|
||||
Color color = playerColors[i];
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ContentInfoDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
public void show(UnlockableContent content){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
Table table = new Table();
|
||||
table.margin(10);
|
||||
@@ -21,7 +21,7 @@ public class ContentInfoDialog extends FloatingDialog{
|
||||
content.displayInfo(table);
|
||||
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
content().add(pane);
|
||||
cont.add(pane);
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -13,15 +13,15 @@ public class ControlsDialog extends KeybindDialog{
|
||||
setStyle(Core.scene.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
setFillParent(true);
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().add(new Image("white"))
|
||||
title.setAlignment(Align.center);
|
||||
titleTable.row();
|
||||
titleTable.add(new Image("white"))
|
||||
.growX().height(3f).pad(4f).get().setColor(Palette.accent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("$back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
buttons.addImageTextButton("$back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
|
||||
keyDown(key -> {
|
||||
if(key == KeyCode.ESCAPE || key == KeyCode.BACK)
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
Table maps = new Table();
|
||||
maps.marginRight(14);
|
||||
@@ -56,8 +56,8 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
selmode.add(modes);
|
||||
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
|
||||
|
||||
content().add(selmode);
|
||||
content().row();
|
||||
cont.add(selmode);
|
||||
cont.row();
|
||||
|
||||
Difficulty[] ds = Difficulty.values();
|
||||
|
||||
@@ -82,8 +82,8 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
state.difficulty = (ds[Mathf.mod(state.difficulty.ordinal() + 1, ds.length)]);
|
||||
}).width(s);
|
||||
|
||||
content().add(sdif);
|
||||
content().row();
|
||||
cont.add(sdif);
|
||||
cont.row();
|
||||
|
||||
float images = 146f;
|
||||
|
||||
@@ -129,7 +129,7 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
maps.add("$maps.none").pad(50);
|
||||
}
|
||||
|
||||
content().add(pane).uniformX();
|
||||
cont.add(pane).uniformX();
|
||||
}
|
||||
|
||||
private void displayGameModeHelp(){
|
||||
@@ -146,8 +146,8 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
table.row();
|
||||
}
|
||||
|
||||
d.content().add(pane);
|
||||
d.buttons().addButton("$ok", d::hide).size(110, 50).pad(10f);
|
||||
d.cont.add(pane);
|
||||
d.buttons.addButton("$ok", d::hide).size(110, 50).pad(10f);
|
||||
d.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@ import io.anuke.arc.collection.ObjectIntMap;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
|
||||
import static io.anuke.mindustry.Vars.data;
|
||||
|
||||
public class DeployDialog extends FloatingDialog{
|
||||
|
||||
@@ -15,28 +19,45 @@ public class DeployDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
buttons().clear();
|
||||
content().clear();
|
||||
buttons.clear();
|
||||
cont.clear();
|
||||
|
||||
addCloseButton();
|
||||
|
||||
content().stack(new Table(){{
|
||||
cont.stack(new Table(){{
|
||||
top().left().margin(10);
|
||||
|
||||
ObjectIntMap<Item> items = Vars.data.items();
|
||||
ObjectIntMap<Item> items = data.items();
|
||||
for(Item item : Vars.content.items()){
|
||||
if(item.type == ItemType.material && Vars.data.isUnlocked(item)){
|
||||
if(item.type == ItemType.material && data.isUnlocked(item)){
|
||||
add(items.get(item, 0) + "").left();
|
||||
addImage(item.region).size(8*4).pad(4);
|
||||
add("[LIGHT_GRAY]" + item.localizedName()).left();
|
||||
row();
|
||||
}
|
||||
}
|
||||
|
||||
}}, new Table(){{
|
||||
addButton("Wasteland", () -> {
|
||||
hide();
|
||||
Vars.world.generator.playRandomMap();
|
||||
}).size(190f, 60f);
|
||||
|
||||
for(Zone zone : Vars.content.zones()){
|
||||
if(data.isUnlocked(zone)){
|
||||
table(t -> {
|
||||
t.addButton(zone.localizedName(), () -> {
|
||||
data.removeItems(zone.deployCost);
|
||||
hide();
|
||||
Vars.world.generator.playRandomMap();
|
||||
}).size(150f).disabled(b -> !data.hasItems(zone.deployCost));
|
||||
t.row();
|
||||
t.table(req -> {
|
||||
req.left();
|
||||
for(ItemStack stack : zone.deployCost){
|
||||
req.addImage(stack.item.region).size(8*3);
|
||||
req.add(stack.amount + "").left();
|
||||
}
|
||||
}).pad(3).growX();
|
||||
}).pad(3);
|
||||
}
|
||||
}
|
||||
}}).grow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ public class DiscordDialog extends Dialog{
|
||||
|
||||
float h = 70f;
|
||||
|
||||
content().margin(12f);
|
||||
cont.margin(12f);
|
||||
|
||||
Color color = Color.valueOf("7289da");
|
||||
|
||||
content().table(t -> {
|
||||
cont.table(t -> {
|
||||
t.background("button").margin(0);
|
||||
|
||||
t.table(img -> {
|
||||
@@ -36,13 +36,13 @@ public class DiscordDialog extends Dialog{
|
||||
t.add("$discord").color(Palette.accent).growX().padLeft(10f);
|
||||
}).size(470f, h).pad(10f);
|
||||
|
||||
buttons().defaults().size(170f, 50);
|
||||
buttons.defaults().size(170f, 50);
|
||||
|
||||
buttons().addButton("$back", this::hide);
|
||||
buttons().addButton("$copylink", () -> {
|
||||
buttons.addButton("$back", this::hide);
|
||||
buttons.addButton("$copylink", () -> {
|
||||
Core.app.getClipboard().setContents(discordURL);
|
||||
});
|
||||
buttons().addButton("$openlink", () -> {
|
||||
buttons.addButton("$openlink", () -> {
|
||||
if(!Core.net.openURI(discordURL)){
|
||||
ui.showError("$linkfail");
|
||||
Core.app.getClipboard().setContents(discordURL);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class FileChooser extends FloatingDialog{
|
||||
}
|
||||
|
||||
private void setupWidgets(){
|
||||
content().margin(-10);
|
||||
cont.margin(-10);
|
||||
|
||||
Table content = new Table();
|
||||
|
||||
@@ -151,7 +151,7 @@ public class FileChooser extends FloatingDialog{
|
||||
|
||||
content.add(buttons).growX();
|
||||
|
||||
content().add(content);
|
||||
cont.add(content);
|
||||
}
|
||||
|
||||
private void updateFileFieldStatus(){
|
||||
@@ -264,7 +264,7 @@ public class FileChooser extends FloatingDialog{
|
||||
@Override
|
||||
public Dialog show(){
|
||||
Time.runTask(2f, () -> {
|
||||
content().clear();
|
||||
cont.clear();
|
||||
setupWidgets();
|
||||
super.show();
|
||||
Core.scene.setScrollFocus(pane);
|
||||
|
||||
@@ -20,9 +20,9 @@ public class FloatingDialog extends Dialog{
|
||||
public FloatingDialog(String title){
|
||||
super(title, "dialog");
|
||||
setFillParent(true);
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().addImage("white", Palette.accent)
|
||||
this.title.setAlignment(Align.center);
|
||||
titleTable.row();
|
||||
titleTable.addImage("white", Palette.accent)
|
||||
.growX().height(3f).pad(4f);
|
||||
|
||||
hidden(() -> {
|
||||
@@ -63,7 +63,7 @@ public class FloatingDialog extends Dialog{
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("$back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
buttons.addImageTextButton("$back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
|
||||
keyDown(key -> {
|
||||
if(key == KeyCode.ESCAPE || key == KeyCode.BACK) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class GenViewDialog extends FloatingDialog{
|
||||
public GenViewDialog(){
|
||||
super("generate view");
|
||||
|
||||
content().add(new GenView()).grow();
|
||||
cont.add(new GenView()).grow();
|
||||
}
|
||||
|
||||
public class GenView extends Element{
|
||||
|
||||
@@ -24,7 +24,7 @@ public class HostDialog extends FloatingDialog{
|
||||
|
||||
addCloseButton();
|
||||
|
||||
content().table(t -> {
|
||||
cont.table(t -> {
|
||||
t.add("$name").padRight(10);
|
||||
t.addField(Core.settings.getString("name"), text -> {
|
||||
player.name = text;
|
||||
@@ -43,11 +43,11 @@ public class HostDialog extends FloatingDialog{
|
||||
button.update(() -> button.getStyle().imageUpColor = player.color);
|
||||
}).width(w).height(70f).pad(4).colspan(3);
|
||||
|
||||
content().row();
|
||||
cont.row();
|
||||
|
||||
content().add().width(65f);
|
||||
cont.add().width(65f);
|
||||
|
||||
content().addButton("$host", () -> {
|
||||
cont.addButton("$host", () -> {
|
||||
if(Core.settings.getString("name").trim().isEmpty()){
|
||||
ui.showInfo("$noname");
|
||||
return;
|
||||
@@ -66,6 +66,6 @@ public class HostDialog extends FloatingDialog{
|
||||
});
|
||||
}).width(w).height(70f);
|
||||
|
||||
content().addButton("?", () -> ui.showInfo("$host.info")).size(65f, 70f).padLeft(6f);
|
||||
cont.addButton("?", () -> ui.showInfo("$host.info")).size(65f, 70f).padLeft(6f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,28 +35,28 @@ public class JoinDialog extends FloatingDialog{
|
||||
|
||||
loadServers();
|
||||
|
||||
buttons().add().width(60f);
|
||||
buttons().add().growX();
|
||||
buttons.add().width(60f);
|
||||
buttons.add().growX();
|
||||
|
||||
addCloseButton();
|
||||
|
||||
buttons().add().growX();
|
||||
buttons().addButton("?", () -> ui.showInfo("$join.info")).size(60f, 64f);
|
||||
buttons.add().growX();
|
||||
buttons.addButton("?", () -> ui.showInfo("$join.info")).size(60f, 64f);
|
||||
|
||||
add = new FloatingDialog("$joingame.title");
|
||||
add.content().add("$joingame.ip").padRight(5f).left();
|
||||
add.cont.add("$joingame.ip").padRight(5f).left();
|
||||
|
||||
TextField field = add.content().addField(Core.settings.getString("ip"), text -> {
|
||||
TextField field = add.cont.addField(Core.settings.getString("ip"), text -> {
|
||||
Core.settings.put("ip", text);
|
||||
Core.settings.save();
|
||||
}).size(320f, 54f).get();
|
||||
|
||||
Platform.instance.addDialog(field, 100);
|
||||
|
||||
add.content().row();
|
||||
add.buttons().defaults().size(140f, 60f).pad(4f);
|
||||
add.buttons().addButton("$cancel", add::hide);
|
||||
add.buttons().addButton("$ok", () -> {
|
||||
add.cont.row();
|
||||
add.buttons.defaults().size(140f, 60f).pad(4f);
|
||||
add.buttons.addButton("$cancel", add::hide);
|
||||
add.buttons.addButton("$ok", () -> {
|
||||
if(renaming == null){
|
||||
Server server = new Server();
|
||||
server.setIP(Core.settings.getString("ip"));
|
||||
@@ -74,7 +74,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
}).disabled(b -> Core.settings.getString("ip").isEmpty() || Net.active());
|
||||
|
||||
add.shown(() -> {
|
||||
add.getTitleLabel().setText(renaming != null ? "$server.edit" : "$server.add");
|
||||
add.title.setText(renaming != null ? "$server.edit" : "$server.add");
|
||||
if(renaming != null){
|
||||
field.setText(renaming.displayIP());
|
||||
}
|
||||
@@ -200,8 +200,8 @@ public class JoinDialog extends FloatingDialog{
|
||||
setupRemote();
|
||||
refreshRemote();
|
||||
|
||||
content().clear();
|
||||
content().table(t -> {
|
||||
cont.clear();
|
||||
cont.table(t -> {
|
||||
t.add("$name").padRight(10);
|
||||
t.addField(Core.settings.getString("name"), text -> {
|
||||
player.name = text;
|
||||
@@ -218,10 +218,10 @@ public class JoinDialog extends FloatingDialog{
|
||||
}).size(54f).get();
|
||||
button.update(() -> button.getStyle().imageUpColor = player.color);
|
||||
}).width(w).height(70f).pad(4);
|
||||
content().row();
|
||||
content().add(pane).width(w + 38).pad(0);
|
||||
content().row();
|
||||
content().addCenteredImageTextButton("$server.add", "icon-add", 14 * 3, () -> {
|
||||
cont.row();
|
||||
cont.add(pane).width(w + 38).pad(0);
|
||||
cont.row();
|
||||
cont.addCenteredImageTextButton("$server.add", "icon-add", 14 * 3, () -> {
|
||||
renaming = null;
|
||||
add.show();
|
||||
}).marginLeft(6).width(w).height(80f).update(button -> {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class LanguageDialog extends FloatingDialog{
|
||||
langs.add(button).group(group).update(t -> t.setChecked(loc.equals(getLocale()))).size(400f, 50f).pad(2).row();
|
||||
}
|
||||
|
||||
content().add(pane);
|
||||
cont.add(pane);
|
||||
}
|
||||
|
||||
public Locale getLocale(){
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
protected void setup(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
slots = new Table();
|
||||
pane = new ScrollPane(slots);
|
||||
@@ -132,7 +132,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
slots.row();
|
||||
}
|
||||
|
||||
content().add(pane);
|
||||
cont.add(pane);
|
||||
|
||||
addSetup();
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ public class LocalPlayerDialog extends FloatingDialog{
|
||||
private void rebuild(){
|
||||
float size = 140f;
|
||||
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
if(players.length > 1){
|
||||
content().addImageButton("icon-cancel", 14 * 2, () -> {
|
||||
cont.addImageButton("icon-cancel", 14 * 2, () -> {
|
||||
control.removePlayer();
|
||||
rebuild();
|
||||
}).size(50f, size).pad(5).bottom();
|
||||
}else{
|
||||
content().add().size(50f, size);
|
||||
cont.add().size(50f, size);
|
||||
}
|
||||
|
||||
for(Player player : players){
|
||||
@@ -48,11 +48,11 @@ public class LocalPlayerDialog extends FloatingDialog{
|
||||
table.row();
|
||||
table.add(stack).size(size);
|
||||
|
||||
content().add(table).pad(5);
|
||||
cont.add(table).pad(5);
|
||||
}
|
||||
|
||||
if(players.length < 4){
|
||||
content().addImageButton("icon-add", 14 * 2, () -> {
|
||||
cont.addImageButton("icon-add", 14 * 2, () -> {
|
||||
control.addPlayer(players.length);
|
||||
rebuild();
|
||||
}).size(50f, size).pad(5).bottom();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
super("$maps");
|
||||
|
||||
addCloseButton();
|
||||
buttons().addImageTextButton("$editor.importmap", "icon-add", 14 * 2, () -> {
|
||||
buttons.addImageTextButton("$editor.importmap", "icon-add", 14 * 2, () -> {
|
||||
Platform.instance.showFileChooser("$editor.importmap", "Map File", file -> {
|
||||
try{
|
||||
DataInputStream stream = new DataInputStream(file.read());
|
||||
@@ -68,7 +68,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
Table maps = new Table();
|
||||
maps.marginRight(24);
|
||||
@@ -104,7 +104,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
maps.add("$maps.none");
|
||||
}
|
||||
|
||||
content().add(pane).uniformX();
|
||||
cont.add(pane).uniformX();
|
||||
}
|
||||
|
||||
void showMapInfo(Map map){
|
||||
@@ -112,7 +112,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
dialog.addCloseButton();
|
||||
|
||||
float mapsize = UIUtils.portrait() ? 160f : 300f;
|
||||
Table table = dialog.content();
|
||||
Table table = dialog.cont;
|
||||
|
||||
table.stack(new Image(map.texture).setScaling(Scaling.fit), new BorderImage(map.texture).setScaling(Scaling.fit)).size(mapsize);
|
||||
|
||||
|
||||
@@ -40,30 +40,30 @@ public class PausedDialog extends FloatingDialog{
|
||||
}
|
||||
});
|
||||
|
||||
content().table(t -> missionTable = t).colspan(mobile ? 3 : 2);
|
||||
content().row();
|
||||
cont.table(t -> missionTable = t).colspan(mobile ? 3 : 2);
|
||||
cont.row();
|
||||
|
||||
if(!mobile){
|
||||
float dw = 210f;
|
||||
content().defaults().width(dw).height(50).pad(5f);
|
||||
cont.defaults().width(dw).height(50).pad(5f);
|
||||
|
||||
content().addButton("$back", this::hide).colspan(2).width(dw*2 + 20f);
|
||||
cont.addButton("$back", this::hide).colspan(2).width(dw*2 + 20f);
|
||||
|
||||
content().row();
|
||||
content().addButton("$unlocks", ui.unlocks::show);
|
||||
content().addButton("$settings", ui.settings::show);
|
||||
cont.row();
|
||||
cont.addButton("$unlocks", ui.unlocks::show);
|
||||
cont.addButton("$settings", ui.settings::show);
|
||||
|
||||
content().row();
|
||||
content().addButton("$savegame", save::show);
|
||||
content().addButton("$loadgame", load::show).disabled(b -> Net.active());
|
||||
cont.row();
|
||||
cont.addButton("$savegame", save::show);
|
||||
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
|
||||
|
||||
content().row();
|
||||
cont.row();
|
||||
|
||||
content().addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw*2 + 20f);
|
||||
cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw*2 + 20f);
|
||||
|
||||
content().row();
|
||||
cont.row();
|
||||
|
||||
content().addButton("$quit", () -> {
|
||||
cont.addButton("$quit", () -> {
|
||||
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
||||
if(Net.client()) netClient.disconnectQuietly();
|
||||
runExitSave();
|
||||
@@ -72,18 +72,18 @@ public class PausedDialog extends FloatingDialog{
|
||||
}).colspan(2).width(dw + 10f);
|
||||
|
||||
}else{
|
||||
content().defaults().size(120f).pad(5);
|
||||
cont.defaults().size(120f).pad(5);
|
||||
float isize = 14f * 4;
|
||||
|
||||
content().addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
|
||||
content().addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show);
|
||||
content().addRowImageTextButton("$save", "icon-save", isize, save::show);
|
||||
cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
|
||||
cont.addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show);
|
||||
cont.addRowImageTextButton("$save", "icon-save", isize, save::show);
|
||||
|
||||
content().row();
|
||||
cont.row();
|
||||
|
||||
content().addRowImageTextButton("$load", "icon-load", isize, load::show).disabled(b -> Net.active());
|
||||
content().addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
||||
content().addRowImageTextButton("$quit", "icon-quit", isize, () -> {
|
||||
cont.addRowImageTextButton("$load", "icon-load", isize, load::show).disabled(b -> Net.active());
|
||||
cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
||||
cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> {
|
||||
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
||||
if(Net.client()) netClient.disconnectQuietly();
|
||||
runExitSave();
|
||||
|
||||
@@ -21,26 +21,26 @@ public class RestartDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void rebuild(){
|
||||
buttons().clear();
|
||||
content().clear();
|
||||
buttons.clear();
|
||||
cont.clear();
|
||||
|
||||
buttons().margin(10);
|
||||
buttons.margin(10);
|
||||
|
||||
if(state.mode.isPvp){
|
||||
content().add(Core.bundle.format("gameover.pvp",winner.localized())).pad(6);
|
||||
buttons().addButton("$menu", () -> {
|
||||
cont.add(Core.bundle.format("gameover.pvp",winner.localized())).pad(6);
|
||||
buttons.addButton("$menu", () -> {
|
||||
hide();
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
}).size(130f, 60f);
|
||||
}else{
|
||||
if(control.isHighScore()){
|
||||
content().add("$highscore").pad(6);
|
||||
content().row();
|
||||
cont.add("$highscore").pad(6);
|
||||
cont.row();
|
||||
}
|
||||
content().add(Core.bundle.format("wave.lasted", state.wave)).pad(12);
|
||||
cont.add(Core.bundle.format("wave.lasted", state.wave)).pad(12);
|
||||
|
||||
buttons().addButton("$menu", () -> {
|
||||
buttons.addButton("$menu", () -> {
|
||||
hide();
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
|
||||
@@ -8,11 +8,8 @@ import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.event.InputEvent;
|
||||
import io.anuke.arc.scene.event.InputListener;
|
||||
import io.anuke.arc.scene.ui.Image;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.SettingsDialog;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.SettingsDialog.SettingsTable.Setting;
|
||||
import io.anuke.arc.scene.ui.Slider;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@@ -49,14 +46,14 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
});
|
||||
|
||||
setFillParent(true);
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().add(new Image("white"))
|
||||
title.setAlignment(Align.center);
|
||||
titleTable.row();
|
||||
titleTable.add(new Image("white"))
|
||||
.growX().height(3f).pad(4f).get().setColor(Palette.accent);
|
||||
|
||||
content().clearChildren();
|
||||
content().remove();
|
||||
buttons().remove();
|
||||
cont.clearChildren();
|
||||
cont.remove();
|
||||
buttons.remove();
|
||||
|
||||
menu = new Table();
|
||||
|
||||
@@ -113,7 +110,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
row();
|
||||
add(pane).grow().top();
|
||||
row();
|
||||
add(buttons()).fillX();
|
||||
add(buttons).fillX();
|
||||
|
||||
hidden(this::back);
|
||||
|
||||
@@ -141,16 +138,16 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
table.addButton("$settings.cleardata", () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("$settings.cleardata");
|
||||
dialog.setFillParent(false);
|
||||
dialog.content().defaults().size(230f, 60f).pad(3);
|
||||
dialog.cont.defaults().size(230f, 60f).pad(3);
|
||||
dialog.addCloseButton();
|
||||
dialog.content().addButton("$settings.clearunlocks", () -> {
|
||||
dialog.cont.addButton("$settings.clearunlocks", () -> {
|
||||
ui.showConfirm("$confirm", "$settings.clear.confirm", () -> {
|
||||
data.reset();
|
||||
dialog.hide();
|
||||
});
|
||||
});
|
||||
dialog.content().row();
|
||||
dialog.content().addButton("$settings.clearall", () -> {
|
||||
dialog.cont.row();
|
||||
dialog.cont.addButton("$settings.clearall", () -> {
|
||||
ui.showConfirm("$confirm", "$settings.clearall.confirm", () -> {
|
||||
ObjectMap<String, Object> map = new ObjectMap<>();
|
||||
for(String value : Core.settings.keys()){
|
||||
@@ -169,7 +166,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
Core.app.exit();
|
||||
});
|
||||
});
|
||||
dialog.content().row();
|
||||
dialog.cont.row();
|
||||
dialog.show();
|
||||
}).size(220f, 60f).pad(6).left();
|
||||
table.add();
|
||||
@@ -214,7 +211,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("$menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
buttons.addImageTextButton("$menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
|
||||
keyDown(key -> {
|
||||
if(key == KeyCode.ESCAPE || key == KeyCode.BACK)
|
||||
|
||||
@@ -9,7 +9,7 @@ public class TraceDialog extends FloatingDialog{
|
||||
}
|
||||
/*
|
||||
public void show(Player player, SessionInfo info){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
Table table = new Table("clear");
|
||||
table.margin(14);
|
||||
@@ -48,7 +48,7 @@ public class TraceDialog extends FloatingDialog{
|
||||
table.add(Core.bundle.format("trace.lastblockplaced", info.lastBlockPlaced.formalName));
|
||||
table.row();
|
||||
|
||||
content().add(table);
|
||||
cont.add(table);
|
||||
|
||||
show();
|
||||
}*/
|
||||
|
||||
@@ -27,13 +27,13 @@ public class UnlocksDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void rebuild(){
|
||||
content().clear();
|
||||
cont.clear();
|
||||
|
||||
Table table = new Table();
|
||||
table.margin(20);
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
|
||||
Array<Content>[] allContent = content.getContentMap();
|
||||
Array<Content>[] allContent = Vars.content.getContentMap();
|
||||
|
||||
for(int j = 0; j < allContent.length; j ++){
|
||||
ContentType type = ContentType.values()[j];
|
||||
@@ -77,6 +77,6 @@ public class UnlocksDialog extends FloatingDialog{
|
||||
table.row();
|
||||
}
|
||||
|
||||
content().add(pane);
|
||||
cont.add(pane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
int row = 0;
|
||||
|
||||
table.margin(6f);
|
||||
table.defaults().size(mobile ? 16 * 3 : 16 * 2).space(6f);
|
||||
table.defaults().size(16 * 2.5f).space(6f);
|
||||
|
||||
if(tile.block().hasItems){
|
||||
|
||||
|
||||
@@ -119,12 +119,14 @@ public class ChatFragment extends Table{
|
||||
chatfield.tapped(() -> {
|
||||
Dialog dialog = new Dialog("", "dialog");
|
||||
dialog.setFillParent(true);
|
||||
dialog.content().top();
|
||||
dialog.content().defaults().height(65f);
|
||||
TextField to = dialog.content().addField("", t-> {}).pad(15).width(250f).get();
|
||||
dialog.cont.top();
|
||||
dialog.cont.defaults().height(65f);
|
||||
TextField to = dialog.cont.addField("", t-> {}).pad(15).width(250f).get();
|
||||
to.setMaxLength(maxTextLength);
|
||||
to.keyDown(KeyCode.ENTER, () -> dialog.content().find("okb").fireClick());
|
||||
dialog.content().addButton("$ok", () -> {
|
||||
to.keyDown(KeyCode.ENTER, () -> {
|
||||
dialog.cont.find("okb").fireClick();
|
||||
});
|
||||
dialog.cont.addButton("$ok", () -> {
|
||||
chatfield.clearText();
|
||||
chatfield.appendText(to.getText());
|
||||
chatfield.change();
|
||||
|
||||
@@ -329,9 +329,9 @@ public class HudFragment extends Fragment{
|
||||
new FloatingDialog("$mission.info"){{
|
||||
shouldPause = true;
|
||||
setFillParent(false);
|
||||
getCell(content()).growX();
|
||||
content().margin(15).add(str).width(400f).wrap().get().setAlignment(Align.left, Align.left);
|
||||
buttons().addButton("$continue", this::hide).size(140, 60).pad(4);
|
||||
getCell(cont).growX();
|
||||
cont.margin(15).add(str).width(400f).wrap().get().setAlignment(Align.left, Align.left);
|
||||
buttons.addButton("$continue", this::hide).size(140, 60).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -146,27 +146,27 @@ public class MenuFragment extends Fragment{
|
||||
|
||||
FloatingDialog dialog = new FloatingDialog("$play");
|
||||
dialog.addCloseButton();
|
||||
dialog.content().defaults().height(66f).width(w).padRight(5f);
|
||||
dialog.cont.defaults().height(66f).width(w).padRight(5f);
|
||||
|
||||
dialog.content().add(new MenuButton("icon-play-2", "$map.random", () -> {
|
||||
dialog.cont.add(new MenuButton("icon-play-2", "$map.random", () -> {
|
||||
dialog.hide();
|
||||
world.generator.playRandomMap();
|
||||
})).width(bw).colspan(2);
|
||||
dialog.content().row();
|
||||
dialog.cont.row();
|
||||
|
||||
dialog.content().add(new MenuButton("icon-add", "$joingame", () -> {
|
||||
dialog.cont.add(new MenuButton("icon-add", "$joingame", () -> {
|
||||
ui.join.show();
|
||||
dialog.hide();
|
||||
}));
|
||||
|
||||
dialog.content().add(new MenuButton("icon-editor", "$customgame", () -> {
|
||||
dialog.cont.add(new MenuButton("icon-editor", "$customgame", () -> {
|
||||
dialog.hide();
|
||||
ui.levels.show();
|
||||
}));
|
||||
|
||||
dialog.content().row();
|
||||
dialog.cont.row();
|
||||
|
||||
dialog.content().add(new MenuButton("icon-load", "$loadgame", () -> {
|
||||
dialog.cont.add(new MenuButton("icon-load", "$loadgame", () -> {
|
||||
ui.load.show();
|
||||
dialog.hide();
|
||||
})).width(bw).colspan(2);
|
||||
|
||||
Reference in New Issue
Block a user