project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m
author koda
Sat, 17 Jul 2010 06:56:39 +0200
changeset 3648 2477029463ed
parent 3644 42c5684289ae
child 3659 f8d5ac50e307
permissions -rw-r--r--
some further chat polishing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     1
//
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     2
//  SingleWeaponViewController.m
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     3
//  Hedgewars
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     4
//
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     5
//  Created by Vittorio on 19/06/10.
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     7
//
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     8
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
     9
#import "SingleWeaponViewController.h"
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    10
#import "WeaponCellView.h"
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    11
#import "CommodityFunctions.h"
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    12
#import "UIImageExtra.h"
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    13
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    14
@implementation SingleWeaponViewController
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    15
@synthesize ammoStoreImage, ammoNames;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    16
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    17
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    18
    return rotationManager(interfaceOrientation);
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    19
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    20
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    21
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    22
#pragma mark View lifecycle
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    23
-(void) viewDidLoad {
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    24
    [super viewDidLoad];
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    25
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    26
    NSArray *array = [[NSArray alloc] initWithObjects:
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    27
                      NSLocalizedString(@"Grenade",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    28
                      NSLocalizedString(@"Cluster Bomb",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    29
                      NSLocalizedString(@"Bazooka",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    30
                      NSLocalizedString(@"Homing Bee",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    31
                      NSLocalizedString(@"Shotgun",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    32
                      NSLocalizedString(@"Pick Hammer",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    33
                      NSLocalizedString(@"Skip",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    34
                      NSLocalizedString(@"Rope",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    35
                      NSLocalizedString(@"Mine",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    36
                      NSLocalizedString(@"Deagle",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    37
                      NSLocalizedString(@"Dynamite",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    38
                      NSLocalizedString(@"Fire Punch",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    39
                      NSLocalizedString(@"Slash",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    40
                      NSLocalizedString(@"Baseball bat",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    41
                      NSLocalizedString(@"Parachute",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    42
                      NSLocalizedString(@"Air Attack",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    43
                      NSLocalizedString(@"Mines Attack",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    44
                      NSLocalizedString(@"Blow Torch",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    45
                      NSLocalizedString(@"Construction",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    46
                      NSLocalizedString(@"Teleport",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    47
                      NSLocalizedString(@"Switch Hedgehog",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    48
                      NSLocalizedString(@"Mortar",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    49
                      NSLocalizedString(@"Kamikaze",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    50
                      NSLocalizedString(@"Cake",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    51
                      NSLocalizedString(@"Seduction",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    52
                      NSLocalizedString(@"Watermelon Bomb",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    53
                      NSLocalizedString(@"Hellish Hand Grenade",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    54
                      NSLocalizedString(@"Napalm Attack",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    55
                      NSLocalizedString(@"Drill Rocket",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    56
                      NSLocalizedString(@"Ballgun",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    57
                      NSLocalizedString(@"RC Plane",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    58
                      NSLocalizedString(@"Low Gravity",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    59
                      NSLocalizedString(@"Extra Damage",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    60
                      NSLocalizedString(@"Invulnerable",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    61
                      NSLocalizedString(@"Extra Time",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    62
                      NSLocalizedString(@"Laser Sight",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    63
                      NSLocalizedString(@"Vampirism",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    64
                      NSLocalizedString(@"Sniper Rifle",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    65
                      NSLocalizedString(@"Flying Saucer",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    66
                      NSLocalizedString(@"Molotov Cocktail",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    67
                      NSLocalizedString(@"Birdy",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    68
                      NSLocalizedString(@"Portable Portal Device",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    69
                      NSLocalizedString(@"Piano Attack",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    70
                      NSLocalizedString(@"Old Limburger",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    71
                      NSLocalizedString(@"Sine Gun",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    72
                      NSLocalizedString(@"Flamethrower",@""),
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    73
                      nil];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    74
    self.ammoNames = array;
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    75
    [array release];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    76
3644
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
    77
    quantity = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
    78
    probability = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
    79
    delay = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
    80
    crateness = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    81
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    82
    NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    83
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:str];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    84
    self.ammoStoreImage = img;
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    85
    [img release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    86
    
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    87
    self.tableView.rowHeight = 120;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    88
}
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    89
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    90
-(void) viewWillAppear:(BOOL) animated {
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    91
    [super viewWillAppear:animated];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    92
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    93
    NSString *ammoFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",WEAPONS_DIRECTORY(),self.title];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    94
    NSDictionary *weapon = [[NSDictionary alloc] initWithContentsOfFile:ammoFile];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    95
    [ammoFile release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    96
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    97
    const char *tmp1 = [[weapon objectForKey:@"ammostore_initialqt"] UTF8String];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    98
    const char *tmp2 = [[weapon objectForKey:@"ammostore_probability"] UTF8String];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
    99
    const char *tmp3 = [[weapon objectForKey:@"ammostore_delay"] UTF8String];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   100
    const char *tmp4 = [[weapon objectForKey:@"ammostore_crate"] UTF8String];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   101
    [weapon release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   102
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   103
    // if the new weaponset is diffrent from the older we need to update it replacing
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   104
    // the missing ammos with 0 quantity
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   105
    int oldlen = strlen(tmp1);
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   106
    for (int i = 0; i < oldlen; i++) {
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   107
        quantity[i] = tmp1[i];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   108
        probability[i] = tmp2[i];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   109
        delay[i] = tmp3[i];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   110
        crateness[i] = tmp4[i];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   111
    }
3623
f14db208f2fa graphics applied and fixes here and there
koda
parents: 3621
diff changeset
   112
    for (int i = oldlen; i < CURRENT_AMMOSIZE; i++) {
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   113
        quantity[i] = '0';
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   114
        probability[i] = '0';
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   115
        delay[i] = '0';
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   116
        crateness[i] = '0';
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   117
    }
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   118
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   119
    [self.tableView reloadData];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   120
}
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   121
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   122
-(void) viewWillDisappear:(BOOL) animated {
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   123
    [super viewWillDisappear:animated];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   124
    
3644
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   125
    quantity[CURRENT_AMMOSIZE] = '\0';
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   126
    probability[CURRENT_AMMOSIZE] = '\0';
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   127
    delay[CURRENT_AMMOSIZE] = '\0';
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   128
    crateness[CURRENT_AMMOSIZE] = '\0';
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   129
    
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   130
    NSString *quantityStr = [NSString stringWithUTF8String:quantity];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   131
    NSString *probabilityStr = [NSString stringWithUTF8String:probability];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   132
    NSString *delayStr = [NSString stringWithUTF8String:delay];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   133
    NSString *cratenessStr = [NSString stringWithUTF8String:crateness];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   134
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   135
    NSDictionary *weapon = [[NSDictionary alloc] initWithObjectsAndKeys:
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   136
                            [NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   137
                            quantityStr,@"ammostore_initialqt",
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   138
                            probabilityStr,@"ammostore_probability",
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   139
                            delayStr,@"ammostore_delay",
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   140
                            cratenessStr,@"ammostore_crate", nil];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   141
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   142
    NSString *ammoFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",WEAPONS_DIRECTORY(),self.title];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   143
    [weapon writeToFile:ammoFile atomically:YES];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   144
    [ammoFile release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   145
    [weapon release];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   146
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   147
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   148
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   149
#pragma mark Table view data source
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   150
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   151
    return 1;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   152
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   153
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   154
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3623
f14db208f2fa graphics applied and fixes here and there
koda
parents: 3621
diff changeset
   155
    return CURRENT_AMMOSIZE;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   156
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   157
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   158
// Customize the appearance of table view cells.
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   159
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   160
    static NSString *CellIdentifier = @"Cell";
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   161
    NSInteger row = [indexPath row];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   162
    
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   163
    WeaponCellView *cell = (WeaponCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   164
    if (cell == nil) {
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   165
        cell = [[[WeaponCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
3624
304c6d32383a button to open ammomenu
koda
parents: 3623
diff changeset
   166
        cell.delegate = self;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   167
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   168
    
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   169
    int x = ((row*32)/1024)*32;
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   170
    int y = (row*32)%1024;
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   171
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   172
    UIImage *img = [[self.ammoStoreImage cutAt:CGRectMake(x, y, 32, 32)] makeRoundCornersOfSize:CGSizeMake(7, 7)];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   173
    cell.weaponIcon.image = img;
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   174
    cell.weaponName.text = [ammoNames objectAtIndex:row];
3624
304c6d32383a button to open ammomenu
koda
parents: 3623
diff changeset
   175
    cell.tag = row;
304c6d32383a button to open ammomenu
koda
parents: 3623
diff changeset
   176
    
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   177
    [cell.initialQt setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO];
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   178
    [cell.probabilityQt setValue:[[NSString stringWithFormat:@"%c", probability[row]] intValue] animated:NO];
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   179
    [cell.delayQt setValue:[[NSString stringWithFormat:@"%c", delay[row]] intValue] animated:NO];
3644
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   180
    [cell.crateQt setValue:[[NSString stringWithFormat:@"%c", crateness[row]] intValue] animated:NO];
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   181
    
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   182
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   183
    return cell;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   184
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   185
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   186
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   187
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   188
#pragma mark Table view delegate
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   189
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   190
    // Navigation logic may go here. Create and push another view controller.
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   191
    /*
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   192
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   193
     // ...
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   194
     // Pass the selected object to the new view controller.
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   195
     [self.navigationController pushViewController:detailViewController animated:YES];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   196
     [detailViewController release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   197
     */
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   198
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   199
3624
304c6d32383a button to open ammomenu
koda
parents: 3623
diff changeset
   200
#pragma mark -
304c6d32383a button to open ammomenu
koda
parents: 3623
diff changeset
   201
#pragma mark WeaponButtonControllerDelegate
3644
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   202
-(void) updateValues:(NSArray *)withArray atIndex:(NSInteger) index {
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   203
    quantity[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:0] intValue]] characterAtIndex:0];
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   204
    probability[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:1] intValue]] characterAtIndex:0];
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   205
    delay[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:2] intValue]] characterAtIndex:0];
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   206
    crateness[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:3] intValue]] characterAtIndex:0];
3624
304c6d32383a button to open ammomenu
koda
parents: 3623
diff changeset
   207
}
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   208
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   209
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   210
#pragma mark Memory management
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   211
-(void) didReceiveMemoryWarning {
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   212
    // Releases the view if it doesn't have a superview.
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   213
    [super didReceiveMemoryWarning];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   214
    // Relinquish ownership any cached data, images, etc that aren't in use.
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   215
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   216
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   217
-(void) viewDidUnload {
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   218
    free(quantity);
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   219
    free(probability);
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   220
    free(delay);
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   221
    free(crateness);
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   222
    [super viewDidUnload];
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   223
    MSG_DIDUNLOAD();
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   224
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   225
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   226
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents: 3547
diff changeset
   227
-(void) dealloc {
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   228
    [super dealloc];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   229
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   230
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   231
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   232
@end
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   233