|
@@ -4,30 +4,44 @@ import ui.model.Model;
|
|
|
|
|
|
public class AutoSaveController {
|
|
public class AutoSaveController {
|
|
private Model MODEL;
|
|
private Model MODEL;
|
|
|
|
+ private int max = Integer.MAX_VALUE;
|
|
private int numberOfSaves = 20;
|
|
private int numberOfSaves = 20;
|
|
- private int autoSaveNr, tmp = 0;
|
|
|
|
|
|
+ private int currentSave;
|
|
|
|
+ private int count = 0;
|
|
|
|
+ private boolean isAllowed = false;
|
|
|
|
+
|
|
public AutoSaveController(Model model) {
|
|
public AutoSaveController(Model model) {
|
|
this.MODEL = model;
|
|
this.MODEL = model;
|
|
}
|
|
}
|
|
-
|
|
|
|
- public void increaseAutoSaveNr(){
|
|
|
|
- autoSaveNr = MODEL.getAutoSaveNr()+1;
|
|
|
|
- tmp = MODEL.getAutoSaveNr();
|
|
|
|
- if(autoSaveNr > numberOfSaves){
|
|
|
|
- autoSaveNr = 0;
|
|
|
|
|
|
+
|
|
|
|
+ public void increaseAutoSaveNr() {
|
|
|
|
+ currentSave = MODEL.getAutoSaveNr() + 1;
|
|
|
|
+ if (count < currentSave) {
|
|
|
|
+ count = currentSave;
|
|
|
|
+ }
|
|
|
|
+ if (numberOfSaves == count) {
|
|
|
|
+ isAllowed = true;
|
|
}
|
|
}
|
|
- MODEL.setAutoSaveNr(autoSaveNr);
|
|
|
|
|
|
+ if (currentSave > max) {
|
|
|
|
+ currentSave = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MODEL.setAutoSaveNr(currentSave);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void decreaseAutoSaveNr() {
|
|
public void decreaseAutoSaveNr() {
|
|
- autoSaveNr = MODEL.getAutoSaveNr()-1;
|
|
|
|
- if(autoSaveNr < 0){
|
|
|
|
- autoSaveNr = numberOfSaves;
|
|
|
|
|
|
+ currentSave = MODEL.getAutoSaveNr() - 1;
|
|
|
|
+ if (currentSave < 0) {
|
|
|
|
+ currentSave = max;
|
|
}
|
|
}
|
|
- MODEL.setAutoSaveNr(autoSaveNr);
|
|
|
|
|
|
+ MODEL.setAutoSaveNr(currentSave);
|
|
}
|
|
}
|
|
-
|
|
|
|
- public int getAutoSaveNr(){
|
|
|
|
|
|
+
|
|
|
|
+ public int getAutoSaveNr() {
|
|
return MODEL.getAutoSaveNr();
|
|
return MODEL.getAutoSaveNr();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean allowed() {
|
|
|
|
+ return isAllowed;
|
|
|
|
+ }
|
|
}
|
|
}
|