--- a/hedgewars/SDLh.pas Sat Jun 02 14:27:09 2012 +0200
+++ b/hedgewars/SDLh.pas Sat Jun 02 22:54:09 2012 +0200
@@ -968,6 +968,10 @@
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};
function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
--- a/hedgewars/uGears.pas Sat Jun 02 14:27:09 2012 +0200
+++ b/hedgewars/uGears.pas Sat Jun 02 22:54:09 2012 +0200
@@ -363,11 +363,11 @@
FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
- ParseCommand('/nextturn', true);
SwitchHedgehog;
AfterSwitchHedgehog;
- bBetweenTurns:= false
+ bBetweenTurns:= false;
+ ParseCommand('/nextturn', true)
end;
step:= Low(step)
end;
--- a/hedgewars/uGearsRender.pas Sat Jun 02 14:27:09 2012 +0200
+++ b/hedgewars/uGearsRender.pas Sat Jun 02 22:54:09 2012 +0200
@@ -321,8 +321,8 @@
// reached edge of land. assume infinite beam. Extend it way out past camera
if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
begin
- tx:= round(lx + ax * (LAND_WIDTH div 4));
- ty:= round(ly + ay * (LAND_WIDTH div 4));
+ tx:= round(lx + ax * (LAND_WIDTH div 2));
+ ty:= round(ly + ay * (LAND_WIDTH div 2));
end;
//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
--- a/hedgewars/uWorld.pas Sat Jun 02 14:27:09 2012 +0200
+++ b/hedgewars/uWorld.pas Sat Jun 02 22:54:09 2012 +0200
@@ -214,8 +214,13 @@
procedure InitTouchInterface;
begin
{$IFDEF USE_TOUCH_INTERFACE}
+
//positioning of the buttons
+{$IFDEF ANDROID}
+buttonScale:= Android_JNI_getDensity()/cDefaultZoomLevel;
+{$ELSE}
buttonScale:= 1.5/cDefaultZoomLevel;
+{$ENDIF}
with JumpWidget do
--- a/project_files/Android-build/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp Sat Jun 02 14:27:09 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp Sat Jun 02 22:54:09 2012 +0200
@@ -638,6 +638,21 @@
return Android_JNI_FileClose(ctx, true);
}
+/*******************************************************************************
+ Functions called by the hwengine into Java
+*******************************************************************************/
+
+extern "C" float Android_JNI_getDensity(){
+ jmethodID mid;
+ jfloat density;
+ //SDLActivity.getDensity()
+ mid = mEnv->GetStaticMethodID(mActivityClass, "getDensity", "()F");
+ if(!mid) return 1.5f;
+ density = mEnv->CallStaticFloatMethod(mActivityClass, mid);
+ return density;
+
+}
+
#endif /* __ANDROID__ */
/* vi: set ts=4 sw=4 expandtab: */
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Sat Jun 02 14:27:09 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Sat Jun 02 22:54:09 2012 +0200
@@ -24,6 +24,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -401,6 +402,11 @@
mAudioTrack = null;
}
}
+
+ public static float getDensity(){
+ DisplayMetrics dm = SDLActivity.getContext().getResources().getDisplayMetrics();
+ return dm.density;
+ }
}
/**
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua Sat Jun 02 14:27:09 2012 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua Sat Jun 02 22:54:09 2012 +0200
@@ -111,11 +111,11 @@
-- Note that there are 1000 ticks within one second.
-- You shouldn't try to calculate too complicated
-- code here as this might slow down your game.
-function onGameTick()
+function onGameTick20()
-- If time's up, set the game to be lost.
-- We actually check the time to be "1 ms" as it
-- will be at "0 ms" right at the start of the game.
- if TurnTimeLeft == 1 and score < score_goal then
+ if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal then
game_lost = true
-- ... and show a short message.
ShowMission(loc("Bazooka Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
@@ -133,7 +133,7 @@
EndGame()
else
-- ... or just lower the timer by 1.
- end_timer = end_timer - 1
+ end_timer = end_timer - 20
-- Reset the time left to stop the timer
TurnTimeLeft = time_goal
end
@@ -150,8 +150,8 @@
-- This function is called when a new gear is added.
-- We don't need it for this training, so we can
-- keep it empty.
-function onGearAdd(gear)
-end
+-- function onGearAdd(gear)
+-- end
-- This function is called before a gear is destroyed.
-- We use it to count the number of targets destroyed.
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Cluster_Bomb.lua Sat Jun 02 14:27:09 2012 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Cluster_Bomb.lua Sat Jun 02 22:54:09 2012 +0200
@@ -63,9 +63,9 @@
end
-function onGameTick()
+function onGameTick20()
- if TurnTimeLeft == 1 and scored < 12 and game_lost == false then
+ if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < 12 and game_lost == false then
game_lost = true
ShowMission(loc("Cluster Bomb Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
SetHealth(player, 0)
@@ -76,7 +76,7 @@
if end_timer == 0 then
EndGame()
else
- end_timer = end_timer - 1
+ end_timer = end_timer - 20
TurnTimeLeft = time_goal
end
end
@@ -87,8 +87,8 @@
ParseCommand("setweap " .. string.char(amClusterBomb))
end
-function onGearAdd(gear)
-end
+--function onGearAdd(gear)
+--end
function onGearDamage(gear, damage)
@@ -120,4 +120,4 @@
end
function onGearDelete(gear)
-end
\ No newline at end of file
+end
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua Sat Jun 02 14:27:09 2012 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua Sat Jun 02 22:54:09 2012 +0200
@@ -114,11 +114,11 @@
-- Note that there are 1000 ticks within one second.
-- You shouldn't try to calculate too complicated
-- code here as this might slow down your game.
-function onGameTick()
+function onGameTick20()
-- If time's up, set the game to be lost.
-- We actually check the time to be "1 ms" as it
-- will be at "0 ms" right at the start of the game.
- if TurnTimeLeft == 1 and score < score_goal then
+ if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal then
game_lost = true
-- ... and show a short message.
ShowMission(loc("Grenade Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
@@ -145,7 +145,7 @@
end
else
-- ... or just lower the timer by 1.
- end_timer = end_timer - 1
+ end_timer = end_timer - 20
-- Reset the time left to stop the timer
TurnTimeLeft = time_goal
end
@@ -162,8 +162,8 @@
-- This function is called when a new gear is added.
-- We don't need it for this training, so we can
-- keep it empty.
-function onGearAdd(gear)
-end
+-- function onGearAdd(gear)
+-- end
-- This function is called before a gear is destroyed.
-- We use it to count the number of targets destroyed.
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua Sat Jun 02 14:27:09 2012 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua Sat Jun 02 22:54:09 2012 +0200
@@ -128,8 +128,8 @@
ParseCommand( "setweap " .. string.char( amRope ) ) -- Set the default weapon to Rope
end
-function onGameTick()
- if TurnTimeLeft == 1 then -- Round starts at 0, so we check if the round is finished by using 1
+function onGameTick20()
+ if TurnTimeLeft < 40 and TurnTimeLeft > 0 then -- Round starts at 0, so we check if the round is finished by using 1
GameLost = true -- You lost the game
Info( "Aiming Practice", "You did not make it in time, try again!", -amSkip )
SetHealth( Player, 0 ) -- Kill the player so he can't keep moving!
@@ -151,7 +151,7 @@
WaitTime = -1
else
- WaitTime = WaitTime - 1
+ WaitTime = WaitTime - 20
end
end
@@ -161,7 +161,7 @@
FollowTime = 1500
FollowGear( Player )
else
- FollowTime = FollowTime - 1
+ FollowTime = FollowTime - 20
end
end
@@ -172,7 +172,7 @@
end
end
- GetTime = GetTime + 1
+ GetTime = GetTime + 20
CheckPosition( Player, 70 ) -- Run the CheckPosition function to check if the player is close to a target
end
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Shotgun.lua Sat Jun 02 14:27:09 2012 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Shotgun.lua Sat Jun 02 22:54:09 2012 +0200
@@ -111,11 +111,11 @@
-- Note that there are 1000 ticks within one second.
-- You shouldn't try to calculate too complicated
-- code here as this might slow down your game.
-function onGameTick()
+function onGameTick20()
-- If time's up, set the game to be lost.
-- We actually check the time to be "1 ms" as it
-- will be at "0 ms" right at the start of the game.
- if TurnTimeLeft == 1 and score < score_goal then
+ if TurnTimeLeft < 40 and TurnTimeLeft > 20 and score < score_goal then
game_lost = true
-- ... and show a short message.
ShowMission(loc("Shotgun Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
@@ -133,7 +133,7 @@
EndGame()
else
-- ... or just lower the timer by 1.
- end_timer = end_timer - 1
+ end_timer = end_timer - 20
-- Reset the time left to stop the timer
TurnTimeLeft = time_goal
end
@@ -150,8 +150,8 @@
-- This function is called when a new gear is added.
-- We don't need it for this training, so we can
-- keep it empty.
-function onGearAdd(gear)
-end
+-- function onGearAdd(gear)
+-- end
-- This function is called before a gear is destroyed.
-- We use it to count the number of targets destroyed.
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua Sat Jun 02 14:27:09 2012 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua Sat Jun 02 22:54:09 2012 +0200
@@ -112,7 +112,7 @@
-- Note that there are 1000 ticks within one second.
-- You shouldn't try to calculate too complicated
-- code here as this might slow down your game.
-function onGameTick()
+function onGameTick20()
if game_lost then
return
end
@@ -127,7 +127,7 @@
-- If time's up, set the game to be lost.
-- We actually check the time to be "1 ms" as it
-- will be at "0 ms" right at the start of the game.
- if TurnTimeLeft == 1 and score < score_goal then
+ if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal then
game_lost = true
-- ... and show a short message.
ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
@@ -145,7 +145,7 @@
EndGame()
else
-- ... or just lower the timer by 1.
- end_timer = end_timer - 1
+ end_timer = end_timer - 20
-- Reset the time left to stop the timer
TurnTimeLeft = time_goal
end
@@ -162,8 +162,8 @@
-- This function is called when a new gear is added.
-- We don't need it for this training, so we can
-- keep it empty.
-function onGearAdd(gear)
-end
+-- function onGearAdd(gear)
+-- end
-- This function is called before a gear is destroyed.
-- We use it to count the number of targets destroyed.