From 6aacff8e6a673f12e18e9ae0d8b95d020e536655 Mon Sep 17 00:00:00 2001 From: Gongxter Date: Tue, 2 Feb 2016 17:36:10 +0100 Subject: [PATCH] fixed arrowMarker for error dependencies --- .../ui/GameActivity.java | 13 +++++++++ .../ui/view/SudokuFieldLayout.java | 28 +++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java index 479f3fa..f34f6de 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/GameActivity.java @@ -20,6 +20,7 @@ import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Gravity; +import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; @@ -112,6 +113,10 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On setSupportActionBar(toolbar); //toolbar.addView(); + if(gameSolved) { + disableReset(); + } + //Create new GameField layout = (SudokuFieldLayout)findViewById(R.id.sudokuLayout); gameController.registerGameSolvedListener(this); @@ -178,6 +183,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On } gameController.notifyHighlightChangedListeners(); gameController.notifyTimerListener(gameController.getTime()); + } @Override @@ -286,6 +292,7 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On gameController.pauseTimer(); gameController.deleteGame(this); + disableReset(); //Show time hints new plus old best time @@ -342,6 +349,12 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On return h + ":" + m + ":" + s; } + + private void disableReset(){ + NavigationView navView = (NavigationView)findViewById(R.id.nav_view); + Menu navMenu = navView.getMenu(); + navMenu.findItem(R.id.menu_reset).setEnabled(false); + } @Override public void onTick(int time) { diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java index 2b97c6b..c51c7b4 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/ui/view/SudokuFieldLayout.java @@ -221,13 +221,31 @@ public class SudokuFieldLayout extends RelativeLayout implements IHighlightChang int row2 = conflict.getRowCell2(); int col2 = conflict.getColCell2(); - canvas.drawCircle(gameCellWidth * col2 + gameCellWidth / 2, gameCellHeight * row2 + gameCellHeight / 2, gameCellWidth/2 - gameCellWidth / 8, p); + canvas.drawCircle(gameCellWidth * col2 + gameCellWidth / 2, gameCellHeight * row2 + gameCellHeight / 2, gameCellWidth / 2 - gameCellWidth / 8, p); + + float offset1=0; + float offset2= 0; + + float radius = gameCellWidth/2 - gameCellWidth / 8; + if (col == col2 || row == row2) { + offset1 = (col > col2)? 0-radius:radius; + offset2 = (row > row2)? 0-radius:radius; + offset1 = (col == col2)?0f:offset1; + offset2 = (row == row2)?0f:offset2; + } else { + double alpha = Math.atan((Math.abs(col2-col))/(Math.abs(row2 - row))); + offset1 = (col > col2)? 0-radius:radius; + offset2 = (row > row2)? 0-radius:radius; + offset1*=Math.sin(alpha); + offset2*=Math.cos(alpha); + } + canvas.drawLine( - gameCellWidth * col + gameCellWidth / 2, - gameCellHeight * row + gameCellHeight / 2, - gameCellWidth * col2 + gameCellWidth / 2, - gameCellHeight * row2 + gameCellHeight / 2, p); + (gameCellWidth * col + gameCellWidth / 2)+offset1, + (gameCellHeight * row + gameCellHeight / 2)+offset2, + (gameCellWidth * col2 + gameCellWidth / 2)-offset1, + (gameCellHeight * row2 + gameCellHeight / 2)-offset2, p); } } }