edit the notes location in a cell to an dynamic one added rotation for the drawable pen in note button Blue TU Theme should now be finished

This commit is contained in:
Gongxter 2015-12-10 13:37:04 +01:00
parent 3714a321d9
commit 97becd93e5
4 changed files with 30 additions and 29 deletions

View file

@ -344,7 +344,9 @@ public class GameController implements IModelChangedListener {
return selectedCol;
}
public int getSelectedValue() {
return selectedValue;
if(isValidCellSelected()){
return getValue(getSelectedRow(),getSelectedCol()); //selectedValue;
} else return 0;
}
public void selectCell(int row, int col) {

View file

@ -25,6 +25,7 @@ public class SudokuCellView extends View {
int mSectionWidth;
int mRow;
int mCol;
int size;
boolean selected;
CellHighlightTypes highlightType = CellHighlightTypes.Default;
Symbol symbolsToUse = Symbol.Default;
@ -42,7 +43,7 @@ public class SudokuCellView extends View {
this.selected = b;
}
public void setValues (int width, int height, int sectionHeight, int sectionWidth, GameCell gameCell) {
public void setValues (int width, int height, int sectionHeight, int sectionWidth, GameCell gameCell,int size) {
mSectionHeight = sectionHeight;
mSectionWidth = sectionWidth;
mGameCell = gameCell;
@ -50,6 +51,7 @@ public class SudokuCellView extends View {
mHeight = height;
mRow = gameCell.getRow();
mCol = gameCell.getCol();
this.size = size;
}
public void setHighlightType(CellHighlightTypes highlightType) {
@ -123,24 +125,24 @@ public class SudokuCellView extends View {
public void drawValue(Canvas canvas) {
Paint p = new Paint();
int j= 3;
int k = 3;
int root = (int) Math.sqrt(size);
int j= root+1;
int k = root;
if(mGameCell.getValue() == 0) {
for (int i = 0; i < mGameCell.getNotes().length; i++) {
if (mGameCell.getNotes()[i]) {
p.setTypeface(Typeface.SANS_SERIF);
p.setTextSize(mWidth / 4);
p.setTextAlign(Paint.Align.RIGHT);
// TODO settings: get SymbolEnum from settings
canvas.drawText(Symbol.getSymbol(symbolsToUse, i),(mWidth*1/12)*k,(mWidth*1/12)*j,p);
canvas.drawText(Symbol.getSymbol(symbolsToUse, i),(mWidth*1/(size+root))*k,(mWidth*1/(size+root+1))*j,p);
/*canvas.drawText(String.valueOf(1), (mWidth * 1 / 12)*3, (mWidth* 1 / 12)*3, p);
canvas.drawText(String.valueOf(2),(mWidth*1/12)*7, (mWidth* 1 / 12)*7,p );
canvas.drawText(String.valueOf(3),(mWidth*1/12)*11, (mWidth* 1 / 12)*11,p );*/
}
k+=4;
if (k > 11) {
k = 3;
j +=4;
k+=root+1;
if (k > (size+root)) {
k = root;
j +=root+1;
}
}
return;

View file

@ -135,7 +135,7 @@ public class SudokuFieldLayout extends RelativeLayout {
for (int i = 0; i < gameController.getSize(); i++) {
for (int j = 0; j < gameController.getSize(); j++) {
gamecells[i][j].setValues(gameCellWidth, gameCellHeight, sectionHeight, sectionWidth, gameController.getGameCell(i, j));
gamecells[i][j].setValues(gameCellWidth, gameCellHeight, sectionHeight, sectionWidth, gameController.getGameCell(i, j),gameController.getSize());
}
}
}

View file

@ -1,29 +1,16 @@
package tu_darmstadt.sudoku.ui.view;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RotateDrawable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.LinkedList;
import tu_darmstadt.sudoku.controller.GameController;
import tu_darmstadt.sudoku.game.GameBoard;
/**
* Created by TMZ_LToP on 17.11.2015.
@ -34,6 +21,8 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size();
GameController gameController;
SudokuKeyboardLayout keyboard;
Bitmap bitMap,bitResult;
Canvas canvas;
OnClickListener listener = new OnClickListener() {
@ -51,21 +40,29 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
break;
case NoteToggle:
//btn.setText(keyboard.notesEnabled ? "ON" : "OFF");
//TODO: add rotation
AnimationSet aniset = new AnimationSet(true);
//Animation rotates whole button
/*AnimationSet aniset = new AnimationSet(true);
aniset.setInterpolator(new DecelerateInterpolator());
aniset.setFillAfter(true);
aniset.setFillEnabled(true);
RotateAnimation rotate = new RotateAnimation(0.0f,(keyboard.notesEnabled ? 90.0f:-90.0f),
RotateAnimation rotate = new RotateAnimation(0.0f,(keyboard.notesEnabled ? 90.0f:0.0f),
RotateAnimation.RELATIVE_TO_SELF,0.5f,
Animation.RELATIVE_TO_SELF,0.5f);
rotate.setDuration(1500);
rotate.setFillAfter(true);
aniset.addAnimation(rotate);
btn.startAnimation(aniset);
btn.startAnimation(aniset);*/
// rotates now only the Drawable
bitMap = BitmapFactory.decodeResource(getResources(), btn.getType().getResID());
bitResult = Bitmap.createBitmap(bitMap.getWidth(), bitMap.getHeight(), Bitmap.Config.ARGB_8888);
canvas = new Canvas(bitResult);
canvas.rotate(keyboard.notesEnabled?0.0f:90.0f,bitMap.getWidth()/2,bitMap.getHeight()/2);
canvas.drawBitmap(bitMap,0,0,null);
btn.setImageBitmap(bitResult);
keyboard.toggleNotesEnabled();
break;
case Do: