project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m
author koda
Sun, 27 Jun 2010 16:44:24 +0200
changeset 3573 c84067629035
parent 3547 02875b1145b7
child 3574 78fc6e61570b
permissions -rw-r--r--
complete configuration for schemes added my stuff to hgignore
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
//  SingleSchemeViewController.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 23/05/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 "SingleSchemeViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    10
#import <QuartzCore/QuartzCore.h>
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    11
#import "CommodityFunctions.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    12
#import "UIImageExtra.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    13
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    14
#define LABEL_TAG  12345
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    15
#define SLIDER_TAG 54321
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    16
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    17
@implementation SingleSchemeViewController
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    18
@synthesize textFieldBeingEdited, schemeArray, basicSettingList, gameModifierArray;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    19
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    20
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    21
    return rotationManager(interfaceOrientation);
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    22
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    23
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    24
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    25
#pragma mark View lifecycle
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    26
-(void) viewDidLoad {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    27
    [super viewDidLoad];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    28
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    29
    NSArray *mods = [[NSArray alloc] initWithObjects:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    30
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Fort Mode",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    31
                      NSLocalizedString(@"Defend your fort and destroy the opponents (two team colours max)",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    32
                      @"Forts",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    33
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Divide Team",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    34
                      NSLocalizedString(@"Teams will start on opposite sides of the terrain (two team colours max)",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    35
                      @"TeamsDivide",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    36
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Solid Land",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    37
                      NSLocalizedString(@"Land can not be destroyed",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    38
                      @"Solid",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    39
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Border",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    40
                      NSLocalizedString(@"Add an indestructable border around the terrain",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    41
                      @"Border",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    42
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Low Gravity",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    43
                      NSLocalizedString(@"Lower gravity",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    44
                      @"LowGravity",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    45
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Laser Sight",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    46
                      NSLocalizedString(@"Assisted aiming with laser sight",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    47
                      @"LaserSight",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    48
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Invulnerable",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    49
                      NSLocalizedString(@"All hogs have a personal forcefield",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    50
                      @"Invulnerable",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    51
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Mines",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    52
                      NSLocalizedString(@"Enable random mines",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    53
                      @"Mines",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    54
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Vampirism Mode",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    55
                      NSLocalizedString(@"Gain 80% of the damage you do back in health",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    56
                      @"Vampiric",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    57
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Karma Mode",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    58
                      NSLocalizedString(@"Share your opponents pain, share their damage",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    59
                      @"Karma",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    60
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Artillery Mode",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    61
                      NSLocalizedString(@"Your hogs are unable to move, test your aim",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    62
                      @"Artillery",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    63
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Random Order",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    64
                      NSLocalizedString(@"Order of play is random instead of in room order",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    65
                      @"RandomOrder",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    66
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"King Mode",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    67
                      NSLocalizedString(@"Play with a King. If he dies, your side loses",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    68
                      @"King",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    69
                     [NSDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(@"Place Hedgehogs",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    70
                      NSLocalizedString(@"Take turns placing your hedgehogs pre-game",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    71
                      @"PlaceHog",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    72
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Clan Shares Ammo",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    73
                      NSLocalizedString(@"Ammo is shared between all clan teams",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    74
                      @"SharedAmmo",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    75
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Girders",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    76
                      NSLocalizedString(@"Disable girders when generating random maps",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    77
                      @"DisableGirders",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    78
                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Land Objects",@""),@"title",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    79
                      NSLocalizedString(@"Disable land objects when generating maps",@""),@"description",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    80
                      @"DisableLandObjects",@"image",nil],
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    81
                     nil];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    82
    self.gameModifierArray = mods;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    83
    [mods release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    84
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    85
    NSArray *basicSettings = [[NSArray alloc] initWithObjects:
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    86
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Damage Modifier",@""),@"title",@"Damage",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    87
                               [NSNumber numberWithInt:100],@"default",[NSNumber numberWithInt:10],@"min",[NSNumber numberWithInt:300],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    88
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Turn Time",@""),@"title",@"Time",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    89
                               [NSNumber numberWithInt:45],@"default",[NSNumber numberWithInt:1],@"min",[NSNumber numberWithInt:99],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    90
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Initial Health",@""),@"title",@"Health",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    91
                               [NSNumber numberWithInt:100],@"default",[NSNumber numberWithInt:50],@"min",[NSNumber numberWithInt:200],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    92
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Sudden Death Timeout",@""),@"title",@"SuddenDeath",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    93
                               [NSNumber numberWithInt:15],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:50],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    94
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Crate Drops",@""),@"title",@"Box",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    95
                               [NSNumber numberWithInt:5],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:9],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    96
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Time",@""),@"title",@"Time",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    97
                               [NSNumber numberWithInt:3],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:3],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    98
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Number",@""),@"title",@"Mine",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
    99
                               [NSNumber numberWithInt:4],@"default",[NSNumber numberWithInt:1],@"min",[NSNumber numberWithInt:80],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   100
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Dud Mines Probability",@""),@"title",@"Dud",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   101
                               [NSNumber numberWithInt:0],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:100],@"max",nil],
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   102
                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Explosives",@""),@"title",@"Damage",@"image",
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   103
                               [NSNumber numberWithInt:2],@"default",[NSNumber numberWithInt:0],@"min",[NSNumber numberWithInt:40],@"max",nil],
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   104
                              nil];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   105
    self.basicSettingList = basicSettings;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   106
    [basicSettings release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   107
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   108
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   109
// load from file
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   110
-(void) viewWillAppear:(BOOL) animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   111
    [super viewWillAppear:animated];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   112
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   113
    NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   114
    NSMutableArray *scheme = [[NSMutableArray alloc] initWithContentsOfFile:schemeFile];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   115
    self.schemeArray = scheme;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   116
    [scheme release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   117
    [schemeFile release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   118
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   119
    [self.tableView reloadData];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   120
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   121
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   122
// save to file
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   123
-(void) viewWillDisappear:(BOOL) animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   124
    [super viewWillDisappear:animated];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   125
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   126
    NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   127
    [self.schemeArray writeToFile:schemeFile atomically:YES];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   128
    [schemeFile release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   129
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   130
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   131
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   132
#pragma mark textfield methods
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   133
-(void) cancel:(id) sender {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   134
    if (textFieldBeingEdited != nil)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   135
        [self.textFieldBeingEdited resignFirstResponder];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   136
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   137
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   138
// set the new value
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   139
-(BOOL) save:(id) sender {    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   140
    if (textFieldBeingEdited != nil) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   141
        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] error:NULL];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   142
        self.title = self.textFieldBeingEdited.text;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   143
        [self.schemeArray writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] atomically:YES];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   144
        [self.textFieldBeingEdited resignFirstResponder];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   145
        return YES;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   146
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   147
    return NO;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   148
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   149
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   150
// the textfield is being modified, update the navigation controller
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   151
-(void) textFieldDidBeginEditing:(UITextField *)aTextField{   
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   152
    self.textFieldBeingEdited = aTextField;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   153
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   154
    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",@"from schemes table")
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   155
                                                                     style:UIBarButtonItemStylePlain
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   156
                                                                    target:self
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   157
                                                                    action:@selector(cancel:)];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   158
    self.navigationItem.leftBarButtonItem = cancelButton;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   159
    [cancelButton release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   160
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   161
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save",@"from schemes table")
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   162
                                                                     style:UIBarButtonItemStyleDone
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   163
                                                                    target:self
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   164
                                                                    action:@selector(save:)];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   165
    self.navigationItem.rightBarButtonItem = saveButton;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   166
    [saveButton release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   167
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   168
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   169
// the textfield has been modified, check for empty strings and restore original navigation bar
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   170
-(void) textFieldDidEndEditing:(UITextField *)aTextField{
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   171
    if ([textFieldBeingEdited.text length] == 0) 
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   172
        textFieldBeingEdited.text = [NSString stringWithFormat:@"New Scheme"];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   173
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   174
    self.textFieldBeingEdited = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   175
    self.navigationItem.rightBarButtonItem = self.navigationItem.backBarButtonItem;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   176
    self.navigationItem.leftBarButtonItem = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   177
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   178
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   179
// limit the size of the field to 64 characters like in original frontend
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   180
-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   181
    int limit = 64;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   182
    return !([textField.text length] > limit && [string length] > range.length);
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   183
}
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
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   187
#pragma mark Table view data source
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   188
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   189
    return 3;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   190
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   191
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   192
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   193
    switch (section) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   194
        case 0:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   195
            return 1;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   196
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   197
        case 1:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   198
            return [self.basicSettingList count];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   199
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   200
        case 2:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   201
            return [self.gameModifierArray count];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   202
        default:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   203
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   204
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   205
    return 0;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   206
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   207
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   208
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   209
    static NSString *CellIdentifier0 = @"Cell0";
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   210
    static NSString *CellIdentifier1 = @"Cell1";
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   211
    static NSString *CellIdentifier2 = @"Cell2";
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   212
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   213
    UITableViewCell *cell = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   214
    NSInteger row = [indexPath row];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   215
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   216
    switch ([indexPath section]) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   217
        case 0:
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   218
            cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   219
            if (cell == nil) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   220
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   221
                                               reuseIdentifier:CellIdentifier0] autorelease];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   222
                // create a uitextfield for each row, expand it to take the maximum size
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   223
                UITextField *aTextField = [[UITextField alloc] 
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   224
                                           initWithFrame:CGRectMake(5, 12, (cell.frame.size.width + cell.frame.size.width/3) - 42, 25)];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   225
                aTextField.clearsOnBeginEditing = NO;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   226
                aTextField.returnKeyType = UIReturnKeyDone;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   227
                aTextField.adjustsFontSizeToFitWidth = YES;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   228
                aTextField.delegate = self;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   229
                aTextField.tag = [indexPath row];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   230
                aTextField.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   231
                aTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   232
                [aTextField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   233
                [cell.contentView addSubview:aTextField];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   234
                [aTextField release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   235
            }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   236
            
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   237
            for (UIView *oneView in cell.contentView.subviews) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   238
                if ([oneView isMemberOfClass:[UITextField class]]) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   239
                    // we find the uitextfied and we'll use its tag to understand which one is being edited
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   240
                    UITextField *textFieldFound = (UITextField *)oneView;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   241
                    textFieldFound.text = self.title;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   242
                }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   243
            }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   244
            cell.detailTextLabel.text = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   245
            cell.imageView.image = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   246
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   247
        case 1:
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   248
            cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   249
            NSDictionary *detail = [self.basicSettingList objectAtIndex:row];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   250
            // need to offset this section (see format in CommodityFunctions.m and above)
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   251
            NSInteger gmSize = [self.gameModifierArray count];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   252
            if (cell == nil) {
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   253
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   254
                                               reuseIdentifier:CellIdentifier1] autorelease];
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   255
                UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(260, 12, 150, 23)];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   256
                slider.maximumValue = [[detail objectForKey:@"max"] floatValue];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   257
                slider.minimumValue = [[detail objectForKey:@"min"] floatValue];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   258
                slider.tag = row+gmSize;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   259
                [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   260
                [cell.contentView addSubview:slider];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   261
                [slider release];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   262
                
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   263
                UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   264
                label.tag = LABEL_TAG;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   265
                label.backgroundColor = [UIColor clearColor];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   266
                label.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   267
                [cell.contentView addSubview:label];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   268
                [label release];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   269
            }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   270
            
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   271
            UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   272
            cell.imageView.image = [img scaleToSize:CGSizeMake(40, 40)];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   273
            [img release];
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   274
            
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   275
            UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   276
            cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   277
            
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   278
            UISlider *cellSlider = (UISlider *)[cell.contentView viewWithTag:row+gmSize];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   279
            cellSlider.value = [[self.schemeArray objectAtIndex:row+gmSize] floatValue];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   280
            
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   281
            // forced to use this weird format otherwise the label disappears when size of the text is bigger than the original
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   282
            cell.detailTextLabel.text = [NSString stringWithFormat:@"%0.3d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   283
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   284
        case 2:
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   285
            cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier2];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   286
            if (cell == nil) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   287
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   288
                                               reuseIdentifier:CellIdentifier2] autorelease];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   289
                UISwitch *onOff = [[UISwitch alloc] init];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   290
                onOff.tag = row;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   291
                [onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   292
                cell.accessoryView = onOff;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   293
                [onOff release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   294
            }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   295
            
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   296
            UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   297
            cell.imageView.image = image;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   298
            [image release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   299
            [cell.imageView.layer setCornerRadius:7.0f];
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   300
            [cell.imageView.layer setBorderWidth:1];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   301
            [cell.imageView.layer setMasksToBounds:YES];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   302
            cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   303
            cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   304
            [(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   305
        }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   306
    
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   307
    return cell;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   308
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   309
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   310
-(void) toggleSwitch:(id) sender {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   311
    UISwitch *theSwitch = (UISwitch *)sender;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   312
    [self.schemeArray replaceObjectAtIndex:theSwitch.tag withObject:[NSNumber numberWithBool:theSwitch.on]];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   313
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   314
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   315
-(void) sliderChanged:(id) sender {
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   316
    // need to offset this section (see format in CommodityFunctions.m and above)
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   317
    NSInteger gmSize = [self.gameModifierArray count];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   318
    // the slider that changed is sent as object
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   319
    UISlider *theSlider = (UISlider *)sender;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   320
    // create the indexPath of the row of the slider
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   321
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:theSlider.tag-gmSize inSection:1];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   322
    // get its cell
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   323
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   324
    // grab the associated label
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   325
    UILabel *label = (UILabel *)cell.detailTextLabel;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   326
    // modify it
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   327
    label.text = [NSString stringWithFormat:@"%0.3d",(int)theSlider.value];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   328
    // save changes in the main array (remember that you need to offset it)
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   329
    [self.schemeArray replaceObjectAtIndex:theSlider.tag withObject:[NSNumber numberWithInt:(int)theSlider.value]];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   330
    NSLog(@"%@",self.schemeArray);
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   331
}
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   332
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   333
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   334
#pragma mark Table view delegate
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   335
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   336
    UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   337
    UISwitch *sw = nil;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   338
    UISlider *cellSlider = nil;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   339
    
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   340
    switch ([indexPath section]) {
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   341
        case 0:
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   342
            for (UIView *oneView in cell.contentView.subviews) {
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   343
                if ([oneView isMemberOfClass:[UITextField class]]) {
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   344
                    textFieldBeingEdited = (UITextField *)oneView;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   345
                    [textFieldBeingEdited becomeFirstResponder];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   346
                }
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   347
            }
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   348
            break;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   349
        case 1:
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   350
            cellSlider = (UISlider *)[cell.contentView viewWithTag:[indexPath row]+[self.gameModifierArray count]];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   351
            [cellSlider setValue:[[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] floatValue] animated:YES];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   352
            [self sliderChanged:cellSlider];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   353
            //cell.detailTextLabel.text = [[[self.basicSettingList objectAtIndex:[indexPath row]] objectForKey:@"default"] stringValue];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   354
            break;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   355
        case 2:
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   356
            sw = (UISwitch *)cell.accessoryView;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   357
            [sw setOn:!sw.on animated:YES];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   358
            [self toggleSwitch:sw];
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   359
            break;
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   360
        default:
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   361
            break;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   362
    }
3573
c84067629035 complete configuration for schemes
koda
parents: 3547
diff changeset
   363
    
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   364
    [aTableView deselectRowAtIndexPath:indexPath animated:YES];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   365
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   366
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   367
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   368
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   369
#pragma mark Memory management
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   370
-(void) didReceiveMemoryWarning {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   371
    [super didReceiveMemoryWarning];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   372
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   373
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   374
-(void) viewDidUnload {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   375
    self.textFieldBeingEdited = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   376
    self.schemeArray = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   377
    self.basicSettingList = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   378
    self.gameModifierArray = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   379
    [super viewDidUnload];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   380
    MSG_DIDUNLOAD();
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   381
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   382
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   383
-(void) dealloc {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   384
    [textFieldBeingEdited release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   385
    [schemeArray release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   386
    [basicSettingList release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   387
    [gameModifierArray release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   388
    [super dealloc];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   389
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   390
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   391
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   392
@end
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   393