library ToolBox; {$mode delphi}{$H+} {$R *.res} uses Classes { you can add units after this } ,mainform, uHCDefines, uHCGCI, uHCGlobals, uHCTypeDefs, uHCEventHelpers, uHCDateTime, uHCAnnexHelpers, uHCAnnexDefs, uLazGUIGlobals, Windows, Forms, ShellAPI, SysUtils, Types, Dialogs, Interfaces, Controls, runtimetypeinfocontrols; const DLLVERN = 26; DLLVERINTN = 17; var frmMain: TfrmMain; intGameTime, intGameTimeLeft: Long; dt_scen_start: PHCDateTimeRec; {*** Return DLL internal version, i.e. revision 5 of my DLL ***} function DLLVer():word;export;cdecl; begin result := DLLVERN; end; {*** Return DLL interface version, i.e. revision 1 of HCE interface spec ***} function DLLVerInt():word;export;cdecl; begin result := DLLVERINTN; end; {*** Return DLL description, 255 characters max ***} function DLLDesc():PAnsiChar;export;cdecl; begin result := 'HCE Toolbox - export DLL by Don Thomas/Tony Eischens'; end; {*** Free DLL ***} procedure DLLFree();export;cdecl; begin // Do any cleanup here, this is the end frmMain.Free; end; {*** Init DLL ***} procedure DLLInit(hwndHC: HWND; pathHC: PAnsiChar; verHC: PAnsiChar; verSaveGame: LongWord; funcRefs: PHCDLL_FUNC_REF; PGEClosing: Pointer; PDLLBusy: Pointer; verInterface: LongWord);export;cdecl; var funcTmp: PHCDLL_FUNC_REF; begin // here we initialize globals and such for the life of the DLL Application.Initialize; uLazGUIGlobals.PDLLBusy:=PDLLBusy; uLazGUIGlobals.PGEClosing:=PGEClosing; uLazGUIGlobals.intVerInterface:=verInterface; uLazGUIGlobals.intVerSaveGame:=verSaveGame; frmMain := TfrmMain.Create(nil); frmMain.ParentWindow := hwndHC; // use inifile to set postion? frmMain.Caption := 'Toolbox V 1.6.0 requires GE V 2017.005+'; // assign pointer location for 'stuff' funcTmp := funcRefs; while (funcTmp <> nil) do begin if (funcTmp^.funcName = 'NewPtr') then frmMain.NewPtr := funcTmp^.funcPtr else if (funcTmp^.funcName = 'DispPtr') then frmMain.DisposPtr := funcTmp^.funcPtr else if (funcTmp^.funcName = 'del_HarpoonEvent_list') then frmMain.del_HarpoonEvent_list := PHCDLL_FUNC_REF(PHCDLL_FUNC_REF(funcRefs^.next).next).funcPtr else if (funcTmp^.funcName = 'QueueHarpoonEvent') then frmMain.HCQueueHarpoonEvent := THCQueueHarpoonEvent(funcTmp^.funcPtr) else if (funcTmp^.funcName = 'dllCheckLatLonDepth') then frmMain.HCdllCheckLatLonDepth := THCdllCheckLatLonDepth(funcTmp^.funcPtr) else if (funcTmp^.funcName = 'annex_id_to_disk_id') then frmMain.HCannex_id_to_disk_id := THCannex_id_to_disk_id(funcTmp^.funcPtr) else if (funcTmp^.funcName = 'disk_id_to_annex_id') then frmMain.HCdisk_id_to_annex_id := THCdisk_id_to_annex_id(funcTmp^.funcPtr) ; funcTmp := funcTmp^.next; end; frmMain.Show; frmMain.intPageActive:= 2; end; procedure StartGroup(StartGroup: PHCGroup);export;cdecl; begin frmMain.PStartGroup:=StartGroup; end; procedure ScenLoad(strHarpPath: PAnsiChar; intScenNum: SmallInt; strScenFPath: PAnsiChar; intBSNum: ShortInt; strBSFName: PAnsiChar; intSide: byte; intGameTimeIn: Long; intGameTimeLeftIn: Long; dt_scen_start_in: PHCDateTimeRec; AnnexDataIn: PHCAnnexes_disk);export;cdecl; begin frmMain.strMySide:=format('%d',[intSide]); frmMain.MySide:= intSide; case intSide of 0: frmMain.EnmySide:= uchar(1); 1: frmMain.EnmySide:= 0; end; frmMain.MLtmemLog.Lines.Clear; frmMain.PAnnexData:= AnnexDataIn; frmMain.dt_scen_start:= dt_scen_start_in; HCAnnexHelper := THCAnnexHelper.Create(AnnexDataIn, frmMain.HCannex_id_to_disk_id, uLazGUIGlobals.intVerInterface, uLazGUIGlobals.intVerSaveGame); end; procedure MsgLog(MsgLine: PAnsiChar);export;cdecl; begin while (frmMain.MLtmemLog.Lines.Count > frmMain.SETspnMLC.Value) do begin frmMain.MLtmemLog.Lines.Delete(frmMain.MLtmemLog.Lines.Count - 1) end; frmMain.MLtmemLog.Lines.Insert(0, ''); frmMain.MLtmemLog.Lines.Strings[0]:=Format('%s', [MsgLine]); end; procedure HarpoonEventHead(HarpEventHead: PHCHarpoonEvent);export;cdecl; begin If HarpEventHead <> nil then begin frmMain.PHCEventHead:= HarpEventHead; if ((HarpEventHead^.flag and CommandMask) = AIR_REFUEL_EVENT) and (PHCGroup(HarpEventHead^.ourGroup)^.side = frmMain.MySide) then // ddt 20150720 begin frmMain.RflLbxGroups.Clear; frmMain.RflLbxGroups.Items.Add(Format('%3.3s %d', [PHCGroup(HarpEventHead^.ourGroup)^.id, HarpEventHead^.Time])); if (frmMain.RflChkBPause.Checked = True) then begin Byte(PDLLBusy^) := CTRUE; frmMain.intPageActive:= frmMain.PageControl1.ActivePageIndex; frmMain.RflChkBResume.Checked:= False; frmMain.WindowState:= wsNormal; frmMain.PageControl1.ActivePageIndex:=3; frmMain.RflLbxUnitFill(HarpEventHead^.ourGroup); frmMain.RflLbxDetailFill(HarpEventHead); end; end; end; end; procedure GameTime(GameTime: Long; GameTimeLeft: Long);export;cdecl; begin frmMain.intGameTime := GameTime; frmMain.intGameTimeLeft:= GameTimeLeft; frmMain.RflLblGameTime.Caption:= Format('%9.9d',[GameTime]); end; exports DLLVer, DLLVerInt, DLLDesc, DLLFree, DLLInit, ScenLoad, MsgLog, HarpoonEventHead, GameTime, StartGroup; // ALE 20130205 Sends updated GroupPtr whenever that changes end.