Saves / Paused dialog cleanup / Zone rule save
|
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 543 B |
|
Before Width: | Height: | Size: 529 B After Width: | Height: | Size: 534 B |
|
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 252 B |
|
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 291 B |
|
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 285 B |
|
Before Width: | Height: | Size: 401 B After Width: | Height: | Size: 398 B |
|
Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 419 B |
|
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 377 B |
|
Before Width: | Height: | Size: 419 B After Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 423 B After Width: | Height: | Size: 411 B |
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 392 B |
|
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 311 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 397 B |
|
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 460 B |
|
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 346 B |
|
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 419 B |
|
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 380 B |
|
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 261 B |
|
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 323 B |
|
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 261 B |
|
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 300 B |
|
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 289 B After Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 428 B After Width: | Height: | Size: 438 B |
|
Before Width: | Height: | Size: 396 B After Width: | Height: | Size: 396 B |
|
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 444 B |
|
Before Width: | Height: | Size: 428 B After Width: | Height: | Size: 422 B |
|
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 317 B |
|
Before Width: | Height: | Size: 393 B After Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 456 B |
|
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 443 B |
|
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 397 B After Width: | Height: | Size: 408 B |
|
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 369 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 393 B |
|
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 272 B |
|
Before Width: | Height: | Size: 329 B After Width: | Height: | Size: 335 B |
|
Before Width: | Height: | Size: 413 B After Width: | Height: | Size: 407 B |
|
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 199 B |
|
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 366 B |
|
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 348 B |
|
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 1,017 B After Width: | Height: | Size: 1,006 B |
|
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 436 B |
|
Before Width: | Height: | Size: 421 B After Width: | Height: | Size: 399 B |
|
Before Width: | Height: | Size: 680 B After Width: | Height: | Size: 677 B |
|
Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 192 B |
|
|
@ -227,6 +227,7 @@ tutorial = Tutorial
|
|||
editor = Editor
|
||||
mapeditor = Map Editor
|
||||
donate = Donate
|
||||
resume = Resume Zone:\n[LIGHT_GRAY]{0}
|
||||
|
||||
connectfail = [crimson]Failed to connect to server:\n\n[accent]{0}
|
||||
error.unreachable = Server unreachable.\nIs the address spelled correctly?
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 515 KiB After Width: | Height: | Size: 457 KiB |
|
|
@ -116,6 +116,12 @@ public class Control implements ApplicationListener{
|
|||
//todo high scores for custom maps, as well as other statistics
|
||||
|
||||
Events.on(GameOverEvent.class, event -> {
|
||||
if(state.rules.zone != -1){
|
||||
//remove zone save on game over
|
||||
if(saves.getZoneSlot() != null){
|
||||
saves.getZoneSlot().delete();
|
||||
}
|
||||
}
|
||||
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
|
||||
//the restart dialog can show info for any number of scenarios
|
||||
Call.onGameOver(event.winner);
|
||||
|
|
|
|||
|
|
@ -192,6 +192,10 @@ public class World implements ApplicationListener{
|
|||
return generating;
|
||||
}
|
||||
|
||||
public boolean isZone(){
|
||||
return state.rules.zone != -1;
|
||||
}
|
||||
|
||||
public void playZone(Zone zone){
|
||||
ui.loadAnd(() -> {
|
||||
logic.reset();
|
||||
|
|
@ -202,6 +206,8 @@ public class World implements ApplicationListener{
|
|||
core.entity.items.add(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
state.rules.zone = zone.id;
|
||||
control.saves.zoneSave();
|
||||
logic.play();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,6 @@ public class Rules{
|
|||
public float respawnTime = 60 * 4;
|
||||
/**Time between waves in ticks.*/
|
||||
public float waveSpacing = 60 * 60;
|
||||
/**Zone ID, -1 for invalid zone.*/
|
||||
public byte zone = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
|||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.io.SaveMeta;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.type.Zone;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -105,6 +107,16 @@ public class Saves{
|
|||
return saving;
|
||||
}
|
||||
|
||||
public void zoneSave(){
|
||||
SaveSlot slot = new SaveSlot(-1);
|
||||
slot.setName("zone");
|
||||
saves.remove(s -> s.index == -1);
|
||||
saves.add(slot);
|
||||
saveMap.put(slot.index, slot);
|
||||
slot.save();
|
||||
saveSlots();
|
||||
}
|
||||
|
||||
public SaveSlot addSave(String name){
|
||||
SaveSlot slot = new SaveSlot(nextSlot);
|
||||
nextSlot++;
|
||||
|
|
@ -129,6 +141,11 @@ public class Saves{
|
|||
return slot;
|
||||
}
|
||||
|
||||
public SaveSlot getZoneSlot(){
|
||||
SaveSlot slot = getByID(-1);
|
||||
return slot == null || slot.getZone() == null ? null : slot;
|
||||
}
|
||||
|
||||
public SaveSlot getByID(int id){
|
||||
return saveMap.get(id);
|
||||
}
|
||||
|
|
@ -203,6 +220,10 @@ public class Saves{
|
|||
Core.settings.save();
|
||||
}
|
||||
|
||||
public Zone getZone(){
|
||||
return content.getByID(ContentType.zone, meta.rules.zone);
|
||||
}
|
||||
|
||||
public int getBuild(){
|
||||
return meta.build;
|
||||
}
|
||||
|
|
@ -211,10 +232,6 @@ public class Saves{
|
|||
return meta.wave;
|
||||
}
|
||||
|
||||
public Difficulty getDifficulty(){
|
||||
return meta.difficulty;
|
||||
}
|
||||
|
||||
public boolean isAutosave(){
|
||||
return Core.settings.getBool("save-" + index + "-autosave", true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@ import io.anuke.arc.util.Pack;
|
|||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.entities.traits.SaveTrait;
|
||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.MappableContent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.Serialization;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||
|
|
@ -33,11 +31,11 @@ public abstract class SaveFileVersion{
|
|||
long time = stream.readLong();
|
||||
long playtime = stream.readLong();
|
||||
int build = stream.readInt();
|
||||
byte mode = stream.readByte();
|
||||
|
||||
Rules rules = Serialization.readRules(stream);
|
||||
String map = stream.readUTF();
|
||||
int wave = stream.readInt();
|
||||
byte difficulty = stream.readByte();
|
||||
return new SaveMeta(version, time, playtime, build, mode, map, wave, Difficulty.values()[difficulty]);
|
||||
return new SaveMeta(version, time, playtime, build, map, wave, rules);
|
||||
}
|
||||
|
||||
public void writeMap(DataOutputStream stream) throws IOException{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package io.anuke.mindustry.io;
|
||||
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.Rules;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
|
@ -12,15 +12,15 @@ public class SaveMeta{
|
|||
public long timePlayed;
|
||||
public Map map;
|
||||
public int wave;
|
||||
public Difficulty difficulty;
|
||||
public Rules rules;
|
||||
|
||||
public SaveMeta(int version, long timestamp, long timePlayed, int build, int mode, String map, int wave, Difficulty difficulty){
|
||||
public SaveMeta(int version, long timestamp, long timePlayed, int build, String map, int wave, Rules rules){
|
||||
this.version = version;
|
||||
this.build = build;
|
||||
this.timestamp = timestamp;
|
||||
this.timePlayed = timePlayed;
|
||||
this.map = world.maps.getByName(map);
|
||||
this.wave = wave;
|
||||
this.difficulty = difficulty;
|
||||
this.rules = rules;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.ObjectIntMap;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.Vars;
|
||||
|
|
@ -39,24 +40,30 @@ public class DeployDialog extends FloatingDialog{
|
|||
|
||||
}}, new Table(){{
|
||||
|
||||
for(Zone zone : Vars.content.zones()){
|
||||
if(data.isUnlocked(zone)){
|
||||
table(t -> {
|
||||
t.addButton(zone.localizedName(), () -> {
|
||||
data.removeItems(zone.deployCost);
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
}).size(150f)/*.disabled(b -> !data.hasItems(zone.deployCost))*/;
|
||||
t.row();
|
||||
t.table(req -> {
|
||||
req.left();
|
||||
for(ItemStack stack : zone.deployCost){
|
||||
req.addImage(stack.item.region).size(8*3);
|
||||
req.add(stack.amount + "").left();
|
||||
}
|
||||
}).pad(3).growX();
|
||||
}).pad(3);
|
||||
if(control.saves.getZoneSlot() == null){
|
||||
|
||||
for(Zone zone : Vars.content.zones()){
|
||||
if(data.isUnlocked(zone)){
|
||||
table(t -> {
|
||||
t.addButton(zone.localizedName(), () -> {
|
||||
data.removeItems(zone.deployCost);
|
||||
hide();
|
||||
world.playZone(zone);
|
||||
}).size(150f).disabled(b -> !data.hasItems(zone.deployCost));
|
||||
t.row();
|
||||
t.table(req -> {
|
||||
req.left();
|
||||
for(ItemStack stack : zone.deployCost){
|
||||
req.addImage(stack.item.region).size(8 * 3);
|
||||
req.add(stack.amount + "").left();
|
||||
}
|
||||
}).pad(3).growX();
|
||||
}).pad(3);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
addButton(Core.bundle.format("resume", control.saves.getZoneSlot().getZone().localizedName()), () -> control.saves.getZoneSlot().load())
|
||||
.size(200f);
|
||||
}
|
||||
}}).grow();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,8 +116,6 @@ public class LoadDialog extends FloatingDialog{
|
|||
button.row();
|
||||
button.add(Core.bundle.format("save.wave", color + slot.getWave()));
|
||||
button.row();
|
||||
button.add(Core.bundle.format("save.difficulty", color + slot.getDifficulty()));
|
||||
button.row();
|
||||
button.label(() -> Core.bundle.format("save.autosave", color + Core.bundle.get(slot.isAutosave() ? "on" : "off")));
|
||||
button.row();
|
||||
button.label(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime()));
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package io.anuke.mindustry.ui.dialogs;
|
|||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.scene.style.Drawable;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
|
||||
|
|
@ -12,12 +10,10 @@ import static io.anuke.mindustry.Vars.*;
|
|||
public class PausedDialog extends FloatingDialog{
|
||||
private SaveDialog save = new SaveDialog();
|
||||
private LoadDialog load = new LoadDialog();
|
||||
private Table missionTable;
|
||||
|
||||
public PausedDialog(){
|
||||
super("$menu");
|
||||
shouldPause = true;
|
||||
setup();
|
||||
|
||||
shown(this::rebuild);
|
||||
|
||||
|
|
@ -29,20 +25,14 @@ public class PausedDialog extends FloatingDialog{
|
|||
}
|
||||
|
||||
void rebuild(){
|
||||
missionTable.clear();
|
||||
missionTable.background((Drawable) null);
|
||||
}
|
||||
cont.clear();
|
||||
|
||||
void setup(){
|
||||
update(() -> {
|
||||
if(state.is(State.menu) && isShown()){
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
cont.table(t -> missionTable = t).colspan(mobile ? 3 : 2);
|
||||
cont.row();
|
||||
|
||||
if(!mobile){
|
||||
float dw = 210f;
|
||||
cont.defaults().width(dw).height(50).pad(5f);
|
||||
|
|
@ -53,9 +43,11 @@ public class PausedDialog extends FloatingDialog{
|
|||
cont.addButton("$unlocks", ui.unlocks::show);
|
||||
cont.addButton("$settings", ui.settings::show);
|
||||
|
||||
cont.row();
|
||||
cont.addButton("$savegame", save::show);
|
||||
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
|
||||
if(!world.isZone()){
|
||||
cont.row();
|
||||
cont.addButton("$savegame", save::show);
|
||||
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
|
||||
}
|
||||
|
||||
cont.row();
|
||||
|
||||
|
|
@ -77,11 +69,15 @@ public class PausedDialog extends FloatingDialog{
|
|||
|
||||
cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
|
||||
cont.addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show);
|
||||
cont.addRowImageTextButton("$save", "icon-save", isize, save::show);
|
||||
|
||||
cont.row();
|
||||
if(!world.isZone()){
|
||||
cont.addRowImageTextButton("$save", "icon-save", isize, save::show);
|
||||
|
||||
cont.row();
|
||||
|
||||
cont.addRowImageTextButton("$load", "icon-load", isize, load::show).disabled(b -> Net.active());
|
||||
}
|
||||
|
||||
cont.addRowImageTextButton("$load", "icon-load", isize, load::show).disabled(b -> Net.active());
|
||||
cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
||||
cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> {
|
||||
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
||||
|
|
|
|||