49 [self.view.layer setCornerRadius:10]; |
49 [self.view.layer setCornerRadius:10]; |
50 [self.view.layer setMasksToBounds:YES]; |
50 [self.view.layer setMasksToBounds:YES]; |
51 self.view.autoresizingMask = UIViewAutoresizingNone; |
51 self.view.autoresizingMask = UIViewAutoresizingNone; |
52 |
52 |
53 self.isVisible = NO; |
53 self.isVisible = NO; |
54 delay = (uint8_t *) calloc(HW_getNumberOfWeapons(), sizeof(uint8_t)); |
54 delay = (uint8_t *)calloc(HW_getNumberOfWeapons(), sizeof(uint8_t)); |
55 HW_getAmmoDelays(delay); |
55 HW_getAmmoDelays(delay); |
|
56 |
|
57 shouldUpdateImage = (BOOL *)calloc(HW_getNumberOfWeapons(), sizeof(BOOL)); |
56 |
58 |
57 [super viewDidLoad]; |
59 [super viewDidLoad]; |
58 } |
60 } |
59 |
61 |
60 -(void) viewWillAppear:(BOOL)animated { |
62 -(void) viewWillAppear:(BOOL)animated { |
173 UIButton *button = [self.buttonsArray objectAtIndex:i]; |
175 UIButton *button = [self.buttonsArray objectAtIndex:i]; |
174 if (loadout[i] > 0) { |
176 if (loadout[i] > 0) { |
175 if (delay[i]-turns >= 0) { |
177 if (delay[i]-turns >= 0) { |
176 button.layer.borderColor = [[UIColor lightGrayColor] CGColor]; |
178 button.layer.borderColor = [[UIColor lightGrayColor] CGColor]; |
177 [button setTitle:[NSString stringWithFormat:@" %d ",delay[i]-turns+1] forState:UIControlStateNormal]; |
179 [button setTitle:[NSString stringWithFormat:@" %d ",delay[i]-turns+1] forState:UIControlStateNormal]; |
178 if (button.currentBackgroundImage == nil) { |
180 if (button.currentBackgroundImage == nil || shouldUpdateImage[i] == NO) { |
179 UIImage *img = [self.imagesArray objectAtIndex:i]; |
181 UIImage *img = [self.imagesArray objectAtIndex:i]; |
180 [button setBackgroundImage:[img convertToGrayScale] forState:UIControlStateNormal]; |
182 [button setBackgroundImage:[img convertToGrayScale] forState:UIControlStateNormal]; |
181 button.imageView.tag = 10000; |
183 shouldUpdateImage[i] = YES; |
182 } |
184 } |
183 } else { |
185 } else { |
184 button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor]; |
186 button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor]; |
185 [button setTitle:nil forState:UIControlStateNormal]; |
187 [button setTitle:nil forState:UIControlStateNormal]; |
186 if (button.currentBackgroundImage == nil || button.imageView.tag == 10000) { |
188 if (button.currentBackgroundImage == nil || shouldUpdateImage[i] == YES) { |
187 UIImage *img = [self.imagesArray objectAtIndex:i]; |
189 UIImage *img = [self.imagesArray objectAtIndex:i]; |
188 [button setBackgroundImage:img forState:UIControlStateNormal]; |
190 [button setBackgroundImage:img forState:UIControlStateNormal]; |
189 button.imageView.tag = 0; |
191 shouldUpdateImage[i] = NO; |
190 } |
192 } |
191 } |
193 } |
192 button.enabled = YES; |
194 button.enabled = YES; |
193 } else { |
195 } else { |
194 if (button.enabled == YES) |
196 if (button.enabled == YES) |
195 [button setBackgroundImage:nil forState:UIControlStateNormal]; |
197 [button setBackgroundImage:nil forState:UIControlStateNormal]; |
196 button.layer.borderColor = [[UIColor darkGrayColor] CGColor]; |
198 button.layer.borderColor = [[UIColor darkGrayColor] CGColor]; |
197 button.enabled = NO; |
199 button.enabled = NO; |
|
200 shouldUpdateImage[i] = NO; |
198 } |
201 } |
199 } |
202 } |
200 } else { |
203 } else { |
201 self.view.userInteractionEnabled = NO; |
204 self.view.userInteractionEnabled = NO; |
202 } |
205 } |
272 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
275 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
273 self.imagesArray = nil; |
276 self.imagesArray = nil; |
274 self.buttonsArray = nil; |
277 self.buttonsArray = nil; |
275 free(delay); |
278 free(delay); |
276 delay = NULL; |
279 delay = NULL; |
|
280 free(shouldUpdateImage); |
|
281 shouldUpdateImage = NULL; |
277 MSG_DIDUNLOAD(); |
282 MSG_DIDUNLOAD(); |
278 [super viewDidUnload]; |
283 [super viewDidUnload]; |
279 } |
284 } |
280 |
285 |
281 -(void) dealloc { |
286 -(void) dealloc { |