--- a/hedgewars/SDLh.pas Sun Mar 13 20:34:01 2011 +0300
+++ b/hedgewars/SDLh.pas Sun Mar 13 20:34:27 2011 +0300
@@ -93,10 +93,6 @@
///////////////////// CONSTANT DEFINITIONS /////////////////////
/////////////////////////////////////////////////////////////////
- SDL_SWSURFACE = $00000000;
- SDL_HWSURFACE = $00000001;
- SDL_SRCALPHA = $00010000;
-
SDL_INIT_TIMER = $00000001;
SDL_INIT_AUDIO = $00000010;
SDL_INIT_VIDEO = $00000020;
@@ -114,76 +110,114 @@
SDL_BUTTON_WHEELUP = 4;
SDL_BUTTON_WHEELDOWN = 5;
-
-{*begin SDL_Event binding*}
-
{$IFDEF SDL13}
- SDL_FIRSTEVENT = 0;
- SDL_QUITEV = $100;
- SDL_WINDOWEVENT = $200;
- SDL_SYSWMEVENT = $201;
- SDL_KEYDOWN = $300;
- SDL_KEYUP = $301;
- SDL_TEXTEDITING = $302;
- SDL_TEXTINPUT = $303;
- SDL_MOUSEMOTION = $400;
+ // SDL_Event types
+ SDL_FIRSTEVENT = 0;
+ SDL_QUITEV = $100;
+ SDL_WINDOWEVENT = $200;
+ SDL_SYSWMEVENT = $201;
+ SDL_KEYDOWN = $300;
+ SDL_KEYUP = $301;
+ SDL_TEXTEDITING = $302;
+ SDL_TEXTINPUT = $303;
+ SDL_MOUSEMOTION = $400;
SDL_MOUSEBUTTONDOWN = $401;
- SDL_MOUSEBUTTONUP = $402;
- SDL_MOUSEWHEEL = $403;
- SDL_PROXIMITYIN = $500;
- SDL_PROXIMITYOUT = $501;
- SDL_JOYAXISMOTION = $600;
- SDL_JOYBALLMOTION = $601;
- SDL_JOYHATMOTION = $602;
- SDL_JOYBUTTONDOWN = $603;
- SDL_JOYBUTTONUP = $604;
- SDL_USEREVENT = $8000;
- SDL_LASTEVENT = $FFFF;
-{$ELSE}
- SDL_NOEVENT = 0;
- SDL_ACTIVEEVENT = 1;
- SDL_KEYDOWN = 2;
- SDL_KEYUP = 3;
- SDL_MOUSEMOTION = 4;
- SDL_MOUSEBUTTONDOWN = 5;
- SDL_MOUSEBUTTONUP = 6;
- SDL_JOYAXISMOTION = 7;
- SDL_JOYBALLMOTION = 8;
- SDL_JOYHATMOTION = 9;
- SDL_JOYBUTTONDOWN = 10;
- SDL_JOYBUTTONUP = 11;
- SDL_QUITEV = 12;
- SDL_VIDEORESIZE = 16; // TODO: outdated? no longer in SDL 1.3?
-{$ENDIF}
-{*end SDL_Event binding*}
+ SDL_MOUSEBUTTONUP = $402;
+ SDL_MOUSEWHEEL = $403;
+ SDL_PROXIMITYIN = $500;
+ SDL_PROXIMITYOUT = $501;
+ SDL_JOYAXISMOTION = $600;
+ SDL_JOYBALLMOTION = $601;
+ SDL_JOYHATMOTION = $602;
+ SDL_JOYBUTTONDOWN = $603;
+ SDL_JOYBUTTONUP = $604;
+ SDL_USEREVENT = $8000;
+ SDL_LASTEVENT = $FFFF;
-{$IFDEF SDL13}
- SDL_ASYNCBLIT = $08000000;
- SDL_ANYFORMAT = $10000000;
+ // SDL_Surface flags
+ SDL_SWSURFACE = $00000000; //*< Not used */
+ SDL_PREALLOC = $00000001; //*< Surface uses preallocated memory */
+ SDL_RLEACCEL = $00000002; //*< Surface is RLE encoded */
+ SDL_DONTFREE = $00000004; //*< Surface is referenced internally */
+ SDL_SRCALPHA = $00010000;
+ SDL_SRCCOLORKEY = $00020000;
+ SDL_ANYFORMAT = $00100000;
SDL_HWPALETTE = $00200000;
SDL_DOUBLEBUF = $00400000;
SDL_FULLSCREEN = $00800000;
- SDL_HWACCEL = $08000000;
- SDL_SRCCOLORKEY = $00020000;
- SDL_RLEACCEL = $08000000;
+ SDL_RESIZABLE = $01000000;
SDL_NOFRAME = $02000000;
SDL_OPENGL = $04000000;
- SDL_RESIZABLE = $01000000;
+ SDL_HWSURFACE = $08000001; //*< Not used */
+ SDL_ASYNCBLIT = $08000000; //*< Not used */
+ SDL_RLEACCELOK = $08000000; //*< Not used */
+ SDL_HWACCEL = $08000000; //*< Not used */
+
+ // SDL_WindowFlags (enum)
+ SDL_WINDOW_FULLSCREEN = $00000001; //*< fullscreen window, implies borderless */
+ SDL_WINDOW_OPENGL = $00000002; //*< window usable with OpenGL context */
+ SDL_WINDOW_SHOWN = $00000004; //*< window is visible */
+// SDL_WINDOW_HIDDEN = $00000008; //*< window is not visible */
+ SDL_WINDOW_BORDERLESS = $00000008; //*< no window decoration */
+ SDL_WINDOW_RESIZABLE = $00000010; //*< window can be resized */
+ SDL_WINDOW_MINIMIZED = $00000020; //*< window is minimized */
+ SDL_WINDOW_MAXIMIZED = $00000040; //*< window is maximized */
+ SDL_WINDOW_INPUT_GRABBED = $00000100; //*< window has grabbed input focus */
+ SDL_WINDOW_INPUT_FOCUS = $00000200; //*< window has input focus */
+ SDL_WINDOW_MOUSE_FOCUS = $00000400; //*< window has mouse focus */
+ SDL_WINDOW_FOREIGN = $00000800; //*< window not created by SDL */
+
+ SDL_WINDOWPOS_CENTERED_MASK = $2FFF0000;
+
+ // SDL_WindowEventID (enum)
+ SDL_WINDOWEVENT_NONE = 0; //*< Never used
+ SDL_WINDOWEVENT_SHOWN = 1; //*< Window has been shown
+ SDL_WINDOWEVENT_HIDDEN = 2; //*< Window has been hidden
+ SDL_WINDOWEVENT_EXPOSED = 3; //*< Window has been exposed and should be redrawn
+ SDL_WINDOWEVENT_MOVED = 4; //*< Window has been moved to data1, data2
+ SDL_WINDOWEVENT_RESIZED = 5; //*< Window size changed to data1xdata2
+ SDL_WINDOWEVENT_MINIMIZED = 6; //*< Window has been minimized
+ SDL_WINDOWEVENT_MAXIMIZED = 7; //*< Window has been maximized
+ SDL_WINDOWEVENT_RESTORED = 8; //*< Window has been restored to normal size and position
+ SDL_WINDOWEVENT_ENTER = 9; //*< Window has gained mouse focus
+ SDL_WINDOWEVENT_LEAVE = 10; //*< Window has lost mouse focus
+ SDL_WINDOWEVENT_FOCUS_GAINED = 11; //*< Window has gained keyboard focus
+ SDL_WINDOWEVENT_FOCUS_LOST = 12; //*< Window has lost keyboard focus
+ SDL_WINDOWEVENT_CLOSE = 13; //*< The window manager requests that the window be closed */
{$ELSE}
+ // SDL_Event types
+ SDL_NOEVENT = 0;
+ SDL_ACTIVEEVENT = 1;
+ SDL_KEYDOWN = 2;
+ SDL_KEYUP = 3;
+ SDL_MOUSEMOTION = 4;
+ SDL_MOUSEBUTTONDOWN = 5;
+ SDL_MOUSEBUTTONUP = 6;
+ SDL_JOYAXISMOTION = 7;
+ SDL_JOYBALLMOTION = 8;
+ SDL_JOYHATMOTION = 9;
+ SDL_JOYBUTTONDOWN = 10;
+ SDL_JOYBUTTONUP = 11;
+ SDL_QUITEV = 12;
+ SDL_VIDEORESIZE = 16; // TODO: outdated? no longer in SDL 1.3?
+
+ // SDL_Surface flags
+ SDL_SWSURFACE = $00000000;
+ SDL_HWSURFACE = $00000001;
+ SDL_OPENGL = $00000002;
SDL_ASYNCBLIT = $00000004;
+ SDL_RESIZABLE = $00000010;
+ SDL_NOFRAME = $00000020;
+ SDL_HWACCEL = $00000100;
+ SDL_SRCCOLORKEY = $00001000;
+ SDL_RLEACCEL = $00004000;
+ SDL_SRCALPHA = $00010000;
SDL_ANYFORMAT = $00100000;
SDL_HWPALETTE = $20000000;
SDL_DOUBLEBUF = $40000000;
SDL_FULLSCREEN = $80000000;
- SDL_HWACCEL = $00000100;
- SDL_SRCCOLORKEY = $00001000;
- SDL_RLEACCEL = $00004000;
- SDL_NOFRAME = $00000020;
- SDL_OPENGL = $00000002;
- SDL_RESIZABLE = $00000010;
{$ENDIF}
-
{$IFDEF ENDIAN_LITTLE}
RMask = $000000FF;
GMask = $0000FF00;
@@ -196,43 +230,12 @@
AMask = $000000FF;
{$ENDIF}
-{$IFDEF SDL13}
- // SDL_WindowFlags (enum)
- SDL_WINDOW_FULLSCREEN = $00000001; //*< fullscreen window, implies borderless */
- SDL_WINDOW_OPENGL = $00000002; //*< window usable with OpenGL context */
- SDL_WINDOW_SHOWN = $00000004; //*< window is visible */
- SDL_WINDOW_BORDERLESS = $00000008; //*< no window decoration */
- SDL_WINDOW_RESIZABLE = $00000010; //*< window can be resized */
- SDL_WINDOW_MINIMIZED = $00000020; //*< window is minimized */
- SDL_WINDOW_MAXIMIZED = $00000040; //*< window is maximized */
- SDL_WINDOW_INPUT_GRABBED = $00000100; //*< window has grabbed input focus */
- SDL_WINDOW_INPUT_FOCUS = $00000200; //*< window has input focus */
- SDL_WINDOW_MOUSE_FOCUS = $00000400; //*< window has mouse focus */
- SDL_WINDOW_FOREIGN = $00000800; //*< window not created by SDL */
-
- // SDL_WindowEventID (enum)
- SDL_WINDOWEVENT_NONE = 0; //*< Never used
- SDL_WINDOWEVENT_SHOWN = 1; //*< Window has been shown
- SDL_WINDOWEVENT_HIDDEN = 2; //*< Window has been hidden
- SDL_WINDOWEVENT_EXPOSED = 3; //*< Window has been exposed and should be redrawn
- SDL_WINDOWEVENT_MOVED = 4; //*< Window has been moved to data1, data2
- SDL_WINDOWEVENT_RESIZED = 5; //*< Window size changed to data1xdata2
- SDL_WINDOWEVENT_MINIMIZED = 6; //*< Window has been minimized
- SDL_WINDOWEVENT_MAXIMIZED = 7; //*< Window has been maximized
- SDL_WINDOWEVENT_RESTORED = 8; //*< Window has been restored to normal size and position
- SDL_WINDOWEVENT_ENTER = 9; //*< Window has gained mouse focus
- SDL_WINDOWEVENT_LEAVE = 10; //*< Window has lost mouse focus
- SDL_WINDOWEVENT_FOCUS_GAINED = 11; //*< Window has gained keyboard focus
- SDL_WINDOWEVENT_FOCUS_LOST = 12; //*< Window has lost keyboard focus
- SDL_WINDOWEVENT_CLOSE = 13; //*< The window manager requests that the window be closed */
-{$ENDIF}
-
{* SDL_mixer *}
MIX_MAX_VOLUME = 128;
- MIX_INIT_FLAC = $00000001;
- MIX_INIT_MOD = $00000002;
- MIX_INIT_MP3 = $00000004;
- MIX_INIT_OGG = $00000008;
+ MIX_INIT_FLAC = $00000001;
+ MIX_INIT_MOD = $00000002;
+ MIX_INIT_MP3 = $00000004;
+ MIX_INIT_OGG = $00000008;
{* SDL_TTF *}
TTF_STYLE_NORMAL = 0;
@@ -247,8 +250,8 @@
SDL_HAT_LEFT = $08;
SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP;
SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
- SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
- SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
+ SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
+ SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
{* SDL_image *}
IMG_INIT_JPG = $00000001;
@@ -277,6 +280,9 @@
PSDL_PixelFormat = ^TSDL_PixelFormat;
TSDL_PixelFormat = record
+{$IFDEF SDL13}
+ format: Longword;
+{$ENDIF}
palette: Pointer;
BitsPerPixel : Byte;
BytesPerPixel: Byte;
@@ -292,8 +298,13 @@
GMask : Longword;
BMask : Longword;
AMask : Longword;
+{$IFDEF SDL13}
+ refcount: LongInt;
+ next: Pointer;
+{$ELSE}
colorkey: Longword;
- alpha : Byte;
+ alpha: Byte;
+{$ENDIF}
end;
@@ -720,7 +731,6 @@
function SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
function SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
procedure SDL_VideoQuit; cdecl; external SDLLibName;
-function SDL_SelectVideoDisplay(index: LongInt): LongInt; cdecl; external SDLLibName;
function SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
function SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r,g,b,a: byte): LongInt; cdecl; external SDLLibName;
@@ -733,6 +743,9 @@
function SDL_GetRelativeMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
function SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
function SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
+
+function SDL_AllocFormat(format: Longword): PSDL_PixelFormat; cdecl; external SDLLibName;
+procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
{$ENDIF}
function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
@@ -863,7 +876,11 @@
function SDL_MustLock(Surface: PSDL_Surface): Boolean;
begin
+{$IFDEF SDL13}
+ SDL_MustLock:= ((surface^.flags and SDL_RLEACCEL) <> 0)
+{$ELSE}
SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
+{$ENDIF}
end;
procedure SDLNet_Write16(value: Word; buf: pointer);
--- a/hedgewars/uMisc.pas Sun Mar 13 20:34:01 2011 +0300
+++ b/hedgewars/uMisc.pas Sun Mar 13 20:34:27 2011 +0300
@@ -21,7 +21,7 @@
unit uMisc;
interface
-uses SDLh, uConsts, GLunit, uTypes;
+uses SDLh, uConsts, GLunit, uTypes;
procedure movecursor(dx, dy: LongInt);
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
@@ -116,11 +116,21 @@
FreeMem(p)
end;
+// http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
-{* for more information http://www.idevgames.com/forum/showpost.php?p=85864&postcount=7 *}
-var convertedSurf: PSDL_Surface = nil;
+const conversionFormat: TSDL_PixelFormat = (
+{$IFDEF SDL13}format: 0;{$ENDIF}
+ palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
+ Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
+{$IFDEF ENDIAN_LITTLE}Rshift: 0; Gshift: 8; Bshift: 16; Ashift: 24;
+{$ELSE} Rshift: 24; Gshift: 16; Bshift: 8; Ashift: 0;{$ENDIF}
+ RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
+{$IFDEF SDL13}refcount: 0; next: nil;
+{$ELSE} colorkey: 0; alpha: 255{$ENDIF});
+var convertedSurf: PSDL_Surface;
begin
- if (tmpsurf^.format^.bitsperpixel = 24) or ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) then
+ if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
+ (tmpsurf^.format^.bitsperpixel = 24) then
begin
convertedSurf:= SDL_ConvertSurface(tmpsurf, @conversionFormat, SDL_SWSURFACE);
SDL_FreeSurface(tmpsurf);
--- a/hedgewars/uStore.pas Sun Mar 13 20:34:01 2011 +0300
+++ b/hedgewars/uStore.pas Sun Mar 13 20:34:27 2011 +0300
@@ -881,6 +881,7 @@
var flags: Longword = 0;
ico: PSDL_Surface;
buf: array[byte] of char;
+ x, y: LongInt;
begin
s:= s; // avoid compiler hint
if Length(s) = 0 then cFullScreen:= not cFullScreen
@@ -922,20 +923,17 @@
end;
{$IFDEF SDL13}
-{$IFDEF IPHONEOS}
- // ipad can have 2 monitors, display sdl window on the second one
- SDL_SelectVideoDisplay(SDL_GetNumVideoDisplays() - 1);
-{$ENDIF}
-
if SDLwindow = nil then
begin
- SDLwindow:= SDL_CreateWindow('Hedgewars', 0, 0, cScreenWidth, cScreenHeight,
- SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN
- {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF});
+ // on ipad, when second monitor is attached, display window in second monitor always
+ x:= {$IFDEF IPHONEOS}(SDL_WINDOWPOS_CENTERED_MASK or (SDL_GetNumVideoDisplays() - 1)){$ELSE}0{$ENDIF};
+ y:= {$IFDEF IPHONEOS}(SDL_WINDOWPOS_CENTERED_MASK or (SDL_GetNumVideoDisplays() - 1)){$ELSE}0{$ENDIF};
+ SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN
+ {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS {$ENDIF});
SDLrender:= SDL_CreateRenderer(SDLwindow, -1, 1 and 2);
end;
- SDL_SetRenderDrawColor(SDLrender,0, 0, 0, 255);
+ SDL_SetRenderDrawColor(SDLrender, 0, 0, 0, 255);
SDL_RenderClear(SDLrender);
SDL_RenderPresent(SDLrender);
{$ELSE}
--- a/hedgewars/uVariables.pas Sun Mar 13 20:34:01 2011 +0300
+++ b/hedgewars/uVariables.pas Sun Mar 13 20:34:27 2011 +0300
@@ -2077,35 +2077,6 @@
ejectY: 0)
);
-
- conversionFormat: TSDL_PixelFormat = (
- palette: nil;
- BitsPerPixel : 32;
- BytesPerPixel: 4;
- Rloss : 0;
- Gloss : 0;
- Bloss : 0;
- Aloss : 0;
-{$IFDEF ENDIAN_LITTLE}
- Rshift: 0;
- Gshift: 8;
- Bshift: 16;
- Ashift: 24;
-{$ELSE}
- Rshift: 24;
- Gshift: 16;
- Bshift: 8;
- Ashift: 0;
-{$ENDIF}
- RMask : RMask;
- GMask : GMask;
- BMask : BMask;
- AMask : AMask;
- colorkey: 0;
- alpha : 255
- );
-
-
var
Land: TCollisionArray;
LandPixels: TLandArray;
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sun Mar 13 20:34:27 2011 +0300
@@ -20,7 +20,6 @@
#import "GameConfigViewController.h"
-#import "SDL_uikitappdelegate.h"
#import "MapConfigViewController.h"
#import "TeamConfigViewController.h"
#import "SchemeWeaponConfigViewController.h"
@@ -242,11 +241,11 @@
NSArray *stats;
if (IS_DUALHEAD()) {
- stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
+ stats = [[HedgewarsAppDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
[self presentModalViewController:statsPage animated:NO];
} else {
[self performSelector:@selector(presentModalViewController:animated:) withObject:statsPage afterDelay:3];
- stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
+ stats = [[HedgewarsAppDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
}
if ([stats count] <= 1) {
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Sun Mar 13 20:34:27 2011 +0300
@@ -20,7 +20,6 @@
#import "GameSetup.h"
-#import "SDL_uikitappdelegate.h"
#import "PascalImports.h"
#import "CommodityFunctions.h"
#import "OverlayViewController.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.h Sun Mar 13 20:34:27 2011 +0300
@@ -0,0 +1,48 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2011 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 <UIKit/UIKit.h>
+#import "SDL_uikitappdelegate.h"
+
+@class MainMenuViewController;
+@class OverlayViewController;
+
+@interface HedgewarsAppDelegate:SDLUIKitDelegate {
+ MainMenuViewController *mainViewController;
+ OverlayViewController *overlayController;
+ UIWindow *uiwindow;
+ UIWindow *secondWindow;
+ BOOL isInGame;
+}
+
+@property (assign) BOOL isInGame;
+@property (nonatomic,retain) MainMenuViewController *mainViewController;
+@property (nonatomic,retain) OverlayViewController *overlayController;
+@property (nonatomic,retain) UIWindow *uiwindow;
+@property (nonatomic,retain) UIWindow *secondWindow;
+
++(HedgewarsAppDelegate *)sharedAppDelegate;
+-(NSArray *)startSDLgame:(NSDictionary *)gameDictionary;
+-(void) displayOverlayLater:(id) object;
+
+@end
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m Sun Mar 13 20:34:27 2011 +0300
@@ -0,0 +1,261 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2011 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, mods for Hedgewars by Vittorio Giovara
+ slouken@libsdl.org, vittorio.giovara@gmail.com
+*/
+
+#import "HedgewarsAppDelegate.h"
+#import "PascalImports.h"
+#import "ObjcExports.h"
+#import "CommodityFunctions.h"
+#import "GameSetup.h"
+#import "MainMenuViewController.h"
+#import "OverlayViewController.h"
+#import "Appirater.h"
+#include <unistd.h>
+
+#ifdef main
+#undef main
+#endif
+
+#define BLACKVIEW_TAG 17935
+#define SECONDBLACKVIEW_TAG 48620
+#define VALGRIND "/opt/fink/bin/valgrind"
+
+int main (int argc, char *argv[]) {
+#ifdef VALGRIND_REXEC
+ // Using the valgrind build config, rexec ourself in valgrind
+ // from http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html
+ if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0))
+ execl(VALGRIND, VALGRIND, "--leak-check=full", "--dsymutil=yes", argv[0], "-valgrind", NULL);
+#endif
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ int retVal = UIApplicationMain(argc, argv, nil, @"HedgewarsAppDelegate");
+ [pool release];
+ return retVal;
+}
+
+int SDL_main(int argc, char **argv) {
+ // dummy function to prevent linkage fail
+ return 0;
+}
+
+@implementation HedgewarsAppDelegate
+@synthesize mainViewController, overlayController, uiwindow, secondWindow, isInGame;
+
+// convenience method
++(HedgewarsAppDelegate *)sharedAppDelegate {
+ return (HedgewarsAppDelegate *)[[UIApplication sharedApplication] delegate];
+}
+
+-(id) init {
+ if (self = [super init]){
+ mainViewController = nil;
+ uiwindow = nil;
+ secondWindow = nil;
+ isInGame = NO;
+ }
+ return self;
+}
+
+-(void) dealloc {
+ [mainViewController release];
+ [overlayController release];
+ [uiwindow release];
+ [secondWindow release];
+ [super dealloc];
+}
+
+// main routine for calling the actual game engine
+-(NSArray *)startSDLgame:(NSDictionary *)gameDictionary {
+ UIWindow *gameWindow;
+ if (IS_DUALHEAD())
+ gameWindow = self.secondWindow;
+ else
+ gameWindow = self.uiwindow;
+
+ UIView *blackView = [[UIView alloc] initWithFrame:gameWindow.frame];
+ blackView.backgroundColor = [UIColor blackColor];
+ blackView.opaque = YES;
+ blackView.tag = BLACKVIEW_TAG;
+ [gameWindow addSubview:blackView];
+ if (IS_DUALHEAD()) {
+ blackView.alpha = 0;
+ [UIView beginAnimations:@"fading to game first" context:NULL];
+ [UIView setAnimationDuration:1];
+ blackView.alpha = 1;
+ [UIView commitAnimations];
+
+ UIView *secondBlackView = [[UIView alloc] initWithFrame:self.uiwindow.frame];
+ secondBlackView.backgroundColor = [UIColor blackColor];
+ secondBlackView.opaque = YES;
+ secondBlackView.tag = SECONDBLACKVIEW_TAG;
+ secondBlackView.alpha = 0;
+ [self.uiwindow addSubview:secondBlackView];
+ [UIView beginAnimations:@"fading to game second" context:NULL];
+ [UIView setAnimationDuration:1];
+ secondBlackView.alpha = 1;
+ [UIView commitAnimations];
+ [secondBlackView release];
+ }
+ [blackView release];
+
+
+ // pull out useful configuration info from various files
+ GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary];
+ NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"];
+
+ [NSThread detachNewThreadSelector:@selector(engineProtocol)
+ toTarget:setup
+ withObject:nil];
+
+ NSNumber *menuStyle = [NSNumber numberWithBool:setup.menuStyle];
+ NSNumber *orientation = [[gameDictionary objectForKey:@"game_dictionary"] objectForKey:@"orientation"];
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ isNetGameNum,@"net",
+ menuStyle,@"menu",
+ orientation,@"orientation",
+ nil];
+ [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:1];
+
+ // need to set again [gameDictionary objectForKey:@"savefile"] because if it's empty it means it's a normal game
+ const char **gameArgs = [setup getGameSettings:[gameDictionary objectForKey:@"savefile"]];
+ self.isInGame = YES;
+ // this is the pascal fuction that starts the game
+ Game(gameArgs);
+ self.isInGame = NO;
+ free(gameArgs);
+
+ NSArray *stats = setup.statsArray;
+ [setup release];
+
+
+ [self.uiwindow makeKeyAndVisible];
+ [self.uiwindow bringSubviewToFront:self.mainViewController.view];
+
+ UIView *refBlackView = [gameWindow viewWithTag:BLACKVIEW_TAG];
+ UIView *refSecondBlackView = [self.uiwindow viewWithTag:SECONDBLACKVIEW_TAG];
+ [UIView beginAnimations:@"fading in from ingame" context:NULL];
+ [UIView setAnimationDuration:1];
+ refBlackView.alpha = 0;
+ refSecondBlackView.alpha = 0;
+ [UIView commitAnimations];
+ [refBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1];
+ [refSecondBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:2];
+
+ return stats;
+}
+
+// overlay with controls, become visible later, with a transparency effect since the sdlwindow is not yet created
+-(void) displayOverlayLater:(id) object {
+ NSDictionary *dict = (NSDictionary *)object;
+ self.overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
+ self.overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue];
+ self.overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue];
+ self.overlayController.initialOrientation = [[dict objectForKey:@"orientation"] intValue];
+
+ UIWindow *gameWindow;
+ if (IS_DUALHEAD())
+ gameWindow = self.uiwindow;
+ else
+ gameWindow = [[UIApplication sharedApplication] keyWindow];
+ [gameWindow addSubview:self.overlayController.view];
+}
+
+// override the direct execution of SDL_main to allow us to implement our own frontend
+-(void) postFinishLaunch {
+ [[UIApplication sharedApplication] setStatusBarHidden:YES];
+ [Appirater appLaunched];
+
+ self.uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+
+ if (IS_IPAD())
+ self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil];
+ else
+ self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil];
+
+ [self.uiwindow addSubview:self.mainViewController.view];
+ [self.mainViewController release];
+ self.uiwindow.backgroundColor = [UIColor blackColor];
+ [self.uiwindow makeKeyAndVisible];
+
+ // check for dual monitor support
+ if (IS_DUALHEAD()) {
+ DLog(@"dual head mode ftw");
+ self.secondWindow = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:1] bounds]];
+ self.secondWindow.backgroundColor = [UIColor blackColor];
+ self.secondWindow.screen = [[UIScreen screens] objectAtIndex:1];
+ UIImage *titleImage = [UIImage imageWithContentsOfFile:@"title.png"];
+ UIImageView *titleView = [[UIImageView alloc] initWithImage:titleImage];
+ titleView.center = self.secondWindow.center;
+ [self.secondWindow addSubview:titleView];
+ [titleView release];
+ [self.secondWindow makeKeyAndVisible];
+ }
+}
+
+-(void) applicationWillTerminate:(UIApplication *)application {
+ if (self.isInGame)
+ HW_terminate(YES);
+
+ [super applicationWillTerminate:application];
+}
+
+-(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
+ // don't clean mainMenuViewController here!!!
+ MSG_MEMCLEAN();
+ print_free_memory();
+}
+
+-(void) applicationWillResignActive:(UIApplication *)application {
+ [super applicationWillResignActive: application];
+
+ UIDevice* device = [UIDevice currentDevice];
+ if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
+ device.multitaskingSupported &&
+ self.isInGame) {
+ // let's try to be permissive with multitasking here...
+ NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
+ if ([[settings objectForKey:@"multitasking"] boolValue])
+ HW_suspend();
+ else {
+ // so the game returns to the configuration view
+ if (isGameRunning())
+ HW_terminate(NO);
+ else {
+ // while screen is loading you can't call HW_terminate() so we close the app
+ [self applicationWillTerminate:application];
+ }
+ }
+ [settings release];
+ }
+}
+
+-(void) applicationDidBecomeActive:(UIApplication *)application {
+ [super applicationDidBecomeActive:application];
+
+ UIDevice* device = [UIDevice currentDevice];
+ if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
+ device.multitaskingSupported &&
+ self.isInGame) {
+ HW_resume();
+ }
+}
+
+@end
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Sun Mar 13 20:34:27 2011 +0300
@@ -19,7 +19,6 @@
*/
-#import "SDL_uikitappdelegate.h"
#import "InGameMenuViewController.h"
#import "PascalImports.h"
#import "CommodityFunctions.h"
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Mar 13 20:34:27 2011 +0300
@@ -21,7 +21,6 @@
#import "MainMenuViewController.h"
#import "CreationChamber.h"
-#import "SDL_uikitappdelegate.h"
#import "PascalImports.h"
#import "GameConfigViewController.h"
#import "SplitViewRootController.h"
--- a/project_files/HedgewarsMobile/Classes/ObjcExports.m Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/ObjcExports.m Sun Mar 13 20:34:27 2011 +0300
@@ -97,7 +97,7 @@
void clearView() {
// don't use any engine calls here as this function is called every time the ammomenu is opened
- UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
+ UIWindow *theWindow = (IS_DUALHEAD()) ? [HedgewarsAppDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.h Sun Mar 13 20:34:01 2011 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2011 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 <UIKit/UIKit.h>
-
-@class MainMenuViewController;
-@class OverlayViewController;
-
-@interface SDLUIKitDelegate:NSObject<UIApplicationDelegate> {
- MainMenuViewController *mainViewController;
- OverlayViewController *overlayController;
- UIWindow *uiwindow;
- UIWindow *secondWindow;
- BOOL isInGame;
-}
-
-@property (assign) BOOL isInGame;
-@property (nonatomic,retain) MainMenuViewController *mainViewController;
-@property (nonatomic,retain) OverlayViewController *overlayController;
-@property (nonatomic,retain) UIWindow *uiwindow;
-@property (nonatomic,retain) UIWindow *secondWindow;
-
-+(SDLUIKitDelegate *)sharedAppDelegate;
--(NSArray *)startSDLgame:(NSDictionary *)gameDictionary;
--(void) displayOverlayLater:(id) object;
-
-@end
-
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Sun Mar 13 20:34:01 2011 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,269 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2011 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, mods for Hedgewars by Vittorio Giovara
- slouken@libsdl.org, vittorio.giovara@gmail.com
-*/
-
-#import "SDL_uikitappdelegate.h"
-#import "SDL_uikitopenglview.h"
-#import "SDL_uikitwindow.h"
-#import "SDL_events_c.h"
-#import "jumphack.h"
-#import "SDL_video.h"
-#import "SDL_mixer.h"
-#import "PascalImports.h"
-#import "ObjcExports.h"
-#import "CommodityFunctions.h"
-#import "GameSetup.h"
-#import "MainMenuViewController.h"
-#import "OverlayViewController.h"
-#import "Appirater.h"
-#include <unistd.h>
-
-#ifdef main
-#undef main
-#endif
-
-#define BLACKVIEW_TAG 17935
-#define SECONDBLACKVIEW_TAG 48620
-#define VALGRIND "/opt/fink/bin/valgrind"
-
-int main (int argc, char *argv[]) {
-#ifdef VALGRIND_REXEC
- // Using the valgrind build config, rexec ourself in valgrind
- // from http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html
- if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0))
- execl(VALGRIND, VALGRIND, "--leak-check=full", "--dsymutil=yes", argv[0], "-valgrind", NULL);
-#endif
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, @"SDLUIKitDelegate");
- [pool release];
- return retVal;
-}
-
-@implementation SDLUIKitDelegate
-@synthesize mainViewController, overlayController, uiwindow, secondWindow, isInGame;
-
-// convenience method
-+(SDLUIKitDelegate *)sharedAppDelegate {
- // the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
- return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
-}
-
--(id) init {
- if (self = [super init]){
- mainViewController = nil;
- uiwindow = nil;
- secondWindow = nil;
- isInGame = NO;
- }
- return self;
-}
-
--(void) dealloc {
- [mainViewController release];
- [overlayController release];
- [uiwindow release];
- [secondWindow release];
- [super dealloc];
-}
-
-// main routine for calling the actual game engine
--(NSArray *)startSDLgame:(NSDictionary *)gameDictionary {
- UIWindow *gameWindow;
- if (IS_DUALHEAD())
- gameWindow = self.secondWindow;
- else
- gameWindow = self.uiwindow;
-
- UIView *blackView = [[UIView alloc] initWithFrame:gameWindow.frame];
- blackView.backgroundColor = [UIColor blackColor];
- blackView.opaque = YES;
- blackView.tag = BLACKVIEW_TAG;
- [gameWindow addSubview:blackView];
- if (IS_DUALHEAD()) {
- blackView.alpha = 0;
- [UIView beginAnimations:@"fading to game first" context:NULL];
- [UIView setAnimationDuration:1];
- blackView.alpha = 1;
- [UIView commitAnimations];
-
- UIView *secondBlackView = [[UIView alloc] initWithFrame:self.uiwindow.frame];
- secondBlackView.backgroundColor = [UIColor blackColor];
- secondBlackView.opaque = YES;
- secondBlackView.tag = SECONDBLACKVIEW_TAG;
- secondBlackView.alpha = 0;
- [self.uiwindow addSubview:secondBlackView];
- [UIView beginAnimations:@"fading to game second" context:NULL];
- [UIView setAnimationDuration:1];
- secondBlackView.alpha = 1;
- [UIView commitAnimations];
- [secondBlackView release];
- }
- [blackView release];
-
-
- // pull out useful configuration info from various files
- GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary];
- NSNumber *isNetGameNum = [gameDictionary objectForKey:@"netgame"];
-
- [NSThread detachNewThreadSelector:@selector(engineProtocol)
- toTarget:setup
- withObject:nil];
-
- NSNumber *menuStyle = [NSNumber numberWithBool:setup.menuStyle];
- NSNumber *orientation = [[gameDictionary objectForKey:@"game_dictionary"] objectForKey:@"orientation"];
- NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
- isNetGameNum,@"net",
- menuStyle,@"menu",
- orientation,@"orientation",
- nil];
- [self performSelector:@selector(displayOverlayLater:) withObject:dict afterDelay:1];
-
- // need to set again [gameDictionary objectForKey:@"savefile"] because if it's empty it means it's a normal game
- const char **gameArgs = [setup getGameSettings:[gameDictionary objectForKey:@"savefile"]];
- self.isInGame = YES;
- // this is the pascal fuction that starts the game
- Game(gameArgs);
- self.isInGame = NO;
- free(gameArgs);
-
- NSArray *stats = setup.statsArray;
- [setup release];
-
-
- [self.uiwindow makeKeyAndVisible];
- [self.uiwindow bringSubviewToFront:self.mainViewController.view];
-
- UIView *refBlackView = [gameWindow viewWithTag:BLACKVIEW_TAG];
- UIView *refSecondBlackView = [self.uiwindow viewWithTag:SECONDBLACKVIEW_TAG];
- [UIView beginAnimations:@"fading in from ingame" context:NULL];
- [UIView setAnimationDuration:1];
- refBlackView.alpha = 0;
- refSecondBlackView.alpha = 0;
- [UIView commitAnimations];
- [refBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1];
- [refSecondBlackView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:2];
-
- return stats;
-}
-
-// overlay with controls, become visible later, with a transparency effect since the sdlwindow is not yet created
--(void) displayOverlayLater:(id) object {
- NSDictionary *dict = (NSDictionary *)object;
- self.overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
- self.overlayController.isNetGame = [[dict objectForKey:@"net"] boolValue];
- self.overlayController.useClassicMenu = [[dict objectForKey:@"menu"] boolValue];
- self.overlayController.initialOrientation = [[dict objectForKey:@"orientation"] intValue];
-
- UIWindow *gameWindow;
- if (IS_DUALHEAD())
- gameWindow = self.uiwindow;
- else
- gameWindow = [[UIApplication sharedApplication] keyWindow];
- [gameWindow addSubview:self.overlayController.view];
-}
-
-// override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib)
--(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- [application setStatusBarHidden:YES];
-
- self.uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-
- if (IS_IPAD())
- self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil];
- else
- self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil];
-
- [self.uiwindow addSubview:self.mainViewController.view];
- [self.mainViewController release];
- self.uiwindow.backgroundColor = [UIColor blackColor];
- [self.uiwindow makeKeyAndVisible];
-
- // set working directory to resource path
- [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];
-
- // check for dual monitor support
- if (IS_DUALHEAD()) {
- DLog(@"dual head mode ftw");
- self.secondWindow = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:1] bounds]];
- self.secondWindow.backgroundColor = [UIColor blackColor];
- self.secondWindow.screen = [[UIScreen screens] objectAtIndex:1];
- UIImage *titleImage = [UIImage imageWithContentsOfFile:@"title.png"];
- UIImageView *titleView = [[UIImageView alloc] initWithImage:titleImage];
- titleView.center = self.secondWindow.center;
- [self.secondWindow addSubview:titleView];
- [titleView release];
- [self.secondWindow makeKeyAndVisible];
- }
-
- [Appirater appLaunched];
- return YES;
-}
-
--(void) applicationWillTerminate:(UIApplication *)application {
- SDL_SendQuit();
-
- if (self.isInGame) {
- HW_terminate(YES);
- // hack to prevent automatic termination. See SDL_uikitevents.m for details
- longjmp(*(jump_env()), 1);
- }
-}
-
--(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
- // don't clean mainMenuViewController here!!!
- MSG_MEMCLEAN();
- print_free_memory();
-}
-
--(void) applicationWillResignActive:(UIApplication *)application {
- UIDevice* device = [UIDevice currentDevice];
- if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
- device.multitaskingSupported &&
- self.isInGame) {
- // let's try to be permissive with multitasking here...
- NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
- if ([[settings objectForKey:@"multitasking"] boolValue])
- HW_suspend();
- else {
- // so the game returns to the configuration view
- if (isGameRunning())
- HW_terminate(NO);
- else {
- // while screen is loading you can't call HW_terminate() so we close the app
- SDL_SendQuit();
- HW_terminate(YES);
- longjmp(*(jump_env()), 1);
- }
- }
- [settings release];
- }
-}
-
--(void) applicationDidBecomeActive:(UIApplication *)application {
- UIDevice* device = [UIDevice currentDevice];
- if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
- device.multitaskingSupported &&
- self.isInGame) {
- HW_resume();
- }
-}
-
-@end
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m Sun Mar 13 20:34:27 2011 +0300
@@ -20,7 +20,6 @@
#import "SavedGamesViewController.h"
-#import "SDL_uikitappdelegate.h"
#import "StatsPageViewController.h"
#import "CommodityFunctions.h"
@@ -228,11 +227,11 @@
NSArray *stats;
if (IS_DUALHEAD()) {
- stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
+ stats = [[HedgewarsAppDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
[self presentModalViewController:statsPage animated:NO];
} else {
[self performSelector:@selector(presentModalViewController:animated:) withObject:statsPage afterDelay:3];
- stats = [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
+ stats = [[HedgewarsAppDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
}
if ([stats count] <= 1) {
--- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Sun Mar 13 20:34:27 2011 +0300
@@ -21,7 +21,6 @@
#import "SchemeWeaponConfigViewController.h"
#import "CommodityFunctions.h"
-#import "SDL_uikitappdelegate.h"
#define LABEL_TAG 57423
@@ -262,7 +261,7 @@
#pragma mark -
#pragma mark Memory management
-(void) didReceiveMemoryWarning {
- if ([[SDLUIKitDelegate sharedAppDelegate] isInGame]) {
+ if ([[HedgewarsAppDelegate sharedAppDelegate] isInGame]) {
self.lastIndexPath_sc = nil;
self.lastIndexPath_we = nil;
self.listOfSchemes = nil;
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sun Mar 13 20:34:27 2011 +0300
@@ -111,7 +111,7 @@
6165925311CA9CB400D6E256 /* MainMenuViewController-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6165924B11CA9CB400D6E256 /* MainMenuViewController-iPad.xib */; };
6165925511CA9CB400D6E256 /* MapConfigViewController-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6165924D11CA9CB400D6E256 /* MapConfigViewController-iPad.xib */; };
6165925811CA9CB400D6E256 /* OverlayViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6165925011CA9CB400D6E256 /* OverlayViewController.xib */; };
- 6165929E11CA9E2F00D6E256 /* SDL_uikitappdelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6165929D11CA9E2F00D6E256 /* SDL_uikitappdelegate.m */; };
+ 6165929E11CA9E2F00D6E256 /* HedgewarsAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6165929D11CA9E2F00D6E256 /* HedgewarsAppDelegate.m */; };
6172555A12B3DD4A0098D069 /* libLua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6172555912B3DCEE0098D069 /* libLua.a */; };
6172FED91298CF9800D73365 /* background~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = 6172FED71298CF9800D73365 /* background~iphone.png */; };
6172FEEF1298D25D00D73365 /* mediumBackground~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 6172FEEB1298D25D00D73365 /* mediumBackground~ipad.png */; };
@@ -182,7 +182,7 @@
61AC067412B2E32D000B52A2 /* Appirater.m in Sources */ = {isa = PBXBuildFile; fileRef = 61AC067312B2E32D000B52A2 /* Appirater.m */; };
61B3D71C11EA6F2700EC7420 /* uKeys.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987FE114AA34C00BA94A9 /* uKeys.pas */; };
61B7A33812CC21080086B604 /* StatsPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B7A33712CC21080086B604 /* StatsPageViewController.m */; };
- 61B7A61512FA13B00051E14E /* libSDLiPhoneOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B7A54E12FA129F0051E14E /* libSDLiPhoneOS.a */; };
+ 61B7A61512FA13B00051E14E /* libSDL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B7A54E12FA129F0051E14E /* libSDL.a */; };
61B7A61612FA13B00051E14E /* libSDL_image.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B7A55812FA12AD0051E14E /* libSDL_image.a */; };
61B7A61712FA13B00051E14E /* libSDL_mixer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B7A56012FA12BF0051E14E /* libSDL_mixer.a */; };
61B7A61812FA13B00051E14E /* libSDL_net.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B7A56812FA12D00051E14E /* libSDL_net.a */; };
@@ -879,8 +879,8 @@
6165924D11CA9CB400D6E256 /* MapConfigViewController-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MapConfigViewController-iPad.xib"; path = "Resources/MapConfigViewController-iPad.xib"; sourceTree = SOURCE_ROOT; };
6165924E11CA9CB400D6E256 /* MapConfigViewController-iPhone.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MapConfigViewController-iPhone.xib"; path = "Resources/MapConfigViewController-iPhone.xib"; sourceTree = SOURCE_ROOT; };
6165925011CA9CB400D6E256 /* OverlayViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = OverlayViewController.xib; path = Resources/OverlayViewController.xib; sourceTree = SOURCE_ROOT; };
- 6165929C11CA9E2F00D6E256 /* SDL_uikitappdelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_uikitappdelegate.h; path = Classes/SDL_uikitappdelegate.h; sourceTree = "<group>"; };
- 6165929D11CA9E2F00D6E256 /* SDL_uikitappdelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_uikitappdelegate.m; path = Classes/SDL_uikitappdelegate.m; sourceTree = "<group>"; };
+ 6165929C11CA9E2F00D6E256 /* HedgewarsAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HedgewarsAppDelegate.h; path = Classes/HedgewarsAppDelegate.h; sourceTree = "<group>"; };
+ 6165929D11CA9E2F00D6E256 /* HedgewarsAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HedgewarsAppDelegate.m; path = Classes/HedgewarsAppDelegate.m; sourceTree = "<group>"; };
6172554E12B3DCEE0098D069 /* Lua.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Lua.xcodeproj; path = ../../../Library/Lua/Lua.xcodeproj; sourceTree = SOURCE_ROOT; };
6172FEA21298C7F900D73365 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "Resources/Icons/Default@2x.png"; sourceTree = "<group>"; };
6172FEC81298CE4800D73365 /* savesButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "savesButton@2x.png"; path = "Resources/Frontend/savesButton@2x.png"; sourceTree = "<group>"; };
@@ -1023,7 +1023,7 @@
922F64900F10F53100DC6EC0 /* libfpc.a in Frameworks */,
611E03E711FA747C0077A41E /* libvorbis.a in Frameworks */,
611E0E5111FA92170077A41E /* libfreetype.a in Frameworks */,
- 61B7A61512FA13B00051E14E /* libSDLiPhoneOS.a in Frameworks */,
+ 61B7A61512FA13B00051E14E /* libSDL.a in Frameworks */,
61B7A61612FA13B00051E14E /* libSDL_image.a in Frameworks */,
61B7A61712FA13B00051E14E /* libSDL_mixer.a in Frameworks */,
61B7A61812FA13B00051E14E /* libSDL_net.a in Frameworks */,
@@ -1089,10 +1089,10 @@
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
- 6165929C11CA9E2F00D6E256 /* SDL_uikitappdelegate.h */,
- 6165929D11CA9E2F00D6E256 /* SDL_uikitappdelegate.m */,
61AC067212B2E32D000B52A2 /* Appirater.h */,
61AC067312B2E32D000B52A2 /* Appirater.m */,
+ 6165929C11CA9E2F00D6E256 /* HedgewarsAppDelegate.h */,
+ 6165929D11CA9E2F00D6E256 /* HedgewarsAppDelegate.m */,
61DE91561258B76800B80214 /* Custom UIs */,
32CA4F630368D1EE00C91783 /* Hedgewars_Prefix.pch */,
6165922911CA9BD500D6E256 /* PascalImports.h */,
@@ -1403,7 +1403,7 @@
61B7A54712FA129F0051E14E /* Products */ = {
isa = PBXGroup;
children = (
- 61B7A54E12FA129F0051E14E /* libSDLiPhoneOS.a */,
+ 61B7A54E12FA129F0051E14E /* libSDL.a */,
61B7A55012FA129F0051E14E /* testsdl.app */,
);
name = Products;
@@ -2151,10 +2151,10 @@
remoteRef = 6172555812B3DCEE0098D069 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
- 61B7A54E12FA129F0051E14E /* libSDLiPhoneOS.a */ = {
+ 61B7A54E12FA129F0051E14E /* libSDL.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
- path = libSDLiPhoneOS.a;
+ path = libSDL.a;
remoteRef = 61B7A54D12FA129F0051E14E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
@@ -2405,7 +2405,7 @@
6165922F11CA9BD500D6E256 /* CommodityFunctions.m in Sources */,
6165923111CA9BD500D6E256 /* SquareButtonView.m in Sources */,
6165923211CA9BD500D6E256 /* UIImageExtra.m in Sources */,
- 6165929E11CA9E2F00D6E256 /* SDL_uikitappdelegate.m in Sources */,
+ 6165929E11CA9E2F00D6E256 /* HedgewarsAppDelegate.m in Sources */,
6163EE7E11CC2600001C0453 /* SingleWeaponViewController.m in Sources */,
61E1F4F811D004240016A5AA /* adler32.pas in Sources */,
61F904D711DF7DA30068B24D /* WeaponCellView.m in Sources */,
--- a/project_files/HedgewarsMobile/Hedgewars_Prefix.pch Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/Hedgewars_Prefix.pch Sun Mar 13 20:34:27 2011 +0300
@@ -23,7 +23,7 @@
#import "PascalImports.h"
#import "UIImageExtra.h"
#import "CommodityFunctions.h"
-#import "SDL_uikitappdelegate.h"
+#import "HedgewarsAppDelegate.h"
#import "SDL.h"
#import "SDL_video.h"
#import "SDL_net.h"
--- a/project_files/HedgewarsMobile/SDL.patch Sun Mar 13 20:34:01 2011 +0300
+++ b/project_files/HedgewarsMobile/SDL.patch Sun Mar 13 20:34:27 2011 +0300
@@ -1,45 +1,25 @@
-diff -r 1fbe1c202501 Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
---- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Mon Feb 07 10:40:21 2011 -0800
-+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Fri Feb 18 00:09:03 2011 +0100
-@@ -1603,11 +1603,15 @@
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
-+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+diff -r 48067bfc300c Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
+--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Mon Feb 14 11:50:18 2011 -0600
++++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Sun Mar 13 18:22:16 2011 +0100
+@@ -1695,6 +1695,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_DEBUGGING_SYMBOLS = full;
+ GCC_THUMB_SUPPORT = NO;
-+ GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = NO;
-+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../include\"";
IPHONEOS_DEPLOYMENT_TARGET = 3.1;
- ONLY_ACTIVE_ARCH = NO;
- PREBINDING = NO;
-@@ -1620,12 +1624,18 @@
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
-- ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
-+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+@@ -1712,6 +1713,7 @@
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
-+ GCC_OPTIMIZATION_LEVEL = s;
+ GCC_THUMB_SUPPORT = NO;
-+ GCC_UNROLL_LOOPS = NO;
-+ GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = NO;
-+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../include\"";
IPHONEOS_DEPLOYMENT_TARGET = 3.1;
-+ OTHER_CFLAGS = "";
- PREBINDING = NO;
- SDKROOT = iphoneos;
- TARGETED_DEVICE_FAMILY = "1,2";
-diff -r 1fbe1c202501 include/SDL_config_iphoneos.h
---- a/include/SDL_config_iphoneos.h Mon Feb 07 10:40:21 2011 -0800
-+++ b/include/SDL_config_iphoneos.h Fri Feb 18 00:09:03 2011 +0100
+diff -r 48067bfc300c include/SDL_config_iphoneos.h
+--- a/include/SDL_config_iphoneos.h Mon Feb 14 11:50:18 2011 -0600
++++ b/include/SDL_config_iphoneos.h Sun Mar 13 18:22:16 2011 +0100
@@ -119,7 +119,7 @@
/* enable iPhone version of Core Audio driver */
#define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1
@@ -79,24 +59,28 @@
+#define SDL_VIEW_TAG 456987
+
#endif /* _SDL_config_iphoneos_h */
-diff -r 1fbe1c202501 src/video/SDL_video.c
---- a/src/video/SDL_video.c Mon Feb 07 10:40:21 2011 -0800
-+++ b/src/video/SDL_video.c Fri Feb 18 00:09:03 2011 +0100
-@@ -1657,9 +1657,11 @@
- SDL_MinimizeWindow(window);
- }
+diff -r 48067bfc300c src/video/uikit/SDL_uikitappdelegate.m
+--- a/src/video/uikit/SDL_uikitappdelegate.m Mon Feb 14 11:50:18 2011 -0600
++++ b/src/video/uikit/SDL_uikitappdelegate.m Sun Mar 13 18:22:16 2011 +0100
+@@ -35,6 +35,7 @@
+ static int forward_argc;
+ static char **forward_argv;
+
++#if 0
+ int main(int argc, char **argv) {
-+ /*
- if (display->gamma && _this->SetDisplayGammaRamp) {
- _this->SetDisplayGammaRamp(_this, display, display->saved_gamma);
- }
-+ */
- if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
- && _this->SetWindowGrab) {
- _this->SetWindowGrab(_this, window);
-diff -r 1fbe1c202501 src/video/uikit/SDL_uikitopengles.m
---- a/src/video/uikit/SDL_uikitopengles.m Mon Feb 07 10:40:21 2011 -0800
-+++ b/src/video/uikit/SDL_uikitopengles.m Fri Feb 18 00:09:03 2011 +0100
+ int i;
+@@ -55,6 +56,7 @@
+ [pool release];
+
+ }
++#endif
+
+ @implementation SDLUIKitDelegate
+
+diff -r 48067bfc300c src/video/uikit/SDL_uikitopengles.m
+--- a/src/video/uikit/SDL_uikitopengles.m Mon Feb 14 11:50:18 2011 -0600
++++ b/src/video/uikit/SDL_uikitopengles.m Sun Mar 13 18:22:16 2011 +0100
@@ -117,6 +117,7 @@
majorVersion: _this->gl_config.major_version];