diff -r 40d225cf9c43 -r af9b2b929b03 Source/BoardUIView.m --- a/Source/BoardUIView.m Tue Mar 11 09:21:53 2008 -0700 +++ b/Source/BoardUIView.m Wed Mar 12 15:51:32 2008 -0700 @@ -42,19 +42,33 @@ - (void) startGameNamed: (NSString*)gameClassName { + Class gameClass = NSClassFromString(gameClassName); + NSAssert1(gameClass,@"Unknown game '%@'",gameClassName); + + setObj(&_game,nil); if( _gameboard ) { [_gameboard removeFromSuperlayer]; _gameboard = nil; } + + CALayer *rootLayer = self.layer; + self.layer.affineTransform = CGAffineTransformIdentity; + CGRect frame = rootLayer.frame; + frame.origin.x = frame.origin.y = 0; + rootLayer.bounds = frame; + + if( [gameClass landscapeOriented] && frame.size.height > frame.size.width ) { + rootLayer.affineTransform = CGAffineTransformMakeRotation(M_PI/2); + frame = CGRectMake(0,0,frame.size.height,frame.size.width); + rootLayer.bounds = frame; + } + _gameboard = [[GGBLayer alloc] init]; - _gameboard.frame = [self gameBoardFrame]; - _gameboard.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable; - [self.layer addSublayer: _gameboard]; + _gameboard.frame = frame; + [rootLayer addSublayer: _gameboard]; [_gameboard release]; - Class gameClass = NSClassFromString(gameClassName); - NSAssert1(gameClass,@"Unknown game '%@'",gameClassName); - setObj(&_game, [[gameClass alloc] initWithBoard: _gameboard]); + _game = [[gameClass alloc] initWithBoard: _gameboard]; }