cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
author koda
Mon, 31 May 2010 19:33:42 +0000
changeset 3487 b1d00f1950c8
parent 3479 972ae3ec178a
child 3490 016b3172b645
permissions -rw-r--r--
add some memory aware code revert sdl calls to past implementation (the one that did not crash) add some debug methods found online
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     1
/*
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     2
 SDL - Simple DirectMedia Layer
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     3
 Copyright (C) 1997-2009 Sam Lantinga
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     4
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     5
 This library is free software; you can redistribute it and/or
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     6
 modify it under the terms of the GNU Lesser General Public
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     7
 License as published by the Free Software Foundation; either
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     8
 version 2.1 of the License, or (at your option) any later version.
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
     9
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    10
 This library is distributed in the hope that it will be useful,
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    13
 Lesser General Public License for more details.
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    14
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    15
 You should have received a copy of the GNU Lesser General Public
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    16
 License along with this library; if not, write to the Free Software
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    17
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    18
 
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    19
 Sam Lantinga, mods for Hedgewars by Vittorio Giovara
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    20
 slouken@libsdl.org, vittorio.giovara@gmail.com
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    21
*/
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    22
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    23
#import "SDL_uikitappdelegate.h"
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    24
#import "SDL_uikitopenglview.h"
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    25
#import "SDL_uikitwindow.h"
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    26
#import "SDL_events_c.h"
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    27
#import "../SDL_sysvideo.h"
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    28
#import "jumphack.h"
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    29
#import "SDL_video.h"
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents: 2692
diff changeset
    30
#import "GameSetup.h"
2698
90585aba87ad objc/pascal finally working
koda
parents: 2697
diff changeset
    31
#import "PascalImports.h"
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2743
diff changeset
    32
#import "MainMenuViewController.h"
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents: 3063
diff changeset
    33
#import "OverlayViewController.h"
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
    34
#import "CommodityFunctions.h"
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    35
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    36
#ifdef main
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    37
#undef main
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    38
#endif
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    39
3316
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    40
#define VALGRIND "/opt/valgrind/bin/valgrind"
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    41
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2701
diff changeset
    42
int main (int argc, char *argv[]) {
3316
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    43
#ifdef VALGRIND_REXEC
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    44
    // Using the valgrind build config, rexec ourself in valgrind
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    45
    // from http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    46
    if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0)) {
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    47
        execl(VALGRIND, VALGRIND, "--leak-check=full", "--show-reachable=yes", argv[0], "-valgrind", NULL);
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    48
    }
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    49
#endif
52f0482b043f fix a couple of leaks in hte ifrontend
koda
parents: 3305
diff changeset
    50
3027
32890edaa483 lotsa optimizations and redraws for the iFrontend
koda
parents: 3026
diff changeset
    51
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
2723
eaa6ac1e95ea LANDSCAPE ON IPHONE
koda
parents: 2720
diff changeset
    52
	int retVal = UIApplicationMain(argc, argv, nil, @"SDLUIKitDelegate");
eaa6ac1e95ea LANDSCAPE ON IPHONE
koda
parents: 2720
diff changeset
    53
	[pool release];
eaa6ac1e95ea LANDSCAPE ON IPHONE
koda
parents: 2720
diff changeset
    54
	return retVal;
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    55
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    56
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    57
@implementation SDLUIKitDelegate
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
    58
@synthesize uiwindow, window;
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    59
2803
1f446fc5c8ec allow to compile engine as library with HWLIBRARY symbol
koda
parents: 2772
diff changeset
    60
