hedgewars/uUtils.pas
branchwebgl
changeset 9521 8054d9d775fd
parent 9127 e350500c4edb
parent 9377 48ab6dea8d2f
child 9950 2759212a27de
equal deleted inserted replaced
9282:92af50454cf2 9521:8054d9d775fd
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uUtils;
    21 unit uUtils;
    22 
    22 
    23 interface
    23 interface
    24 uses uTypes, uFloat, GLunit;
    24 uses uTypes, uFloat;
    25 
    25 
    26 procedure SplitBySpace(var a, b: shortstring);
    26 procedure SplitBySpace(var a, b: shortstring);
    27 procedure SplitByChar(var a, b: shortstring; c: char);
    27 procedure SplitByChar(var a, b: shortstring; c: char);
    28 
    28 
    29 {$IFNDEF PAS2C}
    29 {$IFNDEF PAS2C}
    42 
    42 
    43 function  IntToStr(n: LongInt): shortstring;
    43 function  IntToStr(n: LongInt): shortstring;
    44 function  StrToInt(s: shortstring): LongInt;
    44 function  StrToInt(s: shortstring): LongInt;
    45 function  FloatToStr(n: hwFloat): shortstring;
    45 function  FloatToStr(n: hwFloat): shortstring;
    46 
    46 
    47 function  DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; inline;
    47 function  DxDy2Angle(const _dY, _dX: hwFloat): real; inline;
    48 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
    48 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
    49 function  DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
    49 function  DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
    50 function  DxDy2AttackAnglef(const _dY, _dX: extended): LongInt;
    50 function  DxDy2AttackAnglef(const _dY, _dX: extended): LongInt;
    51 
    51 
    52 procedure SetLittle(var r: hwFloat);
    52 procedure SetLittle(var r: hwFloat);
    73 procedure Write(var f: textfile; s: shortstring);
    73 procedure Write(var f: textfile; s: shortstring);
    74 procedure WriteLn(var f: textfile; s: shortstring);
    74 procedure WriteLn(var f: textfile; s: shortstring);
    75 {$ENDIF}
    75 {$ENDIF}
    76 
    76 
    77 function  isPhone: Boolean; inline;
    77 function  isPhone: Boolean; inline;
    78 function  getScreenDPI: Double; inline; //cdecl; external;
       
    79 
    78 
    80 {$IFDEF IPHONEOS}
    79 {$IFDEF IPHONEOS}
    81 procedure startLoadingIndicator; cdecl; external;
    80 procedure startLoadingIndicator; cdecl; external;
    82 procedure stopLoadingIndicator; cdecl; external;
    81 procedure stopLoadingIndicator; cdecl; external;
    83 procedure saveFinishedSynching; cdecl; external;
    82 procedure saveFinishedSynching; cdecl; external;
   212 begin
   211 begin
   213 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))
   212 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))
   214 end;
   213 end;
   215 
   214 
   216 
   215 
   217 function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; inline;
   216 function DxDy2Angle(const _dY, _dX: hwFloat): real; inline;
   218 var dY, dX: Extended;
   217 var dY, dX: Extended;
   219 begin
   218 begin
   220 dY:= hwFloat2Float(_dY);
   219 dY:= hwFloat2Float(_dY);
   221 dX:= hwFloat2Float(_dX);
   220 dX:= hwFloat2Float(_dX);
   222 DxDy2Angle:= arctan2(dY, dX) * 180 / pi
   221 DxDy2Angle:= arctan2(dY, dX) * 180 / pi
   450     if (cScreenWidth < 1000) and (cScreenHeight < 500) then
   449     if (cScreenWidth < 1000) and (cScreenHeight < 500) then
   451         isPhone:= true;
   450         isPhone:= true;
   452 {$ENDIF}
   451 {$ENDIF}
   453 end;
   452 end;
   454 
   453 
   455 //This dummy function should be reimplemented (externally).
       
   456 function getScreenDPI: Double; inline;
       
   457 begin
       
   458 {$IFDEF ANDROID}
       
   459 //    getScreenDPI:= Android_JNI_getDensity();
       
   460     getScreenDPI:= 1;
       
   461 {$ELSE}
       
   462     getScreenDPI:= 1;
       
   463 {$ENDIF}
       
   464 end;
       
   465 
   454 
   466 function  sanitizeForLog(s: shortstring): shortstring;
   455 function  sanitizeForLog(s: shortstring): shortstring;
   467 var i: byte;
   456 var i: byte;
   468     r: shortstring;
   457     r: shortstring;
   469 begin
   458 begin
   531         end;
   520         end;
   532     Rewrite(f);
   521     Rewrite(f);
   533 {$I+}
   522 {$I+}
   534 {$ENDIF}
   523 {$ENDIF}
   535 
   524 
       
   525     //mobile stuff
       
   526 {$IFDEF IPHONEOS}
       
   527     mobileRecord.PerformRumble:= @AudioServicesPlaySystemSound;
       
   528     mobileRecord.GameLoading:= @startLoadingIndicator;
       
   529     mobileRecord.GameLoaded:= @stopLoadingIndicator;
       
   530     mobileRecord.SaveLoadingEnded:= @saveFinishedSynching;
       
   531 {$ELSE}
       
   532     mobileRecord.PerformRumble:= nil;
       
   533     mobileRecord.GameLoading:= nil;
       
   534     mobileRecord.GameLoaded:= nil;
       
   535     mobileRecord.SaveLoadingEnded:= nil;
       
   536 {$ENDIF}
       
   537 
   536 end;
   538 end;
   537 
   539 
   538 procedure freeModule;
   540 procedure freeModule;
   539 begin
   541 begin
   540 {$IFDEF DEBUGFILE}
   542 {$IFDEF DEBUGFILE}