Saves / Paused dialog cleanup / Zone rule save

This commit is contained in:
Anuken
2019-01-16 23:25:43 -05:00
parent 836a4eb892
commit 58e83c11f0
66 changed files with 996 additions and 965 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 534 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 B

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 B

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

After

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 B

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 B

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 B

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 341 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1017 B

After

Width:  |  Height:  |  Size: 1006 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 192 B

View File

@@ -227,6 +227,7 @@ tutorial = Tutorial
editor = Editor editor = Editor
mapeditor = Map Editor mapeditor = Map Editor
donate = Donate donate = Donate
resume = Resume Zone:\n[LIGHT_GRAY]{0}
connectfail = [crimson]Failed to connect to server:\n\n[accent]{0} connectfail = [crimson]Failed to connect to server:\n\n[accent]{0}
error.unreachable = Server unreachable.\nIs the address spelled correctly? error.unreachable = Server unreachable.\nIs the address spelled correctly?

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 KiB

After

Width:  |  Height:  |  Size: 457 KiB

View File

@@ -116,6 +116,12 @@ public class Control implements ApplicationListener{
//todo high scores for custom maps, as well as other statistics //todo high scores for custom maps, as well as other statistics
Events.on(GameOverEvent.class, event -> { 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); Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
//the restart dialog can show info for any number of scenarios //the restart dialog can show info for any number of scenarios
Call.onGameOver(event.winner); Call.onGameOver(event.winner);

View File

@@ -192,6 +192,10 @@ public class World implements ApplicationListener{
return generating; return generating;
} }
public boolean isZone(){
return state.rules.zone != -1;
}
public void playZone(Zone zone){ public void playZone(Zone zone){
ui.loadAnd(() -> { ui.loadAnd(() -> {
logic.reset(); logic.reset();
@@ -202,6 +206,8 @@ public class World implements ApplicationListener{
core.entity.items.add(stack.item, stack.amount); core.entity.items.add(stack.item, stack.amount);
} }
} }
state.rules.zone = zone.id;
control.saves.zoneSave();
logic.play(); logic.play();
}); });
} }

View File

@@ -24,4 +24,6 @@ public class Rules{
public float respawnTime = 60 * 4; public float respawnTime = 60 * 4;
/**Time between waves in ticks.*/ /**Time between waves in ticks.*/
public float waveSpacing = 60 * 60; public float waveSpacing = 60 * 60;
/**Zone ID, -1 for invalid zone.*/
public byte zone = -1;
} }

View File

@@ -13,6 +13,8 @@ import io.anuke.mindustry.game.EventType.StateChangeEvent;
import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.io.SaveMeta; import io.anuke.mindustry.io.SaveMeta;
import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.Zone;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -105,6 +107,16 @@ public class Saves{
return saving; 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){ public SaveSlot addSave(String name){
SaveSlot slot = new SaveSlot(nextSlot); SaveSlot slot = new SaveSlot(nextSlot);
nextSlot++; nextSlot++;
@@ -129,6 +141,11 @@ public class Saves{
return slot; return slot;
} }
public SaveSlot getZoneSlot(){
SaveSlot slot = getByID(-1);
return slot == null || slot.getZone() == null ? null : slot;
}
public SaveSlot getByID(int id){ public SaveSlot getByID(int id){
return saveMap.get(id); return saveMap.get(id);
} }
@@ -203,6 +220,10 @@ public class Saves{
Core.settings.save(); Core.settings.save();
} }
public Zone getZone(){
return content.getByID(ContentType.zone, meta.rules.zone);
}
public int getBuild(){ public int getBuild(){
return meta.build; return meta.build;
} }
@@ -211,10 +232,6 @@ public class Saves{
return meta.wave; return meta.wave;
} }
public Difficulty getDifficulty(){
return meta.difficulty;
}
public boolean isAutosave(){ public boolean isAutosave(){
return Core.settings.getBool("save-" + index + "-autosave", true); return Core.settings.getBool("save-" + index + "-autosave", true);
} }

View File

