project_files/HedgewarsMobile/Classes/WeaponCellView.m
author koda
Sat, 11 Feb 2012 19:24:09 +0100
changeset 6670 d57fa21781ea
parent 6078 8c0cc07731e5
child 6671 5532d5f6285c
permissions -rw-r--r--
ios weapon setting page supports rotation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     1
/*
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 3996
diff changeset
     3
 * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     4
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     8
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    12
 * GNU General Public License for more details.
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    13
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    14
 * You should have received a copy of the GNU General Public License
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    15
 * along with this program; if not, write to the Free Software
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    17
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    18
 * File created on 07/03/2010.
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    19
 */
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    20
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    21
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    22
#import "WeaponCellView.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: 6074
diff changeset
    23
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    24
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    25
@implementation WeaponCellView
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    26
@synthesize delegate, weaponName, weaponIcon, initialSli, probabilitySli, delaySli, crateSli, helpLabel,
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    27
            initialImg, probabilityImg, delayImg, crateImg, initialLab, probabilityLab, delayLab, crateLab;
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    28
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    29
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    30
    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    31
        delegate = nil;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    32
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    33
        weaponName = [[UILabel alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    34
        weaponName.backgroundColor = [UIColor clearColor];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    35
        weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    36
        weaponIcon = [[UIImageView alloc] init];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    37
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    38
        initialSli = [[UISlider alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    39
        [initialSli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    40
        [initialSli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    41
        [initialSli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    42
        initialSli.maximumValue = 9;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    43
        initialSli.minimumValue = 0;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    44
        initialSli.tag = 100;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    45
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    46
        probabilitySli = [[UISlider alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    47
        [probabilitySli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    48
        [probabilitySli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    49
        [probabilitySli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    50
        probabilitySli.maximumValue = 9;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    51
        probabilitySli.minimumValue = 0;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    52
        probabilitySli.tag = 200;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    53
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    54
        delaySli = [[UISlider alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    55
        [delaySli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    56
        [delaySli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    57
        [delaySli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    58
        delaySli.maximumValue = 9;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    59
        delaySli.minimumValue = 0;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    60
        delaySli.tag = 300;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    61
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    62
        crateSli = [[UISlider alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    63
        [crateSli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    64
        [crateSli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    65
        [crateSli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    66
        crateSli.maximumValue = 9;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    67
        crateSli.minimumValue = 0;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    68
        crateSli.tag = 400;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    69
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    70
        NSString *imgAmmoStr = [[NSString alloc] initWithFormat:@"%@/ammopic.png",ICONS_DIRECTORY()];
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    71
        initialImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgAmmoStr]];
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    72
        [imgAmmoStr release];
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    73
        NSString *imgDamageStr = [[NSString alloc] initWithFormat:@"%@/iconDamage.png",ICONS_DIRECTORY()];
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    74
        probabilityImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]];
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    75
        [imgDamageStr release];
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    76
        NSString *imgTimeStr = [[NSString alloc] initWithFormat:@"%@/iconTime.png",ICONS_DIRECTORY()];
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    77
        delayImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgTimeStr]];
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    78
        [imgTimeStr release];
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    79
        NSString *imgBoxStr = [[NSString alloc] initWithFormat:@"%@/iconBox.png",ICONS_DIRECTORY()];
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    80
        crateImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgBoxStr]];
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 4976
diff changeset
    81
        [imgBoxStr release];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    82
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    83
        initialLab = [[UILabel alloc] init];
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    84
        initialLab.backgroundColor = [UIColor clearColor];
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    85
        initialLab.textColor = [UIColor grayColor];
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
    86
        initialLab.textAlignment = UITextAlignmentCenter;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    87
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    88
        probabilityLab = [[UILabel alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    89
        probabilityLab.backgroundColor = [UIColor clearColor];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    90
        probabilityLab.textColor = [UIColor grayColor];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    91
        probabilityLab.textAlignment = UITextAlignmentCenter;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    92
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    93
        delayLab = [[UILabel alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    94
        delayLab.backgroundColor = [UIColor clearColor];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    95
        delayLab.textColor = [UIColor grayColor];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    96
        delayLab.textAlignment = UITextAlignmentCenter;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
    97
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    98
        crateLab = [[UILabel alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
    99
        crateLab.backgroundColor = [UIColor clearColor];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   100
        crateLab.textColor = [UIColor grayColor];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   101
        crateLab.textAlignment = UITextAlignmentCenter;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   102
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   103
        helpLabel = [[UILabel alloc] init];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   104
        helpLabel.backgroundColor = [UIColor clearColor];
6074
047eaed35cbb ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents: 5982
diff changeset
   105
        helpLabel.textColor = [UIColor darkGrayColor];
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   106
        helpLabel.textAlignment = UITextAlignmentRight;
6074
047eaed35cbb ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents: 5982
diff changeset
   107
        helpLabel.font = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]];
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   108
        helpLabel.adjustsFontSizeToFitWidth = YES;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   109
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   110
        [self.contentView addSubview:weaponName];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   111
        [self.contentView addSubview:weaponIcon];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   112
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   113
        [self.contentView addSubview:initialSli];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   114
        [self.contentView addSubview:probabilitySli];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   115
        [self.contentView addSubview:delaySli];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   116
        [self.contentView addSubview:crateSli];
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
   117
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   118
        [self.contentView addSubview:initialImg];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   119
        [self.contentView addSubview:probabilityImg];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   120
        [self.contentView addSubview:delayImg];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   121
        [self.contentView addSubview:crateImg];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   122
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   123
        [self.contentView addSubview:initialLab];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   124
        [self.contentView addSubview:probabilityLab];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   125
        [self.contentView addSubview:delayLab];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   126
        [self.contentView addSubview:crateLab];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   127
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   128
        [self.contentView addSubview:helpLabel];
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   129
    }
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   130
    return self;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   131
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   132
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   133
-(void) layoutSubviews {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   134
    [super layoutSubviews];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   135
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   136
    CGFloat hOffset = 80;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   137
    CGFloat hOffsetWhenLandscape = 234;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   138
    CGFloat vOffset = 40;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   139
    CGFloat vOffsetWhenPortrait = 0;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   140
    CGFloat helpLabelOffset = 0;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   141
    CGFloat helpLabelLength = 0;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   142
    CGFloat sliderLength = 150;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   143
3996
eb549fd864a5 the ios port is also iphone compatible
koda
parents: 3829
diff changeset
   144
    if (IS_IPAD()) {
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   145
        if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   146
            sliderLength = 190;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   147
            hOffsetWhenLandscape = 0;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   148
            vOffsetWhenPortrait = 80;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   149
            hOffset = 120;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   150
            helpLabelOffset = -35;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   151
            helpLabelLength = 200;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   152
        } else {
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   153
            hOffset = 145;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   154
            helpLabelOffset = 35;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   155
            helpLabelLength = 350;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   156
        }
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   157
    } else {
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   158
        helpLabelLength = 250;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   159
        hOffset = 67;
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   160
    }
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   161
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   162
    weaponIcon.frame = CGRectMake(5, 5, 32, 32);
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   163
    weaponName.frame = CGRectMake(45, 8, 200, 25);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   164
    
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   165
    helpLabel.frame = CGRectMake(200 + helpLabelOffset, 11, helpLabelLength, 20);
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   166
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   167
    // second line
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   168
    initialImg.frame = CGRectMake(hOffset - 60, vOffset, 32, 32);
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   169
    initialLab.frame = CGRectMake(hOffset - 23, vOffset, 20, 32);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   170
    initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value];
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   171
    initialSli.frame = CGRectMake(hOffset, vOffset, sliderLength, 32);
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   172
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   173
    probabilityImg.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 60, vOffset + vOffsetWhenPortrait, 32, 32);
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   174
    probabilityLab.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 23, vOffset + vOffsetWhenPortrait, 20, 32);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   175
    probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value];
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   176
    probabilitySli.frame = CGRectMake(hOffset + hOffsetWhenLandscape, vOffset + vOffsetWhenPortrait, sliderLength, 32);
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   177
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   178
    // third line
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   179
    delayImg.frame = CGRectMake(hOffset - 60, vOffset + 40, 32, 32);
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   180
    delayLab.frame = CGRectMake(hOffset - 23, vOffset + 40, 20, 32);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   181
    delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value];
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   182
    delaySli.frame = CGRectMake(hOffset, vOffset + 40, sliderLength, 32);
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   183
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   184
    crateImg.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 60, vOffset + 40 + vOffsetWhenPortrait, 32, 32);
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   185
    crateLab.frame = CGRectMake(hOffset + hOffsetWhenLandscape - 23, vOffset + 40 + vOffsetWhenPortrait, 20, 32);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   186
    crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value];
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   187
    crateSli.frame = CGRectMake(hOffset + hOffsetWhenLandscape, vOffset + 40 + vOffsetWhenPortrait, sliderLength, 32);
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   188
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   189
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   190
/*
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   191
-(void) setSelected:(BOOL)selected animated:(BOOL)animated {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   192
    [super setSelected:selected animated:animated];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   193
    // Configure the view for the selected state
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   194
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   195
*/
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   196
3643
858b20bafb6e reworked the ammunition configuration page (visually)
koda
parents: 3624
diff changeset
   197
-(void) valueChanged:(id) sender {
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
   198
    if (self.delegate != nil) {
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   199
        initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   200
        probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   201
        delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value];
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   202
        crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3667
diff changeset
   203
3644
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   204
        [delegate updateValues:[NSArray arrayWithObjects:
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   205
                                [NSNumber numberWithInt:(int)initialSli.value],
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   206
                                [NSNumber numberWithInt:(int)probabilitySli.value],
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   207
                                [NSNumber numberWithInt:(int)delaySli.value],
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   208
                                [NSNumber numberWithInt:(int)crateSli.value], nil]
3644
42c5684289ae finished ammo configuration (which is the last page missing in config \o/)
koda
parents: 3643
diff changeset
   209
                       atIndex:self.tag];
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
   210
    } else
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
   211
        DLog(@"error - delegate = nil!");
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
   212
}
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
   213
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   214
-(void) startDragging:(id) sender {
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   215
    UISlider *slider = (UISlider *)sender;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   216
    NSString *str = nil;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   217
    
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   218
    switch (slider.tag) {
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   219
        case 100:
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   220
            str = NSLocalizedString(@"Initial quantity",@"ammo selection");
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   221
            break;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   222
        case 200:
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   223
            if (IS_IPAD() && (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])))
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   224
                str = NSLocalizedString(@"Probability in crates",@"ammo selection");
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   225
            else
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   226
                str = NSLocalizedString(@"Presence probability in crates",@"ammo selection");
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   227
            break;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   228
        case 300:
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   229
            if (IS_IPAD() && (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])))
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   230
                str = NSLocalizedString(@"Weapon delay",@"ammo selection");
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   231
            else
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   232
                str = NSLocalizedString(@"Turns before this weapon becomes usable",@"ammo selection");
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   233
            break;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   234
        case 400:
6670
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   235
            if (IS_IPAD() && (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])))
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   236
                str = NSLocalizedString(@"Quantity per crate",@"ammo selection");
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   237
            else
d57fa21781ea ios weapon setting page supports rotation
koda
parents: 6078
diff changeset
   238
                str = NSLocalizedString(@"Quantity you will find in a crate",@"ammo selection");
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   239
            break;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   240
        default:
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   241
            DLog(@"Nope");
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   242
            break;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   243
    }
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   244
    self.helpLabel.text = str;
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   245
}
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   246
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   247
-(void) stopDragging:(id) sender {
3778
2e61bb50cc57 add a nice group of hogs in lobby page
koda
parents: 3766
diff changeset
   248
    self.helpLabel.text = @"";
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   249
}
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   250
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   251
-(void) dealloc {
3667
9359a70df013 use external libs more consistently
koda
parents: 3659
diff changeset
   252
    self.delegate = nil;
9359a70df013 use external libs more consistently
koda
parents: 3659
diff changeset
   253
    releaseAndNil(weaponName);
9359a70df013 use external libs more consistently
koda
parents: 3659
diff changeset
   254
    releaseAndNil(weaponIcon);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   255
    releaseAndNil(initialSli);
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   256
    releaseAndNil(probabilitySli);
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   257
    releaseAndNil(delaySli);
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   258
    releaseAndNil(crateSli);
3667
9359a70df013 use external libs more consistently
koda
parents: 3659
diff changeset
   259
    releaseAndNil(initialImg);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   260
    releaseAndNil(probabilityImg);
3667
9359a70df013 use external libs more consistently
koda
parents: 3659
diff changeset
   261
    releaseAndNil(delayImg);
9359a70df013 use external libs more consistently
koda
parents: 3659
diff changeset
   262
    releaseAndNil(crateImg);
9359a70df013 use external libs more consistently
koda
parents: 3659
diff changeset
   263
    releaseAndNil(initialLab);
3766
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   264
    releaseAndNil(probabilityLab);
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   265
    releaseAndNil(delayLab);
36b625111609 add a little explanation when modifying weaponset in ifrontend
koda
parents: 3697
diff changeset
   266
    releaseAndNil(crateLab);
3778
2e61bb50cc57 add a nice group of hogs in lobby page
koda
parents: 3766
diff changeset
   267
    releaseAndNil(helpLabel);
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   268
    [super dealloc];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   269
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   270
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   271
@end