12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package holeg.ui.controller;
- import holeg.ui.model.GuiSettings;
- /**
- * Autosave Controller.
- *
- * @author Gruppe14
- */
- public class AutoSaveController {
- private int max = Integer.MAX_VALUE;
- private int numberOfSaves = 20;
- private int currentSave;
- private int count = 0;
- private boolean isAllowed = false;
- /**
- * Increase the Auto save number.
- */
- public void increaseAutoSaveNr() {
- currentSave = GuiSettings.autoSaveNr + 1;
- if (count < currentSave) {
- count = currentSave;
- }
- if (numberOfSaves == count) {
- isAllowed = true;
- }
- if (currentSave > max) {
- currentSave = 0;
- }
- GuiSettings.autoSaveNr = (currentSave);
- }
- /**
- * Decrease the Autosave Number.
- */
- public void decreaseAutoSaveNr() {
- currentSave = GuiSettings.autoSaveNr - 1;
- // if (currentSave < 0) {
- // currentSave = max;
- // }
- GuiSettings.autoSaveNr = (currentSave);
- }
- /**
- * Return isAllowed.
- *
- * @return isAllowed
- */
- public boolean allowed() {
- return isAllowed;
- }
- }
|