author | koda |
Sat, 12 Nov 2011 19:00:31 +0100 | |
branch | hedgeroid |
changeset 6344 | cba81e10235c |
parent 6328 | d14adf1c7721 |
child 6415 | af2047bb4f70 |
permissions | -rw-r--r-- |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
1 |
/* |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
4 |
* |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
8 |
* |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
13 |
* |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
17 |
* |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
18 |
* File created on 18/04/2011. |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
19 |
*/ |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
20 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
21 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
22 |
#import "GameInterfaceBridge.h" |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
23 |
#import "EngineProtocolNetwork.h" |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
24 |
#import "OverlayViewController.h" |
5158
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
25 |
#import "StatsPageViewController.h" |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5709
diff
changeset
|
26 |
#import "AudioManagerController.h" |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5166
diff
changeset
|
27 |
#import "ObjcExports.h" |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
28 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
29 |
@implementation GameInterfaceBridge |
6344 | 30 |
@synthesize blackView; |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
31 |
|
6344 | 32 |
#pragma mark - |
33 |
#pragma mark Instance methods for engine interaction |
|
34 |
// prepares the controllers for hosting a game |
|
35 |
-(void) earlyEngineLaunch:(NSString *)pathOrNil withOptions:(NSDictionary *)optionsOrNil { |
|
36 |
[self retain]; |
|
37 |
[AudioManagerController stopBackgroundMusic]; |
|
38 |
[EngineProtocolNetwork spawnThread:pathOrNil withOptions:optionsOrNil]; |
|
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
39 |
|
6344 | 40 |
// add a black view hiding the background |
41 |
CGRect theFrame = [[UIScreen mainScreen] bounds]; |
|
42 |
UIWindow *thisWindow = [[HedgewarsAppDelegate sharedAppDelegate] uiwindow]; |
|
43 |
self.blackView = [[UIView alloc] initWithFrame:theFrame]; |
|
44 |
self.blackView.opaque = YES; |
|
45 |
self.blackView.backgroundColor = [UIColor blackColor]; |
|
46 |
self.blackView.alpha = 0; |
|
47 |
[UIView beginAnimations:@"fade out" context:NULL]; |
|
48 |
[UIView setAnimationDuration:1]; |
|
49 |
self.blackView.alpha = 1; |
|
50 |
[UIView commitAnimations]; |
|
51 |
[thisWindow addSubview:self.blackView]; |
|
52 |
[self.blackView release]; |
|
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
53 |
|
6344 | 54 |
// keep track of uncompleted games |
55 |
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; |
|
56 |
[userDefaults setObject:pathOrNil forKey:@"savedGamePath"]; |
|
57 |
[userDefaults synchronize]; |
|
58 |
||
59 |
// let's launch the engine using this -perfomSelector so that the runloop can deal with queued messages first |
|
60 |
[self performSelector:@selector(engineLaunch:) withObject:pathOrNil afterDelay:0.1f]; |
|
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
61 |
} |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
62 |
|
6344 | 63 |
// cleans up everything |
64 |
-(void) lateEngineLaunch { |
|
65 |
// remove completed games notification |
|
66 |
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; |
|
67 |
[userDefaults setObject:@"" forKey:@"savedGamePath"]; |
|
68 |
[userDefaults synchronize]; |
|
6301
1259736c0134
engine interaction class refactoring, round 4 or 5, can't remember: this time use the class methods to create an instance object and operates on that, reducing the number of arguments between methods and simplifying memory management
koda
parents:
6276
diff
changeset
|
69 |
|
6344 | 70 |
// remove the cover view with a transition |
71 |
self.blackView.alpha = 1; |
|
72 |
[UIView beginAnimations:@"fade in" context:NULL]; |
|
73 |
[UIView setAnimationDuration:1]; |
|
74 |
self.blackView.alpha = 0; |
|
75 |
[UIView commitAnimations]; |
|
76 |
[self.blackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
|
77 |
||
78 |
// the overlay is not needed any more and can be removed |
|
79 |
[[OverlayViewController mainOverlay] removeOverlay]; |
|
80 |
||
81 |
// restart music and we're done |
|
82 |
[AudioManagerController playBackgroundMusic]; |
|
83 |
[self release]; |
|
6301
1259736c0134
engine interaction class refactoring, round 4 or 5, can't remember: this time use the class methods to create an instance object and operates on that, reducing the number of arguments between methods and simplifying memory management
koda
parents:
6276
diff
changeset
|
84 |
} |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
85 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
86 |
// main routine for calling the actual game engine |
6344 | 87 |
-(void) engineLaunch:(NSString *)pathOrNil { |
5156 | 88 |
const char *gameArgs[11]; |
6209 | 89 |
CGFloat width, height; |
6344 | 90 |
NSInteger enginePort = [EngineProtocolNetwork activeEnginePort]; |
6209 | 91 |
CGFloat screenScale = [[UIScreen mainScreen] safeScale]; |
6344 | 92 |
NSString *ipcString = [[NSString alloc] initWithFormat:@"%d",enginePort]; |
93 |
NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt",[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
|
5206 | 94 |
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
95 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
96 |
if (IS_DUALHEAD()) { |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
97 |
CGRect screenBounds = [[[UIScreen screens] objectAtIndex:1] bounds]; |
6209 | 98 |
width = screenBounds.size.width; |
99 |
height = screenBounds.size.height; |
|
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
100 |
} else { |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
101 |
CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
6209 | 102 |
width = screenBounds.size.height; |
103 |
height = screenBounds.size.width; |
|
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
104 |
} |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
105 |
|
6209 | 106 |
NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", (int)(width * screenScale)]; |
107 |
NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", (int)(height * screenScale)]; |
|
6344 | 108 |
NSString *resourcePath = [[NSString alloc] initWithFormat:@"%@/Data", [[NSBundle mainBundle] resourcePath]]; |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
109 |
|
6078
8c0cc07731e5
headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents:
6020
diff
changeset
|
110 |
NSString *modelId = [HWUtils modelType]; |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
111 |
NSInteger tmpQuality; |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
112 |
if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"]) // = iPhone and iPhone 3G or iPod Touch or iPod Touch 2G |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
113 |
tmpQuality = 0x00000001 | 0x00000002 | 0x00000008 | 0x00000040; // rqLowRes | rqBlurryLand | rqSimpleRope | rqKillFlakes |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
114 |
else if ([modelId hasPrefix:@"iPhone2"] || [modelId hasPrefix:@"iPod3"]) // = iPhone 3GS or iPod Touch 3G |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
115 |
tmpQuality = 0x00000002 | 0x00000040; // rqBlurryLand | rqKillFlakes |
5709 | 116 |
else if ([modelId hasPrefix:@"iPad1"] || [modelId hasPrefix:@"iPod4"]) // = iPad 1G or iPod Touch 4G |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
117 |
tmpQuality = 0x00000002; // rqBlurryLand |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
118 |
else // = everything else |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
119 |
tmpQuality = 0; // full quality |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
120 |
|
6344 | 121 |
// disable ammomenu animation |
122 |
tmpQuality = tmpQuality | 0x00000080; |
|
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
123 |
// disable tooltips on iPhone |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
124 |
if (IS_IPAD() == NO) |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
125 |
tmpQuality = tmpQuality | 0x00000400; |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
126 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
127 |
// prevents using an empty nickname |
5206 | 128 |
NSString *username = [settings objectForKey:@"username"]; |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
129 |
if ([username length] == 0) |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
130 |
username = [NSString stringWithFormat:@"MobileUser-%@",ipcString]; |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
131 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
132 |
gameArgs[ 0] = [ipcString UTF8String]; //ipcPort |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
133 |
gameArgs[ 1] = [horizontalSize UTF8String]; //cScreenWidth |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
134 |
gameArgs[ 2] = [verticalSize UTF8String]; //cScreenHeight |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
135 |
gameArgs[ 3] = [[NSString stringWithFormat:@"%d",tmpQuality] UTF8String]; //quality |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
136 |
gameArgs[ 4] = "en.txt";//[localeString UTF8String]; //cLocaleFName |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
137 |
gameArgs[ 5] = [username UTF8String]; //UserNick |
5206 | 138 |
gameArgs[ 6] = [[[settings objectForKey:@"sound"] stringValue] UTF8String]; //isSoundEnabled |
139 |
gameArgs[ 7] = [[[settings objectForKey:@"music"] stringValue] UTF8String]; //isMusicEnabled |
|
140 |
gameArgs[ 8] = [[[settings objectForKey:@"alternate"] stringValue] UTF8String]; //cAltDamage |
|
6344 | 141 |
gameArgs[ 9] = [resourcePath UTF8String]; //PathPrefix |
142 |
gameArgs[10] = ([HWUtils gameType] == gtSave) ? [pathOrNil UTF8String] : NULL; //recordFileName |
|
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
143 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
144 |
[verticalSize release]; |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
145 |
[horizontalSize release]; |
6344 | 146 |
[resourcePath release]; |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
147 |
[localeString release]; |
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
148 |
[ipcString release]; |
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
149 |
|
6344 | 150 |
[HWUtils setGameStatus:gsLoading]; |
151 |
||
152 |
// this is the pascal function that starts the game |
|
153 |
Game(gameArgs); |
|
154 |
[self lateEngineLaunch]; |
|
155 |
} |
|
5194 | 156 |
|
6344 | 157 |
#pragma mark - |
158 |
#pragma mark Class methods for setting up the engine from outsite |
|
159 |
+(void) startGame:(TGameType) type atPath:(NSString *)path withOptions:(NSDictionary *)config { |
|
160 |
[HWUtils setGameType:type]; |
|
161 |
GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] init]; |
|
162 |
[bridge earlyEngineLaunch:path withOptions:config]; |
|
163 |
[bridge release]; |
|
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
164 |
} |
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
165 |
|
6344 | 166 |
+(void) startLocalGame:(NSDictionary *)withOptions { |
167 |
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init]; |
|
168 |
[outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"]; |
|
169 |
NSString *savePath = [[NSString alloc] initWithFormat:@"%@%@.hws",SAVES_DIRECTORY(),[outputFormatter stringFromDate:[NSDate date]]]; |
|
170 |
[outputFormatter release]; |
|
5224
6e8fbbfb0de5
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusic for the ios frontend finally
koda
parents:
5220
diff
changeset
|
171 |
|
6344 | 172 |
// in the rare case in which a savefile with the same name exists the older one must be removed (otherwise it gets corrupted) |
173 |
if ([[NSFileManager defaultManager] fileExistsAtPath:savePath]) |
|
174 |
[[NSFileManager defaultManager] removeItemAtPath:savePath error:nil]; |
|
5220
76a2246f18f0
when the match is not completed (eg out of memory or crash) the game asks for restoring it as soon as it is opened again
koda
parents:
5207
diff
changeset
|
175 |
|
6344 | 176 |
[self startGame:gtLocal atPath:savePath withOptions:withOptions]; |
177 |
[savePath release]; |
|
6321 | 178 |
} |
179 |
||
6344 | 180 |
+(void) startSaveGame:(NSString *)atPath { |
181 |
[self startGame:gtSave atPath:atPath withOptions:nil]; |
|
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
182 |
} |
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
183 |
|
6344 | 184 |
+(void) startMissionGame:(NSString *)withScript { |
185 |
NSString *missionPath = [[NSString alloc] initWithFormat:@"escript Missions/Training/%@.lua",withScript]; |
|
186 |
NSDictionary *missionLine = [[NSDictionary alloc] initWithObjectsAndKeys:missionPath,@"mission_command",nil]; |
|
187 |
[missionPath release]; |
|
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
188 |
|
6344 | 189 |
[self startGame:gtMission atPath:nil withOptions:missionLine]; |
190 |
[missionLine release]; |
|
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
191 |
} |
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
192 |
|
6344 | 193 |
/* |
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
194 |
-(void) gameHasEndedWithStats:(NSArray *)stats { |
6020
c792d4b3e080
this finally fixes the interaction between RestoredGameViewController and StatsPagesViewController
koda
parents:
6018
diff
changeset
|
195 |
// wrap this around a retain/realse to prevent being deallocated too soon |
c792d4b3e080
this finally fixes the interaction between RestoredGameViewController and StatsPagesViewController
koda
parents:
6018
diff
changeset
|
196 |
[self retain]; |
c792d4b3e080
this finally fixes the interaction between RestoredGameViewController and StatsPagesViewController
koda
parents:
6018
diff
changeset
|
197 |
// display stats page if there is something to display |
5158
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
198 |
if (stats != nil) { |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
199 |
StatsPageViewController *statsPage = [[StatsPageViewController alloc] initWithStyle:UITableViewStyleGrouped]; |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
200 |
statsPage.statsArray = stats; |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
201 |
statsPage.modalTransitionStyle = UIModalTransitionStyleCoverVertical; |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
202 |
if ([statsPage respondsToSelector:@selector(setModalPresentationStyle:)]) |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
203 |
statsPage.modalPresentationStyle = UIModalPresentationPageSheet; |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
204 |
|
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
205 |
[self.parentController presentModalViewController:statsPage animated:YES]; |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
206 |
[statsPage release]; |
4941df038b95
stats implemented once again! refactoring complete \o/
koda
parents:
5157
diff
changeset
|
207 |
} |
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
208 |
|
5157 | 209 |
// can remove the savefile if the replay has ended |
6344 | 210 |
if ([HWUtils gameType] == gtSave) |
5157 | 211 |
[[NSFileManager defaultManager] removeItemAtPath:self.savePath error:nil]; |
6020
c792d4b3e080
this finally fixes the interaction between RestoredGameViewController and StatsPagesViewController
koda
parents:
6018
diff
changeset
|
212 |
[self release]; |
5155
f2165724605c
more refactoring, less warnings, less stuff kept around
koda
parents:
5154
diff
changeset
|
213 |
} |
6344 | 214 |
*/ |
5154
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
215 |
|
851f36579ed4
initial refactoring for interfacing the game engine from the ios frontend (game doesn't run yet)
koda
parents:
diff
changeset
|
216 |
@end |