AutoSaveController.java 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package holeg.ui.controller;
  2. import holeg.ui.model.GuiSettings;
  3. /**
  4. * Autosave Controller.
  5. *
  6. * @author Gruppe14
  7. */
  8. public class AutoSaveController {
  9. private int max = Integer.MAX_VALUE;
  10. private int numberOfSaves = 20;
  11. private int currentSave;
  12. private int count = 0;
  13. private boolean isAllowed = false;
  14. /**
  15. * Increase the Auto save number.
  16. */
  17. public void increaseAutoSaveNr() {
  18. currentSave = GuiSettings.autoSaveNr + 1;
  19. if (count < currentSave) {
  20. count = currentSave;
  21. }
  22. if (numberOfSaves == count) {
  23. isAllowed = true;
  24. }
  25. if (currentSave > max) {
  26. currentSave = 0;
  27. }
  28. GuiSettings.autoSaveNr = (currentSave);
  29. }
  30. /**
  31. * Decrease the Autosave Number.
  32. */
  33. public void decreaseAutoSaveNr() {
  34. currentSave = GuiSettings.autoSaveNr - 1;
  35. // if (currentSave < 0) {
  36. // currentSave = max;
  37. // }
  38. GuiSettings.autoSaveNr = (currentSave);
  39. }
  40. /**
  41. * Return isAllowed.
  42. *
  43. * @return isAllowed
  44. */
  45. public boolean allowed() {
  46. return isAllowed;
  47. }
  48. }