author | antonc27 <antonc27@mail.ru> |
Sat, 17 Oct 2015 20:07:10 +0200 | |
branch | ios-revival |
changeset 11220 | 76fd61a88c1e |
parent 11218 | d8135421833c |
child 11221 | e68b3e392091 |
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 |
|
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:
6869
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3829 | 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 |
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
|
49 |
// 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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
[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
|
55 |
[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
|
56 |
[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
|
57 |
[tableView release]; |
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
58 |
self.navigationItem.leftBarButtonItem = [self doneButton]; |
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
|
59 |
} |
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 |
} 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
|
61 |
// 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
|
62 |
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
|
63 |
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
|
64 |
|
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 |
if (nil == generalSettingsViewController) { |
3701 | 66 |
generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
11218
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
67 |
generalSettingsViewController.tabBarItem = [self tabBarItemWithTitle:[self.controllerNames objectAtIndex:0] imageName:@"flower" selectedImageName:@"flower_filled"]; |
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
|
68 |
navController = [[UINavigationController alloc] initWithRootViewController:generalSettingsViewController]; |
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
69 |
UIBarButtonItem *generalSettingsDoneButton = [self doneButton]; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
70 |
generalSettingsViewController.navigationItem.backBarButtonItem = generalSettingsDoneButton; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
71 |
generalSettingsViewController.navigationItem.leftBarButtonItem = generalSettingsDoneButton; |
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
|
72 |
[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
|
73 |
[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
|
74 |
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
|
75 |
} |
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 |
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
|
77 |
teamSettingsViewController = [[TeamSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
11218
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
78 |
teamSettingsViewController.tabBarItem = [self tabBarItemWithTitle:[self.controllerNames objectAtIndex:1] imageName:@"teams" selectedImageName:@"teams_filled"]; |
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
|
79 |
navController = [[UINavigationController alloc] initWithRootViewController:teamSettingsViewController]; |
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
80 |
UIBarButtonItem *teamSettingsDoneButton = [self doneButton]; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
81 |
teamSettingsViewController.navigationItem.backBarButtonItem = teamSettingsDoneButton; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
82 |
teamSettingsViewController.navigationItem.leftBarButtonItem = teamSettingsDoneButton; |
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
|
83 |
[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
|
84 |
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
|
85 |
} |
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 |
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
|
87 |
weaponSettingsViewController = [[WeaponSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
11218
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
88 |
weaponSettingsViewController.tabBarItem = [self tabBarItemWithTitle:[self.controllerNames objectAtIndex:2] imageName:@"bullet" selectedImageName:@"bullet_filled"]; |
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
|
89 |
navController = [[UINavigationController alloc] initWithRootViewController:weaponSettingsViewController]; |
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
90 |
UIBarButtonItem *weaponSettingsDoneButton = [self doneButton]; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
91 |
weaponSettingsViewController.navigationItem.backBarButtonItem = weaponSettingsDoneButton; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
92 |
weaponSettingsViewController.navigationItem.leftBarButtonItem = weaponSettingsDoneButton; |
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
|
93 |
[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
|
94 |
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
|
95 |
} |
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 |
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
|
97 |
schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
11218
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
98 |
schemeSettingsViewController.tabBarItem = [self tabBarItemWithTitle:[self.controllerNames objectAtIndex:3] imageName:@"target" selectedImageName:@"target_filled"]; |
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
|
99 |
navController = [[UINavigationController alloc] initWithRootViewController:schemeSettingsViewController]; |
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
100 |
UIBarButtonItem *schemeSettingsDoneButton = [self doneButton]; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
101 |
schemeSettingsViewController.navigationItem.backBarButtonItem = schemeSettingsDoneButton; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
102 |
schemeSettingsViewController.navigationItem.leftBarButtonItem = schemeSettingsDoneButton; |
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
|
103 |
[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
|
104 |
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
|
105 |
} |
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 |
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
|
107 |
supportViewController = [[SupportViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
11218
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
108 |
supportViewController.tabBarItem = [self tabBarItemWithTitle:[self.controllerNames objectAtIndex:4] imageName:@"heart" selectedImageName:@"heart_filled"]; |
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
|
109 |
navController = [[UINavigationController alloc] initWithRootViewController:supportViewController]; |
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
110 |
UIBarButtonItem *supportViewDoneButton = [self doneButton]; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
111 |
supportViewController.navigationItem.backBarButtonItem = supportViewDoneButton; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
112 |
supportViewController.navigationItem.leftBarButtonItem = supportViewDoneButton; |
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
|
113 |
[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
|
114 |
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
|
115 |
} |
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 |
|
6076 | 117 |
self.tabController = [[UITabBarController alloc] init]; |
118 |
self.tabController.viewControllers = tabBarNavigationControllers; |
|
119 |
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
|
120 |
|
6076 | 121 |
[self.view addSubview:self.tabController.view]; |
3701 | 122 |
} |
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
123 |
|
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
|
124 |
[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
|
125 |
} |
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 |
|
11220
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
127 |
- (UIBarButtonItem *)doneButton |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
128 |
{ |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
129 |
return [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
130 |
target:self |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
131 |
action:@selector(dismissSplitView)] autorelease]; |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
132 |
} |
76fd61a88c1e
- Better way of creating/using doneButton in Settings
antonc27 <antonc27@mail.ru>
parents:
11218
diff
changeset
|
133 |
|
11218
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
134 |
- (UITabBarItem *)tabBarItemWithTitle: (NSString *)title |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
135 |
imageName: (NSString *)imageName |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
136 |
selectedImageName: (NSString *)selectedImageName |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
137 |
{ |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
138 |
return [[[UITabBarItem alloc] initWithTitle:title |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
139 |
image:[UIImage imageNamed:imageName] |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
140 |
selectedImage:[UIImage imageNamed:selectedImageName]] autorelease]; |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
141 |
} |
d8135421833c
- Added new set of tabbar icons for Settings on iPhone
antonc27 <antonc27@mail.ru>
parents:
11148
diff
changeset
|
142 |
|
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
|
143 |
-(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
|
144 |
[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
|
145 |
} |
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
|
146 |
|
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
|
147 |
-(void) dismissSplitView { |
6869
a187c280dd3d
ios: convert audio operation from class to instance, plays better with memory
koda
parents:
6832
diff
changeset
|
148 |
[[AudioManagerController mainManager] playBackSound]; |
11116
102684240fe8
- Interscreen transitions fixed
Anton Malmygin <antonc27@mail.ru>
parents:
10108
diff
changeset
|
149 |
[[[HedgewarsAppDelegate sharedAppDelegate] mainViewController] dismissViewControllerAnimated:YES completion:nil]; |
3547 | 150 |
} |
151 |
||
6672
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
152 |
-(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
|
153 |
if (IS_IPAD() == NO) |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
154 |
return; |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
155 |
|
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
156 |
if (self.targetController != nil) { |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
} |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
160 |
} |
4f728ccdd06b
fixed a little event propagation problem, added rotation support to the scheme setting page
koda
parents:
6319
diff
changeset
|
161 |
|
3547 | 162 |
#pragma mark - |
163 |
#pragma mark Table view data source |
|
164 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
165 |
return 1; |
|
166 |
} |
|
167 |
||
168 |
-(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
|
169 |
return [self.controllerNames count]; |
3547 | 170 |
} |
171 |
||
172 |
// Customize the appearance of table view cells. |
|
173 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
174 |
static NSString *CellIdentifier = @"Cell"; |
|
3697 | 175 |
|
3547 | 176 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
3783 | 177 |
if (cell == nil) |
3547 | 178 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
3783 | 179 |
|
180 |
NSString *iconStr = nil; |
|
181 |
switch ([indexPath row]) { |
|
182 |
case 0: |
|
183 |
iconStr = [NSString stringWithFormat:@"%@/TargetBee.png",GRAPHICS_DIRECTORY()]; |
|
184 |
break; |
|
185 |
case 1: |
|
186 |
iconStr = [NSString stringWithFormat:@"%@/Egg.png",GRAPHICS_DIRECTORY()]; |
|
187 |
break; |
|
188 |
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
|
189 |
iconStr = [NSString stringWithFormat:@"%@/cheese.png",GRAPHICS_DIRECTORY()]; |
3783 | 190 |
break; |
191 |
case 3: |
|
192 |
iconStr = [NSString stringWithFormat:@"%@/Target.png",GRAPHICS_DIRECTORY()]; |
|
193 |
break; |
|
3884 | 194 |
case 4: |
195 |
iconStr = [NSString stringWithFormat:@"%@/Seduction.png",GRAPHICS_DIRECTORY()]; |
|
196 |
break; |
|
3783 | 197 |
default: |
198 |
DLog(@"Nope"); |
|
199 |
break; |
|
3547 | 200 |
} |
6075
0173cd44c3bc
rename the ios settings files into something more appropriate
koda
parents:
6074
diff
changeset
|
201 |
|
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
|
202 |
cell.accessoryType = UITableViewCellAccessoryNone; |
3701 | 203 |
cell.textLabel.text = [controllerNames objectAtIndex:[indexPath row]]; |
3783 | 204 |
UIImage *icon = [[UIImage alloc] initWithContentsOfFile:iconStr]; |
205 |
cell.imageView.image = icon; |
|
206 |
[icon release]; |
|
3701 | 207 |
|
3547 | 208 |
return cell; |
209 |
} |
|
210 |
||
211 |
#pragma mark - |
|
212 |
#pragma mark Table view delegate |
|
213 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
11148
064a53861759
- Refactoring in order to remove some warning related to using of int instead of NSInteger
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
214 |
NSInteger newRow = [indexPath row]; |
064a53861759
- Refactoring in order to remove some warning related to using of int instead of NSInteger
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
215 |
NSInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
3547 | 216 |
UIViewController *nextController = nil; |
3697 | 217 |
|
3547 | 218 |
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
|
219 |
[tableView deselectRowAtIndexPath:lastIndexPath animated:YES]; |
3701 | 220 |
[targetController.navigationController popToRootViewControllerAnimated:NO]; |
3697 | 221 |
|
3547 | 222 |
switch (newRow) { |
223 |
case 0: |
|
224 |
if (nil == generalSettingsViewController) |
|
225 |
generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
226 |
nextController = generalSettingsViewController; |
|
227 |
break; |
|
228 |
case 1: |
|
229 |
if (nil == teamSettingsViewController) |
|
230 |
teamSettingsViewController = [[TeamSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
231 |
nextController = teamSettingsViewController; |
|
232 |
break; |
|
233 |
case 2: |
|
234 |
if (nil == weaponSettingsViewController) |
|
235 |
weaponSettingsViewController = [[WeaponSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
236 |
nextController = weaponSettingsViewController; |
|
237 |
break; |
|
238 |
case 3: |
|
239 |
if (nil == schemeSettingsViewController) |
|
240 |
schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
|
241 |
nextController = schemeSettingsViewController; |
|
242 |
break; |
|
3884 | 243 |
case 4: |
244 |
if (nil == supportViewController) |
|
4115 | 245 |
supportViewController = [[SupportViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
3884 | 246 |
nextController = supportViewController; |
247 |
break; |
|
3547 | 248 |
} |
3697 | 249 |
|
3547 | 250 |
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
|
251 |
[tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
3701 | 252 |
|
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
|
253 |
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
|
254 |
[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
|
255 |
[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
|
256 |
[[AudioManagerController mainManager] playClickSound]; |
3547 | 257 |
} |
258 |
} |
|
259 |
||
260 |
||
261 |
#pragma mark - |
|
262 |
#pragma mark Memory management |
|
263 |
-(void) didReceiveMemoryWarning { |
|
264 |
if (generalSettingsViewController.view.superview == nil) |
|
265 |
generalSettingsViewController = nil; |
|
266 |
if (teamSettingsViewController.view.superview == nil) |
|
267 |
teamSettingsViewController = nil; |
|
268 |
if (weaponSettingsViewController.view.superview == nil) |
|
269 |
weaponSettingsViewController = nil; |
|
270 |
if (schemeSettingsViewController.view.superview == nil) |
|
271 |
schemeSettingsViewController = nil; |
|
3884 | 272 |
if (supportViewController.view.superview == nil) |
273 |
supportViewController = nil; |
|
6076 | 274 |
if (tabController.view.superview == nil) |
275 |
tabController = nil; |
|
3547 | 276 |
MSG_MEMCLEAN(); |
3971 | 277 |
[super didReceiveMemoryWarning]; |
3547 | 278 |
} |
279 |
||
280 |
-(void) viewDidUnload { |
|
281 |
self.controllerNames = nil; |
|
282 |
self.lastIndexPath = nil; |
|
6076 | 283 |
self.targetController = nil; |
284 |
self.tabController = nil; |
|
3547 | 285 |
generalSettingsViewController = nil; |
286 |
teamSettingsViewController = nil; |
|
287 |
weaponSettingsViewController = nil; |
|
288 |
schemeSettingsViewController = nil; |
|
3884 | 289 |
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
|
290 |
MSG_DIDUNLOAD(); |
3547 | 291 |
[super viewDidUnload]; |
292 |
} |
|
293 |
||
294 |
-(void) dealloc { |
|
5219 | 295 |
releaseAndNil(targetController); |
5208 | 296 |
releaseAndNil(controllerNames); |
297 |
releaseAndNil(lastIndexPath); |
|
6076 | 298 |
releaseAndNil(tabController); |
5208 | 299 |
releaseAndNil(generalSettingsViewController); |
300 |
releaseAndNil(teamSettingsViewController); |
|
301 |
releaseAndNil(weaponSettingsViewController); |
|
302 |
releaseAndNil(schemeSettingsViewController); |
|
303 |
releaseAndNil(supportViewController); |
|
3547 | 304 |
[super dealloc]; |
305 |
} |
|
306 |
||
6319 | 307 |
|
308 |
-(void) viewWillDisappear:(BOOL)animated { |
|
309 |
// this will send -viewWillDisappear: only the active view |
|
310 |
[self.tabController viewWillDisappear:animated]; |
|
311 |
// let's send that to every page, even though only GeneralSettingsViewController needs it |
|
312 |
[generalSettingsViewController viewWillDisappear:animated]; |
|
313 |
[teamSettingsViewController viewWillDisappear:animated]; |
|
314 |
[weaponSettingsViewController viewWillDisappear:animated]; |
|
315 |
[schemeSettingsViewController viewWillDisappear:animated]; |
|
316 |
[supportViewController viewWillDisappear:animated]; |
|
317 |
[super viewWillDisappear:animated]; |
|
318 |
} |
|
319 |
||
3547 | 320 |
@end |
321 |