Permalink
Browse files

moving files around and fixing zoom issue

  • Loading branch information...
kigster committed Mar 18, 2012
1 parent 16479ee commit 2f673e52249d4727608935dbf4a523febdb4f421
@@ -52,8 +52,13 @@ - (void) initBoardWithGame:(Game *) newGame {
self.boardView = nil;
}
+ // remove subviews if any
+ for(UIView *subview in [self.boardScrollView subviews]) {
+ [subview removeFromSuperview];
+ }
+
self.boardView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, boardSize * MAX_CELL_WIDTH,
- boardSize * MAX_CELL_WIDTH)];
+ boardSize * MAX_CELL_WIDTH)];
[self.gameStatus setText:@"Game Starting!"];
if (self.cellImages == NULL) {
@@ -72,7 +77,6 @@ - (void) initBoardWithGame:(Game *) newGame {
}
self.cells = [NSMutableArray array];
-
//setup squares of the board
for (int x = 0; x < boardSize; x++) {
for (int y = 0; y < boardSize; y++) {
@@ -86,18 +90,16 @@ - (void) initBoardWithGame:(Game *) newGame {
[self.boardView addSubview:currentCell];
}
}
-
+
+ CGFloat viewSize = boardSize * MAX_CELL_WIDTH;
+ self.boardScrollView.contentSize = CGSizeMake(viewSize, viewSize);
+ CGFloat zoomScale = self.boardScrollView.frame.size.width / viewSize;
+ NSLog(@"resetting view zoom scale to %.2f frame size %.2f", zoomScale, self.boardScrollView.frame.size.width);
+ [self.boardScrollView setMinimumZoomScale:zoomScale];
+ [self.boardScrollView setMaximumZoomScale:zoomScale * 2];
+ [self.boardScrollView setZoomScale:zoomScale animated:NO];
[self.boardScrollView addSubview:self.boardView];
-
- CGRect screenRect = [[UIScreen mainScreen] bounds];
- CGFloat screenWidth = screenRect.size.width;
- int viewSize = boardSize * MAX_CELL_WIDTH;
- self.boardScrollView.zoomScale = screenWidth / viewSize;
- self.boardScrollView.minimumZoomScale = self.boardScrollView.zoomScale;
- self.boardScrollView.maximumZoomScale = 2 * self.boardScrollView.zoomScale;
-
- self.boardScrollView.contentSize = CGSizeMake(viewSize, viewSize);
// create Back button
undoButton = [[UIBarButtonItem alloc] initWithTitle:@"Undo"
@@ -183,6 +185,7 @@ - (void) aboutToMakeMove {
- (void) didMakeMove {
[self updateCellImageForMove:[game lastMove] highlighted:YES empty:NO];
+ [self updateGameStatus];
}
- (void) undoLastMove {
@@ -193,11 +196,14 @@ - (void) undoLastMove {
}
}
[self updateCellImageForMove:[game lastMove] highlighted:NO empty:YES];
+ [self updateGameStatus];
}
- (void) gameOver {
- NSString *winner = [self currentPlayerMarker];
- NSString *status = [NSString stringWithFormat:@"Player '%@' Won Yo!", winner];
+ int winner = game.currentPlayerIndex;
+ NSString *status = (winner == 0) ?
+ @"Doh! You lost :(" :
+ @"Great job! You won :)";
[self.gameStatus setText:status];
NSArray *winningMoves = self.game.board.winningMoves;
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
- <int key="IBDocument.SystemTarget">1280</int>
+ <int key="IBDocument.SystemTarget">1296</int>
<string key="IBDocument.SystemVersion">11D50b</string>
- <string key="IBDocument.InterfaceBuilderVersion">1938</string>
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
<string key="IBDocument.AppKitVersion">1138.32</string>
<string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">933</string>
+ <string key="NS.object.0">1179</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -45,12 +45,13 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{0, 140}, {320, 320}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSNextKeyView"/>
+ <reference key="NSWindow"/>
+ <bool key="IBUIAutoresizesSubviews">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
+ <int key="IBUIContentMode">5</int>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIBounces">NO</bool>
- <bool key="IBUIScrollEnabled">NO</bool>
<float key="IBUIMinimumZoomScale">0.0</float>
<bool key="IBUIBouncesZoom">NO</bool>
</object>
@@ -59,15 +60,16 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 63}, {280, 39}}</string>
<reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="408326628"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Game Status</string>
- <object class="NSColor" key="IBUITextColor">
+ <object class="NSColor" key="IBUITextColor" id="974267921">
<int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MC45MDUyNTIyMDc5IDAuNjI0ODE1NDUzNiAwLjIzODcxMTc2MzkAA</bytes>
+ <bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
<nil key="IBUIHighlightedColor"/>
<object class="NSColor" key="IBUIShadowColor" id="487426886">
@@ -76,36 +78,34 @@
</object>
<string key="IBUIShadowOffset">{1, 1}</string>
<int key="IBUIBaselineAdjustment">0</int>
- <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<float key="IBUIMinimumFontSize">15</float>
<int key="IBUITextAlignment">1</int>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<string key="name">Papyrus-Condensed</string>
<string key="family">Papyrus</string>
<int key="traits">0</int>
- <double key="pointSize">35</double>
+ <double key="pointSize">30</double>
</object>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Papyrus-Condensed</string>
- <double key="NSSize">35</double>
+ <double key="NSSize">30</double>
<int key="NSfFlags">16</int>
</object>
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
<object class="IBUILabel" id="526143967">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{-116, 90}, {552, 65}}</string>
<reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="504897353"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">pinch zoom to scale, or move board with two fingers</string>
- <object class="NSColor" key="IBUITextColor">
- <int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MC45MDUyNTIyMDc5IDAuNjI0ODE1NDUzNiAwLjIzODcxMTc2MzkAA</bytes>
- </object>
+ <reference key="IBUITextColor" ref="974267921"/>
<nil key="IBUIHighlightedColor"/>
<reference key="IBUIShadowColor" ref="487426886"/>
<string key="IBUIShadowOffset">{1, 1}</string>
@@ -127,6 +127,7 @@
</object>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="526143967"/>
<reference key="IBUIBackgroundColor" ref="487426886"/>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
@@ -239,7 +240,7 @@
<string>13.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>GameBoardViewController</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -265,19 +266,63 @@
<nil key="sourceID"/>
<int key="maxID">13</int>
</object>
- <object class="IBClassDescriber" key="IBDocument.Classes"/>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">GameBoardViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>boardScrollView</string>
+ <string>gameStatus</string>
+ </object>
+ <object class="NSArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>UIScrollView</string>
+ <string>UILabel</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>boardScrollView</string>
+ <string>gameStatus</string>
+ </object>
+ <object class="NSArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBToOneOutletInfo">
+ <string key="name">boardScrollView</string>
+ <string key="candidateClassName">UIScrollView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">gameStatus</string>
+ <string key="candidateClassName">UILabel</string>
+ </object>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/GameBoardViewController.h</string>
+ </object>
+ </object>
+ </object>
+ </object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
- <real value="1280" key="NS.object.0"/>
+ <real value="1296" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
- <string key="IBCocoaTouchPluginVersion">933</string>
+ <string key="IBCocoaTouchPluginVersion">1179</string>
</data>
</archive>
@@ -64,9 +64,8 @@
<object class="IBUIButton" id="995173306">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{177, 359}, {117, 40}}</string>
+ <string key="NSFrame">{{193, 359}, {117, 40}}</string>
<reference key="NSSuperview" ref="774585933"/>
- <reference key="NSNextKeyView"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -134,7 +133,7 @@
<object class="IBUIPickerView" id="178958117">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{177, 105}, {117, 216}}</string>
+ <string key="NSFrame">{{193, 112}, {117, 216}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSNextKeyView" ref="305490809"/>
<string key="NSReuseIdentifierKey">_NS:650</string>
@@ -145,17 +144,17 @@
<object class="IBUILabel" id="479842847">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{95, -5}, {280, 76}}</string>
+ <string key="NSFrame">{{90, 0}, {280, 76}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSNextKeyView" ref="103564192"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">gomoku</string>
- <object class="NSColor" key="IBUITextColor">
+ <object class="NSColor" key="IBUITextColor" id="743946178">
<int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MSAwLjM3NDI4MjMxNjcgMAA</bytes>
+ <bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
<nil key="IBUIHighlightedColor"/>
<object class="NSColor" key="IBUIShadowColor" id="327572318">
@@ -181,18 +180,15 @@
<object class="IBUILabel" id="103564192">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{168, 46}, {147, 36}}</string>
+ <string key="NSFrame">{{163, 59}, {147, 36}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSNextKeyView" ref="413359070"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">kashikoi</string>
- <object class="NSColor" key="IBUITextColor">
- <int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MSAwLjM3NDI4MjMxNjcgMAA</bytes>
- </object>
+ <reference key="IBUITextColor" ref="743946178"/>
<nil key="IBUIHighlightedColor"/>
<reference key="IBUIShadowColor" ref="327572318"/>
<string key="IBUIShadowOffset">{1, 1}</string>
@@ -214,24 +210,21 @@
<object class="IBUILabel" id="305490809">
<reference key="NSNextResponder" ref="774585933"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{50, 407}, {220, 65}}</string>
+ <string key="NSFrame">{{90, 407}, {220, 65}}</string>
<reference key="NSSuperview" ref="774585933"/>
<reference key="NSNextKeyView" ref="995173306"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">© 2012 Konstantin Gredeskoul</string>
- <object class="NSColor" key="IBUITextColor">
- <int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MSAwLjM3NDI4MjMxNjcgMAA</bytes>
- </object>
+ <reference key="IBUITextColor" ref="743946178"/>
<nil key="IBUIHighlightedColor"/>
<reference key="IBUIShadowColor" ref="327572318"/>
<string key="IBUIShadowOffset">{1, 1}</string>
<int key="IBUIBaselineAdjustment">1</int>
<int key="IBUINumberOfLines">2</int>
- <int key="IBUITextAlignment">1</int>
+ <int key="IBUITextAlignment">2</int>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<string key="name">Noteworthy-Bold</string>
<string key="family">Noteworthy</string>
@@ -336,12 +329,12 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="413359070"/>
- <reference ref="479842847"/>
- <reference ref="103564192"/>
- <reference ref="305490809"/>
- <reference ref="995173306"/>
<reference ref="576230962"/>
+ <reference ref="103564192"/>
+ <reference ref="479842847"/>
<reference ref="178958117"/>
+ <reference ref="995173306"/>
+ <reference ref="305490809"/>
</object>
<reference key="parent" ref="0"/>
</object>
File renamed without changes.
Oops, something went wrong.

0 comments on commit 2f673e5

Please sign in to comment.