# HG changeset patch
# User koda
# Date 1285432685 -7200
# Node ID db01c37494aff6f730616058ba388a02883f65a8
# Parent 3aac7ca07b0e48ff4894551b403d212042cc68d5
pimp-my-savagame-table
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/AboutViewController.xib
--- a/project_files/HedgewarsMobile/Classes/AboutViewController.xib Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/AboutViewController.xib Sat Sep 25 18:38:05 2010 +0200
@@ -12,7 +12,6 @@
- {429, 44}
+ {543, 44}
+
IBIPadFramework
YES
@@ -120,8 +121,9 @@
274
- {{0, 44}, {429, 433}}
+ {{0, 44}, {543, 577}}
+
NO
IBIPadFramework
@@ -132,8 +134,9 @@
274
- {{0, 44}, {429, 433}}
+ {{0, 44}, {543, 577}}
+
1
MCAwIDAgMAA
@@ -150,8 +153,9 @@
10
- {429, 477}
+ {543, 621}
+
3
MQA
@@ -318,7 +322,7 @@
UIResponder
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- {{505, 182}, {429, 477}}
+ {{376, 170}, {543, 621}}
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
@@ -685,7 +689,7 @@
3
background_small.png
- {320, 436}
+ {539, 639}
117
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/MainMenuViewController.m
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sat Sep 25 18:38:05 2010 +0200
@@ -292,7 +292,7 @@
if (nil == self.savedGamesViewController) {
SavedGamesViewController *savedgames = [[SavedGamesViewController alloc] initWithNibName:@"SavedGamesViewController" bundle:nil];
savedgames.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
- savedgames.modalPresentationStyle = UIModalPresentationFormSheet;
+ savedgames.modalPresentationStyle = UIModalPresentationPageSheet;
self.savedGamesViewController = savedgames;
[savedgames release];
}
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/SavedGamesViewController.h
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.h Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.h Sat Sep 25 18:38:05 2010 +0200
@@ -20,9 +20,9 @@
#import
-
+#import "EditableCellView.h"
-@interface SavedGamesViewController : UIViewController {
+@interface SavedGamesViewController : UIViewController {
UITableView *tableView;
NSMutableArray *listOfSavegames;
}
@@ -30,7 +30,7 @@
@property (nonatomic,retain) IBOutlet UITableView *tableView;
@property (nonatomic,retain) NSMutableArray *listOfSavegames;
-
-(IBAction) buttonPressed:(id) sender;
+-(IBAction) toggleEdit:(id) sender;
@end
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/SavedGamesViewController.m
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Sat Sep 25 18:38:05 2010 +0200
@@ -49,9 +49,22 @@
-(IBAction) buttonPressed:(id) sender {
playSound(@"backSound");
+ [self.tableView setEditing:NO animated:YES];
[[self parentViewController] dismissModalViewControllerAnimated:YES];
}
+// modifies the navigation bar to add the "Add" and "Done" buttons
+-(IBAction) toggleEdit:(id) sender {
+ BOOL isEditing = self.tableView.editing;
+ [self.tableView setEditing:!isEditing animated:YES];
+
+ UIBarButtonItem *barButton = (UIBarButtonItem *)sender;
+ if (isEditing)
+ [barButton setTitle:NSLocalizedString(@"Edit",@"")];
+ else
+ [barButton setTitle:NSLocalizedString(@"Commit",@"")];
+}
+
#pragma mark -
#pragma mark Table view data source
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
@@ -65,15 +78,61 @@
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil)
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
+ EditableCellView *editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (editableCell == nil) {
+ editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ editableCell.delegate = self;
+ }
+ editableCell.tag = [indexPath row];
+
+ editableCell.textField.text = [[self.listOfSavegames objectAtIndex:[indexPath row]] stringByDeletingPathExtension];
+ editableCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+
+ UIImage *addImg = [UIImage imageWithContentsOfFile:@"plus.png"];
+ UIButton *customButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
+ customButton.tag = [indexPath row];
+ [customButton setImage:addImg forState:UIControlStateNormal];
+ [customButton addTarget:self action:@selector(duplicateEntry:) forControlEvents:UIControlEventTouchUpInside];
+ editableCell.editingAccessoryView = customButton;
+
+ return (UITableViewCell *)editableCell;
+}
+/*
+-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section {
+ UITableViewCellEditingStyleInsert
+}*//*
+-(UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
+ return UITableViewCellEditingStyleInsert;
+}*/
- // first all the names, then the title (which is offset 5)
- cell.textLabel.text = [[self.listOfSavegames objectAtIndex:[indexPath row]] stringByDeletingPathExtension];
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+ NSUInteger row = [indexPath row];
+ [(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil];
+
+ NSString *saveName = [self.listOfSavegames objectAtIndex:row];
+ NSString *currentFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),saveName];
+ [[NSFileManager defaultManager] removeItemAtPath:currentFilePath error:nil];
+ [self.listOfSavegames removeObject:saveName];
+
+ [self.tableView reloadData];
+}
- return cell;
+-(void) duplicateEntry:(id) sender {
+ UIButton *button = (UIButton *)sender;
+ NSUInteger row = button.tag;
+
+ [(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil];
+ NSString *currentSaveName = [self.listOfSavegames objectAtIndex:row];
+ NSString *newSaveName = [[currentSaveName stringByDeletingPathExtension] stringByAppendingFormat:@" %d.hws",[self.listOfSavegames count]];
+
+ NSString *currentFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),currentSaveName];
+ NSString *newFilePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),newSaveName];
+ [[NSFileManager defaultManager] copyItemAtPath:currentFilePath toPath:newFilePath error:nil];
+ [self.listOfSavegames addObject:newSaveName];
+ [self.listOfSavegames sortUsingSelector:@selector(compare:)];
+
+ //[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.listOfSavegames indexOfObject:newSaveName] inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
+ [self.tableView reloadData];
}
#pragma mark -
@@ -81,6 +140,8 @@
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
+ [(EditableCellView *)[self.tableView cellForRowAtIndexPath:indexPath] save:nil];
+
NSString *filePath = [NSString stringWithFormat:@"%@/%@",SAVES_DIRECTORY(),[self.listOfSavegames objectAtIndex:[indexPath row]]];
NSDictionary *allDataNecessary = [NSDictionary dictionaryWithObjectsAndKeys:
@@ -92,6 +153,20 @@
}
#pragma mark -
+#pragma mark editableCellView delegate
+// rename old file if names differ
+-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
+ 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 -
#pragma mark Memory Management
-(void) didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/SavedGamesViewController.xib
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.xib Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.xib Sat Sep 25 18:38:05 2010 +0200
@@ -42,10 +42,22 @@
292
YES
+
+
+ 292
+ {768, 768}
+
+ NO
+ IBIPadFramework
+
+ NSImage
+ background_med.png
+
+
290
- {408, 44}
+ {768, 44}
NO
IBIPadFramework
@@ -57,12 +69,23 @@
0
+
+ IBIPadFramework
+
+ 5
+
+
+ Edit
+ IBIPadFramework
+ 1
+
+
274
- {{0, 44}, {408, 414}}
+ {{0, 44}, {768, 724}}
1
@@ -80,7 +103,7 @@
10
- {408, 458}
+ {768, 768}
3
@@ -136,6 +159,14 @@
10
+
+
+ toggleEdit:
+
+
+
+ 14
+
@@ -164,6 +195,7 @@
YES
+
@@ -173,6 +205,8 @@
YES
+
+
@@ -186,6 +220,21 @@
+
+ 11
+
+
+
+
+ 12
+
+
+
+
+ 13
+
+
+
@@ -194,6 +243,9 @@
YES
-1.CustomClassName
-2.CustomClassName
+ 11.IBPluginDependency
+ 12.IBPluginDependency
+ 13.IBPluginDependency
2.IBEditorWindowLastContentRect
2.IBPluginDependency
4.IBPluginDependency
@@ -204,7 +256,10 @@
YES
SavedGamesViewController
UIResponder
- {{677, 547}, {408, 458}}
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ com.apple.InterfaceBuilder.IBCocoaTouchPlugin
+ {{486, 215}, {768, 768}}
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
com.apple.InterfaceBuilder.IBCocoaTouchPlugin
@@ -227,7 +282,7 @@
- 10
+ 14
@@ -236,14 +291,35 @@
SavedGamesViewController
UIViewController
- buttonPressed:
- id
+ YES
+
+ YES
+ buttonPressed:
+ toggleEdit:
+
+
+ YES
+ id
+ id
+
- buttonPressed:
-
- buttonPressed:
- id
+ YES
+
+ YES
+ buttonPressed:
+ toggleEdit:
+
+
+ YES
+
+ buttonPressed:
+ id
+
+
+ toggleEdit:
+ id
+
@@ -387,6 +463,14 @@
+ UIImageView
+ UIView
+
+ IBFrameworkSource
+ UIKit.framework/Headers/UIImageView.h
+
+
+
UIResponder
NSObject
@@ -497,6 +581,10 @@
YES
../Hedgewars.xcodeproj
3
+
+ background_med.png
+ {768, 768}
+
117
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m
--- a/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Sat Sep 25 18:38:05 2010 +0200
@@ -41,7 +41,6 @@
action:@selector(toggleEdit:)];
self.navigationItem.rightBarButtonItem = editButton;
[editButton release];
-
}
-(void) viewWillAppear:(BOOL) animated {
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/UIImageExtra.h
--- a/project_files/HedgewarsMobile/Classes/UIImageExtra.h Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/UIImageExtra.h Sat Sep 25 18:38:05 2010 +0200
@@ -30,6 +30,7 @@
-(id) initWithContentsOfFile:(NSString *)path andCutAt:(CGRect) rect;
-(UIImage *)cutAt:(CGRect) rect;
-(UIImage *)convertToGrayScale;
+-(UIImage *)convertToNegative;
-(UIImage *)maskImageWith:(UIImage *)maskImage;
-(UIImage *)makeRoundCornersOfSize:(CGSize) sizewh;
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Classes/UIImageExtra.m
--- a/project_files/HedgewarsMobile/Classes/UIImageExtra.m Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/UIImageExtra.m Sat Sep 25 18:38:05 2010 +0200
@@ -207,4 +207,17 @@
return newImage;
}
+// by http://www.sixtemia.com/journal/2010/06/23/uiimage-negative-color-effect/
+-(UIImage *)convertToNegative {
+ UIGraphicsBeginImageContext(self.size);
+ CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
+ [self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)];
+ CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference);
+ CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);
+ CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, self.size.width, self.size.height));
+ UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
+ return result;
+}
+
@end
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Sep 25 03:04:22 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Sep 25 18:38:05 2010 +0200
@@ -28,6 +28,8 @@
611D9B12124949D000008271 /* NSStringExtra.m in Sources */ = {isa = PBXBuildFile; fileRef = 611D9B11124949D000008271 /* NSStringExtra.m */; };
611D9BFB12497E9800008271 /* SavedGamesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 611D9BF912497E9800008271 /* SavedGamesViewController.m */; };
611D9BFC12497E9800008271 /* SavedGamesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 611D9BFA12497E9800008271 /* SavedGamesViewController.xib */; };
+ 611DA031124E2BC500008271 /* background_med.png in Resources */ = {isa = PBXBuildFile; fileRef = 611DA030124E2BC500008271 /* background_med.png */; };
+ 611DA1D0124E5C6300008271 /* plus.png in Resources */ = {isa = PBXBuildFile; fileRef = 611DA1CF124E5C6300008271 /* plus.png */; };
611E03E711FA747C0077A41E /* libvorbis.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 611E037C11FA74590077A41E /* libvorbis.a */; };
611E0E5111FA92170077A41E /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 611E0E5011FA92130077A41E /* libfreetype.a */; };
611E0EE711FB20610077A41E /* ammoButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 611E0EE511FB20610077A41E /* ammoButton.png */; };
@@ -700,6 +702,8 @@
611D9BF812497E9800008271 /* SavedGamesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SavedGamesViewController.h; sourceTree = ""; };
611D9BF912497E9800008271 /* SavedGamesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SavedGamesViewController.m; sourceTree = ""; };
611D9BFA12497E9800008271 /* SavedGamesViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SavedGamesViewController.xib; sourceTree = ""; };
+ 611DA030124E2BC500008271 /* background_med.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = background_med.png; path = Resources/Overlay/background_med.png; sourceTree = ""; };
+ 611DA1CF124E5C6300008271 /* plus.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = plus.png; path = Resources/Overlay/plus.png; sourceTree = ""; };
611E02EC11FA74580077A41E /* cocos2d-iphone.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "cocos2d-iphone.xcodeproj"; path = "../../../Library/cocos2d/cocos2d-iphone.xcodeproj"; sourceTree = SOURCE_ROOT; };
611E0E4B11FA92130077A41E /* freetype.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = freetype.xcodeproj; path = "../../../Library/freetype/Xcode-iPhoneOS/freetype.xcodeproj"; sourceTree = SOURCE_ROOT; };
611E0EE511FB20610077A41E /* ammoButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ammoButton.png; path = Resources/Overlay/ammoButton.png; sourceTree = ""; };
@@ -1291,6 +1295,8 @@
6179936611501D1E00BA94A9 /* Overlay */ = {
isa = PBXGroup;
children = (
+ 611DA1CF124E5C6300008271 /* plus.png */,
+ 611DA030124E2BC500008271 /* background_med.png */,
611E0EE511FB20610077A41E /* ammoButton.png */,
611E0EE611FB20610077A41E /* cornerButton.png */,
61EF920511DF57AC003441C4 /* arrowDown.png */,
@@ -2051,6 +2057,8 @@
6199E83A124647DE00DADF8C /* SupportViewController.xib in Resources */,
6199E86D12464A8E00DADF8C /* surpise.png in Resources */,
611D9BFC12497E9800008271 /* SavedGamesViewController.xib in Resources */,
+ 611DA031124E2BC500008271 /* background_med.png in Resources */,
+ 611DA1D0124E5C6300008271 /* plus.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Resources/Overlay/background_med.png
Binary file project_files/HedgewarsMobile/Resources/Overlay/background_med.png has changed
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Resources/Overlay/background_small.png
Binary file project_files/HedgewarsMobile/Resources/Overlay/background_small.png has changed
diff -r 3aac7ca07b0e -r db01c37494af project_files/HedgewarsMobile/Resources/Overlay/plus.png
Binary file project_files/HedgewarsMobile/Resources/Overlay/plus.png has changed