--- a/hedgewars/SDLh.pas Wed Jun 13 11:18:30 2012 -0400
+++ b/hedgewars/SDLh.pas Wed Jun 13 23:25:15 2012 +0200
@@ -981,9 +981,6 @@
function SDL_getenv(const text: PChar): PChar; cdecl; external SDLLibName;
{$ENDIF}
-{$IFDEF ANDROID}
-function Android_JNI_getDensity(): Single; cdecl; external SDLLibName;
-{$ENDIF}
{* Compatibility between SDL-1.2 and SDL-1.3 *}
procedure SDL_WarpMouse(x, y: Word); {$IFDEF SDL13}inline{$ELSE}cdecl; external SDLLibName{$ENDIF};
--- a/hedgewars/uMobile.pas Wed Jun 13 11:18:30 2012 -0400
+++ b/hedgewars/uMobile.pas Wed Jun 13 23:25:15 2012 +0200
@@ -28,6 +28,7 @@
interface
function isPhone: Boolean; inline;
+function getScreenDPI: Single; inline;
procedure performRumble; inline;
procedure GameLoading; inline;
@@ -47,6 +48,10 @@
procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external;
{$ENDIF}
+{$IFDEF ANDROID}
+function Android_JNI_getDensity(): Single; cdecl; external;
+{$ENDIF}
+
// this function is just to determine whether we are running on a limited screen device
function isPhone: Boolean; inline;
begin
@@ -61,6 +66,15 @@
{$ENDIF}
end;
+function getScreenDPI: Single; inline;
+begin
+{$IFDEF ANDROID}
+ getScreenDPI:= Android_JNI_getDensity();
+{$ELSE}
+ getScreenDPI:= 1;
+{$ENDIF}
+end;
+
// this function should make the device vibrate in some way
procedure PerformRumble; inline;
{$IFDEF IPHONEOS}const kSystemSoundID_Vibrate = $00000FFF;{$ENDIF}
--- a/hedgewars/uTouch.pas Wed Jun 13 11:18:30 2012 -0400
+++ b/hedgewars/uTouch.pas Wed Jun 13 23:25:15 2012 +0200
@@ -22,7 +22,7 @@
interface
-uses SysUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, uIO, GLUnit, uTypes, uCaptions, uAmmos, uWorld;
+uses SysUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, uIO, GLUnit, uTypes, uCaptions, uAmmos, uWorld, uMobile;
procedure initModule;
@@ -557,7 +557,7 @@
isOnCrosshair:= isOnRect((x-HalfRectSize), (y-HalfRectSize), RectSize, RectSize, finger);
printFinger(finger);
WriteLnToConsole(inttostr(finger.x) + ' ' + inttostr(x));
- WriteLnToConsole(inttostr(x) + ' ' + inttostr(y) + ' ' + inttostr(round(Android_JNI_getDensity() * 10)));
+ WriteLnToConsole(inttostr(x) + ' ' + inttostr(y) + ' ' + inttostr(round(uMobile.getScreenDPI * 10)));
end;
function isOnCurrentHog(finger: TTouch_Data): boolean;
--- a/hedgewars/uWorld.pas Wed Jun 13 11:18:30 2012 -0400
+++ b/hedgewars/uWorld.pas Wed Jun 13 23:25:15 2012 +0200
@@ -216,11 +216,7 @@
{$IFDEF USE_TOUCH_INTERFACE}
//positioning of the buttons
-{$IFDEF ANDROID}
-buttonScale:= Android_JNI_getDensity()/cDefaultZoomLevel;
-{$ELSE}
-buttonScale:= 1.5/cDefaultZoomLevel;
-{$ENDIF}
+buttonScale:= uMobile.getScreenDPI/cDefaultZoomLevel;
with JumpWidget do