# HG changeset patch # User koda # Date 1265665792 0 # Node ID 1965eba10be63cd2fb91437bb80afa99ce3620e8 # Parent 477957a8988139c18c9ef0f383c0eb60880ed9d7 some code cleanup for the ifrontend diff -r 477957a89881 -r 1965eba10be6 cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Mon Feb 08 18:12:06 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h Mon Feb 08 21:49:52 2010 +0000 @@ -22,7 +22,8 @@ #import #import "SDL_video.h" -#import "MainMenuViewController.h" + +@class MainMenuViewController; @interface SDLUIKitDelegate:NSObject { SDL_Window *window; diff -r 477957a89881 -r 1965eba10be6 cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Mon Feb 08 18:12:06 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Mon Feb 08 21:49:52 2010 +0000 @@ -28,6 +28,7 @@ #import "SDL_video.h" #import "GameSetup.h" #import "PascalImports.h" +#import "MainMenuViewController.h" //#import "SoundEffect.h" // SoundEffect *erasingSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"Erase" ofType:@"caf"]]; @@ -85,15 +86,13 @@ NSLog(@"Game is launching..."); const char **gameArgs = [setup getSettings]; + [setup release]; - // direct execution or thread? check the one that gives most fps - // library or call SDL_main? pascal quits at the end of the main + // this is the pascal fuction that starts the game Game(gameArgs); free(gameArgs); NSLog(@"Game is exting..."); - - [setup release]; [uiwindow addSubview: viewController.view]; [uiwindow makeKeyAndVisible]; @@ -107,6 +106,7 @@ } -(BOOL) checkFirstRun { + //move all this inside the MainMenuViewController BOOL isFirstRun = NO; //use a nssthread a ask the user to wait diff -r 477957a89881 -r 1965eba10be6 cocoaTouch/SDLOverrides/SDL_uikitview.h --- a/cocoaTouch/SDLOverrides/SDL_uikitview.h Mon Feb 08 18:12:06 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitview.h Mon Feb 08 21:49:52 2010 +0000 @@ -21,12 +21,10 @@ */ #import -#include "SDL_stdinc.h" -#include "SDL_mouse.h" -#include "SDL_mouse_c.h" -#include "SDL_events.h" - -#import "CGPointUtils.h" +#import "SDL_stdinc.h" +#import "SDL_mouse.h" +#import "SDL_mouse_c.h" +#import "SDL_events.h" #if SDL_IPHONE_MULTIPLE_MICE #define MAX_SIMULTANEOUS_TOUCHES 5 diff -r 477957a89881 -r 1965eba10be6 cocoaTouch/SDLOverrides/SDL_uikitview.m --- a/cocoaTouch/SDLOverrides/SDL_uikitview.m Mon Feb 08 18:12:06 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m Mon Feb 08 21:49:52 2010 +0000 @@ -20,7 +20,8 @@ slouken@libsdl.org, vittorio.giovara@gmail.com */ -#include "PascalImports.h" +#import "PascalImports.h" +#import "CGPointUtils.h" #import "SDL_uikitview.h" #import "SDL_uikitappdelegate.h" @@ -64,7 +65,8 @@ } self.multipleTouchEnabled = YES; - + self.exclusiveTouch = YES; +/* // custom code // the coordinate system is still like in Portrait even though everything is rotated attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260, 50)]; @@ -109,7 +111,7 @@ [chatButton addTarget:[self superclass] action:@selector(chatBegin) forControlEvents:UIControlEventTouchDown]; [self insertSubview:chatButton atIndex:0]; [chatButton release]; - + */ return self; } @@ -123,11 +125,13 @@ void IPH_showControls (void) { NSLog(@"Showing controls"); + /* [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; attackButton.frame = CGRectMake(30, 430, 260, 50); menuButton.frame = CGRectMake(0, 430, 30, 50); [UIView commitAnimations]; + */ } #pragma mark - @@ -157,8 +161,7 @@ } +(void) chatBegin { - HW_chat(); - SDL_iPhoneKeyboardShow([SDLUIKitDelegate sharedAppDelegate].uiwindow); + //TODO: implement a UITextScroll and put received chat lines in there } #pragma mark - @@ -169,55 +172,7 @@ // we override default touch input to implement our own gestures - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - /* - NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch =(UITouch*)[enumerator nextObject]; - - // associate touches with mice, so long as we have slots - int i; - int found = 0; - for(i=0; touch && i < MAX_SIMULTANEOUS_TOUCHES; i++) { - - // check if this mouse is already tracking a touch - if (mice[i].driverdata != NULL) { - continue; - } - - // mouse not associated with anything right now, associate the touch with this mouse - found = 1; - - // save old mouse so we can switch back - int oldMouse = SDL_SelectMouse(-1); - - // select this slot's mouse - SDL_SelectMouse(i); - CGPoint locationInView = [touch locationInView: self]; - - CGFloat oldX = locationInView.x; - locationInView.x = locationInView.y; - locationInView.y = 320 - oldX; - - // set driver data to touch object, we'll use touch object later - mice[i].driverdata = [touch retain]; - - // send moved event - SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); - - // send mouse down event - SDL_SendMouseButton(i, SDL_PRESSED, SDL_BUTTON_LEFT); - - // re-calibrate relative mouse motion - SDL_GetRelativeMouseState(i, NULL, NULL); - - // grab next touch - touch = (UITouch*)[enumerator nextObject]; - - // switch back to our old mouse - SDL_SelectMouse(oldMouse); - - } - */ - + NSArray *twoTouches; UITouch *touch = [touches anyObject]; switch ([touches count]) { @@ -226,7 +181,8 @@ initialDistanceForPinching = 0; switch ([touch tapCount]) { case 1: - NSLog(@"X:%d Y:%d", (int) gestureStartPoint.x, gestureStartPoint.y ); + + NSLog(@"X:%d Y:%d", (int)gestureStartPoint.x, (int)gestureStartPoint.y ); SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, (int)gestureStartPoint.y, 320 - (int)gestureStartPoint.x); HW_click(); @@ -244,7 +200,7 @@ } // pinching - NSArray *twoTouches = [touches allObjects]; + twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; UITouch *second = [twoTouches objectAtIndex:1]; initialDistanceForPinching = distanceBetweenPoints([first locationInView:self], [second locationInView:self]); @@ -257,34 +213,14 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { initialDistanceForPinching = 0; - + gestureStartPoint.x = 0; + gestureStartPoint.y = 0; HW_allKeysUp(); - /* - NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch=nil; - - while(touch = (UITouch *)[enumerator nextObject]) { - // search for the mouse slot associated with this touch - int i, found = NO; - for (i=0; i