project_files/HedgewarsMobile/Classes/ObjcExports.m
changeset 4034 634a8c8682de
parent 4028 eb371ada631d
child 4362 8dae325dc625
equal deleted inserted replaced
4032:4aeab704d006 4034:634a8c8682de
    31 NSInteger grenadeTime;
    31 NSInteger grenadeTime;
    32 
    32 
    33 #pragma mark -
    33 #pragma mark -
    34 #pragma mark functions called like oop
    34 #pragma mark functions called like oop
    35 void objcExportsInit() {
    35 void objcExportsInit() {
    36         gameRunning = NO;
    36     gameRunning = NO;
    37         savedGame = NO;
    37     savedGame = NO;
    38         grenadeTime = 2;
    38     grenadeTime = 2;
    39 }
    39 }
    40 
    40 
    41 BOOL inline isGameRunning() {
    41 BOOL inline isGameRunning() {
    42     return gameRunning;
    42     return gameRunning;
    43 }
    43 }
    54     grenadeTime = value;
    54     grenadeTime = value;
    55 }
    55 }
    56 
    56 
    57 #pragma mark -
    57 #pragma mark -
    58 #pragma mark functions called by pascal code
    58 #pragma mark functions called by pascal code
    59 // called by uStore from AddProgress
       
    60 void startSpinning() {
    59 void startSpinning() {
    61     gameRunning = NO;
    60     gameRunning = NO;
    62     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
    61     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
    63     UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    62     UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    64     indicator.tag = ACTIVITYINDICATOR_TAG;
    63     indicator.tag = ACTIVITYINDICATOR_TAG;
    75     [indicator startAnimating];
    74     [indicator startAnimating];
    76     [theWindow addSubview:indicator];
    75     [theWindow addSubview:indicator];
    77     [indicator release];
    76     [indicator release];
    78 }
    77 }
    79 
    78 
    80 // called by uStore from FinishProgress and by OverlayViewController by replayBegan
       
    81 void stopSpinning() {
    79 void stopSpinning() {
    82     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
    80     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
    83     UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[theWindow viewWithTag:ACTIVITYINDICATOR_TAG];
    81     UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[theWindow viewWithTag:ACTIVITYINDICATOR_TAG];
    84     [indicator stopAnimating];
    82     [indicator stopAnimating];
    85     HW_zoomSet(1.7);
    83     HW_zoomSet(1.7);
    86     if (savedGame == NO)
    84     if (savedGame == NO)
    87         gameRunning = YES;
    85         gameRunning = YES;
    88 }
    86 }
    89 
    87 
    90 // called by CCHandlers from chNextTurn
       
    91 void clearView() {
    88 void clearView() {
    92     UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
    89     UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
    93     UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
    90     UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
    94     UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
    91     UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
    95 
    92 
   105         [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:ANIMATION_DURATION];
   102         [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:ANIMATION_DURATION];
   106 
   103 
   107     grenadeTime = 2;
   104     grenadeTime = 2;
   108 }
   105 }
   109 
   106 
   110 // called by hwengine
       
   111 void replayBegan() {
   107 void replayBegan() {
   112     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
   108     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
   113     UIView *blackView = [[UIView alloc] initWithFrame:theWindow.frame];
   109     UIView *blackView = [[UIView alloc] initWithFrame:theWindow.frame];
   114     blackView.backgroundColor = [UIColor blackColor];
   110     blackView.backgroundColor = [UIColor blackColor];
   115     blackView.alpha = 0.6;
   111     blackView.alpha = 0.6;
   128 
   124 
   129     savedGame = YES;
   125     savedGame = YES;
   130     stopSpinning();
   126     stopSpinning();
   131 }
   127 }
   132 
   128 
   133 // called by uGame
       
   134 void replayFinished() {
   129 void replayFinished() {
   135     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
   130     UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
   136     UIView *blackView = (UIView *)[theWindow viewWithTag:REPLAYBLACKVIEW_TAG];
   131     UIView *blackView = (UIView *)[theWindow viewWithTag:REPLAYBLACKVIEW_TAG];
   137 
   132 
   138     [UIView beginAnimations:@"removing black" context:NULL];
   133     [UIView beginAnimations:@"removing black" context:NULL];
   142     [theWindow performSelector:@selector(removeFromSuperview) withObject:blackView afterDelay:1];
   137     [theWindow performSelector:@selector(removeFromSuperview) withObject:blackView afterDelay:1];
   143 
   138 
   144     gameRunning = YES;
   139     gameRunning = YES;
   145     savedGame = NO;
   140     savedGame = NO;
   146 }
   141 }
       
   142 
       
   143 void updateVisualsNewTurn(void) {
       
   144     [[NSNotificationCenter defaultCenter] postNotificationName:@"updateAmmoVisuals" object:nil];
       
   145 }