// convenience method
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    61
+(SDLUIKitDelegate *)sharedAppDelegate {
2803
1f446fc5c8ec allow to compile engine as library with HWLIBRARY symbol
koda
parents: 2772
diff changeset
    62
	// the delegate is set in UIApplicationMain(), which is guaranteed to be called before this method
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    63
	return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    64
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
    65
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2702
diff changeset
    66
-(id) init {
3122
e005359efc59 hide the background gl context that remains active (might be worth freeing ithide the background gl context that remains active (might be worth freeing it))
koda
parents: 3116
diff changeset
    67
	if (self = [super init]){
3385
361bd29293f4 add automatic rotation in ipad (landscape only)
koda
parents: 3374
diff changeset
    68
        mainViewController = nil;
3122
e005359efc59 hide the background gl context that remains active (might be worth freeing ithide the background gl context that remains active (might be worth freeing it))
koda
parents: 3116
diff changeset
    69
        isInGame = NO;
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
    70
        self.uiwindow = nil; 	 
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
    71
        self.window = NULL;
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    72
    }
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    73
    return self;
2714
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2702
diff changeset
    74
}
c85ffe57d971 update iphone frontend to the new (silly) sdl api, code cleanups for other sections
koda
parents: 2702
diff changeset
    75
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2693
diff changeset
    76
-(void) dealloc {
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
    77
    SDL_DestroyWindow(self.window);
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
    78
     [uiwindow release];
3385
361bd29293f4 add automatic rotation in ipad (landscape only)
koda
parents: 3374
diff changeset
    79
    [mainViewController release];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2693
diff changeset
    80
	[super dealloc];
41aa7b56c17b settings are applied to game launch
koda
parents: 2693
diff changeset
    81
}
41aa7b56c17b settings are applied to game launch
koda
parents: 2693
diff changeset
    82
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3027
diff changeset
    83
// main routine for calling the actual game engine
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents: 2692
diff changeset
    84
-(IBAction) startSDLgame {
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    85
    [UIView beginAnimations:@"removing main controller" context:NULL];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    86
	[UIView setAnimationDuration:1];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    87
	mainViewController.view.alpha = 0;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    88
	[UIView commitAnimations];
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3027
diff changeset
    89
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3027
diff changeset
    90
    // pull out useful configuration info from various files
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2701
diff changeset
    91
	GameSetup *setup = [[GameSetup alloc] init];
2693
3207e0eacd43 GameSetup is now a class, use of NSThread instead of pthreads, game doesn't quit after first execution (but crashes aftewards - the irony)
koda
parents: 2692
diff changeset
    92
	[setup startThread:@"engineProtocol"];
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2701
diff changeset
    93
	const char **gameArgs = [setup getSettings];
2772
1965eba10be6 some code cleanup for the ifrontend
koda
parents: 2743
diff changeset
    94
	[setup release];
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    95
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    96
    // since the sdlwindow is not yet created, we add the overlayController with a delay
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
    97
    [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:1];
3317
198ec44b6d92 minor tweaks, icon for ipad, merged overlayviewcontroller, pop viewcontroller when selected a hat
koda
parents: 3316
diff changeset
    98
    
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
    99
    // this is the pascal fuction that starts the game (wrapped around isInGame)
3063
0092dc37fbd6 reworked interaction of engine/frontend when closing
koda
parents: 3029
diff changeset
   100
    isInGame = YES;
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   101
	Game(gameArgs);
3063
0092dc37fbd6 reworked interaction of engine/frontend when closing
koda
parents: 3029
diff changeset
   102
    isInGame = NO;
3006
da6023c2745b restore compilation on simulator and device
koda
parents: 2803
diff changeset
   103
    
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3027
diff changeset
   104
    free(gameArgs);
3006
da6023c2745b restore compilation on simulator and device
koda
parents: 2803
diff changeset
   105
    
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   106
    [UIView beginAnimations:@"inserting main controller" context:NULL];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   107
	[UIView setAnimationDuration:1];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   108
	mainViewController.view.alpha = 1;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   109
	[UIView commitAnimations];
2702
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2701
diff changeset
   110
}
48fc46a922fd rewrite gamesetup to use less memory, rename effects to sound plus some nice actions, settings work in game again
koda
parents: 2701
diff changeset
   111
3479
972ae3ec178a initial support for game modifiers (schemes)
koda
parents: 3463
diff changeset
   112
-(void) displayOverlayLater {
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   113
    // overlay with controls, become visible after 4 seconds, with a transparency effect
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   114
    OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   115
    
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   116
    [[[UIApplication sharedApplication] keyWindow] addSubview:overlayController.view];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   117
    [overlayController release];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   118
}
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   119
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   120
// override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib)
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   121
-(void) applicationDidFinishLaunching:(UIApplication *)application {
3270
9bd8fb1707b9 initial support for hat selection on the ifrontend
koda
parents: 3250
diff changeset
   122
    [application setStatusBarHidden:YES];
3116
97dc65a47b15 branch ipad/iphone files to keep compatibility between versions
koda
parents: 3063
diff changeset
   123
    [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];  
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents: 3335
diff changeset
   124
    
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   125
    uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   126
	uiwindow.backgroundColor = [UIColor blackColor];
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   127
    // needed to keep the app running after a game (gets released in sdl_uikitwindow)
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   128
	[uiwindow retain];
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   129
    
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents: 3270
diff changeset
   130
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
3385
361bd29293f4 add automatic rotation in ipad (landscape only)
koda
parents: 3374
diff changeset
   131
        mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil];
3305
91074496d5c9 merged code from ipad and iphone frontends
koda
parents: 3270
diff changeset
   132
    else
3385
361bd29293f4 add automatic rotation in ipad (landscape only)
koda
parents: 3374
diff changeset
   133
        mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPhone" bundle:nil];
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   134
3385
361bd29293f4 add automatic rotation in ipad (landscape only)
koda
parents: 3374
diff changeset
   135
	[uiwindow addSubview:mainViewController.view];
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   136
	[uiwindow makeKeyAndVisible];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   137
2803
1f446fc5c8ec allow to compile engine as library with HWLIBRARY symbol
koda
parents: 2772
diff changeset
   138
	// Set working directory to resource path
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents: 3361
diff changeset
   139
	[[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   140
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   141
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   142
-(void) applicationWillTerminate:(UIApplication *)application {
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   143
	SDL_SendQuit();
3063
0092dc37fbd6 reworked interaction of engine/frontend when closing
koda
parents: 3029
diff changeset
   144
    if (isInGame) {
0092dc37fbd6 reworked interaction of engine/frontend when closing
koda
parents: 3029
diff changeset
   145
        HW_terminate(YES);
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3199
diff changeset
   146
        // hack to prevent automatic termination. See SDL_uikitevents.m for details
3063
0092dc37fbd6 reworked interaction of engine/frontend when closing
koda
parents: 3029
diff changeset
   147
        longjmp(*(jump_env()), 1);
0092dc37fbd6 reworked interaction of engine/frontend when closing
koda
parents: 3029
diff changeset
   148
    }
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   149
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   150
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3027
diff changeset
   151
-(void) applicationWillResignActive:(UIApplication *)application {
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3318
diff changeset
   152
	//NSLog(@"%@", NSStringFromSelector(_cmd));
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   153
    if (isInGame) {
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   154
        HW_pause();
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   155
        
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   156
        /*
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   157
        // Send every window on every screen a MINIMIZED event.
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   158
        SDL_VideoDevice *_this = SDL_GetVideoDevice();
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   159
        if (!_this)
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   160
            return;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   161
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   162
        int i;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   163
        for (i = 0; i < _this->num_displays; i++) {
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   164
            const SDL_VideoDisplay *display = &_this->displays[i];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   165
            SDL_Window *window;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   166
            for (window = display->windows; window != nil; window = window->next)
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   167
                SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   168
        }
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   169
        */
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   170
    }
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   171
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   172
3029
67483e87590c a couple of smaller cleanups that didn't get in previous commit
koda
parents: 3027
diff changeset
   173
-(void) applicationDidBecomeActive:(UIApplication *)application {
3335
2520ee7a5484 new manager for handling (future) rotations
koda
parents: 3318
diff changeset
   174
	//NSLog(@"%@", NSStringFromSelector(_cmd));
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   175
    if (isInGame) {
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   176
        HW_pause();
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   177
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   178
        /*
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   179
        // Send every window on every screen a RESTORED event.
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   180
        SDL_VideoDevice *_this = SDL_GetVideoDevice();
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   181
        if (!_this)
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   182
            return;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   183
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   184
        int i;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   185
        for (i = 0; i < _this->num_displays; i++) {
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   186
            const SDL_VideoDisplay *display = &_this->displays[i];
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   187
            SDL_Window *window;
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   188
            for (window = display->windows; window != nil; window = window->next)
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   189
                SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   190
        }
3487
b1d00f1950c8 add some memory aware code
koda
parents: 3479
diff changeset
   191
        */
3463
23c50be687a9 update sdl functions to latest revision
koda
parents: 3385
diff changeset
   192
    }
2688
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   193
}
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   194
174c94b8ea72 move all sdl source files in a proper directory
koda
parents:
diff changeset
   195
@end