author | nemo |
Fri, 07 Oct 2011 17:29:00 -0400 | |
changeset 6091 | 77b826a8f996 |
parent 6078 | 8c0cc07731e5 |
child 6209 | 074ab6ebcb3e |
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> |
|
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
24 |
|
3924 | 25 |
|
3989 | 26 |
#define BTNS_PER_ROW 9 |
4032 | 27 |
#define DEFAULT_DESCRIPTION IS_IPAD() ? \ |
4356 | 28 |
NSLocalizedString(@"Hold your finger on a weapon to see what it does.\nYou can move this window anywhere on the screen.",@"") : \ |
4032 | 29 |
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
|
30 |
|
3924 | 31 |
@implementation AmmoMenuViewController |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
32 |
@synthesize imagesArray, buttonsArray, nameLabel, extraLabel, captionLabel, isVisible; |
3924 | 33 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
34 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
35 |
return rotationManager(interfaceOrientation); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
36 |
} |
3924 | 37 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
38 |
#pragma mark - |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
39 |
#pragma mark view handling |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
40 |
-(void) viewDidLoad { |
3924 | 41 |
self.view.frame = CGRectMake(0, 0, 480, 320); |
42 |
self.view.backgroundColor = [UIColor blackColor]; |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
43 |
self.view.layer.borderColor = [[UIColor whiteColor] CGColor]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
44 |
self.view.layer.borderWidth = 1.3f; |
3924 | 45 |
[self.view.layer setCornerRadius:10]; |
46 |
[self.view.layer setMasksToBounds:YES]; |
|
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
47 |
self.view.autoresizingMask = UIViewAutoresizingNone; |
4032 | 48 |
placingPoint = CGPointMake(-1, -1); |
49 |
||
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
50 |
self.isVisible = NO; |
3978 | 51 |
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
|
52 |
HW_getAmmoDelays(delay); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
53 |
|
3978 | 54 |
shouldUpdateImage = (BOOL *)calloc(HW_getNumberOfWeapons(), sizeof(BOOL)); |
55 |
||
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
56 |
[super viewDidLoad]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
57 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
58 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
59 |
-(void) viewWillAppear:(BOOL)animated { |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
60 |
[self updateAmmoVisuals]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
61 |
[super viewWillAppear:animated]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
62 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
63 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
64 |
-(void) appearInView:(UIView *)container { |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
65 |
[self viewWillAppear:YES]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
66 |
[container addSubview:self.view]; |
4032 | 67 |
|
5195 | 68 |
if (placingPoint.x == -1 || placingPoint.y == -1) |
4032 | 69 |
placingPoint = container.center; |
5662
99083392cd4f
FREE AT LAST!!! SDL came around a (mostly) sane way for implementing rotation events, so we can scrap all the workaround code that has been added to workaround it!! Also this allows us to use proper (internal) multitasking handling and can simplify optional settings and other yet unexplored features. Yay!
koda
parents:
5208
diff
changeset
|
70 |
self.view.center = placingPoint; |
5195 | 71 |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
72 |
self.isVisible = YES; |
4853
afe24c4491ef
sheepluva suggested that game should pause when in weapon screen (iphone only)
koda
parents:
4362
diff
changeset
|
73 |
if (IS_IPAD() == NO) |
afe24c4491ef
sheepluva suggested that game should pause when in weapon screen (iphone only)
koda
parents:
4362
diff
changeset
|
74 |
HW_pause(); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
75 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
76 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
77 |
-(void) disappear { |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
78 |
if (self.isVisible) |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
79 |
[self.view removeFromSuperview]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
80 |
self.isVisible = NO; |
5662
99083392cd4f
FREE AT LAST!!! SDL came around a (mostly) sane way for implementing rotation events, so we can scrap all the workaround code that has been added to workaround it!! Also this allows us to use proper (internal) multitasking handling and can simplify optional settings and other yet unexplored features. Yay!
koda
parents:
5208
diff
changeset
|
81 |
placingPoint = self.view.center; |
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_pauseToggle(); |
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 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
86 |
#pragma mark - |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
87 |
#pragma mark drawing |
3989 | 88 |
-(void) loadLabels { |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
89 |
int x = 12; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
90 |
int y = (HW_getNumberOfWeapons()/BTNS_PER_ROW)*44 + 18; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
91 |
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
|
92 |
name.backgroundColor = [UIColor clearColor]; |
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
93 |
name.textColor = [UIColor darkYellowColor]; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
94 |
name.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
95 |
self.nameLabel = name; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
96 |
[self.view addSubview:self.nameLabel]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
97 |
[name release]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
98 |
|
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
99 |
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
|
100 |
caption.backgroundColor = [UIColor clearColor]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
101 |
caption.textColor = [UIColor whiteColor]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
102 |
caption.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
103 |
caption.adjustsFontSizeToFitWidth = YES; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
104 |
caption.minimumFontSize = 8; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
105 |
self.captionLabel = caption; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
106 |
[self.view addSubview:self.captionLabel]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
107 |
[caption release]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
108 |
|
5195 | 109 |
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
|
110 |
description.backgroundColor = [UIColor clearColor]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
111 |
description.textColor = [UIColor whiteColor]; |
3989 | 112 |
description.text = DEFAULT_DESCRIPTION; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
113 |
description.font = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
114 |
description.adjustsFontSizeToFitWidth = YES; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
115 |
description.minimumFontSize = 8; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
116 |
description.numberOfLines = 0; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
117 |
self.extraLabel = description; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
118 |
[self.view addSubview:self.extraLabel]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
119 |
[description release]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
120 |
} |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
121 |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
122 |
-(void) loadAmmoStuff:(id) object { |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
123 |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
3924 | 124 |
NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()]; |
125 |
UIImage *ammoStoreImage = [[UIImage alloc] initWithContentsOfFile:str]; |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
126 |
|
3977 | 127 |
NSMutableArray *imgs = [[NSMutableArray alloc] initWithCapacity:HW_getNumberOfWeapons()]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
128 |
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:HW_getNumberOfWeapons()]; |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
129 |
int i, j, e; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
130 |
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
|
131 |
int x, y; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
132 |
float w, radius; |
3924 | 133 |
|
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
134 |
// move utilities aside and make 'em rounded |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
135 |
if (HW_isWeaponAnEffect(i)) { |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
136 |
x = 432; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
137 |
y = 20 + 48*e++; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
138 |
w = 1.5; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
139 |
radius = 22; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
140 |
} else { |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
141 |
x = 10+(j%BTNS_PER_ROW)*44; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
142 |
y = 10+(j/BTNS_PER_ROW)*44; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
143 |
if (j / BTNS_PER_ROW % 2 != 0) |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
144 |
x += 20; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
145 |
w = 1; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
146 |
radius = 6; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
147 |
j++; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
148 |
} |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
149 |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
150 |
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
151 |
button.frame = CGRectMake(x, y, 40, 40); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
152 |
button.tag = i; |
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
153 |
button.layer.borderColor = [[UIColor lightYellowColor] CGColor]; |
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
154 |
button.layer.borderWidth = w; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3941
diff
changeset
|
155 |
[button.layer setCornerRadius:radius]; |
3924 | 156 |
[button.layer setMasksToBounds:YES]; |
3976 | 157 |
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown]; |
158 |
[button addTarget:self action:@selector(buttonReleased:) forControlEvents:UIControlEventTouchUpInside]; |
|
3989 | 159 |
[button addTarget:self action:@selector(buttonCancelled:) forControlEvents:UIControlEventTouchUpOutside|UIControlEventTouchCancel]; |
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
160 |
[button setTitleColor:[UIColor lightYellowColor] forState:UIControlStateNormal]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
161 |
button.titleLabel.backgroundColor = [UIColor blackColor]; |
3935 | 162 |
button.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
163 |
[button.titleLabel.layer setCornerRadius:3]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
164 |
[button.titleLabel.layer setMasksToBounds:YES]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
165 |
button.titleLabel.layer.borderColor = [[UIColor whiteColor] CGColor]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
166 |
button.titleLabel.layer.borderWidth = 1; |
3924 | 167 |
[self.view addSubview:button]; |
168 |
[array addObject:button]; |
|
3977 | 169 |
|
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
170 |
int size = 32 * [[UIScreen mainScreen] scale]; |
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
171 |
int x_src = ((i*size)/(int)(ammoStoreImage.size.height * [[UIScreen mainScreen] scale]))*size; |
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
172 |
int y_src = (i*size)%(int)(ammoStoreImage.size.height * [[UIScreen mainScreen] scale]); |
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5662
diff
changeset
|
173 |
UIImage *img = [ammoStoreImage cutAt:CGRectMake(x_src, y_src, size, size)]; |
3977 | 174 |
[imgs addObject:img]; |
3924 | 175 |
} |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
176 |
[self performSelectorOnMainThread:@selector(setButtonsArray:) withObject:array waitUntilDone:NO]; |
3924 | 177 |
[array release]; |
3977 | 178 |
|
179 |
[self performSelectorOnMainThread:@selector(setImagesArray:) withObject:imgs waitUntilDone:NO]; |
|
180 |
[imgs release]; |
|
181 |
[ammoStoreImage release]; |
|
182 |
||
3989 | 183 |
[self performSelectorOnMainThread:@selector(loadLabels) withObject:nil waitUntilDone:NO]; |
184 |
||
3977 | 185 |
[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
|
186 |
UIActivityIndicatorView *spinner = (UIActivityIndicatorView *)object; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
187 |
[spinner stopAnimating]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
188 |
[pool drain]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
189 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
190 |
|
3935 | 191 |
-(void) updateAmmoVisuals { |
3977 | 192 |
if (self.buttonsArray == nil || self.imagesArray == nil) { |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
193 |
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
194 |
spinner.hidesWhenStopped = YES; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
195 |
spinner.center = self.view.center; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
196 |
[spinner startAnimating]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
197 |
[self.view addSubview:spinner]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
198 |
[NSThread detachNewThreadSelector:@selector(loadAmmoStuff:) toTarget:self withObject:spinner]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
199 |
[spinner release]; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
200 |
return; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
201 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
202 |
|
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
203 |
int *loadout = (int *)calloc(HW_getNumberOfWeapons(), sizeof(int)); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
204 |
int res = HW_getAmmoCounts(loadout); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
205 |
int turns = HW_getTurnsForCurrentTeam(); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
206 |
|
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
207 |
if (res == 0) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
208 |
self.view.userInteractionEnabled = YES; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
209 |
|
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
210 |
for (int i = 0; i < HW_getNumberOfWeapons(); i++) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
211 |
UIButton *button = [self.buttonsArray objectAtIndex:i]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
212 |
if (loadout[i] > 0) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
213 |
if (delay[i]-turns >= 0) { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
214 |
button.layer.borderColor = [[UIColor lightGrayColor] CGColor]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
215 |
[button setTitle:[NSString stringWithFormat:@" %d ",delay[i]-turns+1] forState:UIControlStateNormal]; |
3978 | 216 |
if (button.currentBackgroundImage == nil || shouldUpdateImage[i] == NO) { |
3977 | 217 |
UIImage *img = [self.imagesArray objectAtIndex:i]; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
218 |
[button setBackgroundImage:[img convertToGrayScale] forState:UIControlStateNormal]; |
3978 | 219 |
shouldUpdateImage[i] = YES; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
220 |
} |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
221 |
} else { |
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6000
diff
changeset
|
222 |
button.layer.borderColor = [[UIColor lightYellowColor] CGColor]; |
3976 | 223 |
[button setTitle:nil forState:UIControlStateNormal]; |
3978 | 224 |
if (button.currentBackgroundImage == nil || shouldUpdateImage[i] == YES) { |
3977 | 225 |
UIImage *img = [self.imagesArray objectAtIndex:i]; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
226 |
[button setBackgroundImage:img forState:UIControlStateNormal]; |
3978 | 227 |
shouldUpdateImage[i] = NO; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
228 |
} |
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 |
button.enabled = YES; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
231 |
} else { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
232 |
if (button.enabled == YES) |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
233 |
[button setBackgroundImage:nil forState:UIControlStateNormal]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
234 |
button.layer.borderColor = [[UIColor darkGrayColor] CGColor]; |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
235 |
button.enabled = NO; |
3978 | 236 |
shouldUpdateImage[i] = NO; |
3935 | 237 |
} |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
238 |
} |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
239 |
} else { |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
240 |
self.view.userInteractionEnabled = NO; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
241 |
} |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
242 |
|
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
243 |
free(loadout); |
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
244 |
loadout = NULL; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
245 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
246 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
247 |
#pragma mark - |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
248 |
#pragma mark user interaction |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
249 |
-(void) buttonPressed:(id) sender { |
3924 | 250 |
UIButton *theButton = (UIButton *)sender; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
251 |
if (self.nameLabel == nil || self.extraLabel == nil) |
3989 | 252 |
[self loadLabels]; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
253 |
|
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
254 |
self.nameLabel.text = [NSString stringWithUTF8String:HW_getWeaponNameByIndex(theButton.tag)]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
255 |
// 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
|
256 |
NSString *description = [NSString stringWithUTF8String:HW_getWeaponDescriptionByIndex(theButton.tag)]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
257 |
NSArray *elements = [description componentsSeparatedByString:@".|"]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
258 |
NSArray *purgedElements = [[elements objectAtIndex:0] componentsSeparatedByString:@"!|"]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
259 |
NSArray *morePurgedElements = [[purgedElements objectAtIndex:0] componentsSeparatedByString:@"?|"]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
260 |
self.extraLabel.text = [[[morePurgedElements objectAtIndex:0] stringByReplacingOccurrencesOfString:@"|" withString:@" "] stringByAppendingString:@"."]; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
261 |
if (theButton.currentTitle != nil) |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
262 |
self.captionLabel.text = NSLocalizedString(@"This weapon is locked",@""); |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
263 |
else |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
264 |
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
|
265 |
|
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
266 |
self.nameLabel.backgroundColor = [UIColor blackColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
267 |
self.captionLabel.backgroundColor = [UIColor blackColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
268 |
self.extraLabel.backgroundColor = [UIColor blackColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
269 |
|
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
270 |
int y, x = 8; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
271 |
// display labels on top for lower buttons |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
272 |
if (theButton.tag > 41) |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
273 |
y = 5; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
274 |
else |
5195 | 275 |
y = (HW_getNumberOfWeapons()/BTNS_PER_ROW)*40; |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
276 |
|
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
277 |
self.nameLabel.frame = CGRectMake(x, y, 200, 20); |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
278 |
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
|
279 |
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
|
280 |
} |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
281 |
|
3989 | 282 |
-(void) buttonCancelled:(id) sender { |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
283 |
self.nameLabel.text = nil; |
4032 | 284 |
self.extraLabel.text = nil; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
285 |
self.captionLabel.text = nil; |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
286 |
self.extraLabel.backgroundColor = [UIColor clearColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
287 |
self.captionLabel.backgroundColor = [UIColor clearColor]; |
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
288 |
self.nameLabel.backgroundColor = [UIColor clearColor]; |
3976 | 289 |
} |
290 |
||
291 |
-(void) buttonReleased:(id) sender { |
|
292 |
UIButton *theButton = (UIButton *)sender; |
|
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
293 |
if (self.nameLabel == nil || self.extraLabel == nil) |
3989 | 294 |
[self loadLabels]; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
295 |
|
3976 | 296 |
if (theButton.currentTitle == nil) { |
297 |
HW_setWeapon(theButton.tag); |
|
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5976
diff
changeset
|
298 |
[AudioManagerController playClickSound]; |
3984 | 299 |
if (IS_DUALHEAD() == NO) |
300 |
[self disappear]; |
|
3976 | 301 |
} |
4945
541d35d1f2e8
in the cocoa ammomenu show descriptions properly for lower weapons
koda
parents:
4853
diff
changeset
|
302 |
[self buttonCancelled:sender]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
303 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
304 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
305 |
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
306 |
NSSet *allTouches = [event allTouches]; |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
307 |
|
4032 | 308 |
if (IS_IPAD() && [touches count] == 1) { |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
309 |
self.view.layer.borderWidth = 3.5; |
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
310 |
currentPoint = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
311 |
} |
4032 | 312 |
|
3996 | 313 |
if (IS_IPAD() == NO) |
314 |
[self disappear]; |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
315 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
316 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
317 |
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
4032 | 318 |
self.view.layer.borderWidth = 1.3; |
3924 | 319 |
} |
320 |
||
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
321 |
// better window dragging implementation by |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
322 |
// 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
|
323 |
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { |
4032 | 324 |
if (IS_IPAD() && [touches count] == 1) { |
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
325 |
// Get active location upon move |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
326 |
CGPoint activePoint = [[touches anyObject] locationInView:self.view]; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
327 |
|
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
328 |
// 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
|
329 |
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
|
330 |
self.view.center.y + (activePoint.y - currentPoint.y)); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
331 |
|
4946
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
332 |
// 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
|
333 |
float midPointX = CGRectGetMidX(self.view.bounds); |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
334 |
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
|
335 |
newPoint.x = self.view.superview.bounds.size.width - midPointX; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
336 |
else if (newPoint.x < midPointX) |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
337 |
newPoint.x = midPointX; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
338 |
|
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
339 |
float midPointY = CGRectGetMidY(self.view.bounds); |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
340 |
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
|
341 |
newPoint.y = self.view.superview.bounds.size.height - midPointY; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
342 |
else if (newPoint.y < midPointY) |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
343 |
newPoint.y = midPointY; |
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
344 |
|
076767e86f2b
better ammomenu window dragging algorithm (as suggested by iphonedevelopertips)
koda
parents:
4945
diff
changeset
|
345 |
self.view.center = newPoint; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
346 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
347 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
348 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
349 |
-(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
4032 | 350 |
[self touchesEnded:touches withEvent:event]; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
351 |
} |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
352 |
|
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
353 |
#pragma mark - |
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
354 |
#pragma mark memory |
3924 | 355 |
-(void) didReceiveMemoryWarning { |
3977 | 356 |
self.imagesArray = nil; |
4082 | 357 |
if (self.isVisible == NO) |
358 |
self.buttonsArray = nil; |
|
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
359 |
self.nameLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
360 |
self.extraLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
361 |
self.captionLabel = nil; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
362 |
MSG_MEMCLEAN(); |
3924 | 363 |
[super didReceiveMemoryWarning]; |
364 |
} |
|
365 |
||
366 |
-(void) viewDidUnload { |
|
3977 | 367 |
self.imagesArray = nil; |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
368 |
self.buttonsArray = nil; |
3981
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
369 |
self.nameLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
370 |
self.extraLabel = nil; |
928e2040d34f
add name, caption and description to the new ammomenu
koda
parents:
3978
diff
changeset
|
371 |
self.captionLabel = nil; |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
372 |
free(delay); |
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
373 |
delay = NULL; |
3978 | 374 |
free(shouldUpdateImage); |
375 |
shouldUpdateImage = NULL; |
|
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
376 |
MSG_DIDUNLOAD(); |
3924 | 377 |
[super viewDidUnload]; |
378 |
} |
|
379 |
||
380 |
-(void) dealloc { |
|
5208 | 381 |
releaseAndNil(nameLabel); |
382 |
releaseAndNil(extraLabel); |
|
383 |
releaseAndNil(captionLabel); |
|
384 |
releaseAndNil(imagesArray); |
|
385 |
releaseAndNil(buttonsArray); |
|
3924 | 386 |
[super dealloc]; |
387 |
} |
|
388 |
||
3933
1a873262f5dd
polishing the cocoa ammomenu a little, still requires work
koda
parents:
3924
diff
changeset
|
389 |
@end |