# HG changeset patch # User koda # Date 1276901327 -7200 # Node ID 156c04c6a3d89f859402abc047fd9d63b9d43b61 # Parent c3dcb80bdb1da3ac72e15bd3e34b4faeb75baade add initial stubs for selecting weapons in the ifrontend diff -r c3dcb80bdb1d -r 156c04c6a3d8 CMakeLists.txt --- a/CMakeLists.txt Fri Jun 18 20:45:45 2010 +0200 +++ b/CMakeLists.txt Sat Jun 19 00:48:47 2010 +0200 @@ -244,21 +244,21 @@ "hwconsts.cpp$" "playlist.inc$" "CPack" - "^${PROJECT_SOURCE_DIR}/misc/openalbridge" - "^${PROJECT_SOURCE_DIR}/cocoaTouch" - "^${PROJECT_SOURCE_DIR}/bin/[a-z]" - "^${PROJECT_SOURCE_DIR}/tools/templates" - "^${PROJECT_SOURCE_DIR}/doc" - "^${PROJECT_SOURCE_DIR}/templates" - "^${PROJECT_SOURCE_DIR}/Graphics" - "^${PROJECT_SOURCE_DIR}/realtest" - "^${PROJECT_SOURCE_DIR}/tmp" - "^${PROJECT_SOURCE_DIR}/utils" - "^${PROJECT_SOURCE_DIR}/share/hedgewars/Data/Maps/test" - "^${PROJECT_SOURCE_DIR}/share/hedgewars/Data/Themes/ethereal" - "^${PROJECT_SOURCE_DIR}/install_manifest.txt" - "^${PROJECT_SOURCE_DIR}/CMakeCache.txt" - "^${PROJECT_SOURCE_DIR}/hedgewars\\\\." +# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libopenalbridge" + "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/HedgewarsMobile/" + "^${CMAKE_CURRENT_SOURCE_DIR}/bin/[a-z]" + "^${CMAKE_CURRENT_SOURCE_DIR}/tools/templates" + "^${CMAKE_CURRENT_SOURCE_DIR}/doc" + "^${CMAKE_CURRENT_SOURCE_DIR}/templates" + "^${CMAKE_CURRENT_SOURCE_DIR}/Graphics" + "^${CMAKE_CURRENT_SOURCE_DIR}/realtest" + "^${CMAKE_CURRENT_SOURCE_DIR}/tmp" + "^${CMAKE_CURRENT_SOURCE_DIR}/utils" + "^${CMAKE_CURRENT_SOURCE_DIR}/share/hedgewars/Data/Maps/test" + "^${CMAKE_CURRENT_SOURCE_DIR}/share/hedgewars/Data/Themes/ethereal" + "^${CMAKE_CURRENT_SOURCE_DIR}/install_manifest.txt" + "^${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" + "^${CMAKE_CURRENT_SOURCE_DIR}/hedgewars\\\\." ) include(CPack) diff -r c3dcb80bdb1d -r 156c04c6a3d8 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Fri Jun 18 20:45:45 2010 +0200 +++ b/hedgewars/CCHandlers.inc Sat Jun 19 00:48:47 2010 +0200 @@ -730,6 +730,7 @@ AddFileLog('Freeing old primary surface...'); {$ENDIF} SDL_FreeSurface(SDLPrimSurface); + SDLPrimSurface:= nil; end; {$IFDEF SDL13} diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/GameSetup.m --- a/project_files/HedgewarsMobile/Classes/GameSetup.m Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Sat Jun 19 00:48:47 2010 +0200 @@ -102,14 +102,9 @@ // unpacks ammostore data from the selected ammo.plist to a sequence of engine commands -(void) provideAmmoData:(NSString *)ammostoreName forPlayingTeams:(NSInteger) numberOfTeams { - - //NSDictionary *ammoData = [[NSDictionary alloc] initWithContentsOfFile:ammoDataFile]; - NSDictionary *ammoData = [[NSDictionary alloc] initWithObjectsAndKeys: - @"9391929422199121032235111001201000000211190911",@"ammostore_initialqt", - @"0405040541600655546554464776576666666155501000",@"ammostore_probability", - @"0000000000000205500000040007004000000000200000",@"ammostore_delay", - @"1311110312111111123114111111111111111211101111",@"ammostore_crate", nil]; - + NSString *weaponPath = [[NSString alloc] initWithFormat:@"%@/%@",WEAPONS_DIRECTORY(),ammostoreName]; + NSDictionary *ammoData = [[NSDictionary alloc] initWithContentsOfFile:ammoDataFile]; + [weaponPath release]; NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@", [ammoData objectForKey:@"ammostore_initialqt"]]; [self sendToEngine: ammloadt]; @@ -250,23 +245,23 @@ serverQuit = NO; if (SDLNet_Init() < 0) { - NSLog(@"SDLNet_Init: %s", SDLNet_GetError()); + DLog(@"SDLNet_Init: %s", SDLNet_GetError()); serverQuit = YES; } // Resolving the host using NULL make network interface to listen if (SDLNet_ResolveHost(&ip, NULL, ipcPort) < 0) { - NSLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError()); + DLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError()); serverQuit = YES; } // Open a connection with the IP provided (listen on the host's port) if (!(sd = SDLNet_TCP_Open(&ip))) { - NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), ipcPort); + DLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), ipcPort); serverQuit = YES; } - NSLog(@"engineProtocol - Waiting for a client on port %d", ipcPort); + DLog(@"Waiting for a client on port %d", ipcPort); while (!serverQuit) { // This check the sd if there is a pending connection. // If there is one, accept that, and open a new socket for communicating @@ -274,17 +269,17 @@ if (NULL != csd) { // Now we can communicate with the client using csd socket // sd will remain opened waiting other connections - NSLog(@"engineProtocol - Client found"); + DLog(@"client found"); //first byte of the command alwayas contain the size of the command SDLNet_TCP_Recv(csd, &msgSize, sizeof(uint8_t)); SDLNet_TCP_Recv(csd, buffer, msgSize); gameTicks = SDLNet_Read16 (&buffer[msgSize - 2]); - //NSLog(@"engineProtocol - %d: received [%s]", gameTicks, buffer); + //DLog(@"engineProtocol - %d: received [%s]", gameTicks, buffer); if ('C' == buffer[0]) { - NSLog(@"engineProtocol - sending game config"); + DLog(@"sending game config"); // local game [self sendToEngine:@"TL"]; @@ -311,11 +306,11 @@ ofColor:[teamData objectForKey:@"color"]]; } - [self provideAmmoData:nil forPlayingTeams:[teamsConfig count]]; + [self provideAmmoData:@"Default" forPlayingTeams:[teamsConfig count]]; clientQuit = NO; } else { - NSLog(@"engineProtocolThread - wrong message or client closed connection"); + DLog(@"wrong message or client closed connection"); clientQuit = YES; } @@ -329,15 +324,15 @@ clientQuit = YES; gameTicks = SDLNet_Read16(&buffer[msgSize - 2]); - //NSLog(@"engineProtocolThread - %d: received [%s]", gameTicks, buffer); + //DLog(@"engineProtocolThread - %d: received [%s]", gameTicks, buffer); switch (buffer[0]) { case '?': - NSLog(@"Ping? Pong!"); + DLog(@"Ping? Pong!"); [self sendToEngine:@"!"]; break; case 'E': - NSLog(@"ERROR - last console line: [%s]", buffer); + DLog(@"ERROR - last console line: [%s]", buffer); clientQuit = YES; break; case 'e': @@ -347,9 +342,9 @@ HW_versionInfo(&netProto, &versionStr); if (netProto == eProto) { - NSLog(@"Setting protocol version %d (%s)", eProto, versionStr); + DLog(@"Setting protocol version %d (%s)", eProto, versionStr); } else { - NSLog(@"ERROR - wrong protocol number: [%s] - expecting %d", buffer, eProto); + DLog(@"ERROR - wrong protocol number: [%s] - expecting %d", buffer, eProto); clientQuit = YES; } @@ -360,7 +355,7 @@ NSLog(@"Winning team: %s", &buffer[2]); break; case 'k': - NSLog(@"Best Hedgehog: %s", &buffer[2]); + NSLog(@"Best Hedgehog: %s", &buffer[2]); break; } break; @@ -370,7 +365,7 @@ // missing case for exiting right away } } - NSLog(@"Engine exited, closing server"); + DLog(@"Engine exited, closing server"); // wait a little to let the client close cleanly [NSThread sleepForTimeInterval:2]; // Close the client socket diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/MainMenuViewController.m --- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sat Jun 19 00:48:47 2010 +0200 @@ -71,10 +71,10 @@ [alert addSubview:indicator]; [indicator release]; - // create a team + // create default files (teams/weapons/scheme) createTeamNamed(@"Pirates"); createTeamNamed(@"Ninjas"); - + createWeaponNamed(@"Default"); createSchemeNamed(@"Default"); // create settings.plist diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m --- a/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Sat Jun 19 00:48:47 2010 +0200 @@ -118,7 +118,6 @@ #pragma mark - #pragma mark Table view delegate - -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (childController == nil) { childController = [[SingleSchemeViewController alloc] initWithStyle:UITableViewStyleGrouped]; diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/SingleWeaponViewController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.h Sat Jun 19 00:48:47 2010 +0200 @@ -0,0 +1,16 @@ +// +// SingleWeaponViewController.h +// Hedgewars +// +// Created by Vittorio on 19/06/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import + + +@interface SingleWeaponViewController : UITableViewController { + +} + +@end diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m Sat Jun 19 00:48:47 2010 +0200 @@ -0,0 +1,180 @@ +// +// SingleWeaponViewController.m +// Hedgewars +// +// Created by Vittorio on 19/06/10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "SingleWeaponViewController.h" + + +@implementation SingleWeaponViewController + + +#pragma mark - +#pragma mark Initialization + +/* +- (id)initWithStyle:(UITableViewStyle)style { + // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. + if ((self = [super initWithStyle:style])) { + } + return self; +} +*/ + + +#pragma mark - +#pragma mark View lifecycle + +/* +- (void)viewDidLoad { + [super viewDidLoad]; + + // Uncomment the following line to preserve selection between presentations. + self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} +*/ + +/* +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; +} +*/ +/* +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} +*/ +/* +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; +} +*/ +/* +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; +} +*/ +/* +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} +*/ + + +#pragma mark - +#pragma mark Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + // Return the number of sections. + return 0; +} + + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + // Return the number of rows in the section. + return 0; +} + + +// Customize the appearance of table view cells. +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + } + + // Configure the cell... + + 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; +} +*/ + + +/* +// 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]; + } + 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 { +} +*/ + + +/* +// 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 *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + // Navigation logic may go here. Create and push another view controller. + /* + <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; + // ... + // Pass the selected object to the new view controller. + [self.navigationController pushViewController:detailViewController animated:YES]; + [detailViewController release]; + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Relinquish ownership any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. + // For example: self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end + diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/VoicesViewController.m --- a/project_files/HedgewarsMobile/Classes/VoicesViewController.m Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/VoicesViewController.m Sat Jun 19 00:48:47 2010 +0200 @@ -27,6 +27,12 @@ srandom(time(NULL)); openal_init(20); + voiceBeingPlayed = -1; + + // load all the voices names and store them into voiceArray + // it's here and not in viewWillAppear because user cannot add/remove them + NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:VOICES_DIRECTORY() error:NULL]; + self.voiceArray = array; } - (void)viewWillAppear:(BOOL)animated { @@ -34,20 +40,9 @@ // this moves the tableview to the top [self.tableView setContentOffset:CGPointMake(0,0) animated:NO]; - voiceBeingPlayed = -1; - - // load all the voices names and store them into voiceArray - NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:VOICES_DIRECTORY() error:NULL]; - self.voiceArray = array; } -/* -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; -} -*/ - -- (void)viewWillDisappear:(BOOL)animated { +-(void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; if(voiceBeingPlayed >= 0) { openal_stopsound(voiceBeingPlayed); diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.h --- a/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.h Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.h Sat Jun 19 00:48:47 2010 +0200 @@ -7,10 +7,13 @@ // #import - +@class SingleWeaponViewController; @interface WeaponSettingsViewController : UITableViewController { - + NSMutableArray *listOfWeapons; + SingleWeaponViewController *childController; } +@property (nonatomic, retain) NSMutableArray *listOfWeapons; + @end diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m --- a/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Sat Jun 19 00:48:47 2010 +0200 @@ -7,85 +7,87 @@ // #import "WeaponSettingsViewController.h" - +#import "CommodityFunctions.h" +#import "SingleWeaponViewController.h" @implementation WeaponSettingsViewController - - -#pragma mark - -#pragma mark Initialization +@synthesize listOfWeapons; -/* -- (id)initWithStyle:(UITableViewStyle)style { - // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - if ((self = [super initWithStyle:style])) { - } - return self; +-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + return rotationManager(interfaceOrientation); } -*/ - #pragma mark - #pragma mark View lifecycle - -/* -- (void)viewDidLoad { +-(void) viewDidLoad { [super viewDidLoad]; - - // Uncomment the following line to preserve selection between presentations. - self.clearsSelectionOnViewWillAppear = NO; - - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; -} -*/ - -/* -- (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; + + UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the weapon panel") + style:UIBarButtonItemStyleBordered + target:self + action:@selector(toggleEdit:)]; + self.navigationItem.rightBarButtonItem = editButton; + [editButton release]; + } -*/ -/* -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; -} -*/ -/* -- (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; -} -*/ -/* -- (void)viewDidDisappear:(BOOL)animated { - [super viewDidDisappear:animated]; -} -*/ - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - // Override to allow orientations other than the default portrait orientation. - return YES; +-(void) viewWillAppear:(BOOL) animated { + [super viewWillAppear:animated]; + + NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:WEAPONS_DIRECTORY() error:NULL]; + NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES]; + self.listOfWeapons = array; + [array release]; + + [self.tableView reloadData]; } +// modifies the navigation bar to add the "Add" and "Done" buttons +-(void) toggleEdit:(id) sender { + BOOL isEditing = self.tableView.editing; + [self.tableView setEditing:!isEditing animated:YES]; + + if (isEditing) { + [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the scheme panel")]; + [self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered]; + self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem; + } else { + [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Done",@"from the scheme panel")]; + [self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone]; + UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Add",@"from the scheme panel") + style:UIBarButtonItemStyleBordered + target:self + action:@selector(addWeapon:)]; + self.navigationItem.leftBarButtonItem = addButton; + [addButton release]; + } +} + +-(void) addWeapon:(id) sender { + NSString *fileName = [[NSString alloc] initWithFormat:@"Weapon %u.plist", [self.listOfWeapons count]]; + + createWeaponNamed([fileName stringByDeletingPathExtension]); + + [self.listOfWeapons addObject:fileName]; + [fileName release]; + + // order the array alphabetically, so schemes will keep their position + [self.listOfWeapons sortUsingSelector:@selector(compare:)]; + + [self.tableView reloadData]; +} #pragma mark - #pragma mark Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - // Return the number of sections. +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - // Return the number of rows in the section. - return 1; +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return [self.listOfWeapons count]; } - -// Customize the appearance of table view cells. -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - +-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; @@ -93,84 +95,63 @@ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } - // Configure the cell... + NSUInteger row = [indexPath row]; + NSString *rowString = [[self.listOfWeapons objectAtIndex:row] stringByDeletingPathExtension]; + cell.textLabel.text = rowString; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 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; -} -*/ - - -/* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { +// delete the row and the file +-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + NSUInteger row = [indexPath row]; - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; - } - 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 - } + NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@",WEAPONS_DIRECTORY(),[self.listOfWeapons objectAtIndex:row]]; + [[NSFileManager defaultManager] removeItemAtPath:schemeFile error:NULL]; + [schemeFile release]; + + [self.listOfWeapons removeObjectAtIndex:row]; + [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } -*/ - - -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { -} -*/ - - -/* -// 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 *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (childController == nil) { + childController = [[SingleWeaponViewController alloc] initWithStyle:UITableViewStyleGrouped]; + } + + NSInteger row = [indexPath row]; + NSString *selectedWeaponFile = [self.listOfWeapons objectAtIndex:row]; + + // this must be set so childController can load the correct plist + childController.title = [selectedWeaponFile stringByDeletingPathExtension]; + [childController.tableView setContentOffset:CGPointMake(0,0) animated:NO]; -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - // Navigation logic may go here. Create and push another view controller. - /* - <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; - // ... - // Pass the selected object to the new view controller. - [self.navigationController pushViewController:detailViewController animated:YES]; - [detailViewController release]; - */ + [self.navigationController pushViewController:childController animated:YES]; } #pragma mark - #pragma mark Memory management - -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. +-(void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; - - // Relinquish ownership any cached data, images, etc that aren't in use. + if (childController.view.superview == nil ) + childController = nil; } -- (void)viewDidUnload { - // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. - // For example: self.myOutlet = nil; +-(void) viewDidUnload { + self.listOfWeapons = nil; + childController = nil; + [super viewDidUnload]; + MSG_DIDUNLOAD(); } -- (void)dealloc { +-(void) dealloc { + [self.listOfWeapons release]; + [childController release]; [super dealloc]; } diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/otherSrc/CommodityFunctions.h --- a/project_files/HedgewarsMobile/Classes/otherSrc/CommodityFunctions.h Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/otherSrc/CommodityFunctions.h Sat Jun 19 00:48:47 2010 +0200 @@ -20,6 +20,8 @@ #define TEAMS_DIRECTORY() [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \ objectAtIndex:0] stringByAppendingString:@"/Teams/"] +#define WEAPONS_DIRECTORY() [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \ + objectAtIndex:0] stringByAppendingString:@"/Weapons/"] #define SCHEMES_DIRECTORY() [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \ objectAtIndex:0] stringByAppendingString:@"/Schemes/"] @@ -38,6 +40,7 @@ #define MSG_DIDUNLOAD() DLog(@"did unload"); void createTeamNamed (NSString *nameWithoutExt); +void createWeaponNamed (NSString *nameWithoutExt); void createSchemeNamed (NSString *nameWithoutExt); BOOL rotationManager (UIInterfaceOrientation interfaceOrientation); NSInteger randomPort (); diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/otherSrc/CommodityFunctions.m --- a/project_files/HedgewarsMobile/Classes/otherSrc/CommodityFunctions.m Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/otherSrc/CommodityFunctions.m Sat Jun 19 00:48:47 2010 +0200 @@ -43,6 +43,29 @@ [theTeam release]; } +void createWeaponNamed (NSString *nameWithoutExt) { + NSString *weaponsDirectory = WEAPONS_DIRECTORY(); + + if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { + [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory + withIntermediateDirectories:NO + attributes:nil + error:NULL]; + } + + NSDictionary *theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: + @"9391929422199121032235111001201000000211190911",@"ammostore_initialqt", + @"0405040541600655546554464776576666666155501000",@"ammostore_probability", + @"0000000000000205500000040007004000000000200000",@"ammostore_delay", + @"1311110312111111123114111111111111111211101111",@"ammostore_crate", nil]; + + NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; + + [theWeapon writeToFile:weaponFile atomically:YES]; + [weaponFile release]; + [theWeapon release]; +} + void createSchemeNamed (NSString *nameWithoutExt) { NSString *schemesDirectory = SCHEMES_DIRECTORY(); @@ -128,9 +151,7 @@ DLog(@"Failed to fetch vm statistics"); /* Stats in bytes */ - natural_t mem_used = (vm_stat.active_count + - vm_stat.inactive_count + - vm_stat.wire_count) * pagesize; + natural_t mem_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize; natural_t mem_free = vm_stat.free_count * pagesize; natural_t mem_total = mem_used + mem_free; DLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total); diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Classes/otherSrc/PascalImports.h --- a/project_files/HedgewarsMobile/Classes/otherSrc/PascalImports.h Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/otherSrc/PascalImports.h Sat Jun 19 00:48:47 2010 +0200 @@ -19,7 +19,7 @@ */ void Game(const char *args[]); - void GenLandPreview(); + void GenLandPreview(void); void HW_versionInfo(short int*, char**); diff -r c3dcb80bdb1d -r 156c04c6a3d8 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Fri Jun 18 20:45:45 2010 +0200 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Jun 19 00:48:47 2010 +0200 @@ -32,6 +32,7 @@ 61272339117DF778005B90CF /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61272338117DF778005B90CF /* MobileCoreServices.framework */; }; 61370653117B1D50004EE44A /* Entitlements-Distribution.plist in Resources */ = {isa = PBXBuildFile; fileRef = 61370652117B1D50004EE44A /* Entitlements-Distribution.plist */; }; 6151347E116C2803001F16D1 /* Icon-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 6151347D116C2803001F16D1 /* Icon-iPad.png */; }; + 6163EE7E11CC2600001C0453 /* SingleWeaponViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6163EE7D11CC2600001C0453 /* SingleWeaponViewController.m */; }; 6165920C11CA9BA200D6E256 /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 616591DF11CA9BA200D6E256 /* DetailViewController.m */; }; 6165920D11CA9BA200D6E256 /* FlagsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 616591E111CA9BA200D6E256 /* FlagsViewController.m */; }; 6165920E11CA9BA200D6E256 /* FortsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 616591E311CA9BA200D6E256 /* FortsViewController.m */; }; @@ -235,6 +236,8 @@ 61272338117DF778005B90CF /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; 61370652117B1D50004EE44A /* Entitlements-Distribution.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Entitlements-Distribution.plist"; sourceTree = ""; }; 6151347D116C2803001F16D1 /* Icon-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-iPad.png"; path = "Resources/Icon-iPad.png"; sourceTree = ""; }; + 6163EE7C11CC2600001C0453 /* SingleWeaponViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleWeaponViewController.h; sourceTree = ""; }; + 6163EE7D11CC2600001C0453 /* SingleWeaponViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SingleWeaponViewController.m; sourceTree = ""; }; 616591DE11CA9BA200D6E256 /* DetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = ""; }; 616591DF11CA9BA200D6E256 /* DetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailViewController.m; sourceTree = ""; }; 616591E011CA9BA200D6E256 /* FlagsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlagsViewController.h; sourceTree = ""; }; @@ -428,52 +431,13 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( - 616591DE11CA9BA200D6E256 /* DetailViewController.h */, - 616591DF11CA9BA200D6E256 /* DetailViewController.m */, - 616591E011CA9BA200D6E256 /* FlagsViewController.h */, - 616591E111CA9BA200D6E256 /* FlagsViewController.m */, - 616591E211CA9BA200D6E256 /* FortsViewController.h */, - 616591E311CA9BA200D6E256 /* FortsViewController.m */, - 616591E411CA9BA200D6E256 /* GameConfigViewController.h */, - 616591E511CA9BA200D6E256 /* GameConfigViewController.m */, - 616591E611CA9BA200D6E256 /* GameSetup.h */, - 616591E711CA9BA200D6E256 /* GameSetup.m */, - 616591E811CA9BA200D6E256 /* GeneralSettingsViewController.h */, - 616591E911CA9BA200D6E256 /* GeneralSettingsViewController.m */, - 616591EA11CA9BA200D6E256 /* GravesViewController.h */, - 616591EB11CA9BA200D6E256 /* GravesViewController.m */, - 616591EC11CA9BA200D6E256 /* HogHatViewController.h */, - 616591ED11CA9BA200D6E256 /* HogHatViewController.m */, - 616591EE11CA9BA200D6E256 /* LevelViewController.h */, - 616591EF11CA9BA200D6E256 /* LevelViewController.m */, + 6163EE4D11CC247D001C0453 /* Game Config */, + 6163EE4C11CC2478001C0453 /* Settings Pages */, + 6163EE6C11CC253F001C0453 /* Overlay */, 616591F011CA9BA200D6E256 /* MainMenuViewController.h */, 616591F111CA9BA200D6E256 /* MainMenuViewController.m */, - 616591F211CA9BA200D6E256 /* MapConfigViewController.h */, - 616591F311CA9BA200D6E256 /* MapConfigViewController.m */, - 616591F411CA9BA200D6E256 /* MasterViewController.h */, - 616591F511CA9BA200D6E256 /* MasterViewController.m */, - 616591F611CA9BA200D6E256 /* OverlayViewController.h */, - 616591F711CA9BA200D6E256 /* OverlayViewController.m */, - 616591F811CA9BA200D6E256 /* PopoverMenuViewController.h */, - 616591F911CA9BA200D6E256 /* PopoverMenuViewController.m */, - 616591FA11CA9BA200D6E256 /* SchemeSettingsViewController.h */, - 616591FB11CA9BA200D6E256 /* SchemeSettingsViewController.m */, - 616591FC11CA9BA200D6E256 /* SchemeWeaponConfigViewController.h */, - 616591FD11CA9BA200D6E256 /* SchemeWeaponConfigViewController.m */, - 616591FE11CA9BA200D6E256 /* SingleSchemeViewController.h */, - 616591FF11CA9BA200D6E256 /* SingleSchemeViewController.m */, - 6165920011CA9BA200D6E256 /* SingleTeamViewController.h */, - 6165920111CA9BA200D6E256 /* SingleTeamViewController.m */, - 6165920211CA9BA200D6E256 /* SplitViewRootController.h */, - 6165920311CA9BA200D6E256 /* SplitViewRootController.m */, - 6165920411CA9BA200D6E256 /* TeamConfigViewController.h */, - 6165920511CA9BA200D6E256 /* TeamConfigViewController.m */, - 6165920611CA9BA200D6E256 /* TeamSettingsViewController.h */, - 6165920711CA9BA200D6E256 /* TeamSettingsViewController.m */, - 6165920811CA9BA200D6E256 /* VoicesViewController.h */, - 6165920911CA9BA200D6E256 /* VoicesViewController.m */, - 6165920A11CA9BA200D6E256 /* WeaponSettingsViewController.h */, - 6165920B11CA9BA200D6E256 /* WeaponSettingsViewController.m */, + 616591E611CA9BA200D6E256 /* GameSetup.h */, + 616591E711CA9BA200D6E256 /* GameSetup.m */, ); path = Classes; sourceTree = ""; @@ -603,6 +567,95 @@ name = Products; sourceTree = ""; }; + 6163EE4C11CC2478001C0453 /* Settings Pages */ = { + isa = PBXGroup; + children = ( + 6165920211CA9BA200D6E256 /* SplitViewRootController.h */, + 6165920311CA9BA200D6E256 /* SplitViewRootController.m */, + 616591F411CA9BA200D6E256 /* MasterViewController.h */, + 616591F511CA9BA200D6E256 /* MasterViewController.m */, + 616591DE11CA9BA200D6E256 /* DetailViewController.h */, + 616591DF11CA9BA200D6E256 /* DetailViewController.m */, + 6163EE4E11CC248D001C0453 /* First Level */, + 6163EE4F11CC2497001C0453 /* Second Level */, + 6163EE5011CC24A1001C0453 /* Third Level */, + ); + name = "Settings Pages"; + sourceTree = ""; + }; + 6163EE4D11CC247D001C0453 /* Game Config */ = { + isa = PBXGroup; + children = ( + 616591E411CA9BA200D6E256 /* GameConfigViewController.h */, + 616591E511CA9BA200D6E256 /* GameConfigViewController.m */, + 6165920411CA9BA200D6E256 /* TeamConfigViewController.h */, + 6165920511CA9BA200D6E256 /* TeamConfigViewController.m */, + 616591F211CA9BA200D6E256 /* MapConfigViewController.h */, + 616591F311CA9BA200D6E256 /* MapConfigViewController.m */, + 616591FC11CA9BA200D6E256 /* SchemeWeaponConfigViewController.h */, + 616591FD11CA9BA200D6E256 /* SchemeWeaponConfigViewController.m */, + ); + name = "Game Config"; + sourceTree = ""; + }; + 6163EE4E11CC248D001C0453 /* First Level */ = { + isa = PBXGroup; + children = ( + 616591E811CA9BA200D6E256 /* GeneralSettingsViewController.h */, + 616591E911CA9BA200D6E256 /* GeneralSettingsViewController.m */, + 6165920611CA9BA200D6E256 /* TeamSettingsViewController.h */, + 6165920711CA9BA200D6E256 /* TeamSettingsViewController.m */, + 6165920A11CA9BA200D6E256 /* WeaponSettingsViewController.h */, + 6165920B11CA9BA200D6E256 /* WeaponSettingsViewController.m */, + 616591FA11CA9BA200D6E256 /* SchemeSettingsViewController.h */, + 616591FB11CA9BA200D6E256 /* SchemeSettingsViewController.m */, + ); + name = "First Level"; + sourceTree = ""; + }; + 6163EE4F11CC2497001C0453 /* Second Level */ = { + isa = PBXGroup; + children = ( + 616591FE11CA9BA200D6E256 /* SingleSchemeViewController.h */, + 616591FF11CA9BA200D6E256 /* SingleSchemeViewController.m */, + 6165920011CA9BA200D6E256 /* SingleTeamViewController.h */, + 6165920111CA9BA200D6E256 /* SingleTeamViewController.m */, + 6163EE7C11CC2600001C0453 /* SingleWeaponViewController.h */, + 6163EE7D11CC2600001C0453 /* SingleWeaponViewController.m */, + ); + name = "Second Level"; + sourceTree = ""; + }; + 6163EE5011CC24A1001C0453 /* Third Level */ = { + isa = PBXGroup; + children = ( + 616591EC11CA9BA200D6E256 /* HogHatViewController.h */, + 616591ED11CA9BA200D6E256 /* HogHatViewController.m */, + 616591EE11CA9BA200D6E256 /* LevelViewController.h */, + 616591EF11CA9BA200D6E256 /* LevelViewController.m */, + 616591E011CA9BA200D6E256 /* FlagsViewController.h */, + 616591E111CA9BA200D6E256 /* FlagsViewController.m */, + 616591E211CA9BA200D6E256 /* FortsViewController.h */, + 616591E311CA9BA200D6E256 /* FortsViewController.m */, + 616591EA11CA9BA200D6E256 /* GravesViewController.h */, + 616591EB11CA9BA200D6E256 /* GravesViewController.m */, + 6165920811CA9BA200D6E256 /* VoicesViewController.h */, + 6165920911CA9BA200D6E256 /* VoicesViewController.m */, + ); + name = "Third Level"; + sourceTree = ""; + }; + 6163EE6C11CC253F001C0453 /* Overlay */ = { + isa = PBXGroup; + children = ( + 616591F811CA9BA200D6E256 /* PopoverMenuViewController.h */, + 616591F911CA9BA200D6E256 /* PopoverMenuViewController.m */, + 616591F611CA9BA200D6E256 /* OverlayViewController.h */, + 616591F711CA9BA200D6E256 /* OverlayViewController.m */, + ); + name = Overlay; + sourceTree = ""; + }; 6165924811CA9C4B00D6E256 /* libopenalbridge */ = { isa = PBXGroup; children = ( @@ -854,8 +907,8 @@ ); projectRoot = ""; targets = ( + 928301160F10CAFC00CC5A3C /* fpc */, 1D6058900D05DD3D006BFB54 /* Hedgewars */, - 928301160F10CAFC00CC5A3C /* fpc */, 61C3251C1179A300001E70B1 /* openalbridge */, 6179928B114AE0C800BA94A9 /* UpdateDataFolder */, ); @@ -1063,6 +1116,7 @@ 6165923111CA9BD500D6E256 /* SquareButtonView.m in Sources */, 6165923211CA9BD500D6E256 /* UIImageExtra.m in Sources */, 6165929E11CA9E2F00D6E256 /* SDL_uikitappdelegate.m in Sources */, + 6163EE7E11CC2600001C0453 /* SingleWeaponViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };