cocoaTouch/MainMenuViewController.m
author smxx
Fri, 12 Feb 2010 18:40:14 +0000
changeset 2802 28cd5b87bce9
parent 2799 558b29bf00c5
child 2803 1f446fc5c8ec
permissions -rw-r--r--
Engine: * Added alt weapon icon to parachute and flying saucer * Hide alt weapon icon once weapon was used
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"
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
    11
#import "PascalImports.h"
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    12
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    13
@implementation MainMenuViewController
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    14
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    15
@synthesize versionLabel, settingsViewController, mainView;
2685
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
/*
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    18
 // 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
    19
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    20
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    21
        // Custom initialization
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    22
    }
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    23
    return self;
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
*/
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    26
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    27
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    28
	return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
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
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    32
- (void)didReceiveMemoryWarning {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    33
	// Releases the view if it doesn't have a superview.
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    34
	[super didReceiveMemoryWarning];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    35
	
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    36
	// Release any cached data, images, etc that aren't in use.
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    37
	if (nil == self.settingsViewController.view.superview) {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    38
		self.settingsViewController = nil;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
    39
		[settingsViewController release];
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    40
	}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    41
}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    42
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    43
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    44
// 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
    45
-(void) viewDidLoad {
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
    46
	char *ver;
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
    47
	HW_versionInfo(NULL, &ver);
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
    48
	self.versionLabel.text = [[NSString stringWithUTF8String:ver] autorelease];
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    49
	[super viewDidLoad];
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    50
}
2723
eaa6ac1e95ea LANDSCAPE ON IPHONE
koda
parents: 2694
diff changeset
    51
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    52
- (void)viewDidUnload {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    53
	// Release any retained subviews of the main view.
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    54
	self.versionLabel = nil;
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    55
}
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    56
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    57
- (void)dealloc {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    58
	[versionLabel release];
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    59
	[settingsViewController release];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    60
	[super dealloc];
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    61
}
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    62
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    63
// 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
    64
-(void) viewWillDisappear:(BOOL)animated {
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    65
	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
    66
	[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
    67
}
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    68
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    69
-(void) viewDidAppear:(BOOL)animated {
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    70
	self.mainView.userInteractionEnabled = YES;
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
    71
	[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
    72
}
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    73
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    74
#pragma mark -
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    75
#pragma mark Action buttons
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    76
-(IBAction) startPlaying {
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    77
	[[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
    78
}
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    79
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    80
-(IBAction) notYetImplemented {
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    81
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented"
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    82
							message:@"Sorry, this feature is not yet implemented"
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    83
						       delegate:nil
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    84
					      cancelButtonTitle:@"Well, don't worry"
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    85
					      otherButtonTitles:nil];
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    86
	[alert show];
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    87
	[alert release];
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    88
}
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents: 2685
diff changeset
    89
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    90
-(IBAction) switchViews:(id)sender {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    91
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    92
	// view not displayed or not created
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    93
	if (nil == self.settingsViewController.view.superview) {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    94
		// view not created
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    95
		if (nil == self.settingsViewController) {
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    96
			SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController"
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    97
												      bundle:nil];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    98
			self.settingsViewController = controller;
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
    99
			[controller release];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   100
		}
2743
39d097ac2276 implement transition in the way i had in mind
koda
parents: 2740
diff changeset
   101
		self.settingsViewController.view.frame = CGRectMake(0, -320, 480, 320);
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
   102
		self.settingsViewController.parentView = self.mainView;
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   103
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   104
		[UIView beginAnimations:@"View Switch" context:NULL];
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
   105
		[UIView setAnimationDuration:1];
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2743
diff changeset
   106
		//[UIView setAnimationDuration:UIViewAnimationCurveEaseOut];
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   107
		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
   108
		self.mainView.frame = CGRectMake(0, 320, 480, 320);
2740
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   109
		
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   110
		[self.view addSubview:settingsViewController.view];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   111
		[UIView commitAnimations];
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   112
	}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   113
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   114
}
03df0573a9fd programmatically load main controller
koda
parents: 2738
diff changeset
   115
2685
0ba746be5d59 frontend images by Tiy, first setup of frontend
koda
parents:
diff changeset
   116
@end