--- a/project_files/HedgewarsMobile/Classes/Appirater.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/Appirater.h Sat Jan 26 23:57:37 2013 +0100
@@ -1,9 +1,9 @@
/*
This file is part of Appirater, http://arashpayan.com
-
+
Copyright (c) 2010, Arash Payan
All rights reserved.
-
+
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
@@ -12,10 +12,10 @@
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
-
+
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
--- a/project_files/HedgewarsMobile/Classes/Appirater.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/Appirater.m Sat Jan 26 23:57:37 2013 +0100
@@ -1,9 +1,9 @@
/*
This file is part of Appirater, http://arashpayan.com
-
+
Copyright (c) 2010, Arash Payan
All rights reserved.
-
+
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
@@ -12,10 +12,10 @@
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
-
+
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -66,7 +66,7 @@
trackingVersion = version;
[userDefaults setObject:version forKey:kAppiraterCurrentVersion];
}
-
+
if (APPIRATER_DEBUG)
DLog(@"APPIRATER Tracking version: %@", trackingVersion);
@@ -98,7 +98,7 @@
launchCount > LAUNCHES_UNTIL_PROMPT &&
!declinedToRate &&
!ratedApp) {
- if ([HWUtils isNetworkReachable]) { // check if they can reach the app store
+ if ([HWUtils isNetworkReachable]) { // check if they can reach the app store
willShowPrompt = YES;
[self performSelectorOnMainThread:@selector(showPrompt) withObject:nil waitUntilDone:NO];
}
@@ -141,7 +141,7 @@
// they want to rate it
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]]]];
-
+
[userDefaults setBool:YES forKey:kAppiraterRatedCurrentVersion];
break;
case 2:
--- a/project_files/HedgewarsMobile/Classes/AudioManagerController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/AudioManagerController.m Sat Jan 26 23:57:37 2013 +0100
@@ -79,7 +79,7 @@
self.backgroundMusic.delegate = nil;
self.backgroundMusic.numberOfLoops = -1;
}
-
+
self.backgroundMusic.volume = DEFAULT_VOLUME;
[self.backgroundMusic play];
}
@@ -98,7 +98,7 @@
if (self.audioFaderQueue == nil)
self.audioFaderQueue = [[NSOperationQueue alloc] init];
-
+
MXAudioPlayerFadeOperation *fadeOut = [[MXAudioPlayerFadeOperation alloc] initFadeWithAudioPlayer:self.backgroundMusic
toVolume:0.0
overDuration:FADEOUT_DURATION];
@@ -144,30 +144,30 @@
-(void) playClickSound {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"sound"] boolValue] == NO)
return;
-
+
if (self.clickSound == -1)
self.clickSound = [self loadSound:@"clickSound"];
-
+
AudioServicesPlaySystemSound(self.clickSound);
}
-(void) playBackSound {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"sound"] boolValue] == NO)
return;
-
+
if (self.backSound == -1)
self.backSound = [self loadSound:@"backSound"];
-
+
AudioServicesPlaySystemSound(self.backSound);
}
-(void) playSelectSound {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"sound"] boolValue] == NO)
return;
-
+
if (self.selSound == -1)
self.selSound = [self loadSound:@"selSound"];
-
+
AudioServicesPlaySystemSound(self.selSound);
}
--- a/project_files/HedgewarsMobile/Classes/CreationChamber.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/CreationChamber.m Sat Jan 26 23:57:37 2013 +0100
@@ -390,7 +390,7 @@
[basicArray release];
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt];
-
+
[theScheme writeToFile:schemeFile atomically:YES];
[schemeFile release];
[theScheme release];
--- a/project_files/HedgewarsMobile/Classes/DefinesAndMacros.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/DefinesAndMacros.h Sat Jan 26 23:57:37 2013 +0100
@@ -39,7 +39,7 @@
#define rotationManager(x) (IS_IPAD() ? YES : (x == UIInterfaceOrientationLandscapeRight) || (x == UIInterfaceOrientationLandscapeLeft))
#define START_TIMER() NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
-#define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; DLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]);
+#define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; DLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]);
#define DOCUMENTS_FOLDER() [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
--- a/project_files/HedgewarsMobile/Classes/FlagsViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/FlagsViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -35,7 +35,7 @@
NSMutableArray *array_na = [[NSMutableArray alloc] init];
NSMutableArray *array_cm = [[NSMutableArray alloc] init];
-
+
for (NSString *name in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:FLAGS_DIRECTORY() error:NULL]) {
if ([name hasPrefix:@"cm_"]) {
NSString *processed = [name substringFromIndex:3];
@@ -43,7 +43,7 @@
} else
[array_na addObject:name];
}
-
+
self.flagArray = array_na;
[array_na release];
self.communityArray = array_cm;
@@ -135,14 +135,14 @@
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
int newSection = [indexPath section];
int oldSection = (lastIndexPath != nil) ? [lastIndexPath section] : -1;
-
+
if (newRow != oldRow || newSection != oldSection) {
NSString *flag = nil;
if ([indexPath section] == 0)
flag = [self.flagArray objectAtIndex:newRow];
else
flag = [NSString stringWithFormat:@"cm_%@",[self.communityArray objectAtIndex:newRow]];
-
+
// if the two selected rows differ update data on the hog dictionary and reload table content
[self.teamDictionary setValue:[flag stringByDeletingPathExtension] forKey:@"flag"];
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -62,7 +62,7 @@
}
}
[self startGame:theButton];
-
+
break;
case 2:
[[AudioManagerController mainManager] playClickSound];
--- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -149,7 +149,7 @@
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
editableCell.textField.textColor = [UIColor blackColor];
}
-
+
if (row == 0) {
editableCell.titleLabel.text = NSLocalizedString(@"Nickname","from the settings table");
editableCell.textField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@"from the settings table");
@@ -163,7 +163,7 @@
editableCell.textField.secureTextEntry = YES;
editableCell.tag = 50;
}
-
+
editableCell.accessoryView = nil;
cell = editableCell;
break;
@@ -176,7 +176,7 @@
cell.accessoryView = theSwitch;
[theSwitch release];
}
-
+
switchContent = (UISwitch *)cell.accessoryView;
if (row == 0) {
cell.textLabel.text = NSLocalizedString(@"Sound Effects", @"from the settings table");
@@ -197,7 +197,7 @@
cell.accessoryView = theSwitch;
[theSwitch release];
}
-
+
switchContent = (UISwitch *)cell.accessoryView;
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
switch (row) {
@@ -221,7 +221,7 @@
default:
break;
}
-
+
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.imageView.image = nil;
--- a/project_files/HedgewarsMobile/Classes/HoldTableViewCell.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/HoldTableViewCell.m Sat Jan 26 23:57:37 2013 +0100
@@ -35,8 +35,8 @@
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
-
- time = touch.timestamp;
+
+ time = touch.timestamp;
[self performSelector:@selector(holdAction) withObject:nil afterDelay:0.25];
[super touchesBegan:touches withEvent:event];
@@ -44,12 +44,12 @@
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
-
+
if ( touch.timestamp - time < 0.25 ) {
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(holdAction)
object:nil];
-
+
[super touchesEnded:touches withEvent:event];
} else
[super touchesCancelled:touches withEvent:event];
--- a/project_files/HedgewarsMobile/Classes/LevelViewController.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/LevelViewController.h Sat Jan 26 23:57:37 2013 +0100
@@ -26,7 +26,7 @@
NSArray *levelArray;
NSArray *levelSprites;
NSIndexPath *lastIndexPath;
-
+
NSInteger numberOfSections;
}
--- a/project_files/HedgewarsMobile/Classes/LevelViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/LevelViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -48,19 +48,19 @@
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
-
+
if ([[[[self.teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:0] objectForKey:@"level"] intValue] == 0)
numberOfSections = 1;
else
numberOfSections = 2;
-
+
[self.tableView reloadData];
// this moves the tableview to the top
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
}
-(void) viewWillDisappear:(BOOL)animated {
- // stuff like checking that at least 1 field was selected
+ // stuff like checking that at least 1 field was selected
}
#pragma mark -
@@ -84,7 +84,7 @@
NSInteger row = [indexPath row];
NSInteger section = [indexPath section];
UITableViewCell *cell;
-
+
if (section == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (cell == nil) {
@@ -104,7 +104,7 @@
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
-
+
cell.textLabel.text = [levelArray objectAtIndex:row];
NSDictionary *hog = [[self.teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:0];
if ([[hog objectForKey:@"level"] intValue] == row+1) {
@@ -113,14 +113,14 @@
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
-
+
NSString *botlevelPath = [[NSString alloc] initWithFormat:@"%@/bot%d.png",[[NSBundle mainBundle] resourcePath],row+1];
UIImage *levelImage = [[UIImage alloc] initWithContentsOfFile:botlevelPath];
[botlevelPath release];
cell.imageView.image = levelImage;
[levelImage release];
}
-
+
return cell;
}
@@ -129,7 +129,7 @@
NSIndexSet *sections = [[NSIndexSet alloc] initWithIndex:1];
NSMutableArray *hogs = [self.teamDictionary objectForKey:@"hedgehogs"];
NSInteger level;
-
+
if (theSwitch.on) {
numberOfSections = 2;
[self.tableView insertSections:sections withRowAnimation:UITableViewRowAnimationFade];
@@ -156,19 +156,19 @@
int newRow = [indexPath row];
int oldRow = (self.lastIndexPath != nil) ? [self.lastIndexPath row] : -1;
- if ([indexPath section] != 0) {
+ if ([indexPath section] != 0) {
if (newRow != oldRow) {
NSMutableArray *hogs = [self.teamDictionary objectForKey:@"hedgehogs"];
-
+
NSInteger level = newRow + 1;
for (NSMutableDictionary *hog in hogs)
[hog setObject:[NSNumber numberWithInt:level] forKey:@"level"];
DLog(@"New level is %d",level);
-
+
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
[self.tableView reloadData];
-
+
self.lastIndexPath = indexPath;
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
}
--- a/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitCornersView.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitCornersView.h Sat Jan 26 23:57:37 2013 +0100
@@ -9,18 +9,18 @@
#import <UIKit/UIKit.h>
typedef enum _MGCornersPosition {
- MGCornersPositionLeadingVertical = 0, // top of screen for a left/right split.
- MGCornersPositionTrailingVertical = 1, // bottom of screen for a left/right split.
- MGCornersPositionLeadingHorizontal = 2, // left of screen for a top/bottom split.
- MGCornersPositionTrailingHorizontal = 3 // right of screen for a top/bottom split.
+ MGCornersPositionLeadingVertical = 0, // top of screen for a left/right split.
+ MGCornersPositionTrailingVertical = 1, // bottom of screen for a left/right split.
+ MGCornersPositionLeadingHorizontal = 2, // left of screen for a top/bottom split.
+ MGCornersPositionTrailingHorizontal = 3 // right of screen for a top/bottom split.
} MGCornersPosition;
@class MGSplitViewController;
@interface MGSplitCornersView : UIView {
- float cornerRadius;
- MGSplitViewController *splitViewController;
- MGCornersPosition cornersPosition;
- UIColor *cornerBackgroundColor;
+ float cornerRadius;
+ MGSplitViewController *splitViewController;
+ MGCornersPosition cornersPosition;
+ UIColor *cornerBackgroundColor;
}
@property (nonatomic, assign) float cornerRadius;
--- a/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitCornersView.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitCornersView.m Sat Jan 26 23:57:37 2013 +0100
@@ -19,23 +19,23 @@
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
- self.contentMode = UIViewContentModeRedraw;
- self.userInteractionEnabled = NO;
- self.opaque = NO;
- self.backgroundColor = [UIColor clearColor];
- cornerRadius = 0.0; // actual value is set by the splitViewController.
- cornersPosition = MGCornersPositionLeadingVertical;
+ self.contentMode = UIViewContentModeRedraw;
+ self.userInteractionEnabled = NO;
+ self.opaque = NO;
+ self.backgroundColor = [UIColor clearColor];
+ cornerRadius = 0.0; // actual value is set by the splitViewController.
+ cornersPosition = MGCornersPositionLeadingVertical;
}
-
+
return self;
}
- (void)dealloc
{
- self.cornerBackgroundColor = nil;
-
- [super dealloc];
+ self.cornerBackgroundColor = nil;
+
+ [super dealloc];
}
@@ -45,131 +45,131 @@
- (void)drawRect:(CGRect)rect
{
- // Draw two appropriate corners, with cornerBackgroundColor behind them.
- if (cornerRadius > 0) {
- if (NO) { // just for debugging.
- [[UIColor redColor] set];
- UIRectFill(self.bounds);
- }
-
- float maxX = CGRectGetMaxX(self.bounds);
- float maxY = CGRectGetMaxY(self.bounds);
- UIBezierPath *path = [UIBezierPath bezierPath];
- CGPoint pt = CGPointZero;
- switch (cornersPosition) {
- case MGCornersPositionLeadingVertical: // top of screen for a left/right split
- [path moveToPoint:pt];
- pt.y += cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(90) endAngle:0 clockwise:YES]];
- pt.x += cornerRadius;
- pt.y -= cornerRadius;
- [path addLineToPoint:pt];
- [path addLineToPoint:CGPointZero];
- [path closePath];
-
- pt.x = maxX - cornerRadius;
- pt.y = 0;
- [path moveToPoint:pt];
- pt.y = maxY;
- [path addLineToPoint:pt];
- pt.x += cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(90) clockwise:YES]];
- pt.y -= cornerRadius;
- [path addLineToPoint:pt];
- pt.x -= cornerRadius;
- [path addLineToPoint:pt];
- [path closePath];
-
- break;
-
- case MGCornersPositionTrailingVertical: // bottom of screen for a left/right split
- pt.y = maxY;
- [path moveToPoint:pt];
- pt.y -= cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(270) endAngle:degreesToRadians(360) clockwise:NO]];
- pt.x += cornerRadius;
- pt.y += cornerRadius;
- [path addLineToPoint:pt];
- pt.x -= cornerRadius;
- [path addLineToPoint:pt];
- [path closePath];
-
- pt.x = maxX - cornerRadius;
- pt.y = maxY;
- [path moveToPoint:pt];
- pt.y -= cornerRadius;
- [path addLineToPoint:pt];
- pt.x += cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(270) clockwise:NO]];
- pt.y += cornerRadius;
- [path addLineToPoint:pt];
- pt.x -= cornerRadius;
- [path addLineToPoint:pt];
- [path closePath];
-
- break;
-
- case MGCornersPositionLeadingHorizontal: // left of screen for a top/bottom split
- pt.x = 0;
- pt.y = cornerRadius;
- [path moveToPoint:pt];
- pt.y -= cornerRadius;
- [path addLineToPoint:pt];
- pt.x += cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(270) clockwise:NO]];
- pt.y += cornerRadius;
- [path addLineToPoint:pt];
- pt.x -= cornerRadius;
- [path addLineToPoint:pt];
- [path closePath];
-
- pt.x = 0;
- pt.y = maxY - cornerRadius;
- [path moveToPoint:pt];
- pt.y = maxY;
- [path addLineToPoint:pt];
- pt.x += cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(90) clockwise:YES]];
- pt.y -= cornerRadius;
- [path addLineToPoint:pt];
- pt.x -= cornerRadius;
- [path addLineToPoint:pt];
- [path closePath];
-
- break;
-
- case MGCornersPositionTrailingHorizontal: // right of screen for a top/bottom split
- pt.y = cornerRadius;
- [path moveToPoint:pt];
- pt.y -= cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(270) endAngle:degreesToRadians(360) clockwise:NO]];
- pt.x += cornerRadius;
- pt.y += cornerRadius;
- [path addLineToPoint:pt];
- pt.x -= cornerRadius;
- [path addLineToPoint:pt];
- [path closePath];
-
- pt.y = maxY - cornerRadius;
- [path moveToPoint:pt];
- pt.y += cornerRadius;
- [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(90) endAngle:0 clockwise:YES]];
- pt.x += cornerRadius;
- pt.y -= cornerRadius;
- [path addLineToPoint:pt];
- pt.x -= cornerRadius;
- [path addLineToPoint:pt];
- [path closePath];
-
- break;
-
- default:
- break;
- }
-
- [self.cornerBackgroundColor set];
- [path fill];
- }
+ // Draw two appropriate corners, with cornerBackgroundColor behind them.
+ if (cornerRadius > 0) {
+ if (NO) { // just for debugging.
+ [[UIColor redColor] set];
+ UIRectFill(self.bounds);
+ }
+
+ float maxX = CGRectGetMaxX(self.bounds);
+ float maxY = CGRectGetMaxY(self.bounds);
+ UIBezierPath *path = [UIBezierPath bezierPath];
+ CGPoint pt = CGPointZero;
+ switch (cornersPosition) {
+ case MGCornersPositionLeadingVertical: // top of screen for a left/right split
+ [path moveToPoint:pt];
+ pt.y += cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(90) endAngle:0 clockwise:YES]];
+ pt.x += cornerRadius;
+ pt.y -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path addLineToPoint:CGPointZero];
+ [path closePath];
+
+ pt.x = maxX - cornerRadius;
+ pt.y = 0;
+ [path moveToPoint:pt];
+ pt.y = maxY;
+ [path addLineToPoint:pt];
+ pt.x += cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(90) clockwise:YES]];
+ pt.y -= cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path closePath];
+
+ break;
+
+ case MGCornersPositionTrailingVertical: // bottom of screen for a left/right split
+ pt.y = maxY;
+ [path moveToPoint:pt];
+ pt.y -= cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(270) endAngle:degreesToRadians(360) clockwise:NO]];
+ pt.x += cornerRadius;
+ pt.y += cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path closePath];
+
+ pt.x = maxX - cornerRadius;
+ pt.y = maxY;
+ [path moveToPoint:pt];
+ pt.y -= cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x += cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(270) clockwise:NO]];
+ pt.y += cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path closePath];
+
+ break;
+
+ case MGCornersPositionLeadingHorizontal: // left of screen for a top/bottom split
+ pt.x = 0;
+ pt.y = cornerRadius;
+ [path moveToPoint:pt];
+ pt.y -= cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x += cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(270) clockwise:NO]];
+ pt.y += cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path closePath];
+
+ pt.x = 0;
+ pt.y = maxY - cornerRadius;
+ [path moveToPoint:pt];
+ pt.y = maxY;
+ [path addLineToPoint:pt];
+ pt.x += cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(180) endAngle:degreesToRadians(90) clockwise:YES]];
+ pt.y -= cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path closePath];
+
+ break;
+
+ case MGCornersPositionTrailingHorizontal: // right of screen for a top/bottom split
+ pt.y = cornerRadius;
+ [path moveToPoint:pt];
+ pt.y -= cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(270) endAngle:degreesToRadians(360) clockwise:NO]];
+ pt.x += cornerRadius;
+ pt.y += cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path closePath];
+
+ pt.y = maxY - cornerRadius;
+ [path moveToPoint:pt];
+ pt.y += cornerRadius;
+ [path appendPath:[UIBezierPath bezierPathWithArcCenter:pt radius:cornerRadius startAngle:degreesToRadians(90) endAngle:0 clockwise:YES]];
+ pt.x += cornerRadius;
+ pt.y -= cornerRadius;
+ [path addLineToPoint:pt];
+ pt.x -= cornerRadius;
+ [path addLineToPoint:pt];
+ [path closePath];
+
+ break;
+
+ default:
+ break;
+ }
+
+ [self.cornerBackgroundColor set];
+ [path fill];
+ }
}
@@ -179,38 +179,38 @@
- (void)setCornerRadius:(float)newRadius
{
- if (newRadius != cornerRadius) {
- cornerRadius = newRadius;
- [self setNeedsDisplay];
- }
+ if (newRadius != cornerRadius) {
+ cornerRadius = newRadius;
+ [self setNeedsDisplay];
+ }
}
- (void)setSplitViewController:(MGSplitViewController *)theController
{
- if (theController != splitViewController) {
- splitViewController = theController;
- [self setNeedsDisplay];
- }
+ if (theController != splitViewController) {
+ splitViewController = theController;
+ [self setNeedsDisplay];
+ }
}
- (void)setCornersPosition:(MGCornersPosition)posn
{
- if (cornersPosition != posn) {
- cornersPosition = posn;
- [self setNeedsDisplay];
- }
+ if (cornersPosition != posn) {
+ cornersPosition = posn;
+ [self setNeedsDisplay];
+ }
}
- (void)setCornerBackgroundColor:(UIColor *)color
{
- if (color != cornerBackgroundColor) {
- [cornerBackgroundColor release];
- cornerBackgroundColor = [color retain];
- [self setNeedsDisplay];
- }
+ if (color != cornerBackgroundColor) {
+ [cornerBackgroundColor release];
+ cornerBackgroundColor = [color retain];
+ [self setNeedsDisplay];
+ }
}
--- a/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitDividerView.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitDividerView.h Sat Jan 26 23:57:37 2013 +0100
@@ -10,8 +10,8 @@
@class MGSplitViewController;
@interface MGSplitDividerView : UIView {
- MGSplitViewController *splitViewController;
- BOOL allowsDragging;
+ MGSplitViewController *splitViewController;
+ BOOL allowsDragging;
}
@property (nonatomic, assign) MGSplitViewController *splitViewController; // weak ref.
--- a/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitDividerView.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitDividerView.m Sat Jan 26 23:57:37 2013 +0100
@@ -19,19 +19,19 @@
- (id)initWithFrame:(CGRect)frame
{
- if ((self = [super initWithFrame:frame])) {
- self.userInteractionEnabled = NO;
- self.allowsDragging = NO;
- self.contentMode = UIViewContentModeRedraw;
- }
- return self;
+ if ((self = [super initWithFrame:frame])) {
+ self.userInteractionEnabled = NO;
+ self.allowsDragging = NO;
+ self.contentMode = UIViewContentModeRedraw;
+ }
+ return self;
}
- (void)dealloc
{
- self.splitViewController = nil;
- [super dealloc];
+ self.splitViewController = nil;
+ [super dealloc];
}
@@ -41,139 +41,139 @@
- (void)drawRect:(CGRect)rect
{
- if (splitViewController.dividerStyle == MGSplitViewDividerStyleThin) {
- [super drawRect:rect];
-
- } else if (splitViewController.dividerStyle == MGSplitViewDividerStylePaneSplitter) {
- // Draw gradient background.
- CGRect bounds = self.bounds;
- CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
- CGFloat locations[2] = {0, 1};
- CGFloat components[8] = { 0.988, 0.988, 0.988, 1.0, // light
- 0.875, 0.875, 0.875, 1.0 };// dark
- CGGradientRef gradient = CGGradientCreateWithColorComponents (rgb, components, locations, 2);
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGPoint start, end;
- if (splitViewController.vertical) {
- // Light left to dark right.
- start = CGPointMake(CGRectGetMinX(bounds), CGRectGetMidY(bounds));
- end = CGPointMake(CGRectGetMaxX(bounds), CGRectGetMidY(bounds));
- } else {
- // Light top to dark bottom.
- start = CGPointMake(CGRectGetMidX(bounds), CGRectGetMinY(bounds));
- end = CGPointMake(CGRectGetMidX(bounds), CGRectGetMaxY(bounds));
- }
- CGContextDrawLinearGradient(context, gradient, start, end, 0);
- CGColorSpaceRelease(rgb);
- CGGradientRelease(gradient);
-
- // Draw borders.
- float borderThickness = 1.0;
- [[UIColor colorWithWhite:0.7 alpha:1.0] set];
- CGRect borderRect = bounds;
- if (splitViewController.vertical) {
- borderRect.size.width = borderThickness;
- UIRectFill(borderRect);
- borderRect.origin.x = CGRectGetMaxX(bounds) - borderThickness;
- UIRectFill(borderRect);
-
- } else {
- borderRect.size.height = borderThickness;
- UIRectFill(borderRect);
- borderRect.origin.y = CGRectGetMaxY(bounds) - borderThickness;
- UIRectFill(borderRect);
- }
-
- // Draw grip.
- [self drawGripThumbInRect:bounds];
- }
+ if (splitViewController.dividerStyle == MGSplitViewDividerStyleThin) {
+ [super drawRect:rect];
+
+ } else if (splitViewController.dividerStyle == MGSplitViewDividerStylePaneSplitter) {
+ // Draw gradient background.
+ CGRect bounds = self.bounds;
+ CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
+ CGFloat locations[2] = {0, 1};
+ CGFloat components[8] = { 0.988, 0.988, 0.988, 1.0, // light
+ 0.875, 0.875, 0.875, 1.0 };// dark
+ CGGradientRef gradient = CGGradientCreateWithColorComponents (rgb, components, locations, 2);
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ CGPoint start, end;
+ if (splitViewController.vertical) {
+ // Light left to dark right.
+ start = CGPointMake(CGRectGetMinX(bounds), CGRectGetMidY(bounds));
+ end = CGPointMake(CGRectGetMaxX(bounds), CGRectGetMidY(bounds));
+ } else {
+ // Light top to dark bottom.
+ start = CGPointMake(CGRectGetMidX(bounds), CGRectGetMinY(bounds));
+ end = CGPointMake(CGRectGetMidX(bounds), CGRectGetMaxY(bounds));
+ }
+ CGContextDrawLinearGradient(context, gradient, start, end, 0);
+ CGColorSpaceRelease(rgb);
+ CGGradientRelease(gradient);
+
+ // Draw borders.
+ float borderThickness = 1.0;
+ [[UIColor colorWithWhite:0.7 alpha:1.0] set];
+ CGRect borderRect = bounds;
+ if (splitViewController.vertical) {
+ borderRect.size.width = borderThickness;
+ UIRectFill(borderRect);
+ borderRect.origin.x = CGRectGetMaxX(bounds) - borderThickness;
+ UIRectFill(borderRect);
+
+ } else {
+ borderRect.size.height = borderThickness;
+ UIRectFill(borderRect);
+ borderRect.origin.y = CGRectGetMaxY(bounds) - borderThickness;
+ UIRectFill(borderRect);
+ }
+
+ // Draw grip.
+ [self drawGripThumbInRect:bounds];
+ }
}
- (void)drawGripThumbInRect:(CGRect)rect
{
- float width = 9.0;
- float height;
- if (splitViewController.vertical) {
- height = 30.0;
- } else {
- height = width;
- width = 30.0;
- }
-
- // Draw grip in centred in rect.
- CGRect gripRect = CGRectMake(0, 0, width, height);
- gripRect.origin.x = ((rect.size.width - gripRect.size.width) / 2.0);
- gripRect.origin.y = ((rect.size.height - gripRect.size.height) / 2.0);
-
- float stripThickness = 1.0;
- UIColor *stripColor = [UIColor colorWithWhite:0.35 alpha:1.0];
- UIColor *lightColor = [UIColor colorWithWhite:1.0 alpha:1.0];
- float space = 3.0;
- if (splitViewController.vertical) {
- gripRect.size.width = stripThickness;
- [stripColor set];
- UIRectFill(gripRect);
-
- gripRect.origin.x += stripThickness;
- gripRect.origin.y += 1;
- [lightColor set];
- UIRectFill(gripRect);
- gripRect.origin.x -= stripThickness;
- gripRect.origin.y -= 1;
-
- gripRect.origin.x += space + stripThickness;
- [stripColor set];
- UIRectFill(gripRect);
-
- gripRect.origin.x += stripThickness;
- gripRect.origin.y += 1;
- [lightColor set];
- UIRectFill(gripRect);
- gripRect.origin.x -= stripThickness;
- gripRect.origin.y -= 1;
-
- gripRect.origin.x += space + stripThickness;
- [stripColor set];
- UIRectFill(gripRect);
-
- gripRect.origin.x += stripThickness;
- gripRect.origin.y += 1;
- [lightColor set];
- UIRectFill(gripRect);
-
- } else {
- gripRect.size.height = stripThickness;
- [stripColor set];
- UIRectFill(gripRect);
-
- gripRect.origin.y += stripThickness;
- gripRect.origin.x -= 1;
- [lightColor set];
- UIRectFill(gripRect);
- gripRect.origin.y -= stripThickness;
- gripRect.origin.x += 1;
-
- gripRect.origin.y += space + stripThickness;
- [stripColor set];
- UIRectFill(gripRect);
-
- gripRect.origin.y += stripThickness;
- gripRect.origin.x -= 1;
- [lightColor set];
- UIRectFill(gripRect);
- gripRect.origin.y -= stripThickness;
- gripRect.origin.x += 1;
-
- gripRect.origin.y += space + stripThickness;
- [stripColor set];
- UIRectFill(gripRect);
-
- gripRect.origin.y += stripThickness;
- gripRect.origin.x -= 1;
- [lightColor set];
- UIRectFill(gripRect);
- }
+ float width = 9.0;
+ float height;
+ if (splitViewController.vertical) {
+ height = 30.0;
+ } else {
+ height = width;
+ width = 30.0;
+ }
+
+ // Draw grip in centred in rect.
+ CGRect gripRect = CGRectMake(0, 0, width, height);
+ gripRect.origin.x = ((rect.size.width - gripRect.size.width) / 2.0);
+ gripRect.origin.y = ((rect.size.height - gripRect.size.height) / 2.0);
+
+ float stripThickness = 1.0;
+ UIColor *stripColor = [UIColor colorWithWhite:0.35 alpha:1.0];
+ UIColor *lightColor = [UIColor colorWithWhite:1.0 alpha:1.0];
+ float space = 3.0;
+ if (splitViewController.vertical) {
+ gripRect.size.width = stripThickness;
+ [stripColor set];
+ UIRectFill(gripRect);
+
+ gripRect.origin.x += stripThickness;
+ gripRect.origin.y += 1;
+ [lightColor set];
+ UIRectFill(gripRect);
+ gripRect.origin.x -= stripThickness;
+ gripRect.origin.y -= 1;
+
+ gripRect.origin.x += space + stripThickness;
+ [stripColor set];
+ UIRectFill(gripRect);
+
+ gripRect.origin.x += stripThickness;
+ gripRect.origin.y += 1;
+ [lightColor set];
+ UIRectFill(gripRect);
+ gripRect.origin.x -= stripThickness;
+ gripRect.origin.y -= 1;
+
+ gripRect.origin.x += space + stripThickness;
+ [stripColor set];
+ UIRectFill(gripRect);
+
+ gripRect.origin.x += stripThickness;
+ gripRect.origin.y += 1;
+ [lightColor set];
+ UIRectFill(gripRect);
+
+ } else {
+ gripRect.size.height = stripThickness;
+ [stripColor set];
+ UIRectFill(gripRect);
+
+ gripRect.origin.y += stripThickness;
+ gripRect.origin.x -= 1;
+ [lightColor set];
+ UIRectFill(gripRect);
+ gripRect.origin.y -= stripThickness;
+ gripRect.origin.x += 1;
+
+ gripRect.origin.y += space + stripThickness;
+ [stripColor set];
+ UIRectFill(gripRect);
+
+ gripRect.origin.y += stripThickness;
+ gripRect.origin.x -= 1;
+ [lightColor set];
+ UIRectFill(gripRect);
+ gripRect.origin.y -= stripThickness;
+ gripRect.origin.x += 1;
+
+ gripRect.origin.y += space + stripThickness;
+ [stripColor set];
+ UIRectFill(gripRect);
+
+ gripRect.origin.y += stripThickness;
+ gripRect.origin.x -= 1;
+ [lightColor set];
+ UIRectFill(gripRect);
+ }
}
@@ -183,16 +183,16 @@
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
- UITouch *touch = [touches anyObject];
- if (touch) {
- CGPoint lastPt = [touch previousLocationInView:self];
- CGPoint pt = [touch locationInView:self];
- float offset = (splitViewController.vertical) ? pt.x - lastPt.x : pt.y - lastPt.y;
- if (!splitViewController.masterBeforeDetail) {
- offset = -offset;
- }
- splitViewController.splitPosition = splitViewController.splitPosition + offset;
- }
+ UITouch *touch = [touches anyObject];
+ if (touch) {
+ CGPoint lastPt = [touch previousLocationInView:self];
+ CGPoint pt = [touch locationInView:self];
+ float offset = (splitViewController.vertical) ? pt.x - lastPt.x : pt.y - lastPt.y;
+ if (!splitViewController.masterBeforeDetail) {
+ offset = -offset;
+ }
+ splitViewController.splitPosition = splitViewController.splitPosition + offset;
+ }
}
@@ -202,10 +202,10 @@
- (void)setAllowsDragging:(BOOL)flag
{
- if (flag != allowsDragging) {
- allowsDragging = flag;
- self.userInteractionEnabled = allowsDragging;
- }
+ if (flag != allowsDragging) {
+ allowsDragging = flag;
+ self.userInteractionEnabled = allowsDragging;
+ }
}
--- a/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitViewController.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitViewController.h Sat Jan 26 23:57:37 2013 +0100
@@ -9,28 +9,28 @@
#import <UIKit/UIKit.h>
typedef enum _MGSplitViewDividerStyle {
- // These names have been chosen to be conceptually similar to those of NSSplitView on Mac OS X.
- MGSplitViewDividerStyleThin = 0, // Thin divider, like UISplitViewController (default).
- MGSplitViewDividerStylePaneSplitter = 1 // Thick divider, drawn with a grey gradient and a grab-strip.
+ // These names have been chosen to be conceptually similar to those of NSSplitView on Mac OS X.
+ MGSplitViewDividerStyleThin = 0, // Thin divider, like UISplitViewController (default).
+ MGSplitViewDividerStylePaneSplitter = 1 // Thick divider, drawn with a grey gradient and a grab-strip.
} MGSplitViewDividerStyle;
@class MGSplitDividerView;
@protocol MGSplitViewControllerDelegate;
@interface MGSplitViewController : UIViewController <UIPopoverControllerDelegate> {
- BOOL _showsMasterInPortrait;
- BOOL _showsMasterInLandscape;
- float _splitWidth;
- id _delegate;
- BOOL _vertical;
- BOOL _masterBeforeDetail;
- NSMutableArray *_viewControllers;
- UIBarButtonItem *_barButtonItem; // To be compliant with wacky UISplitViewController behaviour.
+ BOOL _showsMasterInPortrait;
+ BOOL _showsMasterInLandscape;
+ float _splitWidth;
+ id _delegate;
+ BOOL _vertical;
+ BOOL _masterBeforeDetail;
+ NSMutableArray *_viewControllers;
+ UIBarButtonItem *_barButtonItem; // To be compliant with wacky UISplitViewController behaviour.
UIPopoverController *_hiddenPopoverController; // Popover used to hold the master view if it's not always visible.
- MGSplitDividerView *_dividerView; // View that draws the divider between the master and detail views.
- NSArray *_cornerViews; // Views to draw the inner rounded corners between master and detail views.
- float _splitPosition;
- BOOL _reconfigurePopup;
- MGSplitViewDividerStyle _dividerStyle; // Meta-setting which configures several aspects of appearance and behaviour.
+ MGSplitDividerView *_dividerView; // View that draws the divider between the master and detail views.
+ NSArray *_cornerViews; // Views to draw the inner rounded corners between master and detail views.
+ float _splitPosition;
+ BOOL _reconfigurePopup;
+ MGSplitViewDividerStyle _dividerStyle; // Meta-setting which configures several aspects of appearance and behaviour.
}
@property (nonatomic, assign) IBOutlet id <MGSplitViewControllerDelegate> delegate;
@@ -60,14 +60,14 @@
// Conveniences for you, because I care.
- (BOOL)isShowingMaster;
- (void)setSplitPosition:(float)posn animated:(BOOL)animate; // Allows for animation of splitPosition changes. The property's regular setter is not animated.
-/* Note: splitPosition is the width (in a left/right split, or height in a top/bottom split) of the master view.
- It is relative to the appropriate side of the splitView, which can be any of the four sides depending on the values in isMasterBeforeDetail and isVertical:
- isVertical = YES, isMasterBeforeDetail = YES: splitPosition is relative to the LEFT edge. (Default)
- isVertical = YES, isMasterBeforeDetail = NO: splitPosition is relative to the RIGHT edge.
- isVertical = NO, isMasterBeforeDetail = YES: splitPosition is relative to the TOP edge.
- isVertical = NO, isMasterBeforeDetail = NO: splitPosition is relative to the BOTTOM edge.
+/* Note: splitPosition is the width (in a left/right split, or height in a top/bottom split) of the master view.
+ It is relative to the appropriate side of the splitView, which can be any of the four sides depending on the values in isMasterBeforeDetail and isVertical:
+ isVertical = YES, isMasterBeforeDetail = YES: splitPosition is relative to the LEFT edge. (Default)
+ isVertical = YES, isMasterBeforeDetail = NO: splitPosition is relative to the RIGHT edge.
+ isVertical = NO, isMasterBeforeDetail = YES: splitPosition is relative to the TOP edge.
+ isVertical = NO, isMasterBeforeDetail = NO: splitPosition is relative to the BOTTOM edge.
- This implementation was chosen so you don't need to recalculate equivalent splitPositions if the user toggles masterBeforeDetail themselves.
+ This implementation was chosen so you don't need to recalculate equivalent splitPositions if the user toggles masterBeforeDetail themselves.
*/
- (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle animated:(BOOL)animate; // Allows for animation of dividerStyle changes. The property's regular setter is not animated.
- (NSArray *)cornerViews;
@@ -76,8 +76,8 @@
The first view is the "leading" corners (top edge of screen for left/right split, left edge of screen for top/bottom split).
The second view is the "trailing" corners (bottom edge of screen for left/right split, right edge of screen for top/bottom split).
Do NOT modify them, except to:
- 1. Change their .cornerBackgroundColor
- 2. Change their .cornerRadius
+ 1. Change their .cornerBackgroundColor
+ 2. Change their .cornerRadius
*/
@end
@@ -88,19 +88,19 @@
@optional
// Called when a button should be added to a toolbar for a hidden view controller.
-- (void)splitViewController:(MGSplitViewController*)svc
- willHideViewController:(UIViewController *)aViewController
- withBarButtonItem:(UIBarButtonItem*)barButtonItem
- forPopoverController: (UIPopoverController*)pc;
+- (void)splitViewController:(MGSplitViewController*)svc
+ willHideViewController:(UIViewController *)aViewController
+ withBarButtonItem:(UIBarButtonItem*)barButtonItem
+ forPopoverController: (UIPopoverController*)pc;
// Called when the master view is shown again in the split view, invalidating the button and popover controller.
-- (void)splitViewController:(MGSplitViewController*)svc
- willShowViewController:(UIViewController *)aViewController
+- (void)splitViewController:(MGSplitViewController*)svc
+ willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem;
// Called when the master view is shown in a popover, so the delegate can take action like hiding other popovers.
-- (void)splitViewController:(MGSplitViewController*)svc
- popoverController:(UIPopoverController*)pc
+- (void)splitViewController:(MGSplitViewController*)svc
+ popoverController:(UIPopoverController*)pc
willPresentViewController:(UIViewController *)aViewController;
// Called when the split orientation will change (from vertical to horizontal, or vice versa).
--- a/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -10,18 +10,18 @@
#import "MGSplitDividerView.h"
#import "MGSplitCornersView.h"
-#define MG_DEFAULT_SPLIT_POSITION 320.0 // default width of master view in UISplitViewController.
-#define MG_DEFAULT_SPLIT_WIDTH 1.0 // default width of split-gutter in UISplitViewController.
-#define MG_DEFAULT_CORNER_RADIUS 5.0 // default corner-radius of overlapping split-inner corners on the master and detail views.
-#define MG_DEFAULT_CORNER_COLOR [UIColor blackColor] // default color of intruding inner corners (and divider background).
+#define MG_DEFAULT_SPLIT_POSITION 320.0 // default width of master view in UISplitViewController.
+#define MG_DEFAULT_SPLIT_WIDTH 1.0 // default width of split-gutter in UISplitViewController.
+#define MG_DEFAULT_CORNER_RADIUS 5.0 // default corner-radius of overlapping split-inner corners on the master and detail views.
+#define MG_DEFAULT_CORNER_COLOR [UIColor blackColor] // default color of intruding inner corners (and divider background).
-#define MG_PANESPLITTER_CORNER_RADIUS 0.0 // corner-radius of split-inner corners for MGSplitViewDividerStylePaneSplitter style.
-#define MG_PANESPLITTER_SPLIT_WIDTH 25.0 // width of split-gutter for MGSplitViewDividerStylePaneSplitter style.
+#define MG_PANESPLITTER_CORNER_RADIUS 0.0 // corner-radius of split-inner corners for MGSplitViewDividerStylePaneSplitter style.
+#define MG_PANESPLITTER_SPLIT_WIDTH 25.0 // width of split-gutter for MGSplitViewDividerStylePaneSplitter style.
-#define MG_MIN_VIEW_WIDTH 200.0 // minimum width a view is allowed to become as a result of changing the splitPosition.
+#define MG_MIN_VIEW_WIDTH 200.0 // minimum width a view is allowed to become as a result of changing the splitPosition.
-#define MG_ANIMATION_CHANGE_SPLIT_ORIENTATION @"ChangeSplitOrientation" // Animation ID for internal use.
-#define MG_ANIMATION_CHANGE_SUBVIEWS_ORDER @"ChangeSubviewsOrder" // Animation ID for internal use.
+#define MG_ANIMATION_CHANGE_SPLIT_ORIENTATION @"ChangeSplitOrientation" // Animation ID for internal use.
+#define MG_ANIMATION_CHANGE_SUBVIEWS_ORDER @"ChangeSubviewsOrder" // Animation ID for internal use.
@interface MGSplitViewController (MGPrivateMethods)
@@ -48,50 +48,50 @@
- (NSString *)nameOfInterfaceOrientation:(UIInterfaceOrientation)theOrientation
{
- NSString *orientationName = nil;
- switch (theOrientation) {
- case UIInterfaceOrientationPortrait:
- orientationName = @"Portrait"; // Home button at bottom
- break;
- case UIInterfaceOrientationPortraitUpsideDown:
- orientationName = @"Portrait (Upside Down)"; // Home button at top
- break;
- case UIInterfaceOrientationLandscapeLeft:
- orientationName = @"Landscape (Left)"; // Home button on left
- break;
- case UIInterfaceOrientationLandscapeRight:
- orientationName = @"Landscape (Right)"; // Home button on right
- break;
- default:
- break;
- }
-
- return orientationName;
+ NSString *orientationName = nil;
+ switch (theOrientation) {
+ case UIInterfaceOrientationPortrait:
+ orientationName = @"Portrait"; // Home button at bottom
+ break;
+ case UIInterfaceOrientationPortraitUpsideDown:
+ orientationName = @"Portrait (Upside Down)"; // Home button at top
+ break;
+ case UIInterfaceOrientationLandscapeLeft:
+ orientationName = @"Landscape (Left)"; // Home button on left
+ break;
+ case UIInterfaceOrientationLandscapeRight:
+ orientationName = @"Landscape (Right)"; // Home button on right
+ break;
+ default:
+ break;
+ }
+
+ return orientationName;
}
- (BOOL)isLandscape
{
- return UIInterfaceOrientationIsLandscape(self.interfaceOrientation);
+ return UIInterfaceOrientationIsLandscape(self.interfaceOrientation);
}
- (BOOL)shouldShowMasterForInterfaceOrientation:(UIInterfaceOrientation)theOrientation
{
- // Returns YES if master view should be shown directly embedded in the splitview, instead of hidden in a popover.
- return ((UIInterfaceOrientationIsLandscape(theOrientation)) ? _showsMasterInLandscape : _showsMasterInPortrait);
+ // Returns YES if master view should be shown directly embedded in the splitview, instead of hidden in a popover.
+ return ((UIInterfaceOrientationIsLandscape(theOrientation)) ? _showsMasterInLandscape : _showsMasterInPortrait);
}
- (BOOL)shouldShowMaster
{
- return [self shouldShowMasterForInterfaceOrientation:self.interfaceOrientation];
+ return [self shouldShowMasterForInterfaceOrientation:self.interfaceOrientation];
}
- (BOOL)isShowingMaster
{
- return [self shouldShowMaster] && self.masterViewController && self.masterViewController.view && ([self.masterViewController.view superview] == self.view);
+ return [self shouldShowMaster] && self.masterViewController && self.masterViewController.view && ([self.masterViewController.view superview] == self.view);
}
@@ -101,61 +101,61 @@
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
- if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
- [self setup];
- }
-
- return self;
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
+ [self setup];
+ }
+
+ return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
- if ((self = [super initWithCoder:aDecoder])) {
- [self setup];
- }
-
- return self;
+ if ((self = [super initWithCoder:aDecoder])) {
+ [self setup];
+ }
+
+ return self;
}
- (void)setup
{
- // Configure default behaviour.
- _viewControllers = [[NSMutableArray alloc] initWithObjects:[NSNull null], [NSNull null], nil];
- _splitWidth = MG_DEFAULT_SPLIT_WIDTH;
- _showsMasterInPortrait = NO;
- _showsMasterInLandscape = YES;
- _reconfigurePopup = NO;
- _vertical = YES;
- _masterBeforeDetail = YES;
- _splitPosition = MG_DEFAULT_SPLIT_POSITION;
- CGRect divRect = self.view.bounds;
- if ([self isVertical]) {
- divRect.origin.y = _splitPosition;
- divRect.size.height = _splitWidth;
- } else {
- divRect.origin.x = _splitPosition;
- divRect.size.width = _splitWidth;
- }
- _dividerView = [[MGSplitDividerView alloc] initWithFrame:divRect];
- _dividerView.splitViewController = self;
- _dividerView.backgroundColor = MG_DEFAULT_CORNER_COLOR;
- _dividerStyle = MGSplitViewDividerStyleThin;
+ // Configure default behaviour.
+ _viewControllers = [[NSMutableArray alloc] initWithObjects:[NSNull null], [NSNull null], nil];
+ _splitWidth = MG_DEFAULT_SPLIT_WIDTH;
+ _showsMasterInPortrait = NO;
+ _showsMasterInLandscape = YES;
+ _reconfigurePopup = NO;
+ _vertical = YES;
+ _masterBeforeDetail = YES;
+ _splitPosition = MG_DEFAULT_SPLIT_POSITION;
+ CGRect divRect = self.view.bounds;
+ if ([self isVertical]) {
+ divRect.origin.y = _splitPosition;
+ divRect.size.height = _splitWidth;
+ } else {
+ divRect.origin.x = _splitPosition;
+ divRect.size.width = _splitWidth;
+ }
+ _dividerView = [[MGSplitDividerView alloc] initWithFrame:divRect];
+ _dividerView.splitViewController = self;
+ _dividerView.backgroundColor = MG_DEFAULT_CORNER_COLOR;
+ _dividerStyle = MGSplitViewDividerStyleThin;
}
- (void)dealloc
{
- _delegate = nil;
- [self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
- [_viewControllers release];
- [_barButtonItem release];
- [_hiddenPopoverController release];
- [_dividerView release];
- [_cornerViews release];
-
- [super dealloc];
+ _delegate = nil;
+ [self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
+ [_viewControllers release];
+ [_barButtonItem release];
+ [_hiddenPopoverController release];
+ [_dividerView release];
+ [_cornerViews release];
+
+ [super dealloc];
}
@@ -171,371 +171,371 @@
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
- [self.masterViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
- [self.detailViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
+ [self.masterViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
+ [self.detailViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
- [self.masterViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
- [self.detailViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
+ [self.masterViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
+ [self.detailViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
-- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
- duration:(NSTimeInterval)duration
+- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
+ duration:(NSTimeInterval)duration
{
- [self.masterViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
- [self.detailViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
-
- // Hide popover.
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- // Re-tile views.
- _reconfigurePopup = YES;
- [self layoutSubviewsForInterfaceOrientation:toInterfaceOrientation withAnimation:YES];
+ [self.masterViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
+ [self.detailViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
+
+ // Hide popover.
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ // Re-tile views.
+ _reconfigurePopup = YES;
+ [self layoutSubviewsForInterfaceOrientation:toInterfaceOrientation withAnimation:YES];
}
- (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
- [self.masterViewController willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
- [self.detailViewController willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
+ [self.masterViewController willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
+ [self.detailViewController willAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
- (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
- [self.masterViewController didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
- [self.detailViewController didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
+ [self.masterViewController didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
+ [self.detailViewController didAnimateFirstHalfOfRotationToInterfaceOrientation:toInterfaceOrientation];
}
- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration
{
- [self.masterViewController willAnimateSecondHalfOfRotationFromInterfaceOrientation:fromInterfaceOrientation duration:duration];
- [self.detailViewController willAnimateSecondHalfOfRotationFromInterfaceOrientation:fromInterfaceOrientation duration:duration];
+ [self.masterViewController willAnimateSecondHalfOfRotationFromInterfaceOrientation:fromInterfaceOrientation duration:duration];
+ [self.detailViewController willAnimateSecondHalfOfRotationFromInterfaceOrientation:fromInterfaceOrientation duration:duration];
}
- (CGSize)splitViewSizeForOrientation:(UIInterfaceOrientation)theOrientation
{
- UIScreen *screen = [UIScreen mainScreen];
- CGRect fullScreenRect = screen.bounds; // always implicitly in Portrait orientation.
- CGRect appFrame = screen.applicationFrame;
-
- // Find status bar height by checking which dimension of the applicationFrame is narrower than screen bounds.
- // Little bit ugly looking, but it'll still work even if they change the status bar height in future.
- float statusBarHeight = MAX((fullScreenRect.size.width - appFrame.size.width), (fullScreenRect.size.height - appFrame.size.height));
-
- // Initially assume portrait orientation.
- float width = fullScreenRect.size.width;
- float height = fullScreenRect.size.height;
-
- // Correct for orientation.
- if (UIInterfaceOrientationIsLandscape(theOrientation)) {
- width = height;
- height = fullScreenRect.size.width;
- }
-
- // Account for status bar, which always subtracts from the height (since it's always at the top of the screen).
- height -= statusBarHeight;
-
- return CGSizeMake(width, height);
+ UIScreen *screen = [UIScreen mainScreen];
+ CGRect fullScreenRect = screen.bounds; // always implicitly in Portrait orientation.
+ CGRect appFrame = screen.applicationFrame;
+
+ // Find status bar height by checking which dimension of the applicationFrame is narrower than screen bounds.
+ // Little bit ugly looking, but it'll still work even if they change the status bar height in future.
+ float statusBarHeight = MAX((fullScreenRect.size.width - appFrame.size.width), (fullScreenRect.size.height - appFrame.size.height));
+
+ // Initially assume portrait orientation.
+ float width = fullScreenRect.size.width;
+ float height = fullScreenRect.size.height;
+
+ // Correct for orientation.
+ if (UIInterfaceOrientationIsLandscape(theOrientation)) {
+ width = height;
+ height = fullScreenRect.size.width;
+ }
+
+ // Account for status bar, which always subtracts from the height (since it's always at the top of the screen).
+ height -= statusBarHeight;
+
+ return CGSizeMake(width, height);
}
- (void)layoutSubviewsForInterfaceOrientation:(UIInterfaceOrientation)theOrientation withAnimation:(BOOL)animate
{
- if (_reconfigurePopup) {
- [self reconfigureForMasterInPopover:![self shouldShowMasterForInterfaceOrientation:theOrientation]];
- }
-
- // Layout the master, detail and divider views appropriately, adding/removing subviews as needed.
- // First obtain relevant geometry.
- CGSize fullSize = [self splitViewSizeForOrientation:theOrientation];
- float width = fullSize.width;
- float height = fullSize.height;
-
- if (NO) { // Just for debugging.
- NSLog(@"Target orientation is %@, dimensions will be %.0f x %.0f",
- [self nameOfInterfaceOrientation:theOrientation], width, height);
- }
-
- // Layout the master, divider and detail views.
- CGRect newFrame = CGRectMake(0, 0, width, height);
- UIViewController *controller;
- UIView *theView;
- BOOL shouldShowMaster = [self shouldShowMasterForInterfaceOrientation:theOrientation];
- BOOL masterFirst = [self isMasterBeforeDetail];
- if ([self isVertical]) {
- // Master on left, detail on right (or vice versa).
- CGRect masterRect, dividerRect, detailRect;
- if (masterFirst) {
- if (!shouldShowMaster) {
- // Move off-screen.
- newFrame.origin.x -= (_splitPosition + _splitWidth);
- }
-
- newFrame.size.width = _splitPosition;
- masterRect = newFrame;
-
- newFrame.origin.x += newFrame.size.width;
- newFrame.size.width = _splitWidth;
- dividerRect = newFrame;
-
- newFrame.origin.x += newFrame.size.width;
- newFrame.size.width = width - newFrame.origin.x;
- detailRect = newFrame;
-
- } else {
- if (!shouldShowMaster) {
- // Move off-screen.
- newFrame.size.width += (_splitPosition + _splitWidth);
- }
-
- newFrame.size.width -= (_splitPosition + _splitWidth);
- detailRect = newFrame;
-
- newFrame.origin.x += newFrame.size.width;
- newFrame.size.width = _splitWidth;
- dividerRect = newFrame;
-
- newFrame.origin.x += newFrame.size.width;
- newFrame.size.width = _splitPosition;
- masterRect = newFrame;
- }
-
- // Position master.
- controller = self.masterViewController;
- if (controller && [controller isKindOfClass:[UIViewController class]]) {
- theView = controller.view;
- if (theView) {
- theView.frame = masterRect;
- if (!theView.superview) {
- [controller viewWillAppear:NO];
- [self.view addSubview:theView];
- [controller viewDidAppear:NO];
- }
- }
- }
-
- // Position divider.
- theView = _dividerView;
- theView.frame = dividerRect;
- if (!theView.superview) {
- [self.view addSubview:theView];
- }
-
- // Position detail.
- controller = self.detailViewController;
- if (controller && [controller isKindOfClass:[UIViewController class]]) {
- theView = controller.view;
- if (theView) {
- theView.frame = detailRect;
- if (!theView.superview) {
- [self.view insertSubview:theView aboveSubview:self.masterViewController.view];
- } else {
- [self.view bringSubviewToFront:theView];
- }
- }
- }
-
- } else {
- // Master above, detail below (or vice versa).
- CGRect masterRect, dividerRect, detailRect;
- if (masterFirst) {
- if (!shouldShowMaster) {
- // Move off-screen.
- newFrame.origin.y -= (_splitPosition + _splitWidth);
- }
-
- newFrame.size.height = _splitPosition;
- masterRect = newFrame;
-
- newFrame.origin.y += newFrame.size.height;
- newFrame.size.height = _splitWidth;
- dividerRect = newFrame;
-
- newFrame.origin.y += newFrame.size.height;
- newFrame.size.height = height - newFrame.origin.y;
- detailRect = newFrame;
-
- } else {
- if (!shouldShowMaster) {
- // Move off-screen.
- newFrame.size.height += (_splitPosition + _splitWidth);
- }
-
- newFrame.size.height -= (_splitPosition + _splitWidth);
- detailRect = newFrame;
-
- newFrame.origin.y += newFrame.size.height;
- newFrame.size.height = _splitWidth;
- dividerRect = newFrame;
-
- newFrame.origin.y += newFrame.size.height;
- newFrame.size.height = _splitPosition;
- masterRect = newFrame;
- }
-
- // Position master.
- controller = self.masterViewController;
- if (controller && [controller isKindOfClass:[UIViewController class]]) {
- theView = controller.view;
- if (theView) {
- theView.frame = masterRect;
- if (!theView.superview) {
- [controller viewWillAppear:NO];
- [self.view addSubview:theView];
- [controller viewDidAppear:NO];
- }
- }
- }
-
- // Position divider.
- theView = _dividerView;
- theView.frame = dividerRect;
- if (!theView.superview) {
- [self.view addSubview:theView];
- }
-
- // Position detail.
- controller = self.detailViewController;
- if (controller && [controller isKindOfClass:[UIViewController class]]) {
- theView = controller.view;
- if (theView) {
- theView.frame = detailRect;
- if (!theView.superview) {
- [self.view insertSubview:theView aboveSubview:self.masterViewController.view];
- } else {
- [self.view bringSubviewToFront:theView];
- }
- }
- }
- }
-
- // Create corner views if necessary.
- MGSplitCornersView *leadingCorners; // top/left of screen in vertical/horizontal split.
- MGSplitCornersView *trailingCorners; // bottom/right of screen in vertical/horizontal split.
- if (!_cornerViews) {
- CGRect cornerRect = CGRectMake(0, 0, 10, 10); // arbitrary, will be resized below.
- leadingCorners = [[MGSplitCornersView alloc] initWithFrame:cornerRect];
- leadingCorners.splitViewController = self;
- leadingCorners.cornerBackgroundColor = MG_DEFAULT_CORNER_COLOR;
- leadingCorners.cornerRadius = MG_DEFAULT_CORNER_RADIUS;
- trailingCorners = [[MGSplitCornersView alloc] initWithFrame:cornerRect];
- trailingCorners.splitViewController = self;
- trailingCorners.cornerBackgroundColor = MG_DEFAULT_CORNER_COLOR;
- trailingCorners.cornerRadius = MG_DEFAULT_CORNER_RADIUS;
- _cornerViews = [[NSArray alloc] initWithObjects:leadingCorners, trailingCorners, nil];
- [leadingCorners release];
- [trailingCorners release];
-
- } else if ([_cornerViews count] == 2) {
- leadingCorners = [_cornerViews objectAtIndex:0];
- trailingCorners = [_cornerViews objectAtIndex:1];
- }
-
- // Configure and layout the corner-views.
- leadingCorners.cornersPosition = (_vertical) ? MGCornersPositionLeadingVertical : MGCornersPositionLeadingHorizontal;
- trailingCorners.cornersPosition = (_vertical) ? MGCornersPositionTrailingVertical : MGCornersPositionTrailingHorizontal;
- leadingCorners.autoresizingMask = (_vertical) ? UIViewAutoresizingFlexibleBottomMargin : UIViewAutoresizingFlexibleRightMargin;
- trailingCorners.autoresizingMask = (_vertical) ? UIViewAutoresizingFlexibleTopMargin : UIViewAutoresizingFlexibleLeftMargin;
-
- float x, y, cornersWidth, cornersHeight;
- CGRect leadingRect, trailingRect;
- float radius = leadingCorners.cornerRadius;
- if (_vertical) { // left/right split
- cornersWidth = (radius * 2.0) + _splitWidth;
- cornersHeight = radius;
- x = ((shouldShowMaster) ? ((masterFirst) ? _splitPosition : width - (_splitPosition + _splitWidth)) : (0 - _splitWidth)) - radius;
- y = 0;
- leadingRect = CGRectMake(x, y, cornersWidth, cornersHeight); // top corners
- trailingRect = CGRectMake(x, (height - cornersHeight), cornersWidth, cornersHeight); // bottom corners
-
- } else { // top/bottom split
- x = 0;
- y = ((shouldShowMaster) ? ((masterFirst) ? _splitPosition : height - (_splitPosition + _splitWidth)) : (0 - _splitWidth)) - radius;
- cornersWidth = radius;
- cornersHeight = (radius * 2.0) + _splitWidth;
- leadingRect = CGRectMake(x, y, cornersWidth, cornersHeight); // left corners
- trailingRect = CGRectMake((width - cornersWidth), y, cornersWidth, cornersHeight); // right corners
- }
-
- leadingCorners.frame = leadingRect;
- trailingCorners.frame = trailingRect;
-
- // Ensure corners are visible and frontmost.
- if (!leadingCorners.superview) {
- [self.view insertSubview:leadingCorners aboveSubview:self.detailViewController.view];
- [self.view insertSubview:trailingCorners aboveSubview:self.detailViewController.view];
- } else {
- [self.view bringSubviewToFront:leadingCorners];
- [self.view bringSubviewToFront:trailingCorners];
- }
+ if (_reconfigurePopup) {
+ [self reconfigureForMasterInPopover:![self shouldShowMasterForInterfaceOrientation:theOrientation]];
+ }
+
+ // Layout the master, detail and divider views appropriately, adding/removing subviews as needed.
+ // First obtain relevant geometry.
+ CGSize fullSize = [self splitViewSizeForOrientation:theOrientation];
+ float width = fullSize.width;
+ float height = fullSize.height;
+
+ if (NO) { // Just for debugging.
+ NSLog(@"Target orientation is %@, dimensions will be %.0f x %.0f",
+ [self nameOfInterfaceOrientation:theOrientation], width, height);
+ }
+
+ // Layout the master, divider and detail views.
+ CGRect newFrame = CGRectMake(0, 0, width, height);
+ UIViewController *controller;
+ UIView *theView;
+ BOOL shouldShowMaster = [self shouldShowMasterForInterfaceOrientation:theOrientation];
+ BOOL masterFirst = [self isMasterBeforeDetail];
+ if ([self isVertical]) {
+ // Master on left, detail on right (or vice versa).
+ CGRect masterRect, dividerRect, detailRect;
+ if (masterFirst) {
+ if (!shouldShowMaster) {
+ // Move off-screen.
+ newFrame.origin.x -= (_splitPosition + _splitWidth);
+ }
+
+ newFrame.size.width = _splitPosition;
+ masterRect = newFrame;
+
+ newFrame.origin.x += newFrame.size.width;
+ newFrame.size.width = _splitWidth;
+ dividerRect = newFrame;
+
+ newFrame.origin.x += newFrame.size.width;
+ newFrame.size.width = width - newFrame.origin.x;
+ detailRect = newFrame;
+
+ } else {
+ if (!shouldShowMaster) {
+ // Move off-screen.
+ newFrame.size.width += (_splitPosition + _splitWidth);
+ }
+
+ newFrame.size.width -= (_splitPosition + _splitWidth);
+ detailRect = newFrame;
+
+ newFrame.origin.x += newFrame.size.width;
+ newFrame.size.width = _splitWidth;
+ dividerRect = newFrame;
+
+ newFrame.origin.x += newFrame.size.width;
+ newFrame.size.width = _splitPosition;
+ masterRect = newFrame;
+ }
+
+ // Position master.
+ controller = self.masterViewController;
+ if (controller && [controller isKindOfClass:[UIViewController class]]) {
+ theView = controller.view;
+ if (theView) {
+ theView.frame = masterRect;
+ if (!theView.superview) {
+ [controller viewWillAppear:NO];
+ [self.view addSubview:theView];
+ [controller viewDidAppear:NO];
+ }
+ }
+ }
+
+ // Position divider.
+ theView = _dividerView;
+ theView.frame = dividerRect;
+ if (!theView.superview) {
+ [self.view addSubview:theView];
+ }
+
+ // Position detail.
+ controller = self.detailViewController;
+ if (controller && [controller isKindOfClass:[UIViewController class]]) {
+ theView = controller.view;
+ if (theView) {
+ theView.frame = detailRect;
+ if (!theView.superview) {
+ [self.view insertSubview:theView aboveSubview:self.masterViewController.view];
+ } else {
+ [self.view bringSubviewToFront:theView];
+ }
+ }
+ }
+
+ } else {
+ // Master above, detail below (or vice versa).
+ CGRect masterRect, dividerRect, detailRect;
+ if (masterFirst) {
+ if (!shouldShowMaster) {
+ // Move off-screen.
+ newFrame.origin.y -= (_splitPosition + _splitWidth);
+ }
+
+ newFrame.size.height = _splitPosition;
+ masterRect = newFrame;
+
+ newFrame.origin.y += newFrame.size.height;
+ newFrame.size.height = _splitWidth;
+ dividerRect = newFrame;
+
+ newFrame.origin.y += newFrame.size.height;
+ newFrame.size.height = height - newFrame.origin.y;
+ detailRect = newFrame;
+
+ } else {
+ if (!shouldShowMaster) {
+ // Move off-screen.
+ newFrame.size.height += (_splitPosition + _splitWidth);
+ }
+
+ newFrame.size.height -= (_splitPosition + _splitWidth);
+ detailRect = newFrame;
+
+ newFrame.origin.y += newFrame.size.height;
+ newFrame.size.height = _splitWidth;
+ dividerRect = newFrame;
+
+ newFrame.origin.y += newFrame.size.height;
+ newFrame.size.height = _splitPosition;
+ masterRect = newFrame;
+ }
+
+ // Position master.
+ controller = self.masterViewController;
+ if (controller && [controller isKindOfClass:[UIViewController class]]) {
+ theView = controller.view;
+ if (theView) {
+ theView.frame = masterRect;
+ if (!theView.superview) {
+ [controller viewWillAppear:NO];
+ [self.view addSubview:theView];
+ [controller viewDidAppear:NO];
+ }
+ }
+ }
+
+ // Position divider.
+ theView = _dividerView;
+ theView.frame = dividerRect;
+ if (!theView.superview) {
+ [self.view addSubview:theView];
+ }
+
+ // Position detail.
+ controller = self.detailViewController;
+ if (controller && [controller isKindOfClass:[UIViewController class]]) {
+ theView = controller.view;
+ if (theView) {
+ theView.frame = detailRect;
+ if (!theView.superview) {
+ [self.view insertSubview:theView aboveSubview:self.masterViewController.view];
+ } else {
+ [self.view bringSubviewToFront:theView];
+ }
+ }
+ }
+ }
+
+ // Create corner views if necessary.
+ MGSplitCornersView *leadingCorners; // top/left of screen in vertical/horizontal split.
+ MGSplitCornersView *trailingCorners; // bottom/right of screen in vertical/horizontal split.
+ if (!_cornerViews) {
+ CGRect cornerRect = CGRectMake(0, 0, 10, 10); // arbitrary, will be resized below.
+ leadingCorners = [[MGSplitCornersView alloc] initWithFrame:cornerRect];
+ leadingCorners.splitViewController = self;
+ leadingCorners.cornerBackgroundColor = MG_DEFAULT_CORNER_COLOR;
+ leadingCorners.cornerRadius = MG_DEFAULT_CORNER_RADIUS;
+ trailingCorners = [[MGSplitCornersView alloc] initWithFrame:cornerRect];
+ trailingCorners.splitViewController = self;
+ trailingCorners.cornerBackgroundColor = MG_DEFAULT_CORNER_COLOR;
+ trailingCorners.cornerRadius = MG_DEFAULT_CORNER_RADIUS;
+ _cornerViews = [[NSArray alloc] initWithObjects:leadingCorners, trailingCorners, nil];
+ [leadingCorners release];
+ [trailingCorners release];
+
+ } else if ([_cornerViews count] == 2) {
+ leadingCorners = [_cornerViews objectAtIndex:0];
+ trailingCorners = [_cornerViews objectAtIndex:1];
+ }
+
+ // Configure and layout the corner-views.
+ leadingCorners.cornersPosition = (_vertical) ? MGCornersPositionLeadingVertical : MGCornersPositionLeadingHorizontal;
+ trailingCorners.cornersPosition = (_vertical) ? MGCornersPositionTrailingVertical : MGCornersPositionTrailingHorizontal;
+ leadingCorners.autoresizingMask = (_vertical) ? UIViewAutoresizingFlexibleBottomMargin : UIViewAutoresizingFlexibleRightMargin;
+ trailingCorners.autoresizingMask = (_vertical) ? UIViewAutoresizingFlexibleTopMargin : UIViewAutoresizingFlexibleLeftMargin;
+
+ float x, y, cornersWidth, cornersHeight;
+ CGRect leadingRect, trailingRect;
+ float radius = leadingCorners.cornerRadius;
+ if (_vertical) { // left/right split
+ cornersWidth = (radius * 2.0) + _splitWidth;
+ cornersHeight = radius;
+ x = ((shouldShowMaster) ? ((masterFirst) ? _splitPosition : width - (_splitPosition + _splitWidth)) : (0 - _splitWidth)) - radius;
+ y = 0;
+ leadingRect = CGRectMake(x, y, cornersWidth, cornersHeight); // top corners
+ trailingRect = CGRectMake(x, (height - cornersHeight), cornersWidth, cornersHeight); // bottom corners
+
+ } else { // top/bottom split
+ x = 0;
+ y = ((shouldShowMaster) ? ((masterFirst) ? _splitPosition : height - (_splitPosition + _splitWidth)) : (0 - _splitWidth)) - radius;
+ cornersWidth = radius;
+ cornersHeight = (radius * 2.0) + _splitWidth;
+ leadingRect = CGRectMake(x, y, cornersWidth, cornersHeight); // left corners
+ trailingRect = CGRectMake((width - cornersWidth), y, cornersWidth, cornersHeight); // right corners
+ }
+
+ leadingCorners.frame = leadingRect;
+ trailingCorners.frame = trailingRect;
+
+ // Ensure corners are visible and frontmost.
+ if (!leadingCorners.superview) {
+ [self.view insertSubview:leadingCorners aboveSubview:self.detailViewController.view];
+ [self.view insertSubview:trailingCorners aboveSubview:self.detailViewController.view];
+ } else {
+ [self.view bringSubviewToFront:leadingCorners];
+ [self.view bringSubviewToFront:trailingCorners];
+ }
}
- (void)layoutSubviewsWithAnimation:(BOOL)animate
{
- [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:animate];
+ [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:animate];
}
- (void)layoutSubviews
{
- [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:YES];
+ [self layoutSubviewsForInterfaceOrientation:self.interfaceOrientation withAnimation:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
- [super viewWillAppear:animated];
-
- if ([self isShowingMaster]) {
- [self.masterViewController viewWillAppear:animated];
- }
- [self.detailViewController viewWillAppear:animated];
-
- _reconfigurePopup = YES;
- [self layoutSubviews];
+ [super viewWillAppear:animated];
+
+ if ([self isShowingMaster]) {
+ [self.masterViewController viewWillAppear:animated];
+ }
+ [self.detailViewController viewWillAppear:animated];
+
+ _reconfigurePopup = YES;
+ [self layoutSubviews];
}
- (void)viewDidAppear:(BOOL)animated
{
- [super viewDidAppear:animated];
-
- if ([self isShowingMaster]) {
- [self.masterViewController viewDidAppear:animated];
- }
- [self.detailViewController viewDidAppear:animated];
+ [super viewDidAppear:animated];
+
+ if ([self isShowingMaster]) {
+ [self.masterViewController viewDidAppear:animated];
+ }
+ [self.detailViewController viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
- [super viewWillDisappear:animated];
-
- if ([self isShowingMaster]) {
- [self.masterViewController viewWillDisappear:animated];
- }
- [self.detailViewController viewWillDisappear:animated];
+ [super viewWillDisappear:animated];
+
+ if ([self isShowingMaster]) {
+ [self.masterViewController viewWillDisappear:animated];
+ }
+ [self.detailViewController viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
- [super viewDidDisappear:animated];
-
- if ([self isShowingMaster]) {
- [self.masterViewController viewDidDisappear:animated];
- }
- [self.detailViewController viewDidDisappear:animated];
+ [super viewDidDisappear:animated];
+
+ if ([self isShowingMaster]) {
+ [self.masterViewController viewDidDisappear:animated];
+ }
+ [self.detailViewController viewDidDisappear:animated];
}
@@ -545,73 +545,73 @@
- (void)reconfigureForMasterInPopover:(BOOL)inPopover
{
- _reconfigurePopup = NO;
-
- if ((inPopover && _hiddenPopoverController) || (!inPopover && !_hiddenPopoverController) || !self.masterViewController) {
- // Nothing to do.
- return;
- }
-
- if (inPopover && !_hiddenPopoverController && !_barButtonItem) {
- // Create and configure popover for our masterViewController.
- [_hiddenPopoverController release];
- _hiddenPopoverController = nil;
- [self.masterViewController viewWillDisappear:NO];
- _hiddenPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.masterViewController];
- [self.masterViewController viewDidDisappear:NO];
-
- // Create and configure _barButtonItem.
- _barButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Master", nil)
- style:UIBarButtonItemStyleBordered
- target:self
- action:@selector(showMasterPopover:)];
-
- // Inform delegate of this state of affairs.
- if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willHideViewController:withBarButtonItem:forPopoverController:)]) {
- [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
- willHideViewController:self.masterViewController
- withBarButtonItem:_barButtonItem
- forPopoverController:_hiddenPopoverController];
- }
-
- } else if (!inPopover && _hiddenPopoverController && _barButtonItem) {
- // I know this looks strange, but it fixes a bizarre issue with UIPopoverController leaving masterViewController's views in disarray.
- [_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
-
- // Remove master from popover and destroy popover, if it exists.
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- [_hiddenPopoverController release];
- _hiddenPopoverController = nil;
-
- // Inform delegate that the _barButtonItem will become invalid.
- if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willShowViewController:invalidatingBarButtonItem:)]) {
- [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
- willShowViewController:self.masterViewController
- invalidatingBarButtonItem:_barButtonItem];
- }
-
- // Destroy _barButtonItem.
- [_barButtonItem release];
- _barButtonItem = nil;
-
- // Move master view.
- UIView *masterView = self.masterViewController.view;
- if (masterView && masterView.superview != self.view) {
- [masterView removeFromSuperview];
- }
- }
+ _reconfigurePopup = NO;
+
+ if ((inPopover && _hiddenPopoverController) || (!inPopover && !_hiddenPopoverController) || !self.masterViewController) {
+ // Nothing to do.
+ return;
+ }
+
+ if (inPopover && !_hiddenPopoverController && !_barButtonItem) {
+ // Create and configure popover for our masterViewController.
+ [_hiddenPopoverController release];
+ _hiddenPopoverController = nil;
+ [self.masterViewController viewWillDisappear:NO];
+ _hiddenPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.masterViewController];
+ [self.masterViewController viewDidDisappear:NO];
+
+ // Create and configure _barButtonItem.
+ _barButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Master", nil)
+ style:UIBarButtonItemStyleBordered
+ target:self
+ action:@selector(showMasterPopover:)];
+
+ // Inform delegate of this state of affairs.
+ if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willHideViewController:withBarButtonItem:forPopoverController:)]) {
+ [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
+ willHideViewController:self.masterViewController
+ withBarButtonItem:_barButtonItem
+ forPopoverController:_hiddenPopoverController];
+ }
+
+ } else if (!inPopover && _hiddenPopoverController && _barButtonItem) {
+ // I know this looks strange, but it fixes a bizarre issue with UIPopoverController leaving masterViewController's views in disarray.
+ [_hiddenPopoverController presentPopoverFromRect:CGRectZero inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
+
+ // Remove master from popover and destroy popover, if it exists.
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ [_hiddenPopoverController release];
+ _hiddenPopoverController = nil;
+
+ // Inform delegate that the _barButtonItem will become invalid.
+ if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willShowViewController:invalidatingBarButtonItem:)]) {
+ [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
+ willShowViewController:self.masterViewController
+ invalidatingBarButtonItem:_barButtonItem];
+ }
+
+ // Destroy _barButtonItem.
+ [_barButtonItem release];
+ _barButtonItem = nil;
+
+ // Move master view.
+ UIView *masterView = self.masterViewController.view;
+ if (masterView && masterView.superview != self.view) {
+ [masterView removeFromSuperview];
+ }
+ }
}
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
- [self reconfigureForMasterInPopover:NO];
+ [self reconfigureForMasterInPopover:NO];
}
- (void)notePopoverDismissed
{
- [self popoverControllerDidDismissPopover:_hiddenPopoverController];
+ [self popoverControllerDidDismissPopover:_hiddenPopoverController];
}
@@ -621,14 +621,14 @@
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
- if (([animationID isEqualToString:MG_ANIMATION_CHANGE_SPLIT_ORIENTATION] ||
- [animationID isEqualToString:MG_ANIMATION_CHANGE_SUBVIEWS_ORDER])
- && _cornerViews) {
- for (UIView *corner in _cornerViews) {
- corner.hidden = NO;
- }
- _dividerView.hidden = NO;
- }
+ if (([animationID isEqualToString:MG_ANIMATION_CHANGE_SPLIT_ORIENTATION] ||
+ [animationID isEqualToString:MG_ANIMATION_CHANGE_SUBVIEWS_ORDER])
+ && _cornerViews) {
+ for (UIView *corner in _cornerViews) {
+ corner.hidden = NO;
+ }
+ _dividerView.hidden = NO;
+ }
}
@@ -638,83 +638,83 @@
- (IBAction)toggleSplitOrientation:(id)sender
{
- BOOL showingMaster = [self isShowingMaster];
- if (showingMaster) {
- if (_cornerViews) {
- for (UIView *corner in _cornerViews) {
- corner.hidden = YES;
- }
- _dividerView.hidden = YES;
- }
- [UIView beginAnimations:MG_ANIMATION_CHANGE_SPLIT_ORIENTATION context:nil];
- [UIView setAnimationDelegate:self];
- [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
- }
- self.vertical = (!self.vertical);
- if (showingMaster) {
- [UIView commitAnimations];
- }
+ BOOL showingMaster = [self isShowingMaster];
+ if (showingMaster) {
+ if (_cornerViews) {
+ for (UIView *corner in _cornerViews) {
+ corner.hidden = YES;
+ }
+ _dividerView.hidden = YES;
+ }
+ [UIView beginAnimations:MG_ANIMATION_CHANGE_SPLIT_ORIENTATION context:nil];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
+ }
+ self.vertical = (!self.vertical);
+ if (showingMaster) {
+ [UIView commitAnimations];
+ }
}
- (IBAction)toggleMasterBeforeDetail:(id)sender
{
- BOOL showingMaster = [self isShowingMaster];
- if (showingMaster) {
- if (_cornerViews) {
- for (UIView *corner in _cornerViews) {
- corner.hidden = YES;
- }
- _dividerView.hidden = YES;
- }
- [UIView beginAnimations:MG_ANIMATION_CHANGE_SUBVIEWS_ORDER context:nil];
- [UIView setAnimationDelegate:self];
- [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
- }
- self.masterBeforeDetail = (!self.masterBeforeDetail);
- if (showingMaster) {
- [UIView commitAnimations];
- }
+ BOOL showingMaster = [self isShowingMaster];
+ if (showingMaster) {
+ if (_cornerViews) {
+ for (UIView *corner in _cornerViews) {
+ corner.hidden = YES;
+ }
+ _dividerView.hidden = YES;
+ }
+ [UIView beginAnimations:MG_ANIMATION_CHANGE_SUBVIEWS_ORDER context:nil];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
+ }
+ self.masterBeforeDetail = (!self.masterBeforeDetail);
+ if (showingMaster) {
+ [UIView commitAnimations];
+ }
}
- (IBAction)toggleMasterView:(id)sender
{
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- if (![self isShowingMaster]) {
- // We're about to show the master view. Ensure it's in place off-screen to be animated in.
- _reconfigurePopup = YES;
- [self reconfigureForMasterInPopover:NO];
- [self layoutSubviews];
- }
-
- // This action functions on the current primary orientation; it is independent of the other primary orientation.
- [UIView beginAnimations:@"toggleMaster" context:nil];
- if (self.isLandscape) {
- self.showsMasterInLandscape = !_showsMasterInLandscape;
- } else {
- self.showsMasterInPortrait = !_showsMasterInPortrait;
- }
- [UIView commitAnimations];
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ if (![self isShowingMaster]) {
+ // We're about to show the master view. Ensure it's in place off-screen to be animated in.
+ _reconfigurePopup = YES;
+ [self reconfigureForMasterInPopover:NO];
+ [self layoutSubviews];
+ }
+
+ // This action functions on the current primary orientation; it is independent of the other primary orientation.
+ [UIView beginAnimations:@"toggleMaster" context:nil];
+ if (self.isLandscape) {
+ self.showsMasterInLandscape = !_showsMasterInLandscape;
+ } else {
+ self.showsMasterInPortrait = !_showsMasterInPortrait;
+ }
+ [UIView commitAnimations];
}
- (IBAction)showMasterPopover:(id) sender
{
- if (_hiddenPopoverController && !(_hiddenPopoverController.popoverVisible)) {
- // Inform delegate.
- if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:popoverController:willPresentViewController:)]) {
- [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
- popoverController:_hiddenPopoverController
- willPresentViewController:self.masterViewController];
- }
-
- // Show popover.
- [_hiddenPopoverController presentPopoverFromBarButtonItem:_barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- }
+ if (_hiddenPopoverController && !(_hiddenPopoverController.popoverVisible)) {
+ // Inform delegate.
+ if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:popoverController:willPresentViewController:)]) {
+ [(NSObject <MGSplitViewControllerDelegate> *)_delegate splitViewController:self
+ popoverController:_hiddenPopoverController
+ willPresentViewController:self.masterViewController];
+ }
+
+ // Show popover.
+ [_hiddenPopoverController presentPopoverFromBarButtonItem:_barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+ }
}
@@ -724,395 +724,395 @@
- (id)delegate
{
- return _delegate;
+ return _delegate;
}
- (void)setDelegate:(id <MGSplitViewControllerDelegate>)newDelegate
{
- if (newDelegate != _delegate &&
- (!newDelegate || [(NSObject *)newDelegate conformsToProtocol:@protocol(MGSplitViewControllerDelegate)])) {
- _delegate = newDelegate;
- }
+ if (newDelegate != _delegate &&
+ (!newDelegate || [(NSObject *)newDelegate conformsToProtocol:@protocol(MGSplitViewControllerDelegate)])) {
+ _delegate = newDelegate;
+ }
}
- (BOOL)showsMasterInPortrait
{
- return _showsMasterInPortrait;
+ return _showsMasterInPortrait;
}
- (void)setShowsMasterInPortrait:(BOOL)flag
{
- if (flag != _showsMasterInPortrait) {
- _showsMasterInPortrait = flag;
-
- if (![self isLandscape]) { // i.e. if this will cause a visual change.
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- // Rearrange views.
- _reconfigurePopup = YES;
- [self layoutSubviews];
- }
- }
+ if (flag != _showsMasterInPortrait) {
+ _showsMasterInPortrait = flag;
+
+ if (![self isLandscape]) { // i.e. if this will cause a visual change.
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ // Rearrange views.
+ _reconfigurePopup = YES;
+ [self layoutSubviews];
+ }
+ }
}
- (BOOL)showsMasterInLandscape
{
- return _showsMasterInLandscape;
+ return _showsMasterInLandscape;
}
- (void)setShowsMasterInLandscape:(BOOL)flag
{
- if (flag != _showsMasterInLandscape) {
- _showsMasterInLandscape = flag;
-
- if ([self isLandscape]) { // i.e. if this will cause a visual change.
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- // Rearrange views.
- _reconfigurePopup = YES;
- [self layoutSubviews];
- }
- }
+ if (flag != _showsMasterInLandscape) {
+ _showsMasterInLandscape = flag;
+
+ if ([self isLandscape]) { // i.e. if this will cause a visual change.
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ // Rearrange views.
+ _reconfigurePopup = YES;
+ [self layoutSubviews];
+ }
+ }
}
- (BOOL)isVertical
{
- return _vertical;
+ return _vertical;
}
- (void)setVertical:(BOOL)flag
{
- if (flag != _vertical) {
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- _vertical = flag;
-
- // Inform delegate.
- if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willChangeSplitOrientationToVertical:)]) {
- [_delegate splitViewController:self willChangeSplitOrientationToVertical:_vertical];
- }
-
- [self layoutSubviews];
- }
+ if (flag != _vertical) {
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ _vertical = flag;
+
+ // Inform delegate.
+ if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willChangeSplitOrientationToVertical:)]) {
+ [_delegate splitViewController:self willChangeSplitOrientationToVertical:_vertical];
+ }
+
+ [self layoutSubviews];
+ }
}
- (BOOL)isMasterBeforeDetail
{
- return _masterBeforeDetail;
+ return _masterBeforeDetail;
}
- (void)setMasterBeforeDetail:(BOOL)flag
{
- if (flag != _masterBeforeDetail) {
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- _masterBeforeDetail = flag;
-
- if ([self isShowingMaster]) {
- [self layoutSubviews];
- }
- }
+ if (flag != _masterBeforeDetail) {
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ _masterBeforeDetail = flag;
+
+ if ([self isShowingMaster]) {
+ [self layoutSubviews];
+ }
+ }
}
- (float)splitPosition
{
- return _splitPosition;
+ return _splitPosition;
}
- (void)setSplitPosition:(float)posn
{
- // Check to see if delegate wishes to constrain the position.
- float newPosn = posn;
- BOOL constrained = NO;
- CGSize fullSize = [self splitViewSizeForOrientation:self.interfaceOrientation];
- if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:constrainSplitPosition:splitViewSize:)]) {
- newPosn = [_delegate splitViewController:self constrainSplitPosition:newPosn splitViewSize:fullSize];
- constrained = YES; // implicitly trust delegate's response.
-
- } else {
- // Apply default constraints if delegate doesn't wish to participate.
- float minPos = MG_MIN_VIEW_WIDTH;
- float maxPos = ((_vertical) ? fullSize.width : fullSize.height) - (MG_MIN_VIEW_WIDTH + _splitWidth);
- constrained = (newPosn != _splitPosition && newPosn >= minPos && newPosn <= maxPos);
- }
-
- if (constrained) {
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- _splitPosition = newPosn;
-
- // Inform delegate.
- if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willMoveSplitToPosition:)]) {
- [_delegate splitViewController:self willMoveSplitToPosition:_splitPosition];
- }
-
- if ([self isShowingMaster]) {
- [self layoutSubviews];
- }
- }
+ // Check to see if delegate wishes to constrain the position.
+ float newPosn = posn;
+ BOOL constrained = NO;
+ CGSize fullSize = [self splitViewSizeForOrientation:self.interfaceOrientation];
+ if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:constrainSplitPosition:splitViewSize:)]) {
+ newPosn = [_delegate splitViewController:self constrainSplitPosition:newPosn splitViewSize:fullSize];
+ constrained = YES; // implicitly trust delegate's response.
+
+ } else {
+ // Apply default constraints if delegate doesn't wish to participate.
+ float minPos = MG_MIN_VIEW_WIDTH;
+ float maxPos = ((_vertical) ? fullSize.width : fullSize.height) - (MG_MIN_VIEW_WIDTH + _splitWidth);
+ constrained = (newPosn != _splitPosition && newPosn >= minPos && newPosn <= maxPos);
+ }
+
+ if (constrained) {
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ _splitPosition = newPosn;
+
+ // Inform delegate.
+ if (_delegate && [_delegate respondsToSelector:@selector(splitViewController:willMoveSplitToPosition:)]) {
+ [_delegate splitViewController:self willMoveSplitToPosition:_splitPosition];
+ }
+
+ if ([self isShowingMaster]) {
+ [self layoutSubviews];
+ }
+ }
}
- (void)setSplitPosition:(float)posn animated:(BOOL)animate
{
- BOOL shouldAnimate = (animate && [self isShowingMaster]);
- if (shouldAnimate) {
- [UIView beginAnimations:@"SplitPosition" context:nil];
- }
- [self setSplitPosition:posn];
- if (shouldAnimate) {
- [UIView commitAnimations];
- }
+ BOOL shouldAnimate = (animate && [self isShowingMaster]);
+ if (shouldAnimate) {
+ [UIView beginAnimations:@"SplitPosition" context:nil];
+ }
+ [self setSplitPosition:posn];
+ if (shouldAnimate) {
+ [UIView commitAnimations];
+ }
}
- (float)splitWidth
{
- return _splitWidth;
+ return _splitWidth;
}
- (void)setSplitWidth:(float)width
{
- if (width != _splitWidth && width >= 0) {
- _splitWidth = width;
- if ([self isShowingMaster]) {
- [self layoutSubviews];
- }
- }
+ if (width != _splitWidth && width >= 0) {
+ _splitWidth = width;
+ if ([self isShowingMaster]) {
+ [self layoutSubviews];
+ }
+ }
}
- (NSArray *)viewControllers
{
- return [[_viewControllers copy] autorelease];
+ return [[_viewControllers copy] autorelease];
}
- (void)setViewControllers:(NSArray *)controllers
{
- if (controllers != _viewControllers) {
- for (UIViewController *controller in _viewControllers) {
- if ([controller isKindOfClass:[UIViewController class]]) {
- [controller.view removeFromSuperview];
- }
- }
- [_viewControllers release];
- _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
- if (controllers && [controllers count] >= 2) {
- self.masterViewController = [controllers objectAtIndex:0];
- self.detailViewController = [controllers objectAtIndex:1];
- } else {
- NSLog(@"Error: %@ requires 2 view-controllers. (%@)", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
- }
-
- [self layoutSubviews];
- }
+ if (controllers != _viewControllers) {
+ for (UIViewController *controller in _viewControllers) {
+ if ([controller isKindOfClass:[UIViewController class]]) {
+ [controller.view removeFromSuperview];
+ }
+ }
+ [_viewControllers release];
+ _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
+ if (controllers && [controllers count] >= 2) {
+ self.masterViewController = [controllers objectAtIndex:0];
+ self.detailViewController = [controllers objectAtIndex:1];
+ } else {
+ NSLog(@"Error: %@ requires 2 view-controllers. (%@)", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
+ }
+
+ [self layoutSubviews];
+ }
}
- (UIViewController *)masterViewController
{
- if (_viewControllers && [_viewControllers count] > 0) {
- NSObject *controller = [_viewControllers objectAtIndex:0];
- if ([controller isKindOfClass:[UIViewController class]]) {
- return [[controller retain] autorelease];
- }
- }
-
- return nil;
+ if (_viewControllers && [_viewControllers count] > 0) {
+ NSObject *controller = [_viewControllers objectAtIndex:0];
+ if ([controller isKindOfClass:[UIViewController class]]) {
+ return [[controller retain] autorelease];
+ }
+ }
+
+ return nil;
}
- (void)setMasterViewController:(UIViewController *)master
{
- if (!_viewControllers) {
- _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
- }
-
- NSObject *newMaster = master;
- if (!newMaster) {
- newMaster = [NSNull null];
- }
-
- BOOL changed = YES;
- if ([_viewControllers count] > 0) {
- if ([_viewControllers objectAtIndex:0] == newMaster) {
- changed = NO;
- } else {
- [_viewControllers replaceObjectAtIndex:0 withObject:newMaster];
- }
-
- } else {
- [_viewControllers addObject:newMaster];
- }
-
- if (changed) {
- [self layoutSubviews];
- }
+ if (!_viewControllers) {
+ _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
+ }
+
+ NSObject *newMaster = master;
+ if (!newMaster) {
+ newMaster = [NSNull null];
+ }
+
+ BOOL changed = YES;
+ if ([_viewControllers count] > 0) {
+ if ([_viewControllers objectAtIndex:0] == newMaster) {
+ changed = NO;
+ } else {
+ [_viewControllers replaceObjectAtIndex:0 withObject:newMaster];
+ }
+
+ } else {
+ [_viewControllers addObject:newMaster];
+ }
+
+ if (changed) {
+ [self layoutSubviews];
+ }
}
- (UIViewController *)detailViewController
{
- if (_viewControllers && [_viewControllers count] > 1) {
- NSObject *controller = [_viewControllers objectAtIndex:1];
- if ([controller isKindOfClass:[UIViewController class]]) {
- return [[controller retain] autorelease];
- }
- }
-
- return nil;
+ if (_viewControllers && [_viewControllers count] > 1) {
+ NSObject *controller = [_viewControllers objectAtIndex:1];
+ if ([controller isKindOfClass:[UIViewController class]]) {
+ return [[controller retain] autorelease];
+ }
+ }
+
+ return nil;
}
- (void)setDetailViewController:(UIViewController *)detail
{
- if (!_viewControllers) {
- _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
- [_viewControllers addObject:[NSNull null]];
- }
-
- BOOL changed = YES;
- if ([_viewControllers count] > 1) {
- if ([_viewControllers objectAtIndex:1] == detail) {
- changed = NO;
- } else {
- [_viewControllers replaceObjectAtIndex:1 withObject:detail];
- }
-
- } else {
- [_viewControllers addObject:detail];
- }
-
- if (changed) {
- [self layoutSubviews];
- }
+ if (!_viewControllers) {
+ _viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
+ [_viewControllers addObject:[NSNull null]];
+ }
+
+ BOOL changed = YES;
+ if ([_viewControllers count] > 1) {
+ if ([_viewControllers objectAtIndex:1] == detail) {
+ changed = NO;
+ } else {
+ [_viewControllers replaceObjectAtIndex:1 withObject:detail];
+ }
+
+ } else {
+ [_viewControllers addObject:detail];
+ }
+
+ if (changed) {
+ [self layoutSubviews];
+ }
}
- (MGSplitDividerView *)dividerView
{
- return [[_dividerView retain] autorelease];
+ return [[_dividerView retain] autorelease];
}
- (void)setDividerView:(MGSplitDividerView *)divider
{
- if (divider != _dividerView) {
- [_dividerView removeFromSuperview];
- [_dividerView release];
- _dividerView = [divider retain];
- _dividerView.splitViewController = self;
- _dividerView.backgroundColor = MG_DEFAULT_CORNER_COLOR;
- if ([self isShowingMaster]) {
- [self layoutSubviews];
- }
- }
+ if (divider != _dividerView) {
+ [_dividerView removeFromSuperview];
+ [_dividerView release];
+ _dividerView = [divider retain];
+ _dividerView.splitViewController = self;
+ _dividerView.backgroundColor = MG_DEFAULT_CORNER_COLOR;
+ if ([self isShowingMaster]) {
+ [self layoutSubviews];
+ }
+ }
}
- (BOOL)allowsDraggingDivider
{
- if (_dividerView) {
- return _dividerView.allowsDragging;
- }
-
- return NO;
+ if (_dividerView) {
+ return _dividerView.allowsDragging;
+ }
+
+ return NO;
}
- (void)setAllowsDraggingDivider:(BOOL)flag
{
- if (self.allowsDraggingDivider != flag && _dividerView) {
- _dividerView.allowsDragging = flag;
- }
+ if (self.allowsDraggingDivider != flag && _dividerView) {
+ _dividerView.allowsDragging = flag;
+ }
}
- (MGSplitViewDividerStyle)dividerStyle
{
- return _dividerStyle;
+ return _dividerStyle;
}
- (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle
{
- if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
- [_hiddenPopoverController dismissPopoverAnimated:NO];
- }
-
- // We don't check to see if newStyle equals _dividerStyle, because it's a meta-setting.
- // Aspects could have been changed since it was set.
- _dividerStyle = newStyle;
-
- // Reconfigure general appearance and behaviour.
- float cornerRadius;
- if (_dividerStyle == MGSplitViewDividerStyleThin) {
- cornerRadius = MG_DEFAULT_CORNER_RADIUS;
- _splitWidth = MG_DEFAULT_SPLIT_WIDTH;
- self.allowsDraggingDivider = NO;
-
- } else if (_dividerStyle == MGSplitViewDividerStylePaneSplitter) {
- cornerRadius = MG_PANESPLITTER_CORNER_RADIUS;
- _splitWidth = MG_PANESPLITTER_SPLIT_WIDTH;
- self.allowsDraggingDivider = YES;
- }
-
- // Update divider and corners.
- [_dividerView setNeedsDisplay];
- if (_cornerViews) {
- for (MGSplitCornersView *corner in _cornerViews) {
- corner.cornerRadius = cornerRadius;
- }
- }
-
- // Layout all views.
- [self layoutSubviews];
+ if (_hiddenPopoverController && _hiddenPopoverController.popoverVisible) {
+ [_hiddenPopoverController dismissPopoverAnimated:NO];
+ }
+
+ // We don't check to see if newStyle equals _dividerStyle, because it's a meta-setting.
+ // Aspects could have been changed since it was set.
+ _dividerStyle = newStyle;
+
+ // Reconfigure general appearance and behaviour.
+ float cornerRadius;
+ if (_dividerStyle == MGSplitViewDividerStyleThin) {
+ cornerRadius = MG_DEFAULT_CORNER_RADIUS;
+ _splitWidth = MG_DEFAULT_SPLIT_WIDTH;
+ self.allowsDraggingDivider = NO;
+
+ } else if (_dividerStyle == MGSplitViewDividerStylePaneSplitter) {
+ cornerRadius = MG_PANESPLITTER_CORNER_RADIUS;
+ _splitWidth = MG_PANESPLITTER_SPLIT_WIDTH;
+ self.allowsDraggingDivider = YES;
+ }
+
+ // Update divider and corners.
+ [_dividerView setNeedsDisplay];
+ if (_cornerViews) {
+ for (MGSplitCornersView *corner in _cornerViews) {
+ corner.cornerRadius = cornerRadius;
+ }
+ }
+
+ // Layout all views.
+ [self layoutSubviews];
}
- (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle animated:(BOOL)animate
{
- BOOL shouldAnimate = (animate && [self isShowingMaster]);
- if (shouldAnimate) {
- [UIView beginAnimations:@"DividerStyle" context:nil];
- }
- [self setDividerStyle:newStyle];
- if (shouldAnimate) {
- [UIView commitAnimations];
- }
+ BOOL shouldAnimate = (animate && [self isShowingMaster]);
+ if (shouldAnimate) {
+ [UIView beginAnimations:@"DividerStyle" context:nil];
+ }
+ [self setDividerStyle:newStyle];
+ if (shouldAnimate) {
+ [UIView commitAnimations];
+ }
}
- (NSArray *)cornerViews
{
- if (_cornerViews) {
- return [[_cornerViews retain] autorelease];
- }
-
- return nil;
+ if (_cornerViews) {
+ return [[_cornerViews retain] autorelease];
+ }
+
+ return nil;
}
--- a/project_files/HedgewarsMobile/Classes/MXAudioPlayerFadeOperation.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MXAudioPlayerFadeOperation.h Sat Jan 26 23:57:37 2013 +0100
@@ -17,26 +17,26 @@
BOOL _playBeforeFade;
}
-// The AVAudioPlayer that the volume fade will be applied to.
+// The AVAudioPlayer that the volume fade will be applied to.
// Retained until the fade is completed.
// Must be set with init method.
-@property (nonatomic, retain, readonly) AVAudioPlayer *audioPlayer;
+@property (nonatomic, retain, readonly) AVAudioPlayer *audioPlayer;
-// The duration of the volume fade.
+// The duration of the volume fade.
// Default value is 1.0
-@property (nonatomic, assign) NSTimeInterval fadeDuration;
+@property (nonatomic, assign) NSTimeInterval fadeDuration;
-// The delay before the volume fade begins.
+// The delay before the volume fade begins.
// Default value is 0.0
-@property (nonatomic, assign) NSTimeInterval delay;
+@property (nonatomic, assign) NSTimeInterval delay;
-// The volume that will be faded to.
+// The volume that will be faded to.
// Default value is 0.0
-@property (nonatomic, assign) float finishVolume;
+@property (nonatomic, assign) float finishVolume;
-// If YES, audio player will be sent a pause message when the fade has completed.
+// If YES, audio player will be sent a pause message when the fade has completed.
// Default value is NO, however, if finishVolume is 0.0, default is YES
-@property (nonatomic, assign) BOOL pauseAfterFade;
+@property (nonatomic, assign) BOOL pauseAfterFade;
// If YES, when the fade has completed the audio player will be sent a stop message.
// Default value is NO.
--- a/project_files/HedgewarsMobile/Classes/MXAudioPlayerFadeOperation.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MXAudioPlayerFadeOperation.m Sat Jan 26 23:57:37 2013 +0100
@@ -10,7 +10,7 @@
#define SKVolumeChangesPerSecond 15
@interface MXAudioPlayerFadeOperation ()
-@property (nonatomic, retain, readwrite) AVAudioPlayer *audioPlayer;
+@property (nonatomic, retain, readwrite) AVAudioPlayer *audioPlayer;
- (void)beginFadeOperation;
- (void)finishFadeOperation;
@end
@@ -87,21 +87,21 @@
else {
ALog(@"AudioPlayerFadeOperation began with invalid AVAudioPlayer");
}
-
+
[pool release];
}
- (void)beginFadeOperation {
if (![self.audioPlayer isPlaying] && _playBeforeFade) [self.audioPlayer play];
-
+
if (_fadeDuration != 0.0) {
-
+
NSTimeInterval sleepInterval = (1.0 / SKVolumeChangesPerSecond);
NSTimeInterval startTime = [[NSDate date] timeIntervalSinceReferenceDate];
NSTimeInterval now = startTime;
-
+
float startVolume = [self.audioPlayer volume];
-
+
while (now < (startTime + _fadeDuration)) {
float ratioOfFadeCompleted = (now - startTime)/_fadeDuration;
float volume = (_finishVolume * ratioOfFadeCompleted) + (startVolume * (1-ratioOfFadeCompleted));
@@ -109,7 +109,7 @@
[NSThread sleepForTimeInterval:sleepInterval];
now = [[NSDate date] timeIntervalSinceReferenceDate];
}
-
+
[self.audioPlayer setVolume:_finishVolume];
[self finishFadeOperation];
}
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -150,8 +150,8 @@
// this set details for a static map (called by didSelectRowAtIndexPath)
-(void) setDetailsForStaticMap:(NSInteger) index {
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
-
- NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg",
+
+ NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg",
(scIndex == 1) ? MAPS_DIRECTORY() : MISSIONS_DIRECTORY(),[source objectAtIndex:index]];
NSString *contents = [[NSString alloc] initWithContentsOfFile:fileCfg encoding:NSUTF8StringEncoding error:NULL];
[fileCfg release];
@@ -166,7 +166,7 @@
else
max = @"18";
[self setMaxLabelText:max];
-
+
self.themeCommand = [NSString stringWithFormat:@"etheme %@", [split objectAtIndex:0]];
self.staticMapCommand = [NSString stringWithFormat:@"emap %@", [source objectAtIndex:index]];
@@ -357,7 +357,7 @@
-(NSArray *) dataSourceArray {
if (dataSourceArray == nil) {
NSString *model = [HWUtils modelType];
-
+
// only folders containing icon.png are a valid theme
NSArray *themeArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:THEMES_DIRECTORY() error:NULL];
NSMutableArray *themeArray = [[NSMutableArray alloc] init];
@@ -367,7 +367,7 @@
[themeArray addObject:themeName];
[checkPath release];
}
-
+
// remove images that are too big for certain devices without loading the whole image
NSArray *mapArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
NSMutableArray *mapArray = [[NSMutableArray alloc] init];
@@ -379,7 +379,7 @@
continue;
[mapArray addObject:str];
}
-
+
NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL];
NSMutableArray *missionArray = [[NSMutableArray alloc] init];
for (NSString *str in missionArrayFull) {
@@ -394,7 +394,7 @@
[missionArray release];
[themeArray release];
[mapArray release];
-
+
self.dataSourceArray = array;
[array release];
}
@@ -404,7 +404,7 @@
-(void) viewDidLoad {
[super viewDidLoad];
srandom(time(NULL));
-
+
// initialize some "default" values
self.slider.value = 0.05f;
self.slider.enabled = NO;
--- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Sat Jan 26 23:57:37 2013 +0100
@@ -52,7 +52,7 @@
}
#pragma mark -
-#pragma mark preview
+#pragma mark preview
-(int) sendToEngine:(NSString *)string {
unsigned char length = [string length];
@@ -157,7 +157,7 @@
[self performSelectorOnMainThread:@selector(removeIndicator)
withObject:nil
waitUntilDone:NO];
-
+
[pool release];
}
@@ -165,12 +165,12 @@
// remove the current preview and title
[self setImage:nil forState:UIControlStateNormal];
[self setTitle:nil forState:UIControlStateNormal];
-
+
// don't display preview on slower device, too slow and memory hog
if (IS_NOT_POWERFUL([HWUtils modelType])) {
[self setTitle:NSLocalizedString(@"Preview not available",@"") forState:UIControlStateNormal];
[self turnOnWidgets];
- } else {
+ } else {
// add a very nice spinning wheel
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
@@ -179,7 +179,7 @@
[indicator startAnimating];
[self addSubview:indicator];
[indicator release];
-
+
// let's draw in a separate thread so the gui can work; at the end it restore other widgets
[NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil];
}
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Jan 26 23:57:37 2013 +0100
@@ -44,7 +44,7 @@
int HW_getMaxNumberOfTeams(void);
void HW_memoryWarningCallback(void);
-
+
#ifdef __cplusplus
}
#endif
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -203,12 +203,12 @@
[self updateTable];
NSString *oldFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:tagValue]];
NSString *newFilePath = [NSString stringWithFormat:@"%@/%@.hws",SAVES_DIRECTORY(),textString];
-
+
if ([oldFilePath isEqualToString:newFilePath] == NO) {
[[NSFileManager defaultManager] moveItemAtPath:oldFilePath toPath:newFilePath error:nil];
[self.listOfSavegames replaceObjectAtIndex:tagValue withObject:[textString stringByAppendingString:@".hws"]];
}
-
+
}
#pragma mark -
--- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -151,7 +151,7 @@
editableCell.selectionStyle = UITableViewCellSelectionStyleNone;
editableCell.imageView.image = nil;
editableCell.detailTextLabel.text = nil;
-
+
if (row == 0) {
editableCell.textField.text = self.schemeName;
editableCell.textField.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
@@ -199,7 +199,7 @@
if ([oneView isMemberOfClass:[UISlider class]]) {
cellSlider = (UISlider *)oneView;
break;
- }
+ }
}
cellSlider.tag = SLIDER_TAG + row;
cellSlider.maximumValue = [[detail objectForKey:@"max"] floatValue];
@@ -244,7 +244,7 @@
UISwitch *switcher = (UISwitch *)cell.accessoryView;
switcher.tag = SWITCH_TAG + row;
[switcher setOn:[[[self.schemeDictionary objectForKey:@"gamemod"] objectAtIndex:row] boolValue] animated:NO];
-
+
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",ICONS_DIRECTORY(),
[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]];
cell.imageView.image = image;
--- a/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -69,7 +69,7 @@
NSLocalizedString(@"Level",@""),nil];
self.secondaryItems = array;
[array release];
-
+
// labels for the subtitles
NSArray *moreArray = [[NSArray alloc] initWithObjects:
NSLocalizedString(@"Mark the death of your fallen warriors",@""),
@@ -295,35 +295,35 @@
case 0: // grave
if (nil == gravesViewController)
gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
[gravesViewController setTeamDictionary:teamDictionary];
[self.navigationController pushViewController:gravesViewController animated:YES];
break;
case 1: // voice
if (nil == voicesViewController)
voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
[voicesViewController setTeamDictionary:teamDictionary];
[self.navigationController pushViewController:voicesViewController animated:YES];
break;
case 2: // fort
if (nil == fortsViewController)
fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
[fortsViewController setTeamDictionary:teamDictionary];
[self.navigationController pushViewController:fortsViewController animated:YES];
break;
case 3: // flag
if (nil == flagsViewController)
flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
[flagsViewController setTeamDictionary:teamDictionary];
[self.navigationController pushViewController:flagsViewController animated:YES];
break;
case 4: // level
if (nil == levelViewController)
levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
[levelViewController setTeamDictionary:teamDictionary];
[self.navigationController pushViewController:levelViewController animated:YES];
break;
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -31,38 +31,38 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
-
+
NSString *trFilePath = [NSString stringWithFormat:@"%@/%@.txt",LOCALE_DIRECTORY(),[[NSLocale preferredLanguages] objectAtIndex:0]];
// fill the data structure that we are going to read
LoadLocaleWrapper([trFilePath UTF8String]);
-
+
quantity = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
probability = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
delay = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
crateness = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1));
-
+
NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()];
UIImage *img = [[UIImage alloc] initWithContentsOfFile:str];
self.ammoStoreImage = img;
[img release];
-
+
self.title = NSLocalizedString(@"Edit weapons preferences",@"");
}
-(void) viewWillAppear:(BOOL) animated {
[super viewWillAppear:animated];
-
+
NSString *ammoFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",WEAPONS_DIRECTORY(),self.weaponName];
NSDictionary *weapon = [[NSDictionary alloc] initWithContentsOfFile:ammoFile];
[ammoFile release];
-
+
self.description = [weapon objectForKey:@"description"];
const char *tmp1 = [[weapon objectForKey:@"ammostore_initialqt"] UTF8String];
const char *tmp2 = [[weapon objectForKey:@"ammostore_probability"] UTF8String];
const char *tmp3 = [[weapon objectForKey:@"ammostore_delay"] UTF8String];
const char *tmp4 = [[weapon objectForKey:@"ammostore_crate"] UTF8String];
[weapon release];
-
+
// if the new weaponset is diffrent from the older we need to update it replacing
// the missing ammos with 0 quantity
int oldlen = strlen(tmp1);
@@ -78,7 +78,7 @@
delay[i] = '0';
crateness[i] = '0';
}
-
+
[self.tableView reloadData];
}
@@ -92,20 +92,20 @@
probability[HW_getNumberOfWeapons()] = '\0';
delay[HW_getNumberOfWeapons()] = '\0';
crateness[HW_getNumberOfWeapons()] = '\0';
-
+
NSString *quantityStr = [NSString stringWithUTF8String:quantity];
NSString *probabilityStr = [NSString stringWithUTF8String:probability];
NSString *delayStr = [NSString stringWithUTF8String:delay];
NSString *cratenessStr = [NSString stringWithUTF8String:crateness];
-
+
NSDictionary *weapon = [[NSDictionary alloc] initWithObjectsAndKeys:
quantityStr,@"ammostore_initialqt",
probabilityStr,@"ammostore_probability",
delayStr,@"ammostore_delay",
- cratenessStr,@"ammostore_crate",
+ cratenessStr,@"ammostore_crate",
self.description,@"description",
nil];
-
+
NSString *ammoFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",WEAPONS_DIRECTORY(),self.weaponName];
[weapon writeToFile:ammoFile atomically:YES];
[ammoFile release];
@@ -131,7 +131,7 @@
static NSString *CellIdentifier1 = @"Cell1";
NSInteger row = [indexPath row];
UITableViewCell *cell = nil;
-
+
if (0 == [indexPath section]) {
EditableCellView *editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (editableCell == nil) {
@@ -143,7 +143,7 @@
editableCell.selectionStyle = UITableViewCellSelectionStyleNone;
editableCell.imageView.image = nil;
editableCell.detailTextLabel.text = nil;
-
+
if (row == 0) {
editableCell.textField.text = self.weaponName;
editableCell.textField.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
--- a/project_files/HedgewarsMobile/Classes/SupportViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/SupportViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -107,7 +107,7 @@
[imgView release];
}
[img release];
-
+
return cell;
}
@@ -150,7 +150,7 @@
imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[footer addSubview:imgView];
[imgView release];
-
+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 20)];
label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
label.textAlignment = UITextAlignmentCenter;
@@ -159,7 +159,7 @@
label.center = CGPointMake(self.tableView.frame.size.width/2, 250);
[footer addSubview:label];
[label release];
-
+
return [footer autorelease];
} else
return nil;
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -150,7 +150,7 @@
cell.textLabel.text = [[[self.listOfAllTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
cell.textLabel.backgroundColor = [UIColor clearColor];
-
+
NSString *teamPath = [NSString stringWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),cell.textLabel.text];
NSDictionary *firstHog = [[[NSDictionary dictionaryWithContentsOfFile:teamPath] objectForKey:@"hedgehogs"] objectAtIndex:0];
if ([[firstHog objectForKey:@"level"] intValue] != 0) {
@@ -159,7 +159,7 @@
[imgString release];
UIImageView *spriteView = [[UIImageView alloc] initWithImage:sprite];
[sprite release];
-
+
cell.accessoryView = spriteView;
[spriteView release];
} else
--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.m Sat Jan 26 23:57:37 2013 +0100
@@ -159,7 +159,7 @@
weaponIcon.frame = CGRectMake(5, 5, 32, 32);
weaponName.frame = CGRectMake(45, 8, 200, 25);
-
+
helpLabel.frame = CGRectMake(200 + helpLabelOffset, 11, helpLabelLength, 20);
// second line
@@ -212,7 +212,7 @@
-(void) startDragging:(id) sender {
UISlider *slider = (UISlider *)sender;
NSString *str = nil;
-
+
switch (slider.tag) {
case 100:
str = NSLocalizedString(@"Initial quantity",@"ammo selection");
--- a/project_files/HedgewarsMobile/Locale/hw-desc_da.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_da.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Hedgewars er tilgængeligt i Mac App Store! Søg efter Hedgewars på din Mac og få din GRATIS kopi i dag!
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
iOS versionen har flere eksklusive funktioner, så som
* iPad VGA-udgangssignal: tilslut en ekstern skærm og spil i fuld oplysning;
--- a/project_files/HedgewarsMobile/Locale/hw-desc_de.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_de.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Hedgewars ist jetzt auch im Mac Appstore verfügbar! Suche Hedgewars von deinem Mac und bekomme deine GRATIS Kopie!
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Der iOS-Port hat einige exklusiven Features, wie z.B.:
* iPad VGA-Ausgabe: Schließe einen externen Bildschirm an und spiele mit voller Auflösung;
--- a/project_files/HedgewarsMobile/Locale/hw-desc_en.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_en.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Hedgewars is available for the Mac Appstore! Search Hedgewars on your Mac and get your FREE copy today!
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
The iOS port has some exclusive features, such as
* iPad VGA Out: hook an external display and play at full resolution;
--- a/project_files/HedgewarsMobile/Locale/hw-desc_es.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_es.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
¡Hedgewars esta disponible en la Mac Appstore! ¡Busca Hedgewars en tu Mac y consigue tu copia gratuita hoy!
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
La versión para iOS contiene algunas características exclusivas, como:
* Salida VGA para iPad: conecta un monitor externo y juega a resolución completa;
--- a/project_files/HedgewarsMobile/Locale/hw-desc_fr.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_fr.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Hedgewars est disponible sur le Mac Appstore ! Cherchez Hedgewars sur votre Mac et obtenez une copie gratuite aujourd'hui !
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Le portage vers iOS a quelques fonctionnalités exclusives, comme :
* Sortie VGA de l'iPad: connectez un affichage externe et jouez à la résolution maximale;
--- a/project_files/HedgewarsMobile/Locale/hw-desc_it.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_it.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Hedgewars è disponiile sul Mac Appstore! Cerca Hedgewars sul tuo Mac e scarica la tua copia gratuitamente!
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
La verisone per iOS offre alcune fantastiche esclusive, come
* iPad VGA Out: attacca un dispaly esterno e gioca a piena risoluzione;
--- a/project_files/HedgewarsMobile/Locale/hw-desc_pl.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_pl.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Hedgewars jest dostępny na Mac Appstore! Poszukaj Hedgewars na swoim Mac'u i otrzymaj kopię za darmo!
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
Port na iOS posiada kilka unikalnych funkcji, takich jak:
* Wtyczka iPad VGA : podłącz zewnętrzny ekran i graj w pełnej rozdzielczości;
--- a/project_files/HedgewarsMobile/Locale/hw-desc_pt.txt Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Locale/hw-desc_pt.txt Sat Jan 26 23:57:37 2013 +0100
@@ -4,7 +4,7 @@
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
O Hedgewars está disponível na Mac App Store! Pesquisa Hedgewars no teu MacBook e obtém a tua cópia GRATUITA hoje!
✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
-✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
+✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭
A versão para iOS tem algumas funcionalidades exclusivas, como
* Saída VGA no iPad: liga-o a um ecrã externo e joga em resolução completa;