# HG changeset patch # User koda # Date 1262998752 0 # Node ID dfda97c153a43900c57c0db27380d538a9b8cd80 # Parent 174c94b8ea72d3c495984337ba1bc1189e2d294a iphone overlay button animation diff -r 174c94b8ea72 -r dfda97c153a4 CMakeLists.txt --- a/CMakeLists.txt Fri Jan 08 03:52:44 2010 +0000 +++ b/CMakeLists.txt Sat Jan 09 00:59:12 2010 +0000 @@ -205,6 +205,8 @@ "hwconsts.cpp$" "playlist.inc$" "CPack" + "^${PROJECT_SOURCE_DIR}/openalbridge" + "^${PROJECT_SOURCE_DIR}/cocoaTouch" "^${PROJECT_SOURCE_DIR}/bin/[a-z]" "^${PROJECT_SOURCE_DIR}/tools/templates" "^${PROJECT_SOURCE_DIR}/doc" diff -r 174c94b8ea72 -r dfda97c153a4 cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Fri Jan 08 03:52:44 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Sat Jan 09 00:59:12 2010 +0000 @@ -81,6 +81,9 @@ /* Set working directory to resource path */ [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]]; +//#import "SoundEffect.h" +// SoundEffect *erasingSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"Erase" ofType:@"caf"]]; +// SoundEffect *selectSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"Select" ofType:@"caf"]]; [window addSubview:controller.view]; [window makeKeyAndVisible]; diff -r 174c94b8ea72 -r dfda97c153a4 cocoaTouch/SDLOverrides/SDL_uikitview.m --- a/cocoaTouch/SDLOverrides/SDL_uikitview.m Fri Jan 08 03:52:44 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m Sat Jan 09 00:59:12 2010 +0000 @@ -34,16 +34,24 @@ @synthesize initialDistance, gestureStartPoint; +// they have to be global variables to allow showControls() to use them +UIButton *attackButton, *menuButton; + - (void)dealloc { #if SDL_IPHONE_KEYBOARD SDL_DelKeyboard(0); [textField release]; #endif + [menuButton release]; + [attackButton release]; [super dealloc]; } - (id)initWithFrame:(CGRect)frame { - + // the addTarget parameter for the buttons below is set like that because + // this object is inherited by SDL_openglesview.m which is the one allocated by SDL. + // We select this class with [self superclass] and call the selectors with "+" because + // they are superclass methods self = [super initWithFrame: frame]; #if SDL_IPHONE_KEYBOARD @@ -56,26 +64,39 @@ mice[i].driverdata = NULL; SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1); } - - UIButton *attackButton; - attackButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 90,60)]; + attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260,50)]; [attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal]; - // this object is inherited by SDL_openglesview.m which is the one allocated by SDL. - // We select this class with [self superclass] and call the selectors with "+" because - // they are superclass methods [attackButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchDown]; [attackButton addTarget:[self superclass] action:@selector(attackButtonReleased) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; - [self insertSubview:attackButton atIndex:10]; - [attackButton release]; + [self addSubview:attackButton]; + + menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 480, 30,50)]; + [menuButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal]; + [menuButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + [self addSubview:menuButton]; self.multipleTouchEnabled = YES; - + return self; } #pragma mark - +#pragma mark Show and Hide overlaid buttons + +// standard C function to be called from pascal +void 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 - #pragma mark Superclass methods + +(void) attackButtonPressed { HW_shoot(); } diff -r 174c94b8ea72 -r dfda97c153a4 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Fri Jan 08 03:52:44 2010 +0000 +++ b/hedgewars/SDLh.pas Sat Jan 09 00:59:12 2010 +0000 @@ -734,7 +734,8 @@ function SDLNet_Read32(buf: pointer): LongWord; {$IFDEF IPHONEOS} -function get_documents_path: PChar; cdecl; external 'hwutils'; +function get_documents_path: PChar; cdecl; external 'hwutils'; +procedure IPH_showControls; cdecl; external name 'showControls'; {$ENDIF} implementation diff -r 174c94b8ea72 -r dfda97c153a4 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Fri Jan 08 03:52:44 2010 +0000 +++ b/hedgewars/hwengine.pas Sat Jan 09 00:59:12 2010 +0000 @@ -96,7 +96,7 @@ FinishProgress; PlayMusic; SetScale(zoom); - GameState:= gsGame + GameState:= gsGame; end; gsConfirm, gsGame: begin diff -r 174c94b8ea72 -r dfda97c153a4 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Fri Jan 08 03:52:44 2010 +0000 +++ b/hedgewars/uStore.pas Sat Jan 09 00:59:12 2010 +0000 @@ -1159,9 +1159,9 @@ // prepare default translation/scaling glLoadIdentity(); glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); -//{$IFDEF IPHONEOS} +{$IFDEF IPHONEOS} //glRotatef(90, 0, 0, 1); -//{$ENDIF} +{$ENDIF} glTranslatef(0, -cScreenHeight / 2, 0); // enable alpha blending @@ -1181,9 +1181,9 @@ glPushMatrix; // save default scaling glLoadIdentity; glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); -//{$IFDEF IPHONEOS} +{$IFDEF IPHONEOS} // glRotatef(90, 0, 0, 1); -//{$ENDIF} +{$ENDIF} glTranslatef(0, -cScreenHeight / 2, 0); end; @@ -1236,7 +1236,13 @@ begin WriteLnToConsole('Freeing progress surface... '); FreeTexture(ProgrTex); -ProgrTex:= nil +ProgrTex:= nil; + +{$IFDEF IPHONEOS} +// show overlay buttons +IPH_showControls; +{$ENDIF} + end; procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean);