cocoaTouch/GameConfigViewController.m
author koda
Wed, 21 Apr 2010 01:57:23 +0000
changeset 3361 cfc6cd502f85
parent 3356 3ae3fccb439e
child 3364 e5403e2bf02c
permissions -rw-r--r--
buttons for number of hogs in game config buttons for color of team in game config update and code cleanup fixed crashes at uitextfield
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     1
    //
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     2
//  GameConfigViewController.m
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     3
//  HedgewarsMobile
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     4
//
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     5
//  Created by Vittorio on 18/04/10.
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     7
//
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     8
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
     9
#import "GameConfigViewController.h"
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    10
#import "SDL_uikitappdelegate.h"
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    11
#import "CommodityFunctions.h"
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    12
#import "TeamConfigViewController.h"
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    13
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    14
@implementation GameConfigViewController
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    15
@synthesize availableTeamsTableView, weaponsButton, schemesButton, mapButton, randomButton, startButton;
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    16
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    17
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    18
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    19
    return rotationManager(interfaceOrientation);
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    20
}
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    21
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    22
-(IBAction) buttonPressed:(id) sender {
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    23
    // works even if it's not actually a button
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    24
    UIButton *theButton = (UIButton *)sender;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    25
    switch (theButton.tag) {
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    26
        case 0:
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    27
            [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    28
            break;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    29
        case 1:
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    30
            [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    31
            [self performSelector:@selector(startSDLgame)
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    32
                       withObject:nil
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    33
                       afterDelay:0.4];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    34
            break;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    35
    }
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    36
}
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    37
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    38
-(void) startSDLgame {
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    39
    [[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    40
}
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    41
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    42
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    43
-(void) viewDidLoad {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    44
    teamConfigViewController = [[TeamConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    45
    activeController = teamConfigViewController;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    46
    
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    47
    [self.view insertSubview:teamConfigViewController.view atIndex:0];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    48
    
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    49
    [super viewDidLoad];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    50
}
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    51
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    52
-(void) didReceiveMemoryWarning {
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    53
    // Releases the view if it doesn't have a superview.
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    54
    [super didReceiveMemoryWarning];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    55
    // Release any cached data, images, etc that aren't in use.
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    56
}
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    57
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    58
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    59
-(void) viewDidUnload {
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    60
    activeController = nil;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    61
    teamConfigViewController = nil;
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    62
    self.availableTeamsTableView = nil;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    63
    self.weaponsButton = nil;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    64
    self.schemesButton = nil;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    65
    self.mapButton = nil;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    66
    self.randomButton = nil;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    67
    self.startButton = nil;
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    68
    [super viewDidUnload];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    69
}
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    70
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    71
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    72
-(void) dealloc {
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    73
    [activeController release];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    74
    [teamConfigViewController release];
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    75
    [availableTeamsTableView release];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    76
    [weaponsButton release];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    77
    [schemesButton release];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    78
    [mapButton release];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    79
    [randomButton release];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    80
    [startButton release];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    81
    [super dealloc];
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    82
}
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
    83
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    84
-(void) viewWillAppear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    85
    [super viewWillAppear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    86
    [activeController viewWillAppear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    87
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    88
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    89
-(void) viewWillDisappear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    90
    [super viewWillDisappear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    91
    [activeController viewWillDisappear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    92
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    93
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    94
-(void) viewDidAppear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    95
    [super viewDidLoad];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    96
    [activeController viewDidAppear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    97
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    98
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
    99
-(void) viewDidDisappear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
   100
    [super viewDidUnload];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
   101
    [activeController viewDidDisappear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3356
diff changeset
   102
}
3356
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
   103
3ae3fccb439e add missing controller stubs
koda
parents:
diff changeset
   104
@end