diff --git a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameView.java b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameView.java index c36d0cd7..ec68dfc1 100644 --- a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameView.java +++ b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameView.java @@ -197,6 +197,21 @@ protected void useRedPainter() { mPaint.setShadowLayer(5, 5, 5, R.color.holo_dark_red); } + protected void useTransparentBlackPainter() { + mPaint.setColor(getResources().getColor(R.color.transparent_grey)); + mPaint.setShadowLayer(0, 0, 0, R.color.transparent_grey); + } + + protected void useTransparentGreenPainter() { + mPaint.setColor(getResources().getColor(R.color.transparent_green)); + mPaint.setShadowLayer(0, 0, 0, R.color.transparent_green); + } + + protected void useWhitePainter() { + mPaint.setColor(getResources().getColor(R.color.white)); + mPaint.setShadowLayer(5, 5, 5, R.color.alpha_shadow); + } + protected float getTextSizeFromStyle(Context context, int styleId) { final TextView textView = new TextView(context); textView.setTextAppearance(context, styleId); diff --git a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewStandard.java b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewStandard.java index c6ba3983..17776100 100644 --- a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewStandard.java +++ b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewStandard.java @@ -5,6 +5,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; +import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import fr.tvbarthel.games.chasewhisply.R; @@ -25,6 +26,8 @@ public class GameViewStandard extends GameView { protected final Bitmap[] mBlondGhostBitmap; protected final Bitmap[] mBlondTargetedBitmap; protected final Bitmap mAmmoBitmap; + protected final Bitmap mTimerBitmap; + protected final Bitmap mScoreBitmap; protected final Bitmap mBulletHoleBitmap; protected final Bitmap mBabyGhostBitmap; protected final Bitmap mTargetedBabyGhostBitmap; @@ -55,7 +58,9 @@ public GameViewStandard(Context c, GameEngineStandard gameEngine) { BitmapFactory.decodeResource(res, R.drawable.blond_ghost_in_tears_targeted), BitmapFactory.decodeResource(res, R.drawable.blond_ghost_targeted), }; - mAmmoBitmap = BitmapFactory.decodeResource(res, R.drawable.ammo); + mAmmoBitmap = BitmapFactory.decodeResource(res, R.drawable.ic_ammo); + mTimerBitmap = BitmapFactory.decodeResource(res, R.drawable.ic_timer); + mScoreBitmap = BitmapFactory.decodeResource(res, R.drawable.ic_score); mBulletHoleBitmap = BitmapFactory.decodeResource(res, R.drawable.bullethole); mBabyGhostBitmap = BitmapFactory.decodeResource(res, R.drawable.baby_ghost); mTargetedBabyGhostBitmap = BitmapFactory.decodeResource(res, R.drawable.baby_ghost_targeted); @@ -198,8 +203,14 @@ protected void drawCrossHair(Canvas canvas) { */ protected void drawAmmo(Canvas canvas) { final int currentAmmunition = mGameEngine.getCurrentAmmunition(); + final String ammo = String.valueOf(currentAmmunition); + final int radius = Math.max(mAmmoBitmap.getWidth(), mAmmoBitmap.getHeight()) + (int) mPadding; resetPainter(); + //draw transparent overlay + useTransparentBlackPainter(); + canvas.drawOval(new RectF(mScreenWidth - radius, mScreenHeight - radius, mScreenWidth + radius, mScreenHeight + radius), mPaint); + if (currentAmmunition == 0) { useRedPainter(); final String noAmmoMessage = getResources().getString(R.string.in_game_no_ammo_message); @@ -209,16 +220,17 @@ protected void drawAmmo(Canvas canvas) { (mScreenHeight + mCrossHairs.getHeight()) / 2 + mBounds.height(), mPaint); } else { - useGreenPainter(); + useWhitePainter(); } - canvas.drawBitmap(mAmmoBitmap, (float) (mScreenWidth - mAmmoBitmap.getWidth() - mPadding), - (float) (getHeight() - mAmmoBitmap.getHeight() - mPadding), mPaint); + canvas.drawBitmap(mAmmoBitmap, (float) (mScreenWidth - mAmmoBitmap.getWidth()), + (float) (getHeight() - mAmmoBitmap.getHeight()), mPaint); mPaint.setTextSize(mAmmoBitmap.getHeight() / 2); - canvas.drawText(String.valueOf(currentAmmunition) - , mScreenWidth - mAmmoBitmap.getWidth() - mPaint.getTextSize() / 2 - mPadding - , mScreenHeight - (mAmmoBitmap.getHeight() / 4) + mPaint.getTextBounds(ammo, 0, ammo.length(), mBounds); + canvas.drawText(ammo + , mScreenWidth - radius + , mScreenHeight - radius + mBounds.height() / 2 , mPaint); } @@ -248,13 +260,22 @@ protected void drawCombo(Canvas canvas) { */ protected void drawScore(Canvas canvas) { resetPainter(); - useGreenPainter(); - final String score = String.format(mScoreString, mGameEngine.getCurrentScore()); + final String score = String.valueOf(mGameEngine.getCurrentScore()); + final int radius = Math.max(mScoreBitmap.getWidth(), mScoreBitmap.getHeight()) + (int) mPadding; + + //draw transparent overlay + useTransparentBlackPainter(); + canvas.drawOval(new RectF(-radius, mScreenHeight - radius, radius, mScreenHeight + radius), mPaint); + + //draw score icon + useWhitePainter(); + canvas.drawBitmap(mScoreBitmap, 0, mScreenHeight - mScoreBitmap.getHeight(), mPaint); + //draw score mPaint.getTextBounds(score, 0, score.length(), mBounds); canvas.drawText(score - , mBounds.width() / 2 + mPadding - , mScreenHeight - mPaint.getTextSize() + , radius + mBounds.width() / 2 + , mScreenHeight - radius + mBounds.height() / 2 , mPaint); } diff --git a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTime.java b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTime.java index 296a0ef7..36c000cd 100644 --- a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTime.java +++ b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTime.java @@ -3,6 +3,7 @@ import android.content.Context; import android.graphics.Canvas; +import android.graphics.RectF; import fr.tvbarthel.games.chasewhisply.mechanics.engine.GameEngineTime; @@ -28,13 +29,23 @@ public void onDrawing(Canvas c) { protected void drawTimer(Canvas canvas) { final long millis = mGameEngine.getCurrentTime(); final int seconds = (int) (millis / 1000); - final String remainingTime = String.format(mTimeString, seconds); + final String remainingTime = String.valueOf(seconds); + final int radius = Math.max(mTimerBitmap.getWidth(), mTimerBitmap.getHeight()) + (int) mPadding; resetPainter(); - useGreenPainter(); + + //draw transparent overlay + useTransparentBlackPainter(); + canvas.drawOval(new RectF(-radius, -radius, radius, radius), mPaint); + + //draw icon + useWhitePainter(); + canvas.drawBitmap(mTimerBitmap, 0, 0, mPaint); + + //draw time mPaint.getTextBounds(remainingTime, 0, remainingTime.length(), mBounds); canvas.drawText(remainingTime - , mPadding + mBounds.width() / 2 - , mPadding + mPaint.getTextSize() + , mPadding + radius + , radius , mPaint); } diff --git a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTimeDecreasing.java b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTimeDecreasing.java index 01436bae..683689b2 100644 --- a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTimeDecreasing.java +++ b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTimeDecreasing.java @@ -41,6 +41,7 @@ protected void onDetachedFromWindow() { super.onDetachedFromWindow(); } + /** * draw time, in red if time < 10 sec else in green * @@ -53,12 +54,7 @@ protected void drawTimer(Canvas canvas) { resetPainter(); if (seconds > 5) { if (!mRedCountDownTextView.getText().equals("")) mRedCountDownTextView.setText(""); - useGreenPainter(); - mPaint.getTextBounds(remainingTime, 0, remainingTime.length(), mBounds); - canvas.drawText(remainingTime - , mPadding + mBounds.width() / 2 - , mPadding + mPaint.getTextSize() - , mPaint); + super.drawTimer(canvas); } else if (seconds >= 0) { final Animation currentAnimation = mRedCountDownTextView.getAnimation(); final String mayBeANewValue = String.valueOf(seconds); diff --git a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTwentyInARow.java b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTwentyInARow.java index 7a773f07..de9dd266 100644 --- a/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTwentyInARow.java +++ b/ChaseWhisply/src/main/java/fr/tvbarthel/games/chasewhisply/ui/gameviews/GameViewTwentyInARow.java @@ -3,6 +3,7 @@ import android.content.Context; import android.graphics.Canvas; +import android.graphics.RectF; import fr.tvbarthel.games.chasewhisply.mechanics.engine.GameEngineTime; import fr.tvbarthel.games.chasewhisply.mechanics.engine.GameEngineTwentyInARow; @@ -19,16 +20,27 @@ public void onDrawing(Canvas c) { drawCurrentStack(c); } + @Override + protected void drawScore(Canvas canvas) { + //don't draw score + } + protected void drawCurrentStack(Canvas canvas) { final int currentStack = ((GameEngineTwentyInARow) mGameEngine).getCurrentStack(); final String currentStackStr = String.valueOf(currentStack); - resetPainter(); - useGreenPainter(); - mPaint.getTextBounds(currentStackStr, 0, currentStackStr.length(), mBounds); + final int stackLength = currentStackStr.length(); + final int radius = Math.max(mScreenWidth / (12 - stackLength), mScreenHeight / (12 - stackLength)); + + //draw transparent overlay + useTransparentBlackPainter(); + canvas.drawOval(new RectF(-radius, mScreenHeight - radius, radius, mScreenHeight + radius), mPaint); + + //draw Score + useWhitePainter(); mPaint.getTextBounds(currentStackStr, 0, currentStackStr.length(), mBounds); canvas.drawText(currentStackStr - , mBounds.width() / 2 + mPadding - , mScreenHeight - mPaint.getTextSize() * 2 - mPadding + , mBounds.width() / 2 + radius / 4 + , mScreenHeight - radius / 4 , mPaint); } diff --git a/ChaseWhisply/src/main/res/drawable-hdpi/ic_ammo.png b/ChaseWhisply/src/main/res/drawable-hdpi/ic_ammo.png new file mode 100644 index 00000000..4a491285 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-hdpi/ic_ammo.png differ diff --git a/ChaseWhisply/src/main/res/drawable-hdpi/ic_score.png b/ChaseWhisply/src/main/res/drawable-hdpi/ic_score.png new file mode 100644 index 00000000..f1c71222 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-hdpi/ic_score.png differ diff --git a/ChaseWhisply/src/main/res/drawable-hdpi/ic_timer.png b/ChaseWhisply/src/main/res/drawable-hdpi/ic_timer.png new file mode 100644 index 00000000..fae428d0 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-hdpi/ic_timer.png differ diff --git a/ChaseWhisply/src/main/res/drawable-mdpi/ic_ammo.png b/ChaseWhisply/src/main/res/drawable-mdpi/ic_ammo.png new file mode 100644 index 00000000..3f5682d7 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-mdpi/ic_ammo.png differ diff --git a/ChaseWhisply/src/main/res/drawable-mdpi/ic_score.png b/ChaseWhisply/src/main/res/drawable-mdpi/ic_score.png new file mode 100644 index 00000000..a38f147e Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-mdpi/ic_score.png differ diff --git a/ChaseWhisply/src/main/res/drawable-mdpi/ic_timer.png b/ChaseWhisply/src/main/res/drawable-mdpi/ic_timer.png new file mode 100644 index 00000000..547e8c73 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-mdpi/ic_timer.png differ diff --git a/ChaseWhisply/src/main/res/drawable-xhdpi/ic_ammo.png b/ChaseWhisply/src/main/res/drawable-xhdpi/ic_ammo.png new file mode 100644 index 00000000..28a51bd8 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-xhdpi/ic_ammo.png differ diff --git a/ChaseWhisply/src/main/res/drawable-xhdpi/ic_score.png b/ChaseWhisply/src/main/res/drawable-xhdpi/ic_score.png new file mode 100644 index 00000000..48377fee Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-xhdpi/ic_score.png differ diff --git a/ChaseWhisply/src/main/res/drawable-xhdpi/ic_timer.png b/ChaseWhisply/src/main/res/drawable-xhdpi/ic_timer.png new file mode 100644 index 00000000..d2798d8c Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-xhdpi/ic_timer.png differ diff --git a/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_ammo.png b/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_ammo.png new file mode 100644 index 00000000..e68d32c0 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_ammo.png differ diff --git a/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_score.png b/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_score.png new file mode 100644 index 00000000..49883958 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_score.png differ diff --git a/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_timer.png b/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_timer.png new file mode 100644 index 00000000..21527dc5 Binary files /dev/null and b/ChaseWhisply/src/main/res/drawable-xxhdpi/ic_timer.png differ diff --git a/ChaseWhisply/src/main/res/values/colors.xml b/ChaseWhisply/src/main/res/values/colors.xml index fc177a63..c3ff528e 100644 --- a/ChaseWhisply/src/main/res/values/colors.xml +++ b/ChaseWhisply/src/main/res/values/colors.xml @@ -14,4 +14,6 @@ #CC0000 #e5e5e5 #888888 + #AA666666 + #668a9d20 \ No newline at end of file