# HG changeset patch # User koda # Date 1284862378 -7200 # Node ID 66995a52e2653967d3e7858eddd8fdcd5459ce68 # Parent e570268a9d521575fc9dccd3495cd741360fa36c# Parent a566d33b285683542865b9931f7520957cac0575 merge diff -r a566d33b2856 -r 66995a52e265 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Sat Sep 18 21:30:36 2010 +0200 +++ b/hedgewars/uStore.pas Sun Sep 19 04:12:58 2010 +0200 @@ -395,7 +395,7 @@ if ((cReducedQuality and rqNoBackground) = 0) or (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR, sprFlake, sprSplash, sprDroplet])) then // FIXME: hack begin if AltPath = ptNone then - if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR, sprFlake] then // FIXME: hack + if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR] then // FIXME: hack tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent) else tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical) @@ -489,7 +489,7 @@ _l, _r, _t, _b: real; VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; begin -if (SourceTexture = nil) or (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then exit; +if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then exit; // don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then diff -r a566d33b2856 -r 66995a52e265 project_files/HedgewarsMobile/Classes/GameConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Sep 18 21:30:36 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sun Sep 19 04:12:58 2010 +0200 @@ -104,9 +104,7 @@ [self.view addSubview:activeController.view]; } --(void) startGame:(UIButton *)button { - button.enabled = YES; - +-(BOOL) isEverythingSet { // don't start playing if the preview is in progress if ([mapConfigViewController busy]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Wait for the Preview",@"") @@ -116,9 +114,9 @@ otherButtonTitles:nil]; [alert show]; [alert release]; - return; + return NO; } - + // play only if there is more than one team if ([teamConfigViewController.listOfSelectedTeams count] < 2) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"") @@ -128,14 +126,14 @@ otherButtonTitles:nil]; [alert show]; [alert release]; - return; + return NO; } - + // play if there's room for enough hogs in the selected map int hogs = 0; for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams) hogs += [[teamData objectForKey:@"number"] intValue]; - + if (hogs > mapConfigViewController.maxHogs) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"") message:NSLocalizedString(@"The map is too small for that many hogs",@"") @@ -144,9 +142,20 @@ otherButtonTitles:nil]; [alert show]; [alert release]; - return; + return NO; } - + + if ([teamConfigViewController.listOfSelectedTeams count] > 6) { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many teams",@"") + message:NSLocalizedString(@"Max six teams are allowed in the same game",@"") + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"") + otherButtonTitles:nil]; + [alert show]; + [alert release]; + return NO; + } + if ([schemeWeaponConfigViewController.selectedScheme length] == 0 || [schemeWeaponConfigViewController.selectedWeapon length] == 0 ) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Missing detail",@"") message:NSLocalizedString(@"Select one Scheme and one Weapon for this game",@"") @@ -155,8 +164,17 @@ otherButtonTitles:nil]; [alert show]; [alert release]; + return NO; + } + + return YES; +} + +-(void) startGame:(UIButton *)button { + button.enabled = YES; + + if ([self isEverythingSet] == NO) return; - } // create the configuration file that is going to be sent to engine NSDictionary *gameDictionary = [NSDictionary dictionaryWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command", diff -r a566d33b2856 -r 66995a52e265 project_files/HedgewarsMobile/Classes/LevelViewController.h --- a/project_files/HedgewarsMobile/Classes/LevelViewController.h Sat Sep 18 21:30:36 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/LevelViewController.h Sun Sep 19 04:12:58 2010 +0200 @@ -28,6 +28,8 @@ NSArray *levelArray; NSArray *levelSprites; NSIndexPath *lastIndexPath; + + NSInteger numberOfSections; } @property (nonatomic,retain) NSDictionary *teamDictionary; diff -r a566d33b2856 -r 66995a52e265 project_files/HedgewarsMobile/Classes/LevelViewController.m --- a/project_files/HedgewarsMobile/Classes/LevelViewController.m Sat Sep 18 21:30:36 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/LevelViewController.m Sun Sep 19 04:12:58 2010 +0200 @@ -34,11 +34,10 @@ #pragma mark - #pragma mark View lifecycle -- (void)viewDidLoad { +-(void) viewDidLoad { [super viewDidLoad]; NSArray *array = [[NSArray alloc] initWithObjects: - NSLocalizedString(@"Human",@""), NSLocalizedString(@"Brutal",@""), NSLocalizedString(@"Aggressive",@""), NSLocalizedString(@"Bully",@""), @@ -51,114 +50,132 @@ self.title = NSLocalizedString(@"Set difficulty level",@""); } -- (void)viewWillAppear:(BOOL)animated { +-(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 +} + #pragma mark - #pragma mark Table view data source -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { - return 1; + return numberOfSections; } --(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return [self.levelArray count]; +-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section { + if (section == 0) + return 1; + else + return 5; } // Customize the appearance of table view cells. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *CellIdentifier = @"Cell"; + static NSString *CellIdentifier0 = @"Cell0"; + static NSString *CellIdentifier1 = @"Cell1"; NSInteger row = [indexPath row]; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + NSInteger section = [indexPath section]; + UITableViewCell *cell; + + if (section == 0) { + cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; + UISwitch *theSwitch = [[UISwitch alloc] init]; + if (numberOfSections == 1) + theSwitch.on = NO; + else + theSwitch.on = YES; + [theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged]; + cell.accessoryView = theSwitch; + [theSwitch release]; + } + cell.textLabel.text = NSLocalizedString(@"Hogs controlled by AI",@""); + } else { + 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) { + cell.accessoryType = UITableViewCellAccessoryCheckmark; + self.lastIndexPath = indexPath; + } else { + cell.accessoryType = UITableViewCellAccessoryNone; + } + + NSString *botlevelPath = [[NSString alloc] initWithFormat:@"%@/%d.png",BOTLEVELS_DIRECTORY(),row+1]; + UIImage *levelImage = [[UIImage alloc] initWithContentsOfFile:botlevelPath]; + [botlevelPath release]; + cell.imageView.image = levelImage; + [levelImage release]; } - - cell.textLabel.text = [levelArray objectAtIndex:row]; - NSDictionary *hog = [[self.teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:0]; - if ([[hog objectForKey:@"level"] intValue] == row) { - cell.accessoryType = UITableViewCellAccessoryCheckmark; - self.lastIndexPath = indexPath; - } else { - cell.accessoryType = UITableViewCellAccessoryNone; - } - - NSString *botlevelPath = [[NSString alloc] initWithFormat:@"%@/%d.png",BOTLEVELS_DIRECTORY(),row]; - UIImage *levelImage = [[UIImage alloc] initWithContentsOfFile:botlevelPath]; - [botlevelPath release]; - cell.imageView.image = levelImage; - [levelImage release]; - + return cell; } - -/* -// Override to support conditional editing of the table view. -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the specified item to be editable. - return YES; -} -*/ +-(void) switchValueChanged:(id) sender { + UISwitch *theSwitch = (UISwitch *)sender; + NSIndexSet *sections = [[NSIndexSet alloc] initWithIndex:1]; + NSMutableArray *hogs = [self.teamDictionary objectForKey:@"hedgehogs"]; + if (theSwitch.on) { + numberOfSections = 2; + [self.tableView insertSections:sections withRowAnimation:UITableViewRowAnimationFade]; + for (NSMutableDictionary *hog in hogs) + [hog setObject:[NSNumber numberWithInt:4] forKey:@"level"]; + + [[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil]; + [self.tableView reloadData]; + } else { + numberOfSections = 1; + [self.tableView deleteSections:sections withRowAnimation:UITableViewRowAnimationFade]; + + for (NSMutableDictionary *hog in hogs) + [hog setObject:[NSNumber numberWithInt:0] forKey:@"level"]; -/* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil]; } - else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } -} -*/ - - -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { + [sections release]; } -*/ - - -/* -// Override to support conditional rearranging of the table view. -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the item to be re-orderable. - return YES; -} -*/ #pragma mark - #pragma mark Table view delegate -- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { +-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int newRow = [indexPath row]; - int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; - - if (newRow != oldRow) { - NSMutableArray *hogs = [teamDictionary objectForKey:@"hedgehogs"]; + int oldRow = (self.lastIndexPath != nil) ? [self.lastIndexPath row] : -1; - for (NSMutableDictionary *hog in hogs) { - [hog setObject:[NSNumber numberWithInt:newRow] forKey:@"level"]; + if ([indexPath section] != 0) { + if (newRow != oldRow) { + NSMutableArray *hogs = [self.teamDictionary objectForKey:@"hedgehogs"]; + + for (NSMutableDictionary *hog in hogs) + [hog setObject:[NSNumber numberWithInt:newRow+1] forKey:@"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]; } - - // 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]; + [self.navigationController popViewControllerAnimated:YES]; } [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; - [self.navigationController popViewControllerAnimated:YES]; } diff -r a566d33b2856 -r 66995a52e265 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Sep 18 21:30:36 2010 +0200 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sun Sep 19 04:12:58 2010 +0200 @@ -2027,7 +2027,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\ncp -R ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\n\n#copy some files from QTfrontend/res\nmkdir ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/btn*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/ammopic.png ${PROJECT_DIR}/Data/Graphics/Btn/iconAmmo.png\ncp ${PROJECT_DIR}/../../QTfrontend/res/icon*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels\n\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps and hats\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,KnockBall,Ruler,BasketBall}\nrm -rf ${PROJECT_DIR}/Data/Hats/{TeamCap,TeamHeadband,TeamHair}\n\ncp -R ${PROJECT_DIR}/audio/* ${PROJECT_DIR}/Data/\n\n#the following ones must be removed when their support is implemented\nrm -rf ${PROJECT_DIR}/Data/Maps/{Cheese,FlightJoust}\nrm -rf ${PROJECT_DIR}/Data/Themes/{City,Island}\n\n#delete some voices\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/Classic\n#rm -rf ${PROJECT_DIR}/Data/Sounds/voices/{Classic,British,Mobster,Pirate,Robot,Russian,Singer,Surfer}\n\n#delete useless fonts\nrm -rf ${PROJECT_DIR}/Data/Fonts/wqy-zenhei.ttc\n\n#delete all names, missions, reserved hats\nrm -rf ${PROJECT_DIR}/Data/Names/\nrm -rf ${PROJECT_DIR}/Data/Missions/\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/\n"; + shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\ncp -R ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\n\n#copy some files from QTfrontend/res\nmkdir ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/btn*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/ammopic.png ${PROJECT_DIR}/Data/Graphics/Btn/iconAmmo.png\ncp ${PROJECT_DIR}/../../QTfrontend/res/icon*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels\n\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps and hats\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,KnockBall,Ruler,BasketBall}\nrm -rf ${PROJECT_DIR}/Data/Hats/{TeamCap,TeamHeadband,TeamHair}\n\ncp -R ${PROJECT_DIR}/audio/* ${PROJECT_DIR}/Data/\n\n#the following ones must be removed when their support is implemented\nrm -rf ${PROJECT_DIR}/Data/Maps/{Cheese,FlightJoust}\nrm -rf ${PROJECT_DIR}/Data/Themes/Island\n\n#reduce the number of flakes for City\nawk '{if ($1 == 1500) $1=40; print $0}' < ${PROJECT_DIR}/Data/Themes/City/theme.cfg > /tmp/tempfile\nmv /tmp/tempfile ${PROJECT_DIR}/Data/Themes/City/theme.cfg\n\n#remove Isalnd from the list of Themes\nawk '{if ($1 != \"Island\") print $0}' < ${PROJECT_DIR}/Data/Themes/themes.cfg > /tmp/tempfile\nmv /tmp/tempfile ${PROJECT_DIR}/Data/Themes/themes.cfg\n\n#delete some voices\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/Classic\n#rm -rf ${PROJECT_DIR}/Data/Sounds/voices/{Classic,British,Mobster,Pirate,Robot,Russian,Singer,Surfer}\n\n#delete useless fonts\nrm -rf ${PROJECT_DIR}/Data/Fonts/wqy-zenhei.ttc\nrm -rf ${PROJECT_DIR}/Data/Fonts/DroidSansFallback.ttf\n\n#delete all names, missions, reserved hats\nrm -rf ${PROJECT_DIR}/Data/Names/\nrm -rf ${PROJECT_DIR}/Data/Missions/\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/\n"; showEnvVarsInLog = 0; }; 9283011B0F10CB2D00CC5A3C /* Build libfpc.a */ = {