add a class method for getting the overlay (and fix a silly mistake while at it) and use it
authorkoda
Sat, 24 Sep 2011 22:27:52 +0200
changeset 6018 3b86826f6665
parent 6017 24631fd2fb9e
child 6019 8843ea756cfc
add a class method for getting the overlay (and fix a silly mistake while at it) and use it
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
project_files/HedgewarsMobile/Classes/ObjcExports.h
project_files/HedgewarsMobile/Classes/ObjcExports.m
project_files/HedgewarsMobile/Classes/OverlayViewController.h
project_files/HedgewarsMobile/Classes/OverlayViewController.m
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sat Sep 24 21:54:11 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sat Sep 24 22:27:52 2011 +0200
@@ -121,7 +121,7 @@
     [localeString release];
     [ipcString release];
 
-    objcExportsInit(self.overlayController);
+    objcExportsInit();
 
     // this is the pascal fuction that starts the game, wrapped around isInGame
     [HedgewarsAppDelegate sharedAppDelegate].isInGame = YES;
--- a/project_files/HedgewarsMobile/Classes/ObjcExports.h	Sat Sep 24 21:54:11 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.h	Sat Sep 24 22:27:52 2011 +0200
@@ -19,17 +19,15 @@
  */
 
 
-@class OverlayViewController;
-
-void objcExportsInit(OverlayViewController *instance);
-BOOL isGameRunning();
+void objcExportsInit(void);
+BOOL isGameRunning(void);
 void setGameRunning(BOOL value);
-NSInteger cachedGrenadeTime();
-void clearView();
+NSInteger cachedGrenadeTime(void);
+void clearView(void);
 void setGrenadeTime(NSInteger value);
 BOOL isApplePhone(void);
 
-void startSpinningProgress();
-void stopSpinningProgress();
-void saveBeganSynching();
-void saveFinishedSynching();
+void startSpinningProgress(void);
+void stopSpinningProgress(void);
+void saveBeganSynching(void);
+void saveFinishedSynching(void);
--- a/project_files/HedgewarsMobile/Classes/ObjcExports.m	Sat Sep 24 21:54:11 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.m	Sat Sep 24 22:27:52 2011 +0200
@@ -37,8 +37,8 @@
 
 #pragma mark -
 #pragma mark functions called like oop
-void objcExportsInit(OverlayViewController* instance) {
-    overlay_instance = instance;
+void objcExportsInit() {
+    overlay_instance = [OverlayViewController mainOverlay];
     gameRunning = NO;
     savedGame = NO;
     grenadeTime = 2;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Sat Sep 24 21:54:11 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Sat Sep 24 22:27:52 2011 +0200
@@ -67,6 +67,8 @@
 @property (assign) NSInteger initialScreenCount;
 
 
++(OverlayViewController *)mainOverlay;
+
 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
 -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Sep 24 21:54:11 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Sep 24 22:27:52 2011 +0200
@@ -34,6 +34,8 @@
 #define doNotDim()          [dimTimer setFireDate:HIDING_TIME_NEVER]
 
 
+static OverlayViewController *mainOverlay;
+
 @implementation OverlayViewController
 @synthesize popoverController, popupMenu, helpPage, amvc, initialScreenCount, lowerIndicator, savesIndicator,
             confirmButton, grenadeTimeSegment;
@@ -47,17 +49,22 @@
 
 #pragma mark -
 #pragma mark View Management
--(id) initWithCoder:(NSCoder *)aDecoder {
-    if ((self = [super initWithCoder:aDecoder])) {
+-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
+    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
         isAttacking = NO;
         isPopoverVisible = NO;
         initialScreenCount = (IS_DUALHEAD() ? 2 : 1);
         lowerIndicator = nil;
         savesIndicator = nil;
+        mainOverlay = self;
     }
     return self;
 }
 
++(OverlayViewController *)mainOverlay {
+    return mainOverlay;
+}
+
 -(void) viewDidLoad {
     // fill all the screen available as sdlview disables autoresizing
     CGRect rect = [[UIScreen mainScreen] bounds];
@@ -108,6 +115,7 @@
 
     // only objects initialized in viewDidLoad should be here
     dimTimer = nil;
+    mainOverlay = nil;
     self.helpPage = nil;
     [self dismissPopover];
     self.popoverController = nil;