hedgewars/hwLibrary.pas
branchhedgeroid
changeset 7855 ddcdedd3330b
parent 7083 5339aba29571
child 7500 6253cae96f21
equal deleted inserted replaced
6350:41b0a9955c47 7855:ddcdedd3330b
     1 (*
     1 (*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     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
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
    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
    49     JNI_HW_versionInfoVersion name Java_Prefix+'HWversionInfoVersion', 
   104     JNI_HW_versionInfoVersion name Java_Prefix+'HWversionInfoVersion', 
    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     Game;
       
   111 {$ELSE}
       
   112 exports
       
   113     Game,
       
   114     GenLandPreview,
       
   115     LoadLocaleWrapper,
       
   116     HW_versionInfo,
       
   117     HW_terminate,
       
   118     HW_getNumberOfWeapons,
       
   119     HW_getMaxNumberOfHogs,
       
   120     HW_getMaxNumberOfTeams,
       
   121     HW_getWeaponNameByIndex,
       
   122     HW_memoryWarningCallback;
    55 {$ENDIF}
   123 {$ENDIF}
    56 
   124 
    57 begin
   125 begin
    58 
       
    59 end.
   126 end.
    60