project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m
changeset 3782 dc3531e49e4c
parent 3781 2bfda544ae48
child 3825 fd6c20cd90e3
equal deleted inserted replaced
3781:2bfda544ae48 3782:dc3531e49e4c
   138 
   138 
   139 #pragma mark -
   139 #pragma mark -
   140 #pragma mark editableCellView delegate
   140 #pragma mark editableCellView delegate
   141 // set the new value
   141 // set the new value
   142 -(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
   142 -(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
   143     // delete old file
   143     if (tagValue == 0) {
   144     [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] error:NULL];
   144         // delete old file
   145     // update filename
   145         [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] error:NULL];
   146     self.schemeName = textString;
   146         // update filename
   147     // save new file
   147         self.schemeName = textString;
   148     [self.schemeDictionary writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] atomically:YES];
   148         // save new file
       
   149         [self.schemeDictionary writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] atomically:YES];
       
   150     } else {
       
   151         [self.schemeDictionary setObject:textString forKey:@"description"];
       
   152     }
   149 }
   153 }
   150 
   154 
   151 #pragma mark -
   155 #pragma mark -
   152 #pragma mark Table view data source
   156 #pragma mark Table view data source
   153 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
   157 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
   155 }
   159 }
   156 
   160 
   157 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   161 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   158     switch (section) {
   162     switch (section) {
   159         case 0:
   163         case 0:
   160             return 1;
   164             return 2;
   161             break;
   165             break;
   162         case 1:
   166         case 1:
   163             return [self.basicSettingList count];
   167             return [self.basicSettingList count];
   164             break;
   168             break;
   165         case 2:
   169         case 2:
   185             if (editableCell == nil) {
   189             if (editableCell == nil) {
   186                 editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
   190                 editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
   187                                                reuseIdentifier:CellIdentifier0] autorelease];
   191                                                reuseIdentifier:CellIdentifier0] autorelease];
   188                 editableCell.delegate = self;
   192                 editableCell.delegate = self;
   189             }
   193             }
   190 
   194             editableCell.tag = row;
   191             editableCell.textField.text = self.schemeName;
   195             editableCell.selectionStyle = UITableViewCellSelectionStyleNone;
       
   196             editableCell.imageView.image = nil;
   192             editableCell.detailTextLabel.text = nil;
   197             editableCell.detailTextLabel.text = nil;
   193             editableCell.imageView.image = nil;
   198          
   194             editableCell.selectionStyle = UITableViewCellSelectionStyleNone;
   199             if (row == 0) {
       
   200                 editableCell.textField.text = self.schemeName;
       
   201             } else {
       
   202                 editableCell.textField.font = [UIFont systemFontOfSize:[UIFont labelFontSize]];
       
   203                 editableCell.textField.text = [self.schemeDictionary objectForKey:@"description"];
       
   204                 editableCell.textField.placeholder = NSLocalizedString(@"You can add a description if you wish",@"");
       
   205             }
   195             cell = editableCell;
   206             cell = editableCell;
   196             break;
   207             break;
   197         case 1:
   208         case 1:
   198             cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
   209             cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
   199             NSDictionary *detail = [self.basicSettingList objectAtIndex:row];
   210             NSDictionary *detail = [self.basicSettingList objectAtIndex:row];