equal
deleted
inserted
replaced
136 } |
136 } |
137 |
137 |
138 // set the new value |
138 // set the new value |
139 -(BOOL) save:(id) sender { |
139 -(BOOL) save:(id) sender { |
140 if (textFieldBeingEdited != nil) { |
140 if (textFieldBeingEdited != nil) { |
|
141 if ([textFieldBeingEdited.text length] == 0) |
|
142 textFieldBeingEdited.text = self.title; |
|
143 |
141 [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] error:NULL]; |
144 [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] error:NULL]; |
142 self.title = self.textFieldBeingEdited.text; |
145 self.title = self.textFieldBeingEdited.text; |
143 [self.schemeArray writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] atomically:YES]; |
146 [self.schemeArray writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] atomically:YES]; |
144 [self.textFieldBeingEdited resignFirstResponder]; |
147 [self.textFieldBeingEdited resignFirstResponder]; |
145 return YES; |
148 return YES; |
241 textFieldFound.text = self.title; |
244 textFieldFound.text = self.title; |
242 } |
245 } |
243 } |
246 } |
244 cell.detailTextLabel.text = nil; |
247 cell.detailTextLabel.text = nil; |
245 cell.imageView.image = nil; |
248 cell.imageView.image = nil; |
|
249 cell.selectionStyle = UITableViewCellSelectionStyleNone; |
246 break; |
250 break; |
247 case 1: |
251 case 1: |
248 cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
252 cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1]; |
249 NSDictionary *detail = [self.basicSettingList objectAtIndex:row]; |
253 NSDictionary *detail = [self.basicSettingList objectAtIndex:row]; |
250 // need to offset this section (see format in CommodityFunctions.m and above) |
254 // need to offset this section (see format in CommodityFunctions.m and above) |
277 |
281 |
278 UISlider *cellSlider = (UISlider *)[cell.contentView viewWithTag:row+gmSize]; |
282 UISlider *cellSlider = (UISlider *)[cell.contentView viewWithTag:row+gmSize]; |
279 cellSlider.value = [[self.schemeArray objectAtIndex:row+gmSize] floatValue]; |
283 cellSlider.value = [[self.schemeArray objectAtIndex:row+gmSize] floatValue]; |
280 |
284 |
281 // forced to use this weird format otherwise the label disappears when size of the text is bigger than the original |
285 // forced to use this weird format otherwise the label disappears when size of the text is bigger than the original |
282 cell.detailTextLabel.text = [NSString stringWithFormat:@"%0.3d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]]; |
286 NSString *prestring = [NSString stringWithFormat:@"%d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]]; |
|
287 while ([prestring length] <= 4) |
|
288 prestring = [NSString stringWithFormat:@" %@",prestring]; |
|
289 cell.detailTextLabel.text = prestring; |
|
290 |
|
291 cell.selectionStyle = UITableViewCellSelectionStyleBlue; |
283 break; |
292 break; |
284 case 2: |
293 case 2: |
285 cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
294 cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2]; |
286 if (cell == nil) { |
295 if (cell == nil) { |
287 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
296 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle |
300 [cell.imageView.layer setBorderWidth:1]; |
309 [cell.imageView.layer setBorderWidth:1]; |
301 [cell.imageView.layer setMasksToBounds:YES]; |
310 [cell.imageView.layer setMasksToBounds:YES]; |
302 cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"]; |
311 cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"]; |
303 cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"]; |
312 cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"]; |
304 [(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO]; |
313 [(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO]; |
|
314 |
|
315 cell.selectionStyle = UITableViewCellSelectionStyleNone; |
305 } |
316 } |
306 |
317 |
307 return cell; |
318 return cell; |
308 } |
319 } |
309 |
320 |
322 // get its cell |
333 // get its cell |
323 UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; |
334 UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; |
324 // grab the associated label |
335 // grab the associated label |
325 UILabel *label = (UILabel *)cell.detailTextLabel; |
336 UILabel *label = (UILabel *)cell.detailTextLabel; |
326 // modify it |
337 // modify it |
327 label.text = [NSString stringWithFormat:@"%0.3d",(int)theSlider.value]; |
338 label.text = [NSString stringWithFormat:@"%d",(int)theSlider.value]; |
328 // save changes in the main array (remember that you need to offset it) |
339 // save changes in the main array (remember that you need to offset it) |
329 [self.schemeArray replaceObjectAtIndex:theSlider.tag withObject:[NSNumber numberWithInt:(int)theSlider.value]]; |
340 [self.schemeArray replaceObjectAtIndex:theSlider.tag withObject:[NSNumber numberWithInt:(int)theSlider.value]]; |
330 NSLog(@"%@",self.schemeArray); |
|
331 } |
341 } |
332 |
342 |
333 #pragma mark - |
343 #pragma mark - |
334 #pragma mark Table view delegate |
344 #pragma mark Table view delegate |
335 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
345 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
351 [cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES]; |
361 [cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES]; |
352 [self sliderChanged:cellSlider]; |
362 [self sliderChanged:cellSlider]; |
353 //cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue]; |
363 //cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue]; |
354 break; |
364 break; |
355 case 2: |
365 case 2: |
356 sw = (UISwitch *)cell.accessoryView; |
366 /*sw = (UISwitch *)cell.accessoryView; |
357 [sw setOn:!sw.on animated:YES]; |
367 [sw setOn:!sw.on animated:YES]; |
358 [self toggleSwitch:sw]; |
368 [self toggleSwitch:sw];*/ |
359 break; |
369 break; |
360 default: |
370 default: |
361 break; |
371 break; |
362 } |
372 } |
363 |
373 |