import java.util.Timer;
import java.util.TimerTask;
-import de.cwde.shisensho.R;
-
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Cap;
surfaceHolder.addCallback(this);
}
+ public ShisenShoView(Context ctx) {
+ super((Context)ctx);
+ // silence lint?
+ }
+
private void paint(StatePaint pstate) {
this.pstate=pstate;
repaint();
tileWidth = tileset.getWidth()/tilesetCols;
tileHeight = tileset.getHeight()/tilesetRows;
tile = new Bitmap[tilesetRows*tilesetCols];
+
+ // align to screen
+ Matrix matrix = new Matrix();
+ matrix.setScale(1.0f, 1.0f); // FIXME!
+
+ // TODO: go on.
+
int k=0;
for (int i=0; i<tilesetRows; i++) {
for (int j=0; j<tilesetCols; j++) {
- tile[k] = Bitmap.createBitmap(tileset, j*tileWidth, i*tileHeight, tileWidth, tileHeight, null, false);
+ tile[k] = Bitmap.createBitmap(tileset, j*tileWidth, i*tileHeight, tileWidth, tileHeight, matrix, false);
tile[k].setDensity(Bitmap.DENSITY_NONE);
k++;
}
}
};
timer=new Timer();
- timer.scheduleAtFixedRate(new TimerTask() {
- public void run() {
- timerHandler.sendEmptyMessage(Activity.RESULT_OK);
- }
- }, 0, 1000);
+ timer.scheduleAtFixedRate(new TimerTask() {
+ public void run() {
+ timerHandler.sendEmptyMessage(Activity.RESULT_OK);
+ }
+ }, 0, 1000);
timerRegistered=true;
}
private void unregisterTimer() {
if (timer==null) return; // Already unregistered
timer.cancel();
- timer = null;
+ timer = null;
timerHandler = null;
timerRegistered=false;
}
private void initializeGame() {
loadBackground();
- loadTileset();
screenWidth=getWidth();
screenHeight=getHeight();
+ loadTileset();
//undo.sensitive=false;
pstate=StatePaint.BOARD;
app.newPlay();
}
public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.hint:
- this.postDelayed(new Runnable() { public void run() { onHintActivate(); } }, 100);
- return true;
- case R.id.undo:
- this.postDelayed(new Runnable() { public void run() { onUndoActivate(); } }, 100);
- return true;
- case R.id.clean:
- this.postDelayed(new Runnable() { public void run() { reset(); } }, 100);
- return true;
- case R.id.options:
- return true;
- case R.id.about:
- return true;
- default:
- return false;
- }
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.hint:
+ this.postDelayed(new Runnable() { public void run() { onHintActivate(); } }, 100);
+ return true;
+ case R.id.undo:
+ this.postDelayed(new Runnable() { public void run() { onUndoActivate(); } }, 100);
+ return true;
+ case R.id.clean:
+ this.postDelayed(new Runnable() { public void run() { reset(); } }, 100);
+ return true;
+ case R.id.options:
+ return true;
+ case R.id.about:
+ return true;
+ default:
+ return false;
+ }
}
public void reset() {
private void onUpdateTime() {
paint(pstate);
- if (!(app.timeCounter && cstate!=StatePlay.GAMEOVER)) {
- unregisterTimer();
- }
+ if (!(app.timeCounter && cstate!=StatePlay.GAMEOVER)) {
+ unregisterTimer();
+ }
}
+ @SuppressWarnings("deprecation")
public void drawMessage(Canvas canvas, int x, int y, boolean centered, String message, String color, float textSize) {
Paint paint = new Paint();
paint.setColor(Color.parseColor(color));
l+=30;
}
}
- */
+ */
// Double buffer dumping
// canvas.drawBitmap(buffer, 0, 0, null);
switch (cstate) {
case IDLE:
if (i>=0 &&
- i<app.board.boardSize[0] &&
- j>=0 && j<app.board.boardSize[1] &&
- app.board.board[i][j]!=0) {
+ i<app.board.boardSize[0] &&
+ j>=0 && j<app.board.boardSize[1] &&
+ app.board.board[i][j]!=0) {
selection1[0]=i;
selection1[1]=j;
paint(StatePaint.SELECTED1);
break;
case SELECTED1:
if (i>=0 && i<app.board.boardSize[0] &&
- j>=0 && j<app.board.boardSize[1] &&
- app.board.board[i][j]!=0) {
+ j>=0 && j<app.board.boardSize[1] &&
+ app.board.board[i][j]!=0) {
if (i==selection1[0] && j==selection1[1]) {
paint(StatePaint.BOARD);
control(StatePlay.IDLE);
paint.setColor(Color.parseColor("#006666"));
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
}
-*/
-}
\ No newline at end of file
+ */
+}