project_files/HedgewarsMobile/Classes/MainMenuViewController.m
changeset 3884 d7479079a8a8
parent 3829 81db3c85784b
child 3891 f8f0d0ceb19c
equal deleted inserted replaced
3883:5934ddf9ed5d 3884:d7479079a8a8
    50     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    50     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    51     // do somthing in the future
    51     // do somthing in the future
    52     [pool release];
    52     [pool release];
    53 }
    53 }
    54 
    54 
    55 -(void) viewDidLoad {
    55 // check if some configuration files are already set; if they are present it means that the current copy must be updated
    56     [NSThread detachNewThreadSelector:@selector(initAudioThread)
    56 -(void) createNecessaryFiles {
    57                              toTarget:self
       
    58                            withObject:nil];
       
    59 
       
    60     char *ver;
       
    61     HW_versionInfo(NULL, &ver);
       
    62     NSString *versionNumber = [[NSString alloc] initWithCString:ver];
       
    63     self.versionLabel.text = @"";//versionNumber;
       
    64     [versionNumber release];
       
    65 
       
    66     // listen to request to remove the modalviewcontroller
       
    67     [[NSNotificationCenter defaultCenter] addObserver:self
       
    68                                              selector:@selector(dismissModalViewController)
       
    69                                                  name: @"dismissModalView"
       
    70                                                object:nil];
       
    71     
       
    72     // now check if some configuration files are already set; if they are present it means that the current copy must be updated
       
    73     BOOL doCreateFiles = NO;
    57     BOOL doCreateFiles = NO;
    74     NSString *resDir = [[NSBundle mainBundle] resourcePath];
    58     NSString *resDir = [[NSBundle mainBundle] resourcePath];
    75     
    59     
    76     NSString *versionFileToCheck = [NSString stringWithFormat:@"%@/version.txt",DOCUMENTS_FOLDER()];
    60     NSString *versionFileToCheck = [NSString stringWithFormat:@"%@/version.txt",DOCUMENTS_FOLDER()];
    77     if ([[NSFileManager defaultManager] fileExistsAtPath:versionFileToCheck]) {
    61     if ([[NSFileManager defaultManager] fileExistsAtPath:versionFileToCheck]) {
   157         DLog(@"Success");
   141         DLog(@"Success");
   158         
   142         
   159         if (err != nil) 
   143         if (err != nil) 
   160             DLog(@"%@", err);
   144             DLog(@"%@", err);
   161     }
   145     }
       
   146 }
       
   147 
       
   148 /* // ask the user to leave a review for this app
       
   149 -(void) reviewCounter {
       
   150     CGFloat reviewInt = [[NSUserDefaults standardUserDefaults] integerForKey: @"intValueKey"];
       
   151     
       
   152     if (reviewInt) {
       
   153         reviewInt++;
       
   154         [[NSUserDefaults standardUserDefaults] setInteger:reviewInt forKey:@"intValueKey"];
       
   155     } else {
       
   156         CGFloat start = 1;
       
   157         NSUserDefaults *reviewPrefs = [NSUserDefaults standardUserDefaults];
       
   158         [reviewPrefs setInteger:start forKey: @"intValueKey"];
       
   159         [reviewPrefs synchronize]; // writes modifications to disk
       
   160     }
       
   161     
       
   162     if (1) {
       
   163         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Mabuhay!"
       
   164                                                         message:@"Looks like you Enjoy using this app. Could you spare a moment of your time to review it in the AppStore?"
       
   165                                                        delegate:self
       
   166                                               cancelButtonTitle:nil
       
   167                                               otherButtonTitles: @"OK, I'll Review It Now", @"Remind Me Later", @"Don't Remind Me", nil];
       
   168         [alert show]; 
       
   169         [alert release];
       
   170         
       
   171         reviewInt++;
       
   172         
       
   173         [[NSUserDefaults standardUserDefaults] setInteger:reviewInt forKey:@"intValueKey"];
       
   174     }
       
   175 }
       
   176 
       
   177 #pragma mark -
       
   178 #pragma mark alert view delegate
       
   179 -(void) alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger) buttonIndex {
       
   180     // the user clicked one of the OK/Cancel buttons
       
   181     if (buttonIndex == 0) {
       
   182         NSString *str = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa";
       
   183         str = [NSString stringWithFormat:@"%@/wa/viewContentsUserReviews?", str]; 
       
   184         str = [NSString stringWithFormat:@"%@type=Vittorio+Giovara&id=", str];
       
   185         
       
   186         // Here is the app id from itunesconnect
       
   187         str = [NSString stringWithFormat:@"%@391234866", str]; 
       
   188         
       
   189         [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=391234866&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software"]]; 
       
   190     } else if (buttonIndex == 1) {
       
   191         int startAgain = 0;
       
   192         [[NSUserDefaults standardUserDefaults] setInteger:startAgain forKey:@"intValueKey"];
       
   193         
       
   194     } else if (buttonIndex == 2) { 
       
   195         int neverRemind = 4;
       
   196         [[NSUserDefaults standardUserDefaults] setInteger:neverRemind forKey:@"intValueKey"];
       
   197     }
       
   198 } */
       
   199 
       
   200 #pragma mark -
       
   201 -(void) viewDidLoad {
       
   202     [NSThread detachNewThreadSelector:@selector(initAudioThread)
       
   203                              toTarget:self
       
   204                            withObject:nil];
       
   205 
       
   206     char *ver;
       
   207     HW_versionInfo(NULL, &ver);
       
   208     NSString *versionNumber = [[NSString alloc] initWithCString:ver];
       
   209     self.versionLabel.text = @"";//versionNumber;
       
   210     [versionNumber release];
       
   211 
       
   212     // listen to request to remove the modalviewcontroller
       
   213     [[NSNotificationCenter defaultCenter] addObserver:self
       
   214                                              selector:@selector(dismissModalViewController)
       
   215                                                  name: @"dismissModalView"
       
   216                                                object:nil];
       
   217 
       
   218     [self createNecessaryFiles];
   162     
   219     
   163     [super viewDidLoad];
   220     [super viewDidLoad];
   164 }
   221 }
   165 
   222 
   166 
   223