# HG changeset patch # User koda # Date 1316896072 -7200 # Node ID 3b86826f666585096f766f45909c6810d935d954 # Parent 24631fd2fb9eb4a22f0f8ca95128a33fa432a285 add a class method for getting the overlay (and fix a silly mistake while at it) and use it diff -r 24631fd2fb9e -r 3b86826f6665 project_files/HedgewarsMobile/Classes/GameInterfaceBridge.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; diff -r 24631fd2fb9e -r 3b86826f6665 project_files/HedgewarsMobile/Classes/ObjcExports.h --- 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); diff -r 24631fd2fb9e -r 3b86826f6665 project_files/HedgewarsMobile/Classes/ObjcExports.m --- 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; diff -r 24631fd2fb9e -r 3b86826f6665 project_files/HedgewarsMobile/Classes/OverlayViewController.h --- 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; diff -r 24631fd2fb9e -r 3b86826f6665 project_files/HedgewarsMobile/Classes/OverlayViewController.m --- 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;