Bugfix. Runnable again.
This commit is contained in:
parent
86581ffd8e
commit
327f9a6c66
6 changed files with 15 additions and 7 deletions
|
@ -34,6 +34,7 @@ public class GameController implements IModelChangedListener {
|
||||||
private int selectedCol;
|
private int selectedCol;
|
||||||
private SharedPreferences settings;
|
private SharedPreferences settings;
|
||||||
private int gameID = 0;
|
private int gameID = 0;
|
||||||
|
private GameDifficulty difficulty;
|
||||||
private CellConflictList errorList = new CellConflictList();
|
private CellConflictList errorList = new CellConflictList();
|
||||||
private int selectedValue;
|
private int selectedValue;
|
||||||
private LinkedList<IGameSolvedListener> solvedListeners = new LinkedList<>();
|
private LinkedList<IGameSolvedListener> solvedListeners = new LinkedList<>();
|
||||||
|
@ -51,9 +52,8 @@ public class GameController implements IModelChangedListener {
|
||||||
|
|
||||||
public GameController(GameType type, SharedPreferences pref) {
|
public GameController(GameType type, SharedPreferences pref) {
|
||||||
setGameType(type);
|
setGameType(type);
|
||||||
gameBoard = new GameBoard(type);
|
|
||||||
gameBoard.registerOnModelChangeListener(this);
|
|
||||||
setSettings(pref);
|
setSettings(pref);
|
||||||
|
gameBoard = new GameBoard(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGameID() {
|
public int getGameID() {
|
||||||
|
@ -112,6 +112,7 @@ public class GameController implements IModelChangedListener {
|
||||||
int[] setValues = gic.getSetValues();
|
int[] setValues = gic.getSetValues();
|
||||||
boolean[][] setNotes = gic.getSetNotes();
|
boolean[][] setNotes = gic.getSetNotes();
|
||||||
this.gameID = gic.getID();
|
this.gameID = gic.getID();
|
||||||
|
this.difficulty = gic.getDifficulty();
|
||||||
|
|
||||||
setGameType(gic.getGameType());
|
setGameType(gic.getGameType());
|
||||||
this.gameBoard = new GameBoard(gic.getGameType());
|
this.gameBoard = new GameBoard(gic.getGameType());
|
||||||
|
@ -142,6 +143,8 @@ public class GameController implements IModelChangedListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gameBoard.registerOnModelChangeListener(this);
|
||||||
|
|
||||||
// call the solve function to get the solution of this board
|
// call the solve function to get the solution of this board
|
||||||
solve();
|
solve();
|
||||||
}
|
}
|
||||||
|
@ -303,6 +306,10 @@ public class GameController implements IModelChangedListener {
|
||||||
return c.getNotes().clone();
|
return c.getNotes().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameDifficulty getDifficulty() {
|
||||||
|
return difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteNote(int row, int col, int value) {
|
public void deleteNote(int row, int col, int value) {
|
||||||
GameCell c = gameBoard.getCell(row,col);
|
GameCell c = gameBoard.getCell(row,col);
|
||||||
c.deleteNote(value);
|
c.deleteNote(value);
|
||||||
|
|
|
@ -117,6 +117,10 @@ public class GameInfoContainer {
|
||||||
return setNotes;
|
return setNotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameDifficulty getDifficulty() {
|
||||||
|
return difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
public int getID() {
|
public int getID() {
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,6 @@ public class GameBoard implements Cloneable {
|
||||||
public void registerOnModelChangeListener(final IModelChangedListener listener) {
|
public void registerOnModelChangeListener(final IModelChangedListener listener) {
|
||||||
if(!modelChangedListeners.contains(listener)) {
|
if(!modelChangedListeners.contains(listener)) {
|
||||||
actionOnCells(new ICellAction<Boolean>() {
|
actionOnCells(new ICellAction<Boolean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean action(GameCell gc, Boolean existing) {
|
public Boolean action(GameCell gc, Boolean existing) {
|
||||||
gc.registerOnModelChangeListener(listener);
|
gc.registerOnModelChangeListener(listener);
|
||||||
|
|
|
@ -27,7 +27,7 @@ public enum GameType {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.sectionHeight = sectionHeight;
|
this.sectionHeight = sectionHeight;
|
||||||
this.sectionWidth = sectionWidth;
|
this.sectionWidth = sectionWidth;
|
||||||
this.resIDString = this.resIDString;
|
this.resIDString = resIDString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<GameType> getValidGameTypes() {
|
public static List<GameType> getValidGameTypes() {
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
int lastChosenDifficulty = settings.getInt("lastChosenDifficulty", 1);
|
int lastChosenDifficulty = settings.getInt("lastChosenDifficulty", 1);
|
||||||
difficultyBar.setProgress(lastChosenDifficulty);
|
difficultyBar.setRating(lastChosenDifficulty);
|
||||||
|
|
||||||
// on first create always check for loadable levels!
|
// on first create always check for loadable levels!
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
|
|
@ -52,8 +52,6 @@
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
tools:context="tu_darmstadt.sudoku.ui.MainActivity"
|
tools:context="tu_darmstadt.sudoku.ui.MainActivity"
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:weightSum="8"
|
android:weightSum="8"
|
||||||
android:divider="#000"
|
android:divider="#000"
|
||||||
|
|
Loading…
Reference in a new issue