author | koda |
Thu, 20 Jan 2011 01:49:20 +0100 | |
changeset 4861 | 91f889289a47 |
parent 4507 | 0f9b86942c19 |
child 4948 | c3dc41ae68fa |
permissions | -rw-r--r-- |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
1 |
(* |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
4 |
* |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
8 |
* |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
13 |
* |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
17 |
*) |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
18 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
19 |
{$INCLUDE "options.inc"} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
20 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
21 |
unit uMobile; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
22 |
interface |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
23 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
24 |
{$IFDEF IPHONEOS} |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
25 |
(* iOS calls written in ObjcExports.m *) |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
26 |
procedure clearView; cdecl; external; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
27 |
procedure startSpinning; cdecl; external; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
28 |
procedure stopSpinning; cdecl; external; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
29 |
procedure replayBegan; cdecl; external; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
30 |
procedure replayFinished; cdecl; external; |
4861
91f889289a47
(ios) perform a small change about how to close the game window, should hopefully save memory and avoid crashes (who am i kidding? that's the usual PR talk...)
koda
parents:
4507
diff
changeset
|
31 |
procedure setGameRunning(arg: boolean); cdecl; external; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
32 |
procedure updateVisualsNewTurn; cdecl; external; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
33 |
function isApplePhone: Boolean; cdecl; external; |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
34 |
function isAppleDeviceMuted: Boolean; cdecl; external; |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
35 |
procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
36 |
{$ENDIF} |
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
37 |
function isPhone: Boolean; inline; |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
38 |
function isDeviceMute: Boolean; inline; |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
39 |
procedure performRumble; inline; |
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
40 |
procedure perfExt_AddProgress; inline; |
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
41 |
procedure perfExt_FinishProgress; inline; |
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
42 |
procedure perfExt_AmmoUpdate; // don't inline |
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
43 |
procedure perfExt_NewTurnBeginning; inline; |
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
44 |
procedure perfExt_SaveBeganSynching; inline; |
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
45 |
procedure perfExt_SaveFinishedSynching; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
46 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
47 |
implementation |
4437
05192cdbce9b
un-break build (wrong merge in uConsole) and update project file with the new sources
koda
parents:
4436
diff
changeset
|
48 |
uses uVariables; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
49 |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
50 |
function isPhone: Boolean; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
51 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
52 |
{$IFDEF IPHONEOS} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
53 |
exit(isApplePhone()); |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
54 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
55 |
exit(false); |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
56 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
57 |
|
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
58 |
function isDeviceMute: Boolean; inline; |
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
59 |
begin |
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
60 |
{$IFDEF IPHONEOS} |
4507
0f9b86942c19
audio_session is giving problems with multitasking so disabling it for now
koda
parents:
4461
diff
changeset
|
61 |
// exit(isAppleDeviceMuted()); |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
62 |
{$ENDIF} |
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
63 |
exit(false); |
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
64 |
end; |
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4437
diff
changeset
|
65 |
|
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
66 |
procedure performRumble; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
67 |
begin |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
68 |
{$IFDEF IPHONEOS} |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
69 |
// kSystemSoundID_Vibrate = $00000FFF |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
70 |
AudioServicesPlaySystemSound($00000FFF); |
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
71 |
{$ENDIF} |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
72 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
73 |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
74 |
procedure perfExt_AddProgress; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
75 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
76 |
{$IFDEF IPHONEOS} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
77 |
startSpinning(); |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
78 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
79 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
80 |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
81 |
procedure perfExt_FinishProgress; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
82 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
83 |
{$IFDEF IPHONEOS} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
84 |
stopSpinning(); |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
85 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
86 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
87 |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
88 |
procedure perfExt_AmmoUpdate; // don't inline |
3935 | 89 |
begin |
90 |
{$IFDEF IPHONEOS} |
|
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4034
diff
changeset
|
91 |
if (CurrentTeam = nil) or |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4034
diff
changeset
|
92 |
(CurrentTeam^.ExtDriven) or |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4034
diff
changeset
|
93 |
(CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then |
3940
cc29628976cc
some optimizations to drawing and fetching data of new ammomenu
koda
parents:
3935
diff
changeset
|
94 |
exit(); // the other way around throws a compiler error |
3935 | 95 |
updateVisualsNewTurn(); |
96 |
{$ENDIF} |
|
97 |
end; |
|
98 |
||
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
99 |
procedure perfExt_NewTurnBeginning; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
100 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
101 |
{$IFDEF IPHONEOS} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
102 |
clearView(); |
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
103 |
perfExt_AmmoUpdate(); |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
104 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
105 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
106 |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
107 |
procedure perfExt_SaveBeganSynching; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
108 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
109 |
{$IFDEF IPHONEOS} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
110 |
replayBegan(); |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
111 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
112 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
113 |
|
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
114 |
procedure perfExt_SaveFinishedSynching; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
115 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
116 |
{$IFDEF IPHONEOS} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
117 |
replayFinished(); |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
118 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
119 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
120 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
121 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
122 |
end. |