18 * File created on 19/06/2010. |
18 * File created on 19/06/2010. |
19 */ |
19 */ |
20 |
20 |
21 |
21 |
22 #import "SingleWeaponViewController.h" |
22 #import "SingleWeaponViewController.h" |
23 #import "WeaponCellView.h" |
|
24 #import "CommodityFunctions.h" |
23 #import "CommodityFunctions.h" |
25 #import "UIImageExtra.h" |
24 #import "UIImageExtra.h" |
|
25 #import "PascalImports.h" |
26 |
26 |
27 @implementation SingleWeaponViewController |
27 @implementation SingleWeaponViewController |
28 @synthesize weaponName, description, ammoStoreImage, ammoNames; |
28 @synthesize weaponName, description, ammoStoreImage; |
29 |
29 |
30 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
30 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
31 return rotationManager(interfaceOrientation); |
31 return rotationManager(interfaceOrientation); |
32 } |
32 } |
33 |
33 |
34 #pragma mark - |
34 #pragma mark - |
35 #pragma mark View lifecycle |
35 #pragma mark View lifecycle |
36 -(void) viewDidLoad { |
36 -(void) viewDidLoad { |
37 [super viewDidLoad]; |
37 [super viewDidLoad]; |
38 |
38 |
39 // also increment CURRENT_AMMOSIZE in CommodityFunctions.h |
39 NSString *trFilePath = [NSString stringWithFormat:@"%@/en.txt",LOCALE_DIRECTORY()]; |
40 NSArray *array = [[NSArray alloc] initWithObjects: |
40 // fill the data structure that we are going to read |
41 NSLocalizedString(@"Grenade",@""), |
41 LoadLocaleWrapper([trFilePath UTF8String]); |
42 NSLocalizedString(@"Cluster Bomb",@""), |
42 |
43 NSLocalizedString(@"Bazooka",@""), |
43 quantity = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1)); |
44 NSLocalizedString(@"Homing Bee",@""), |
44 probability = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1)); |
45 NSLocalizedString(@"Shotgun",@""), |
45 delay = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1)); |
46 NSLocalizedString(@"Pick Hammer",@""), |
46 crateness = (char *)malloc(sizeof(char)*(HW_getNumberOfWeapons()+1)); |
47 NSLocalizedString(@"Skip",@""), |
|
48 NSLocalizedString(@"Rope",@""), |
|
49 NSLocalizedString(@"Mine",@""), |
|
50 NSLocalizedString(@"Deagle",@""), |
|
51 NSLocalizedString(@"Dynamite",@""), |
|
52 NSLocalizedString(@"Fire Punch",@""), |
|
53 NSLocalizedString(@"Slash",@""), |
|
54 NSLocalizedString(@"Baseball bat",@""), |
|
55 NSLocalizedString(@"Parachute",@""), |
|
56 NSLocalizedString(@"Air Attack",@""), |
|
57 NSLocalizedString(@"Mines Attack",@""), |
|
58 NSLocalizedString(@"Blow Torch",@""), |
|
59 NSLocalizedString(@"Construction",@""), |
|
60 NSLocalizedString(@"Teleport",@""), |
|
61 NSLocalizedString(@"Switch Hedgehog",@""), |
|
62 NSLocalizedString(@"Mortar",@""), |
|
63 NSLocalizedString(@"Kamikaze",@""), |
|
64 NSLocalizedString(@"Cake",@""), |
|
65 NSLocalizedString(@"Seduction",@""), |
|
66 NSLocalizedString(@"Watermelon Bomb",@""), |
|
67 NSLocalizedString(@"Hellish Hand Grenade",@""), |
|
68 NSLocalizedString(@"Napalm Attack",@""), |
|
69 NSLocalizedString(@"Drill Rocket",@""), |
|
70 NSLocalizedString(@"Ballgun",@""), |
|
71 NSLocalizedString(@"RC Plane",@""), |
|
72 NSLocalizedString(@"Low Gravity",@""), |
|
73 NSLocalizedString(@"Extra Damage",@""), |
|
74 NSLocalizedString(@"Invulnerable",@""), |
|
75 NSLocalizedString(@"Extra Time",@""), |
|
76 NSLocalizedString(@"Laser Sight",@""), |
|
77 NSLocalizedString(@"Vampirism",@""), |
|
78 NSLocalizedString(@"Sniper Rifle",@""), |
|
79 NSLocalizedString(@"Flying Saucer",@""), |
|
80 NSLocalizedString(@"Molotov Cocktail",@""), |
|
81 NSLocalizedString(@"Birdy",@""), |
|
82 NSLocalizedString(@"Portable Portal Device",@""), |
|
83 NSLocalizedString(@"Piano Attack",@""), |
|
84 NSLocalizedString(@"Old Limburger",@""), |
|
85 NSLocalizedString(@"Sine Gun",@""), |
|
86 NSLocalizedString(@"Flamethrower",@""), |
|
87 NSLocalizedString(@"Sticky Mine",@""), |
|
88 NSLocalizedString(@"Hammer",@""), |
|
89 nil]; |
|
90 self.ammoNames = array; |
|
91 [array release]; |
|
92 |
|
93 quantity = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1)); |
|
94 probability = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1)); |
|
95 delay = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1)); |
|
96 crateness = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1)); |
|
97 |
47 |
98 NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()]; |
48 NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()]; |
99 UIImage *img = [[UIImage alloc] initWithContentsOfFile:str]; |
49 UIImage *img = [[UIImage alloc] initWithContentsOfFile:str]; |
100 self.ammoStoreImage = img; |
50 self.ammoStoreImage = img; |
101 [img release]; |
51 [img release]; |
140 [super viewWillDisappear:animated]; |
90 [super viewWillDisappear:animated]; |
141 [self saveAmmos]; |
91 [self saveAmmos]; |
142 } |
92 } |
143 |
93 |
144 -(void) saveAmmos { |
94 -(void) saveAmmos { |
145 quantity[CURRENT_AMMOSIZE] = '\0'; |
95 quantity[HW_getNumberOfWeapons()] = '\0'; |
146 probability[CURRENT_AMMOSIZE] = '\0'; |
96 probability[HW_getNumberOfWeapons()] = '\0'; |
147 delay[CURRENT_AMMOSIZE] = '\0'; |
97 delay[HW_getNumberOfWeapons()] = '\0'; |
148 crateness[CURRENT_AMMOSIZE] = '\0'; |
98 crateness[HW_getNumberOfWeapons()] = '\0'; |
149 |
99 |
150 NSString *quantityStr = [NSString stringWithUTF8String:quantity]; |
100 NSString *quantityStr = [NSString stringWithUTF8String:quantity]; |
151 NSString *probabilityStr = [NSString stringWithUTF8String:probability]; |
101 NSString *probabilityStr = [NSString stringWithUTF8String:probability]; |
152 NSString *delayStr = [NSString stringWithUTF8String:delay]; |
102 NSString *delayStr = [NSString stringWithUTF8String:delay]; |
153 NSString *cratenessStr = [NSString stringWithUTF8String:crateness]; |
103 NSString *cratenessStr = [NSString stringWithUTF8String:crateness]; |
154 |
104 |
155 NSDictionary *weapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
105 NSDictionary *weapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
156 [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
106 [NSNumber numberWithInt:HW_getNumberOfWeapons()],@"version", |
157 quantityStr,@"ammostore_initialqt", |
107 quantityStr,@"ammostore_initialqt", |
158 probabilityStr,@"ammostore_probability", |
108 probabilityStr,@"ammostore_probability", |
159 delayStr,@"ammostore_delay", |
109 delayStr,@"ammostore_delay", |
160 cratenessStr,@"ammostore_crate", |
110 cratenessStr,@"ammostore_crate", |
161 self.description,@"description", |
111 self.description,@"description", |
218 int x = ((row*32)/(int)self.ammoStoreImage.size.height)*32; |
168 int x = ((row*32)/(int)self.ammoStoreImage.size.height)*32; |
219 int y = (row*32)%(int)self.ammoStoreImage.size.height; |
169 int y = (row*32)%(int)self.ammoStoreImage.size.height; |
220 |
170 |
221 UIImage *img = [[self.ammoStoreImage cutAt:CGRectMake(x, y, 32, 32)] makeRoundCornersOfSize:CGSizeMake(7, 7)]; |
171 UIImage *img = [[self.ammoStoreImage cutAt:CGRectMake(x, y, 32, 32)] makeRoundCornersOfSize:CGSizeMake(7, 7)]; |
222 weaponCell.weaponIcon.image = img; |
172 weaponCell.weaponIcon.image = img; |
223 weaponCell.weaponName.text = [ammoNames objectAtIndex:row]; |
173 weaponCell.weaponName.text = [NSString stringWithUTF8String:HW_getWeaponNameByIndex(row)]; |
224 weaponCell.tag = row; |
174 weaponCell.tag = row; |
225 |
175 |
226 [weaponCell.initialSli setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO]; |
176 [weaponCell.initialSli setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO]; |
227 [weaponCell.probabilitySli setValue:[[NSString stringWithFormat:@"%c", probability[row]] intValue] animated:NO]; |
177 [weaponCell.probabilitySli setValue:[[NSString stringWithFormat:@"%c", probability[row]] intValue] animated:NO]; |
228 [weaponCell.delaySli setValue:[[NSString stringWithFormat:@"%c", delay[row]] intValue] animated:NO]; |
178 [weaponCell.delaySli setValue:[[NSString stringWithFormat:@"%c", delay[row]] intValue] animated:NO]; |