# HG changeset patch # User koda # Date 1264726514 0 # Node ID eaa6ac1e95ea3c5be3febcb856d496026bbcb040 # Parent d891285e500fcdfb15adcd3fd46e07fc6e259354 LANDSCAPE ON IPHONE brings down fps, other localization features diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/MainMenuViewController.m --- a/cocoaTouch/MainMenuViewController.m Thu Jan 28 20:36:24 2010 +0000 +++ b/cocoaTouch/MainMenuViewController.m Fri Jan 29 00:55:14 2010 +0000 @@ -37,6 +37,7 @@ return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ + /* - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/MainWindow.xib --- a/cocoaTouch/MainWindow.xib Thu Jan 28 20:36:24 2010 +0000 +++ b/cocoaTouch/MainWindow.xib Fri Jan 29 00:55:14 2010 +0000 @@ -45,11 +45,7 @@ 1 MCAwIDAAA - NO NO - - 2 - @@ -424,6 +420,7 @@ YES backgroundTap: + deleteData: sliderChanged: textFieldDoneEditing: @@ -432,12 +429,14 @@ id id id + id YES YES + buttonContainer password table username @@ -447,6 +446,7 @@ YES + UIView UITextField UITableView UITextField diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m --- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Thu Jan 28 20:36:24 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m Fri Jan 29 00:55:14 2010 +0000 @@ -39,10 +39,10 @@ #endif int main (int argc, char *argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, @"SDLUIKitDelegate"); - [pool release]; - return retVal; + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, @"SDLUIKitDelegate"); + [pool release]; + return retVal; } @implementation SDLUIKitDelegate @@ -93,7 +93,8 @@ free(gameArgs); NSLog(@"Game is exting..."); - + + [[uiwindow viewWithTag:54321] removeFromSuperview]; [setup release]; [UIView beginAnimations:@"inserting main controller" context:NULL]; @@ -101,7 +102,7 @@ controller.view.alpha = 1; [UIView commitAnimations]; - [uiwindow addSubview:controller.view]; + [uiwindow addSubview: controller.view]; [uiwindow makeKeyAndVisible]; [internal_pool release]; @@ -110,6 +111,8 @@ -(BOOL) checkFirstRun { BOOL isFirstRun = NO; + //use a nssthread a ask the user to wait + NSString *filePath = [self dataFilePath:@"settings.plist"]; if (!([[NSFileManager defaultManager] fileExistsAtPath:filePath])) { isFirstRun = YES; @@ -136,6 +139,7 @@ } -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application { + /* we get too many ones on ipod touch UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Running low on memory" message:@"I will try to free some memory but game might slow down a little" delegate:nil @@ -143,6 +147,7 @@ otherButtonTitles:nil ]; [alert show]; [alert release]; + */ } #pragma mark - @@ -177,11 +182,4 @@ SDL_SendWindowEvent(self.window, SDL_WINDOWEVENT_RESTORED, 0, 0); } -/* --(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { - NSLog(@"Rotating..."); - return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); -} -*/ - @end diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/SDLOverrides/SDL_uikitopengles.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitopengles.h Fri Jan 29 00:55:14 2010 +0000 @@ -0,0 +1,38 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#include "SDL_config.h" + +#ifndef _SDL_uikitopengles +#define _SDL_uikitopengles + +#include "SDL_uikitvideo.h" + +extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, + SDL_GLContext context); +extern void UIKit_GL_SwapWindow(_THIS, SDL_Window * window); +extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window); +extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context); +extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc); +extern int UIKit_GL_LoadLibrary(_THIS, const char *path); + +#endif diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/SDLOverrides/SDL_uikitopengles.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitopengles.m Fri Jan 29 00:55:14 2010 +0000 @@ -0,0 +1,128 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org + */ + +#include "SDL_uikitopengles.h" +#include "SDL_uikitopenglview.h" +#include "SDL_uikitappdelegate.h" +#include "SDL_uikitwindow.h" +#include "jumphack.h" +#include "SDL_sysvideo.h" +#include "SDL_loadso.h" +#include + +static int UIKit_GL_Initialize(_THIS); + +void * +UIKit_GL_GetProcAddress(_THIS, const char *proc) { + /* Look through all SO's for the proc symbol. Here's why: + -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator. + -We don't know that the path won't change in the future. + */ + return SDL_LoadFunction(RTLD_DEFAULT, proc); +} + +/* + note that SDL_GL_Delete context makes it current without passing the window + */ +int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { + + if (context) { + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + [data->view setCurrentContext]; + } + else { + [EAGLContext setCurrentContext: nil]; + } + + return 0; +} + +int UIKit_GL_LoadLibrary(_THIS, const char *path) { + /* + shouldn't be passing a path into this function + why? Because we've already loaded the library + and because the SDK forbids loading an external SO + */ + if (path != NULL) { + SDL_SetError("iPhone GL Load Library just here for compatibility"); + return -1; + } + return 0; +} + +void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) { + + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + + if (nil == data->view) { + return; + } + [data->view swapBuffers]; + /* since now we've got something to draw + make the window visible */ + [data->uiwindow makeKeyAndVisible]; + + /* we need to let the event cycle run, or the OS won't update the OpenGL view! */ + SDL_PumpEvents(); + +} + +SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) { + + SDL_uikitopenglview *view; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + + /* construct our view, passing in SDL's OpenGL configuration data */ + view = [[SDL_uikitopenglview alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame] \ + retainBacking: _this->gl_config.retained_backing \ + rBits: _this->gl_config.red_size \ + gBits: _this->gl_config.green_size \ + bBits: _this->gl_config.blue_size \ + aBits: _this->gl_config.alpha_size \ + depthBits: _this->gl_config.depth_size ]; + + data->view = view; + view.tag = 54321; + // rotate view + [view setTransform:CGAffineTransformMakeRotation(M_PI/2.0f)]; + /* add the view to our window */ + [data->uiwindow addSubview: view]; + + /* Don't worry, the window retained the view */ + [view release]; + + if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) { + UIKit_GL_DeleteContext(_this, view); + return NULL; + } + + return view; +} + +void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) { + /* the delegate has retained the view, this will release him */ + SDL_uikitopenglview *view = (SDL_uikitopenglview *)context; + /* this will also delete it */ + [view removeFromSuperview]; + + return; +} diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/SDLOverrides/SDL_uikitopenglview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitopenglview.h Fri Jan 29 00:55:14 2010 +0000 @@ -0,0 +1,65 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#import +#import +#import +#import +#import "SDL_uikitview.h" +/* + This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. + The view content is basically an EAGL surface you render your OpenGL scene into. + Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. + */ +/* *INDENT-OFF* */ +@interface SDL_uikitopenglview : SDL_uikitview { + +@private + /* The pixel dimensions of the backbuffer */ + GLint backingWidth; + GLint backingHeight; + + EAGLContext *context; + + /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ + GLuint viewRenderbuffer, viewFramebuffer; + + /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ + GLuint depthRenderbuffer; + +} + +@property (nonatomic, retain, readonly) EAGLContext *context; + +- (void)swapBuffers; +- (void)setCurrentContext; + +- (id)initWithFrame:(CGRect)frame + retainBacking:(BOOL)retained \ + rBits:(int)rBits \ + gBits:(int)gBits \ + bBits:(int)bBits \ + aBits:(int)aBits \ + depthBits:(int)depthBits; + +@end +/* *INDENT-ON* */ diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/SDLOverrides/SDL_uikitopenglview.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitopenglview.m Fri Jan 29 00:55:14 2010 +0000 @@ -0,0 +1,171 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org + */ + +#import +#import +#import "SDL_uikitopenglview.h" + +@interface SDL_uikitopenglview (privateMethods) + +- (BOOL) createFramebuffer; +- (void) destroyFramebuffer; + +@end + + +@implementation SDL_uikitopenglview + +@synthesize context; + ++ (Class)layerClass { + return [CAEAGLLayer class]; +} + +- (id)initWithFrame:(CGRect)frame \ +retainBacking:(BOOL)retained \ +rBits:(int)rBits \ +gBits:(int)gBits \ +bBits:(int)bBits \ +aBits:(int)aBits \ +depthBits:(int)depthBits \ +{ + + NSString *colorFormat=nil; + GLuint depthBufferFormat; + BOOL useDepthBuffer; + + if (rBits == 8 && gBits == 8 && bBits == 8) { + /* if user specifically requests rbg888 or some color format higher than 16bpp */ + colorFormat = kEAGLColorFormatRGBA8; + } + else { + /* default case (faster) */ + colorFormat = kEAGLColorFormatRGB565; + } + + if (depthBits == 24) { + useDepthBuffer = YES; + depthBufferFormat = GL_DEPTH_COMPONENT24_OES; + } + else if (depthBits == 0) { + useDepthBuffer = NO; + } + else { + /* default case when depth buffer is not disabled */ + /* + strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone. + perhaps that's the only depth format iPhone actually supports + */ + useDepthBuffer = YES; + depthBufferFormat = GL_DEPTH_COMPONENT16_OES; + } + + + // we invert heigh and size to get q landscape mode up + CGRect rect = [[UIScreen mainScreen] bounds]; + float swapTemp = rect.size.height; + rect.size.width = rect.size.height; + rect.size.height = swapTemp; + + if ((self = [super initWithFrame:rect])) { + // Get the layer + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil]; + + context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1]; + + if (!context || ![EAGLContext setCurrentContext:context]) { + [self release]; + return nil; + } + + /* create the buffers */ + glGenFramebuffersOES(1, &viewFramebuffer); + glGenRenderbuffersOES(1, &viewRenderbuffer); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); + + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + + if (useDepthBuffer) { + glGenRenderbuffersOES(1, &depthRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); + glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); + } + + if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + return NO; + } + /* end create buffers */ + } + return self; +} + +- (void)setCurrentContext { + [EAGLContext setCurrentContext:context]; +} + + +- (void)swapBuffers { + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; +} + + +- (void)layoutSubviews { + [EAGLContext setCurrentContext:context]; +} + +- (void)destroyFramebuffer { + + glDeleteFramebuffersOES(1, &viewFramebuffer); + viewFramebuffer = 0; + glDeleteRenderbuffersOES(1, &viewRenderbuffer); + viewRenderbuffer = 0; + + if (depthRenderbuffer) { + glDeleteRenderbuffersOES(1, &depthRenderbuffer); + depthRenderbuffer = 0; + } +} + + +- (void)dealloc { + + [self destroyFramebuffer]; + if ([EAGLContext currentContext] == context) { + [EAGLContext setCurrentContext:nil]; + } + [context release]; + [super dealloc]; + +} + +@end diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/SettingsViewController.m --- a/cocoaTouch/SettingsViewController.m Thu Jan 28 20:36:24 2010 +0000 +++ b/cocoaTouch/SettingsViewController.m Fri Jan 29 00:55:14 2010 +0000 @@ -163,10 +163,10 @@ #pragma mark - #pragma mark UIActionSheet Methods -(IBAction) deleteData: (id)sender { - UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you reeeeeally sure?" + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"") delegate:self - cancelButtonTitle:@"Well, maybe not..." - destructiveButtonTitle:@"Sure, let's start over" + cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"") + destructiveButtonTitle:NSLocalizedString(@"As sure as I can be!", @"") otherButtonTitles:nil]; [actionSheet showInView:self.view]; [actionSheet release]; @@ -176,7 +176,7 @@ if ([actionSheet cancelButtonIndex] != buttonIndex) { needsReset = YES; - // get the document dirctory + // get the documents dirctory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; @@ -191,8 +191,8 @@ } // force resetting - UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:@"Hit Home Button to Exit" - message:@"\nEverything is gone!\nNow you need to restart the game..." + UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Hit Home Button to Exit", @"") + message:NSLocalizedString(@"\nEverything is gone!\nNow you need to restart the game...", @"") delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; @@ -297,7 +297,7 @@ switch (section) { case kNetworkFields: - headerLabel.text = NSLocalizedString(@"Network Configuration", @"Network Configuration"); + headerLabel.text = NSLocalizedString(@"Network Configuration", @""); break; case kAudioFields: headerLabel.text = NSLocalizedString(@"Audio Preferences", @""); @@ -307,7 +307,7 @@ break; default: NSLog(@"Warning: unset case value in titleForHeaderInSection!"); - headerLabel.text = @"!!!"; + headerLabel.text = @"!"; break; } diff -r d891285e500f -r eaa6ac1e95ea cocoaTouch/otherSrc/SDL_image.h --- a/cocoaTouch/otherSrc/SDL_image.h Thu Jan 28 20:36:24 2010 +0000 +++ b/cocoaTouch/otherSrc/SDL_image.h Fri Jan 29 00:55:14 2010 +0000 @@ -40,8 +40,7 @@ #define SDL_IMAGE_MINOR_VERSION 2 #define SDL_IMAGE_PATCHLEVEL 10 -typedef enum -{ +typedef enum { IMG_INIT_JPG = 0x00000001, IMG_INIT_PNG = 0x00000002, IMG_INIT_TIF = 0x00000004 diff -r d891285e500f -r eaa6ac1e95ea hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Thu Jan 28 20:36:24 2010 +0000 +++ b/hedgewars/hwengine.pas Fri Jan 29 00:55:14 2010 +0000 @@ -230,8 +230,8 @@ initEverything(); Randomize(); - val('320', cScreenWidth); - val('480', cScreenHeight); + val('480', cScreenWidth); + val('320', cScreenHeight); cInitWidth:= cScreenWidth; cInitHeight:= cScreenHeight; cBitsStr:= '32'; diff -r d891285e500f -r eaa6ac1e95ea hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu Jan 28 20:36:24 2010 +0000 +++ b/hedgewars/uStore.pas Fri Jan 29 00:55:14 2010 +0000 @@ -1142,9 +1142,6 @@ // prepare default translation/scaling glLoadIdentity(); glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); -{$IFDEF IPHONEOS} - //glRotatef(90, 0, 0, 1); -{$ENDIF} glTranslatef(0, -cScreenHeight / 2, 0); // enable alpha blending @@ -1163,9 +1160,6 @@ glPushMatrix; // save default scaling glLoadIdentity; glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); -{$IFDEF IPHONEOS} - //glRotatef(90, 0, 0, 1); -{$ENDIF} glTranslatef(0, -cScreenHeight / 2, 0); end;