# HG changeset patch # User Jens Alfke # Date 1217559686 25200 # Node ID db8640a38fafdf36373ab1a77d6542db068aa9a9 # Parent efe5d4523a23f695bb6232b6f5fdc8abc5806040 * Put the spots in the right place in 13x13 and 19x19 boards. * Fixed some front/back layering issues in Grid. diff -r efe5d4523a23 -r db8640a38faf Source/BoardView.m --- a/Source/BoardView.m Thu Jul 31 13:23:44 2008 -0700 +++ b/Source/BoardView.m Thu Jul 31 20:01:26 2008 -0700 @@ -113,6 +113,7 @@ _table.autoresizingMask = kCALayerMinXMargin | kCALayerMaxXMargin | kCALayerMinYMargin | kCALayerMaxYMargin; // Tell the game to set up the board: + _game.tablePerspectiveAngle = _perspective; _game.table = _table; [self.layer addSublayer: _table]; diff -r efe5d4523a23 -r db8640a38faf Source/GoGame.m --- a/Source/GoGame.m Thu Jul 31 13:23:44 2008 -0700 +++ b/Source/GoGame.m Thu Jul 31 20:01:26 2008 -0700 @@ -34,6 +34,14 @@ + (int) dimensions {return 19;} ++ (const GridCoord*) spotCoords +{ + static GridCoord const sSpots[10]={ { 3,3}, { 3,9}, { 3,15}, + { 9,3}, { 9,9}, { 9,15}, + {15,3}, {15,9}, {15,15}, {NSNotFound,NSNotFound} }; + return sSpots; +} + - (id) init { self = [super init]; @@ -63,12 +71,11 @@ */ board.lineColor = kTranslucentGrayColor; board.cellClass = [GoSquare class]; + board.usesDiagonals = board.allowsMoves = board.allowsCaptures = NO; [board addAllCells]; - ((GoSquare*)[board cellAtRow: 2 column: 2]).dotted = YES; - ((GoSquare*)[board cellAtRow: 6 column: 6]).dotted = YES; - ((GoSquare*)[board cellAtRow: 2 column: 6]).dotted = YES; - ((GoSquare*)[board cellAtRow: 6 column: 2]).dotted = YES; - board.usesDiagonals = board.allowsMoves = board.allowsCaptures = NO; + const GridCoord *spots = [[self class] spotCoords]; + for( int i=0; spots[i].row!=NSNotFound; i++ ) + ((GoSquare*)[board cellAtRow: spots[i].row column: spots[i].col]).dotted = YES; [_table addSublayer: board]; [board release]; @@ -261,10 +268,21 @@ @implementation Go9Game + (NSString*) displayName {return @"Go (9x9)";} + (int) dimensions {return 9;} ++ (const GridCoord*) spotCoords +{ + static GridCoord const sSpots[6]= { {2,2}, {2,6}, {4,4}, {6,2}, {6,6}, {NSNotFound,NSNotFound} }; + return sSpots; +} @end @implementation Go13Game + (NSString*) displayName {return @"Go (13x13)";} + (int) dimensions {return 13;} ++ (const GridCoord*) spotCoords +{ + static GridCoord const sSpots[6] = { { 2,2}, { 2,10}, {6,6}, + {10,2}, {10,10}, {NSNotFound,NSNotFound} }; + return sSpots; +} @end diff -r efe5d4523a23 -r db8640a38faf Source/Grid.h --- a/Source/Grid.h Thu Jul 31 13:23:44 2008 -0700 +++ b/Source/Grid.h Thu Jul 31 20:01:26 2008 -0700 @@ -24,6 +24,11 @@ @class GridCell; +typedef struct { + unsigned col, row; +} GridCoord; + + /** Abstract superclass of regular geometric grids of GridCells that Bits can be placed on. */ @interface Grid : GGBLayer { diff -r efe5d4523a23 -r db8640a38faf Source/Grid.m --- a/Source/Grid.m Thu Jul 31 13:23:44 2008 -0700 +++ b/Source/Grid.m Thu Jul 31 20:01:26 2008 -0700 @@ -167,8 +167,10 @@ cell = [self createCellAtRow: row column: col suggestedFrame: frame]; if( cell ) { [_cells replaceObjectAtIndex: index withObject: cell]; - //[self addSublayer: cell]; - [self insertSublayer: cell atIndex: 0]; + if( _reversed ) + [self addSublayer: cell]; + else + [self insertSublayer: cell atIndex: 0]; [self setNeedsDisplay]; } } @@ -178,7 +180,7 @@ - (void) addAllCells { - for( int row=_nRows-1; row>=0; row-- ) // makes 'upper' cells be in 'back' + for( int row=0; row<_nRows; row++ ) for( int col=0; col<_nColumns; col++ ) [self addCellAtRow: row column: col]; }