project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m
branchhedgeroid
changeset 6224 42b256eca362
parent 6209 074ab6ebcb3e
child 6657 e1125559359f
equal deleted inserted replaced
6055:88cfcd9161d3 6224:42b256eca362
    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 "CommodityFunctions.h"
    23 
    24 #import "UIImageExtra.h"
       
    25 #import "PascalImports.h"
       
    26 
    24 
    27 @implementation SingleWeaponViewController
    25 @implementation SingleWeaponViewController
    28 @synthesize weaponName, description, ammoStoreImage;
    26 @synthesize weaponName, description, ammoStoreImage;
    29 
    27 
    30 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    28 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
   163         if (weaponCell == nil) {
   161         if (weaponCell == nil) {
   164             weaponCell = [[[WeaponCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
   162             weaponCell = [[[WeaponCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
   165             weaponCell.delegate = self;
   163             weaponCell.delegate = self;
   166         }
   164         }
   167 
   165 
   168         int size = 32 * getScreenScale();
   166         CGFloat theScale = [[UIScreen mainScreen] safeScale];
   169         int corners = 8 * getScreenScale();
   167         int size = 32 * theScale;
   170         int x = ((row*size)/(int)(self.ammoStoreImage.size.height*getScreenScale()))*size;
   168         int corners = 8 * theScale;
   171         int y = (row*size)%(int)(self.ammoStoreImage.size.height*getScreenScale());
   169         int x = ((row*size)/(int)(self.ammoStoreImage.size.height * theScale))*size;
       
   170         int y = (row*size)%(int)(self.ammoStoreImage.size.height * theScale);
   172 
   171 
   173         UIImage *img = [[self.ammoStoreImage cutAt:CGRectMake(x, y, size, size)] makeRoundCornersOfSize:CGSizeMake(corners, corners)];
   172         UIImage *img = [[self.ammoStoreImage cutAt:CGRectMake(x, y, size, size)] makeRoundCornersOfSize:CGSizeMake(corners, corners)];
   174         weaponCell.weaponIcon.image = img;
   173         weaponCell.weaponIcon.image = img;
   175         weaponCell.weaponName.text = [NSString stringWithUTF8String:HW_getWeaponNameByIndex(row)];
   174         weaponCell.weaponName.text = [NSString stringWithUTF8String:HW_getWeaponNameByIndex(row)];
   176         weaponCell.tag = row;
   175         weaponCell.tag = row;