[Picross-commit] SF.net SVN: picross:[119] branches/engine_split
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2013-01-15 14:25:12
|
Revision: 119 http://sourceforge.net/p/picross/code/119 Author: yvan_norsa Date: 2013-01-15 14:25:07 +0000 (Tue, 15 Jan 2013) Log Message: ----------- android version Modified Paths: -------------- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java branches/engine_split/android/src/picross/specific/grid/ui/GridController.java branches/engine_split/android/src/picross/specific/grid/ui/GridMediator.java branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java branches/engine_split/common/src/picross/common/grid/ui/AbstractGridMediator.java branches/engine_split/common/src/picross/common/ui/AbstractWaitMenuMediator.java branches/engine_split/common/src/picross/specific/ui/WaitMenuMediator.java branches/engine_split/swing/src/picross/specific/ui/WaitMenuMediator.java Added Paths: ----------- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java Modified: branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -42,6 +42,7 @@ import picross.common.ui.PicrossUI; import picross.engine.PicrossException; import picross.common.game.simple.ui.LevelMenuModel; +import picross.common.game.ui.GameCommand; public final class AndroidLevelMenuMediator extends LevelMenuMediator { private Context context; @@ -51,6 +52,15 @@ this.context = context; } + + @Override + protected GameCommand newSimpleGameCommand(String selectedLevel) { + return new + GameCommand(new + AndroidSimpleGameMediator(this.context, selectedLevel)); + } + + /** {@inheritDoc} */ @Override protected MenuUI initView(PicrossUI ui, MenuController controller) Added: branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -0,0 +1,85 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.specific.game.simple.ui; + +import java.io.IOException; + +import picross.engine.Picross; +import picross.engine.PicrossException; + +import picross.engine.game.simple.XBMModel; + +import picross.specific.game.ui.GameMediator; + +import picross.engine.grid.PicrossGrid; + +import android.content.Context; + +/** + * Mediator for a classic game. + * + * @author Y. Norsa + */ +public final class AndroidSimpleGameMediator extends GameMediator { + /*** Field ***/ + + /** Level to load. */ + private String level; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param levelName name of the level + */ + public AndroidSimpleGameMediator(Context context, String levelName) { + super(context); + + this.level = levelName; + } + + /*** Method overloaded from the class GameMediator ***/ + + /** {@inheritDoc} */ + @Override + protected PicrossGrid initModel() throws PicrossException { + try { + return new XBMModel(Picross.loadDataFile(this.level)); + } catch (IOException ioEx) { + throw new PicrossException(ioEx); + } + } +} + Property changes on: branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidSimpleGameMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: branches/engine_split/android/src/picross/specific/grid/ui/GridController.java =================================================================== --- branches/engine_split/android/src/picross/specific/grid/ui/GridController.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/android/src/picross/specific/grid/ui/GridController.java 2013-01-15 14:25:07 UTC (rev 119) @@ -70,7 +70,6 @@ String cmd = e.getCommandName(); if (cmd.equals(GridCommands.GRID_FILLED_CMD)) { - this.view.rolloverEnded(); this.view.disableGrid(); return; Modified: branches/engine_split/android/src/picross/specific/grid/ui/GridMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/grid/ui/GridMediator.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/android/src/picross/specific/grid/ui/GridMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -49,17 +49,19 @@ public final class GridMediator extends AbstractGridMediator { private Context context; - public GridMediator(Context context, final int width, final int height, boolean[][] data) throws PicrossException { - super(width, height, data); + public GridMediator(Context androidContext, final int width, final int height, boolean[][] data) throws PicrossException { + super(width, height, data, false); - this.context = context; + this.context = androidContext; + + this.doInit(width, height); } @Override protected void initGrid(final int width, final int height, final UIBox[][] boxes, final int[][] colData, final int[][] rowData, final CompletedHints hints, final GridController controller) { //new Thread() { // public void run() { - GridMediator.this.view = new GridUI(width, height, + GridMediator.this.view = new GridUI(this.context, width, height, boxes, colData, rowData, Modified: branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-15 14:25:07 UTC (rev 119) @@ -47,8 +47,18 @@ import picross.engine.grid.GridModel; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Rect; +import android.graphics.Bitmap; +import android.content.Context; +import picross.specific.activities.R; +import android.graphics.Typeface; +import android.graphics.Paint; +import android.graphics.Picture; +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; + /** * Grid UI. * @@ -64,16 +74,14 @@ private static final int LEFT_HINTS = 10; /** Color of the hints text. */ - //private static final Color HINT_TEXT_COLOR = new Color(233, 246, 255); + private static final int HINT_TEXT_COLOR = Color.rgb(233, 246, 255); /** Color of a completed hint text. */ - //private static final Color COMPLETED_HINT_COLOR = new Color(208, 215, 217); + private static final int COMPLETED_HINT_COLOR = Color.rgb(208, 215, 217); /** Font used for the hints. */ - /* - private static final Font HINT_FONT = - new Font("Sans Serif", Font.BOLD, 10); - */ + private static final Typeface HINT_FONT = Typeface.create("Sans Serif", Typeface.BOLD); + /** A box width. */ private static final int BOX_WIDTH = 25; @@ -99,7 +107,7 @@ private static final int HINTS_SPACE = 2; /** Boxes blocks color. */ - //private static final Color BLOCKS_COLOR = new Color(131, 155, 200); + private static final int BLOCKS_COLOR = Color.rgb(131, 155, 200); /** A block width. */ private static final int BLOCK_WIDTH = 5; @@ -107,6 +115,8 @@ /** A block height. */ private static final int BLOCK_HEIGHT = 5; + private static PicrossLogger log = PicrossLogHelper.getLogger(); + /*** Fields ***/ /** Grid width. */ @@ -142,14 +152,11 @@ /** Current state of the grid. */ private transient UIBox[][] boxes; - /** Current rolled-over box. */ - private transient UIBox rollover; - /** Controller attached to this view. */ private transient GridController controller; /** Hint box icon. */ - //private ImageIcon hintBoxIcon; + private Bitmap hintBoxIcon; /** X coordinate of the beginning of a top hints row. */ private int topHintsX; @@ -173,17 +180,13 @@ private int centerHighHintWidth; /** Boxes blocks. */ - //private List<Line2D> blocksLines; + private List<Line2D> blocksLines; /** List of completed hints. */ private transient CompletedHints completedHints; - /** Index of the currently highlighted row. */ - private int rolloverRow = -1; + private Context context; - /** Index of the currently highlighted column. */ - private int rolloverColumn = -1; - /*** Constructor ***/ /** @@ -197,7 +200,7 @@ * @param completedHints list of completed hints * @param controller controller for the grid */ - public GridUI(int width, int height, + public GridUI(Context androidContext, int width, int height, UIBox[][] boxes, int[][] colData, int[][] rowData, @@ -206,6 +209,13 @@ // FIXME //super(true); + GridUI.log.debug("GridUI(" + androidContext + ", " + width + ", " + height + ", boxes, colData, rowData, completedhints, controller)"); + + if (androidContext == null) { + throw new IllegalArgumentException("\"androidContext\" cannot be null"); + } + + this.context = androidContext; this.controller = controller; // FIXME @@ -231,21 +241,22 @@ /*** Method overloaded from JPanel ***/ public void draw(Canvas c) { - /* - Rectangle clipRect = newG.getClipBounds(); + c.drawColor(Color.WHITE); + //Rectangle clipRect = newG.getClipBounds(); + for (int i = 0; i < this.topHints.length; i++) { - if (this.topHints[i].intersects(clipRect)) { - this.drawTopHints(newG, i); - } + //if (this.topHints[i].intersects(clipRect)) { + this.drawTopHints(c, i); + //} } for (int i = 0; i < this.leftHints.length; i++) { - if (this.leftHints[i].intersects(clipRect)) { - this.drawLeftHints(newG, i); - } + //if (this.leftHints[i].intersects(clipRect)) { + this.drawLeftHints(c, i); + //} } - */ + // Paints the boxes for (int i = 0; i < this.width; i++) { for (int j = 0; j < this.height; j++) { @@ -260,13 +271,13 @@ } // Draws the blocks - /* - newG.setColor(GridUI.BLOCKS_COLOR); + Paint paint = new Paint(); + paint.setColor(GridUI.BLOCKS_COLOR); + for (Line2D line : this.blocksLines) { - newG.draw(line); + c.drawLines(line.getPoints(), paint); } - */ } /*** Methods ***/ @@ -277,6 +288,8 @@ * @throws FileNotFoundException if an image is missing */ public void init() throws FileNotFoundException { + GridUI.log.debug("init()"); + // FIXME /* // Computes the size of a hint @@ -292,12 +305,41 @@ textBounds = GridUI.HINT_FONT.getStringBounds(GridUI.LOW_SAMPLE_HINT, frc); int lowHintWidth = (int) textBounds.getWidth(); + */ - this.hintBoxIcon = PicrossUIHelper.getImage(GridUI.HINT_BOX_ICON); + /* + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); + //paint.setStyle(Paint.Style.FILL); + //paint.setColor(color); + paint.setTextAlign(Paint.Align.CENTER); + paint.setTextSize(10); + paint.setTypeface(GridUI.HINT_FONT); + */ + Paint paint = GridUI.getHintPaint(); - int hintBoxWidth = this.hintBoxIcon.getIconWidth(); - int hintBoxHeight = this.hintBoxIcon.getIconHeight(); + Rect textBounds = new Rect(); + // High hint (> 10) + paint.getTextBounds(GridUI.HIGH_SAMPLE_HINT, 0, 2, textBounds); + int hintHeight = (int) textBounds.height(); + int highHintWidth = (int) textBounds.width(); + + GridUI.log.debug("highHintWidth = " + highHintWidth); + + // Low hint + //textBounds = new Rect(); + paint.getTextBounds(GridUI.LOW_SAMPLE_HINT, 0, 1, textBounds); + int lowHintWidth = (int) textBounds.width(); + + GridUI.log.debug("lowHintWidth = " + lowHintWidth); + + // FIXME + //this.hintBoxIcon = PicrossUIHelper.getImage(GridUI.HINT_BOX_ICON); + this.hintBoxIcon = PicrossUIHelper.getImage(this.context.getResources(), R.drawable.hint); + + int hintBoxWidth = this.hintBoxIcon.getWidth(); + int hintBoxHeight = this.hintBoxIcon.getHeight(); + this.leftHintsDecal = hintBoxWidth + GridUI.HINTS_SPACE; this.topHintsDecal = hintBoxHeight + GridUI.HINTS_SPACE; @@ -321,10 +363,20 @@ for (int i = 0; i < this.topHints.length; i++) { this.topHints[i] = new HintBoxInfos(); - this.topHints[i].setRect(new Rectangle(this.leftBoundary + /* + this.topHints[i].setRect(new Rect(this.leftBoundary + (i * GridUI.BOX_WIDTH), 0, GridUI.BOX_WIDTH, this.topBoundary)); + */ + + this.topHints[i].setRect(new Rect(this.leftBoundary + + (i * GridUI.BOX_WIDTH), 0, + this.leftBoundary + + (i * GridUI.BOX_WIDTH) + GridUI.BOX_WIDTH, + this.topBoundary)); + + //GridUI.log.debug("this.topHints[" + i + "].setRect(" + this.topHints[i].getRect() + ")"); } this.leftHints = new HintBoxInfos[this.height]; @@ -332,10 +384,18 @@ for (int i = 0; i < this.leftHints.length; i++) { this.leftHints[i] = new HintBoxInfos(); - this.leftHints[i].setRect(new Rectangle(0, this.topBoundary + /* + this.leftHints[i].setRect(new Rect(0, this.topBoundary + (i * GridUI.BOX_HEIGHT), this.leftBoundary, GridUI.BOX_HEIGHT)); + */ + this.leftHints[i].setRect(new Rect(0, this.topBoundary + + (i * GridUI.BOX_HEIGHT), + this.leftBoundary, +this.topBoundary + + (i * GridUI.BOX_HEIGHT) + + GridUI.BOX_HEIGHT)); } this.topHintsX = this.leftBoundary @@ -348,9 +408,11 @@ (hintBoxHeight / 2) + (hintHeight / 2); this.centerLowHintWidth = (hintBoxWidth / 2) - (lowHintWidth / 2); + GridUI.log.debug("centerLowHintWidth = " + centerLowHintWidth); this.centerHighHintWidth = (hintBoxWidth / 2) - (highHintWidth / 2); - */ + GridUI.log.debug("centerHighHintWidth = " + centerHighHintWidth); + for (int i = 0; i < this.width; i++) { for (int j = 0; j < this.height; j++) { /* @@ -358,6 +420,7 @@ * so we'll be able * to redraw only what is needed */ + /* this.boxes[i][j] .setRect(new Rect(this.leftBoundary + (i * GridUI.BOX_WIDTH), @@ -365,16 +428,30 @@ + (j * GridUI.BOX_WIDTH), GridUI.BOX_WIDTH, GridUI.BOX_HEIGHT)); + */ + this.boxes[i][j] + .setRect(new Rect(this.leftBoundary + + (i * GridUI.BOX_WIDTH), + this.topBoundary + + (j * GridUI.BOX_WIDTH), + +this.leftBoundary + + (i * GridUI.BOX_WIDTH)+ + + GridUI.BOX_WIDTH, + + this.topBoundary + + (j * GridUI.BOX_WIDTH)+ + GridUI.BOX_HEIGHT)); } } - // FIXME - /* this.initBlocks(); this.initTopHints((GridUI.BOX_WIDTH / 2) - (hintBoxWidth / 2)); this.initLeftHints((GridUI.BOX_HEIGHT / 2) - (hintBoxHeight / 2)); - + // FIXME + /* this.setPreferredSize(new Dimension(this.rightBoundary + GridUI.RIGHT_SPACE, this.bottomBoundary @@ -384,23 +461,21 @@ /** Precomputes the blocks lines. */ private void initBlocks() { - // FIXME - /* this.blocksLines = new ArrayList<Line2D>(); - this.blocksLines.add(new Line2D.Double(this.leftBoundary, + this.blocksLines.add(new Line2D(this.leftBoundary, this.topBoundary, this.leftBoundary, this.bottomBoundary)); - this.blocksLines.add(new Line2D.Double(this.leftBoundary, + this.blocksLines.add(new Line2D(this.leftBoundary, this.topBoundary, this.rightBoundary, this.topBoundary)); - this.blocksLines.add(new Line2D.Double(this.rightBoundary, + this.blocksLines.add(new Line2D(this.rightBoundary, this.bottomBoundary, this.leftBoundary, this.bottomBoundary)); - this.blocksLines.add(new Line2D.Double(this.rightBoundary, + this.blocksLines.add(new Line2D(this.rightBoundary, this.bottomBoundary, this.rightBoundary, this.topBoundary)); @@ -412,7 +487,7 @@ int currentY = this.topBoundary + boxHeight; while ((i + GridUI.BLOCK_HEIGHT) <= this.height) { - this.blocksLines.add(new Line2D.Double(this.leftBoundary, + this.blocksLines.add(new Line2D(this.leftBoundary, currentY, this.rightBoundary, currentY)); @@ -425,7 +500,7 @@ int currentX = this.leftBoundary + boxWidth; while ((i + GridUI.BLOCK_WIDTH) <= this.width) { - this.blocksLines.add(new Line2D.Double(currentX, + this.blocksLines.add(new Line2D(currentX, this.topBoundary, currentX, this.bottomBoundary)); @@ -433,7 +508,7 @@ currentX += boxWidth; i += GridUI.BLOCK_WIDTH; } - */ + } /** @@ -443,29 +518,47 @@ */ private void initTopHints(int topHintsStart) { // FIXME - /* for (int k = 0; k < this.topHints.length; k++) { + /* this.topHints[k].setBox( new BufferedImage(GridUI.BOX_WIDTH, this.topBoundary, BufferedImage.TYPE_INT_RGB)); + */ + //Bitmap b = Bitmap.createBitmap(GridUI.BOX_WIDTH, this.topBoundary, Bitmap.Config.ARGB_8888); + Picture b = new Picture(); + //this.topHints[k].setBox(b); - Graphics2D g2d = this.topHints[k].createBoxGraphics(); - g2d.setColor(Color.WHITE); + //Canvas g2d = this.topHints[k].createBoxGraphics(); + Canvas g2d = b.beginRecording(GridUI.BOX_WIDTH, this.topBoundary); + //g2d.drawColor(Color.WHITE); + /* g2d.fillRect(0, 0, this.topHints[k].getWidth(), this.topHints[k].getHeight()); + */ + Paint paint = new Paint(); + paint.setStyle(Paint.Style.FILL); + paint.setColor(Color.WHITE); + g2d.drawRect(new Rect(0, 0, + this.topHints[k].getWidth(), + this.topHints[k].getHeight()), paint); int y = 0; // Column hints are in reverse order for (int i = (this.colData[0].length - 1); i >= 0; i--) { if (this.colData[k][i] != GridModel.EMPTY_HINT) { - this.hintBoxIcon.paintIcon(this, g2d, topHintsStart, y); + //this.hintBoxIcon.paintIcon(this, g2d, topHintsStart, y); + g2d.drawBitmap(this.hintBoxIcon, topHintsStart, y, null); } y += this.topHintsDecal; } - }*/ + + b.endRecording(); + + this.topHints[k].setBox(b); + } } /** @@ -474,29 +567,40 @@ * @param leftHintsStart coordinate where the boxes begin */ private void initLeftHints(int leftHintsStart) { - // FIXME - /* for (int k = 0; k < this.leftHints.length; k++) { + /* this.leftHints[k].setBox( new BufferedImage(this.leftBoundary, GridUI.BOX_HEIGHT, BufferedImage.TYPE_INT_RGB)); + */ + Picture b = new Picture(); + Canvas g2d = b.beginRecording(this.leftBoundary, GridUI.BOX_HEIGHT); - Graphics2D g2d = this.leftHints[k].createBoxGraphics(); - g2d.setColor(Color.WHITE); - g2d.fillRect(0, 0, + //Graphics2D g2d = this.leftHints[k].createBoxGraphics(); + //g2d.setColor(Color.WHITE); + Paint paint = new Paint(); + paint.setStyle(Paint.Style.FILL); + paint.setColor(Color.WHITE); + + g2d.drawRect(new Rect(0, 0, this.leftHints[k].getWidth(), - this.leftHints[k].getHeight()); + this.leftHints[k].getHeight()), paint); int x = 0; for (int j = 0; j < this.rowData[k].length; j++) { if (this.rowData[k][j] != GridModel.EMPTY_HINT) { - this.hintBoxIcon.paintIcon(this, g2d, x, leftHintsStart); + //this.hintBoxIcon.paintIcon(this, g2d, x, leftHintsStart); + g2d.drawBitmap(this.hintBoxIcon, x, leftHintsStart, null); } x += this.leftHintsDecal; } - }*/ + + b.endRecording(); + + this.leftHints[k].setBox(b); + } } /** @@ -504,57 +608,61 @@ * * @param g the graphics context */ - // FIXME - /* - private void drawTopHints(Graphics g, int col) { + private void drawTopHints(Canvas c, int col) { + /* g.drawImage(this.topHints[col].getBox(), this.topHints[col].getX(), this.topHints[col].getY(), null); + */ - g.setFont(GridUI.HINT_FONT); + //this.topHints[col].getBox().draw(c); + c.drawPicture(this.topHints[col].getBox(), this.topHints[col].getRect()); + // FIXME + //g.setFont(GridUI.HINT_FONT); + int x = this.topHintsX + (col * GridUI.BOX_WIDTH); int y = 0; for (int i = this.colData[0].length - 1; i >= 0; i--) { if (this.colData[col][i] != GridModel.EMPTY_HINT) { - this.drawHint(g, this.colData[col][i], x, y, - this.completedHints.isColHintComplete(col, i), - (this.rolloverColumn == col)); + this.drawHint(c, this.colData[col][i], x, y, + this.completedHints.isColHintComplete(col, i)); } y += this.topHintsDecal; - } + } } - */ + /** * Draws the left hints. * * @param g the graphics context */ - // FIXME - /* - private void drawLeftHints(Graphics g, int row) { + private void drawLeftHints(Canvas c, int row) { + /* g.drawImage(this.leftHints[row].getBox(), this.leftHints[row].getX(), this.leftHints[row].getY(), null); + */ + c.drawPicture(this.leftHints[row].getBox(), this.leftHints[row].getRect()); - g.setFont(GridUI.HINT_FONT); + //FIXME + //g.setFont(GridUI.HINT_FONT); int y = this.leftHintsY + (row * GridUI.BOX_HEIGHT); int x = 0; for (int j = 0; j < this.rowData[row].length; j++) { if (this.rowData[row][j] != GridModel.EMPTY_HINT) { - this.drawHint(g, this.rowData[row][j], x, y, - this.completedHints.isRowHintComplete(row, j), - (this.rolloverRow == row)); + this.drawHint(c, this.rowData[row][j], x, y, + this.completedHints.isRowHintComplete(row, j)); } x += this.leftHintsDecal; } } - */ + /** * Draws a hint. * @@ -563,35 +671,43 @@ * @param x X coordinate * @param y Y coordinate */ - // FIXME - /* - private void drawHint(Graphics g, int value, int x, int y, - boolean complete, boolean rollover) { - if (!rollover) { + private void drawHint(Canvas c, int value, int x, int y, + boolean complete) { + //GridUI.log.debug("drawHint(c, " + value + ", " + x + ", " + y + ", " + complete + ")"); + + //Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); + Paint paint = GridUI.getHintPaint(); + if (complete) { - g.setColor(GridUI.COMPLETED_HINT_COLOR); + paint.setColor(GridUI.COMPLETED_HINT_COLOR); } else { - g.setColor(GridUI.HINT_TEXT_COLOR); + paint.setColor(GridUI.HINT_TEXT_COLOR); } - } else { - if (complete) { - g.setColor(new Color(255, 122, 0)); - } else { - g.setColor(Color.ORANGE); - } - } - + /* + paint.setTypeface(GridUI.HINT_FONT); + paint.setTextAlign(Paint.Align.CENTER); +paint.setTextSize(10); + */ y += this.centerHintHeight; if (value < 10) { x += this.centerLowHintWidth; - g.drawString(String.valueOf(value), x, y); + c.drawText(String.valueOf(value), x, y, paint); } else { x += this.centerHighHintWidth; - g.drawString(String.valueOf(value), x, y); + c.drawText(String.valueOf(value), x, y, paint); } } - */ + + private static Paint getHintPaint() { + Paint paint = new Paint(/*Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG*/); + paint.setTypeface(GridUI.HINT_FONT); + paint.setTextAlign(Paint.Align.CENTER); + paint.setTextSize(10); + + return paint; + } + /** * This methods tells wether a point is inside the grid or not. * @@ -657,72 +773,6 @@ //this.repaint(this.boxes[column][row].getRect()); } - /** - * Allows to set the current rolled-over box. - * - * @param row row of the box - * @param column column of the box - */ - void setRollover(int row, int column) { - /* - this.rolloverEnded(); - this.rollover = this.boxes[column][row]; - this.repaint(this.rollover.getRect()); - - this.rolloverHighlight(row, column); - */ - } - /** - * Sets the currently highlighted row and column. - * - * @param row row's index to highlight - * @param column column's index to highlight - */ - void rolloverHighlight(int row, int column) { - /* - if ((this.rolloverColumn != column) || (this.rolloverRow != row)) { - this.repaintColHints(this.rolloverColumn); - this.repaintRowHints(this.rolloverRow); - - this.rolloverColumn = column; - this.rolloverRow = row; - - this.repaintColHints(this.rolloverColumn); - this.repaintRowHints(this.rolloverRow); - } - */ - } - /** Indicates that no box is currently rolled over. */ - - void rolloverEnded() { - /* - if (this.rollover != null) { - */ - /* - * Save the old rolled-over box so we can draw it - * in its initial state - */ - /* - Rectangle rect = this.rollover.getRect(); - - this.rollover = null; - this.repaint(rect); - } - - this.highlightEnded(); - */ - } - - /** Ends the highlight. */ - void highlightEnded() { - /* - this.repaintColHints(this.rolloverColumn); - this.repaintRowHints(this.rolloverRow); - - this.rolloverColumn = -1; - this.rolloverRow = -1; - */ - } /** Repaints top hints. */ void repaintColHints(int col) { // FIXME @@ -750,4 +800,22 @@ public void updateBox(int row, int col, Box box) { this.boxes[row][col].updateState(box); } + + private static class Line2D { + private int x1; + private int y1; + private int x2; + private int y2; + + private Line2D(int x1, int y1, int x2, int y2) { + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + } + + private float[] getPoints() { + return new float[] {this.x1, this.y1, this.x2, this.y2}; + } + } } Modified: branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java =================================================================== --- branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java 2013-01-15 14:25:07 UTC (rev 119) @@ -33,6 +33,10 @@ package picross.specific.grid.ui; +import android.graphics.Rect; +import android.graphics.Canvas; +import android.graphics.Picture; + /** * Informations about a hint box. * @@ -42,10 +46,11 @@ /*** Field ***/ /** The rectangle taken by the box. */ - //private Rectangle rect = null; + private Rect rect = null; /** Pre-rendered image of the box. */ //private BufferedImage box = null; + private Picture box = null; /*** Methods ***/ @@ -55,8 +60,7 @@ * @param rectangle the rectangle to test * @return boolean indicating wether the two rectangles intersect * with each other - *//* - boolean intersects(Rectangle rectangle) { + *//* boolean intersects(Rectangle rectangle) { return this.rect.intersects(rectangle); }*/ @@ -65,46 +69,47 @@ * to the box. * * @return graphical object corresponding to the box - *//* - Graphics2D createBoxGraphics() { - return this.box.createGraphics(); - }*/ - + */ + /* + Canvas createBoxGraphics() { + return new Canvas(this.box); + } + */ /** * Returns the rectangle's width. * * @return width of the box's rectangle - *//* + */ int getWidth() { - return this.rect.width; - }*/ + return this.rect.width(); + } /** * Returns the rectangle's height. * * @return height of the box's rectangle - *//* + */ int getHeight() { - return this.rect.height; - }*/ + return this.rect.height(); + } /** * Return the rectangle's X coordinate. * * @return X coordinate for the rectangle - *//* + */ int getX() { - return this.rect.x; - }*/ + return this.rect.left; + } /** * Return the rectangle's Y coordinate. * * @return Y coordinate for the rectangle - *//* + */ int getY() { - return this.rect.y; - }*/ + return this.rect.top; + } /*** Accessors ***/ @@ -112,36 +117,36 @@ * Sets the rectangle occupied by the box. * * @param newRect the box's rectangle - *//* - void setRect(Rectangle newRect) { + */ + void setRect(Rect newRect) { this.rect = newRect; - }*/ + } /** * Sets the box's image. * * @param newBox pre-rendered image of the box - *//* - void setBox(BufferedImage newBox) { + */ + void setBox(Picture newBox) { this.box = newBox; - }*/ + } /** * Return the box. * * @return the rectangle occupied by the box - *//* - Rectangle getRect() { + */ + Rect getRect() { return this.rect; - }*/ + } /** * Return the box's image. * * @return pre-rendered image of the box - *//* - BufferedImage getBox() { + */ + Picture getBox() { return this.box; - }*/ + } } Modified: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -111,9 +111,12 @@ if (cmd.equals(LevelMenuController.LEVEL_CMD)) { String level = e.getComment(); + /* this.fireEventPerformed(new GameCommand(new SimpleGameMediator(level))); + */ + this.fireEventPerformed(this.newSimpleGameCommand(level)); return; } @@ -126,6 +129,12 @@ super.eventPerformed(e); } + protected GameCommand newSimpleGameCommand(String selectedLevel) { + return new + GameCommand(new + SimpleGameMediator(selectedLevel)); + } + /*** Method ***/ /** Modified: branches/engine_split/common/src/picross/common/grid/ui/AbstractGridMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/grid/ui/AbstractGridMediator.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/common/src/picross/common/grid/ui/AbstractGridMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -81,11 +81,23 @@ * @param data grid content * @throws PicrossException if there is a probleme while building the view */ - public AbstractGridMediator(final int width, final int height, boolean[][] data) + public AbstractGridMediator(int width, int height, boolean[][] data) throws PicrossException { + this(width, height, data, true); + } + + public AbstractGridMediator(int width, int height, boolean[][] data, boolean doInit) + throws PicrossException { + this.model = new GridModel(/*this, */data); + if (doInit) { + this.doInit(width, height); + } + } + + protected void doInit(final int width, final int height) throws PicrossException { final GridController controller = new GridController(); controller.addSimpleListener(this); this.addSimpleListener(controller); @@ -117,7 +129,8 @@ controller.setView(this.view); } - protected void initGrid(int width, int height, UIBox[][] boxes, int[][] colData, int[][] rowData, CompletedHints hints, GridController controller) { + protected abstract void initGrid(int width, int height, UIBox[][] boxes, int[][] colData, int[][] rowData, CompletedHints hints, GridController controller); + /* this.view = new GridUI(width, height, boxes, colData, @@ -125,6 +138,7 @@ hints, controller); } + */ /*** Method overloaded from the class Mediateur ***/ Modified: branches/engine_split/common/src/picross/common/ui/AbstractWaitMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/ui/AbstractWaitMenuMediator.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/common/src/picross/common/ui/AbstractWaitMenuMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -46,11 +46,13 @@ /*** Method overriden from MenuMediator ***/ /** {@inheritDoc} */ + /* @Override protected MenuUI initView(PicrossUI ui, MenuController controller) throws PicrossException { return new WaitMenuUI(); } + */ } Modified: branches/engine_split/common/src/picross/specific/ui/WaitMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/specific/ui/WaitMenuMediator.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/common/src/picross/specific/ui/WaitMenuMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -35,4 +35,4 @@ import picross.common.ui.AbstractWaitMenuMediator; -public final class WaitMenuMediator extends AbstractWaitMenuMediator { } +public abstract class WaitMenuMediator extends AbstractWaitMenuMediator { } Modified: branches/engine_split/swing/src/picross/specific/ui/WaitMenuMediator.java =================================================================== --- branches/engine_split/swing/src/picross/specific/ui/WaitMenuMediator.java 2013-01-15 09:23:58 UTC (rev 118) +++ branches/engine_split/swing/src/picross/specific/ui/WaitMenuMediator.java 2013-01-15 14:25:07 UTC (rev 119) @@ -35,4 +35,18 @@ import picross.common.ui.AbstractWaitMenuMediator; -public final class WaitMenuMediator extends AbstractWaitMenuMediator { } +import picross.engine.PicrossException; + +import picross.specific.ui.MenuController; +import picross.specific.ui.MenuUI; +import picross.specific.ui.WaitMenuUI; +import picross.common.ui.PicrossUI; + +public final class WaitMenuMediator extends AbstractWaitMenuMediator { + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + return new WaitMenuUI(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |