project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m
changeset 6672 4f728ccdd06b
parent 6095 332d45c08592
child 6700 e04da46ee43c
equal deleted inserted replaced
6671:5532d5f6285c 6672:4f728ccdd06b
    85     NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName];
    85     NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName];
    86     [self.schemeDictionary writeToFile:schemeFile atomically:YES];
    86     [self.schemeDictionary writeToFile:schemeFile atomically:YES];
    87     [schemeFile release];
    87     [schemeFile release];
    88 }
    88 }
    89 
    89 
       
    90 // force a redraw of the game mod section to reposition the slider
       
    91 -(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
       
    92     if (IS_IPAD() == NO)
       
    93         return;
       
    94     [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationFade];
       
    95 }
       
    96 
    90 #pragma mark -
    97 #pragma mark -
    91 #pragma mark editableCellView delegate
    98 #pragma mark editableCellView delegate
    92 // set the new value
    99 // set the new value
    93 -(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
   100 -(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
    94     if (tagValue == 0) {
   101     if (tagValue == 0) {
   164             // need to offset this section (see format in CommodityFunctions.m and above)
   171             // need to offset this section (see format in CommodityFunctions.m and above)
   165             if (cell == nil) {
   172             if (cell == nil) {
   166                 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
   173                 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
   167                                                reuseIdentifier:CellIdentifier1] autorelease];
   174                                                reuseIdentifier:CellIdentifier1] autorelease];
   168 
   175 
   169                 int offset = 0;
   176                 UISlider *slider = [[UISlider alloc] init];
   170                 if (IS_IPAD())
       
   171                     offset = 50;
       
   172 
       
   173                 UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)];
       
   174                 [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
   177                 [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
   175                 [cell.contentView addSubview:slider];
   178                 [cell.contentView addSubview:slider];
   176                 [slider release];
   179                 [slider release];
   177 
   180 
   178                 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)];
   181                 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)];
   202             }
   205             }
   203             cellSlider.tag = SLIDER_TAG + row;
   206             cellSlider.tag = SLIDER_TAG + row;
   204             cellSlider.maximumValue = [[detail objectForKey:@"max"] floatValue];
   207             cellSlider.maximumValue = [[detail objectForKey:@"max"] floatValue];
   205             cellSlider.minimumValue = [[detail objectForKey:@"min"] floatValue];
   208             cellSlider.minimumValue = [[detail objectForKey:@"min"] floatValue];
   206             cellSlider.value = [[[self.schemeDictionary objectForKey:@"basic"] objectAtIndex:row] floatValue];
   209             cellSlider.value = [[[self.schemeDictionary objectForKey:@"basic"] objectAtIndex:row] floatValue];
       
   210             // redraw the slider here
       
   211             NSInteger hOffset = 260;
       
   212             NSInteger vOffset = 12;
       
   213             NSInteger sliderLength = 150;
       
   214             if (IS_IPAD()) {
       
   215                 hOffset = 310;
       
   216                 sliderLength = 230;
       
   217                 if (IS_ON_PORTRAIT()) {
       
   218                     hOffset = 50;
       
   219                     vOffset = 40;
       
   220                     sliderLength = 285;
       
   221                 }
       
   222             }
       
   223             cellSlider.frame = CGRectMake(hOffset, vOffset, sliderLength, 23);
   207 
   224 
   208             NSString *prestring = nil;
   225             NSString *prestring = nil;
   209             checkValueString(prestring,cellLabel.text,cellSlider);
   226             checkValueString(prestring,cellLabel.text,cellSlider);
   210 
   227 
   211             // forced to use this weird format otherwise the label disappears when size of the text is bigger than the original
   228             // forced to use this weird format otherwise the label disappears when size of the text is bigger than the original
   319             break;
   336             break;
   320     }
   337     }
   321     return sectionTitle;
   338     return sectionTitle;
   322 }
   339 }
   323 
   340 
   324 -(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   341 -(CGFloat) tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   325     if ([indexPath section] == 2)
   342     if ([indexPath section] == 0)
       
   343         return aTableView.rowHeight;
       
   344     else if ([indexPath section] == 1)
       
   345         return IS_ON_PORTRAIT() ? 72 : aTableView.rowHeight;
       
   346     else
   326         return 56;
   347         return 56;
   327     else
       
   328         return self.tableView.rowHeight;
       
   329 }
   348 }
   330 
   349 
   331 #pragma mark -
   350 #pragma mark -
   332 #pragma mark Memory management
   351 #pragma mark Memory management
   333 -(void) didReceiveMemoryWarning {
   352 -(void) didReceiveMemoryWarning {