Merge remote-tracking branch 'origin/master'
# Conflicts: # app/src/main/AndroidManifest.xml
This commit is contained in:
commit
74b1b0bbdd
5 changed files with 64 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="tu_darmstadt.sudoku.view" >
|
||||
package="tu_darmstadt.sudoku.ui.view" >
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -8,7 +8,7 @@
|
|||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity android:name=".MainActivity" >
|
||||
<activity android:name="tu_darmstadt.sudoku.ui.MainActivity" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@ -16,19 +16,17 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:name="tu_darmstadt.sudoku.ui.SettingsActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:parentActivityName=".MainActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="tu_darmstadt.sudoku.view.MainActivity" />
|
||||
android:parentActivityName="tu_darmstadt.sudoku.ui.MainActivity">
|
||||
</activity>
|
||||
<activity
|
||||
android:screenOrientation="portrait"
|
||||
android:name=".GameActivity"
|
||||
android:label="@string/title_activity_game_view"
|
||||
android:theme="@style/AppTheme.NoActionBar" >
|
||||
|
||||
</activity>
|
||||
<activity android:name="tu_darmstadt.sudoku.ui.AboutActivity" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
|
|
@ -63,9 +63,13 @@ public class GameController {
|
|||
this.sectionHeight = sectionHeight;
|
||||
this.sectionWidth = sectionWidth;
|
||||
this.gameField = new GameField(size, sectionHeight, sectionWidth);
|
||||
|
||||
if(fixedValues == null) throw new IllegalArgumentException("fixedValues may not be null.");
|
||||
|
||||
gameField.initCells(fixedValues);
|
||||
|
||||
// now set the values that are not fixed
|
||||
if (setValues != null) {
|
||||
for (int i = 0; i < size * size; i++) {
|
||||
int row = (int) Math.floor(i / size);
|
||||
int col = i % size;
|
||||
|
@ -73,6 +77,12 @@ public class GameController {
|
|||
}
|
||||
}
|
||||
|
||||
if(setNotes != null) {
|
||||
// set notes.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setSettings(SharedPreferences pref) {
|
||||
settings = pref;
|
||||
}
|
||||
|
@ -240,13 +250,36 @@ public class GameController {
|
|||
return gameField.toString();
|
||||
}
|
||||
|
||||
public int getSelectedRow() {
|
||||
return selectedRow;
|
||||
}
|
||||
|
||||
public int getSelectedCol() {
|
||||
return selectedCol;
|
||||
}
|
||||
|
||||
public void selectCell(int row, int col) {
|
||||
this.selectedRow = row;
|
||||
this.selectedCol = col;
|
||||
if(selectedRow == row && selectedCol == col) {
|
||||
// if we select the same field 2ce -> deselect it
|
||||
selectedRow = -1;
|
||||
selectedCol = -1;
|
||||
} else {
|
||||
// else we set it to the new selected field
|
||||
selectedRow = row;
|
||||
selectedCol = col;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedValue(int value) {
|
||||
setValue(selectedRow, selectedCol, value);
|
||||
if(selectedRow != -1 && selectedCol != -1) setValue(selectedRow, selectedCol, value);
|
||||
}
|
||||
|
||||
public void deleteSelectedValue() {
|
||||
if(selectedRow != -1 && selectedCol != -1) setValue(selectedRow, selectedCol, 0);
|
||||
}
|
||||
|
||||
public void toggleSelectedNote(int value) {
|
||||
if(selectedRow != -1 && selectedCol != -1) toggleNote(selectedRow, selectedCol, value);
|
||||
}
|
||||
|
||||
// public void registerListener(IModelChangeListener l) {
|
||||
|
|
|
@ -51,14 +51,16 @@ public class GameField implements Cloneable {
|
|||
{ 7, 0, 0, 0, 1, 0, 3, 0, 5 }};
|
||||
|
||||
// Initit the game field
|
||||
int[] oneDimension = new int[size*size];
|
||||
for(int i = 0; i < size; i++) {
|
||||
for(int j = 0; j < size; j++) {
|
||||
field[i][j] = new GameCell(i,j,size,placeholder[i][j]);
|
||||
oneDimension[i*size+j] = placeholder[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void initCells(int[] level) {
|
||||
int count = 0;
|
||||
if(level.length != size*size) {
|
||||
throw new IllegalArgumentException("Levelarray must have length of "+size*size+".");
|
||||
}
|
||||
|
@ -66,8 +68,10 @@ public class GameField implements Cloneable {
|
|||
for(int i = 0; i < size*size; i++) {
|
||||
int row = (int)Math.floor(i/size);
|
||||
int col = i%size;
|
||||
if(level[i] != 0) count++;
|
||||
field[row][col] = new GameCell(row,col,size,level[i]);
|
||||
}
|
||||
if(count < 17) throw new IllegalArgumentException("There must be at least 17 fixed values.");
|
||||
}
|
||||
|
||||
public GameCell getCell(int row, int col) {
|
||||
|
|
|
@ -53,12 +53,22 @@ public class SudokuFieldLayout extends RelativeLayout {
|
|||
int row = scv.getRow();
|
||||
int col = scv.getCol();
|
||||
|
||||
gameController.selectCell(row, col);
|
||||
row = gameController.getSelectedRow();
|
||||
col = gameController.getSelectedCol();
|
||||
|
||||
// Reset everything
|
||||
for(int i = 0; i < gameController.getSize(); i++) {
|
||||
for(int j = 0; j < gameController.getSize(); j++) {
|
||||
gamecells[i][j].setHighlightType(CellHighlightTypes.Default);
|
||||
}
|
||||
}
|
||||
|
||||
if(row == -1 || col == -1) {
|
||||
// we clicked on the same cell 2 times.
|
||||
// means it got deselected and we dont highlight any cells.
|
||||
return false;
|
||||
}
|
||||
// Set connected Fields
|
||||
|
||||
//String syncConnPref = sharedPref.getString(SettingsActivity., "");
|
||||
|
@ -70,7 +80,6 @@ public class SudokuFieldLayout extends RelativeLayout {
|
|||
gamecells[c.getRow()][c.getCol()].setHighlightType(CellHighlightTypes.Connected);
|
||||
}
|
||||
// Select touched Cell
|
||||
gameController.selectCell(row, col);
|
||||
scv.setHighlightType(CellHighlightTypes.Selected);
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ public class SolverTest {
|
|||
{ 0, 0, 0, 0, 7, 0, 4, 0, 9 },
|
||||
{ 6, 4, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 7, 0, 0, 0, 1, 0, 3, 0, 5 }};
|
||||
|
||||
controller.loadLevel(9,3,3,new int[]{0,0,0,0,4,1,0,0,0,0,6,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,3,2,0,6,0,0,0,0,0,0,0,0,0,5,0,0,4,1,7,0,0,0,0,0,0,0,0,0,0,0,2,0,0,3,0,0,0,4,8,0,0,0,0,0,0,5,0,1,0,0,0,0,0,0},null,null);
|
||||
}
|
||||
|
||||
//000041000060000200000000000320600000000050041700000000000200300048000000501000000
|
||||
|
|
Loading…
Reference in a new issue