project_files/HedgewarsMobile/Classes/GameConfigViewController.m
branchios-revival
changeset 11221 4d8ab775bad3
parent 11215 51cc7ec00c2d
child 11222 bd45676ab966
equal deleted inserted replaced
11220:32366eb83383 11221:4d8ab775bad3
   236     UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:filePath];
   236     UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:filePath];
   237     [filePath release];
   237     [filePath release];
   238 
   238 
   239     NSArray *hatArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:HATS_DIRECTORY() error:NULL];
   239     NSArray *hatArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:HATS_DIRECTORY() error:NULL];
   240     NSUInteger numberOfHats = [hatArray count];
   240     NSUInteger numberOfHats = [hatArray count];
   241     int animationFrames = IS_VERY_POWERFUL([HWUtils modelType]) ? 18 : 1;
   241     int animationFrames = IS_VERY_POWERFUL([HWUtils modelType]) ? 16 : 1;
   242 
   242 
   243     if (self.imgContainer != nil)
   243     if (self.imgContainer != nil)
   244         [self.imgContainer removeFromSuperview];
   244         [self.imgContainer removeFromSuperview];
   245 
   245 
   246     self.imgContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 40)];
   246     self.imgContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 40)];
   247     NSInteger numberOfHogs = 1 + arc4random_uniform(20);
   247     NSInteger numberOfHogs = 1 + arc4random_uniform(15);
   248     DLog(@"Drawing %ld nice hedgehogs", (long)numberOfHogs);
   248     DLog(@"Drawing %ld nice hedgehogs", (long)numberOfHogs);
   249     for (int i = 0; i < numberOfHogs; i++) {
   249     for (int i = 0; i < numberOfHogs; i++) {
   250         NSString *hat = [hatArray objectAtIndex:arc4random_uniform((int)numberOfHats)];
   250         NSString *hat = [hatArray objectAtIndex:arc4random_uniform((int)numberOfHats)];
   251 
   251 
   252         NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", HATS_DIRECTORY(), hat];
   252         NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", HATS_DIRECTORY(), hat];
   267         hog.animationImages = animation;
   267         hog.animationImages = animation;
   268         hog.animationDuration = 3;
   268         hog.animationDuration = 3;
   269         [animation release];
   269         [animation release];
   270 
   270 
   271         int x = 20*i+arc4random_uniform(128);
   271         int x = 20*i+arc4random_uniform(128);
   272         if (x > 320 - 32)
   272         while (x > 320 - 32)
   273             x = i*arc4random_uniform(32);
   273             x = i*arc4random_uniform(32);
       
   274         
   274         hog.frame = CGRectMake(x, 25, hog.frame.size.width, hog.frame.size.height);
   275         hog.frame = CGRectMake(x, 25, hog.frame.size.width, hog.frame.size.height);
   275         [self.imgContainer addSubview:hog];
   276         [self.imgContainer addSubview:hog];
   276         [hog startAnimating];
   277         [hog startAnimating];
   277         [hog release];
   278         [hog release];
   278     }
   279     }
   356         self.sliderBackground.frame = CGRectMake(465, 975, 200, 40);
   357         self.sliderBackground.frame = CGRectMake(465, 975, 200, 40);
   357         self.mapConfigViewController.slider.frame = CGRectMake(475, 983, 180, 23);
   358         self.mapConfigViewController.slider.frame = CGRectMake(475, 983, 180, 23);
   358     }
   359     }
   359 }
   360 }
   360 
   361 
   361 -(void) viewWillAppear:(BOOL)animated {
   362 -(void) viewWillAppear:(BOOL)animated
   362 //    if (IS_IPAD())
   363 {
   363 //        [NSThread detachNewThreadSelector:@selector(loadNiceHogs) toTarget:self withObject:nil];
   364     [super viewDidAppear:animated];
       
   365     
       
   366     if (IS_IPAD())
       
   367         [NSThread detachNewThreadSelector:@selector(loadNiceHogs) toTarget:self withObject:nil];
   364     
   368     
   365     if (IS_IPAD())
   369     if (IS_IPAD())
   366     {
   370     {
   367         // we assume here what 'statusBarOrientation' will never be changed manually!
   371         // we assume here what 'statusBarOrientation' will never be changed manually!
   368         UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation];
   372         UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation];
   382         UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation];
   386         UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication] statusBarOrientation];
   383         [self updateiPadUIForInterfaceOrientation:currentOrientation];
   387         [self updateiPadUIForInterfaceOrientation:currentOrientation];
   384     }
   388     }
   385 }
   389 }
   386 
   390 
   387 -(void) didReceiveMemoryWarning {
   391 -(void) didReceiveMemoryWarning
       
   392 {
       
   393     [self.imgContainer removeFromSuperview];
   388     self.imgContainer = nil;
   394     self.imgContainer = nil;
   389 
   395 
   390     if (self.titleImage.superview == nil)
   396     if (self.titleImage.superview == nil)
   391         self.titleImage = nil;
   397         self.titleImage = nil;
   392     if (self.sliderBackground.superview == nil)
   398     if (self.sliderBackground.superview == nil)