# HG changeset patch # User koda # Date 1288633898 -3600 # Node ID bfe14b38dad116fea320b1fb58292e6bce3d6f90 # Parent d4cb8f2167240a3c7a28162d4f1d25e10e4bdd7e better support for wimpier i-devices diff -r d4cb8f216724 -r bfe14b38dad1 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Mon Nov 01 13:02:39 2010 -0400 +++ b/hedgewars/uTeams.pas Mon Nov 01 18:51:38 2010 +0100 @@ -275,9 +275,7 @@ ResetKbd; cWindSpeed:= rndSign(GetRandom * 2 * cMaxWindSpeed); -// cWindSpeedf:= cWindSpeed.QWordValue / _1.QWordValue throws Internal error 200502052 on fpc 2.5.1 -// see http://mantis.freepascal.org/view.php?id=17714 -cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; +cWindSpeedf:= cWindSpeed.QWordValue / _1.QWordValue; if cWindSpeed.isNegative then CWindSpeedf := -cWindSpeedf; g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1); diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/AboutViewController.m --- a/project_files/HedgewarsMobile/Classes/AboutViewController.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/AboutViewController.m Mon Nov 01 18:51:38 2010 +0100 @@ -30,7 +30,8 @@ } -(void) viewDidLoad { - self.tableView.backgroundView = nil; + if ([UITableView respondsToSelector:@selector(setBackgroundView:)]) + self.tableView.backgroundView = nil; self.tableView.allowsSelection = NO; NSString *strPath = [NSString stringWithFormat:@"%@/credits.plist",IFRONTEND_DIRECTORY()]; diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m --- a/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m Mon Nov 01 18:51:38 2010 +0100 @@ -334,7 +334,8 @@ #pragma mark memory -(void) didReceiveMemoryWarning { self.imagesArray = nil; - self.buttonsArray = nil; + if (self.isVisible == NO) + self.buttonsArray = nil; self.nameLabel = nil; self.extraLabel = nil; self.captionLabel = nil; diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/CommodityFunctions.h --- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.h Mon Nov 01 18:51:38 2010 +0100 @@ -53,9 +53,10 @@ #define UICOLOR_HW_DARKBLUE [UIColor colorWithRed:(CGFloat)0x0F/255 green:0 blue:(CGFloat)0x42/255 alpha:1] #define UICOLOR_HW_ALPHABLUE [UIColor colorWithRed:(CGFloat)0x0F/255 green:0 blue:(CGFloat)0x42/255 alpha:0.58f] -#define IS_DUALHEAD() ([[UIScreen screens] count] > 1) +#define IS_DUALHEAD() ([UIScreen respondsToSelector:@selector(screens)] && [[UIScreen screens] count] > 1) #define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) - +#define IS_NOT_POWERFUL() ([modelType() hasPrefix:@"iPhone1"] || [modelType() hasPrefix:@"iPod1,1"] || [modelType() hasPrefix:@"iPod2,1"]) + #define DEFAULT_NETGAME_PORT 46631 diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/GameSetup.m --- a/project_files/HedgewarsMobile/Classes/GameSetup.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Mon Nov 01 18:51:38 2010 +0100 @@ -389,7 +389,6 @@ //[[NSNotificationCenter defaultCenter] postNotificationName:@"removedSave" object:nil]; // and remove + disable the overlay [[NSNotificationCenter defaultCenter] postNotificationName:@"remove overlay" object:nil]; - setGameRunning(NO); break; default: [self dumpRawData:buffer ofSize:msgSize]; diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/MapConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Mon Nov 01 18:51:38 2010 +0100 @@ -71,7 +71,8 @@ // perform as if user clicked on an entry [self tableView:self.tableView didSelectRowAtIndexPath:theIndex]; - [self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionNone animated:YES]; + if (IS_NOT_POWERFUL() == NO) + [self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionNone animated:YES]; } -(void) turnOffWidgets { @@ -222,7 +223,7 @@ } #pragma mark - -#pragma mark slider & segmentedControl +#pragma mark slider & segmentedControl & button // this updates the label and the command keys when the slider is moved, depending of the selection in segmentedControl // no methods are called by this routine and you can pass nil to it -(IBAction) sliderChanged:(id) sender { @@ -367,12 +368,14 @@ oldPage = newPage; } -#pragma mark - -#pragma mark calls the parent's function that checks the parameters and starts the game -(IBAction) buttonPressed:(id) sender { - [[NSNotificationCenter defaultCenter] postNotificationName:@"buttonPressed" object:nil userInfo:[NSDictionary dictionaryWithObject:sender forKey:@"sender"]]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"buttonPressed" + object:nil + userInfo:[NSDictionary dictionaryWithObject:sender forKey:@"sender"]]; } +#pragma mark - +#pragma mark view management -(void) loadDataSourceArray { // themes.cfg contains all the user-selectable themes NSString *string = [[NSString alloc] initWithContentsOfFile:[THEMES_DIRECTORY() stringByAppendingString:@"/themes.cfg"] @@ -391,8 +394,6 @@ [themeArray release]; } -#pragma mark - -#pragma mark view management -(void) viewDidLoad { [super viewDidLoad]; @@ -424,7 +425,8 @@ self.missionCommand = @""; if (IS_IPAD()) { - [self.tableView setBackgroundView:nil]; + if ([UITableView respondsToSelector:@selector(setBackgroundView:)]) + [self.tableView setBackgroundView:nil]; self.view.backgroundColor = [UIColor clearColor]; self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/MapPreviewButtonView.h --- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.h Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.h Mon Nov 01 18:51:38 2010 +0100 @@ -38,12 +38,12 @@ @property (nonatomic,assign) id delegate; - -(void) setBackgroundImageRounded:(UIImage *)image forState:(UIControlState)state; -(void) setImageRounded:(UIImage *)image forState:(UIControlState)state; -(void) setImageRoundedForNormalState:(UIImage *)image; -(void) updatePreviewWithSeed:(NSString *)seed; -(void) updatePreviewWithFile:(NSString *)filePath; +-(void) turnOnWidgets; -(NSDictionary *)getDataForEngine; @end diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m --- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m Mon Nov 01 18:51:38 2010 +0100 @@ -196,10 +196,9 @@ [self setTitle:nil forState:UIControlStateNormal]; // don't display preview on slower device, too slow and memory hog - NSString *modelId = modelType(); - if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"]) { - //self.delegate.busy = NO; + if (IS_NOT_POWERFUL()) { [self setTitle:NSLocalizedString(@"Preview not available",@"") forState:UIControlStateNormal]; + [self turnOnWidgets]; } else { // add a very nice spinning wheel UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/OverlayViewController.m --- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Mon Nov 01 18:51:38 2010 +0100 @@ -133,7 +133,10 @@ } // get the number of screens to know the previous state whan a display is connected or detached - initialScreenCount = [[UIScreen screens] count]; + if ([UIScreen respondsToSelector:@selector(screens)]) + initialScreenCount = [[UIScreen screens] count]; + else + initialScreenCount = 1; // set initial orientation of the controller orientation if (IS_DUALHEAD()) { @@ -175,16 +178,19 @@ selector:@selector(cleanup) name:@"remove overlay" object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(numberOfScreensIncreased) - name:UIScreenDidConnectNotification - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(numberOfScreensDecreased) - name:UIScreenDidDisconnectNotification - object:nil]; + + // for iOS > 3.2 + if ([UIScreen respondsToSelector:@selector(screens)]) { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(numberOfScreensIncreased) + name:UIScreenDidConnectNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(numberOfScreensDecreased) + name:UIScreenDidDisconnectNotification + object:nil]; + } // present the overlay [UIView beginAnimations:@"showing overlay" context:NULL]; @@ -234,6 +240,7 @@ -(void) cleanup { [self dismissPopover]; + setGameRunning(NO); HW_terminate(NO); [self.view removeFromSuperview]; } diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/SavedGamesViewController.m --- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Mon Nov 01 18:51:38 2010 +0100 @@ -40,8 +40,10 @@ } -(void) viewDidLoad { - self.tableView.backgroundView = nil; - NSString *imgName; + if ([UITableView respondsToSelector:@selector(setBackgroundView:)]) + self.tableView.backgroundView = nil; + + NSString *imgName; if (IS_IPAD()) imgName = @"mediumBackground~ipad.png"; else @@ -49,6 +51,7 @@ UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; self.view.backgroundColor = [UIColor colorWithPatternImage:img]; [img release]; + [super viewDidLoad]; } diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Mon Nov 01 18:51:38 2010 +0100 @@ -41,7 +41,8 @@ self.selectedScheme = nil; self.selectedWeapon = nil; - [self.tableView setBackgroundView:nil]; + if ([UITableView respondsToSelector:@selector(setBackgroundView:)]) + [self.tableView setBackgroundView:nil]; self.view.backgroundColor = [UIColor clearColor]; self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Classes/TeamConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Mon Nov 01 18:51:38 2010 +0100 @@ -38,8 +38,9 @@ CGSize screenSize = [[UIScreen mainScreen] bounds].size; self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44); - - [self.tableView setBackgroundView:nil]; + + if ([UITableView respondsToSelector:@selector(setBackgroundView:)]) + [self.tableView setBackgroundView:nil]; self.view.backgroundColor = [UIColor clearColor]; self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; diff -r d4cb8f216724 -r bfe14b38dad1 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Mon Nov 01 13:02:39 2010 -0400 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Mon Nov 01 18:51:38 2010 +0100 @@ -2385,7 +2385,7 @@ "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer/\"", ); - IPHONEOS_DEPLOYMENT_TARGET = 3.2; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-lz", @@ -2397,7 +2397,7 @@ SDKROOT = iphoneos4.1; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; - VALID_ARCHS = "armv6 armv7"; + VALID_ARCHS = "armv7 armv6"; }; name = DistributionAppStore; }; @@ -2479,7 +2479,7 @@ "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer/\"", ); - IPHONEOS_DEPLOYMENT_TARGET = 3.2; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-lz", @@ -2491,7 +2491,7 @@ SDKROOT = iphoneos4.1; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; - VALID_ARCHS = "armv6 armv7"; + VALID_ARCHS = "armv7 armv6"; }; name = DistributionAdHoc; }; @@ -2574,7 +2574,7 @@ "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer/\"", ); - IPHONEOS_DEPLOYMENT_TARGET = 3.2; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-lz", @@ -2584,7 +2584,7 @@ SDKROOT = iphoneos4.1; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = NO; - VALID_ARCHS = "armv6 armv7"; + VALID_ARCHS = "armv7 armv6"; }; name = Valgrind; }; @@ -2707,7 +2707,7 @@ "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer/\"", ); - IPHONEOS_DEPLOYMENT_TARGET = 3.2; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-lz", @@ -2717,7 +2717,7 @@ SDKROOT = iphoneos4.1; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = NO; - VALID_ARCHS = "armv6 armv7"; + VALID_ARCHS = "armv7 armv6"; }; name = Debug; }; @@ -2751,7 +2751,7 @@ "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net/\"", "\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer/\"", ); - IPHONEOS_DEPLOYMENT_TARGET = 3.2; + IPHONEOS_DEPLOYMENT_TARGET = 3.1; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-lz", @@ -2763,7 +2763,7 @@ SDKROOT = iphoneos4.1; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = NO; - VALID_ARCHS = "armv6 armv7"; + VALID_ARCHS = "armv7 armv6"; }; name = Release; };