insert a default name when a void string is used
polish schemes configuration
fixed strange bug in the general panel
--- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Sun Jun 27 16:44:24 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Sun Jun 27 18:34:17 2010 +0200
@@ -349,7 +349,8 @@
}
*/
-
+/*
+ causes segfault if pressing twice cancel
#pragma mark -
#pragma mark Table view delegate
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -365,7 +366,7 @@
[aTableView deselectRowAtIndexPath:indexPath animated:NO];
}
}
-
+*/
#pragma mark -
#pragma mark Memory management
--- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sun Jun 27 16:44:24 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sun Jun 27 18:34:17 2010 +0200
@@ -138,6 +138,9 @@
// set the new value
-(BOOL) save:(id) sender {
if (textFieldBeingEdited != nil) {
+ if ([textFieldBeingEdited.text length] == 0)
+ textFieldBeingEdited.text = self.title;
+
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] error:NULL];
self.title = self.textFieldBeingEdited.text;
[self.schemeArray writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] atomically:YES];
@@ -243,6 +246,7 @@
}
cell.detailTextLabel.text = nil;
cell.imageView.image = nil;
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
break;
case 1:
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
@@ -279,7 +283,12 @@
cellSlider.value = [[self.schemeArray objectAtIndex:row+gmSize] floatValue];
// forced to use this weird format otherwise the label disappears when size of the text is bigger than the original
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%0.3d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]];
+ NSString *prestring = [NSString stringWithFormat:@"%d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]];
+ while ([prestring length] <= 4)
+ prestring = [NSString stringWithFormat:@" %@",prestring];
+ cell.detailTextLabel.text = prestring;
+
+ cell.selectionStyle = UITableViewCellSelectionStyleBlue;
break;
case 2:
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2];
@@ -302,6 +311,8 @@
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"];
cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"];
[(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO];
+
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
@@ -324,10 +335,9 @@
// grab the associated label
UILabel *label = (UILabel *)cell.detailTextLabel;
// modify it
- label.text = [NSString stringWithFormat:@"%0.3d",(int)theSlider.value];
+ label.text = [NSString stringWithFormat:@"%d",(int)theSlider.value];
// save changes in the main array (remember that you need to offset it)
[self.schemeArray replaceObjectAtIndex:theSlider.tag withObject:[NSNumber numberWithInt:(int)theSlider.value]];
- NSLog(@"%@",self.schemeArray);
}
#pragma mark -
@@ -353,9 +363,9 @@
//cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue];
break;
case 2:
- sw = (UISwitch *)cell.accessoryView;
+ /*sw = (UISwitch *)cell.accessoryView;
[sw setOn:!sw.on animated:YES];
- [self toggleSwitch:sw];
+ [self toggleSwitch:sw];*/
break;
default:
break;
--- a/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Sun Jun 27 16:44:24 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Sun Jun 27 18:34:17 2010 +0200
@@ -40,8 +40,14 @@
if (textFieldBeingEdited != nil) {
if (TEAMNAME_TAG == index) {
+ if ([textFieldBeingEdited.text length] == 0)
+ textFieldBeingEdited.text = self.title;
[self.teamDictionary setObject:textFieldBeingEdited.text forKey:@"teamname"];
+ self.title = textFieldBeingEdited.text;
} else {
+ if ([textFieldBeingEdited.text length] == 0)
+ textFieldBeingEdited.text = [NSString stringWithFormat:@"hedgehog %d",index];
+
//replace the old value with the new one
NSMutableDictionary *hog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:index];
[hog setObject:textFieldBeingEdited.text forKey:@"hogname"];