Minor fixes.
1.1 --- a/Source/BoardView.m Tue Jul 08 13:12:01 2008 -0700
1.2 +++ b/Source/BoardView.m Tue Jul 08 20:32:52 2008 -0700
1.3 @@ -86,6 +86,7 @@
1.4 - (void) setGame: (Game*)game
1.5 {
1.6 if( game!=_game ) {
1.7 + _game.board = nil;
1.8 setObj(&_game,game);
1.9 [self createGameBoard];
1.10 }
2.1 --- a/Source/GGBLayer.m Tue Jul 08 13:12:01 2008 -0700
2.2 +++ b/Source/GGBLayer.m Tue Jul 08 20:32:52 2008 -0700
2.3 @@ -56,10 +56,14 @@
2.4 _curAnimation = (id)[self animationForKey: @"animateAndBlock:"];
2.5 [self setValue: to forKeyPath: keyPath]; // animation doesn't update the property value
2.6
2.7 - // Now wait for it to finish:
2.8 - while( _curAnimation ) {
2.9 - [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode//NSEventTrackingRunLoopMode
2.10 - beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
2.11 + if( self.presentationLayer ) {
2.12 + // Now wait for it to finish:
2.13 + while( _curAnimation ) {
2.14 + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode//NSEventTrackingRunLoopMode
2.15 + beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
2.16 + }
2.17 + } else {
2.18 + _curAnimation = nil;
2.19 }
2.20 }
2.21
3.1 --- a/Source/Game.m Tue Jul 08 13:12:01 2008 -0700
3.2 +++ b/Source/Game.m Tue Jul 08 20:32:52 2008 -0700
3.3 @@ -125,20 +125,22 @@
3.4 - (void) setBoard: (GGBLayer*)board
3.5 {
3.6 setObj(&_board,board);
3.7 - // Store a pointer to myself as the value of the "Game" property
3.8 - // of my root layer. (CALayers can have arbitrary KV properties stored into them.)
3.9 - // This is used by the -[CALayer game] category method defined below, to find the Game.
3.10 - [_board setValue: self forKey: @"Game"];
3.11 -
3.12 - BeginDisableAnimations();
3.13 -
3.14 - // Tell the game to add the necessary bits to the board:
3.15 - [self setUpBoard];
3.16 -
3.17 - // Re-apply the current state to set up the pieces/cards:
3.18 - self.stateString = [[_turns objectAtIndex: _currentTurnNo] boardState];
3.19 -
3.20 - EndDisableAnimations();
3.21 + if( board ) {
3.22 + // Store a pointer to myself as the value of the "Game" property
3.23 + // of my root layer. (CALayers can have arbitrary KV properties stored into them.)
3.24 + // This is used by the -[CALayer game] category method defined below, to find the Game.
3.25 + [_board setValue: self forKey: @"Game"];
3.26 +
3.27 + BeginDisableAnimations();
3.28 +
3.29 + // Tell the game to add the necessary bits to the board:
3.30 + [self setUpBoard];
3.31 +
3.32 + // Re-apply the current state to set up the pieces/cards:
3.33 + self.stateString = [[_turns objectAtIndex: _currentTurnNo] boardState];
3.34 +
3.35 + EndDisableAnimations();
3.36 + }
3.37 }
3.38
3.39
4.1 --- a/Source/Player.h Tue Jul 08 13:12:01 2008 -0700
4.2 +++ b/Source/Player.h Tue Jul 08 20:32:52 2008 -0700
4.3 @@ -35,6 +35,9 @@
4.4 @property (readonly, getter=isFriendly) BOOL friendly; // Is this player the current player or an ally?
4.5 @property (readonly, getter=isUnfriendly) BOOL unfriendly; // Is this player an opponent of the current player?
4.6 @property (readonly) Player *nextPlayer, *previousPlayer; // The next/previous player in sequence
4.7 +
4.8 +/** Copy all of the player's attributes (name, local...) into myself. */
4.9 +- (void) copyFrom: (Player*)player;
4.10 @end
4.11
4.12
5.1 --- a/Source/Player.m Tue Jul 08 13:12:01 2008 -0700
5.2 +++ b/Source/Player.m Tue Jul 08 20:32:52 2008 -0700
5.3 @@ -78,6 +78,14 @@
5.4 }
5.5
5.6
5.7 +- (void) copyFrom: (Player*)player
5.8 +{
5.9 + self.local = player.local;
5.10 + self.name = player.name;
5.11 + setObj(&_extraValues, [[player->_extraValues mutableCopy] autorelease]);
5.12 +}
5.13 +
5.14 +
5.15 @synthesize game=_game, name=_name, local=_local;
5.16
5.17 - (BOOL) isCurrent {return self == _game.currentPlayer;}