Let's clone that helper from DropBoard & let it help.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@983 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -137,7 +137,7 @@ public abstract class DropBoardView extends PuzzleBoardView
|
|||||||
*/
|
*/
|
||||||
public void createPiece (int piece, int sx, int sy)
|
public void createPiece (int piece, int sx, int sy)
|
||||||
{
|
{
|
||||||
if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) {
|
if (!inBounds(sx, sy)) {
|
||||||
log.warning("Requested to create piece in invalid location", "sx", sx, "sy", sy,
|
log.warning("Requested to create piece in invalid location", "sx", sx, "sy", sy,
|
||||||
new Exception());
|
new Exception());
|
||||||
return;
|
return;
|
||||||
@@ -164,7 +164,7 @@ public abstract class DropBoardView extends PuzzleBoardView
|
|||||||
*/
|
*/
|
||||||
public void updatePiece (int piece, int sx, int sy)
|
public void updatePiece (int piece, int sx, int sy)
|
||||||
{
|
{
|
||||||
if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) {
|
if (!inBounds(sx, sy)) {
|
||||||
log.warning("Requested to update piece in invalid location",
|
log.warning("Requested to update piece in invalid location",
|
||||||
"sx", sx, "sy", sy, new Exception());
|
"sx", sx, "sy", sy, new Exception());
|
||||||
return;
|
return;
|
||||||
@@ -182,7 +182,7 @@ public abstract class DropBoardView extends PuzzleBoardView
|
|||||||
*/
|
*/
|
||||||
public void createPiece (int piece, int sx, int sy, int tx, int ty, long duration)
|
public void createPiece (int piece, int sx, int sy, int tx, int ty, long duration)
|
||||||
{
|
{
|
||||||
if (tx < 0 || ty < 0 || tx >= _bwid || ty >= _bhei) {
|
if (!inBounds(tx, ty)) {
|
||||||
log.warning("Requested to create and move piece to invalid location",
|
log.warning("Requested to create and move piece to invalid location",
|
||||||
"tx", tx, "ty", ty, new Exception());
|
"tx", tx, "ty", ty, new Exception());
|
||||||
return;
|
return;
|
||||||
@@ -512,6 +512,15 @@ public abstract class DropBoardView extends PuzzleBoardView
|
|||||||
return new Dimension(wid, hei);
|
return new Dimension(wid, hei);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the specified coordinate is within the bounds of the board, false if it is
|
||||||
|
* not.
|
||||||
|
*/
|
||||||
|
public boolean inBounds (int col, int row)
|
||||||
|
{
|
||||||
|
return (col >= 0 && row >= 0 && col < getWidth() && row < getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the row of rising pieces to the given graphics context. Sub-classes that make use
|
* Renders the row of rising pieces to the given graphics context. Sub-classes that make use
|
||||||
* of board rising functionality should override this method to draw the rising piece row.
|
* of board rising functionality should override this method to draw the rising piece row.
|
||||||
|
|||||||
Reference in New Issue
Block a user