project_files/HedgewarsMobile/Classes/GameConfigViewController.m
branchios-revival
changeset 11228 e1bbd85a53b7
parent 11222 bd45676ab966
child 11549 893722a2a1f9
equal deleted inserted replaced
11227:0dd98551e3f8 11228:e1bbd85a53b7
    22 #import "TeamConfigViewController.h"
    22 #import "TeamConfigViewController.h"
    23 #import "SchemeWeaponConfigViewController.h"
    23 #import "SchemeWeaponConfigViewController.h"
    24 #import "GameInterfaceBridge.h"
    24 #import "GameInterfaceBridge.h"
    25 #import "HelpPageLobbyViewController.h"
    25 #import "HelpPageLobbyViewController.h"
    26 
    26 
       
    27 @interface GameConfigViewController ()
       
    28 @property (nonatomic, retain) IBOutlet UISegmentedControl *tabsSegmentedControl; //iPhone only
       
    29 
       
    30 @property (nonatomic, retain) IBOutlet UIBarButtonItem *backButton; //iPhone only
       
    31 @property (nonatomic, retain) IBOutlet UIBarButtonItem *startButton; //iPhone only
       
    32 @end
       
    33 
    27 @implementation GameConfigViewController
    34 @implementation GameConfigViewController
    28 @synthesize imgContainer, titleImage, sliderBackground, helpPage,
    35 @synthesize imgContainer, titleImage, sliderBackground, helpPage,
    29             mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController;
    36             mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController;
    30 
    37 
    31 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    38 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    32     return rotationManager(interfaceOrientation);
    39     return rotationManager(interfaceOrientation);
    33 }
    40 }
       
    41 
       
    42 #pragma mark - Buttons
    34 
    43 
    35 -(IBAction) buttonPressed:(id) sender {
    44 -(IBAction) buttonPressed:(id) sender {
    36     UIButton *theButton = (UIButton *)sender;
    45     UIButton *theButton = (UIButton *)sender;
    37 
    46 
    38     switch (theButton.tag) {
    47     switch (theButton.tag) {
    74             DLog(@"Nope");
    83             DLog(@"Nope");
    75             break;
    84             break;
    76     }
    85     }
    77 }
    86 }
    78 
    87 
       
    88 #pragma mark - Tabs Segmented Control
       
    89 
       
    90 - (void)localizeTabsSegmentedControl
       
    91 {
       
    92     for (NSUInteger i = 0; i < self.tabsSegmentedControl.numberOfSegments; i++)
       
    93     {
       
    94         NSString *oldTitle = [self.tabsSegmentedControl titleForSegmentAtIndex:i];
       
    95         [self.tabsSegmentedControl setTitle:NSLocalizedString(oldTitle, nil) forSegmentAtIndex:i];
       
    96     }
       
    97 }
       
    98 
    79 -(IBAction) segmentPressed:(id) sender {
    99 -(IBAction) segmentPressed:(id) sender {
    80 
   100 
    81     UISegmentedControl *theSegment = (UISegmentedControl *)sender;
   101     UISegmentedControl *theSegment = (UISegmentedControl *)sender;
    82 
   102 
    83     [[AudioManagerController mainManager] playSelectSound];
   103     [[AudioManagerController mainManager] playSelectSound];
   113             DLog(@"Nope");
   133             DLog(@"Nope");
   114             break;
   134             break;
   115     }
   135     }
   116 
   136 
   117 }
   137 }
       
   138 
       
   139 #pragma mark -
   118 
   140 
   119 -(BOOL) isEverythingSet {
   141 -(BOOL) isEverythingSet {
   120     // don't start playing if the preview is in progress
   142     // don't start playing if the preview is in progress
   121     if ([self.mapConfigViewController busy]) {
   143     if ([self.mapConfigViewController busy]) {
   122         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Wait for the Preview",@"")
   144         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Wait for the Preview",@"")
   300     
   322     
   301     [self.imgContainer removeFromSuperview];
   323     [self.imgContainer removeFromSuperview];
   302     self.imgContainer = nil;
   324     self.imgContainer = nil;
   303 }
   325 }
   304 
   326 
   305 -(void) viewDidLoad {
   327 -(void) viewDidLoad
       
   328 {
       
   329     [super viewDidLoad];
       
   330     
   306     self.view.backgroundColor = [UIColor blackColor];
   331     self.view.backgroundColor = [UIColor blackColor];
   307 
   332 
   308     CGRect screenRect = [[UIScreen mainScreen] safeBounds];
   333     CGRect screenRect = [[UIScreen mainScreen] safeBounds];
   309     self.view.frame = screenRect;
   334     self.view.frame = screenRect;
   310 
   335 
   311     if (IS_IPAD()) {
   336     if (IS_IPAD())
       
   337     {
   312         // the label for the filter slider
   338         // the label for the filter slider
   313         UILabel *backLabel = [[UILabel alloc] initWithFrame:CGRectMake(116, 714, 310, 40)
   339         UILabel *backLabel = [[UILabel alloc] initWithFrame:CGRectMake(116, 714, 310, 40)
   314                                                    andTitle:nil
   340                                                    andTitle:nil
   315                                             withBorderWidth:2.0f];
   341                                             withBorderWidth:2.0f];
   316         self.sliderBackground = backLabel;
   342         self.sliderBackground = backLabel;
   325         maxLabel.textColor = [UIColor whiteColor];
   351         maxLabel.textColor = [UIColor whiteColor];
   326         maxLabel.textAlignment = UITextAlignmentCenter;
   352         maxLabel.textAlignment = UITextAlignmentCenter;
   327         [self.view addSubview:maxLabel];
   353         [self.view addSubview:maxLabel];
   328         self.mapConfigViewController.maxLabel = maxLabel;
   354         self.mapConfigViewController.maxLabel = maxLabel;
   329         [maxLabel release];
   355         [maxLabel release];
   330     } else {
   356     }
       
   357     else
       
   358     {
       
   359         [self localizeTabsSegmentedControl];
       
   360         
       
   361         [self.backButton setTitle:NSLocalizedString(@"Back", nil)];
       
   362         [self.startButton setTitle:NSLocalizedString(@"Start", nil)];
       
   363         
   331         self.mapConfigViewController.view.frame = CGRectMake(0, 0, screenRect.size.width, screenRect.size.height-44);
   364         self.mapConfigViewController.view.frame = CGRectMake(0, 0, screenRect.size.width, screenRect.size.height-44);
   332     }
   365     }
       
   366     
   333     [self.view addSubview:self.mapConfigViewController.view];
   367     [self.view addSubview:self.mapConfigViewController.view];
   334     [self.view bringSubviewToFront:self.mapConfigViewController.slider];
   368     [self.view bringSubviewToFront:self.mapConfigViewController.slider];
   335 
       
   336     [super viewDidLoad];
       
   337 }
   369 }
   338 
   370 
   339 -(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval) duration {
   371 -(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval) duration {
   340     if (IS_IPAD() == NO)
   372     if (IS_IPAD() == NO)
   341         return;
   373         return;
   434     MSG_DIDUNLOAD();
   466     MSG_DIDUNLOAD();
   435     [super viewDidUnload];
   467     [super viewDidUnload];
   436 }
   468 }
   437 
   469 
   438 -(void) dealloc {
   470 -(void) dealloc {
       
   471     releaseAndNil(_tabsSegmentedControl);
       
   472     releaseAndNil(_backButton);
       
   473     releaseAndNil(_startButton);
   439     releaseAndNil(imgContainer);
   474     releaseAndNil(imgContainer);
   440     releaseAndNil(titleImage);
   475     releaseAndNil(titleImage);
   441     releaseAndNil(sliderBackground);
   476     releaseAndNil(sliderBackground);
   442     releaseAndNil(schemeWeaponConfigViewController);
   477     releaseAndNil(schemeWeaponConfigViewController);
   443     releaseAndNil(teamConfigViewController);
   478     releaseAndNil(teamConfigViewController);