Partial conversion done
This commit is contained in:
@@ -7,9 +7,9 @@ import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.KeybindDialog;
|
||||
|
||||
public class MindustryKeybindDialog extends KeybindDialog{
|
||||
public class ControlsDialog extends KeybindDialog{
|
||||
|
||||
public MindustryKeybindDialog(){
|
||||
public ControlsDialog(){
|
||||
setDialog();
|
||||
|
||||
setFillParent(true);
|
||||
@@ -1,6 +1,14 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
public class HostDialog {
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
|
||||
//TODO
|
||||
public class HostDialog extends Dialog{
|
||||
|
||||
public HostDialog(){
|
||||
super("$text.hostserver", "dialog");
|
||||
}
|
||||
|
||||
/*
|
||||
showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> {
|
||||
int result = Strings.parseInt(text);
|
||||
|
||||
@@ -105,7 +105,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
}
|
||||
|
||||
void connect(String ip, int port){
|
||||
Vars.ui.showLoading("$text.connecting");
|
||||
Vars.ui.loadfrag.show("$text.connecting");
|
||||
|
||||
Timers.runTask(2f, () -> {
|
||||
try{
|
||||
@@ -128,7 +128,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
error = Strings.parseException(e, false);
|
||||
}
|
||||
Vars.ui.showError(Bundles.format("text.connectfail", error));
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -161,18 +161,18 @@ public class LoadDialog extends FloatingDialog{
|
||||
public void modifyButton(TextButton button, SaveSlot slot){
|
||||
button.clicked(() -> {
|
||||
if(!button.childrenPressed()){
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
|
||||
Timers.runTask(3f, () -> {
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
hide();
|
||||
try{
|
||||
slot.load();
|
||||
GameState.set(State.playing);
|
||||
Vars.ui.hideMenu();
|
||||
Vars.ui.menu.hide();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
Vars.ui.hideMenu();
|
||||
Vars.ui.menu.hide();
|
||||
GameState.set(State.menu);
|
||||
Vars.control.reset();
|
||||
Vars.ui.showError("$text.save.corrupted");
|
||||
|
||||
@@ -41,9 +41,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
});
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.settings", () -> {
|
||||
ui.showPrefs();
|
||||
});
|
||||
content().addButton("$text.settings", ui.prefs::show);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.savegame", () -> {
|
||||
@@ -61,7 +59,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
if(Vars.world.getMap().custom){
|
||||
ui.showError("$text.nohost");
|
||||
}else {
|
||||
ui.showHostServer();
|
||||
ui.host.show();
|
||||
}
|
||||
}).disabled(b -> Net.active());
|
||||
|
||||
@@ -89,19 +87,19 @@ public class MenuDialog extends FloatingDialog{
|
||||
GameState.set(State.playing);
|
||||
}).text("$text.back").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
|
||||
new imagebutton("icon-tools", isize, ui.prefs::show).text("$text.settings").padTop(4f);
|
||||
|
||||
new imagebutton("icon-save", isize, ()-> save.show()).text("$text.save").padTop(4f);
|
||||
new imagebutton("icon-save", isize, save::show).text("$text.save").padTop(4f);
|
||||
|
||||
content().row();
|
||||
|
||||
new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f).disabled(Net.active());
|
||||
new imagebutton("icon-load", isize, load::show).text("$text.load").padTop(4f).disabled(Net.active());
|
||||
|
||||
new imagebutton("icon-host", isize, () -> {
|
||||
if(Vars.world.getMap().custom){
|
||||
ui.showError("$text.nohost");
|
||||
}else {
|
||||
ui.showHostServer();
|
||||
ui.host.show();
|
||||
}
|
||||
}).text("$text.host")
|
||||
.disabled(b -> Net.active()).padTop(4f);
|
||||
@@ -128,15 +126,14 @@ public class MenuDialog extends FloatingDialog{
|
||||
if(Vars.control.getSaves().getCurrent() == null ||
|
||||
!Vars.control.getSaves().getCurrent().isAutosave()) return;
|
||||
|
||||
Vars.ui.showLoading("$text.saveload");
|
||||
Vars.ui.loadfrag.show("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
try{
|
||||
Vars.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());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,12 +20,12 @@ public class SaveDialog extends LoadDialog{
|
||||
}
|
||||
|
||||
slots.row();
|
||||
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14*3, () -> {
|
||||
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14*3, () ->
|
||||
Vars.ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {
|
||||
Vars.control.getSaves().addSave(text);
|
||||
setup();
|
||||
});
|
||||
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||
})
|
||||
).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,19 +33,17 @@ public class SaveDialog extends LoadDialog{
|
||||
button.clicked(() -> {
|
||||
if(button.childrenPressed()) return;
|
||||
|
||||
Vars.ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> {
|
||||
save(slot);
|
||||
});
|
||||
Vars.ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> save(slot));
|
||||
});
|
||||
}
|
||||
|
||||
void save(SaveSlot slot){
|
||||
|
||||
Vars.ui.showLoading("$text.saveload");
|
||||
Vars.ui.loadfrag.show("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
hide();
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
try{
|
||||
slot.save();
|
||||
}catch(Throwable e){
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class MindustrySettingsDialog extends SettingsDialog{
|
||||
public class SettingsMenuDialog extends SettingsDialog{
|
||||
public SettingsTable graphics;
|
||||
public SettingsTable game;
|
||||
public SettingsTable sound;
|
||||
@@ -30,7 +30,7 @@ public class MindustrySettingsDialog extends SettingsDialog{
|
||||
private boolean built = false;
|
||||
private boolean wasPaused;
|
||||
|
||||
public MindustrySettingsDialog(){
|
||||
public SettingsMenuDialog(){
|
||||
setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
hidden(()->{
|
||||
@@ -1,10 +1,7 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
@@ -17,6 +14,9 @@ import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class UpgradeDialog extends FloatingDialog{
|
||||
boolean wasPaused = false;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
if(control.hasWeapon(weapon)){
|
||||
button.setDisabled(true);
|
||||
button.setColor(Color.GRAY);
|
||||
}else if(!Vars.control.hasItems(weapon.requirements)){
|
||||
}else if(!control.hasItems(weapon.requirements)){
|
||||
button.setDisabled(true);
|
||||
}else{
|
||||
button.setDisabled(false);
|
||||
@@ -92,7 +92,7 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
ItemStack[] req = weapon.requirements;
|
||||
for(ItemStack s : req){
|
||||
|
||||
int amount = Math.min(Vars.control.getAmount(s.item), s.amount);
|
||||
int amount = Math.min(control.getAmount(s.item), s.amount);
|
||||
reqtable.addImage(Draw.region("icon-" + s.item.name)).padRight(3).size(8*2);
|
||||
reqtable.add(
|
||||
(amount >= s.amount ? "" : "[RED]")
|
||||
@@ -114,7 +114,7 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
|
||||
run.listen();
|
||||
|
||||
Tooltip tip = new Tooltip(tiptable, run);
|
||||
Tooltip<Table> tip = new Tooltip<>(tiptable, run);
|
||||
|
||||
tip.setInstant(true);
|
||||
|
||||
@@ -123,9 +123,9 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
button.clicked(()->{
|
||||
if(button.isDisabled()) return;
|
||||
|
||||
Vars.control.removeItems(weapon.requirements);
|
||||
control.removeItems(weapon.requirements);
|
||||
control.addWeapon(weapon);
|
||||
ui.updateWeapons();
|
||||
ui.weaponfrag.updateWeapons();
|
||||
run.listen();
|
||||
Effects.sound("purchase");
|
||||
});
|
||||
|
||||
@@ -41,9 +41,7 @@ public class HudFragment implements Fragment{
|
||||
defaults().size(dsize).left();
|
||||
float isize = 40;
|
||||
|
||||
menu = new imagebutton("icon-menu", isize, ()->{
|
||||
ui.showMenu();
|
||||
}).get();
|
||||
menu = new imagebutton("icon-menu", isize, ui.menu::show).get();
|
||||
|
||||
flip = new imagebutton("icon-arrow-up", isize, ()->{
|
||||
if(wavetable.getActions().size != 0) return;
|
||||
|
||||
@@ -25,26 +25,26 @@ public class MenuFragment implements Fragment{
|
||||
float scale = 4f;
|
||||
defaults().size(100*scale, 21*scale).pad(-10f);
|
||||
|
||||
add(new MenuButton("$text.play", group, ui::showLevels));
|
||||
add(new MenuButton("$text.play", group, ui.levels::show));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("$text.joingame", group, ui::showJoinGame));
|
||||
add(new MenuButton("$text.joingame", group, ui.join::show));
|
||||
row();
|
||||
}
|
||||
|
||||
add(new MenuButton("$text.tutorial", group, ()-> control.playMap(world.maps().getMap("tutorial"))));
|
||||
row();
|
||||
|
||||
add(new MenuButton("$text.loadgame", group, ui::showLoadGame));
|
||||
add(new MenuButton("$text.loadgame", group, ui.load::show));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("$text.editor", group, ui::showEditor));
|
||||
add(new MenuButton("$text.editor", group, ui.editor::show));
|
||||
row();
|
||||
}
|
||||
|
||||
add(new MenuButton("$text.settings", group, ui::showPrefs));
|
||||
add(new MenuButton("$text.settings", group, ui.prefs::show));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
@@ -61,25 +61,23 @@ public class MenuFragment implements Fragment{
|
||||
defaults().size(120f).pad(5);
|
||||
float isize = 14f*4;
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("$text.play").padTop(4f);
|
||||
new imagebutton("icon-play-2", isize, ui.levels::show).text("$text.play").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getMap("tutorial"))).text("$text.tutorial").padTop(4f);
|
||||
|
||||
new imagebutton("icon-load", isize, () -> ui.showLoadGame()).text("$text.load").padTop(4f);
|
||||
new imagebutton("icon-load", isize, ui.load::show).text("$text.load").padTop(4f);
|
||||
|
||||
new imagebutton("icon-add", isize, () -> ui.showJoinGame()).text("$text.joingame").padTop(4f);
|
||||
new imagebutton("icon-add", isize, ui.join::show).text("$text.joingame").padTop(4f);
|
||||
|
||||
row();
|
||||
|
||||
new imagebutton("icon-editor", isize, () -> ui.showEditor()).text("$text.editor").padTop(4f);
|
||||
new imagebutton("icon-editor", isize, ui.editor::show).text("$text.editor").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
|
||||
new imagebutton("icon-tools", isize, ui.prefs::show).text("$text.settings").padTop(4f);
|
||||
|
||||
new imagebutton("icon-info", isize, () -> ui.showAbout()).text("$text.about.button").padTop(4f);
|
||||
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, Mindustry.platforms::openDonations).text("$text.donate").padTop(4f);
|
||||
|
||||
visible(()->GameState.is(State.menu));
|
||||
}}.end();
|
||||
@@ -90,14 +88,10 @@ public class MenuFragment implements Fragment{
|
||||
new table(){{
|
||||
atop().aright();
|
||||
if(Mindustry.hasDiscord){
|
||||
new imagebutton("icon-discord", 30f, ()->{
|
||||
ui.showDiscord();
|
||||
}).margin(14);
|
||||
new imagebutton("icon-discord", 30f, ui.discord::show).margin(14);
|
||||
}
|
||||
if(!Vars.android) {
|
||||
new imagebutton("icon-info", 30f, () -> {
|
||||
ui.showAbout();
|
||||
}).margin(14);
|
||||
new imagebutton("icon-info", 30f, ui.about::show).margin(14);
|
||||
}
|
||||
}}.end().visible(()->GameState.is(State.menu));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PlayerListFragment implements Fragment{
|
||||
}
|
||||
});
|
||||
|
||||
visible(() -> Inputs.keyDown("player_list") && Net.active() && !GameState.is(State.menu)); //TODO move elsewhere?
|
||||
visible(() -> Inputs.keyDown("player_list") && Net.active() && !GameState.is(State.menu));
|
||||
}}.end();
|
||||
|
||||
rebuild();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
@@ -12,6 +10,8 @@ import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class WeaponFragment implements Fragment{
|
||||
Table weapontable;
|
||||
|
||||
@@ -64,11 +64,8 @@ public class WeaponFragment implements Fragment{
|
||||
tip.setInstant(true);
|
||||
|
||||
button.addListener(tip);
|
||||
|
||||
}
|
||||
|
||||
weapontable.addImageButton("icon-menu", 8*4, ()->{
|
||||
ui.showUpgrades();
|
||||
});
|
||||
weapontable.addImageButton("icon-menu", 8*4, ui.weaponfrag::updateWeapons);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user