author | unc0rr |
Sat, 25 Apr 2015 23:46:09 +0300 | |
branch | qmlfrontend |
changeset 10900 | 6a805e822074 |
parent 10896 | 5a74923120d5 |
child 10951 | 89a7f617e091 |
permissions | -rw-r--r-- |
4930 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9998 | 3 |
* Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com> |
4930 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10017
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4930 | 17 |
*) |
2698 | 18 |
|
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
19 |
{$INCLUDE "options.inc"} |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
20 |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
21 |
(* |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
22 |
* When engine is compiled as library this unit will export functions |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
23 |
* as C declarations for convenient library usage in your application |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
24 |
* and language of choice. |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
25 |
* |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
26 |
* See also: C declarations on Wikipedia |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
27 |
* http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
28 |
*) |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
29 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
30 |
Library hwLibrary; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
31 |
|
10414 | 32 |
uses hwengine |
33 |
, uTypes |
|
34 |
, uConsts |
|
35 |
, uVariables |
|
36 |
, uSound |
|
37 |
, uCommands |
|
38 |
, uUtils |
|
39 |
, uLocale |
|
40 |
{$IFDEF ANDROID}, jni{$ENDIF} |
|
10406 | 41 |
, uFLTypes |
10416 | 42 |
, uFLGameConfig |
43 |
, uFLIPC |
|
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
44 |
, uPhysFSLayer |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10430
diff
changeset
|
45 |
, uFLData |
10442 | 46 |
, uFLTeams |
10517 | 47 |
, uFLScripts |
10616 | 48 |
, uFLSchemes |
10888 | 49 |
, uFLAmmo |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
50 |
, uFLNet |
10416 | 51 |
; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
52 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
53 |
{$INCLUDE "config.inc"} |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
54 |
|
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
55 |
// retrieve protocol information |
10430 | 56 |
procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
57 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
58 |
netProto^:= cNetProtoVersion; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
59 |
versionStr^:= cVersionString; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
60 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
61 |
|
10430 | 62 |
function HW_versionString: PChar; cdecl; |
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
63 |
begin |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
64 |
exit(cVersionString + '-r' + cRevisionString + ' (' + cHashString + ')'); |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
65 |
end; |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
66 |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
67 |
// equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup |
10430 | 68 |
procedure HW_terminate(closeFrontend: boolean); cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
69 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
70 |
closeFrontend:= closeFrontend; // avoid hint |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
71 |
ParseCommand('forcequit', true); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
72 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
73 |
|
10430 | 74 |
function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
75 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
76 |
HW_getWeaponNameByIndex:= (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId])); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
77 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
78 |
|
10430 | 79 |
(*function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
80 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
81 |
HW_getWeaponCaptionByIndex:= (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId])); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
82 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
83 |
|
10430 | 84 |
function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
85 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
86 |
HW_getWeaponDescriptionByIndex:= (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId])); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
87 |
end;*) |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
88 |
|
10430 | 89 |
function HW_getNumberOfWeapons: LongInt; cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
90 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
91 |
HW_getNumberOfWeapons:= ord(high(TAmmoType)); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
92 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
93 |
|
10430 | 94 |
function HW_getMaxNumberOfHogs: LongInt; cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
95 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
96 |
HW_getMaxNumberOfHogs:= cMaxHHIndex + 1; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
97 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
98 |
|
10430 | 99 |
function HW_getMaxNumberOfTeams: LongInt; cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
100 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
101 |
HW_getMaxNumberOfTeams:= cMaxTeams; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
102 |
end; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
103 |
|
10430 | 104 |
procedure HW_memoryWarningCallback; cdecl; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
105 |
begin |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
106 |
ReleaseSound(false); |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
107 |
end; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
108 |
|
10430 | 109 |
procedure flibInit(localPrefix, userPrefix: PChar); cdecl; |
10416 | 110 |
begin |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
111 |
initIPC; |
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
112 |
uPhysFSLayer.initModule(localPrefix, userPrefix); |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
113 |
uFLNet.initModule; |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
114 |
end; |
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
115 |
|
10430 | 116 |
procedure flibFree; cdecl; |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
117 |
begin |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
118 |
uFLNet.freeModule; |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
119 |
uPhysFSLayer.freemodule; |
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
120 |
freeIPC; |
10416 | 121 |
end; |
122 |
||
6027 | 123 |
{$IFDEF ANDROID} |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
124 |
function JNI_HW_versionInfoNet(env: PJNIEnv; obj: JObject):JInt;cdecl; |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
125 |
begin |
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
126 |
env:= env; // avoid hint |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
127 |
obj:= obj; // avoid hint |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
128 |
JNI_HW_versionInfoNet:= cNetProtoVersion; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
129 |
end; |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
130 |
|
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
131 |
function JNI_HW_versionInfoVersion(env: PJNIEnv; obj: JObject):JString; cdecl; |
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
132 |
var envderef : JNIEnv; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
133 |
begin |
6033
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
134 |
obj:= obj; // avoid hint |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
135 |
envderef:= @env; |
6bcc36225162
fix compiling for android, strip out all delphi code, objfpc ftw
koda
parents:
6027
diff
changeset
|
136 |
JNI_HW_versionInfoVersion := envderef^.NewStringUTF(env, PChar(cVersionString)); |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
137 |
end; |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
138 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7500
diff
changeset
|
139 |
procedure JNI_HW_GenLandPreview(env: PJNIEnv; c: JClass; port: JInt); cdecl; |
7500
6253cae96f21
engine: Added JNI-compatible function to start map generation
Medo <smaxein@googlemail.com>
parents:
7083
diff
changeset
|
140 |
begin |
10017 | 141 |
GenLandPreview(port); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7500
diff
changeset
|
142 |
end; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7500
diff
changeset
|
143 |
|
6025
cac1d5601d7c
reviewed the build system and parts of the previous merge, performed some code cleanup
koda
parents:
5452
diff
changeset
|
144 |
exports |
10017 | 145 |
JNI_HW_versionInfoNet name Java_Prefix+'HWversionInfoNetProto', |
146 |
JNI_HW_versionInfoVersion name Java_Prefix+'HWversionInfoVersion', |
|
7500
6253cae96f21
engine: Added JNI-compatible function to start map generation
Medo <smaxein@googlemail.com>
parents:
7083
diff
changeset
|
147 |
JNI_HW_GenLandPreview name Java_Prefix + 'HWGenLandPreview', |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
148 |
HW_getNumberOfweapons name Java_Prefix + 'HWgetNumberOfWeapons', |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
149 |
HW_getMaxNumberOfHogs name Java_Prefix + 'HWgetMaxNumberOfHogs', |
6035
bdd0528ee8a6
Close a game without leaking memory. It should be noted that sending an SDL Quit event leaks memory
Xeli
parents:
6033
diff
changeset
|
150 |
HW_getMaxNumberOfTeams name Java_Prefix + 'HWgetMaxNumberOfTeams', |
7083 | 151 |
Game; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
152 |
{$ELSE} |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
153 |
exports |
10426 | 154 |
runQuickGame, |
10448 | 155 |
runLocalGame, |
10426 | 156 |
getPreview, |
10428
7c25297720f1
More refactoring: move PoC preview getting code into flib
unc0rr
parents:
10426
diff
changeset
|
157 |
registerGUIMessagesCallback, |
10416 | 158 |
flibInit, |
10424
4be6cd55f1cf
- Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents:
10416
diff
changeset
|
159 |
flibFree, |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
160 |
//game config |
10450 | 161 |
resetGameConfig, |
10430 | 162 |
setSeed, |
163 |
getSeed, |
|
10456 | 164 |
setTheme, |
10612 | 165 |
setScript, |
10819
57e21f7621b0
Send selected scheme config on engine initialization (WIP)
unc0rr
parents:
10616
diff
changeset
|
166 |
setScheme, |
10888 | 167 |
setAmmo, |
10434
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10430
diff
changeset
|
168 |
getThemesList, |
1614b13ad35e
Themes model, also add some files I forgot to add previously
unc0rr
parents:
10430
diff
changeset
|
169 |
freeThemesList, |
10436 | 170 |
getThemeIcon, |
10517 | 171 |
getScriptsList, |
10616 | 172 |
getSchemesList, |
10888 | 173 |
getAmmosList, |
10442 | 174 |
getTeamsList, |
10444
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
175 |
tryAddTeam, |
47a6231f1fc1
Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents:
10442
diff
changeset
|
176 |
tryRemoveTeam, |
10452
03519fd9f98d
Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents:
10450
diff
changeset
|
177 |
changeTeamColor, |
10896
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
178 |
// network |
5a74923120d5
Start network support: only setting up a connection for now
unc0rr
parents:
10888
diff
changeset
|
179 |
connectOfficialServer, |
10612 | 180 |
|
10448 | 181 |
// dunno what these are |
182 |
RunEngine, |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
183 |
LoadLocaleWrapper, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
184 |
HW_versionInfo, |
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9080
diff
changeset
|
185 |
HW_versionString, |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
186 |
HW_terminate, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
187 |
HW_getNumberOfWeapons, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
188 |
HW_getMaxNumberOfHogs, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
189 |
HW_getMaxNumberOfTeams, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
190 |
HW_getWeaponNameByIndex, |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6700
diff
changeset
|
191 |
HW_memoryWarningCallback; |
5452
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
192 |
{$ENDIF} |
3edc3e3b8cdc
Created callbacks to give the frontend information of maxteams/hogs
Xeli
parents:
5166
diff
changeset
|
193 |
|
4187 | 194 |
begin |
2698 | 195 |
end. |