Fixed game data clearing
This commit is contained in:
@@ -267,7 +267,8 @@ text.settings.game=Game
|
|||||||
text.settings.sound=Sound
|
text.settings.sound=Sound
|
||||||
text.settings.graphics=Graphics
|
text.settings.graphics=Graphics
|
||||||
text.settings.cleardata=Clear Game Data...
|
text.settings.cleardata=Clear Game Data...
|
||||||
text.settings.clear.confirm=Are you sure you want to clear your data?\nThis cannot be undone!
|
text.settings.clear.confirm=Are you sure you want to clear this data?\nWhat is done cannot be undone!
|
||||||
|
text.settings.clearall.confirm=[scarlet]WARNING![]\nThis will clear all data, including saves, maps, unlocks and keybinds.\nOnce you press 'ok' the game will wipe all data and automatically exit.
|
||||||
text.settings.clearsectors=Clear Sectors
|
text.settings.clearsectors=Clear Sectors
|
||||||
text.settings.clearunlocks=Clear Unlocks
|
text.settings.clearunlocks=Clear Unlocks
|
||||||
text.settings.clearall=Clear All
|
text.settings.clearall=Clear All
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ public class Vars{
|
|||||||
public static boolean android;
|
public static boolean android;
|
||||||
//shorthand for whether or not this is running on GWT
|
//shorthand for whether or not this is running on GWT
|
||||||
public static boolean gwt;
|
public static boolean gwt;
|
||||||
|
//main data directory
|
||||||
|
public static FileHandle dataDirectory;
|
||||||
//directory for user-created map data
|
//directory for user-created map data
|
||||||
public static FileHandle customMapDirectory;
|
public static FileHandle customMapDirectory;
|
||||||
//save file directory
|
//save file directory
|
||||||
@@ -181,8 +183,9 @@ public class Vars{
|
|||||||
gwt = Gdx.app.getType() == ApplicationType.WebGL;
|
gwt = Gdx.app.getType() == ApplicationType.WebGL;
|
||||||
|
|
||||||
if(!gwt){
|
if(!gwt){
|
||||||
customMapDirectory = OS.getAppDataDirectory("Mindustry").child("maps/");
|
dataDirectory = OS.getAppDataDirectory("Mindustry");
|
||||||
saveDirectory = OS.getAppDataDirectory("Mindustry").child("saves/");
|
customMapDirectory = dataDirectory.child("maps/");
|
||||||
|
saveDirectory = dataDirectory.child("saves/");
|
||||||
}
|
}
|
||||||
|
|
||||||
fontScale = Math.max(Unit.dp.scl(1f) / 2f, 0.5f);
|
fontScale = Math.max(Unit.dp.scl(1f) / 2f, 0.5f);
|
||||||
|
|||||||
@@ -294,6 +294,7 @@ public class UI extends SceneModule{
|
|||||||
FloatingDialog dialog = new FloatingDialog(title);
|
FloatingDialog dialog = new FloatingDialog(title);
|
||||||
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
||||||
dialog.buttons().defaults().size(200f, 54f).pad(2f);
|
dialog.buttons().defaults().size(200f, 54f).pad(2f);
|
||||||
|
dialog.setFillParent(false);
|
||||||
dialog.buttons().addButton("$text.cancel", dialog::hide);
|
dialog.buttons().addButton("$text.cancel", dialog::hide);
|
||||||
dialog.buttons().addButton("$text.ok", () -> {
|
dialog.buttons().addButton("$text.ok", () -> {
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ public class Sectors{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load(){
|
public void load(){
|
||||||
|
for(Sector sector : grid.values()){
|
||||||
|
sector.texture.dispose();
|
||||||
|
}
|
||||||
|
grid.clear();
|
||||||
|
|
||||||
Array<Sector> out = Settings.getJson("sectors", Array.class);
|
Array<Sector> out = Settings.getJson("sectors", Array.class);
|
||||||
|
|
||||||
for(Sector sector : out){
|
for(Sector sector : out){
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class SectorsDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
|
selected = null;
|
||||||
content().clear();
|
content().clear();
|
||||||
buttons().clear();
|
buttons().clear();
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package io.anuke.mindustry.ui.dialogs;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
@@ -141,29 +141,38 @@ public class SettingsMenuDialog extends SettingsDialog{
|
|||||||
table.addButton("$text.settings.cleardata", () -> {
|
table.addButton("$text.settings.cleardata", () -> {
|
||||||
FloatingDialog dialog = new FloatingDialog("$text.settings.cleardata");
|
FloatingDialog dialog = new FloatingDialog("$text.settings.cleardata");
|
||||||
dialog.setFillParent(false);
|
dialog.setFillParent(false);
|
||||||
dialog.content().defaults().size(230f, 50f).pad(3);
|
dialog.content().defaults().size(230f, 60f).pad(3);
|
||||||
dialog.addCloseButton();
|
dialog.addCloseButton();
|
||||||
dialog.content().addButton("$text.settings.clearsectors", () -> {
|
dialog.content().addButton("$text.settings.clearsectors", "clear", () -> {
|
||||||
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
||||||
Settings.putString("sectors", "{}");
|
Settings.putString("sectors", "{}");
|
||||||
Settings.save();
|
Settings.save();
|
||||||
|
world.sectors().load();
|
||||||
|
dialog.hide();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
dialog.content().row();
|
dialog.content().row();
|
||||||
dialog.content().addButton("$text.settings.clearunlocks", () -> {
|
dialog.content().addButton("$text.settings.clearunlocks", "clear", () -> {
|
||||||
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
||||||
Settings.putString("unlocks", "{}");
|
Settings.putString("unlocks", "{}");
|
||||||
Settings.save();
|
Settings.save();
|
||||||
|
dialog.hide();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
dialog.content().row();
|
dialog.content().row();
|
||||||
dialog.content().addButton("$text.settings.clearall", () -> {
|
dialog.content().addButton("$text.settings.clearall", "clear", () -> {
|
||||||
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
ui.showConfirm("$text.confirm", "$text.settings.clearall.confirm", () -> {
|
||||||
for(SaveSlot slot : control.getSaves().getSaveSlots()){
|
|
||||||
slot.delete();
|
|
||||||
}
|
|
||||||
Settings.prefs().clear();
|
Settings.prefs().clear();
|
||||||
Settings.save();
|
Settings.save();
|
||||||
|
|
||||||
|
if(!gwt){
|
||||||
|
Settings.prefs().clear();
|
||||||
|
for(FileHandle file : dataDirectory.list()){
|
||||||
|
file.deleteDirectory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdx.app.exit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
dialog.content().row();
|
dialog.content().row();
|
||||||
|
|||||||
Reference in New Issue
Block a user