author | koda |
Mon, 30 May 2011 01:14:25 +0200 | |
changeset 5224 | 6e8fbbfb0de5 |
parent 5208 | 878e551f0b4a |
child 5662 | 99083392cd4f |
permissions | -rw-r--r-- |
3924 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3924 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
* |
|
18 |
* File created on 03/10/2010. |
|
19 |
*/ |
|
20 |
||
21 |
||
22 |
#import "AmmoMenuViewController.h" |
|
23 |
#import <QuartzCore/QuartzCore.h> |
|
24 |
#import "CommodityFunctions.h" |
|
25 |
#import "UIImageExtra.h" |
|
26 |
#import "PascalImports.h" |
|
27 |
||
3989 | 28 |
#define BTNS_PER_ROW 9 |
4032 | 29 |
#define DEFAULT_DESCRIPTION IS_IPAD() ? \ |
4356 | 30 |
NSLocalizedString(@"Hold your finger on a weapon to see what it does.\nYou can move this window anywhere on the screen.",@"") : \ |
4032 | 31 |
NSLocalizedString(@"Hold your finger on a weapon to see what it does.\nTap anywhere to dismiss.",@"") |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
32 |
|
3924 | 33 |
@implementation AmmoMenuViewController |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
34 |
@synthesize imagesArray, buttonsArray, nameLabel, extraLabel, captionLabel, isVisible; |
3924 | 35 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
36 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
37 |
return rotationManager(interfaceOrientation); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
38 |
} |
3924 | 39 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
40 |
#pragma mark - |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
41 |
#pragma mark view handling |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
42 |
-(void) viewDidLoad { |
3924 | 43 |
self.view.frame = CGRectMake(0, 0, 480, 320); |
44 |
self.view.backgroundColor = [UIColor blackColor]; |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
45 |
self.view.layer.borderColor = [[UIColor whiteColor] CGColor]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
46 |
self.view.layer.borderWidth = 1.3f; |
3924 | 47 |
[self.view.layer setCornerRadius:10]; |
48 |
[self.view.layer setMasksToBounds:YES]; |
|
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
49 |
self.view.autoresizingMask = UIViewAutoresizingNone; |
4032 | 50 |
placingPoint = CGPointMake(-1, -1); |
51 |
||
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
52 |
self.isVisible = NO; |
3978 | 53 |
delay = (uint8_t *)calloc(HW_getNumberOfWeapons(), sizeof(uint8_t)); |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
54 |
HW_getAmmoDelays(delay); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
55 |
|
3978 | 56 |
shouldUpdateImage = (BOOL *)calloc(HW_getNumberOfWeapons(), sizeof(BOOL)); |
57 |
||
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
58 |
[super viewDidLoad]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
59 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
60 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
61 |
-(void) viewWillAppear:(BOOL)animated { |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
62 |
[self updateAmmoVisuals]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
63 |
[super viewWillAppear:animated]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
64 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
65 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
66 |
-(void) appearInView:(UIView *)container { |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
67 |
[self viewWillAppear:YES]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
68 |
[container addSubview:self.view]; |
4032 | 69 |
|
5195 | 70 |
if (placingPoint.x == -1 || placingPoint.y == -1) |
4032 | 71 |
placingPoint = container.center; |
5195 | 72 |
if (IS_DUALHEAD() == YES) { |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
73 |
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
74 |
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) |
4032 | 75 |
self.view.center = CGPointMake(placingPoint.y, placingPoint.x); |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
76 |
else |
4032 | 77 |
self.view.center = CGPointMake(placingPoint.x, placingPoint.y); |
5195 | 78 |
} else |
79 |
self.view.center = CGPointMake(placingPoint.y, placingPoint.x); |
|
80 |
||
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
81 |
self.isVisible = YES; |
4853
afe24c4491ef
sheepluva suggested that game should pause when in weapon screen (iphone only)
koda
parents:
4362
diff
changeset
|
82 |
if (IS_IPAD() == NO) |
afe24c4491ef
sheepluva suggested that game should pause when in weapon screen (iphone only)
koda
parents:
4362
diff
changeset
|
83 |
HW_pause(); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
84 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
85 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
86 |
-(void) disappear { |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
87 |
if (self.isVisible) |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
88 |
[self.view removeFromSuperview]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
89 |
self.isVisible = NO; |
4032 | 90 |
placingPoint.x = self.view.center.y; |
91 |
placingPoint.y = self.view.center.x; |
|
4853
afe24c4491ef
sheepluva suggested that game should pause when in weapon screen (iphone only)
koda
parents:
4362
diff
changeset
|
92 |
if (IS_IPAD() == NO) |
afe24c4491ef
sheepluva suggested that game should pause when in weapon screen (iphone only)
koda
parents:
4362
diff
changeset
|
93 |
HW_pauseToggle(); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
94 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
95 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
96 |
#pragma mark - |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
97 |
#pragma mark drawing |
3989 | 98 |
-(void) loadLabels { |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
99 |
int x = 12; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
100 |
int y = (HW_getNumberOfWeapons()/BTNS_PER_ROW)*44 + 18; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
101 |
UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 200, 20)]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
102 |
name.backgroundColor = [UIColor clearColor]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
103 |
name.textColor = UICOLOR_HW_YELLOW_BODER; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
104 |
name.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
105 |
self.nameLabel = name; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
106 |
[self.view addSubview:self.nameLabel]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
107 |
[name release]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
108 |
|
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
109 |
UILabel *caption = [[UILabel alloc] initWithFrame:CGRectMake(x+200, y, 220, 20)]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
110 |
caption.backgroundColor = [UIColor clearColor]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
111 |
caption.textColor = [UIColor whiteColor]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
112 |
caption.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
113 |
caption.adjustsFontSizeToFitWidth = YES; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
114 |
caption.minimumFontSize = 8; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
115 |
self.captionLabel = caption; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
116 |
[self.view addSubview:self.captionLabel]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
117 |
[caption release]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
118 |
|
5195 | 119 |
UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(x+2, self.view.frame.size.height-50, 415, 53)]; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
120 |
description.backgroundColor = [UIColor clearColor]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
121 |
description.textColor = [UIColor whiteColor]; |
3989 | 122 |
description.text = DEFAULT_DESCRIPTION; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
123 |
description.font = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
124 |
description.adjustsFontSizeToFitWidth = YES; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
125 |
description.minimumFontSize = 8; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
126 |
description.numberOfLines = 0; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
127 |
self.extraLabel = description; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
128 |
[self.view addSubview:self.extraLabel]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
129 |
[description release]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
130 |
} |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
131 |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
132 |
-(void) loadAmmoStuff:(id) object { |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
133 |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
3924 | 134 |
NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()]; |
135 |
UIImage *ammoStoreImage = [[UIImage alloc] initWithContentsOfFile:str]; |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
136 |
|
3977 | 137 |
NSMutableArray *imgs = [[NSMutableArray alloc] initWithCapacity:HW_getNumberOfWeapons()]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
138 |
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:HW_getNumberOfWeapons()]; |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
139 |
int i, j, e; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
140 |
for (i = 0, j = 0, e = 0; i < HW_getNumberOfWeapons(); i++) { |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
141 |
int x, y; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
142 |
float w, radius; |
3924 | 143 |
|
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
144 |
// move utilities aside and make 'em rounded |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
145 |
if (HW_isWeaponAnEffect(i)) { |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
146 |
x = 432; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
147 |
y = 20 + 48*e++; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
148 |
w = 1.5; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
149 |
radius = 22; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
150 |
} else { |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
151 |
x = 10+(j%BTNS_PER_ROW)*44; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
152 |
y = 10+(j/BTNS_PER_ROW)*44; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
153 |
if (j / BTNS_PER_ROW % 2 != 0) |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
154 |
x += 20; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
155 |
w = 1; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
156 |
radius = 6; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
157 |
j++; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
158 |
} |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
159 |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
160 |
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
161 |
button.frame = CGRectMake(x, y, 40, 40); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
162 |
button.tag = i; |
3924 | 163 |
button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor]; |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
164 |
button.layer.borderWidth = w; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
165 |
[button.layer setCornerRadius:radius]; |
3924 | 166 |
[button.layer setMasksToBounds:YES]; |
3976 | 167 |
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown]; |
168 |
[button addTarget:self action:@selector(buttonReleased:) forControlEvents:UIControlEventTouchUpInside]; |
|
3989 | 169 |
[button addTarget:self action:@selector(buttonCancelled:) forControlEvents:UIControlEventTouchUpOutside|UIControlEventTouchCancel]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
170 |
[button setTitleColor:UICOLOR_HW_YELLOW_TEXT forState:UIControlStateNormal]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
171 |
button.titleLabel.backgroundColor = [UIColor blackColor]; |
3935 | 172 |
button.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
173 |
[button.titleLabel.layer setCornerRadius:3]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
174 |
[button.titleLabel.layer setMasksToBounds:YES]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
175 |
button.titleLabel.layer.borderColor = [[UIColor whiteColor] CGColor]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
176 |
button.titleLabel.layer.borderWidth = 1; |
3924 | 177 |
[self.view addSubview:button]; |
178 |
[array addObject:button]; |
|
3977 | 179 |
|
180 |
int x_src = ((i*32)/(int)ammoStoreImage.size.height)*32; |
|
181 |
int y_src = (i*32)%(int)ammoStoreImage.size.height; |
|
182 |
UIImage *img = [ammoStoreImage cutAt:CGRectMake(x_src, y_src, 32, 32)]; |
|
183 |
[imgs addObject:img]; |
|
3924 | 184 |
} |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
185 |
[self performSelectorOnMainThread:@selector(setButtonsArray:) withObject:array waitUntilDone:NO]; |
3924 | 186 |
[array release]; |
3977 | 187 |
|
188 |
[self performSelectorOnMainThread:@selector(setImagesArray:) withObject:imgs waitUntilDone:NO]; |
|
189 |
[imgs release]; |
|
190 |
[ammoStoreImage release]; |
|
191 |
||
3989 | 192 |
[self performSelectorOnMainThread:@selector(loadLabels) withObject:nil waitUntilDone:NO]; |
193 |
||
3977 | 194 |
[self performSelectorOnMainThread:@selector(updateAmmoVisuals) withObject:nil waitUntilDone:YES]; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
195 |
UIActivityIndicatorView *spinner = (UIActivityIndicatorView *)object; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
196 |
[spinner stopAnimating]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
197 |
[pool drain]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
198 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
199 |
|
3935 | 200 |
-(void) updateAmmoVisuals { |
3977 | 201 |
if (self.buttonsArray == nil || self.imagesArray == nil) { |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
202 |
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
203 |
spinner.hidesWhenStopped = YES; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
204 |
spinner.center = self.view.center; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
205 |
[spinner startAnimating]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
206 |
[self.view addSubview:spinner]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
207 |
[NSThread detachNewThreadSelector:@selector(loadAmmoStuff:) toTarget:self withObject:spinner]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
208 |
[spinner release]; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
209 |
return; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
210 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
211 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
212 |
int *loadout = (int *)calloc(HW_getNumberOfWeapons(), sizeof(int)); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
213 |
int res = HW_getAmmoCounts(loadout); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
214 |
int turns = HW_getTurnsForCurrentTeam(); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
215 |
|
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
216 |
if (res == 0) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
217 |
self.view.userInteractionEnabled = YES; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
218 |
|
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
219 |
for (int i = 0; i < HW_getNumberOfWeapons(); i++) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
220 |
UIButton *button = [self.buttonsArray objectAtIndex:i]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
221 |
if (loadout[i] > 0) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
222 |
if (delay[i]-turns >= 0) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
223 |
button.layer.borderColor = [[UIColor lightGrayColor] CGColor]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
224 |
[button setTitle:[NSString stringWithFormat:@" %d ",delay[i]-turns+1] forState:UIControlStateNormal]; |
3978 | 225 |
if (button.currentBackgroundImage == nil || shouldUpdateImage[i] == NO) { |
3977 | 226 |
UIImage *img = [self.imagesArray objectAtIndex:i]; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
227 |
[button setBackgroundImage:[img convertToGrayScale] forState:UIControlStateNormal]; |
3978 | 228 |
shouldUpdateImage[i] = YES; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
229 |
} |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
230 |
} else { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
231 |
button.layer.borderColor = [UICOLOR_HW_YELLOW_TEXT CGColor]; |
3976 | 232 |
[button setTitle:nil forState:UIControlStateNormal]; |
3978 | 233 |
if (button.currentBackgroundImage == nil || shouldUpdateImage[i] == YES) { |
3977 | 234 |
UIImage *img = [self.imagesArray objectAtIndex:i]; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
235 |
[button setBackgroundImage:img forState:UIControlStateNormal]; |
3978 | 236 |
shouldUpdateImage[i] = NO; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
237 |
} |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
238 |
} |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
239 |
button.enabled = YES; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
240 |
} else { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
241 |
if (button.enabled == YES) |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
242 |
[button setBackgroundImage:nil forState:UIControlStateNormal]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
243 |
button.layer.borderColor = [[UIColor darkGrayColor] CGColor]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
244 |
button.enabled = NO; |
3978 | 245 |
shouldUpdateImage[i] = NO; |
3935 | 246 |
} |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
247 |
} |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
248 |
} else { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
249 |
self.view.userInteractionEnabled = NO; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
250 |
} |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
251 |
|
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
252 |
free(loadout); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
253 |
loadout = NULL; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
254 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
255 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
256 |
#pragma mark - |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
257 |
#pragma mark user interaction |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
258 |
-(void) buttonPressed:(id) sender { |
3924 | 259 |
UIButton *theButton = (UIButton *)sender; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
260 |
if (self.nameLabel == nil || self.extraLabel == nil) |
3989 | 261 |
[self loadLabels]; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
262 |
|
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
263 |
self.nameLabel.text = [NSString stringWithUTF8String:HW_getWeaponNameByIndex(theButton.tag)]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
264 |
// description contains a lot of unnecessary stuff, we clean it by removing .|, !| and ?| |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
265 |
NSString *description = [NSString stringWithUTF8String:HW_getWeaponDescriptionByIndex(theButton.tag)]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
266 |
NSArray *elements = [description componentsSeparatedByString:@".|"]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
267 |
NSArray *purgedElements = [[elements objectAtIndex:0] componentsSeparatedByString:@"!|"]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
268 |
NSArray *morePurgedElements = [[purgedElements objectAtIndex:0] componentsSeparatedByString:@"?|"]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
269 |
self.extraLabel.text = [[[morePurgedElements objectAtIndex:0] stringByReplacingOccurrencesOfString:@"|" withString:@" "] stringByAppendingString:@"."]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
270 |
if (theButton.currentTitle != nil) |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
271 |
self.captionLabel.text = NSLocalizedString(@"This weapon is locked",@""); |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
272 |
else |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
273 |
self.captionLabel.text = [NSString stringWithUTF8String:HW_getWeaponCaptionByIndex(theButton.tag)]; |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
274 |
|
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
275 |
self.nameLabel.backgroundColor = [UIColor blackColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
276 |
self.captionLabel.backgroundColor = [UIColor blackColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
277 |
self.extraLabel.backgroundColor = [UIColor blackColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
278 |
|
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
279 |
int y, x = 8; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
280 |
// display labels on top for lower buttons |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
281 |
if (theButton.tag > 41) |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
282 |
y = 5; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
283 |
else |
5195 | 284 |
y = (HW_getNumberOfWeapons()/BTNS_PER_ROW)*40; |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
285 |
|
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
286 |
self.nameLabel.frame = CGRectMake(x, y, 200, 20); |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
287 |
self.captionLabel.frame = CGRectMake(x+200, y, 220, 20); |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
288 |
self.extraLabel.frame = CGRectMake(x+2, y+20, 415, 53); |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
289 |
} |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
290 |
|
3989 | 291 |
-(void) buttonCancelled:(id) sender { |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
292 |
self.nameLabel.text = nil; |
4032 | 293 |
self.extraLabel.text = nil; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
294 |
self.captionLabel.text = nil; |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
295 |
self.extraLabel.backgroundColor = [UIColor clearColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
296 |
self.captionLabel.backgroundColor = [UIColor clearColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
297 |
self.nameLabel.backgroundColor = [UIColor clearColor]; |
3976 | 298 |
} |
299 |
||
300 |
-(void) buttonReleased:(id) sender { |
|
301 |
UIButton *theButton = (UIButton *)sender; |
|
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
302 |
if (self.nameLabel == nil || self.extraLabel == nil) |
3989 | 303 |
[self loadLabels]; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
304 |
|
3976 | 305 |
if (theButton.currentTitle == nil) { |
306 |
HW_setWeapon(theButton.tag); |
|
307 |
playSound(@"clickSound"); |
|
3984 | 308 |
if (IS_DUALHEAD() == NO) |
309 |
[self disappear]; |
|
3976 | 310 |
} |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
311 |
[self buttonCancelled:sender]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
312 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
313 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
314 |
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
315 |
NSSet *allTouches = [event allTouches]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
316 |
|
4032 | 317 |
if (IS_IPAD() && [touches count] == 1) { |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
318 |
self.view.layer.borderWidth = 3.5; |
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
319 |
currentPoint = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
320 |
} |
4032 | 321 |
|
3996 | 322 |
if (IS_IPAD() == NO) |
323 |
[self disappear]; |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
324 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
325 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
326 |
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
4032 | 327 |
self.view.layer.borderWidth = 1.3; |
3924 | 328 |
} |
329 |
||
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
330 |
// better window dragging implementation by |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
331 |
// http://iphonedevelopertips.com/graphics/drag-an-image-within-the-bounds-of-superview.html |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
332 |
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { |
4032 | 333 |
if (IS_IPAD() && [touches count] == 1) { |
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
334 |
// Get active location upon move |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
335 |
CGPoint activePoint = [[touches anyObject] locationInView:self.view]; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
336 |
|
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
337 |
// Determine new point based on where the touch is now located |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
338 |
CGPoint newPoint = CGPointMake(self.view.center.x + (activePoint.x - currentPoint.x), |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
339 |
self.view.center.y + (activePoint.y - currentPoint.y)); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
340 |
|
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
341 |
// Make sure we stay within the bounds of the parent view |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
342 |
float midPointX = CGRectGetMidX(self.view.bounds); |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
343 |
if (newPoint.x > self.view.superview.bounds.size.width - midPointX) |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
344 |
newPoint.x = self.view.superview.bounds.size.width - midPointX; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
345 |
else if (newPoint.x < midPointX) |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
346 |
newPoint.x = midPointX; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
347 |
|
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
348 |
float midPointY = CGRectGetMidY(self.view.bounds); |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
349 |
if (newPoint.y > self.view.superview.bounds.size.height - midPointY) |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
350 |
newPoint.y = self.view.superview.bounds.size.height - midPointY; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
351 |
else if (newPoint.y < midPointY) |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
352 |
newPoint.y = midPointY; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
353 |
|
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
354 |
self.view.center = newPoint; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
355 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
356 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
357 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
358 |
-(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
4032 | 359 |
[self touchesEnded:touches withEvent:event]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
360 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
361 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
362 |
#pragma mark - |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
363 |
#pragma mark memory |
3924 | 364 |
-(void) didReceiveMemoryWarning { |
3977 | 365 |
self.imagesArray = nil; |
4082 | 366 |
if (self.isVisible == NO) |
367 |
self.buttonsArray = nil; |
|
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
368 |
self.nameLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
369 |
self.extraLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
370 |
self.captionLabel = nil; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
371 |
MSG_MEMCLEAN(); |
3924 | 372 |
[super didReceiveMemoryWarning]; |
373 |
} |
|
374 |
||
375 |
-(void) viewDidUnload { |
|
3977 | 376 |
self.imagesArray = nil; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
377 |
self.buttonsArray = nil; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
378 |
self.nameLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
379 |
self.extraLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
380 |
self.captionLabel = nil; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
381 |
free(delay); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
382 |
delay = NULL; |
3978 | 383 |
free(shouldUpdateImage); |
384 |
shouldUpdateImage = NULL; |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
385 |
MSG_DIDUNLOAD(); |
3924 | 386 |
[super viewDidUnload]; |
387 |
} |
|
388 |
||
389 |
-(void) dealloc { |
|
5208 | 390 |
releaseAndNil(nameLabel); |
391 |
releaseAndNil(extraLabel); |
|
392 |
releaseAndNil(captionLabel); |
|
393 |
releaseAndNil(imagesArray); |
|
394 |
releaseAndNil(buttonsArray); |
|
3924 | 395 |
[super dealloc]; |
396 |
} |
|
397 |
||
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
398 |
@end |