project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m
author antonc27 <antonc27@mail.ru>
Sun, 20 Sep 2015 01:48:18 +0200
branchios-revival
changeset 11186 ee8e2494eaee
parent 10108 c68cf030eded
child 11229 b49dfdf628f6
permissions -rw-r--r--
- 'One of everything' ammo set added to iOS front-end
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
     1
/*
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
6700
e04da46ee43c the most important commit of the year
koda
parents: 6624
diff changeset
     3
 * Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com>
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
     4
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
81db3c85784b headers ftw, also right project file
koda
parents: 3803
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: 3803
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
     8
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    12
 * GNU General Public License for more details.
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    13
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    14
 * You should have received a copy of the GNU General Public License
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 8441
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    17
 */
81db3c85784b headers ftw, also right project file
koda
parents: 3803
diff changeset
    18
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    19
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    20
#import "GeneralSettingsViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    21
6000
dbcebcd3d79f ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents: 5700
diff changeset
    22
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    23
@implementation GeneralSettingsViewController
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    24
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    25
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    26
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    27
    return rotationManager(interfaceOrientation);
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    28
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    29
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    30
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    31
#pragma mark View Lifecycle
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    32
-(void) viewDidLoad {
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: 6000
diff changeset
    33
    self.navigationItem.title = @"Edit game options";
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    34
    [super viewDidLoad];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    35
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    36
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    37
-(void) viewWillAppear:(BOOL)animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    38
    [self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    39
    [super viewWillAppear:animated];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    40
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    41
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    42
-(void) viewWillDisappear:(BOOL)animated {
5224
6e8fbbfb0de5 muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents: 5207
diff changeset
    43
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
6e8fbbfb0de5 muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents: 5207
diff changeset
    44
    [userDefaults synchronize];
6e8fbbfb0de5 muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents: 5207
diff changeset
    45
    if ([[userDefaults objectForKey:@"music"] boolValue] == NO)
6869
a187c280dd3d ios: convert audio operation from class to instance, plays better with memory
koda
parents: 6832
diff changeset
    46
        [[AudioManagerController mainManager] stopBackgroundMusic];
5224
6e8fbbfb0de5 muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents: 5207
diff changeset
    47
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3663
diff changeset
    48
    [super viewWillDisappear:animated];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    49
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    50
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    51
#pragma mark -
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    52
-(void) switchValueChanged:(id) sender {
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    53
    UISwitch *theSwitch = (UISwitch *)sender;
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
    54
    NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3663
diff changeset
    55
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    56
    switch (theSwitch.tag) {
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    57
        case 10:    //soundSwitch
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
    58
            [settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"sound"];
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    59
            break;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    60
        case 20:    //musicSwitch
8426
4b66e60c9967 update sound preferences in ios settings ('sound' means 'sound effects' instead of 'sound enabled')
koda
parents: 6869
diff changeset
    61
            [settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"music"];
5224
6e8fbbfb0de5 muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents: 5207
diff changeset
    62
            if (theSwitch.on)
6869
a187c280dd3d ios: convert audio operation from class to instance, plays better with memory
koda
parents: 6832
diff changeset
    63
                [[AudioManagerController mainManager] playBackgroundMusic];
5224
6e8fbbfb0de5 muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents: 5207
diff changeset
    64
            else
6869
a187c280dd3d ios: convert audio operation from class to instance, plays better with memory
koda
parents: 6832
diff changeset
    65
                [[AudioManagerController mainManager] pauseBackgroundMusic];
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    66
            break;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    67
        case 30:    //alternateSwitch
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
    68
            [settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"alternate"];
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    69
            break;
5451
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
    70
        case 90:    //synched weapons/scheme
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
    71
            [settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"sync_ws"];
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
    72
            break;
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    73
        default:
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    74
            DLog(@"Wrong tag");
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    75
            break;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    76
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    77
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    78
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    79
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
    80
    NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
    81
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
    82
    if (tagValue == 40)
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
    83
        [settings setObject:textString forKey:@"username"];
5206
db775bddf771 settings.plist is no more, long live nsuserdefaults
koda
parents: 4976
diff changeset
    84
    else
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
    85
        [settings setObject:[textString MD5hash] forKey:@"password"];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    86
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    87
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    88
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    89
#pragma mark TableView Methods
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    90
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    91
    return 3;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    92
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    93
4539
bad3411cba49 store the (future) password with md5 for ifrontend
koda
parents: 4341
diff changeset
    94
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger )section {
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    95
    switch (section) {
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    96
        case 0:     // user and pass
5451
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
    97
            return 1;   // set 2 here to show the password field
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    98
            break;
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    99
        case 1:     // audio
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   100
            return 2;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   101
            break;
5451
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
   102
        case 2:     // other options
6624
e049b5bb0ad1 BUUUUURN OBJC AMMOMENU BUUUURNhg diff! (on a separate note, this reduces the codesize by ~37k)
koda
parents: 6420
diff changeset
   103
            return 2;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   104
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   105
        default:
3935
5ca27a0e9a63 made the new menu toggable
koda
parents: 3884
diff changeset
   106
            DLog(@"Nope");
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   107
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   108
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   109
    return 0;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   110
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   111
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   112
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   113
    NSString *sectionTitle = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   114
    switch (section) {
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   115
        case 0:
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   116
            sectionTitle = NSLocalizedString(@"Main Configuration", @"from the settings table");
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   117
            break;
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   118
        case 1:
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   119
            sectionTitle = NSLocalizedString(@"Audio Preferences", @"from the settings table");
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   120
            break;
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   121
        case 2:
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   122
            sectionTitle = NSLocalizedString(@"Other Settings", @"from the settings table");
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   123
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   124
        default:
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   125
            DLog(@"Nope");
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   126
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   127
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   128
    return sectionTitle;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   129
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   130
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   131
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   132
    static NSString *cellIdentifier0 = @"Cell0";
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   133
    static NSString *cellIdentifier1 = @"Cell1";
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   134
    static NSString *cellIdentifier2 = @"Cell2";
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   135
    NSInteger row = [indexPath row];
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   136
    NSInteger section = [indexPath section];
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
   137
    NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3663
diff changeset
   138
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   139
    UITableViewCell *cell = nil;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   140
    EditableCellView *editableCell = nil;
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   141
    UISwitch *switchContent = nil;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   142
    switch(section) {
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   143
        case 0:
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   144
            editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:cellIdentifier0];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   145
            if (nil == editableCell) {
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   146
                editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier0] autorelease];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   147
                editableCell.minimumCharacters = 0;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   148
                editableCell.delegate = self;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   149
                editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
4341
46b8791e577f minor things
koda
parents: 4244
diff changeset
   150
                editableCell.textField.textColor = [UIColor blackColor];
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   151
            }
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 8426
diff changeset
   152
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   153
            if (row == 0) {
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   154
                editableCell.titleLabel.text = NSLocalizedString(@"Nickname","from the settings table");
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   155
                editableCell.textField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@"from the settings table");
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
   156
                editableCell.textField.text = [settings objectForKey:@"username"];
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   157
                editableCell.textField.secureTextEntry = NO;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   158
                editableCell.tag = 40;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   159
            } else {
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   160
                editableCell.titleLabel.text = NSLocalizedString(@"Password","from the settings table");
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   161
                editableCell.textField.placeholder = NSLocalizedString(@"Insert your password",@"from the settings table");
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
   162
                editableCell.textField.text = [settings objectForKey:@"password"];
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   163
                editableCell.textField.secureTextEntry = YES;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   164
                editableCell.tag = 50;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   165
            }
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 8426
diff changeset
   166
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   167
            editableCell.accessoryView = nil;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   168
            cell = editableCell;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   169
            break;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   170
        case 1:
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   171
            cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier1];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   172
            if (nil == cell) {
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   173
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier1] autorelease];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   174
                UISwitch *theSwitch = [[UISwitch alloc] init];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   175
                [theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   176
                cell.accessoryView = theSwitch;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   177
                [theSwitch release];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   178
            }
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 8426
diff changeset
   179
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   180
            switchContent = (UISwitch *)cell.accessoryView;
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   181
            if (row == 0) {
8426
4b66e60c9967 update sound preferences in ios settings ('sound' means 'sound effects' instead of 'sound enabled')
koda
parents: 6869
diff changeset
   182
                cell.textLabel.text = NSLocalizedString(@"Sound Effects", @"from the settings table");
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
   183
                switchContent.on = [[settings objectForKey:@"sound"] boolValue];
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   184
                switchContent.tag = 10;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   185
            } else {
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   186
                cell.textLabel.text = NSLocalizedString(@"Music", @"from the settings table");
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
   187
                switchContent.on = [[settings objectForKey:@"music"] boolValue];
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   188
                switchContent.tag = 20;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   189
            }
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   190
            break;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   191
        case 2:
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   192
            cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier2];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   193
            if (nil == cell) {
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   194
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier2] autorelease];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   195
                UISwitch *theSwitch = [[UISwitch alloc] init];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   196
                [theSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   197
                cell.accessoryView = theSwitch;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   198
                [theSwitch release];
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   199
            }
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 8426
diff changeset
   200
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   201
            switchContent = (UISwitch *)cell.accessoryView;
