hedgewars/hwLibrary.pas
changeset 7048 0a4c88935902
parent 6700 e04da46ee43c
child 7083 5339aba29571
equal deleted inserted replaced
7047:606acf1f80be 7048:0a4c88935902
    14  * You should have received a copy of the GNU General Public License
    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
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 Library hwLibrary;
       
    20 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    21 
    20 
    22 // Add all your Pascal units to the 'uses' clause below to add them to the program.
    21 (*
    23 // Mark all Pascal procedures/functions that you wish to call from C/C++/Objective-C code using
    22  * When engine is compiled as library this unit will export functions
    24 // 'cdecl; export;' (see the fpclogo.pas unit for an example), and then add C-declarations for
    23  * as C declarations for convenient library usage in your application
    25 // these procedures/functions to the PascalImports.h file (also in the 'Pascal Sources' group)
    24  * and language of choice.
    26 // to make these functions available in the C/C++/Objective-C source files
    25  *
    27 // (add '#include PascalImports.h' near the top of these files if it is not there yet)
    26  * See also: C declarations on Wikipedia
    28 uses PascalExports, hwengine{$IFDEF ANDROID}, jni{$ENDIF};
    27  *           http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl
    29 exports Game, HW_versionInfo;
    28  *)
       
    29 
       
    30 Library hwLibrary;
       
    31 
       
    32 uses hwengine, uTypes, uConsts, uVariables, uSound, uCommands, uUtils,
       
    33      uLocale{$IFDEF ANDROID}, jni{$ENDIF};
       
    34 
       
    35 {$INCLUDE "config.inc"}
       
    36 
       
    37 // retrieve protocol information
       
    38 procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl; export;
       
    39 begin
       
    40     netProto^:= cNetProtoVersion;
       
    41     versionStr^:= cVersionString;
       
    42 end;
       
    43 
       
    44 // equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup
       
    45 procedure HW_terminate(closeFrontend: boolean); cdecl; export;
       
    46 begin
       
    47     closeFrontend:= closeFrontend; // avoid hint
       
    48     ParseCommand('forcequit', true);
       
    49 end;
       
    50 
       
    51 function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export;
       
    52 begin
       
    53     HW_getWeaponNameByIndex:= (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
       
    54 end;
       
    55 
       
    56 (*function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export;
       
    57 begin
       
    58     HW_getWeaponCaptionByIndex:= (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId]));
       
    59 end;
       
    60 
       
    61 function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export;
       
    62 begin
       
    63     HW_getWeaponDescriptionByIndex:= (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId]));
       
    64 end;*)
       
    65 
       
    66 function HW_getNumberOfWeapons: LongInt; cdecl; export;
       
    67 begin
       
    68     HW_getNumberOfWeapons:= ord(high(TAmmoType));
       
    69 end;
       
    70 
       
    71 function HW_getMaxNumberOfHogs: LongInt; cdecl; export;
       
    72 begin
       
    73     HW_getMaxNumberOfHogs:= cMaxHHIndex + 1;
       
    74 end;
       
    75 
       
    76 function HW_getMaxNumberOfTeams: LongInt; cdecl; export;
       
    77 begin
       
    78     HW_getMaxNumberOfTeams:= cMaxTeams;
       
    79 end;
       
    80 
       
    81 procedure HW_memoryWarningCallback; cdecl; export;
       
    82 begin
       
    83     ReleaseSound(false);
       
    84 end;
    30 
    85 
    31 {$IFDEF ANDROID}
    86 {$IFDEF ANDROID}
    32 function JNI_HW_versionInfoNet(env: PJNIEnv; obj: JObject):JInt;cdecl;
    87 function JNI_HW_versionInfoNet(env: PJNIEnv; obj: JObject):JInt;cdecl;
    33 begin
    88 begin
    34     env:= env; // avoid hint
    89     env:= env; // avoid hint
    50     GenLandPreview name Java_Prefix + 'GenLandPreview',
   105     GenLandPreview name Java_Prefix + 'GenLandPreview',
    51     HW_getNumberOfweapons name Java_Prefix + 'HWgetNumberOfWeapons',
   106     HW_getNumberOfweapons name Java_Prefix + 'HWgetNumberOfWeapons',
    52     HW_getMaxNumberOfHogs name Java_Prefix + 'HWgetMaxNumberOfHogs',
   107     HW_getMaxNumberOfHogs name Java_Prefix + 'HWgetMaxNumberOfHogs',
    53     HW_getMaxNumberOfTeams name Java_Prefix + 'HWgetMaxNumberOfTeams',
   108     HW_getMaxNumberOfTeams name Java_Prefix + 'HWgetMaxNumberOfTeams',
    54     HW_terminate name Java_Prefix + 'HWterminate';
   109     HW_terminate name Java_Prefix + 'HWterminate';
       
   110 {$ELSE}
       
   111 exports
       
   112     Game,
       
   113     GenLandPreview,
       
   114     LoadLocaleWrapper,
       
   115     HW_versionInfo,
       
   116     HW_terminate,
       
   117     HW_getNumberOfWeapons,
       
   118     HW_getMaxNumberOfHogs,
       
   119     HW_getMaxNumberOfTeams,
       
   120     HW_getWeaponNameByIndex,
       
   121     HW_memoryWarningCallback;
    55 {$ENDIF}
   122 {$ENDIF}
    56 
   123 
    57 begin
   124 begin
    58 
       
    59 end.
   125 end.
    60