--- a/hedgewars/PascalExports.pas Mon Sep 19 23:18:48 2011 +0200
+++ b/hedgewars/PascalExports.pas Mon Sep 19 23:35:07 2011 +0200
@@ -36,6 +36,7 @@
implementation
{$IFDEF HWLIBRARY}
var cZoomVal: GLfloat;
+ previousGameState: TGameState;
// retrieve protocol information
procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl; export;
@@ -184,6 +185,17 @@
exit( isPaused );
end;
+procedure HW_suspend; cdecl; export;
+begin
+ previousGameState:= GameState;
+ GameState:= gsSuspend;
+end;
+
+procedure HW_resume; cdecl; export;
+begin
+ GameState:= previousGameState;
+end;
+
// equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup
procedure HW_terminate(closeFrontend: boolean); cdecl; export;
begin
--- a/hedgewars/hwengine.pas Mon Sep 19 23:18:48 2011 +0200
+++ b/hedgewars/hwengine.pas Mon Sep 19 23:35:07 2011 +0200
@@ -100,6 +100,7 @@
gsExit: begin
isTerminated:= true;
end;
+ gsSuspend: exit;
end;
{$IFDEF SDL13}
@@ -158,11 +159,11 @@
while isTerminated = false do
begin
SDL_PumpEvents();
- {$IFDEF SDL13}
+{$IFDEF SDL13}
while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) > 0 do
- {$ELSE}
+{$ELSE}
while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_ALLEVENTS) > 0 do
- {$ENDIF}
+{$ENDIF}
begin
case event.type_ of
SDL_KEYDOWN: if GameState = gsChat then
--- a/hedgewars/uTypes.pas Mon Sep 19 23:18:48 2011 +0200
+++ b/hedgewars/uTypes.pas Mon Sep 19 23:35:07 2011 +0200
@@ -36,7 +36,7 @@
end;
// Possible states of the game
- TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit);
+ TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit, gsSuspend);
// Game types that help determining what the engine is actually supposed to do
TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax);
--- a/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m Mon Sep 19 23:18:48 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m Mon Sep 19 23:35:07 2011 +0200
@@ -133,12 +133,19 @@
// don't clean mainMenuViewController here!!!
}
+// true multitasking with sdl works only on 4.2 and above; we close the game to avoid a black screen at return
-(void) applicationWillResignActive:(UIApplication *)application {
- // true multitasking with sdl works only on 4.2 and above; we close the game to avoid a black screen at return
- if (self.isInGame && ([[[UIDevice currentDevice] systemVersion] floatValue] < 4.2f))
- HW_terminate(NO);
+ if (self.isInGame)
+ if ([[[UIDevice currentDevice] systemVersion] floatValue] < 4.2f)
+ HW_terminate(NO);
+ else
+ HW_suspend();
[super applicationWillResignActive:application];
}
+-(void) applicationDidBecomeActive:(UIApplication *)application {
+ HW_resume();
+ [super applicationDidBecomeActive:application];
+}
@end