project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m
changeset 3976 abaf741a4e21
parent 3952 d6412423da45
child 3977 9df7b4812da9
equal deleted inserted replaced
3975:3f605cca9215 3976:abaf741a4e21
   120         button.tag = i;
   120         button.tag = i;
   121         button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor];
   121         button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor];
   122         button.layer.borderWidth = w;
   122         button.layer.borderWidth = w;
   123         [button.layer setCornerRadius:radius];
   123         [button.layer setCornerRadius:radius];
   124         [button.layer setMasksToBounds:YES];
   124         [button.layer setMasksToBounds:YES];
   125         [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
   125         [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];
       
   126         [button addTarget:self action:@selector(buttonReleased:) forControlEvents:UIControlEventTouchUpInside];
   126         [button setTitleColor:UICOLOR_HW_YELLOW_TEXT forState:UIControlStateNormal];
   127         [button setTitleColor:UICOLOR_HW_YELLOW_TEXT forState:UIControlStateNormal];
   127         button.titleLabel.backgroundColor = [UIColor blackColor];
   128         button.titleLabel.backgroundColor = [UIColor blackColor];
   128         button.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]];
   129         button.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]];
   129         [button.titleLabel.layer setCornerRadius:3];
   130         [button.titleLabel.layer setCornerRadius:3];
   130         [button.titleLabel.layer setMasksToBounds:YES];
   131         [button.titleLabel.layer setMasksToBounds:YES];
   180                         [button setBackgroundImage:[img convertToGrayScale] forState:UIControlStateNormal];
   181                         [button setBackgroundImage:[img convertToGrayScale] forState:UIControlStateNormal];
   181                         button.imageView.tag = 10000;
   182                         button.imageView.tag = 10000;
   182                     }
   183                     }
   183                 } else {
   184                 } else {
   184                     button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor];
   185                     button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor];
   185                     [button setTitle:@"" forState:UIControlStateNormal];
   186                     [button setTitle:nil forState:UIControlStateNormal];
   186                     if (button.currentBackgroundImage == nil || button.imageView.tag == 10000) {
   187                     if (button.currentBackgroundImage == nil || button.imageView.tag == 10000) {
   187                         int x_src = ((i*32)/(int)self.weaponsImage.size.height)*32;
   188                         int x_src = ((i*32)/(int)self.weaponsImage.size.height)*32;
   188                         int y_src = (i*32)%(int)self.weaponsImage.size.height;
   189                         int y_src = (i*32)%(int)self.weaponsImage.size.height;
   189                         UIImage *img = [self.weaponsImage cutAt:CGRectMake(x_src, y_src, 32, 32)];
   190                         UIImage *img = [self.weaponsImage cutAt:CGRectMake(x_src, y_src, 32, 32)];
   190                         [button setBackgroundImage:img forState:UIControlStateNormal];
   191                         [button setBackgroundImage:img forState:UIControlStateNormal];
   209     [pool drain];
   210     [pool drain];
   210 }
   211 }
   211 
   212 
   212 #pragma mark -
   213 #pragma mark -
   213 #pragma mark user interaction
   214 #pragma mark user interaction
   214 -(void) buttonPressed:(id) sender {
   215 -(void) buttonPressed:(id)  sender {
   215     UIButton *theButton = (UIButton *)sender;
   216     UIButton *theButton = (UIButton *)sender;
   216     HW_setWeapon(theButton.tag);
   217     if (theButton.currentTitle != nil) {
   217     playSound(@"clickSound");
   218         DLog(@"eeee");
       
   219     }
       
   220 }
       
   221 
       
   222 -(void) buttonReleased:(id) sender {
       
   223     UIButton *theButton = (UIButton *)sender;
       
   224     if (theButton.currentTitle == nil) {
       
   225         HW_setWeapon(theButton.tag);
       
   226         playSound(@"clickSound");
       
   227     }
   218     if (IS_DUALHEAD() == NO)
   228     if (IS_DUALHEAD() == NO)
   219         [self disappear];
   229         [self disappear];
   220 }
   230 }
   221 
   231 
   222 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
   232 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {