author | unc0rr |
Sat, 19 Nov 2011 22:42:52 +0300 | |
changeset 6401 | b9d9024cf203 |
parent 6319 | b57a37a94ad3 |
child 6672 | 4f728ccdd06b |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3829 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
* |
|
18 |
* File created on 27/03/2010. |
|
19 |
*/ |
|
20 |
||
3547 | 21 |
|
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
22 |
#import "SettingsBaseViewController.h" |
3547 | 23 |
#import "GeneralSettingsViewController.h" |
24 |
#import "TeamSettingsViewController.h" |
|
25 |
#import "WeaponSettingsViewController.h" |
|
26 |
#import "SchemeSettingsViewController.h" |
|
3884 | 27 |
#import "SupportViewController.h" |
3547 | 28 |
|
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
29 |
@implementation SettingsBaseViewController |
6076 | 30 |
@synthesize tabController, targetController, controllerNames, lastIndexPath; |
3547 | 31 |
|
32 |
||
33 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
34 |
return rotationManager(interfaceOrientation); |
|
35 |
} |
|
36 |
||
37 |
||
38 |
#pragma mark - |
|
39 |
#pragma mark View lifecycle |
|
40 |
-(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
|
41 |
// the list of available controllers |
3701 | 42 |
NSArray *array = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), |
43 |
NSLocalizedString(@"Teams",@""), |
|
44 |
NSLocalizedString(@"Weapons",@""), |
|
45 |
NSLocalizedString(@"Schemes",@""), |
|
3884 | 46 |
NSLocalizedString(@"Support",@""), |
3701 | 47 |
nil]; |
48 |
self.controllerNames = array; |
|
49 |
[array release]; |
|
50 |
||
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
|
51 |
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone |
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
|
52 |
target:self |
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
|
53 |
action:@selector(dismissSplitView)]; |
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
|
54 |
if (IS_IPAD()) { |
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
|
55 |
// this class gets loaded twice, we tell the difference by looking at targetController |
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
|
56 |
if (self.targetController != nil) { |
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
|
57 |
UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain]; |
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
|
58 |
tableView.delegate = self; |
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
|
59 |
tableView.dataSource = self; |
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
|
60 |
[tableView reloadData]; |
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
|
61 |
[self.view addSubview:tableView]; |
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
|
62 |
[self tableView:tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; |
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
|
63 |
[tableView release]; |
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
|
64 |
self.navigationItem.leftBarButtonItem = doneButton; |
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
|
65 |
} |
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
|
66 |
} else { |
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
|
67 |
// this class just loads all controllers and set up tabbar and navigation controllers |
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
|
68 |
NSMutableArray *tabBarNavigationControllers = [[NSMutableArray alloc] initWithCapacity:5]; |
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
|
69 |
UINavigationController *navController = nil; |
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
|
70 |
|
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
|
71 |
if (nil == generalSettingsViewController) { |
3701 | 72 |
generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
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
|
73 |
generalSettingsViewController.tabBarItem.title = [self.controllerNames objectAtIndex:0]; |
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
|
74 |
generalSettingsViewController.tabBarItem.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/TargetBee.png",GRAPHICS_DIRECTORY()]]; |
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
|
75 |
navController = [[UINavigationController alloc] initWithRootViewController:generalSettingsViewController]; |
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
|
76 |
generalSettingsViewController.navigationItem.backBarButtonItem = doneButton; |
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
|
77 |
generalSettingsViewController.navigationItem.leftBarButtonItem = doneButton; |
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
|
78 |
[generalSettingsViewController release]; |
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
|
79 |
[tabBarNavigationControllers addObject:navController]; |
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
|
80 |
releaseAndNil(navController); |
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
|
81 |
} |
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
|
82 |
if (nil == teamSettingsViewController) { |
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
|
83 |
teamSettingsViewController = [[TeamSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
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
|
84 |
teamSettingsViewController.tabBarItem.title = [self.controllerNames objectAtIndex:1]; |
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
|
85 |
teamSettingsViewController.tabBarItem.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/Egg.png",GRAPHICS_DIRECTORY()]]; |
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
|
86 |
navController = [[UINavigationController alloc] initWithRootViewController:teamSettingsViewController]; |
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
|
87 |
teamSettingsViewController.navigationItem.backBarButtonItem = doneButton; |
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
|
88 |
teamSettingsViewController.navigationItem.leftBarButtonItem = doneButton; |
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
|
89 |
[tabBarNavigationControllers addObject:navController]; |
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
|
90 |
releaseAndNil(navController); |
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
|
91 |
} |
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
|
92 |
if (nil == weaponSettingsViewController) { |
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
|
93 |
weaponSettingsViewController = [[WeaponSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
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
|
94 |
weaponSettingsViewController.tabBarItem.title = [self.controllerNames objectAtIndex:2]; |
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
|
95 |
weaponSettingsViewController.tabBarItem.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/cheese.png",GRAPHICS_DIRECTORY()]]; |
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
|
96 |
navController = [[UINavigationController alloc] initWithRootViewController:weaponSettingsViewController]; |
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
|
97 |
weaponSettingsViewController.navigationItem.backBarButtonItem = doneButton; |
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
|
98 |
weaponSettingsViewController.navigationItem.leftBarButtonItem = doneButton; |
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
|
99 |
[tabBarNavigationControllers addObject:navController]; |
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
|
100 |
releaseAndNil(navController); |
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
|
101 |
} |
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
|
102 |
if (nil == schemeSettingsViewController) { |
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
|
103 |
schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
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
|
104 |
schemeSettingsViewController.tabBarItem.title = [self.controllerNames objectAtIndex:3]; |
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
|
105 |
schemeSettingsViewController.tabBarItem.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/Targetp.png",GRAPHICS_DIRECTORY()]]; |
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
|
106 |
navController = [[UINavigationController alloc] initWithRootViewController:schemeSettingsViewController]; |
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
|
107 |
schemeSettingsViewController.navigationItem.backBarButtonItem = doneButton; |
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
|
108 |
schemeSettingsViewController.navigationItem.leftBarButtonItem = doneButton; |
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
|
109 |
[tabBarNavigationControllers addObject:navController]; |
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
|
110 |
releaseAndNil(navController); |
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
|
111 |
} |
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
|
112 |
if (nil == supportViewController) { |
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
|
113 |
supportViewController = [[SupportViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
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
|
114 |
supportViewController.tabBarItem.title = [self.controllerNames objectAtIndex:4]; |
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
|
115 |
supportViewController.tabBarItem.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/Seduction.png",GRAPHICS_DIRECTORY()]]; |
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
|
116 |
navController = [[UINavigationController alloc] initWithRootViewController:supportViewController]; |
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
|
117 |
supportViewController.navigationItem.backBarButtonItem = doneButton; |
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
|
118 |
supportViewController.navigationItem.leftBarButtonItem = doneButton; |
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
|
119 |
[tabBarNavigationControllers addObject:navController]; |
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
|
120 |
releaseAndNil(navController); |
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
|
121 |
} |
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
|
122 |
|
6076 | 123 |
self.tabController = [[UITabBarController alloc] init]; |
124 |
self.tabController.viewControllers = tabBarNavigationControllers; |
|
125 |
self.tabController.delegate = self; |
|
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
|
126 |
|
6076 | 127 |
[self.view addSubview:self.tabController.view]; |
3701 | 128 |
} |
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
|
129 |
[doneButton release]; |
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
|
130 |
[super viewDidLoad]; |
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
|
131 |
} |
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
|
132 |
|
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
|
133 |
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { |
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
|
134 |
[viewController viewWillAppear:NO]; |
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
|
135 |
} |
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
|
136 |
|
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
|
137 |
-(void) dismissSplitView { |
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
|
138 |
[AudioManagerController playBackSound]; |
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
|
139 |
[[[HedgewarsAppDelegate sharedAppDelegate] mainViewController] dismissModalViewControllerAnimated:YES]; |
3547 | 140 |
} |
141 |
||
142 |
#pragma mark - |
|
143 |
#pragma mark Table view data source |
|
144 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
145 |
return 1; |
|
146 |
} |
|
147 |
||
148 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
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
|
149 |
return [self.controllerNames count]; |
3547 | 150 |
} |
151 |
||
152 |
// Customize the appearance of table view cells. |
|
153 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
154 |
static NSString *CellIdentifier = @"Cell"; |
|
3697 | 155 |
|
3547 | 156 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
3783 | 157 |
if (cell == nil) |
3547 | 158 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
3783 | 159 |
|
160 |
NSString *iconStr = nil; |
|
161 |
switch ([indexPath row]) { |
|
162 |
case 0: |
|
163 |
iconStr = [NSString stringWithFormat:@"%@/TargetBee.png",GRAPHICS_DIRECTORY()]; |
|
164 |
break; |
|
165 |
case 1: |
|
166 |
iconStr = [NSString stringWithFormat:@"%@/Egg.png",GRAPHICS_DIRECTORY()]; |
|
167 |
break; |
|
168 |
case 2: |
|
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5219
diff
changeset
|
169 |
iconStr = [NSString stringWithFormat:@"%@/cheese.png",GRAPHICS_DIRECTORY()]; |
3783 | 170 |
break; |
171 |
case 3: |
|
172 |
iconStr = [NSString stringWithFormat:@"%@/Target.png",GRAPHICS_DIRECTORY()]; |
|
173 |
break; |
|
3884 | 174 |
case 4: |
175 |
iconStr = [NSString stringWithFormat:@"%@/Seduction.png",GRAPHICS_DIRECTORY()]; |
|
176 |
break; |
|
3783 | 177 |
default: |
178 |
DLog(@"Nope"); |
|
179 |
break; |
|
3547 | 180 |
} |
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
181 |
|
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
|
182 |
cell.accessoryType = UITableViewCellAccessoryNone; |
3701 | 183 |
cell.textLabel.text = [controllerNames objectAtIndex:[indexPath row]]; |
3783 | 184 |
UIImage *icon = [[UIImage alloc] initWithContentsOfFile:iconStr]; |
185 |
cell.imageView.image = icon; |
|
186 |
[icon release]; |
|
3701 | 187 |
|
3547 | 188 |
return cell; |
189 |
} |
|
190 |
||
191 |
#pragma mark - |
|
192 |
#pragma mark Table view delegate |
|
193 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
194 |
int newRow = [indexPath row]; |
|
195 |
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
|
196 |
UIViewController *nextController = nil; |
|
3697 | 197 |
|
3547 | 198 |
if (newRow != oldRow) { |
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
|
199 |
[tableView deselectRowAtIndexPath:lastIndexPath animated:YES]; |
3701 | 200 |
[targetController.navigationController popToRootViewControllerAnimated:NO]; |
3697 | 201 |
|
3547 | 202 |
switch (newRow) { |
203 |
case 0: |
|
204 |
if (nil == generalSettingsViewController) |
|
205 |
generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
206 |
nextController = generalSettingsViewController; |
|
207 |
break; |
|
208 |
case 1: |
|
209 |
if (nil == teamSettingsViewController) |
|
210 |
teamSettingsViewController = [[TeamSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
211 |
nextController = teamSettingsViewController; |
|
212 |
break; |
|
213 |
case 2: |
|
214 |
if (nil == weaponSettingsViewController) |
|
215 |
weaponSettingsViewController = [[WeaponSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
216 |
nextController = weaponSettingsViewController; |
|
217 |
break; |
|
218 |
case 3: |
|
219 |
if (nil == schemeSettingsViewController) |
|
220 |
schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
221 |
nextController = schemeSettingsViewController; |
|
222 |
break; |
|
3884 | 223 |
case 4: |
224 |
if (nil == supportViewController) |
|
4115 | 225 |
supportViewController = [[SupportViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
3884 | 226 |
nextController = supportViewController; |
227 |
break; |
|
3547 | 228 |
} |
3697 | 229 |
|
3547 | 230 |
self.lastIndexPath = indexPath; |
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
|
231 |
[tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
3701 | 232 |
|
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
|
233 |
nextController.navigationItem.hidesBackButton = YES; |
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
|
234 |
[nextController viewWillAppear:NO]; |
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
|
235 |
[targetController.navigationController pushViewController:nextController animated:NO]; |
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
|
236 |
[AudioManagerController playClickSound]; |
3547 | 237 |
} |
238 |
} |
|
239 |
||
240 |
||
241 |
#pragma mark - |
|
242 |
#pragma mark Memory management |
|
243 |
-(void) didReceiveMemoryWarning { |
|
244 |
if (generalSettingsViewController.view.superview == nil) |
|
245 |
generalSettingsViewController = nil; |
|
246 |
if (teamSettingsViewController.view.superview == nil) |
|
247 |
teamSettingsViewController = nil; |
|
248 |
if (weaponSettingsViewController.view.superview == nil) |
|
249 |
weaponSettingsViewController = nil; |
|
250 |
if (schemeSettingsViewController.view.superview == nil) |
|
251 |
schemeSettingsViewController = nil; |
|
3884 | 252 |
if (supportViewController.view.superview == nil) |
253 |
supportViewController = nil; |
|
6076 | 254 |
if (tabController.view.superview == nil) |
255 |
tabController = nil; |
|
3547 | 256 |
MSG_MEMCLEAN(); |
3971 | 257 |
[super didReceiveMemoryWarning]; |
3547 | 258 |
} |
259 |
||
260 |
-(void) viewDidUnload { |
|
261 |
self.controllerNames = nil; |
|
262 |
self.lastIndexPath = nil; |
|
6076 | 263 |
self.targetController = nil; |
264 |
self.tabController = nil; |
|
3547 | 265 |
generalSettingsViewController = nil; |
266 |
teamSettingsViewController = nil; |
|
267 |
weaponSettingsViewController = nil; |
|
268 |
schemeSettingsViewController = nil; |
|
3884 | 269 |
supportViewController = nil; |
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3547
diff
changeset
|
270 |
MSG_DIDUNLOAD(); |
3547 | 271 |
[super viewDidUnload]; |
272 |
} |
|
273 |
||
274 |
-(void) dealloc { |
|
5219 | 275 |
releaseAndNil(targetController); |
5208 | 276 |
releaseAndNil(controllerNames); |
277 |
releaseAndNil(lastIndexPath); |
|
6076 | 278 |
releaseAndNil(tabController); |
5208 | 279 |
releaseAndNil(generalSettingsViewController); |
280 |
releaseAndNil(teamSettingsViewController); |
|
281 |
releaseAndNil(weaponSettingsViewController); |
|
282 |
releaseAndNil(schemeSettingsViewController); |
|
283 |
releaseAndNil(supportViewController); |
|
3547 | 284 |
[super dealloc]; |
285 |
} |
|
286 |
||
6319 | 287 |
|
288 |
-(void) viewWillDisappear:(BOOL)animated { |
|
289 |
// this will send -viewWillDisappear: only the active view |
|
290 |
[self.tabController viewWillDisappear:animated]; |
|
291 |
// let's send that to every page, even though only GeneralSettingsViewController needs it |
|
292 |
[generalSettingsViewController viewWillDisappear:animated]; |
|
293 |
[teamSettingsViewController viewWillDisappear:animated]; |
|
294 |
[weaponSettingsViewController viewWillDisappear:animated]; |
|
295 |
[schemeSettingsViewController viewWillDisappear:animated]; |
|
296 |
[supportViewController viewWillDisappear:animated]; |
|
297 |
[super viewWillDisappear:animated]; |
|
298 |
} |
|
299 |
||
3547 | 300 |
@end |
301 |