v1.2.0: deleted games now empty the main file instead of deleting it
This commit is contained in:
@@ -37,7 +37,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Ankh;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
@@ -53,7 +52,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.CityLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.DeadEndLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.HallsLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.LastLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.LastShopLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.CavesBossLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.CityBossLevel;
|
||||
@@ -666,12 +664,20 @@ public class Dungeon {
|
||||
}
|
||||
|
||||
public static void deleteGame( int save, boolean deleteLevels ) {
|
||||
|
||||
FileUtils.deleteFile(GamesInProgress.gameFile(save));
|
||||
|
||||
|
||||
if (deleteLevels) {
|
||||
String folder = GamesInProgress.gameFolder(save);
|
||||
for (String file : FileUtils.filesInDir(folder)){
|
||||
if (file.contains("depth")){
|
||||
FileUtils.deleteFile(folder + "/" + file);
|
||||
}
|
||||
}
|
||||
ArrayList<String> files = FileUtils.filesInDir(GamesInProgress.gameFolder(save));
|
||||
FileUtils.deleteDir(GamesInProgress.gameFolder(save));
|
||||
}
|
||||
|
||||
//we empty this file instead of delete due to steam cloud only persisting file deletions locally
|
||||
FileUtils.setFileEmpty(GamesInProgress.gameFile(save));
|
||||
|
||||
GamesInProgress.delete( save );
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ public class GamesInProgress {
|
||||
private static final String DEPTH_FILE = "depth%d.dat";
|
||||
|
||||
public static boolean gameExists( int slot ){
|
||||
return FileUtils.dirExists(Messages.format(GAME_FOLDER, slot));
|
||||
return FileUtils.dirExists(gameFolder(slot))
|
||||
&& FileUtils.fileExists(gameFile(slot));
|
||||
}
|
||||
|
||||
public static String gameFolder( int slot ){
|
||||
|
||||
@@ -149,8 +149,7 @@ public class WndGameInProgress extends Window {
|
||||
@Override
|
||||
protected void onSelect( int index ) {
|
||||
if (index == 0) {
|
||||
FileUtils.deleteDir(GamesInProgress.gameFolder(slot));
|
||||
GamesInProgress.setUnknown(slot);
|
||||
Dungeon.deleteGame(slot, true);
|
||||
ShatteredPixelDungeon.switchNoFade(StartScene.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user