cocoaTouch/MainMenuViewController.m
author smxx
Thu, 04 Feb 2010 22:29:19 +0000
changeset 2751 2a3091b13ce4
parent 2743 39d097ac2276
child 2799 558b29bf00c5
permissions -rw-r--r--
Engine: * Force 'cpu' flag for AI players; keep players from using it * Updated english Locale/de.txt Graphics: * Added first pack of community submitted flags (cm_*.png) * Added some new hats
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     1
//
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     2
//  MainMenuViewController.m
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     3
//  hwengine
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     4
//
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     5
//  Created by Vittorio on 08/01/10.
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     7
//
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     8
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
     9
#import "MainMenuViewController.h"
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    10
#import "SDL_uikitappdelegate.h"
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    11
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    12
@implementation MainMenuViewController
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    13
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    14
@synthesize versionLabel, settingsViewController, mainView;
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    15
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    16
/*
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    17
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    18
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    19
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    20
        // Custom initialization
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    21
    }
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    22
    return self;
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    23
}
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    24
*/
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    25
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    26
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    27
	return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    28
}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    29
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    30
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    31
- (void)didReceiveMemoryWarning {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    32
	// Releases the view if it doesn't have a superview.
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    33
	[super didReceiveMemoryWarning];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    34
	
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    35
	// Release any cached data, images, etc that aren't in use.
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    36
	if (nil == self.settingsViewController.view.superview) {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    37
		self.settingsViewController = nil;
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    38
	}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    39
}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    40
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    41
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    42
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    43
-(void) viewDidLoad {
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    44
	self.versionLabel.text = @"0.9.13-dev";
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    45
	[super viewDidLoad];
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    46
}
2723
eaa6ac1e95ea LANDSCAPE ON IPHONE
koda
parents: 2694
diff changeset
    47
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    48
- (void)viewDidUnload {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    49
	// Release any retained subviews of the main view.
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    50
	self.versionLabel = nil;
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    51
}
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    52
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    53
- (void)dealloc {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    54
	[versionLabel release];
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    55
	[settingsViewController release];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    56
	[super dealloc];
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    57
}
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    58
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    59
// disable the buttons when to prevent launching twice the game
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    60
-(void) viewWillDisappear:(BOOL)animated {
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    61
	self.mainView.userInteractionEnabled = NO;
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    62
	[super viewWillDisappear:animated];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    63
}
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    64
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    65
-(void) viewDidAppear:(BOOL)animated {
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    66
	self.mainView.userInteractionEnabled = YES;
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    67
	[super viewDidAppear:animated];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    68
}
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    69
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    70
#pragma mark -
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    71
#pragma mark Action buttons
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    72
-(IBAction) startPlaying {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    73
	[[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    74
}
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    75
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    76
-(IBAction) notYetImplemented {
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    77
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented"
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    78
							message:@"Sorry, this feature is not yet implemented"
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    79
						       delegate:nil
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    80
					      cancelButtonTitle:@"Well, don't worry"
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    81
					      otherButtonTitles:nil];
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    82
	[alert show];
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    83
	[alert release];
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    84
}
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    85
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    86
-(IBAction) switchViews:(id)sender {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    87
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    88
	// view not displayed or not created
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    89
	if (nil == self.settingsViewController.view.superview) {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    90
		// view not created
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    91
		if (nil == self.settingsViewController) {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    92
			SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController"
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    93
												      bundle:nil];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    94
			self.settingsViewController = controller;
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    95
			self.settingsViewController.parentView = self.mainView;
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    96
			[controller release];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    97
		}
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    98
		self.settingsViewController.view.frame = CGRectMake(0, -320, 480, 320);
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    99
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   100
		[UIView beginAnimations:@"View Switch" context:NULL];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   101
		[UIView setAnimationDuration:3];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   102
		[UIView setAnimationDuration:UIViewAnimationCurveEaseOut];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   103
		self.settingsViewController.view.frame = CGRectMake(0, 0, 480, 320);
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
   104
		self.mainView.frame = CGRectMake(0, 320, 480, 320);
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   105
		
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   106
		[self.view addSubview:settingsViewController.view];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   107
		[UIView commitAnimations];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   108
	}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   109
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   110
}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   111
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
   112
@end