Merging of map saves
This commit is contained in:
@@ -35,6 +35,7 @@ public class BorderImage extends Image{
|
||||
float scaleY = getScaleY();
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Draw.alpha(parentAlpha);
|
||||
Lines.stroke(Unit.dp.scl(thickness));
|
||||
Lines.rect(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||
Draw.reset();
|
||||
|
||||
@@ -7,9 +7,7 @@ import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.layout.Cell;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.OS;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.io.Contributors;
|
||||
import io.anuke.mindustry.io.Contributors.Contributor;
|
||||
@@ -27,7 +25,10 @@ public class AboutDialog extends FloatingDialog{
|
||||
super("$about.button");
|
||||
|
||||
if(!ios){
|
||||
Contributors.getContributors(out -> contributors = out, Throwable::printStackTrace);
|
||||
shown(() -> Contributors.getContributors(out -> {
|
||||
contributors = out;
|
||||
Core.app.post(this::setup);
|
||||
}, Throwable::printStackTrace));
|
||||
}
|
||||
|
||||
shown(this::setup);
|
||||
|
||||
@@ -24,15 +24,17 @@ public class ChangelogDialog extends FloatingDialog{
|
||||
|
||||
cont.add("$changelog.loading");
|
||||
|
||||
if(!ios && !OS.isMac){
|
||||
Changelogs.getChangelog(result -> {
|
||||
versions = result;
|
||||
Core.app.post(this::setup);
|
||||
}, t -> {
|
||||
Log.err(t);
|
||||
Core.app.post(this::setup);
|
||||
});
|
||||
}
|
||||
shown(() -> {
|
||||
if(!ios && !OS.isMac){
|
||||
Changelogs.getChangelog(result -> {
|
||||
versions = result;
|
||||
Core.app.post(this::setup);
|
||||
}, t -> {
|
||||
Log.err(t);
|
||||
Core.app.post(this::setup);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setup(){
|
||||
|
||||
@@ -2,28 +2,18 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.ButtonGroup;
|
||||
import io.anuke.arc.scene.ui.ImageButton;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.arc.util.Scaling;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.Gamemode;
|
||||
import io.anuke.mindustry.game.Rules;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class CustomGameDialog extends FloatingDialog{
|
||||
Difficulty difficulty = Difficulty.normal;
|
||||
CustomRulesDialog dialog = new CustomRulesDialog();
|
||||
Rules rules;
|
||||
Gamemode selectedGamemode;
|
||||
private MapPlayDialog dialog = new MapPlayDialog();
|
||||
|
||||
public CustomGameDialog(){
|
||||
super("$customgame");
|
||||
@@ -33,9 +23,11 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
selectedGamemode = Gamemode.survival;
|
||||
rules = selectedGamemode.get();
|
||||
|
||||
clearChildren();
|
||||
add(titleTable);
|
||||
row();
|
||||
stack(cont, buttons).grow();
|
||||
buttons.bottom();
|
||||
cont.clear();
|
||||
|
||||
Table maps = new Table();
|
||||
@@ -44,63 +36,9 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
pane.setFadeScrollBars(false);
|
||||
|
||||
int maxwidth = (Core.graphics.isPortrait() ? 2 : 4);
|
||||
|
||||
Table selmode = new Table();
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
selmode.add("$level.mode").colspan(4);
|
||||
selmode.row();
|
||||
int i = 0;
|
||||
|
||||
Table modes = new Table();
|
||||
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
modes.addButton(mode.toString(), "toggle", () -> {
|
||||
selectedGamemode = mode;
|
||||
rules = mode.get();
|
||||
dialog.selectedGamemode = null;
|
||||
dialog.rules = null;
|
||||
}).update(b -> b.setChecked(selectedGamemode == mode)).group(group).size(140f, 54f);
|
||||
if(i++ % 2 == 1) modes.row();
|
||||
}
|
||||
selmode.add(modes);
|
||||
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
|
||||
|
||||
cont.add(selmode);
|
||||
cont.row();
|
||||
|
||||
Difficulty[] ds = Difficulty.values();
|
||||
|
||||
float s = 50f;
|
||||
|
||||
Table sdif = new Table();
|
||||
|
||||
sdif.add("$setting.difficulty.name").colspan(3);
|
||||
sdif.row();
|
||||
sdif.defaults().height(s + 4);
|
||||
sdif.addImageButton("icon-arrow-left", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() - 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
|
||||
sdif.addButton("", () -> {
|
||||
})
|
||||
.update(t -> {
|
||||
t.setText(difficulty.toString());
|
||||
t.touchable(Touchable.disabled);
|
||||
}).width(180f);
|
||||
|
||||
sdif.addImageButton("icon-arrow-right", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() + 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
sdif.addButton("$customize", () -> dialog.show(rules, selectedGamemode)).width(140).padLeft(10);
|
||||
|
||||
cont.add(sdif);
|
||||
cont.row();
|
||||
|
||||
float images = 146f;
|
||||
|
||||
i = 0;
|
||||
int i = 0;
|
||||
maps.defaults().width(170).fillY().top().pad(4f);
|
||||
for(Map map : world.maps.all()){
|
||||
|
||||
@@ -121,10 +59,7 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
border.setScaling(Scaling.fit);
|
||||
image.replaceImage(border);
|
||||
|
||||
image.clicked(() -> {
|
||||
hide();
|
||||
control.playMap(map, (dialog.rules == null) ? rules : dialog.rules);
|
||||
});
|
||||
image.clicked(() -> dialog.show(map));
|
||||
|
||||
maps.add(image);
|
||||
|
||||
@@ -137,22 +72,4 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
|
||||
cont.add(pane).uniformX();
|
||||
}
|
||||
|
||||
private void displayGameModeHelp(){
|
||||
FloatingDialog d = new FloatingDialog(Core.bundle.get("mode.help.title"));
|
||||
d.setFillParent(false);
|
||||
Table table = new Table();
|
||||
table.defaults().pad(1f);
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
pane.setFadeScrollBars(false);
|
||||
table.row();
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
table.labelWrap("[accent]" + mode.toString() + ":[] [lightgray]" + mode.description()).width(400f);
|
||||
table.row();
|
||||
}
|
||||
|
||||
d.cont.add(pane);
|
||||
d.buttons.addButton("$ok", d::hide).size(110, 50).pad(10f);
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.Gamemode;
|
||||
import io.anuke.mindustry.game.Rules;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
|
||||
@@ -13,8 +12,8 @@ import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class CustomRulesDialog extends FloatingDialog{
|
||||
private Table main;
|
||||
public Rules rules;
|
||||
public Gamemode selectedGamemode;
|
||||
private Rules rules;
|
||||
private Supplier<Rules> resetter;
|
||||
|
||||
public CustomRulesDialog(){
|
||||
super("$mode.custom");
|
||||
@@ -24,9 +23,9 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(Rules rules, Gamemode gamemode){
|
||||
public void show(Rules rules, Supplier<Rules> resetter){
|
||||
this.rules = rules;
|
||||
this.selectedGamemode = gamemode;
|
||||
this.resetter = resetter;
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -35,12 +34,12 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
cont.pane(m -> main = m);
|
||||
main.margin(10f);
|
||||
main.addButton("$settings.reset", () -> {
|
||||
rules = selectedGamemode.get();
|
||||
rules = resetter.get();
|
||||
setup();
|
||||
}).size(300f, 50f);
|
||||
main.left().defaults().fillX().left().pad(5);
|
||||
main.row();
|
||||
|
||||
|
||||
title("$rules.title.waves");
|
||||
check("$rules.waves", b -> rules.waves = b, () -> rules.waves);
|
||||
check("$rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer, () -> rules.waves);
|
||||
@@ -49,8 +48,8 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
number("$rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> rules.waves);
|
||||
|
||||
title("$rules.title.respawns");
|
||||
check("$rules.limitedRespawns", b -> rules.limitedRespawns= b, () -> rules.limitedRespawns);
|
||||
number("$rules.respawns", true, f -> rules.respawns = (int) f, () -> rules.respawns, () -> rules.limitedRespawns);
|
||||
check("$rules.limitedRespawns", b -> rules.limitedRespawns = b, () -> rules.limitedRespawns);
|
||||
number("$rules.respawns", true, f -> rules.respawns = (int)f, () -> rules.respawns, () -> rules.limitedRespawns);
|
||||
number("$rules.respawntime", f -> rules.respawnTime = f * 60f, () -> rules.respawnTime / 60f);
|
||||
|
||||
title("$rules.title.resourcesbuilding");
|
||||
@@ -63,7 +62,7 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
number("$rules.playerhealthmultiplier", f -> rules.playerHealthMultiplier = f, () -> rules.playerHealthMultiplier);
|
||||
|
||||
title("$rules.title.unit");
|
||||
check("$rules.unitdrops", b -> rules.unitDrops = b, () -> rules.unitDrops, ()->true);
|
||||
check("$rules.unitdrops", b -> rules.unitDrops = b, () -> rules.unitDrops, () -> true);
|
||||
number("$rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier);
|
||||
number("$rules.unithealthmultiplier", f -> rules.unitHealthMultiplier = f, () -> rules.unitHealthMultiplier);
|
||||
number("$rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier);
|
||||
@@ -80,11 +79,11 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
main.table(t -> {
|
||||
t.left();
|
||||
t.add(text).left().padRight(5)
|
||||
.update(a->a.setColor(condition.get() ? Color.WHITE : Color.GRAY));
|
||||
.update(a -> a.setColor(condition.get() ? Color.WHITE : Color.GRAY));
|
||||
Platform.instance.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.accept(Strings.parseFloat(s)))
|
||||
.padRight(100f)
|
||||
.update(a -> a.setDisabled(!condition.get()))
|
||||
.valid(Strings::canParsePositiveFloat).width(120f) .left().get());
|
||||
.padRight(100f)
|
||||
.update(a -> a.setDisabled(!condition.get()))
|
||||
.valid(Strings::canParsePositiveFloat).width(120f).left().get());
|
||||
}).padTop(0);
|
||||
main.row();
|
||||
}
|
||||
|
||||
@@ -164,9 +164,9 @@ public class JoinDialog extends FloatingDialog{
|
||||
server.content.clear();
|
||||
|
||||
server.content.table(t -> {
|
||||
t.add(versionString).left();
|
||||
t.add("[lightgray]" + host.name).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
t.row();
|
||||
t.add("[lightgray]" + Core.bundle.format("server.hostname", host.name)).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
t.add(versionString).left();
|
||||
t.row();
|
||||
t.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players) :
|
||||
Core.bundle.format("players.single", host.players))).left();
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.anuke.arc.Core;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Strings;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -28,7 +29,7 @@ public class LanguageDialog extends FloatingDialog{
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
|
||||
for(Locale loc : locales){
|
||||
TextButton button = new TextButton(loc.getDisplayName(loc), "toggle");
|
||||
TextButton button = new TextButton(Strings.capitalize(loc.getDisplayName(loc)), "toggle");
|
||||
button.clicked(() -> {
|
||||
if(getLocale().equals(loc)) return;
|
||||
Core.settings.put("locale", loc.toString());
|
||||
|
||||
@@ -185,12 +185,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
button.clicked(() -> {
|
||||
if(!button.childrenPressed()){
|
||||
int build = slot.getBuild();
|
||||
if(SaveIO.breakingVersions.contains(build)){
|
||||
ui.showInfo("$save.old");
|
||||
slot.delete();
|
||||
}else{
|
||||
runLoadSave(slot);
|
||||
}
|
||||
runLoadSave(slot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
118
core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java
Normal file
118
core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Scaling;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MapPlayDialog extends FloatingDialog{
|
||||
Difficulty difficulty = Difficulty.normal;
|
||||
CustomRulesDialog dialog = new CustomRulesDialog();
|
||||
Rules rules;
|
||||
Gamemode selectedGamemode;
|
||||
|
||||
public MapPlayDialog(){
|
||||
super("");
|
||||
setFillParent(false);
|
||||
}
|
||||
|
||||
public void show(Map map){
|
||||
title.setText(map.name());
|
||||
cont.clearChildren();
|
||||
rules = map.rules();
|
||||
|
||||
Table selmode = new Table();
|
||||
selmode.add("$level.mode").colspan(4);
|
||||
selmode.row();
|
||||
int i = 0;
|
||||
|
||||
Table modes = new Table();
|
||||
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
if(mode.hidden) continue;
|
||||
|
||||
if((mode == Gamemode.attack && !map.hasEnemyCore()) || (mode == Gamemode.pvp && !map.hasOtherCores())){
|
||||
continue;
|
||||
}
|
||||
|
||||
modes.addButton(mode.toString(), "toggle", () -> {
|
||||
selectedGamemode = selectedGamemode == mode ? null : mode;
|
||||
rules = mode.apply(map.rules());
|
||||
}).update(b -> b.setChecked(selectedGamemode == mode)).size(140f, 54f);
|
||||
if(i++ % 2 == 1) modes.row();
|
||||
}
|
||||
selmode.add(modes);
|
||||
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
|
||||
|
||||
cont.add(selmode);
|
||||
cont.row();
|
||||
|
||||
Difficulty[] ds = Difficulty.values();
|
||||
|
||||
float s = 50f;
|
||||
|
||||
Table sdif = new Table();
|
||||
|
||||
sdif.add("$setting.difficulty.name").colspan(3);
|
||||
sdif.row();
|
||||
sdif.defaults().height(s + 4);
|
||||
sdif.addImageButton("icon-arrow-left", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() - 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
|
||||
sdif.addButton("", () -> {}).update(t -> {
|
||||
t.setText(difficulty.toString());
|
||||
t.touchable(Touchable.disabled);
|
||||
}).width(180f);
|
||||
|
||||
sdif.addImageButton("icon-arrow-right", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() + 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
sdif.addButton("$customize", () -> dialog.show(rules, () -> rules = (selectedGamemode == null ? map.rules() : selectedGamemode.apply(map.rules())))).width(140).padLeft(10);
|
||||
|
||||
cont.add(sdif);
|
||||
cont.row();
|
||||
cont.add(new BorderImage(map.texture, 3f)).size(250f).get().setScaling(Scaling.fit);
|
||||
|
||||
buttons.clearChildren();
|
||||
addCloseButton();
|
||||
|
||||
buttons.addImageTextButton("$play", "icon-play", 8*3, () -> {
|
||||
control.playMap(map, rules);
|
||||
hide();
|
||||
ui.custom.hide();
|
||||
}).size(210f, 64f);
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void displayGameModeHelp(){
|
||||
FloatingDialog d = new FloatingDialog(Core.bundle.get("mode.help.title"));
|
||||
d.setFillParent(false);
|
||||
Table table = new Table();
|
||||
table.defaults().pad(1f);
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
pane.setFadeScrollBars(false);
|
||||
table.row();
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
if(mode.hidden) continue;
|
||||
table.labelWrap("[accent]" + mode.toString() + ":[] [lightgray]" + mode.description()).width(400f);
|
||||
table.row();
|
||||
}
|
||||
|
||||
d.cont.add(pane);
|
||||
d.buttons.addButton("$ok", d::hide).size(110, 50).pad(10f);
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
buttons.addImageTextButton("$editor.importmap", "icon-add", 14 * 2, () -> {
|
||||
Platform.instance.showFileChooser("$editor.importmap", "Map File", file -> {
|
||||
try{
|
||||
Map map = MapIO.readMap(file, true);
|
||||
Map map = MapIO.createMap(file, true);
|
||||
String name = map.tags.get("name");
|
||||
if(name == null){
|
||||
ui.showError("$editor.errorname");
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
}
|
||||
cont.addButton("$settings", ui.settings::show);
|
||||
|
||||
if(!world.isZone()){
|
||||
if(!world.isZone() && !state.isEditor()){
|
||||
cont.row();
|
||||
cont.addButton("$savegame", save::show);
|
||||
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
|
||||
@@ -55,9 +55,10 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
cont.row();
|
||||
|
||||
cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f);
|
||||
|
||||
cont.row();
|
||||
if(!state.isEditor()){
|
||||
cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f);
|
||||
cont.row();
|
||||
}
|
||||
|
||||
cont.addButton("$quit", () -> {
|
||||
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
||||
@@ -74,7 +75,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
|
||||
cont.addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show);
|
||||
|
||||
if(!world.isZone()){
|
||||
if(!world.isZone() && !state.isEditor()){
|
||||
cont.addRowImageTextButton("$save", "icon-save", isize, save::show);
|
||||
|
||||
cont.row();
|
||||
@@ -84,7 +85,9 @@ public class PausedDialog extends FloatingDialog{
|
||||
cont.row();
|
||||
}
|
||||
|
||||
cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
||||
if(!state.isEditor()){
|
||||
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();
|
||||
@@ -96,8 +99,12 @@ public class PausedDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
public void runExitSave(){
|
||||
if(control.saves.getCurrent() == null ||
|
||||
!control.saves.getCurrent().isAutosave()){
|
||||
if(state.isEditor()){
|
||||
ui.editor.resumeEditing();
|
||||
return;
|
||||
}
|
||||
|
||||
if(control.saves.getCurrent() == null || !control.saves.getCurrent().isAutosave()){
|
||||
state.set(State.menu);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ZoneInfoDialog extends FloatingDialog{
|
||||
ui.deploy.hide();
|
||||
data.removeItems(zone.getLaunchCost());
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
control.playZone(zone);
|
||||
}
|
||||
}).minWidth(150f).margin(13f).padTop(5).disabled(b -> zone.locked() ? !canUnlock(zone) : !data.hasItems(zone.getLaunchCost())).uniformY().get();
|
||||
|
||||
|
||||
@@ -59,11 +59,11 @@ public class BlockInventoryFragment extends Fragment{
|
||||
}
|
||||
|
||||
public void showFor(Tile t){
|
||||
if(this.tile == t.target()){
|
||||
if(this.tile == t){
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
this.tile = t.target();
|
||||
this.tile = t;
|
||||
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.total() == 0)
|
||||
return;
|
||||
rebuild(true);
|
||||
|
||||
@@ -4,30 +4,39 @@ import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.math.Interpolation;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.actions.Actions;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.scene.utils.Elements;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.Packets.AdminAction;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.UnitType;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
|
||||
import java.lang.StringBuilder;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class HudFragment extends Fragment{
|
||||
@@ -131,8 +140,13 @@ public class HudFragment extends Fragment{
|
||||
}
|
||||
});
|
||||
|
||||
cont.table(stuff -> {
|
||||
stuff.left();
|
||||
Table wavesMain, editorMain;
|
||||
|
||||
cont.stack(wavesMain = new Table(), editorMain = new Table()).height(e -> wavesMain.isVisible() ? wavesMain.getPrefHeight() : editorMain.getPrefHeight());
|
||||
|
||||
{
|
||||
wavesMain.visible(() -> shown && !state.isEditor());
|
||||
wavesMain.left();
|
||||
Stack stack = new Stack();
|
||||
TextButton waves = new TextButton("", "wave");
|
||||
Table btable = new Table().margin(0);
|
||||
@@ -142,17 +156,103 @@ public class HudFragment extends Fragment{
|
||||
|
||||
addWaveTable(waves);
|
||||
addPlayButton(btable);
|
||||
stuff.add(stack).width(dsize * 4 + 3f);
|
||||
stuff.row();
|
||||
stuff.table("button", t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.WHITE))
|
||||
wavesMain.add(stack).width(dsize * 4 + 3f);
|
||||
wavesMain.row();
|
||||
wavesMain.table("button", t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.WHITE))
|
||||
.grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get();
|
||||
stuff.row();
|
||||
}).visible(() -> shown);
|
||||
wavesMain.row();
|
||||
}
|
||||
|
||||
{
|
||||
editorMain.table("button-edge-4", t -> {
|
||||
//t.margin(0f);
|
||||
t.add("$editor.teams").growX().left();
|
||||
t.row();
|
||||
t.table(teams -> {
|
||||
teams.left();
|
||||
int i = 0;
|
||||
for(Team team : Team.all){
|
||||
ImageButton button = teams.addImageButton("white", "clear-toggle-partial", 40f, () -> player.setTeam(team))
|
||||
.size(50f).margin(6f).get();
|
||||
button.getImageCell().grow();
|
||||
button.getStyle().imageUpColor = team.color;
|
||||
button.update(() -> button.setChecked(player.getTeam() == team));
|
||||
|
||||
if(++i % 3 == 0){
|
||||
teams.row();
|
||||
}
|
||||
}
|
||||
}).left();
|
||||
|
||||
t.row();
|
||||
t.addImageTextButton("$editor.spawn", "icon-add", 8*3, () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("$editor.spawn");
|
||||
int i = 0;
|
||||
for(UnitType type : content.<UnitType>getBy(ContentType.unit)){
|
||||
dialog.cont.addImageButton("white", 48, () -> {
|
||||
BaseUnit unit = type.create(player.getTeam());
|
||||
unit.set(player.x, player.y);
|
||||
unit.rotation = player.rotation;
|
||||
unit.add();
|
||||
//trigger the entity to become visible
|
||||
unitGroups[player.getTeam().ordinal()].updateEvents();
|
||||
collisions.updatePhysics( unitGroups[player.getTeam().ordinal()]);
|
||||
dialog.hide();
|
||||
}).get().getStyle().imageUp = new TextureRegionDrawable(type.iconRegion);
|
||||
if(++i % 4 == 0) dialog.cont.row();
|
||||
}
|
||||
dialog.addCloseButton();
|
||||
dialog.setFillParent(false);
|
||||
dialog.show();
|
||||
}).fillX();
|
||||
|
||||
float[] size = {0};
|
||||
float[] position = {0, 0};
|
||||
|
||||
t.row();
|
||||
t.addImageTextButton("$editor.removeunit", "icon-quit", "toggle", 8*3, () -> {
|
||||
|
||||
}).fillX().update(b -> {
|
||||
boolean[] found = {false};
|
||||
if(b.isChecked()){
|
||||
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||
if(e == null){
|
||||
Vector2 world = Core.input.mouseWorld();
|
||||
Units.nearby(world.x, world.y, 1f, 1f, unit -> {
|
||||
if(!found[0] && unit instanceof BaseUnit){
|
||||
if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){
|
||||
Effects.effect(Fx.spawn, unit);
|
||||
unit.remove();
|
||||
unitGroups[unit.getTeam().ordinal()].updateEvents();
|
||||
collisions.updatePhysics(unitGroups[unit.getTeam().ordinal()]);
|
||||
}
|
||||
found[0] = true;
|
||||
unit.hitbox(Tmp.r1);
|
||||
size[0] = Mathf.lerpDelta(size[0], Tmp.r1.width*2f + Mathf.absin(Time.time(), 10f, 5f), 0.1f);
|
||||
position[0] = unit.x;
|
||||
position[1] = unit.y;
|
||||
}
|
||||
});
|
||||
//TODO check for unit removal, remove unit if needed
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color(Pal.accent, Color.WHITE, Mathf.absin(Time.time(), 8f, 1f));
|
||||
Lines.poly(position[0], position[1], 4, size[0]/2f);
|
||||
Draw.reset();
|
||||
|
||||
if(!found[0]){
|
||||
size[0] = Mathf.lerpDelta(size[0], 0f, 0.2f);
|
||||
}
|
||||
});
|
||||
}).width(dsize * 4 + 3f);
|
||||
editorMain.visible(() -> shown && state.isEditor());
|
||||
}
|
||||
|
||||
//fps display
|
||||
cont.table(info -> {
|
||||
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps"));
|
||||
info.update(() -> info.setTranslation(state.rules.waves ? 0f : -Unit.dp.scl(dsize * 4 + 3), 0));
|
||||
info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Unit.dp.scl(dsize * 4 + 3), 0));
|
||||
IntFormat fps = new IntFormat("fps");
|
||||
IntFormat ping = new IntFormat("ping");
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PlacementFragment extends Fragment{
|
||||
Table blockTable, toggler, topTable;
|
||||
boolean lastGround;
|
||||
|
||||
//TODO make this configurable
|
||||
//not configurable, no plans to make it configurable
|
||||
final KeyCode[] inputGrid = {
|
||||
KeyCode.NUM_1, KeyCode.NUM_2, KeyCode.NUM_3, KeyCode.NUM_4,
|
||||
KeyCode.Q, KeyCode.W, KeyCode.E, KeyCode.R,
|
||||
@@ -78,7 +78,7 @@ public class PlacementFragment extends Fragment{
|
||||
Tile tile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
|
||||
if(tile != null){
|
||||
tile = tile.target();
|
||||
tile = tile.link();
|
||||
Block tryRecipe = tile.block();
|
||||
if(tryRecipe.isVisible() && unlocked(tryRecipe)){
|
||||
input.block = tryRecipe;
|
||||
@@ -150,7 +150,7 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
button.update(() -> { //color unplacable things gray
|
||||
TileEntity core = player.getClosestCore();
|
||||
Color color = core != null && (core.items.has(block.buildRequirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources) ? Color.WHITE : Color.GRAY;
|
||||
Color color = state.rules.infiniteResources || (core != null && (core.items.has(block.buildRequirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.WHITE : Color.GRAY;
|
||||
button.forEach(elem -> elem.setColor(color));
|
||||
button.setChecked(input.block == block);
|
||||
});
|
||||
@@ -313,7 +313,7 @@ public class PlacementFragment extends Fragment{
|
||||
if(!Core.scene.hasMouse() && topTable.hit(v.x, v.y, false) == null){
|
||||
Tile tile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
if(tile != null){
|
||||
hoverTile = tile.target();
|
||||
hoverTile = tile.link();
|
||||
}else{
|
||||
hoverTile = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user