From d8f00310e486aed1ab289a0f816acec571193c32 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Wed, 24 Aug 2011 11:53:40 -0400 Subject: Added support for multiple local highscore lists This revision increments the database version to 2. Also fixed a small problem with GameModeSelection that aligned the highscore text incorrectly. --- Classes/HighscoreListController.m | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) (limited to 'Classes/HighscoreListController.m') diff --git a/Classes/HighscoreListController.m b/Classes/HighscoreListController.m index 932b147..d7bffcb 100755 --- a/Classes/HighscoreListController.m +++ b/Classes/HighscoreListController.m @@ -10,7 +10,6 @@ #import "Highscore.h" #import "RootViewController.h" #import "cocoslive.h" -#import #import "Cart_CollectAppDelegate.h" @implementation HighscoreListController @@ -23,41 +22,7 @@ // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. self = [super initWithStyle:style]; if (self) { - NSMutableArray* highscores = [NSMutableArray arrayWithCapacity:15]; - const char* sqlQuery = "SELECT * FROM highscores ORDER BY score DESC LIMIT 15"; - sqlite3_stmt* compiled_statement; - - if (sqlite3_prepare_v2([Cart_CollectAppDelegate database], sqlQuery, -1, &compiled_statement, NULL) == SQLITE_OK) - { - while (sqlite3_step(compiled_statement) == SQLITE_ROW) - { - NSString* name = [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiled_statement, 1)]; - int score = sqlite3_column_int(compiled_statement, 2); - - NSDate* date = nil; - char* dateStr = (char*)sqlite3_column_text(compiled_statement, 3); - if (dateStr != NULL) - { - NSString* theDate = [NSString stringWithUTF8String:dateStr]; - NSDateComponents* comps = [[NSDateComponents alloc] init]; - [comps setYear:[[theDate substringToIndex:4] intValue]]; - [comps setMonth:[[theDate substringWithRange:NSMakeRange(5, 2)] intValue]]; - [comps setDay:[[theDate substringWithRange:NSMakeRange(8, 2)] intValue]]; - [comps setHour:[[theDate substringWithRange:NSMakeRange(11, 2)] intValue]]; - [comps setMinute:[[theDate substringWithRange:NSMakeRange(14, 2)] intValue]]; - [comps setSecond:[[theDate substringWithRange:NSMakeRange(17, 2)] intValue]]; - date = [[NSCalendar currentCalendar] dateFromComponents:comps]; - date = [date dateByAddingTimeInterval:[[NSTimeZone localTimeZone] secondsFromGMT]]; - [comps release]; - } - - Highscore* highscore = [[Highscore alloc] initWithName:name score:score date:date]; - [highscores addObject:highscore]; - [highscore release]; - } - } - - localHighscores = [highscores copy]; + localHighscores = [Highscore localHighscoreListForGameMode:@"Collect"]; navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; myNavigationItem = [[UINavigationItem alloc] initWithTitle:@"Highscores"]; -- cgit 1.4.1