diff options
-rwxr-xr-x | Classes/HighscoreListController.h | 4 | ||||
-rwxr-xr-x | Classes/HighscoreListController.m | 55 |
2 files changed, 47 insertions, 12 deletions
diff --git a/Classes/HighscoreListController.h b/Classes/HighscoreListController.h index 7b0069d..5921ec6 100755 --- a/Classes/HighscoreListController.h +++ b/Classes/HighscoreListController.h | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | @interface HighscoreListController : UITableViewController { | 11 | @interface HighscoreListController : UITableViewController { |
12 | UINavigationBar* navigationBar; | 12 | UINavigationBar* navigationBar; |
13 | UIToolbar* toolbar; | ||
13 | UINavigationItem* myNavigationItem; | 14 | UINavigationItem* myNavigationItem; |
14 | NSArray* localHighscores; | 15 | NSArray* localHighscores; |
15 | NSArray* globalHighscores; | 16 | NSArray* globalHighscores; |
@@ -19,10 +20,13 @@ | |||
19 | UIActivityIndicatorView* activity; | 20 | UIActivityIndicatorView* activity; |
20 | UILabel* statusText; | 21 | UILabel* statusText; |
21 | UITableView* tableView; | 22 | UITableView* tableView; |
23 | UISegmentedControl* areaControl; | ||
24 | UISegmentedControl* modeControl; | ||
22 | } | 25 | } |
23 | 26 | ||
24 | - (void)back; | 27 | - (void)back; |
25 | - (void)switchLists:(id)sender; | 28 | - (void)switchLists:(id)sender; |
29 | - (void)switchGameMode:(id)sender; | ||
26 | - (void)scoreRequestOk:(id)sender; | 30 | - (void)scoreRequestOk:(id)sender; |
27 | - (void)scoreRequestFail:(id)sender; | 31 | - (void)scoreRequestFail:(id)sender; |
28 | 32 | ||
diff --git a/Classes/HighscoreListController.m b/Classes/HighscoreListController.m index d7bffcb..68ea2f6 100755 --- a/Classes/HighscoreListController.m +++ b/Classes/HighscoreListController.m | |||
@@ -29,26 +29,36 @@ | |||
29 | UIBarButtonItem* barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(back)]; | 29 | UIBarButtonItem* barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(back)]; |
30 | myNavigationItem.leftBarButtonItem = barButton; | 30 | myNavigationItem.leftBarButtonItem = barButton; |
31 | [barButton release]; | 31 | [barButton release]; |
32 | [navigationBar pushNavigationItem:myNavigationItem animated:NO]; | ||
32 | 33 | ||
33 | UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Local", @"Global", nil]]; | 34 | areaControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Local", @"Global", nil]]; |
34 | segmentedControl.selectedSegmentIndex = 0; | 35 | areaControl.selectedSegmentIndex = 0; |
35 | segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; | 36 | areaControl.segmentedControlStyle = UISegmentedControlStyleBar; |
36 | [segmentedControl addTarget:self action:@selector(switchLists:) forControlEvents:UIControlEventValueChanged]; | 37 | [areaControl addTarget:self action:@selector(switchLists:) forControlEvents:UIControlEventValueChanged]; |
37 | UIBarButtonItem* barButton2 = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; | 38 | UIBarButtonItem* barButton2 = [[UIBarButtonItem alloc] initWithCustomView:areaControl]; |
38 | [segmentedControl release]; | 39 | |
39 | myNavigationItem.rightBarButtonItem = barButton2; | 40 | UIBarButtonItem* btnSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; |
40 | [barButton2 release]; | ||
41 | 41 | ||
42 | [navigationBar pushNavigationItem:myNavigationItem animated:NO]; | 42 | modeControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Collect", @"Jump", nil]]; |
43 | modeControl.selectedSegmentIndex = 0; | ||
44 | modeControl.segmentedControlStyle = UISegmentedControlStyleBar; | ||
45 | [modeControl addTarget:self action:@selector(switchGameMode:) forControlEvents:UIControlEventValueChanged]; | ||
46 | UIBarButtonItem* barButton3 = [[UIBarButtonItem alloc] initWithCustomView:modeControl]; | ||
47 | |||
48 | toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-44, 320, 44)]; | ||
49 | [toolbar setItems:[NSArray arrayWithObjects:barButton3, btnSpace, barButton2, nil] animated:NO]; | ||
50 | [barButton2 release]; | ||
51 | [barButton3 release]; | ||
43 | 52 | ||
44 | showGlobal = NO; | 53 | showGlobal = NO; |
45 | loadingGlobal = NO; | 54 | loadingGlobal = NO; |
46 | 55 | ||
47 | tableView = [(UITableView*)self.view retain]; | 56 | tableView = [(UITableView*)self.view retain]; |
48 | UIView* parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; | 57 | UIView* parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; |
49 | [tableView setFrame:CGRectMake(0, 44, 320, 480-44)]; | 58 | [tableView setFrame:CGRectMake(0, 44, 320, 480-44-44)]; |
50 | [parentView addSubview:navigationBar]; | 59 | [parentView addSubview:navigationBar]; |
51 | [parentView addSubview:tableView]; | 60 | [parentView addSubview:tableView]; |
61 | [parentView addSubview:toolbar]; | ||
52 | self.view = parentView; | 62 | self.view = parentView; |
53 | [parentView release]; | 63 | [parentView release]; |
54 | } | 64 | } |
@@ -282,7 +292,7 @@ | |||
282 | { | 292 | { |
283 | loadingGlobal = YES; | 293 | loadingGlobal = YES; |
284 | 294 | ||
285 | loadingView = [[UIView alloc] initWithFrame:CGRectMake(0, 44, 320, 480-44)]; | 295 | loadingView = [[UIView alloc] initWithFrame:CGRectMake(0, 44, 320, 480-44-44)]; |
286 | activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150, 228-44, 20, 20)]; | 296 | activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150, 228-44, 20, 20)]; |
287 | activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; | 297 | activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; |
288 | statusText = [[UILabel alloc] initWithFrame:CGRectMake(0, 256-44, 320, 21)]; | 298 | statusText = [[UILabel alloc] initWithFrame:CGRectMake(0, 256-44, 320, 21)]; |
@@ -298,7 +308,14 @@ | |||
298 | 308 | ||
299 | CLScoreServerRequest* request = [[CLScoreServerRequest alloc] initWithGameName:@"Cart Collect" delegate:self]; | 309 | CLScoreServerRequest* request = [[CLScoreServerRequest alloc] initWithGameName:@"Cart Collect" delegate:self]; |
300 | tQueryFlags flags = kQueryFlagIgnore; | 310 | tQueryFlags flags = kQueryFlagIgnore; |
301 | [request requestScores:kQueryAllTime limit:15 offset:0 flags:flags category:@"Classic"]; | 311 | |
312 | if (modeControl.selectedSegmentIndex == 0) | ||
313 | { | ||
314 | [request requestScores:kQueryAllTime limit:15 offset:0 flags:flags category:@"Classic"]; | ||
315 | } else { | ||
316 | [request requestScores:kQueryAllTime limit:15 offset:0 flags:flags category:@"Jump"]; | ||
317 | } | ||
318 | |||
302 | [request release]; | 319 | [request release]; |
303 | } else { | 320 | } else { |
304 | showGlobal = YES; | 321 | showGlobal = YES; |
@@ -307,6 +324,20 @@ | |||
307 | } | 324 | } |
308 | } | 325 | } |
309 | 326 | ||
327 | - (void)switchGameMode:(id)sender | ||
328 | { | ||
329 | if ([(UISegmentedControl*)sender selectedSegmentIndex] == 0) | ||
330 | { | ||
331 | localHighscores = [Highscore localHighscoreListForGameMode:@"Collect"]; | ||
332 | } else { | ||
333 | localHighscores = [Highscore localHighscoreListForGameMode:@"Jump"]; | ||
334 | } | ||
335 | |||
336 | globalHighscores = nil; | ||
337 | |||
338 | [self switchLists:areaControl]; | ||
339 | } | ||
340 | |||
310 | - (void)scoreRequestOk:(id)sender | 341 | - (void)scoreRequestOk:(id)sender |
311 | { | 342 | { |
312 | NSArray* highscores = [sender parseScores]; | 343 | NSArray* highscores = [sender parseScores]; |