Skip to content

Commit f4582dc

Browse files
cleanup
1 parent 2567cb9 commit f4582dc

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

engine/src/main/java/org/destinationsol/game/SaveManager.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,16 @@ public static boolean resourceExists(String fileName) {
188188
}
189189

190190
/**
191-
* Tests is the game has a previous ship (a game to continue)
191+
* Tests if the game has a compatible previous ship (a game to continue)
192192
*/
193-
public static boolean hasPrevShip(String fileName) {
194-
return resourceExists(fileName);
193+
public static boolean hasPreviousCompatibleShip() {
194+
if (!resourceExists(Const.SAVE_FILE_NAME)) {
195+
return false;
196+
}
197+
IniReader reader = new IniReader(Const.SAVE_FILE_NAME, null);
198+
String saveMajorVersion = reader.getString("version", "").split("\\.")[0];
199+
String gameMajorVersion = Const.VERSION.split("\\.")[0];
200+
return saveMajorVersion.equals(gameMajorVersion);
195201
}
196202

197203
/**

engine/src/main/java/org/destinationsol/menu/NewGameScreen.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
import com.badlogic.gdx.graphics.Texture;
2020
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
21-
import org.destinationsol.Const;
2221
import org.destinationsol.GameOptions;
23-
import org.destinationsol.IniReader;
2422
import org.destinationsol.SolApplication;
2523
import org.destinationsol.assets.Assets;
2624
import org.destinationsol.common.SolColor;
@@ -60,10 +58,7 @@ public class NewGameScreen extends SolUiBaseScreen {
6058

6159
@Override
6260
public void onAdd(SolApplication solApplication) {
63-
IniReader reader = new IniReader(Const.SAVE_FILE_NAME, null);
64-
String saveMajorVersion = reader.getString("version", "").split("\\.")[0];
65-
String gameMajorVersion = Const.VERSION.split("\\.")[0];
66-
continueControl.setEnabled(SaveManager.hasPrevShip("prevShip.ini") && saveMajorVersion.equals(gameMajorVersion));
61+
continueControl.setEnabled(SaveManager.hasPreviousCompatibleShip());
6762
}
6863

6964
@Override

0 commit comments

Comments
 (0)