5451
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
   202
            cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
4540
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   203
            switch (row) {
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   204
                case 0:
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   205
                    cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @"from the settings table");
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   206
                    cell.detailTextLabel.text = NSLocalizedString(@"Damage popups will notify you on every single hit", @"from the settings table");
5207
4c9ae0f484da some general tweaks (more intelligent use of macros and more caching)
koda
parents: 5206
diff changeset
   207
                    switchContent.on = [[settings objectForKey:@"alternate"] boolValue];
4540
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   208
                    switchContent.tag = 30;
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   209
                    break;
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   210
                case 1:
5451
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
   211
                    cell.textLabel.text = NSLocalizedString(@"Sync Schemes and Weapons", @"");
6420
86a2fe62f338 better ios localization files
koda
parents: 6276
diff changeset
   212
                    cell.detailTextLabel.text = NSLocalizedString(@"Choosing a Scheme will select its associated Weapon", @"from the settings table");
5451
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
   213
                    switchContent.on = [[settings objectForKey:@"sync_ws"] boolValue];
e359a79e3d08 rip out the sync weapons/schemes switch and place it into settings; also perform some runtime check on what can be enabled
koda
parents: 5370
diff changeset
   214
                    switchContent.tag = 90;
4540
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   215
                    break;
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   216
                default:
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   217
                    DLog(@"Nope");
9b614e420de5 add two preferences for enabling/disabling blurry land and multitasking
koda
parents: 4539
diff changeset
   218
                    break;
3779
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   219
            }
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   220
            break;
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   221
        default:
3351a017d4ad tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents: 3703
diff changeset
   222
            break;
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   223
    }
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 8426
diff changeset
   224
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   225
    cell.accessoryType = UITableViewCellAccessoryNone;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   226
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   227
    cell.imageView.image = nil;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3663
diff changeset
   228
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   229
    return cell;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   230
}
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   231
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   232
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   233
#pragma mark Table view delegate
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   234
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
5700
f0960a88ab0e savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents: 5664
diff changeset
   235
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   236
    if (0 == [indexPath section]) {
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   237
        EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath];
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   238
        [cell replyKeyboard];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   239
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   240
}
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   241
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   242
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   243
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   244
#pragma mark Memory management
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   245
-(void) didReceiveMemoryWarning {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   246
    [super didReceiveMemoryWarning];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   247
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   248
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   249
-(void) viewDidUnload {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   250
    [super viewDidUnload];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   251
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   252
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   253
-(void) dealloc {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   254
    [super dealloc];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   255
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   256
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   257
@end