1
0
mirror of https://github.com/thes3m/XNI synced 2024-12-26 13:26:06 +01:00
Matej Jan 01f76821e6 Added a graphics device manager.
git-svn-id: http://xni.googlecode.com/svn/XNI@10 ac433895-eea3-a490-d80a-17149a75e588
2010-07-27 18:23:25 +00:00

83 lines
2.0 KiB
Objective-C

//
// GameWindow.m
// XNI
//
// Created by Matej Jan on 20.7.10.
// Copyright 2010 Retronator. All rights reserved.
//
#import "GameWindow.h"
#import "Retronator.Xni.Framework.h"
@implementation GameWindow
- (id) init {
if (self = [super init]) {
clientBounds = [[Rectangle empty] retain];
currentOrientation = DisplayOrientationDefault;
clientSizeChanged = [[Event alloc] init];
orientationChanged = [[Event alloc] init];
}
return self;
}
// PROPERTIES
@synthesize clientBounds;
@synthesize currentOrientation;
@synthesize clientSizeChanged;
@synthesize orientationChanged;
- (id) handle {
return (id)gameViewController.view.layer;
}
// METHODS
- (void) initialize {
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Initialize game view controller.
gameViewController = [[GameViewController alloc] initWithGameWindow:self];
[((GameView*)gameViewController.view).viewSizeChanged
subscribeDelegate:[Delegate delegateWithTarget:self Method:@selector(gameViewSizeChanged)]];
// Add the game view to the window.
[window addSubview: gameViewController.view];
// Present the window.
[window makeKeyAndVisible];
}
- (void) beginScreenDeviceChangeWithFullscreen:(BOOL)willBeFullscreen {
gameViewController.wantsFullScreenLayout = willBeFullscreen;
[[UIApplication sharedApplication] setStatusBarHidden:willBeFullscreen];
gameViewController.view.frame = [UIScreen mainScreen].applicationFrame;
clientBounds = [Rectangle rectangleWithCGRect:gameViewController.view.bounds];
}
- (void) endScreenDeviceChange {
}
- (void) gameViewSizeChanged {
Rectangle *newClientBounds = [Rectangle rectangleWithCGRect:gameViewController.view.bounds];
if (![newClientBounds equals:clientBounds]) {
[clientBounds release];
clientBounds = [newClientBounds retain];
[clientSizeChanged raiseWithSender:self];
}
}
- (void) dealloc
{
[clientBounds release];
[gameViewController release];
[window release];
[super dealloc];
}
@end