project_files/HedgewarsMobile/Classes/ObjcExports.m
changeset 6822 206db098f8c5
parent 6700 e04da46ee43c
child 6832 fae8fd118da9
equal deleted inserted replaced
6821:d4f75843cf5d 6822:206db098f8c5
    20 
    20 
    21 
    21 
    22 #import "ObjcExports.h"
    22 #import "ObjcExports.h"
    23 #import "OverlayViewController.h"
    23 #import "OverlayViewController.h"
    24 
    24 
    25 
       
    26 // cache the grenade time
       
    27 static NSInteger grenadeTime;
       
    28 // the reference to the newMenu instance
    25 // the reference to the newMenu instance
    29 static OverlayViewController *overlay_instance;
    26 static OverlayViewController *overlay_instance;
    30 
       
    31 @implementation ObjcExports
       
    32 
       
    33 +(void) setGrenadeTime:(NSInteger) value {
       
    34     grenadeTime = value;
       
    35 }
       
    36 
       
    37 +(NSInteger) grenadeTime {
       
    38     return grenadeTime;
       
    39 }
       
    40 
       
    41 @end
       
    42 
       
    43 
    27 
    44 #pragma mark -
    28 #pragma mark -
    45 #pragma mark functions called by pascal code
    29 #pragma mark functions called by pascal code
    46 BOOL inline isApplePhone() {
    30 BOOL inline isApplePhone() {
    47     return (IS_IPAD() == NO);
    31     return (IS_IPAD() == NO);
    49 
    33 
    50 void startLoadingIndicator() {
    34 void startLoadingIndicator() {
    51     // this is the first ojbc function called by engine, so we have to initialize some variables here
    35     // this is the first ojbc function called by engine, so we have to initialize some variables here
    52     overlay_instance = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
    36     overlay_instance = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
    53     // in order to get rotation events we have to insert the view inside the first view of the second window
    37     // in order to get rotation events we have to insert the view inside the first view of the second window
    54     //TODO: when multihead make sure that overlay is displayed in the touch-enabled window
       
    55     [[HWUtils mainSDLViewInstance] addSubview:overlay_instance.view];
    38     [[HWUtils mainSDLViewInstance] addSubview:overlay_instance.view];
    56     grenadeTime = 2;
       
    57 
    39 
    58     if ([HWUtils gameType] == gtSave) {
    40     if ([HWUtils gameType] == gtSave) {
    59         [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    41         [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    60 
    42 
    61         overlay_instance.view.backgroundColor = [UIColor blackColor];
    43         overlay_instance.view.backgroundColor = [UIColor blackColor];
   100     [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
    82     [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
   101     [HWUtils setGameStatus:gsInGame];
    83     [HWUtils setGameStatus:gsInGame];
   102 }
    84 }
   103 
    85 
   104 void clearView() {
    86 void clearView() {
   105     // don't use any engine calls here as this function is called every time the ammomenu is opened
    87     [overlay_instance clearOverlay];
   106     [UIView beginAnimations:@"remove button" context:NULL];
       
   107     [UIView setAnimationDuration:ANIMATION_DURATION];
       
   108     overlay_instance.confirmButton.alpha = 0;
       
   109     overlay_instance.grenadeTimeSegment.alpha = 0;
       
   110     [UIView commitAnimations];
       
   111 
       
   112     if (overlay_instance.confirmButton)
       
   113         [overlay_instance.confirmButton performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
       
   114     if (overlay_instance.grenadeTimeSegment) {
       
   115         [overlay_instance.grenadeTimeSegment performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
       
   116         overlay_instance.grenadeTimeSegment.tag = 0;
       
   117     }
       
   118     grenadeTime = 2;
       
   119 }
    88 }
   120 
    89 
   121 // dummy function to prevent linkage fail
    90 // dummy function to prevent linkage fail
   122 int SDL_main(int argc, char **argv) {
    91 int SDL_main(int argc, char **argv) {
   123     return 0;
    92     return 0;