author | Gianfranco Costamagna <costamagnagianfranco@yahoo.it> |
Thu, 09 Jan 2014 19:10:12 +0100 | |
branch | webgl |
changeset 9984 | 84835d0ceb64 |
parent 6869 | a187c280dd3d |
child 10108 | c68cf030eded |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
6700 | 3 |
* Copyright (c) 2009-2012 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 |
||
3547 | 19 |
|
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
20 |
#import "SettingsBaseViewController.h" |
3547 | 21 |
#import "GeneralSettingsViewController.h" |
22 |
#import "TeamSettingsViewController.h" |
|
23 |
#import "WeaponSettingsViewController.h" |
|
24 |
#import "SchemeSettingsViewController.h" |
|
3884 | 25 |
#import "SupportViewController.h" |
3547 | 26 |
|
6832 | 27 |
|
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
28 |
@implementation SettingsBaseViewController |
6076 | 29 |
@synthesize tabController, targetController, controllerNames, lastIndexPath; |
3547 | 30 |
|
31 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
32 |
return rotationManager(interfaceOrientation); |
|
33 |
} |
|
34 |
||
35 |
#pragma mark - |
|
36 |
#pragma mark View lifecycle |
|
37 |
-(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
|
38 |
// the list of available controllers |
3701 | 39 |
NSArray *array = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""), |
40 |
NSLocalizedString(@"Teams",@""), |
|
41 |
NSLocalizedString(@"Weapons",@""), |
|
42 |
NSLocalizedString(@"Schemes",@""), |
|
3884 | 43 |
NSLocalizedString(@"Support",@""), |
3701 | 44 |
nil]; |
45 |
self.controllerNames = array; |
|
46 |
[array release]; |
|
47 |
||
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
// 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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
[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
|
58 |
[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
|
59 |
[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
|
60 |
[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
|
61 |
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
|
62 |
} |
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 |
} 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
|
64 |
// 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
|
65 |
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
|
66 |
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
|
67 |
|
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 |
if (nil == generalSettingsViewController) { |
3701 | 69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
[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
|
76 |
[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
|
77 |
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
|
78 |
} |
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 |
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
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
[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
|
87 |
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
|
88 |
} |
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 |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
[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
|
97 |
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
|
98 |
} |
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 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
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
|
106 |
[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
|
107 |
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
|
108 |
} |
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 |
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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
[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
|
117 |
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
|
118 |
} |
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 |
|
6076 | 120 |
self.tabController = [[UITabBarController alloc] init]; |
121 |
self.tabController.viewControllers = tabBarNavigationControllers; |
|
122 |
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
|
123 |
|
6076 | 124 |
[self.view addSubview:self.tabController.view]; |
3701 | 125 |
} |
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 |
[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
|
127 |
[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
|
128 |
} |
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 |
|
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 |
-(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
|
131 |
[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
|
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 |
|
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 |
-(void) dismissSplitView { |
6869
a187c280dd3d
ios: convert audio operation from class to instance, plays better with memory
koda
parents:
6832
diff
changeset
|
135 |
[[AudioManagerController mainManager] playBackSound]; |
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
|
136 |
[[[HedgewarsAppDelegate sharedAppDelegate] mainViewController] dismissModalViewControllerAnimated:YES]; |
3547 | 137 |
} |
138 |
||
6672
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
139 |
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
140 |
if (IS_IPAD() == NO) |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
141 |
return; |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
142 |
|
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
143 |
if (self.targetController != nil) { |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
144 |
CGRect screenRect = [[UIScreen mainScreen] safeBounds]; |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
145 |
self.view.frame = CGRectMake(0, 0, 320, screenRect.size.height); |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
146 |
} |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
147 |
} |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
148 |
|
3547 | 149 |
#pragma mark - |
150 |
#pragma mark Table view data source |
|
151 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
152 |
return 1; |
|
153 |
} |
|
154 |
||
155 |
-(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
|
156 |
return [self.controllerNames count]; |
3547 | 157 |
} |
158 |
||
159 |
// Customize the appearance of table view cells. |
|
160 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
161 |
static NSString *CellIdentifier = @"Cell"; |
|
3697 | 162 |
|
3547 | 163 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
3783 | 164 |
if (cell == nil) |
3547 | 165 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
3783 | 166 |
|
167 |
NSString *iconStr = nil; |
|
168 |
switch ([indexPath row]) { |
|
169 |
case 0: |
|
170 |
iconStr = [NSString stringWithFormat:@"%@/TargetBee.png",GRAPHICS_DIRECTORY()]; |
|
171 |
break; |
|
172 |
case 1: |
|
173 |
iconStr = [NSString stringWithFormat:@"%@/Egg.png",GRAPHICS_DIRECTORY()]; |
|
174 |
break; |
|
175 |
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
|
176 |
iconStr = [NSString stringWithFormat:@"%@/cheese.png",GRAPHICS_DIRECTORY()]; |
3783 | 177 |
break; |
178 |
case 3: |
|
179 |
iconStr = [NSString stringWithFormat:@"%@/Target.png",GRAPHICS_DIRECTORY()]; |
|
180 |
break; |
|
3884 | 181 |
case 4: |
182 |
iconStr = [NSString stringWithFormat:@"%@/Seduction.png",GRAPHICS_DIRECTORY()]; |
|
183 |
break; |
|
3783 | 184 |
default: |
185 |
DLog(@"Nope"); |
|
186 |
break; |
|
3547 | 187 |
} |
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
188 |
|
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
|
189 |
cell.accessoryType = UITableViewCellAccessoryNone; |
3701 | 190 |
cell.textLabel.text = [controllerNames objectAtIndex:[indexPath row]]; |
3783 | 191 |
UIImage *icon = [[UIImage alloc] initWithContentsOfFile:iconStr]; |
192 |
cell.imageView.image = icon; |
|
193 |
[icon release]; |
|
3701 | 194 |
|
3547 | 195 |
return cell; |
196 |
} |
|
197 |
||
198 |
#pragma mark - |
|
199 |
#pragma mark Table view delegate |
|
200 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
201 |
int newRow = [indexPath row]; |
|
202 |
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
|
203 |
UIViewController *nextController = nil; |
|
3697 | 204 |
|
3547 | 205 |
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
|
206 |
[tableView deselectRowAtIndexPath:lastIndexPath animated:YES]; |
3701 | 207 |
[targetController.navigationController popToRootViewControllerAnimated:NO]; |
3697 | 208 |
|
3547 | 209 |
switch (newRow) { |
210 |
case 0: |
|
211 |
if (nil == generalSettingsViewController) |
|
212 |
generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
213 |
nextController = generalSettingsViewController; |
|
214 |
break; |
|
215 |
case 1: |
|
216 |
if (nil == teamSettingsViewController) |
|
217 |
teamSettingsViewController = [[TeamSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
218 |
nextController = teamSettingsViewController; |
|
219 |
break; |
|
220 |
case 2: |
|
221 |
if (nil == weaponSettingsViewController) |
|
222 |
weaponSettingsViewController = [[WeaponSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
223 |
nextController = weaponSettingsViewController; |
|
224 |
break; |
|
225 |
case 3: |
|
226 |
if (nil == schemeSettingsViewController) |
|
227 |
schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
228 |
nextController = schemeSettingsViewController; |
|
229 |
break; |
|
3884 | 230 |
case 4: |
231 |
if (nil == supportViewController) |
|
4115 | 232 |
supportViewController = [[SupportViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
3884 | 233 |
nextController = supportViewController; |
234 |
break; |
|
3547 | 235 |
} |
3697 | 236 |
|
3547 | 237 |
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
|
238 |
[tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
3701 | 239 |
|
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
|
240 |
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
|
241 |
[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
|
242 |
[targetController.navigationController pushViewController:nextController animated:NO]; |
6869
a187c280dd3d
ios: convert audio operation from class to instance, plays better with memory
koda
parents:
6832
diff
changeset
|
243 |
[[AudioManagerController mainManager] playClickSound]; |
3547 | 244 |
} |
245 |
} |
|
246 |
||
247 |
||
248 |
#pragma mark - |
|
249 |
#pragma mark Memory management |
|
250 |
-(void) didReceiveMemoryWarning { |
|
251 |
if (generalSettingsViewController.view.superview == nil) |
|
252 |
generalSettingsViewController = nil; |
|
253 |
if (teamSettingsViewController.view.superview == nil) |
|
254 |
teamSettingsViewController = nil; |
|
255 |
if (weaponSettingsViewController.view.superview == nil) |
|
256 |
weaponSettingsViewController = nil; |
|
257 |
if (schemeSettingsViewController.view.superview == nil) |
|
258 |
schemeSettingsViewController = nil; |
|
3884 | 259 |
if (supportViewController.view.superview == nil) |
260 |
supportViewController = nil; |
|
6076 | 261 |
if (tabController.view.superview == nil) |
262 |
tabController = nil; |
|
3547 | 263 |
MSG_MEMCLEAN(); |
3971 | 264 |
[super didReceiveMemoryWarning]; |
3547 | 265 |
} |
266 |
||
267 |
-(void) viewDidUnload { |
|
268 |
self.controllerNames = nil; |
|
269 |
self.lastIndexPath = nil; |
|
6076 | 270 |
self.targetController = nil; |
271 |
self.tabController = nil; |
|
3547 | 272 |
generalSettingsViewController = nil; |
273 |
teamSettingsViewController = nil; |
|
274 |
weaponSettingsViewController = nil; |
|
275 |
schemeSettingsViewController = nil; |
|
3884 | 276 |
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
|
277 |
MSG_DIDUNLOAD(); |
3547 | 278 |
[super viewDidUnload]; |
279 |
} |
|
280 |
||
281 |
-(void) dealloc { |
|
5219 | 282 |
releaseAndNil(targetController); |
5208 | 283 |
releaseAndNil(controllerNames); |
284 |
releaseAndNil(lastIndexPath); |
|
6076 | 285 |
releaseAndNil(tabController); |
5208 | 286 |
releaseAndNil(generalSettingsViewController); |
287 |
releaseAndNil(teamSettingsViewController); |
|
288 |
releaseAndNil(weaponSettingsViewController); |
|
289 |
releaseAndNil(schemeSettingsViewController); |
|
290 |
releaseAndNil(supportViewController); |
|
3547 | 291 |
[super dealloc]; |
292 |
} |
|
293 |
||
6319 | 294 |
|
295 |
-(void) viewWillDisappear:(BOOL)animated { |
|
296 |
// this will send -viewWillDisappear: only the active view |
|
297 |
[self.tabController viewWillDisappear:animated]; |
|
298 |
// let's send that to every page, even though only GeneralSettingsViewController needs it |
|
299 |
[generalSettingsViewController viewWillDisappear:animated]; |
|
300 |
[teamSettingsViewController viewWillDisappear:animated]; |
|
301 |
[weaponSettingsViewController viewWillDisappear:animated]; |
|
302 |
[schemeSettingsViewController viewWillDisappear:animated]; |
|
303 |
[supportViewController viewWillDisappear:animated]; |
|
304 |
[super viewWillDisappear:animated]; |
|
305 |
} |
|
306 |
||
3547 | 307 |
@end |
308 |