# HG changeset patch # User koda # Date 1285198160 -7200 # Node ID 0a9c3735a713d2e1cb11e64bd48d9557c1fa4795 # Parent 27e115fa1143e0fec368630013f1ebe8a4e1d981 implemented reloading savefiles diff -r 27e115fa1143 -r 0a9c3735a713 project_files/HedgewarsMobile/Classes/GameSetup.m --- a/project_files/HedgewarsMobile/Classes/GameSetup.m Thu Sep 23 00:09:16 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Thu Sep 23 01:29:20 2010 +0200 @@ -44,10 +44,14 @@ isNetGame = [[gameDictionary objectForKey:@"netgame"] boolValue]; NSString *path = [gameDictionary objectForKey:@"savefile"]; // if path is empty it means i have to create a new file, otherwise i read from that file - if ([path isEqualToString:@""] == YES) - self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", [[NSDate date] description]]; - else - self.savePath = [SAVES_DIRECTORY() stringByAppendingString:path]; + if ([path isEqualToString:@""] == YES) { + NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; + [outputFormatter setDateFormat:@"yyyy-MM-dd 'at' HH,mm"]; + NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]]; + self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", newDateString]; + [outputFormatter release]; + } else + self.savePath = path; } return self; } diff -r 27e115fa1143 -r 0a9c3735a713 project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m --- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Thu Sep 23 00:09:16 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Thu Sep 23 01:29:20 2010 +0200 @@ -81,7 +81,7 @@ -(void) startSDLgame:(NSDictionary *)gameDictionary { UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; - UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, aWin.frame.size.height, aWin.frame.size.width)]; + UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, aWin.frame.size.width, aWin.frame.size.height)]; blackView.opaque = YES; blackView.backgroundColor = [UIColor blackColor]; [aWin addSubview:blackView]; diff -r 27e115fa1143 -r 0a9c3735a713 project_files/HedgewarsMobile/Classes/SavedGamesViewController.h --- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.h Thu Sep 23 00:09:16 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.h Thu Sep 23 01:29:20 2010 +0200 @@ -22,8 +22,15 @@ #import -@interface SavedGamesViewController : UITableViewController { - +@interface SavedGamesViewController : UIViewController { + UITableView *tableView; + NSMutableArray *listOfSavegames; } +@property (nonatomic,retain) IBOutlet UITableView *tableView; +@property (nonatomic,retain) NSMutableArray *listOfSavegames; + + +-(IBAction) buttonPressed:(id) sender; + @end diff -r 27e115fa1143 -r 0a9c3735a713 project_files/HedgewarsMobile/Classes/SavedGamesViewController.m --- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Thu Sep 23 00:09:16 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Thu Sep 23 01:29:20 2010 +0200 @@ -20,52 +20,93 @@ #import "SavedGamesViewController.h" - +#import "SDL_uikitappdelegate.h" +#import "CommodityFunctions.h" @implementation SavedGamesViewController +@synthesize tableView, listOfSavegames; -/* - // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { - // Custom initialization - } - return self; +-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { + return rotationManager(interfaceOrientation); } -*/ -/* -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad { +-(void) viewDidLoad { + self.tableView.backgroundView = nil; + [super viewDidLoad]; } -*/ + +-(void) viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SAVES_DIRECTORY() error:NULL]; + NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES]; + self.listOfSavegames = array; + [array release]; + + [self.tableView reloadData]; +} -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - // Overriden to allow any orientation. - return YES; +-(IBAction) buttonPressed:(id) sender { + playSound(@"backSound"); + [[self parentViewController] dismissModalViewControllerAnimated:YES]; +} + +#pragma mark - +#pragma mark Table view data source +-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return [self.listOfSavegames count]; } +-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *CellIdentifier = @"Cell"; -- (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. + UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; + + // first all the names, then the title (which is offset 5) + cell.textLabel.text = [[self.listOfSavegames objectAtIndex:[indexPath row]] stringByDeletingPathExtension]; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + + return cell; } - -- (void)viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; +#pragma mark - +#pragma mark Table view delegate +-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; + + NSString *filePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:[indexPath row]]]; + + NSDictionary *allDataNecessary = [NSDictionary dictionaryWithObjectsAndKeys: + [NSDictionary dictionary],@"game_dictionary", + filePath,@"savefile", + [NSNumber numberWithBool:NO],@"netgame", + nil]; + [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary]; } +#pragma mark - +#pragma mark Memory Management +-(void) didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} -- (void)dealloc { +-(void) viewDidUnload { + self.tableView = nil; + self.listOfSavegames = nil; + [super viewDidUnload]; +} + +-(void) dealloc { + [tableView release]; + [listOfSavegames release]; [super dealloc]; } - @end diff -r 27e115fa1143 -r 0a9c3735a713 project_files/HedgewarsMobile/Classes/SavedGamesViewController.xib --- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.xib Thu Sep 23 00:09:16 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.xib Thu Sep 23 01:29:20 2010 +0200 @@ -1,14 +1,14 @@ - + - 800 - 10C540 - 759 - 1038.25 - 458.00 + 1024 + 10F569 + 788 + 1038.29 + 461.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 77 + 117 YES @@ -31,27 +31,64 @@ YES IBFilesOwner - IBCocoaTouchFramework + IBIPadFramework IBFirstResponder - IBCocoaTouchFramework + IBIPadFramework 292 - {1024, 748} + + YES + + + 290 + {408, 44} + + NO + IBIPadFramework + + YES + + IBIPadFramework + 1 + + 0 + + + + + + 274 + {{0, 44}, {408, 414}} + + + 1 + MCAwIDAgMAA + + YES + IBIPadFramework + YES + 1 + 2 + 0 + YES + 44 + 10 + 10 + + + {408, 458} 3 MQA - - 2 - NO - - 2 + + 3 IBIPadFramework @@ -67,6 +104,38 @@ 3 + + + buttonPressed: + + + + 6 + + + + dataSource + + + + 8 + + + + delegate + + + + 9 + + + + tableView + + + + 10 + @@ -91,8 +160,32 @@ 2 + + YES + + + + + 4 + + + YES + + + + + + 5 + + + + + 7 + + + @@ -103,12 +196,18 @@ -2.CustomClassName 2.IBEditorWindowLastContentRect 2.IBPluginDependency + 4.IBPluginDependency + 5.IBPluginDependency + 7.IBPluginDependency YES SavedGamesViewController UIResponder - {{353, 156}, {1024, 768}} + {{677, 547}, {408, 458}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -128,114 +227,39 @@ - 3 + 10 YES - NSObject - - IBProjectSource - IBCocoaTouchTool/IBCocoaTouchToolIntegration.h - - - - NSObject - - IBProjectSource - IBInternalHeaders/IBAppKitAdditions.h - - - - NSObject - - IBProjectSource - IBInternalHeaders/IBConnection.h + SavedGamesViewController + UIViewController + + buttonPressed: + id - - - NSObject - - IBProjectSource - IBInternalHeaders/IBFieldEditor.h + + buttonPressed: + + buttonPressed: + id + - - - NSObject - - IBProjectSource - IBInternalHeaders/IBFoundationAdditions.h + + tableView + UITableView - - - NSObject - - IBProjectSource - IBInternalHeaders/IBObjectContainer.h + + tableView + + tableView + UITableView + - - - NSObject IBProjectSource - IBInternalHeaders/IBObjectIntegrationInternal.h - - - - NSObject - - IBProjectSource - IBInternalHeaders/IBWindowController.h - - - - NSObject - - IBProjectSource - IBPlugin/CustomViews/IBWindowRotationAnimation.h - - - - NSObject - - IBProjectSource - IBPlugin/Utilities/IBObjectMarshalling.h - - - - NSObject - - IBProjectSource - IBPlugin/Utilities/IBValueMarshallers.h - - - - NSObject - - IBProjectSource - IBPlugin/WidgetIntegration/Accessibility/IBUIAccessibilityIntegration.h - - - - NSObject - - IBProjectSource - IBPlugin/WidgetIntegration/IBUIObjectIntegration.h - - - - NSObject - - IBProjectSource - IBPlugin/WidgetIntegration/IBUIViewController/IBUIViewControllerEditorPlaceholderView.h - - - - NSObject - - IBProjectSource - IBPlugin/WidgetIntegration/IBUIViewController/IBUIViewControllerEditorView.h + Classes/SavedGamesViewController.h @@ -245,168 +269,84 @@ NSObject IBFrameworkSource - AppKit.framework/Headers/NSAccessibility.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSApplication.h + Foundation.framework/Headers/NSError.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSApplicationScripting.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSColorPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSControl.h + Foundation.framework/Headers/NSFileManager.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSDictionaryController.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDragging.h + Foundation.framework/Headers/NSKeyValueCoding.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSFontManager.h + Foundation.framework/Headers/NSKeyValueObserving.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSFontPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSKeyValueBinding.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenu.h + Foundation.framework/Headers/NSKeyedArchiver.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSNibLoading.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSOutlineView.h + Foundation.framework/Headers/NSObject.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSPasteboard.h + Foundation.framework/Headers/NSRunLoop.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSSavePanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbarItem.h + Foundation.framework/Headers/NSThread.h NSObject IBFrameworkSource - AppKit.framework/Headers/NSView.h - - - - NSObject - - IBFrameworkSource - DevToolsKit.framework/Headers/DTAssetLibrary.h - - - - NSObject - - IBFrameworkSource - DevToolsKit.framework/Headers/DTDragManager.h + Foundation.framework/Headers/NSURL.h NSObject IBFrameworkSource - DevToolsKit.framework/Headers/DTTemplateChooserViewController.h + Foundation.framework/Headers/NSURLConnection.h NSObject IBFrameworkSource - DevToolsKit.framework/Headers/DTTypeCompletionHandler.h + QuartzCore.framework/Headers/CAAnimation.h NSObject IBFrameworkSource - InterfaceBuilderKit.framework/Headers/IBObjectIntegration.h - - - - NSObject - - IBFrameworkSource - PrintCore.framework/Headers/PDEPluginInterface.h + QuartzCore.framework/Headers/CALayer.h @@ -431,22 +371,132 @@ + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + UIResponder NSObject + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UIToolbar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIToolbar.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + 0 IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 YES - ../../../IBCocoaTouchPlugin.xcodeproj + ../Hedgewars.xcodeproj 3 - 77 - + 117