# HG changeset patch # User koda # Date 1295395975 -3600 # Node ID dbc256913b35516dc15e38d0b88a75837034a834 # Parent 2480ab32505773761a2a09e4e216ca4ca4120abc implemented ranking in ios stats pages diff -r 2480ab325057 -r dbc256913b35 project_files/HedgewarsMobile/Classes/GameConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Tue Jan 18 23:08:47 2011 +0100 +++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Wed Jan 19 01:12:55 2011 +0100 @@ -240,10 +240,12 @@ statsPage.modalPresentationStyle = UIModalPresentationPageSheet; [self presentModalViewController:statsPage animated:NO]; + // also modify SavedGamesViewController.m NSArray *stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary]; - if ([stats count] == 0) + if ([stats count] <= 1) { + DLog(@"%@",stats); [statsPage dismissModalViewControllerAnimated:NO]; - else { + } else { statsPage.statsArray = stats; [statsPage.tableView reloadData]; [statsPage viewWillAppear:YES]; diff -r 2480ab325057 -r dbc256913b35 project_files/HedgewarsMobile/Classes/GameSetup.m --- a/project_files/HedgewarsMobile/Classes/GameSetup.m Tue Jan 18 23:08:47 2011 +0100 +++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Wed Jan 19 01:12:55 2011 +0100 @@ -243,7 +243,6 @@ BOOL clientQuit; char const buffer[BUFFER_SIZE]; uint8_t msgSize; - int statMaxCapacity = 10-3; clientQuit = NO; csd = NULL; @@ -349,29 +348,36 @@ } break; case 'i': - if (self.statsArray == nil) - self.statsArray = [[NSMutableArray alloc] initWithCapacity:statMaxCapacity]; + if (self.statsArray == nil) { + self.statsArray = [[NSMutableArray alloc] initWithCapacity:10 - 2]; + NSMutableArray *ranking = [[NSMutableArray alloc] initWithCapacity:4]; + [self.statsArray insertObject:ranking atIndex:0]; + [ranking release]; + } NSString *tempStr = [NSString stringWithUTF8String:&buffer[2]]; - NSString *arg = [[tempStr componentsSeparatedByString:@" "] objectAtIndex:0]; + NSArray *info = [tempStr componentsSeparatedByString:@" "]; + NSString *arg = [info objectAtIndex:0]; int index = [arg length] + 3; switch (buffer[1]) { case 'r': // winning team - [self.statsArray insertObject:[NSString stringWithUTF8String:&buffer[2]] atIndex:0]; + [self.statsArray insertObject:[NSString stringWithUTF8String:&buffer[2]] atIndex:1]; break; case 'D': // best shot - [self.statsArray addObject:[NSString stringWithFormat:@"The best shot award was won by %s with %@ points", &buffer[index], arg]]; + [self.statsArray addObject:[NSString stringWithFormat:@"The best shot award won by %s (with %@ points)", &buffer[index], arg]]; break; case 'k': // best hedgehog [self.statsArray addObject:[NSString stringWithFormat:@"The best killer is %s with %@ kills in a turn", &buffer[index], arg]]; break; case 'K': // number of hogs killed - [self.statsArray addObject:[NSString stringWithFormat:@"A total of %@ hedgehog(s) were killed during this round", arg]]; + [self.statsArray addObject:[NSString stringWithFormat:@"%@ hedgehog(s) were killed during this round", arg]]; break; - case 'H': //something about team health + case 'H': // team health/graph break; case 'T': // local team stats + // still WIP in statsPage.cpp break; - case 'P': // player postion + case 'P': // teams ranking + [[self.statsArray objectAtIndex:0] addObject:tempStr]; break; case 's': // self damage [self.statsArray addObject:[NSString stringWithFormat:@"%s thought it's good to shoot his own hedgehogs with %@ points", &buffer[index], arg]]; diff -r 2480ab325057 -r dbc256913b35 project_files/HedgewarsMobile/Classes/OverlayViewController.m --- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Tue Jan 18 23:08:47 2011 +0100 +++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Wed Jan 19 01:12:55 2011 +0100 @@ -211,8 +211,6 @@ [UIView setAnimationDuration:2]; self.view.alpha = 1; [UIView commitAnimations]; - - doDim(); } -(void) numberOfScreensIncreased { diff -r 2480ab325057 -r dbc256913b35 project_files/HedgewarsMobile/Classes/SavedGamesViewController.m --- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Tue Jan 18 23:08:47 2011 +0100 +++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Wed Jan 19 01:12:55 2011 +0100 @@ -91,7 +91,6 @@ [self.listOfSavegames addObject:newSaveName]; [self.listOfSavegames sortUsingSelector:@selector(compare:)]; - //[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.listOfSavegames indexOfObject:newSaveName] inSection:0]] withRowAnimation:UITableViewRowAnimationFade]; [self.tableView reloadData]; } @@ -225,8 +224,10 @@ statsPage.modalPresentationStyle = UIModalPresentationPageSheet; [self presentModalViewController:statsPage animated:NO]; + // also modify GameConfigViewController.m NSArray *stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary]; - if ([stats count] == 0) { + if ([stats count] <= 1) { + DLog(@"%@",stats); [statsPage dismissModalViewControllerAnimated:NO]; } else { statsPage.statsArray = stats; diff -r 2480ab325057 -r dbc256913b35 project_files/HedgewarsMobile/Classes/StatsPageViewController.m --- a/project_files/HedgewarsMobile/Classes/StatsPageViewController.m Tue Jan 18 23:08:47 2011 +0100 +++ b/project_files/HedgewarsMobile/Classes/StatsPageViewController.m Wed Jan 19 01:12:55 2011 +0100 @@ -57,36 +57,61 @@ #pragma mark - #pragma mark Table view data source -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { - return 3; + return 4; } -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (section == 0 || section == 2) + if (section == 0 || section == 3) return 1; + else if (section == 1) + return [[self.statsArray objectAtIndex:0] count]; else - return [self.statsArray count] - 1; + return [self.statsArray count] - 2; } -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier0 = @"Cell0"; NSInteger section = [indexPath section]; NSInteger row = [indexPath row]; + NSString *imgString = @""; UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; if (cell == nil) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; - cell.textLabel.textAlignment = UITextAlignmentCenter; - if (section == 0) { - cell.textLabel.text = [self.statsArray objectAtIndex:row]; + if (section == 0) { // winning team + imgString = @"StatsStar"; + cell.textLabel.text = [self.statsArray objectAtIndex:1]; cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; - } else if (section == 1) { - cell.textLabel.text = [self.statsArray objectAtIndex:row + 1]; + } else if (section == 1) { // teams ranking + // color, # kills, teamname + NSArray *info = [[[self.statsArray objectAtIndex:0] objectAtIndex:row] componentsSeparatedByString:@" "]; + NSUInteger color = [[info objectAtIndex:0] intValue]; + cell.textLabel.textColor = [UIColor colorWithRed:((color >> 16) & 0xFF)/255.0f + green:((color >> 8) & 0xFF)/255.0f + blue:(color & 0xFF)/255.0f + alpha:1.0f]; + cell.textLabel.text = [NSString stringWithFormat:@"%d. %@ (%@ kills)", row+1, [info objectAtIndex:2], [info objectAtIndex:1]]; + imgString = [NSString stringWithFormat:@"statsMedal%d",row+1]; + } else if (section == 2) { // general info + imgString = @"iconDamage"; + cell.textLabel.text = [self.statsArray objectAtIndex:row + 2]; cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; - } else { + } else { // exit button cell.textLabel.text = NSLocalizedString(@"Done",@""); cell.textLabel.textColor = [UIColor whiteColor]; + cell.accessoryView = nil; + cell.imageView.image = nil; } + + UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png",BTN_DIRECTORY(),imgString]]; + UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; + cell.imageView.image = img; + [img release]; + cell.accessoryView = imgView; + [imgView release]; + + cell.textLabel.textAlignment = UITextAlignmentCenter; cell.textLabel.adjustsFontSizeToFitWidth = YES; cell.backgroundColor = [UIColor blackColor]; cell.selectionStyle = UITableViewCellSelectionStyleNone; @@ -116,7 +141,7 @@ #pragma mark - #pragma mark Table view delegate -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if ([indexPath section] == 2) + if ([indexPath section] == 3) [self dismissModalViewControllerAnimated:YES]; } diff -r 2480ab325057 -r dbc256913b35 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Tue Jan 18 23:08:47 2011 +0100 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Wed Jan 19 01:12:55 2011 +0100 @@ -2306,7 +2306,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\necho \"Copying Data...\"\ncp -R ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\n\n#copy some files from QTfrontend/res\necho \"Fetching additional graphics from QTfrontend/res...\"\nmkdir ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/btn*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/ammopic.png ${PROJECT_DIR}/Data/Graphics/Btn/iconAmmo.png\ncp ${PROJECT_DIR}/../../QTfrontend/res/icon*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels\n\necho \"Removing text and dummy files...\"\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.svgz -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\nfind ${PROJECT_DIR}/Data -name *.orig -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps and hats, misc stuff\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,Ruler}\nrm -rf ${PROJECT_DIR}/Data/Hats/{TeamCap,TeamHeadband,TeamHair}\nrm -rf ${PROJECT_DIR}/Data/misc/\n\n#delete forbidden maps\nrm -rf ${PROJECT_DIR}/Data/Maps/{Cheese,FlightJoust}\n\n#delete the Classic voice\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/Classic\n\n#delete useless fonts\nrm -rf ${PROJECT_DIR}/Data/Fonts/{wqy-zenhei.ttc,DroidSansFallback.ttf}\n\n#delete all names, reserved hats\nrm -rf ${PROJECT_DIR}/Data/Names/\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/\n\necho \"Copying mono audio...\"\n#copy mono audio\ncp -R ${PROJECT_DIR}/audio/* ${PROJECT_DIR}/Data/\n\necho \"Tweaking Data contents...\"\n#move Lua maps in Missions\nmkdir ${PROJECT_DIR}/Data/Missions/Maps/\nmv ${PROJECT_DIR}/Data/Maps/{Basketball,Knockball,TrophyRace,CTF_Blizzard,Control} ${PROJECT_DIR}/Data/Missions/Maps/\n#workaround for missing map in CTF_Blizzard\nln -s ../../../Maps/Blizzard/map.png ${PROJECT_DIR}/Data/Missions/Maps/CTF_Blizzard/map.png\n\n#reduce the number of flakes for City\nawk '{if ($1 == 1500) $1=40; print $0}' < ${PROJECT_DIR}/Data/Themes/City/theme.cfg > /tmp/tempfile\nmv /tmp/tempfile ${PROJECT_DIR}/Data/Themes/City/theme.cfg\n\n#remove Isalnd from the list of Themes\nawk '{if ($1 != \"Island\") print $0}' < ${PROJECT_DIR}/Data/Themes/themes.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Themes/themes.cfg\n\n#remove Isalnd from the Maps and themes\nrm -rf ${PROJECT_DIR}/Data/Themes/Island\nawk '{if ($1 == \"Island\") print \"Nature\"}' < ${PROJECT_DIR}/Data/Maps/Cave/map.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Maps/Cave/map.cfg\nawk '{if ($1 == \"Island\") print \"Nature\"}' < ${PROJECT_DIR}/Data/Maps/Lonely_Island/map.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Maps/Lonely_Island/map.cfg\nawk '{if ($1 == \"Island\") print \"Nature\"}' < ${PROJECT_DIR}/Data/Maps/PirateFlag/map.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Maps/PirateFlag/map.cfg\n\necho \"Done\""; + shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\necho \"Copying Data...\"\ncp -R ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\n\n#copy some files from QTfrontend/res\necho \"Fetching additional graphics from QTfrontend/res...\"\nmkdir ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/btn*.png ${PROJECT_DIR}/Data/Graphics/Btn/\ncp ${PROJECT_DIR}/../../QTfrontend/res/icon*.png ${PROJECT_DIR}/Data/Graphics/Btn/\ncp ${PROJECT_DIR}/../../QTfrontend/res/StatsMedal*.png ${PROJECT_DIR}/Data/Graphics/Btn/\ncp ${PROJECT_DIR}/../../QTfrontend/res/StatsR.png ${PROJECT_DIR}/Data/Graphics/Btn/StatsStar.png\ncp ${PROJECT_DIR}/../../QTfrontend/res/ammopic.png ${PROJECT_DIR}/Data/Graphics/Btn/iconAmmo.png\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels/\n\necho \"Removing text and dummy files...\"\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.svgz -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\nfind ${PROJECT_DIR}/Data -name *.orig -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps and hats, misc stuff\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,Ruler}\nrm -rf ${PROJECT_DIR}/Data/Hats/{TeamCap,TeamHeadband,TeamHair}\nrm -rf ${PROJECT_DIR}/Data/misc/\n\n#delete forbidden maps\nrm -rf ${PROJECT_DIR}/Data/Maps/{Cheese,FlightJoust}\n\n#delete the Classic voice\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/Classic\n\n#delete useless fonts\nrm -rf ${PROJECT_DIR}/Data/Fonts/{wqy-zenhei.ttc,DroidSansFallback.ttf}\n\n#delete all names, reserved hats\nrm -rf ${PROJECT_DIR}/Data/Names/\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/\n\necho \"Copying mono audio...\"\n#copy mono audio\ncp -R ${PROJECT_DIR}/audio/* ${PROJECT_DIR}/Data/\n\necho \"Tweaking Data contents...\"\n#move Lua maps in Missions\nmkdir ${PROJECT_DIR}/Data/Missions/Maps/\nmv ${PROJECT_DIR}/Data/Maps/{Basketball,Knockball,TrophyRace,CTF_Blizzard,Control} ${PROJECT_DIR}/Data/Missions/Maps/\n#workaround for missing map in CTF_Blizzard\nln -s ../../../Maps/Blizzard/map.png ${PROJECT_DIR}/Data/Missions/Maps/CTF_Blizzard/map.png\n\n#reduce the number of flakes for City\nawk '{if ($1 == 1500) $1=40; print $0}' < ${PROJECT_DIR}/Data/Themes/City/theme.cfg > /tmp/tempfile\nmv /tmp/tempfile ${PROJECT_DIR}/Data/Themes/City/theme.cfg\n\n#remove Isalnd from the list of Themes\nawk '{if ($1 != \"Island\") print $0}' < ${PROJECT_DIR}/Data/Themes/themes.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Themes/themes.cfg\n\n#remove Isalnd from the Maps and themes\nrm -rf ${PROJECT_DIR}/Data/Themes/Island\nawk '{if ($1 == \"Island\") print \"Nature\"}' < ${PROJECT_DIR}/Data/Maps/Cave/map.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Maps/Cave/map.cfg\nawk '{if ($1 == \"Island\") print \"Nature\"}' < ${PROJECT_DIR}/Data/Maps/Lonely_Island/map.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Maps/Lonely_Island/map.cfg\nawk '{if ($1 == \"Island\") print \"Nature\"}' < ${PROJECT_DIR}/Data/Maps/PirateFlag/map.cfg > /tmp/tempfile && mv /tmp/tempfile ${PROJECT_DIR}/Data/Maps/PirateFlag/map.cfg\n\necho \"Done\""; showEnvVarsInLog = 0; }; 9283011B0F10CB2D00CC5A3C /* Build libfpc.a */ = {