unify stats display on ipad and non-ipad and on saved and normal games
authorkoda
Fri, 31 Dec 2010 01:15:43 +0100
changeset 4763 c228a4841e3f
parent 4760 224c31b3ce7d
child 4766 255e6c76c7e9
unify stats display on ipad and non-ipad and on saved and normal games
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/SavedGamesViewController.m
project_files/HedgewarsMobile/Classes/StatsPageViewController.m
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Fri Dec 31 00:10:38 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Fri Dec 31 01:15:43 2010 +0100
@@ -232,25 +232,25 @@
                                       [NSNumber numberWithBool:NO],@"netgame",
                                       @"",@"savefile",
                                       nil];
-    if (IS_IPAD())
-        [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
-    else {
-        // this causes a sporadic crash on the ipad but without this rotation doesn't work on iphone
-        StatsPageViewController *statsPage = [[StatsPageViewController alloc] initWithStyle:UITableViewStyleGrouped];
-        [self presentModalViewController:statsPage animated:NO];
+
+
+    StatsPageViewController *statsPage = [[StatsPageViewController alloc] initWithStyle:UITableViewStyleGrouped];
+    statsPage.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
+    if ([statsPage respondsToSelector:@selector(setModalPresentationStyle:)])
+        statsPage.modalPresentationStyle = UIModalPresentationPageSheet;
+    [self presentModalViewController:statsPage animated:NO];
 
-        NSArray *stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
-        if ([stats count] == 0)
-            [statsPage dismissModalViewControllerAnimated:NO];
-        else {
-            statsPage.statsArray = stats;
-            [statsPage.tableView reloadData];
-            [statsPage viewWillAppear:YES];
-        }
-
-        [statsPage release];
+    NSArray *stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
+    if ([stats count] == 0)
+        [statsPage dismissModalViewControllerAnimated:NO];
+    else {
+        statsPage.statsArray = stats;
+        [statsPage.tableView reloadData];
+        [statsPage viewWillAppear:YES];
     }
 
+
+    [statsPage release];
 }
 
 -(void) loadNiceHogs {
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m	Fri Dec 31 00:10:38 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m	Fri Dec 31 01:15:43 2010 +0100
@@ -21,6 +21,7 @@
 
 #import "SavedGamesViewController.h"
 #import "SDL_uikitappdelegate.h"
+#import "StatsPageViewController.h"
 #import "CommodityFunctions.h"
 
 @implementation SavedGamesViewController
@@ -217,8 +218,23 @@
                                       [NSNumber numberWithBool:NO],@"netgame",
                                       [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:self.interfaceOrientation] forKey:@"orientation"],@"game_dictionary",
                                       nil];
-    [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
-    [self.parentViewController dismissModalViewControllerAnimated:NO];
+
+    StatsPageViewController *statsPage = [[StatsPageViewController alloc] initWithStyle:UITableViewStyleGrouped];
+    statsPage.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
+    if ([statsPage respondsToSelector:@selector(setModalPresentationStyle:)])
+        statsPage.modalPresentationStyle = UIModalPresentationPageSheet;
+    [self presentModalViewController:statsPage animated:NO];
+
+    NSArray *stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
+    if ([stats count] == 0) {
+        [statsPage dismissModalViewControllerAnimated:NO];
+    } else {
+        statsPage.statsArray = stats;
+        [statsPage.tableView reloadData];
+        [statsPage viewWillAppear:YES];
+    }
+    // reload needed because when ending game the entry remains there
+    [self.tableView reloadData];
 }
 
 #pragma mark -
--- a/project_files/HedgewarsMobile/Classes/StatsPageViewController.m	Fri Dec 31 00:10:38 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/StatsPageViewController.m	Fri Dec 31 01:15:43 2010 +0100
@@ -57,7 +57,7 @@
     } else if (section == 1) {
         cell.textLabel.text = [self.statsArray objectAtIndex:row + 1];
     } else {
-        cell.textLabel.text = NSLocalizedString(@"Back",@"");
+        cell.textLabel.text = NSLocalizedString(@"Done",@"");
     }
 
     return cell;