project_files/HedgewarsMobile/Classes/WeaponCellView.m
changeset 6670 d57fa21781ea
parent 6078 8c0cc07731e5
child 6671 5532d5f6285c
equal deleted inserted replaced
6669:3933198e2b28 6670:d57fa21781ea
   103         helpLabel = [[UILabel alloc] init];
   103         helpLabel = [[UILabel alloc] init];
   104         helpLabel.backgroundColor = [UIColor clearColor];
   104         helpLabel.backgroundColor = [UIColor clearColor];
   105         helpLabel.textColor = [UIColor darkGrayColor];
   105         helpLabel.textColor = [UIColor darkGrayColor];
   106         helpLabel.textAlignment = UITextAlignmentRight;
   106         helpLabel.textAlignment = UITextAlignmentRight;
   107         helpLabel.font = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]];
   107         helpLabel.font = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]];
       
   108         helpLabel.adjustsFontSizeToFitWidth = YES;
   108 
   109 
   109         [self.contentView addSubview:weaponName];
   110         [self.contentView addSubview:weaponName];
   110         [self.contentView addSubview:weaponIcon];
   111         [self.contentView addSubview:weaponIcon];
   111 
   112 
   112         [self.contentView addSubview:initialSli];
   113         [self.contentView addSubview:initialSli];
   130 }
   131 }
   131 
   132 
   132 -(void) layoutSubviews {
   133 -(void) layoutSubviews {
   133     [super layoutSubviews];
   134     [super layoutSubviews];
   134 
   135 
   135     CGRect contentRect = self.contentView.bounds;
   136     CGFloat hOffset = 80;
   136     CGFloat shiftSliders = contentRect.origin.x;
   137     CGFloat hOffsetWhenLandscape = 234;
   137     CGFloat shiftLabel = 0;
   138     CGFloat vOffset = 40;
       
   139     CGFloat vOffsetWhenPortrait = 0;
       
   140     CGFloat helpLabelOffset = 0;
       
   141     CGFloat helpLabelLength = 0;
       
   142     CGFloat sliderLength = 150;
   138 
   143 
   139     if (IS_IPAD()) {
   144     if (IS_IPAD()) {
   140         shiftSliders += 65;
   145         if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
   141         shiftLabel += 165;
   146             sliderLength = 190;
   142     } else
   147             hOffsetWhenLandscape = 0;
   143         shiftSliders -= 13;
   148             vOffsetWhenPortrait = 80;
       
   149             hOffset = 120;
       
   150             helpLabelOffset = -35;
       
   151             helpLabelLength = 200;
       
   152         } else {
       
   153             hOffset = 145;
       
   154             helpLabelOffset = 35;
       
   155             helpLabelLength = 350;
       
   156         }
       
   157     } else {
       
   158         helpLabelLength = 250;
       
   159         hOffset = 67;
       
   160     }
   144 
   161 
   145     weaponIcon.frame = CGRectMake(5, 5, 32, 32);
   162     weaponIcon.frame = CGRectMake(5, 5, 32, 32);
   146     weaponName.frame = CGRectMake(45, 8, 200, 25);
   163     weaponName.frame = CGRectMake(45, 8, 200, 25);
   147     
   164     
   148     helpLabel.frame = CGRectMake(shiftLabel + 200, 8, 250, 15);
   165     helpLabel.frame = CGRectMake(200 + helpLabelOffset, 11, helpLabelLength, 20);
   149 
   166 
   150     // second line
   167     // second line
   151     initialImg.frame = CGRectMake(shiftSliders + 20, 40, 32, 32);
   168     initialImg.frame = CGRectMake(hOffset - 60, vOffset, 32, 32);
   152     initialLab.frame = CGRectMake(shiftSliders + 56, 40, 20, 32);
   169     initialLab.frame = CGRectMake(hOffset - 23, vOffset, 20, 32);
   153     initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value];
   170     initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value];
   154     initialSli.frame = CGRectMake(shiftSliders + 80, 40, 150, 32);
   171     initialSli.frame = CGRectMake(hOffset, vOffset, sliderLength, 32);
   155 
   172 
   156     probabilityImg.frame = CGRectMake(shiftSliders + 255, 40, 32, 32);
   173     probabilityImg.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 60, vOffset + vOffsetWhenPortrait, 32, 32);
   157     probabilityLab.frame = CGRectMake(shiftSliders + 291, 40, 20, 32);
   174     probabilityLab.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 23, vOffset + vOffsetWhenPortrait, 20, 32);
   158     probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value];
   175     probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value];
   159     probabilitySli.frame = CGRectMake(shiftSliders + 314, 40, 150, 32);
   176     probabilitySli.frame = CGRectMake(hOffset + hOffsetWhenLandscape, vOffset + vOffsetWhenPortrait, sliderLength, 32);
   160 
   177 
   161     // third line
   178     // third line
   162     delayImg.frame = CGRectMake(shiftSliders + 20, 80, 32, 32);
   179     delayImg.frame = CGRectMake(hOffset - 60, vOffset + 40, 32, 32);
   163     delayLab.frame = CGRectMake(shiftSliders + 56, 80, 20, 32);
   180     delayLab.frame = CGRectMake(hOffset - 23, vOffset + 40, 20, 32);
   164     delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value];
   181     delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value];
   165     delaySli.frame = CGRectMake(shiftSliders + 80, 80, 150, 32);
   182     delaySli.frame = CGRectMake(hOffset, vOffset + 40, sliderLength, 32);
   166 
   183 
   167     crateImg.frame = CGRectMake(shiftSliders + 255, 80, 32, 32);
   184     crateImg.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 60, vOffset + 40 + vOffsetWhenPortrait, 32, 32);
   168     crateLab.frame = CGRectMake(shiftSliders + 291, 80, 20, 32);
   185     crateLab.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 23, vOffset + 40 + vOffsetWhenPortrait, 20, 32);
   169     crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value];
   186     crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value];
   170     crateSli.frame = CGRectMake(shiftSliders + 314, 80, 150, 32);
   187     crateSli.frame = CGRectMake(hOffset + hOffsetWhenLandscape, vOffset + 40 + vOffsetWhenPortrait, sliderLength, 32);
   171 }
   188 }
   172 
   189 
   173 /*
   190 /*
   174 -(void) setSelected:(BOOL)selected animated:(BOOL)animated {
   191 -(void) setSelected:(BOOL)selected animated:(BOOL)animated {
   175     [super setSelected:selected animated:animated];
   192     [super setSelected:selected animated:animated];
   198     UISlider *slider = (UISlider *)sender;
   215     UISlider *slider = (UISlider *)sender;
   199     NSString *str = nil;
   216     NSString *str = nil;
   200     
   217     
   201     switch (slider.tag) {
   218     switch (slider.tag) {
   202         case 100:
   219         case 100:
   203             str = NSLocalizedString(@"Initial quantity ",@"ammo selection");
   220             str = NSLocalizedString(@"Initial quantity",@"ammo selection");
   204             break;
   221             break;
   205         case 200:
   222         case 200:
   206             str = NSLocalizedString(@"Presence probability in crates ",@"ammo selection");
   223             if (IS_IPAD() && (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])))
       
   224                 str = NSLocalizedString(@"Probability in crates",@"ammo selection");
       
   225             else
       
   226                 str = NSLocalizedString(@"Presence probability in crates",@"ammo selection");
   207             break;
   227             break;
   208         case 300:
   228         case 300:
   209             str = NSLocalizedString(@"Number of turns before you can use this weapon ",@"ammo selection");
   229             if (IS_IPAD() && (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])))
       
   230                 str = NSLocalizedString(@"Weapon delay",@"ammo selection");
       
   231             else
       
   232                 str = NSLocalizedString(@"Turns before this weapon becomes usable",@"ammo selection");
   210             break;
   233             break;
   211         case 400:
   234         case 400:
   212             str = NSLocalizedString(@"Quantity that you will find in a crate ",@"ammo selection");
   235             if (IS_IPAD() && (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])))
       
   236                 str = NSLocalizedString(@"Quantity per crate",@"ammo selection");
       
   237             else
       
   238                 str = NSLocalizedString(@"Quantity you will find in a crate",@"ammo selection");
   213             break;
   239             break;
   214         default:
   240         default:
   215             DLog(@"Nope");
   241             DLog(@"Nope");
   216             break;
   242             break;
   217     }
   243     }