3250
|
1 |
//
|
|
2 |
// SingleTeamViewController.m
|
|
3 |
// HedgewarsMobile
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 02/04/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "SingleTeamViewController.h"
|
3270
|
10 |
#import "HogHatViewController.h"
|
3250
|
11 |
|
|
12 |
@implementation SingleTeamViewController
|
3270
|
13 |
@synthesize hogsList, secondaryItems, teamName;
|
3250
|
14 |
|
|
15 |
|
|
16 |
#pragma mark -
|
|
17 |
#pragma mark View lifecycle
|
|
18 |
- (void)viewDidLoad {
|
|
19 |
[super viewDidLoad];
|
|
20 |
|
|
21 |
// Uncomment the following line to preserve selection between presentations.
|
3253
|
22 |
//self.clearsSelectionOnViewWillAppear = NO;
|
3250
|
23 |
|
|
24 |
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
|
|
25 |
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
3270
|
26 |
|
3251
|
27 |
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:
|
|
28 |
NSLocalizedString(@"Color",@""),
|
|
29 |
NSLocalizedString(@"Grave",@""),
|
|
30 |
NSLocalizedString(@"Voice",@""),
|
|
31 |
NSLocalizedString(@"Fort",@""),
|
|
32 |
NSLocalizedString(@"Flag",@""),
|
|
33 |
NSLocalizedString(@"Level",@""),nil];
|
|
34 |
self.secondaryItems = array;
|
|
35 |
[array release];
|
3250
|
36 |
}
|
3251
|
37 |
|
3250
|
38 |
|
|
39 |
- (void)viewWillAppear:(BOOL)animated {
|
|
40 |
[super viewWillAppear:animated];
|
3270
|
41 |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
42 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@Teams/%@.plist",[paths objectAtIndex:0],self.teamName];
|
|
43 |
NSDictionary *teamDict = [[NSDictionary alloc] initWithContentsOfFile:teamFile];
|
|
44 |
[teamFile release];
|
|
45 |
|
|
46 |
self.hogsList = [teamDict objectForKey:@"hedgehogs"];
|
|
47 |
self.teamName = [teamDict objectForKey:@"teamname"];
|
|
48 |
[teamDict release];
|
|
49 |
self.title = teamName;
|
3250
|
50 |
}
|
3270
|
51 |
|
3250
|
52 |
/*
|
|
53 |
- (void)viewDidAppear:(BOOL)animated {
|
|
54 |
[super viewDidAppear:animated];
|
|
55 |
}
|
|
56 |
*/
|
|
57 |
/*
|
|
58 |
- (void)viewWillDisappear:(BOOL)animated {
|
|
59 |
[super viewWillDisappear:animated];
|
|
60 |
}
|
|
61 |
*/
|
|
62 |
/*
|
|
63 |
- (void)viewDidDisappear:(BOOL)animated {
|
|
64 |
[super viewDidDisappear:animated];
|
|
65 |
}
|
|
66 |
*/
|
|
67 |
|
3251
|
68 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
69 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
|
3250
|
70 |
}
|
|
71 |
|
|
72 |
|
|
73 |
#pragma mark -
|
|
74 |
#pragma mark Table view data source
|
|
75 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
|
|
76 |
return 3;
|
|
77 |
}
|
|
78 |
|
|
79 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
80 |
NSInteger rows;
|
|
81 |
switch (section) {
|
|
82 |
case 0:
|
|
83 |
rows = 1;
|
|
84 |
break;
|
|
85 |
case 1:
|
|
86 |
rows = 8;
|
|
87 |
break;
|
|
88 |
case 2:
|
3251
|
89 |
rows = 6;
|
3250
|
90 |
break;
|
|
91 |
default:
|
|
92 |
break;
|
|
93 |
}
|
|
94 |
return rows;
|
|
95 |
}
|
|
96 |
|
3251
|
97 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
3250
|
98 |
static NSString *CellIdentifier = @"Cell";
|
|
99 |
|
|
100 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
|
101 |
if (cell == nil) {
|
3270
|
102 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
|
103 |
reuseIdentifier:CellIdentifier] autorelease];
|
3250
|
104 |
}
|
|
105 |
|
3253
|
106 |
NSInteger row = [indexPath row];
|
3251
|
107 |
switch ([indexPath section]) {
|
3253
|
108 |
case 0:
|
3270
|
109 |
cell.textLabel.text = teamName;
|
3253
|
110 |
break;
|
|
111 |
case 1:
|
|
112 |
cell.textLabel.text = [[self.hogsList objectAtIndex:row] objectForKey:@"hogname"];
|
3270
|
113 |
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
3253
|
114 |
break;
|
3251
|
115 |
case 2:
|
3253
|
116 |
cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
|
3251
|
117 |
break;
|
|
118 |
default:
|
|
119 |
break;
|
|
120 |
}
|
3250
|
121 |
|
|
122 |
return cell;
|
|
123 |
}
|
|
124 |
|
|
125 |
|
|
126 |
/*
|
|
127 |
// Override to support conditional editing of the table view.
|
|
128 |
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
129 |
// Return NO if you do not want the specified item to be editable.
|
|
130 |
return YES;
|
|
131 |
}
|
|
132 |
*/
|
|
133 |
|
|
134 |
|
|
135 |
/*
|
|
136 |
// Override to support editing the table view.
|
|
137 |
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
138 |
|
|
139 |
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
|
140 |
// Delete the row from the data source
|
|
141 |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
|
|
142 |
}
|
|
143 |
else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
|
144 |
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
|
|
145 |
}
|
|
146 |
}
|
|
147 |
*/
|
|
148 |
|
|
149 |
|
|
150 |
/*
|
|
151 |
// Override to support rearranging the table view.
|
|
152 |
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
153 |
}
|
|
154 |
*/
|
|
155 |
|
|
156 |
|
|
157 |
/*
|
|
158 |
// Override to support conditional rearranging of the table view.
|
|
159 |
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
160 |
// Return NO if you do not want the item to be re-orderable.
|
|
161 |
return YES;
|
|
162 |
}
|
|
163 |
*/
|
|
164 |
|
|
165 |
|
|
166 |
#pragma mark -
|
|
167 |
#pragma mark Table view delegate
|
|
168 |
|
3251
|
169 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
3270
|
170 |
if (nil == hogChildController) {
|
|
171 |
hogChildController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped];
|
|
172 |
}
|
|
173 |
|
|
174 |
hogChildController.hog = [hogsList objectAtIndex:[indexPath row]];
|
|
175 |
//NSLog(@"%@",hogChildController.hog);
|
|
176 |
[self.navigationController pushViewController:hogChildController animated:YES];
|
3250
|
177 |
}
|
|
178 |
|
|
179 |
|
|
180 |
#pragma mark -
|
|
181 |
#pragma mark Memory management
|
|
182 |
|
3251
|
183 |
-(void) didReceiveMemoryWarning {
|
3250
|
184 |
// Releases the view if it doesn't have a superview.
|
|
185 |
[super didReceiveMemoryWarning];
|
|
186 |
// Relinquish ownership any cached data, images, etc that aren't in use.
|
|
187 |
}
|
|
188 |
|
3251
|
189 |
-(void) viewDidUnload {
|
3253
|
190 |
self.hogsList = nil;
|
3251
|
191 |
self.secondaryItems = nil;
|
3270
|
192 |
self.teamName = nil;
|
3250
|
193 |
}
|
|
194 |
|
|
195 |
|
3251
|
196 |
-(void) dealloc {
|
3270
|
197 |
[secondaryItems release];
|
3253
|
198 |
[hogsList release];
|
3270
|
199 |
[teamName release];
|
3250
|
200 |
[super dealloc];
|
|
201 |
}
|
|
202 |
|
|
203 |
|
|
204 |
@end
|
|
205 |
|