]> git.zerfleddert.de Git - FreeShisen/blobdiff - src/de/cwde/shisensho/ShisenShoView.java
Fix shit.
[FreeShisen] / src / de / cwde / shisensho / ShisenShoView.java
index 48d16cb64c5c7bbbaec26a468619e28054a9198f..4ff8306aca1868e4dee8e05826545d67ff6084d6 100644 (file)
@@ -11,6 +11,7 @@ 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;
@@ -88,10 +89,17 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
                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++;
                        }
@@ -115,18 +123,18 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
                        }
                };
                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;
        }
@@ -151,9 +159,9 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
 
        private void initializeGame() {
                loadBackground();
-               loadTileset();
                screenWidth=getWidth();
                screenHeight=getHeight();
+               loadTileset();
                //undo.sensitive=false;
                pstate=StatePaint.BOARD;
                app.newPlay();
@@ -168,24 +176,24 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
        }
 
        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() {
@@ -227,9 +235,9 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
 
        private void onUpdateTime() {
                paint(pstate);
-           if (!(app.timeCounter && cstate!=StatePlay.GAMEOVER)) {
-               unregisterTimer();
-           }
+               if (!(app.timeCounter && cstate!=StatePlay.GAMEOVER)) {
+                       unregisterTimer();
+               }
        }
 
        @SuppressWarnings("deprecation")
@@ -475,7 +483,7 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
                                        l+=30;
                                }
                        }
-                       */
+                        */
 
                        // Double buffer dumping
                        // canvas.drawBitmap(buffer, 0, 0, null);
@@ -502,9 +510,9 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
                        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);
@@ -513,8 +521,8 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
                                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);
@@ -662,5 +670,5 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback {
                paint.setColor(Color.parseColor("#006666"));
                paint.setFlags(Paint.ANTI_ALIAS_FLAG);
        }
-*/
+        */
 }
Impressum, Datenschutz