author | Medo <smaxein@googlemail.com> |
Thu, 19 Jul 2012 22:53:39 +0200 | |
changeset 7344 | 25b8906f901a |
parent 7237 | 1bbe31e0d707 |
child 7557 | 5a28d3cfbf62 |
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 |
6700 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
3928
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 |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
21 |
(* |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
22 |
* This unit contains a lot of useful functions when hw is running on mobile |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
23 |
* Unlike HwLibrary when you declare functions that you will call from your code, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
24 |
* here you need to provide functions that Pascall code will call. |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
25 |
*) |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
26 |
|
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
27 |
unit uMobile; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
28 |
interface |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
29 |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
30 |
function isPhone: Boolean; inline; |
7237 | 31 |
function getScreenDPI: Single; inline; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
32 |
procedure performRumble; inline; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
33 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
34 |
procedure GameLoading; inline; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
35 |
procedure GameLoaded; inline; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
36 |
procedure SaveLoadingEnded; inline; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
37 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
38 |
implementation |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
39 |
uses uVariables, uConsole; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
40 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
41 |
// add here any external call that you need |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
42 |
{$IFDEF IPHONEOS} |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
43 |
(* iOS calls written in ObjcExports.m *) |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
5994
diff
changeset
|
44 |
procedure startLoadingIndicator; cdecl; external; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
5994
diff
changeset
|
45 |
procedure stopLoadingIndicator; cdecl; external; |
5180 | 46 |
procedure saveFinishedSynching; cdecl; external; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
47 |
function isApplePhone: Boolean; cdecl; external; |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
48 |
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
|
49 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
50 |
|
7237 | 51 |
{$IFDEF ANDROID} |
52 |
function Android_JNI_getDensity(): Single; cdecl; external; |
|
53 |
{$ENDIF} |
|
54 |
||
5994 | 55 |
// this function is just to determine whether we are running on a limited screen device |
3948
24daa33a3114
some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents:
3940
diff
changeset
|
56 |
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
|
57 |
begin |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6822
diff
changeset
|
58 |
isPhone:= false; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
59 |
{$IFDEF IPHONEOS} |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6822
diff
changeset
|
60 |
isPhone:= isApplePhone(); |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
61 |
{$ENDIF} |
6601
5965e2927b3d
fixed the ammo menu on android, on tablets all weapons are 'choosable' and on phones I've moved the ammomenu up a bit
Xeli
parents:
6580
diff
changeset
|
62 |
{$IFDEF ANDROID} |
5965e2927b3d
fixed the ammo menu on android, on tablets all weapons are 'choosable' and on phones I've moved the ammomenu up a bit
Xeli
parents:
6580
diff
changeset
|
63 |
//nasty nasty hack. TODO: implement callback to java to have a unified way of determining if it is a tablet |
5965e2927b3d
fixed the ammo menu on android, on tablets all weapons are 'choosable' and on phones I've moved the ammomenu up a bit
Xeli
parents:
6580
diff
changeset
|
64 |
if (cScreenWidth < 1000) and (cScreenHeight < 500) then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6822
diff
changeset
|
65 |
isPhone:= true; |
6822
206db098f8c5
ios headers cleanup, with tweaks to +randomPort and grenade timer handling in overlay
koda
parents:
6700
diff
changeset
|
66 |
{$ENDIF} |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
67 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
68 |
|
7237 | 69 |
function getScreenDPI: Single; inline; |
70 |
begin |
|
71 |
{$IFDEF ANDROID} |
|
72 |
getScreenDPI:= Android_JNI_getDensity(); |
|
73 |
{$ELSE} |
|
74 |
getScreenDPI:= 1; |
|
75 |
{$ENDIF} |
|
76 |
end; |
|
77 |
||
5994 | 78 |
// this function should make the device vibrate in some way |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
79 |
procedure PerformRumble; inline; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
80 |
{$IFDEF IPHONEOS}const kSystemSoundID_Vibrate = $00000FFF;{$ENDIF} |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
81 |
begin |
5994 | 82 |
// do not vibrate while synchronising a demo/save |
83 |
if not fastUntilLag then |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
84 |
begin |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
85 |
{$IFDEF IPHONEOS} |
5994 | 86 |
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); |
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3952
diff
changeset
|
87 |
{$ENDIF} |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6990
diff
changeset
|
88 |
end; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
89 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
90 |
|
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5168
diff
changeset
|
91 |
procedure GameLoading; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
92 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
93 |
{$IFDEF IPHONEOS} |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
5994
diff
changeset
|
94 |
startLoadingIndicator(); |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
95 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
96 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
97 |
|
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5168
diff
changeset
|
98 |
procedure GameLoaded; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
99 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
100 |
{$IFDEF IPHONEOS} |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
5994
diff
changeset
|
101 |
stopLoadingIndicator(); |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
102 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
103 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
104 |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
5994
diff
changeset
|
105 |
procedure SaveLoadingEnded; inline; |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
106 |
begin |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
107 |
{$IFDEF IPHONEOS} |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5168
diff
changeset
|
108 |
saveFinishedSynching(); |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
109 |
{$ENDIF} |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
110 |
end; |
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
111 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
112 |
|
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
diff
changeset
|
113 |
end. |