# HG changeset patch # User Jens Alfke # Date 1205252513 25200 # Node ID 40d225cf9c43faaa7e0c53783e170ee46f13347b # Parent 7b0441db81e516302a273c65ea58a87f94ae349a Added support for clicking the board to place new pieces. Go and Tic-Tac-Toe now use this. diff -r 7b0441db81e5 -r 40d225cf9c43 GeekGameBoard-iPhone.xcodeproj/project.pbxproj --- a/GeekGameBoard-iPhone.xcodeproj/project.pbxproj Mon Mar 10 17:32:04 2008 -0700 +++ b/GeekGameBoard-iPhone.xcodeproj/project.pbxproj Tue Mar 11 09:21:53 2008 -0700 @@ -19,6 +19,11 @@ 279F4C1D0D85D0AF00B32DBF /* X.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 279F4C1C0D85D0AF00B32DBF /* X.tiff */; }; 279F4C1F0D85D0CB00B32DBF /* O.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 279F4C1E0D85D0CB00B32DBF /* O.tiff */; }; 279F4C740D85D43800B32DBF /* Background.png in Resources */ = {isa = PBXBuildFile; fileRef = 279F4C730D85D43800B32DBF /* Background.png */; }; + 279F4E0A0D860B8800B32DBF /* Green Ball.png in Resources */ = {isa = PBXBuildFile; fileRef = 279F4E050D860B8800B32DBF /* Green Ball.png */; }; + 279F4E0B0D860B8800B32DBF /* Red Ball.png in Resources */ = {isa = PBXBuildFile; fileRef = 279F4E060D860B8800B32DBF /* Red Ball.png */; }; + 279F4E0C0D860B8800B32DBF /* White Ball.png in Resources */ = {isa = PBXBuildFile; fileRef = 279F4E070D860B8800B32DBF /* White Ball.png */; }; + 279F4E0E0D860B8800B32DBF /* Yellow Ball.png in Resources */ = {isa = PBXBuildFile; fileRef = 279F4E090D860B8800B32DBF /* Yellow Ball.png */; }; + 279F4F1B0D86448100B32DBF /* Wood.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 279F4F1A0D86448100B32DBF /* Wood.jpg */; }; 27C99B0F0D820868005AFD4F /* BoardUIView.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C99AE40D820868005AFD4F /* BoardUIView.m */; }; 27C99B100D820868005AFD4F /* Bit.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C99AE60D820868005AFD4F /* Bit.m */; }; 27C99B110D820868005AFD4F /* BitHolder.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C99AE80D820868005AFD4F /* BitHolder.m */; }; @@ -57,6 +62,11 @@ 279F4C1C0D85D0AF00B32DBF /* X.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = X.tiff; sourceTree = ""; }; 279F4C1E0D85D0CB00B32DBF /* O.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = O.tiff; sourceTree = ""; }; 279F4C730D85D43800B32DBF /* Background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Background.png; sourceTree = ""; }; + 279F4E050D860B8800B32DBF /* Green Ball.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Green Ball.png"; sourceTree = ""; }; + 279F4E060D860B8800B32DBF /* Red Ball.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Red Ball.png"; sourceTree = ""; }; + 279F4E070D860B8800B32DBF /* White Ball.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "White Ball.png"; sourceTree = ""; }; + 279F4E090D860B8800B32DBF /* Yellow Ball.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Yellow Ball.png"; sourceTree = ""; }; + 279F4F1A0D86448100B32DBF /* Wood.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = Wood.jpg; sourceTree = ""; }; 27C99AE30D820868005AFD4F /* BoardUIView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoardUIView.h; sourceTree = ""; }; 27C99AE40D820868005AFD4F /* BoardUIView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BoardUIView.m; sourceTree = ""; }; 27C99AE50D820868005AFD4F /* Bit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bit.h; sourceTree = ""; }; @@ -150,10 +160,6 @@ children = ( 27C99AE30D820868005AFD4F /* BoardUIView.h */, 27C99AE40D820868005AFD4F /* BoardUIView.m */, - 27C99B4F0D82106E005AFD4F /* GGBLayer.h */, - 27C99B500D82106E005AFD4F /* GGBLayer.m */, - 279F4B600D85C63000B32DBF /* GGBTextLayer.h */, - 279F4B610D85C63000B32DBF /* GGBTextLayer.m */, 27C99AE50D820868005AFD4F /* Bit.h */, 27C99AE60D820868005AFD4F /* Bit.m */, 27C99AE70D820868005AFD4F /* BitHolder.h */, @@ -163,6 +169,10 @@ 27C99AF20D820868005AFD4F /* Boards and Pieces */, 27C99AEB0D820868005AFD4F /* Cards */, 27C99AFD0D820868005AFD4F /* Games */, + 27C99B4F0D82106E005AFD4F /* GGBLayer.h */, + 27C99B500D82106E005AFD4F /* GGBLayer.m */, + 279F4B600D85C63000B32DBF /* GGBTextLayer.h */, + 279F4B610D85C63000B32DBF /* GGBTextLayer.m */, 27C99B0A0D820868005AFD4F /* QuartzUtils.h */, 27C99B0B0D820868005AFD4F /* QuartzUtils.m */, 27C99B0C0D820868005AFD4F /* GGBUtils.h */, @@ -248,6 +258,11 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 279F4E050D860B8800B32DBF /* Green Ball.png */, + 279F4E060D860B8800B32DBF /* Red Ball.png */, + 279F4E070D860B8800B32DBF /* White Ball.png */, + 279F4F1A0D86448100B32DBF /* Wood.jpg */, + 279F4E090D860B8800B32DBF /* Yellow Ball.png */, 279F4C730D85D43800B32DBF /* Background.png */, 279F4C1C0D85D0AF00B32DBF /* X.tiff */, 279F4C1E0D85D0CB00B32DBF /* O.tiff */, @@ -312,6 +327,11 @@ 279F4C1D0D85D0AF00B32DBF /* X.tiff in Resources */, 279F4C1F0D85D0CB00B32DBF /* O.tiff in Resources */, 279F4C740D85D43800B32DBF /* Background.png in Resources */, + 279F4E0A0D860B8800B32DBF /* Green Ball.png in Resources */, + 279F4E0B0D860B8800B32DBF /* Red Ball.png in Resources */, + 279F4E0C0D860B8800B32DBF /* White Ball.png in Resources */, + 279F4E0E0D860B8800B32DBF /* Yellow Ball.png in Resources */, + 279F4F1B0D86448100B32DBF /* Wood.jpg in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff -r 7b0441db81e5 -r 40d225cf9c43 Resources/Wood.jpg Binary file Resources/Wood.jpg has changed diff -r 7b0441db81e5 -r 40d225cf9c43 Source/BoardUIView.m --- a/Source/BoardUIView.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/BoardUIView.m Tue Mar 11 09:21:53 2008 -0700 @@ -14,6 +14,11 @@ #import "GGBUtils.h" +@interface BoardUIView () +- (void) _findDropTarget: (CGPoint)pos; +@end + + @implementation BoardUIView @@ -102,17 +107,40 @@ NSAssert(touches.count==1,@"No multitouch support yet"); UITouch *touch = touches.anyObject; + BOOL placing = NO; _dragStartPos = touch.locationInView; _dragBit = (Bit*) [self hitTestPoint: _dragStartPos forLayerMatching: layerIsBit offset: &_dragOffset]; - if( _dragBit ) { - _dragMoved = NO; - _dropTarget = nil; - _oldHolder = _dragBit.holder; - // Ask holder's and game's permission before dragging: - if( _oldHolder ) - _dragBit = [_oldHolder canDragBit: _dragBit]; + + if( ! _dragBit ) { + // If no bit was clicked, see if it's a BitHolder the game will let the user add a Bit to: + id holder = (id) [self hitTestPoint: _dragStartPos + forLayerMatching: layerIsBitHolder + offset: NULL]; + if( holder ) { + _dragBit = [_game bitToPlaceInHolder: holder]; + if( _dragBit ) { + _dragOffset.x = _dragOffset.y = 0; + if( _dragBit.superlayer==nil ) + _dragBit.position = _dragStartPos; + placing = YES; + } + } + } + + if( ! _dragBit ) { + Beep(); + return; + } + + // Clicked on a Bit: + _dragMoved = NO; + _dropTarget = nil; + _oldHolder = _dragBit.holder; + // Ask holder's and game's permission before dragging: + if( _oldHolder ) { + _dragBit = [_oldHolder canDragBit: _dragBit]; if( _dragBit && ! [_game canBit: _dragBit moveFrom: _oldHolder] ) { [_oldHolder cancelDragBit: _dragBit]; _dragBit = nil; @@ -122,14 +150,20 @@ Beep(); return; } - // Start dragging: - _oldSuperlayer = _dragBit.superlayer; - _oldLayerIndex = [_oldSuperlayer.sublayers indexOfObjectIdenticalTo: _dragBit]; - _oldPos = _dragBit.position; - ChangeSuperlayer(_dragBit, self.layer, self.layer.sublayers.count); - _dragBit.pickedUp = YES; - } else - Beep(); + } + // Start dragging: + _oldSuperlayer = _dragBit.superlayer; + _oldLayerIndex = [_oldSuperlayer.sublayers indexOfObjectIdenticalTo: _dragBit]; + _oldPos = _dragBit.position; + ChangeSuperlayer(_dragBit, self.layer, self.layer.sublayers.count); + _dragBit.pickedUp = YES; + + if( placing ) { + if( _oldSuperlayer ) + _dragBit.position = _dragStartPos; // animate Bit to new position + _dragMoved = YES; + [self _findDropTarget: _dragStartPos]; + } } @@ -158,27 +192,33 @@ [CATransaction commit]; // Find what it's over: - id target = (id) [self hitTestPoint: pos - forLayerMatching: layerIsBitHolder - offset: NULL]; - if( target == _oldHolder ) - target = nil; - if( target != _dropTarget ) { - [_dropTarget willNotDropBit: _dragBit]; - _dropTarget.highlighted = NO; - _dropTarget = nil; - } - if( target ) { - CGPoint targetPos = [(CALayer*)target convertPoint: _dragBit.position - fromLayer: _dragBit.superlayer]; - if( [target canDropBit: _dragBit atPoint: targetPos] - && [_game canBit: _dragBit moveFrom: _oldHolder to: target] ) { - _dropTarget = target; - _dropTarget.highlighted = YES; - } + [self _findDropTarget: pos]; + } +} + + +- (void) _findDropTarget: (CGPoint)pos +{ + id target = (id) [self hitTestPoint: pos + forLayerMatching: layerIsBitHolder + offset: NULL]; + if( target == _oldHolder ) + target = nil; + if( target != _dropTarget ) { + [_dropTarget willNotDropBit: _dragBit]; + _dropTarget.highlighted = NO; + _dropTarget = nil; + } + if( target ) { + CGPoint targetPos = [(CALayer*)target convertPoint: _dragBit.position + fromLayer: _dragBit.superlayer]; + if( [target canDropBit: _dragBit atPoint: targetPos] + && [_game canBit: _dragBit moveFrom: _oldHolder to: target] ) { + _dropTarget = target; + _dropTarget.highlighted = YES; } } -} +} - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event @@ -200,9 +240,13 @@ } else { // Nope, cancel: [_dropTarget willNotDropBit: _dragBit]; - ChangeSuperlayer(_dragBit, _oldSuperlayer, _oldLayerIndex); - _dragBit.position = _oldPos; - [_oldHolder cancelDragBit: _dragBit]; + if( _oldSuperlayer ) { + ChangeSuperlayer(_dragBit, _oldSuperlayer, _oldLayerIndex); + _dragBit.position = _oldPos; + [_oldHolder cancelDragBit: _dragBit]; + } else { + [_dragBit removeFromSuperlayer]; + } } } else { // Just a click, without a drag: diff -r 7b0441db81e5 -r 40d225cf9c43 Source/BoardView.m --- a/Source/BoardView.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/BoardView.m Tue Mar 11 09:21:53 2008 -0700 @@ -28,6 +28,11 @@ #import "GGBUtils.h" +@interface BoardView () +- (void) _findDropTarget: (NSPoint)pos; +@end + + @implementation BoardView @@ -137,17 +142,40 @@ - (void) mouseDown: (NSEvent*)ev { + BOOL placing = NO; _dragStartPos = ev.locationInWindow; _dragBit = (Bit*) [self hitTestPoint: _dragStartPos forLayerMatching: layerIsBit offset: &_dragOffset]; - if( _dragBit ) { - _dragMoved = NO; - _dropTarget = nil; - _oldHolder = _dragBit.holder; - // Ask holder's and game's permission before dragging: - if( _oldHolder ) - _dragBit = [_oldHolder canDragBit: _dragBit]; + + if( ! _dragBit ) { + // If no bit was clicked, see if it's a BitHolder the game will let the user add a Bit to: + id holder = (id) [self hitTestPoint: _dragStartPos + forLayerMatching: layerIsBitHolder + offset: NULL]; + if( holder ) { + _dragBit = [_game bitToPlaceInHolder: holder]; + if( _dragBit ) { + _dragOffset.x = _dragOffset.y = 0; + if( _dragBit.superlayer==nil ) + _dragBit.position = NSPointToCGPoint([self convertPoint: _dragStartPos fromView: nil]); + placing = YES; + } + } + } + + if( ! _dragBit ) { + Beep(); + return; + } + + // Clicked on a Bit: + _dragMoved = NO; + _dropTarget = nil; + _oldHolder = _dragBit.holder; + // Ask holder's and game's permission before dragging: + if( _oldHolder ) { + _dragBit = [_oldHolder canDragBit: _dragBit]; if( _dragBit && ! [_game canBit: _dragBit moveFrom: _oldHolder] ) { [_oldHolder cancelDragBit: _dragBit]; _dragBit = nil; @@ -157,17 +185,25 @@ NSBeep(); return; } - // Start dragging: - _oldSuperlayer = _dragBit.superlayer; - _oldLayerIndex = [_oldSuperlayer.sublayers indexOfObjectIdenticalTo: _dragBit]; - _oldPos = _dragBit.position; - ChangeSuperlayer(_dragBit, self.layer, self.layer.sublayers.count); - _dragBit.pickedUp = YES; - [[NSCursor closedHandCursor] push]; - } else - NSBeep(); + } + + // Start dragging: + _oldSuperlayer = _dragBit.superlayer; + _oldLayerIndex = [_oldSuperlayer.sublayers indexOfObjectIdenticalTo: _dragBit]; + _oldPos = _dragBit.position; + ChangeSuperlayer(_dragBit, self.layer, self.layer.sublayers.count); + _dragBit.pickedUp = YES; + [[NSCursor closedHandCursor] push]; + + if( placing ) { + if( _oldSuperlayer ) + _dragBit.position = NSPointToCGPoint([self convertPoint: _dragStartPos fromView: nil]); + _dragMoved = YES; + [self _findDropTarget: _dragStartPos]; + } } + - (void) mouseDragged: (NSEvent*)ev { if( _dragBit ) { @@ -192,28 +228,37 @@ [CATransaction commit]; // Find what it's over: - id target = (id) [self hitTestPoint: where - forLayerMatching: layerIsBitHolder - offset: NULL]; - if( target == _oldHolder ) - target = nil; - if( target != _dropTarget ) { - [_dropTarget willNotDropBit: _dragBit]; - _dropTarget.highlighted = NO; - _dropTarget = nil; - } - if( target ) { - CGPoint targetPos = [(CALayer*)target convertPoint: _dragBit.position - fromLayer: _dragBit.superlayer]; - if( [target canDropBit: _dragBit atPoint: targetPos] - && [_game canBit: _dragBit moveFrom: _oldHolder to: target] ) { - _dropTarget = target; - _dropTarget.highlighted = YES; - } + [self _findDropTarget: pos]; + } +} + + +- (void) _findDropTarget: (NSPoint)locationInWindow +{ + locationInWindow.x += _dragOffset.x; + locationInWindow.y += _dragOffset.y; + id target = (id) [self hitTestPoint: locationInWindow + forLayerMatching: layerIsBitHolder + offset: NULL]; + if( target == _oldHolder ) + target = nil; + if( target != _dropTarget ) { + [_dropTarget willNotDropBit: _dragBit]; + _dropTarget.highlighted = NO; + _dropTarget = nil; + } + if( target ) { + CGPoint targetPos = [(CALayer*)target convertPoint: _dragBit.position + fromLayer: _dragBit.superlayer]; + if( [target canDropBit: _dragBit atPoint: targetPos] + && [_game canBit: _dragBit moveFrom: _oldHolder to: target] ) { + _dropTarget = target; + _dropTarget.highlighted = YES; } } } + - (void) mouseUp: (NSEvent*)ev { if( _dragBit ) { @@ -233,9 +278,13 @@ } else { // Nope, cancel: [_dropTarget willNotDropBit: _dragBit]; - ChangeSuperlayer(_dragBit, _oldSuperlayer, _oldLayerIndex); - _dragBit.position = _oldPos; - [_oldHolder cancelDragBit: _dragBit]; + if( _oldSuperlayer ) { + ChangeSuperlayer(_dragBit, _oldSuperlayer, _oldLayerIndex); + _dragBit.position = _oldPos; + [_oldHolder cancelDragBit: _dragBit]; + } else { + [_dragBit removeFromSuperlayer]; + } } } else { // Just a click, without a drag: diff -r 7b0441db81e5 -r 40d225cf9c43 Source/Game.h --- a/Source/Game.h Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/Game.h Tue Mar 11 09:21:53 2008 -0700 @@ -60,6 +60,10 @@ Default implementation just calls -endTurn. */ - (void) bit: (Bit*)bit movedFrom: (id)src to: (id)dst; +/** Called on mouse-down/touch of an *empty* BitHolder. Should return a Bit if + it's OK to place a new Bit there; else nil. */ +- (Bit*) bitToPlaceInHolder: (id)holder; + /** Called instead of the above if a Bit is simply clicked, not dragged. Should return NO if the click is illegal (i.e. clicking an empty draw pile in a card game.) Default implementation always returns YES. */ diff -r 7b0441db81e5 -r 40d225cf9c43 Source/Game.m --- a/Source/Game.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/Game.m Tue Mar 11 09:21:53 2008 -0700 @@ -30,15 +30,6 @@ @end -/** WARNING: THIS CODE REQUIRES GARBAGE COLLECTION! - ** This sample application uses Objective-C 2.0 garbage collection. - ** Therefore, the source code in this file does NOT perform manual object memory management. - ** If you reuse any of this code in a process that isn't garbage collected, you will need to - ** add all necessary retain/release/autorelease calls, and implement -dealloc methods, - ** otherwise unpleasant leakage will occur! - **/ - - @implementation Game @@ -134,6 +125,12 @@ [self endTurn]; } +- (Bit*) bitToPlaceInHolder: (id)holder +{ + return nil; +} + + - (BOOL) clickedBit: (Bit*)bit { return YES; diff -r 7b0441db81e5 -r 40d225cf9c43 Source/GoGame.m --- a/Source/GoGame.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/GoGame.m Tue Mar 11 09:21:53 2008 -0700 @@ -32,29 +32,20 @@ @implementation GoGame -- (void) x_createDispenser: (NSString*)imageName position: (CGPoint)position forPlayer: (unsigned)playerNo -{ - CGFloat pieceSize = (int)(_grid.spacing.width * 0.9) & ~1; // make sure it's even - Piece *stone = [[Piece alloc] initWithImageNamed: imageName scale: pieceSize]; - stone.owner = [self.players objectAtIndex: playerNo]; - CGRect frame = {position, {1.5*pieceSize,1.5*pieceSize}}; - Dispenser *disp = [[Dispenser alloc] initWithPrototype: stone quantity: INT_MAX frame:frame]; - [_board addSublayer: disp]; - [disp release]; - [stone release]; -} - - - (id) initWithBoard: (GGBLayer*)board { self = [super initWithBoard: board]; if (self != nil) { [self setNumberOfPlayers: 2]; + [(Player*)[_players objectAtIndex: 0] setName: @"Red"]; + [(Player*)[_players objectAtIndex: 1] setName: @"White"]; CGSize size = board.bounds.size; + CGFloat boardSide = MIN(size.width,size.height); RectGrid *grid = [[RectGrid alloc] initWithRows: 9 columns: 9 - frame: CGRectMake((size.width-size.height+16)/2,8, - size.height-16,size.height-16)]; + frame: CGRectMake(floor((size.width-boardSide)/2), + floor((size.height-boardSide)/2), + boardSide,boardSide)]; _grid = grid; grid.backgroundColor = GetCGPatternNamed(@"Wood.jpg"); grid.borderColor = kTranslucentLightGrayColor; @@ -72,15 +63,6 @@ CGRect gridFrame = grid.frame; CGFloat pieceSize = (int)grid.spacing.width & ~1; // make sure it's even - [self x_createDispenser: @"Red Ball.png" - position: CGPointMake(CGRectGetMinX(gridFrame)-2*pieceSize, - CGRectGetMinY(gridFrame)) - forPlayer: 0]; - [self x_createDispenser: @"White Ball.png" - position: CGPointMake(CGRectGetMaxX(gridFrame)+0.5*pieceSize, - CGRectGetMaxY(gridFrame)-1.5*pieceSize) - forPlayer: 1]; - CGFloat captureHeight = gridFrame.size.height-4*pieceSize; _captured[0] = [[Stack alloc] initWithStartPos: CGPointMake(2*pieceSize,0) spacing: CGSizeMake(0,pieceSize) @@ -110,6 +92,18 @@ } +- (Bit*) bitToPlaceInHolder: (id)holder +{ + if( holder.bit != nil || ! [holder isKindOfClass: [GoSquare class]] ) + return nil; + NSString *imageName = self.currentPlayer.index ?@"White Ball.png" :@"Red Ball.png"; + CGFloat pieceSize = (int)(_grid.spacing.width * 0.9) & ~1; // make sure it's even + Piece *stone = [[Piece alloc] initWithImageNamed: imageName scale: pieceSize]; + stone.owner = self.currentPlayer; + return [stone autorelease]; +} + + - (BOOL) canBit: (Bit*)bit moveFrom: (id)srcHolder to: (id)dstHolder { Square *dst=(Square*)dstHolder; diff -r 7b0441db81e5 -r 40d225cf9c43 Source/Grid.m --- a/Source/Grid.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/Grid.m Tue Mar 11 09:21:53 2008 -0700 @@ -67,9 +67,14 @@ { CGFloat spacing = floor(MIN( (frame.size.width -2)/(CGFloat)nColumns, (frame.size.height-2)/(CGFloat)nRows) ); + CGSize size = CGSizeMake(nColumns*spacing+2, nRows*spacing+2); + CGPoint position = frame.origin; + position.x += round( (frame.size.width -size.width )/2.0 ); + position.y += round( (frame.size.height-size.height)/2.0 ); + return [self initWithRows: nRows columns: nColumns spacing: CGSizeMake(spacing,spacing) - position: frame.origin]; + position: position]; } @@ -187,6 +192,7 @@ { // Custom CALayer drawing implementation. Delegates to the cells to draw themselves // in me; this is more efficient than having each cell have its own drawing. + [super drawInContext: ctx]; if( _cellColor ) { CGContextSetFillColorWithColor(ctx, _cellColor); [self drawCellsInContext: ctx fill: YES]; @@ -409,6 +415,7 @@ - (void) setHighlighted: (BOOL)highlighted { [super setHighlighted: highlighted]; + self.cornerRadius = self.bounds.size.width/2.0; self.borderWidth = (highlighted ?6 :0); } diff -r 7b0441db81e5 -r 40d225cf9c43 Source/QuartzUtils.m --- a/Source/QuartzUtils.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/QuartzUtils.m Tue Mar 11 09:21:53 2008 -0700 @@ -71,8 +71,9 @@ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - CGPoint pos = [newSuperlayer convertPoint: layer.position - fromLayer: layer.superlayer]; + CGPoint pos = layer.position; + if( layer.superlayer ) + pos = [newSuperlayer convertPoint: pos fromLayer: layer.superlayer]; [layer retain]; [layer removeFromSuperlayer]; if( index >= 0 ) diff -r 7b0441db81e5 -r 40d225cf9c43 Source/TicTacToeGame.m --- a/Source/TicTacToeGame.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/TicTacToeGame.m Tue Mar 11 09:21:53 2008 -0700 @@ -71,6 +71,14 @@ return self; } +- (Bit*) bitToPlaceInHolder: (id)holder +{ + if( holder.bit==nil && [holder isKindOfClass: [Square class]] ) + return _dispenser[self.currentPlayer.index].bit; + else + return nil; +} + - (void) nextPlayer { [super nextPlayer]; diff -r 7b0441db81e5 -r 40d225cf9c43 Source/iPhoneAppDelegate.m --- a/Source/iPhoneAppDelegate.m Mon Mar 10 17:32:04 2008 -0700 +++ b/Source/iPhoneAppDelegate.m Tue Mar 11 09:21:53 2008 -0700 @@ -45,7 +45,7 @@ [_window addSubview: _headline]; // Start game: - [self startGameNamed: @"TicTacToeGame"]; + [self startGameNamed: @"GoGame"]; // Show window [_window makeKeyAndVisible];