@@ -8,10 +8,8 @@ import io.anuke.arc.util.Pack;
import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.entities.traits.SaveTrait; import io.anuke.mindustry.entities.traits.SaveTrait;
import io.anuke.mindustry.entities.traits.TypeTrait; import io.anuke.mindustry.entities.traits.TypeTrait;
import io.anuke.mindustry.game.Content; import io.anuke.mindustry.game.*;
import io.anuke.mindustry.game.Difficulty; import io.anuke.mindustry.gen.Serialization;
import io.anuke.mindustry.game.MappableContent;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.BlockPart; import io.anuke.mindustry.world.blocks.BlockPart;
@@ -33,11 +31,11 @@ public abstract class SaveFileVersion{
long time = stream.readLong(); long time = stream.readLong();
long playtime = stream.readLong(); long playtime = stream.readLong();
int build = stream.readInt(); int build = stream.readInt();
byte mode = stream.readByte();
Rules rules = Serialization.readRules(stream);
String map = stream.readUTF(); String map = stream.readUTF();
int wave = stream.readInt(); int wave = stream.readInt();
byte difficulty = stream.readByte(); return new SaveMeta(version, time, playtime, build, map, wave, rules);
return new SaveMeta(version, time, playtime, build, mode, map, wave, Difficulty.values()[difficulty]);
} }
public void writeMap(DataOutputStream stream) throws IOException{ public void writeMap(DataOutputStream stream) throws IOException{

View File

@@ -1,6 +1,6 @@
package io.anuke.mindustry.io; package io.anuke.mindustry.io;
import io.anuke.mindustry.game.Difficulty; import io.anuke.mindustry.game.Rules;
import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.maps.Map;
import static io.anuke.mindustry.Vars.world; import static io.anuke.mindustry.Vars.world;
@@ -12,15 +12,15 @@ public class SaveMeta{
public long timePlayed; public long timePlayed;
public Map map; public Map map;
public int wave; 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.version = version;
this.build = build; this.build = build;
this.timestamp = timestamp; this.timestamp = timestamp;
this.timePlayed = timePlayed; this.timePlayed = timePlayed;
this.map = world.maps.getByName(map); this.map = world.maps.getByName(map);
this.wave = wave; this.wave = wave;
this.difficulty = difficulty; this.rules = rules;
} }
} }

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.ui.dialogs; package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.collection.ObjectIntMap; import io.anuke.arc.collection.ObjectIntMap;
import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
@@ -39,24 +40,30 @@ public class DeployDialog extends FloatingDialog{
}}, new Table(){{ }}, new Table(){{
for(Zone zone : Vars.content.zones()){ if(control.saves.getZoneSlot() == null){
if(data.isUnlocked(zone)){
table(t -> { for(Zone zone : Vars.content.zones()){
t.addButton(zone.localizedName(), () -> { if(data.isUnlocked(zone)){
data.removeItems(zone.deployCost); table(t -> {
hide(); t.addButton(zone.localizedName(), () -> {
world.playZone(zone); data.removeItems(zone.deployCost);
}).size(150f)/*.disabled(b -> !data.hasItems(zone.deployCost))*/; hide();
t.row(); world.playZone(zone);
t.table(req -> { }).size(150f).disabled(b -> !data.hasItems(zone.deployCost));
req.left(); t.row();
for(ItemStack stack : zone.deployCost){ t.table(req -> {
req.addImage(stack.item.region).size(8*3); req.left();
req.add(stack.amount + "").left(); for(ItemStack stack : zone.deployCost){
} req.addImage(stack.item.region).size(8 * 3);
}).pad(3).growX(); req.add(stack.amount + "").left();
}).pad(3); }
}).pad(3).growX();
}).pad(3);
}
} }
}else{
addButton(Core.bundle.format("resume", control.saves.getZoneSlot().getZone().localizedName()), () -> control.saves.getZoneSlot().load())
.size(200f);
} }
}}).grow(); }}).grow();
} }

View File

@@ -116,8 +116,6 @@ public class LoadDialog extends FloatingDialog{
button.row(); button.row();
button.add(Core.bundle.format("save.wave", color + slot.getWave())); button.add(Core.bundle.format("save.wave", color + slot.getWave()));
button.row(); 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.label(() -> Core.bundle.format("save.autosave", color + Core.bundle.get(slot.isAutosave() ? "on" : "off")));
button.row(); button.row();
button.label(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime())); button.label(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime()));

View File

@@ -2,8 +2,6 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.input.KeyCode; 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.core.GameState.State;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
@@ -12,12 +10,10 @@ import static io.anuke.mindustry.Vars.*;
public class PausedDialog extends FloatingDialog{ public class PausedDialog extends FloatingDialog{
private SaveDialog save = new SaveDialog(); private SaveDialog save = new SaveDialog();
private LoadDialog load = new LoadDialog(); private LoadDialog load = new LoadDialog();
private Table missionTable;
public PausedDialog(){ public PausedDialog(){
super("$menu"); super("$menu");
shouldPause = true; shouldPause = true;
setup();
shown(this::rebuild); shown(this::rebuild);
@@ -29,20 +25,14 @@ public class PausedDialog extends FloatingDialog{
} }
void rebuild(){ void rebuild(){
missionTable.clear(); cont.clear();
missionTable.background((Drawable) null);
}
void setup(){
update(() -> { update(() -> {
if(state.is(State.menu) && isShown()){ if(state.is(State.menu) && isShown()){
hide(); hide();
} }
}); });
cont.table(t -> missionTable = t).colspan(mobile ? 3 : 2);
cont.row();
if(!mobile){ if(!mobile){
float dw = 210f; float dw = 210f;
cont.defaults().width(dw).height(50).pad(5f); 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("$unlocks", ui.unlocks::show);
cont.addButton("$settings", ui.settings::show); cont.addButton("$settings", ui.settings::show);
cont.row(); if(!world.isZone()){
cont.addButton("$savegame", save::show); cont.row();
cont.addButton("$loadgame", load::show).disabled(b -> Net.active()); cont.addButton("$savegame", save::show);
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
}
cont.row(); cont.row();
@@ -77,11 +69,15 @@ public class PausedDialog extends FloatingDialog{
cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide); cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
cont.addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show); 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("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> { cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> {
ui.showConfirm("$confirm", "$quit.confirm", () -> { ui.showConfirm("$confirm", "$quit.confirm", () -> {