Refactored almost every class, somehow didn't break game yet
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
|
||||
import static io.anuke.mindustry.Vars.discordURL;
|
||||
|
||||
public class DiscordDialog extends Dialog {
|
||||
|
||||
public DiscordDialog(){
|
||||
@@ -11,9 +12,9 @@ public class DiscordDialog extends Dialog {
|
||||
content().margin(12f);
|
||||
content().add("$text.discord");
|
||||
content().row();
|
||||
content().add("[orange]"+ Vars.discordURL);
|
||||
content().add("[orange]"+ discordURL);
|
||||
buttons().defaults().size(200f, 50);
|
||||
buttons().addButton("$text.openlink", () -> Gdx.net.openURI(Vars.discordURL));
|
||||
buttons().addButton("$text.openlink", () -> Gdx.net.openURI(discordURL));
|
||||
buttons().addButton("$text.back", this::hide);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
@@ -49,7 +49,7 @@ public class FileChooser extends FloatingDialog {
|
||||
|
||||
filefield = new TextField();
|
||||
filefield.setOnlyFontChars(false);
|
||||
if(!open) Mindustry.platforms.addDialog(filefield);
|
||||
if(!open) Platform.instance.addDialog(filefield);
|
||||
filefield.setDisabled(open);
|
||||
|
||||
ok = new TextButton(open ? "$text.load" : "$text.save");
|
||||
@@ -251,7 +251,7 @@ public class FileChooser extends FloatingDialog {
|
||||
|
||||
@Override
|
||||
public Dialog show(){
|
||||
Mindustry.platforms.requestWritePerms();
|
||||
Platform.instance.requestWritePerms();
|
||||
Timers.runTask(2f, () -> {
|
||||
content().clear();
|
||||
setupWidgets();
|
||||
@@ -316,8 +316,8 @@ public class FileChooser extends FloatingDialog {
|
||||
}
|
||||
}
|
||||
|
||||
public static interface FileHandleFilter{
|
||||
public boolean accept(FileHandle file);
|
||||
public interface FileHandleFilter{
|
||||
boolean accept(FileHandle file);
|
||||
}
|
||||
|
||||
public static Predicate<FileHandle> pngFilter = file -> file.extension().equalsIgnoreCase("png");
|
||||
|
||||
@@ -9,6 +9,8 @@ import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
//TODO add port specification
|
||||
public class HostDialog extends FloatingDialog{
|
||||
float w = 300;
|
||||
@@ -25,21 +27,21 @@ public class HostDialog extends FloatingDialog{
|
||||
Vars.player.name = text;
|
||||
Settings.put("name", text);
|
||||
Settings.save();
|
||||
Vars.ui.listfrag.rebuild();
|
||||
ui.listfrag.rebuild();
|
||||
}).grow().pad(8);
|
||||
}).width(w).height(70f).pad(4);
|
||||
|
||||
content().row();
|
||||
|
||||
content().addButton("$text.host", () -> {
|
||||
Vars.ui.loadfrag.show("$text.hosting");
|
||||
ui.loadfrag.show("$text.hosting");
|
||||
Timers.runTask(5f, () -> {
|
||||
try{
|
||||
Net.host(Vars.port);
|
||||
}catch (IOException e){
|
||||
Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||
ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||
}
|
||||
Vars.ui.loadfrag.hide();
|
||||
ui.loadfrag.hide();
|
||||
hide();
|
||||
});
|
||||
}).width(w).height(70f);
|
||||
@@ -49,12 +51,12 @@ public class HostDialog extends FloatingDialog{
|
||||
showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> {
|
||||
int result = Strings.parseInt(text);
|
||||
if(result == Integer.MIN_VALUE || result >= 65535){
|
||||
Vars.ui.showError("$text.server.invalidport");
|
||||
ui.showError("$text.server.invalidport");
|
||||
}else{
|
||||
try{
|
||||
Net.host(result);
|
||||
}catch (IOException e){
|
||||
Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||
ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.net.Host;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.UCore;
|
||||
@@ -16,6 +16,8 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class JoinDialog extends FloatingDialog {
|
||||
Array<Server> servers = new Array<>();
|
||||
Dialog add;
|
||||
@@ -35,7 +37,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
add = new FloatingDialog("$text.joingame.title");
|
||||
add.content().add("$text.joingame.ip").padRight(5f).left();
|
||||
|
||||
Mindustry.platforms.addDialog(add.content().addField(Settings.getString("ip"), text ->{
|
||||
Platform.instance.addDialog(add.content().addField(Settings.getString("ip"), text ->{
|
||||
Settings.putString("ip", text);
|
||||
Settings.save();
|
||||
}).size(340f, 54f).get(), 100);
|
||||
@@ -100,7 +102,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
}).margin(3f).padTop(6f).top().right();
|
||||
|
||||
inner.addImageButton("icon-trash-16", "empty", 16*2, () -> {
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.server.delete", () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.server.delete", () -> {
|
||||
servers.removeValue(server, true);
|
||||
saveServers();
|
||||
setupRemote();
|
||||
@@ -207,7 +209,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
}
|
||||
|
||||
void connect(String ip, int port){
|
||||
Vars.ui.loadfrag.show("$text.connecting");
|
||||
ui.loadfrag.show("$text.connecting");
|
||||
|
||||
Timers.runTask(2f, () -> {
|
||||
try{
|
||||
@@ -233,8 +235,8 @@ public class JoinDialog extends FloatingDialog {
|
||||
}else{
|
||||
error = Strings.parseException(e, false);
|
||||
}
|
||||
Vars.ui.showError(Bundles.format("text.connectfail", error));
|
||||
Vars.ui.loadfrag.hide();
|
||||
ui.showError(Bundles.format("text.connectfail", error));
|
||||
ui.loadfrag.hide();
|
||||
|
||||
UCore.error(e);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
@@ -30,17 +30,17 @@ public class LanguageDialog extends FloatingDialog{
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
|
||||
for(Locale loc : locales){
|
||||
TextButton button = new TextButton(Mindustry.platforms.getLocaleName(loc), "toggle");
|
||||
button.setChecked(Vars.ui.getLocale().equals(loc));
|
||||
TextButton button = new TextButton(Platform.instance.getLocaleName(loc), "toggle");
|
||||
button.setChecked(ui.getLocale().equals(loc));
|
||||
button.clicked(() -> {
|
||||
if(Vars.ui.getLocale().equals(loc)) return;
|
||||
if(ui.getLocale().equals(loc)) return;
|
||||
Settings.putString("locale", loc.toString());
|
||||
Settings.save();
|
||||
UCore.log("Setting locale: " + loc.toString());
|
||||
Vars.ui.showInfo("$text.language.restart");
|
||||
ui.showInfo("$text.language.restart");
|
||||
});
|
||||
langs.add(button).group(group).update(t -> {
|
||||
t.setChecked(loc.equals(Vars.ui.getLocale()));
|
||||
t.setChecked(loc.equals(ui.getLocale()));
|
||||
}).size(400f, 60f).row();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
@@ -19,8 +18,10 @@ import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class LevelDialog extends FloatingDialog{
|
||||
private Map selectedMap = Vars.world.maps().getMap(0);
|
||||
private Map selectedMap = world.maps().getMap(0);
|
||||
private TextureRegion region = new TextureRegion();
|
||||
private ScrollPane pane;
|
||||
|
||||
@@ -50,7 +51,7 @@ public class LevelDialog extends FloatingDialog{
|
||||
|
||||
for(GameMode mode : GameMode.values()){
|
||||
TextButton b = Elements.newButton("$mode."+mode.name()+".name", "toggle", ()->{
|
||||
Vars.control.setMode(mode);
|
||||
state.mode = mode;
|
||||
});
|
||||
group.add(b);
|
||||
selmode.add(b).size(130f, 54f);
|
||||
@@ -69,27 +70,27 @@ public class LevelDialog extends FloatingDialog{
|
||||
|
||||
sdif.defaults().height(s+4);
|
||||
sdif.addImageButton("icon-arrow-left", 10*3, () -> {
|
||||
Vars.control.setDifficulty(ds[Mathf.mod(Vars.control.getDifficulty().ordinal() - 1, ds.length)]);
|
||||
state.difficulty = (ds[Mathf.mod(state.difficulty.ordinal() - 1, ds.length)]);
|
||||
}).width(s);
|
||||
|
||||
sdif.addButton("", () -> {
|
||||
|
||||
}).update(t -> {
|
||||
t.setText(Vars.control.getDifficulty().toString());
|
||||
t.setText(state.difficulty.toString());
|
||||
t.setTouchable(Touchable.disabled);
|
||||
}).width(180f);
|
||||
|
||||
sdif.addImageButton("icon-arrow-right", 10*3, () -> {
|
||||
Vars.control.setDifficulty(ds[Mathf.mod(Vars.control.getDifficulty().ordinal() + 1, ds.length)]);
|
||||
state.difficulty = (ds[Mathf.mod(state.difficulty.ordinal() + 1, ds.length)]);
|
||||
}).width(s);
|
||||
|
||||
content().add(sdif);
|
||||
content().row();
|
||||
|
||||
int i = 0;
|
||||
for(Map map : Vars.world.maps().list()){
|
||||
for(Map map : world.maps().list()){
|
||||
|
||||
if(!map.visible && !Vars.debug) continue;
|
||||
if(!map.visible && !debug) continue;
|
||||
|
||||
if(i % maxwidth == 0){
|
||||
maps.row();
|
||||
@@ -122,8 +123,8 @@ public class LevelDialog extends FloatingDialog{
|
||||
image.row();
|
||||
delete[0] = image.addButton("Delete", () -> {
|
||||
Timers.run(1f, () -> {
|
||||
Vars.ui.showConfirm("$text.level.delete.title", Bundles.format("text.level.delete", Bundles.get("map."+map.name+".name", map.name)), () -> {
|
||||
Vars.world.maps().removeMap(map);
|
||||
ui.showConfirm("$text.level.delete.title", Bundles.format("text.level.delete", Bundles.get("map."+map.name+".name", map.name)), () -> {
|
||||
world.maps().removeMap(map);
|
||||
reload();
|
||||
Core.scene.setScrollFocus(pane);
|
||||
});
|
||||
@@ -142,7 +143,7 @@ public class LevelDialog extends FloatingDialog{
|
||||
|
||||
selectedMap = map;
|
||||
hide();
|
||||
Vars.control.playMap(selectedMap);
|
||||
control.playMap(selectedMap);
|
||||
}
|
||||
});
|
||||
image.getImageCell().size(images);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.io.Saves.SaveSlot;
|
||||
@@ -17,6 +15,8 @@ import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class LoadDialog extends FloatingDialog{
|
||||
ScrollPane pane;
|
||||
Table slots;
|
||||
@@ -49,7 +49,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
|
||||
Timers.runTask(2f, () -> Core.scene.setScrollFocus(pane));
|
||||
|
||||
Array<SaveSlot> array = Vars.control.getSaves().getSaveSlots();
|
||||
Array<SaveSlot> array = control.getSaves().getSaveSlots();
|
||||
|
||||
for(SaveSlot slot : array){
|
||||
|
||||
@@ -68,27 +68,27 @@ public class LoadDialog extends FloatingDialog{
|
||||
}).checked(slot.isAutosave()).right();
|
||||
|
||||
t.addImageButton("icon-trash", "empty", 14*3, () -> {
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.save.delete.confirm", () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.save.delete.confirm", () -> {
|
||||
slot.delete();
|
||||
setup();
|
||||
});
|
||||
}).size(14*3).right();
|
||||
|
||||
t.addImageButton("icon-pencil-small", "empty", 14*3, () -> {
|
||||
Vars.ui.showTextInput("$text.save.rename", "$text.save.rename.text", slot.getName(), text -> {
|
||||
ui.showTextInput("$text.save.rename", "$text.save.rename.text", slot.getName(), text -> {
|
||||
slot.setName(text);
|
||||
setup();
|
||||
});
|
||||
}).size(14*3).right();
|
||||
|
||||
if(!Vars.gwt) {
|
||||
if(!gwt) {
|
||||
t.addImageButton("icon-save", "empty", 14 * 3, () -> {
|
||||
new FileChooser("$text.save.export", false, file -> {
|
||||
try {
|
||||
slot.exportFile(file);
|
||||
setup();
|
||||
} catch (IOException e) {
|
||||
Vars.ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
|
||||
ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
|
||||
}
|
||||
}).show();
|
||||
}).size(14 * 3).right();
|
||||
@@ -123,7 +123,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
public void addSetup(){
|
||||
if(Vars.control.getSaves().getSaveSlots().size == 0) {
|
||||
if(control.getSaves().getSaveSlots().size == 0) {
|
||||
|
||||
slots.row();
|
||||
slots.addButton("$text.save.none", "clear", () -> {
|
||||
@@ -132,19 +132,19 @@ public class LoadDialog extends FloatingDialog{
|
||||
|
||||
slots.row();
|
||||
|
||||
if(Vars.gwt) return;
|
||||
if(gwt) return;
|
||||
|
||||
slots.addImageTextButton("$text.save.import", "icon-add", "clear", 14*3, () -> {
|
||||
new FileChooser("$text.save.import", f -> f.extension().equals("mins"), true, file -> {
|
||||
if(SaveIO.isSaveValid(file)){
|
||||
try{
|
||||
Vars.control.getSaves().importSave(file);
|
||||
control.getSaves().importSave(file);
|
||||
setup();
|
||||
}catch (IOException e){
|
||||
Vars.ui.showError(Bundles.format("text.save.import.fail", Strings.parseException(e, false)));
|
||||
ui.showError(Bundles.format("text.save.import.fail", Strings.parseException(e, false)));
|
||||
}
|
||||
}else{
|
||||
Vars.ui.showError("$text.save.import.invalid");
|
||||
ui.showError("$text.save.import.invalid");
|
||||
}
|
||||
}).show();
|
||||
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||
@@ -153,21 +153,21 @@ public class LoadDialog extends FloatingDialog{
|
||||
public void modifyButton(TextButton button, SaveSlot slot){
|
||||
button.clicked(() -> {
|
||||
if(!button.childrenPressed()){
|
||||
Vars.ui.loadfrag.show();
|
||||
ui.loadfrag.show();
|
||||
|
||||
Timers.runTask(3f, () -> {
|
||||
Vars.ui.loadfrag.hide();
|
||||
ui.loadfrag.hide();
|
||||
hide();
|
||||
try{
|
||||
slot.load();
|
||||
state.set(State.playing);
|
||||
Vars.ui.paused.hide();
|
||||
ui.paused.hide();
|
||||
}catch(Exception e){
|
||||
UCore.error(e);
|
||||
Vars.ui.paused.hide();
|
||||
ui.paused.hide();
|
||||
state.set(State.menu);
|
||||
Vars.control.reset();
|
||||
Vars.ui.showError("$text.save.corrupted");
|
||||
logic.reset();
|
||||
ui.showError("$text.save.corrupted");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.ui.PressGroup;
|
||||
@@ -13,7 +11,7 @@ import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PausedDialog extends FloatingDialog{
|
||||
private SaveDialog save = new SaveDialog();
|
||||
@@ -27,22 +25,22 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
void setup(){
|
||||
update(() -> {
|
||||
if(GameState.is(State.menu) && isShown()){
|
||||
if(state.is(State.menu) && isShown()){
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
shown(() -> {
|
||||
wasPaused = GameState.is(State.paused);
|
||||
wasPaused = state.is(State.paused);
|
||||
if(!Net.active()) state.set(State.paused);
|
||||
});
|
||||
|
||||
if(!Vars.android){
|
||||
if(!android){
|
||||
content().defaults().width(220).height(50);
|
||||
|
||||
content().addButton("$text.back", () -> {
|
||||
hide();
|
||||
if((!wasPaused || Net.active()) && !GameState.is(State.menu))
|
||||
if((!wasPaused || Net.active()) && !state.is(State.menu))
|
||||
state.set(State.playing);
|
||||
});
|
||||
|
||||
@@ -52,7 +50,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
content().row();
|
||||
content().addButton("$text.savegame", () -> {
|
||||
save.show();
|
||||
}).disabled(b -> Vars.world.getMap().id == -1);
|
||||
}).disabled(b -> world.getMap().id == -1);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.loadgame", () -> {
|
||||
@@ -61,7 +59,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
content().row();
|
||||
|
||||
if(!Vars.gwt) {
|
||||
if(!gwt) {
|
||||
content().addButton("$text.hostserver", () -> {
|
||||
ui.host.show();
|
||||
}).disabled(b -> Net.active());
|
||||
@@ -71,7 +69,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
content().addButton("$text.quit", () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
if(Net.active() && Net.client()) Vars.netClient.disconnectQuietly();
|
||||
if(Net.client()) netClient.disconnectQuietly();
|
||||
runExitSave();
|
||||
hide();
|
||||
});
|
||||
@@ -87,7 +85,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> {
|
||||
hide();
|
||||
if(!wasPaused && !GameState.is(State.menu))
|
||||
if(!wasPaused && !state.is(State.menu))
|
||||
state.set(State.playing);
|
||||
}).text("$text.back").padTop(4f);
|
||||
|
||||
@@ -95,7 +93,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
imagebutton sa = new imagebutton("icon-save", isize, save::show);
|
||||
sa.text("$text.save").padTop(4f);
|
||||
sa.cell.disabled(b -> Vars.world.getMap().id == -1);
|
||||
sa.cell.disabled(b -> world.getMap().id == -1);
|
||||
|
||||
content().row();
|
||||
|
||||
@@ -110,8 +108,8 @@ public class PausedDialog extends FloatingDialog{
|
||||
ho.cell.disabled(b -> Net.active());
|
||||
|
||||
new imagebutton("icon-quit", isize, () -> {
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
if(Net.active() && Net.client()) Vars.netClient.disconnectQuietly();
|
||||
ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||
if(Net.client()) netClient.disconnectQuietly();
|
||||
runExitSave();
|
||||
hide();
|
||||
});
|
||||
@@ -128,22 +126,22 @@ public class PausedDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
private void runExitSave(){
|
||||
if(Vars.control.getSaves().getCurrent() == null ||
|
||||
!Vars.control.getSaves().getCurrent().isAutosave()){
|
||||
if(control.getSaves().getCurrent() == null ||
|
||||
!control.getSaves().getCurrent().isAutosave()){
|
||||
state.set(State.menu);
|
||||
Vars.control.getTutorial().reset();
|
||||
control.tutorial().reset();
|
||||
return;
|
||||
}
|
||||
|
||||
Vars.ui.loadfrag.show("$text.saveload");
|
||||
ui.loadfrag.show("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
Vars.ui.loadfrag.hide();
|
||||
ui.loadfrag.hide();
|
||||
try{
|
||||
Vars.control.getSaves().getCurrent().save();
|
||||
control.getSaves().getCurrent().save();
|
||||
}catch(Throwable e){
|
||||
e = (e.getCause() == null ? e : e.getCause());
|
||||
Vars.ui.showError("[orange]"+ Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||
ui.showError("[orange]"+ Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||
}
|
||||
state.set(State.menu);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class RestartDialog extends Dialog {
|
||||
|
||||
@@ -18,14 +17,14 @@ public class RestartDialog extends Dialog {
|
||||
content().row();
|
||||
}
|
||||
content().add("$text.lasted").pad(12).get();
|
||||
content().add("[accent]" + control.getWave());
|
||||
content().add("[accent]" + state.wave);
|
||||
pack();
|
||||
});
|
||||
|
||||
getButtonTable().addButton("$text.menu", ()-> {
|
||||
hide();
|
||||
state.set(State.menu);
|
||||
control.reset();
|
||||
logic.reset();
|
||||
}).size(130f, 60f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.io.Saves.SaveSlot;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class SaveDialog extends LoadDialog{
|
||||
|
||||
public SaveDialog() {
|
||||
super("$text.savegame");
|
||||
|
||||
update(() -> {
|
||||
if(GameState.is(State.menu) && isShown()){
|
||||
if(state.is(State.menu) && isShown()){
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addSetup(){
|
||||
if(!Vars.control.getSaves().canAddSave()){
|
||||
if(!control.getSaves().canAddSave()){
|
||||
return;
|
||||
}
|
||||
|
||||
slots.row();
|
||||
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14*3, () ->
|
||||
Vars.ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {
|
||||
Vars.control.getSaves().addSave(text);
|
||||
ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {
|
||||
control.getSaves().addSave(text);
|
||||
setup();
|
||||
})
|
||||
).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||
@@ -40,23 +40,23 @@ public class SaveDialog extends LoadDialog{
|
||||
button.clicked(() -> {
|
||||
if(button.childrenPressed()) return;
|
||||
|
||||
Vars.ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> save(slot));
|
||||
ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> save(slot));
|
||||
});
|
||||
}
|
||||
|
||||
void save(SaveSlot slot){
|
||||
|
||||
Vars.ui.loadfrag.show("$text.saveload");
|
||||
ui.loadfrag.show("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
hide();
|
||||
Vars.ui.loadfrag.hide();
|
||||
ui.loadfrag.hide();
|
||||
try{
|
||||
slot.save();
|
||||
}catch(Throwable e){
|
||||
e = (e.getCause() == null ? e : e.getCause());
|
||||
|
||||
Vars.ui.showError("[orange]"+Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||
ui.showError("[orange]"+Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.core.Core;
|
||||
@@ -18,7 +17,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class SettingsMenuDialog extends SettingsDialog{
|
||||
public SettingsTable graphics;
|
||||
@@ -33,20 +32,20 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
hidden(()->{
|
||||
if(!GameState.is(State.menu)){
|
||||
if(!state.is(State.menu)){
|
||||
if(!wasPaused || Net.active())
|
||||
state.set(State.playing);
|
||||
}
|
||||
});
|
||||
|
||||
shown(()->{
|
||||
if(!GameState.is(State.menu)){
|
||||
wasPaused = GameState.is(State.paused);
|
||||
if(!state.is(State.menu)){
|
||||
wasPaused = state.is(State.paused);
|
||||
if(menu.getScene() != null){
|
||||
wasPaused = ((PausedDialog)menu).wasPaused;
|
||||
}
|
||||
if(!Net.active()) state.set(State.paused);
|
||||
Vars.ui.paused.hide();
|
||||
ui.paused.hide();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -83,10 +82,10 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
menu.addButton("$text.settings.sound", () -> visible(2));
|
||||
if(!Vars.android) {
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.controls", Vars.ui.controls::show);
|
||||
menu.addButton("$text.settings.controls", ui.controls::show);
|
||||
}
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.language", Vars.ui.language::show);
|
||||
menu.addButton("$text.settings.language", ui.language::show);
|
||||
|
||||
prefs.clearChildren();
|
||||
prefs.add(menu);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
public class BackgroundFragment implements Fragment {
|
||||
|
||||
@Override
|
||||
@@ -29,6 +30,6 @@ public class BackgroundFragment implements Fragment {
|
||||
|
||||
Draw.color();
|
||||
Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15, logow, logoh);
|
||||
}).visible(() -> GameState.is(State.menu)).grow();
|
||||
}).visible(() -> state.is(State.menu)).grow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.resource.*;
|
||||
@@ -23,8 +21,7 @@ import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.fontscale;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class BlocksFragment implements Fragment{
|
||||
private Table desctable, itemtable, blocks, weapons;
|
||||
@@ -39,12 +36,12 @@ public class BlocksFragment implements Fragment{
|
||||
abottom();
|
||||
aright();
|
||||
|
||||
visible(() -> !GameState.is(State.menu) && shown);
|
||||
visible(() -> !state.is(State.menu) && shown);
|
||||
|
||||
blocks = new table(){{
|
||||
|
||||
itemtable = new Table("button");
|
||||
itemtable.setVisible(() -> input.recipe == null && !Vars.control.getMode().infiniteResources);
|
||||
itemtable.setVisible(() -> input.recipe == null && !state.mode.infiniteResources);
|
||||
|
||||
desctable = new Table("button");
|
||||
desctable.setVisible(() -> input.recipe != null);
|
||||
@@ -121,8 +118,8 @@ public class BlocksFragment implements Fragment{
|
||||
image.getImageCell().size(size);
|
||||
|
||||
image.update(() -> {
|
||||
boolean canPlace = !control.getTutorial().active() || control.getTutorial().canPlace();
|
||||
boolean has = (control.hasItems(r.requirements)) && canPlace;
|
||||
boolean canPlace = !control.tutorial().active() || control.tutorial().canPlace();
|
||||
boolean has = (state.inventory.hasItems(r.requirements)) && canPlace;
|
||||
image.setChecked(input.recipe == r);
|
||||
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
|
||||
image.getImage().setColor(has ? Color.WHITE : Hue.lightness(0.33f));
|
||||
@@ -152,11 +149,11 @@ public class BlocksFragment implements Fragment{
|
||||
|
||||
row();
|
||||
|
||||
if(!Vars.android) {
|
||||
if(!android) {
|
||||
weapons = new table("button").margin(0).fillX().end().get();
|
||||
}
|
||||
|
||||
visible(() -> !GameState.is(State.menu) && shown);
|
||||
visible(() -> !state.is(State.menu) && shown);
|
||||
|
||||
}}.end().get();
|
||||
}}.end();
|
||||
@@ -165,21 +162,21 @@ public class BlocksFragment implements Fragment{
|
||||
}
|
||||
|
||||
public void updateWeapons(){
|
||||
if(Vars.android) return;
|
||||
if(android) return;
|
||||
|
||||
weapons.clearChildren();
|
||||
weapons.left();
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
for(int i = 0; i < Vars.control.getWeapons().size; i ++){
|
||||
Weapon weapon = Vars.control.getWeapons().get(i);
|
||||
for(int i = 0; i < control.upgrades().getWeapons().size; i ++){
|
||||
Weapon weapon = control.upgrades().getWeapons().get(i);
|
||||
weapons.addImageButton(weapon.name, "toggle", 8*3, () -> {
|
||||
Vars.player.weaponLeft = Vars.player.weaponRight = weapon;
|
||||
player.weaponLeft = player.weaponRight = weapon;
|
||||
}).left().size(40f, 45f).padRight(-1).group(group);
|
||||
}
|
||||
|
||||
int idx = Vars.control.getWeapons().indexOf(Vars.player.weaponLeft, true);
|
||||
int idx = control.upgrades().getWeapons().indexOf(player.weaponLeft, true);
|
||||
|
||||
if(idx != -1)
|
||||
group.getButtons().get(idx).setChecked(true);
|
||||
@@ -197,7 +194,7 @@ public class BlocksFragment implements Fragment{
|
||||
}
|
||||
|
||||
void updateRecipe(){
|
||||
Recipe recipe = Vars.control.input().recipe;
|
||||
Recipe recipe = control.input().recipe;
|
||||
desctable.clear();
|
||||
desctable.setTouchable(Touchable.enabled);
|
||||
|
||||
@@ -228,7 +225,7 @@ public class BlocksFragment implements Fragment{
|
||||
Label desclabel = new Label(recipe.result.fullDescription);
|
||||
desclabel.setWrap(true);
|
||||
|
||||
boolean wasPaused = GameState.is(State.paused);
|
||||
boolean wasPaused = state.is(State.paused);
|
||||
state.set(State.paused);
|
||||
|
||||
FloatingDialog d = new FloatingDialog("$text.blocks.blockinfo");
|
||||
@@ -286,7 +283,7 @@ public class BlocksFragment implements Fragment{
|
||||
Label reqlabel = new Label("");
|
||||
|
||||
reqlabel.update(()->{
|
||||
int current = control.getAmount(stack.item);
|
||||
int current = state.inventory.getAmount(stack.item);
|
||||
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
|
||||
|
||||
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
|
||||
@@ -311,12 +308,12 @@ public class BlocksFragment implements Fragment{
|
||||
itemtable.clear();
|
||||
itemtable.left();
|
||||
|
||||
if(control.getMode().infiniteResources){
|
||||
if(state.mode.infiniteResources){
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < control.getItems().length; i ++){
|
||||
int amount = control.getItems()[i];
|
||||
for(int i = 0; i < state.inventory.getItems().length; i ++){
|
||||
int amount = state.inventory.getItems()[i];
|
||||
if(amount == 0) continue;
|
||||
String formatted = amount > 99999999 ? "inf" : format(amount);
|
||||
Image image = new Image(Draw.hasRegion("icon-" + Item.getByID(i).name) ?
|
||||
|
||||
@@ -6,11 +6,11 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetEvents;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -21,6 +21,7 @@ import io.anuke.ucore.scene.ui.TextField;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.ucore.core.Core.scene;
|
||||
import static io.anuke.ucore.core.Core.skin;
|
||||
|
||||
@@ -45,7 +46,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
setFillParent(true);
|
||||
font = Core.skin.getFont("default-font");
|
||||
|
||||
setVisible(() -> !GameState.is(State.menu) && Net.active());
|
||||
setVisible(() -> !state.is(State.menu) && Net.active());
|
||||
|
||||
//TODO put it in input?
|
||||
update(() -> {
|
||||
@@ -57,7 +58,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
toggle();
|
||||
}
|
||||
|
||||
if(GameState.is(State.menu) && messages.size > 0){
|
||||
if(state.is(State.menu) && messages.size > 0){
|
||||
messages.clear();
|
||||
}
|
||||
});
|
||||
@@ -81,7 +82,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
chatfield.getStyle().fontColor = Color.WHITE;
|
||||
chatfield.getStyle().font = skin.getFont("default-font-chat");
|
||||
chatfield.setStyle(chatfield.getStyle());
|
||||
Mindustry.platforms.addDialog(chatfield, maxLength);
|
||||
Platform.instance.addDialog(chatfield, maxLength);
|
||||
|
||||
bottom().left().marginBottom(offsety).marginLeft(offsetx*2).add(fieldlabel).padBottom(4f);
|
||||
|
||||
@@ -105,10 +106,6 @@ public class ChatFragment extends Table implements Fragment{
|
||||
if(chatOpen)
|
||||
batch.draw(skin.getRegion("white"), offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight()-1);
|
||||
|
||||
//font.getData().down = Unit.dp.scl(-21.5f);
|
||||
//font.getData().lineHeight = 22f;
|
||||
//chatfield.getStyle().font.getData().setScale(Vars.fontscale);
|
||||
|
||||
super.draw(batch, alpha);
|
||||
|
||||
float spacing = chatspace;
|
||||
@@ -151,7 +148,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
|
||||
if(message.replaceAll(" ", "").isEmpty()) return;
|
||||
|
||||
Vars.netClient.handleSendMessage(message);
|
||||
NetEvents.handleSendMessage(message);
|
||||
}
|
||||
|
||||
public void toggle(){
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.anuke.mindustry.ui.fragments;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.core.Core;
|
||||
@@ -28,7 +26,7 @@ public class HudFragment implements Fragment{
|
||||
private Table wavetable;
|
||||
private boolean shown = true;
|
||||
private BlocksFragment blockfrag = new BlocksFragment();
|
||||
|
||||
|
||||
public void build(){
|
||||
|
||||
//menu at top left
|
||||
@@ -66,17 +64,17 @@ public class HudFragment implements Fragment{
|
||||
}).get();
|
||||
|
||||
new imagebutton("icon-pause", isize, () -> {
|
||||
if (Net.active() && Vars.android) {
|
||||
if (Net.active() && android) {
|
||||
ui.listfrag.visible = !ui.listfrag.visible;
|
||||
} else {
|
||||
state.set(GameState.is(State.paused) ? State.playing : State.paused);
|
||||
state.set(state.is(State.paused) ? State.playing : State.paused);
|
||||
}
|
||||
}).update(i -> {
|
||||
if (Net.active() && Vars.android) {
|
||||
if (Net.active() && android) {
|
||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
|
||||
} else {
|
||||
i.setDisabled(Net.active());
|
||||
i.getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause");
|
||||
i.getStyle().imageUp = Core.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
|
||||
}
|
||||
}).get();
|
||||
|
||||
@@ -92,10 +90,10 @@ public class HudFragment implements Fragment{
|
||||
|
||||
row();
|
||||
|
||||
visible(() -> !GameState.is(State.menu));
|
||||
visible(() -> !state.is(State.menu));
|
||||
|
||||
Label fps = new Label(() -> (Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") +
|
||||
(Net.active() && !Vars.gwt && !Net.server() ? " / Ping: " + Net.getPing() : "") : ""));
|
||||
(Net.client() && !gwt ? " / Ping: " + Net.getPing() : "") : ""));
|
||||
row();
|
||||
add(fps).size(-1);
|
||||
|
||||
@@ -110,46 +108,46 @@ public class HudFragment implements Fragment{
|
||||
}).visible(() -> Net.active() && android).top().left().size(58f).get();
|
||||
|
||||
}}.end();
|
||||
|
||||
|
||||
//tutorial ui table
|
||||
new table(){{
|
||||
control.getTutorial().buildUI(this);
|
||||
|
||||
visible(()->control.getTutorial().active());
|
||||
control.tutorial().buildUI(this);
|
||||
|
||||
visible(() -> control.tutorial().active());
|
||||
}}.end();
|
||||
|
||||
|
||||
//paused table
|
||||
new table(){{
|
||||
visible(()->GameState.is(State.paused) && !Net.active());
|
||||
visible(() -> state.is(State.paused) && !Net.active());
|
||||
atop();
|
||||
|
||||
|
||||
new table("pane"){{
|
||||
new label("[orange]< "+ Bundles.get("text.paused") + " >").scale(0.75f).pad(6);
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
|
||||
//respawn background table
|
||||
new table("white"){{
|
||||
respawntable = get();
|
||||
respawntable.setColor(Color.CLEAR);
|
||||
update(t -> {
|
||||
if(GameState.is(State.menu)){
|
||||
if(state.is(State.menu)){
|
||||
respawntable.setColor(Color.CLEAR);
|
||||
}
|
||||
});
|
||||
}}.end();
|
||||
|
||||
|
||||
//respawn table
|
||||
new table(){{
|
||||
new table("pane"){{
|
||||
|
||||
|
||||
new label(()->"[orange]"+Bundles.get("text.respawn")+" " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10);
|
||||
|
||||
visible(()->control.getRespawnTime() > 0 && !GameState.is(State.menu));
|
||||
|
||||
|
||||
visible(()->control.getRespawnTime() > 0 && !state.is(State.menu));
|
||||
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
|
||||
//profiling table
|
||||
if(debug){
|
||||
new table(){{
|
||||
@@ -158,11 +156,11 @@ public class HudFragment implements Fragment{
|
||||
row();
|
||||
new label(() -> "[blue]requests: " + renderer.getBlocks().getRequests()).left();
|
||||
row();
|
||||
new label(() -> "[purple]tiles: " + Vars.control.tileGroup.amount()).left();
|
||||
new label(() -> "[purple]tiles: " + tileGroup.amount()).left();
|
||||
row();
|
||||
new label(() -> "[purple]enemies: " + Vars.control.enemyGroup.amount()).left();
|
||||
new label(() -> "[purple]enemies: " + enemyGroup.amount()).left();
|
||||
row();
|
||||
new label(() -> "[orange]noclip: " + Vars.noclip).left();
|
||||
new label(() -> "[orange]noclip: " + noclip).left();
|
||||
row();
|
||||
new label(() -> "[purple]time: " + (int)(Timers.time() / 10f) % 50).left();
|
||||
row();
|
||||
@@ -172,17 +170,17 @@ public class HudFragment implements Fragment{
|
||||
|
||||
new table(){{
|
||||
abottom();
|
||||
visible(() -> !GameState.is(State.menu) && Vars.control.getSaves().isSaving());
|
||||
visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
|
||||
|
||||
new label("$text.saveload");
|
||||
|
||||
}}.end();
|
||||
|
||||
if(Vars.debugNet) {
|
||||
if(debugNet) {
|
||||
new table() {{
|
||||
new label(() -> "players: " + Vars.control.playerGroup.amount());
|
||||
new label(() -> "players: " + playerGroup.amount());
|
||||
row();
|
||||
new label(() -> "" + Vars.control.playerGroup.all());
|
||||
new label(() -> "" + playerGroup.all());
|
||||
}}.end();
|
||||
}
|
||||
|
||||
@@ -190,44 +188,44 @@ public class HudFragment implements Fragment{
|
||||
}
|
||||
|
||||
private String getEnemiesRemaining() {
|
||||
if(control.getEnemiesRemaining() == 1) {
|
||||
return Bundles.format("text.enemies.single", control.getEnemiesRemaining());
|
||||
} else return Bundles.format("text.enemies", control.getEnemiesRemaining());
|
||||
if(state.enemies == 1) {
|
||||
return Bundles.format("text.enemies.single", state.enemies);
|
||||
} else return Bundles.format("text.enemies", state.enemies);
|
||||
}
|
||||
|
||||
|
||||
private void addWaveTable(){
|
||||
float uheight = 66f;
|
||||
|
||||
|
||||
wavetable = new table("button"){{
|
||||
aleft();
|
||||
new table(){{
|
||||
aleft();
|
||||
|
||||
new label(() -> Bundles.format("text.wave", control.getWave())).scale(fontscale*1.5f).left().padLeft(-6);
|
||||
new label(() -> Bundles.format("text.wave", state.wave)).scale(fontscale*1.5f).left().padLeft(-6);
|
||||
|
||||
row();
|
||||
|
||||
new label(()-> control.getEnemiesRemaining() > 0 ?
|
||||
|
||||
new label(()-> state.enemies > 0 ?
|
||||
getEnemiesRemaining() :
|
||||
(control.getTutorial().active() || Vars.control.getMode().toggleWaves) ? "$text.waiting"
|
||||
: Bundles.format("text.wave.waiting", (int) (control.getWaveCountdown() / 60f)))
|
||||
(control.tutorial().active() || state.mode.toggleWaves) ? "$text.waiting"
|
||||
: Bundles.format("text.wave.waiting", (int) (state.wavetime / 60f)))
|
||||
.minWidth(126).padLeft(-6).padRight(-12).left();
|
||||
|
||||
margin(10f);
|
||||
get().marginLeft(6);
|
||||
}}.left().end();
|
||||
|
||||
|
||||
playButton(uheight);
|
||||
}}.height(uheight).fillX().expandX().end().get();
|
||||
wavetable.getParent().getParent().swapActor(wavetable.getParent(), menu.getParent());
|
||||
}
|
||||
|
||||
|
||||
private void playButton(float uheight){
|
||||
new imagebutton("icon-play", 30f, () -> {
|
||||
Vars.control.runWave();
|
||||
logic.runWave();
|
||||
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36).width(40f).update(l->{
|
||||
boolean vis = Vars.control.getEnemiesRemaining() <= 0 && (Net.server() || !Net.active());
|
||||
boolean paused = GameState.is(State.paused) || !vis;
|
||||
boolean vis = state.enemies <= 0 && (Net.server() || !Net.active());
|
||||
boolean paused = state.is(State.paused) || !vis;
|
||||
|
||||
l.setVisible(vis);
|
||||
l.getStyle().imageUp = Core.skin.getDrawable(vis ? "icon-play" : "clear");
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.ui.MenuButton;
|
||||
import io.anuke.mindustry.ui.PressGroup;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
@@ -28,7 +27,7 @@ public class MenuFragment implements Fragment{
|
||||
add(new MenuButton("$text.play", group, ui.levels::show));
|
||||
row();
|
||||
|
||||
if(Mindustry.platforms.canJoinGame()) {
|
||||
if(Platform.instance.canJoinGame()) {
|
||||
add(new MenuButton("$text.joingame", group, ui.join::show));
|
||||
row();
|
||||
}
|
||||
@@ -53,7 +52,7 @@ public class MenuFragment implements Fragment{
|
||||
get().margin(16);
|
||||
}}.end();
|
||||
|
||||
visible(()-> GameState.is(State.menu));
|
||||
visible(() -> state.is(State.menu));
|
||||
}}.end();
|
||||
}else{
|
||||
new table(){{
|
||||
@@ -77,9 +76,9 @@ public class MenuFragment implements Fragment{
|
||||
|
||||
new imagebutton("icon-info", isize, ui.about::show).text("$text.about.button").padTop(4f);
|
||||
|
||||
new imagebutton("icon-donate", isize, Mindustry.platforms::openDonations).text("$text.donate").padTop(4f);
|
||||
new imagebutton("icon-donate", isize, Platform.instance::openDonations).text("$text.donate").padTop(4f);
|
||||
|
||||
visible(()->GameState.is(State.menu));
|
||||
visible(() -> state.is(State.menu));
|
||||
}}.end();
|
||||
}}.end();
|
||||
}
|
||||
@@ -87,12 +86,12 @@ public class MenuFragment implements Fragment{
|
||||
//extra icons in top right
|
||||
new table(){{
|
||||
atop().aright();
|
||||
if(Mindustry.hasDiscord){
|
||||
if(Platform.instance.hasDiscord()){
|
||||
new imagebutton("icon-discord", 30f, ui.discord::show).margin(14);
|
||||
}
|
||||
if(!Vars.android) {
|
||||
new imagebutton("icon-info", 30f, ui.about::show).margin(14);
|
||||
}
|
||||
}}.end().visible(()->GameState.is(State.menu));
|
||||
}}.end().visible(()->state.is(State.menu));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.anuke.mindustry.ui.fragments;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
@@ -22,7 +20,7 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PlacementFragment implements Fragment{
|
||||
boolean shown = false, placing = false;
|
||||
@@ -30,7 +28,7 @@ public class PlacementFragment implements Fragment{
|
||||
Label modelabel;
|
||||
|
||||
public void build(){
|
||||
if(!Vars.android) return;
|
||||
if(!android) return;
|
||||
|
||||
InputHandler input = control.input();
|
||||
|
||||
@@ -38,7 +36,7 @@ public class PlacementFragment implements Fragment{
|
||||
float translation = Unit.dp.scl(54f);
|
||||
|
||||
new table(){{
|
||||
visible(() -> !GameState.is(State.menu));
|
||||
visible(() -> !state.is(State.menu));
|
||||
|
||||
abottom();
|
||||
aleft();
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetEvents;
|
||||
import io.anuke.mindustry.net.Packets.KickReason;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PlayerListFragment implements Fragment{
|
||||
public boolean visible = false;
|
||||
Table content = new Table();
|
||||
@@ -25,8 +26,8 @@ public class PlayerListFragment implements Fragment{
|
||||
new table(){{
|
||||
new table("pane"){{
|
||||
margin(14f);
|
||||
new label(() -> Bundles.format(Vars.control.playerGroup.amount() == 1 ? "text.players.single" :
|
||||
"text.players", Vars.control.playerGroup.amount()));
|
||||
new label(() -> Bundles.format(playerGroup.amount() == 1 ? "text.players.single" :
|
||||
"text.players", playerGroup.amount()));
|
||||
row();
|
||||
content.marginRight(13f).marginLeft(13f);
|
||||
ScrollPane pane = new ScrollPane(content, "clear");
|
||||
@@ -37,21 +38,22 @@ public class PlayerListFragment implements Fragment{
|
||||
new table("pane"){{
|
||||
margin(12f);
|
||||
get().addCheck("$text.server.friendlyfire", b -> {
|
||||
Vars.control.setFriendlyFire(b);
|
||||
}).growX().update(i -> i.setChecked(Vars.control.isFriendlyFire())).disabled(b -> Net.client());
|
||||
state.friendlyFire = b;
|
||||
NetEvents.handleFriendlyFireChange(b);
|
||||
}).growX().update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client());
|
||||
}}.pad(10f).growX().end();
|
||||
}}.end();
|
||||
|
||||
update(t -> {
|
||||
if(!Vars.android){
|
||||
if(!android){
|
||||
visible = Inputs.keyDown("player_list");
|
||||
}
|
||||
if(!(Net.active() && !GameState.is(State.menu))){
|
||||
if(!(Net.active() && !state.is(State.menu))){
|
||||
visible = false;
|
||||
}
|
||||
if(Vars.control.playerGroup.amount() != last){
|
||||
if(playerGroup.amount() != last){
|
||||
rebuild();
|
||||
last = Vars.control.playerGroup.amount();
|
||||
last = playerGroup.amount();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -66,7 +68,7 @@ public class PlayerListFragment implements Fragment{
|
||||
|
||||
float h = 60f;
|
||||
|
||||
for(Player player : Vars.control.playerGroup.all()){
|
||||
for(Player player : playerGroup.all()){
|
||||
Table button = new Table("button");
|
||||
button.left();
|
||||
button.margin(5).marginBottom(10);
|
||||
|
||||
@@ -3,8 +3,7 @@ package io.anuke.mindustry.ui.fragments;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
@@ -51,13 +50,13 @@ public class ToolFragment implements Fragment{
|
||||
Core.scene.add(tools);
|
||||
|
||||
tools.setVisible(() ->
|
||||
!GameState.is(State.menu) && android && ((input.recipe != null && control.hasItems(input.recipe.requirements) &&
|
||||
!state.is(State.menu) && android && ((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) &&
|
||||
input.placeMode == PlaceMode.cursor) || confirming)
|
||||
);
|
||||
|
||||
tools.update(() -> {
|
||||
if(confirming){
|
||||
Vector2 v = Graphics.screen((px + px2)/2f * Vars.tilesize, Math.min(py, py2) * Vars.tilesize - Vars.tilesize*1.5f);
|
||||
Vector2 v = Graphics.screen((px + px2)/2f * tilesize, Math.min(py, py2) * tilesize - tilesize*1.5f);
|
||||
tools.setPosition(v.x, v.y, Align.top);
|
||||
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user