cocoaTouch/iPad/PopupMenuViewController.m
author koda
Fri, 02 Apr 2010 15:30:54 +0000
changeset 3253 b0b1b1310b7e
parent 3250 d5cd1a617123
permissions -rw-r--r--
display team contents in the ifrontend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     1
    //
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     2
//  popupMenuViewController.m
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     3
//  HedgewarsMobile
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     4
//
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     5
//  Created by Vittorio on 25/03/10.
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     7
//
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
     8
3122
e005359efc59 hide the background gl context that remains active (might be worth freeing ithide the background gl context that remains active (might be worth freeing it))
koda
parents: 3116
diff changeset
     9
#import "SDL_uikitappdelegate.h"
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    10
#import "PopupMenuViewController.h"
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    11
#import "PascalImports.h"
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    12
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    13
@implementation PopupMenuViewController
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
    14
@synthesize menuList;
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    15
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    16
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    17
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    18
    // Overriden to allow any orientation.
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    19
    return YES;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    20
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    21
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    22
-(void) didReceiveMemoryWarning {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    23
    // Releases the view if it doesn't have a superview.
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    24
    [super didReceiveMemoryWarning];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    25
    
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    26
    // Release any cached data, images, etc that aren't in use.
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    27
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    28
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    29
-(void) viewDidLoad {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    30
    isPaused = NO;
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
    31
    self.tableView.allowsSelection = YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
    32
    self.tableView.alwaysBounceVertical = YES;
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
    33
    self.tableView.delaysContentTouches = NO;
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    34
    menuList = [[NSArray alloc] initWithObjects:
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    35
                NSLocalizedString(@"Pause Game", @""),
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    36
                NSLocalizedString(@"Chat", @""),
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    37
                NSLocalizedString(@"End Game", @""),
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    38
                nil];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    39
    [super viewDidLoad];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    40
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    41
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    42
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    43
-(void) dealloc {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    44
    [menuList release];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    45
    [super dealloc];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    46
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    47
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    48
#pragma mark -
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
    49
#pragma mark tableView methods
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    50
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    51
	return 1;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    52
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    53
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    54
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    55
	return 3;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    56
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    57
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    58
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    59
	static NSString *cellIdentifier = @"CellIdentifier";
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    60
	
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    61
	UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    62
    if (nil == cell) {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    63
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    64
                                       reuseIdentifier:cellIdentifier] autorelease];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    65
	}
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
    66
    cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    67
	
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    68
	return cell;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    69
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    70
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    71
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    72
    UIActionSheet *actionSheet;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    73
    
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    74
    switch ([indexPath row]) {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    75
		case 0:
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    76
            HW_pause();
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    77
            isPaused = !isPaused;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    78
            break;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    79
        case 1:
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    80
			HW_chat();
3122
e005359efc59 hide the background gl context that remains active (might be worth freeing ithide the background gl context that remains active (might be worth freeing it))
koda
parents: 3116
diff changeset
    81
            //SDL_iPhoneKeyboardShow([SDLUIKitDelegate sharedAppDelegate].window);
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    82
            break;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    83
        case 2:
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    84
			actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    85
                                                      delegate:self
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    86
                                             cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
    87
                                        destructiveButtonTitle:NSLocalizedString(@"Of course!", @"")
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    88
                                             otherButtonTitles:nil];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    89
            [actionSheet showInView:self.view];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    90
            [actionSheet release];
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    91
            
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    92
            if (!isPaused) 
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    93
                HW_pause();
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    94
            break;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    95
        default:
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    96
			NSLog(@"Warning: unset case value in section!");
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    97
			break;
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
    98
    }
3253
b0b1b1310b7e display team contents in the ifrontend
koda
parents: 3250
diff changeset
    99
    
b0b1b1310b7e display team contents in the ifrontend
koda
parents: 3250
diff changeset
   100
    [aTableView deselectRowAtIndexPath:indexPath animated:YES];
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   101
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   102
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
   103
#pragma mark -
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3122
diff changeset
   104
#pragma mark actionSheet methods
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   105
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   106
	if ([actionSheet cancelButtonIndex] != buttonIndex) {
3253
b0b1b1310b7e display team contents in the ifrontend
koda
parents: 3250
diff changeset
   107
        [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissPopover" object:nil];
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   108
        HW_terminate(NO);
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   109
    }
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   110
	else
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   111
        if (!isPaused) 
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   112
            HW_pause();		
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   113
}
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   114
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents:
diff changeset
   115
@end