patch texte carte
This commit is contained in:
@@ -24,7 +24,7 @@ public class DemoCard extends Card{
|
||||
|
||||
@Override
|
||||
public int getCardPicture() {
|
||||
return R.drawable.guerrier_nul;
|
||||
return R.drawable.elfe_fournisseur;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -71,11 +71,9 @@ public class Drawable {
|
||||
* @param x_size taille du drawable entre 0 et 100
|
||||
* @param y_size taille du drawable entre 0 et 100
|
||||
*/
|
||||
public Drawable(String text,float x_pos,float y_pos,String name, float x_size,float y_size,float textSize)
|
||||
public Drawable(String text,float x_pos,float y_pos,String name, float x_size,float y_size,float textSize , int x_canvasRatio, int y_canvasRatio)
|
||||
{
|
||||
this(x_pos,y_pos,name);
|
||||
int x_scaled_size = (int)x_size* GameActivity.screenWidth/100;
|
||||
int y_scaled_size = (int)y_size* GameActivity.screenHeight/100;
|
||||
|
||||
checkPaint();
|
||||
p.setColor(Color.BLACK);
|
||||
@@ -86,13 +84,13 @@ public class Drawable {
|
||||
p.setTextSize(textSize);
|
||||
|
||||
//+10 permet d'e prendre en compte les p,q,j qui dessende plus bas que les autres
|
||||
bitmap = Bitmap.createBitmap(x_scaled_size, y_scaled_size+10, Bitmap.Config.ARGB_8888);
|
||||
bitmap = Bitmap.createBitmap(x_canvasRatio, y_canvasRatio, Bitmap.Config.ARGB_8888);
|
||||
Canvas c = new Canvas(bitmap);
|
||||
|
||||
int index = 1;
|
||||
for(String line : linesOfText)
|
||||
{
|
||||
c.drawText(line ,0,index*y_scaled_size/linesOfText.size(),p);
|
||||
c.drawText(line ,0,index*y_canvasRatio/linesOfText.size(),p);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ public class DrawableCard extends Drawable{
|
||||
|
||||
private static final int CARD_WITH = 14;
|
||||
private static final int CARD_HEIGHT = 32;
|
||||
private static final float HP_ATK_FONT_SIZE_BIG_CARD =50F;
|
||||
private static final float HP_ATK_FONT_SIZE_BOARD =80F;
|
||||
private static final float HP_ATK_FONT_SIZE_BIG_CARD =30F;
|
||||
private static final float HP_ATK_FONT_SIZE_BOARD =70F;
|
||||
|
||||
private String color;
|
||||
|
||||
@@ -59,11 +59,12 @@ public class DrawableCard extends Drawable{
|
||||
|
||||
onBoard=true;
|
||||
|
||||
cardDescription = new Drawable(c.getDescription(),x+CARD_WITH*0.07F,y+CARD_HEIGHT/2.2F,toString()+"description",CARD_WITH*0.8F,CARD_HEIGHT*0.35F,30F);
|
||||
cardDescription = new DrawableCardDescription(c.getDescription(),x+CARD_WITH*0.07F,y+CARD_HEIGHT/2.2F,toString()+"description",CARD_WITH*0.8F,CARD_HEIGHT*0.35F,30F);
|
||||
updateHpAndAtk(c.getAttack(),c.getHealth());
|
||||
|
||||
color = c.getColor();//CARD_WITH+x
|
||||
Rectangle cardRect = new Rectangle(x,y,(float)(CARD_WITH+x),(float)(CARD_HEIGHT+x));
|
||||
|
||||
Bitmap pictureBitmap = BitmapFactory.decodeResource(context.getResources(),c.getCardPicture());
|
||||
|
||||
try {
|
||||
@@ -112,14 +113,14 @@ public class DrawableCard extends Drawable{
|
||||
{
|
||||
if(onBoard) {
|
||||
if (atk != null)
|
||||
cardAtkDrawable = new Drawable(atk + " ", getX() + 0.6F, getY() + CARD_HEIGHT/2, toString() + "atk", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BOARD);
|
||||
cardAtkDrawable = new DrawableHpAtk(atk+"", getX() + CARD_WITH*0.05F, getY() - CARD_HEIGHT*0.48F, toString() + "atk", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BOARD);
|
||||
if (hp != null)
|
||||
cardHpDrawable = new Drawable(hp + " ", getX() + 2.4F + CARD_WITH / 2, getY() + CARD_HEIGHT/2, toString() + "hp", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BOARD);
|
||||
cardHpDrawable = new DrawableHpAtk(hp+"", getX() + CARD_WITH*0.55F, getY() + CARD_HEIGHT*0.48F, toString() + "hp", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BOARD);
|
||||
}else{
|
||||
if (atk != null)
|
||||
cardAtkDrawable = new Drawable(atk + " ", getX() + 1F, getY() +CARD_HEIGHT-6F, toString() + "atk", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BIG_CARD);
|
||||
cardAtkDrawable = new DrawableHpAtk(atk + " ", getX() + CARD_WITH*0.1F, getY() +CARD_HEIGHT-8F, toString() + "atk", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BIG_CARD);
|
||||
if (hp != null)
|
||||
cardHpDrawable = new Drawable(hp + " ", getX() + 2.8F + CARD_WITH / 2, getY() + CARD_HEIGHT - 6F, toString() + "hp", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BIG_CARD);
|
||||
cardHpDrawable = new DrawableHpAtk(hp + " ", getX() + CARD_WITH *0.7F, getY() + CARD_HEIGHT - 8F, toString() + "hp", CARD_WITH / 2, CARD_HEIGHT / 8, HP_ATK_FONT_SIZE_BIG_CARD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,15 +168,15 @@ public class DrawableCard extends Drawable{
|
||||
if (onBoard) {
|
||||
cardOnBardDrawable.setCoordinates(x,y);
|
||||
PictureDrawable.setCoordinates(x +1, y +2);
|
||||
cardAtkDrawable.setCoordinates(x+1F,y + CARD_HEIGHT/2 );
|
||||
cardHpDrawable.setCoordinates(x+1F+CARD_WITH/2,y + CARD_HEIGHT/2 );
|
||||
cardAtkDrawable.setCoordinates(x+CARD_WITH*0.05F,y + CARD_HEIGHT*0.48F );
|
||||
cardHpDrawable.setCoordinates(x+CARD_WITH*0.55F,y + CARD_HEIGHT*0.48F );
|
||||
}else{
|
||||
super.setCoordinates(x, y);
|
||||
OpacityRectangleDrawable.setCoordinates(x, y);
|
||||
PictureDrawable.setCoordinates(x + 1.1F, y + 2.5F);
|
||||
cardDescription.setCoordinates(x+CARD_WITH*0.07F,y+CARD_HEIGHT/2.2F);
|
||||
cardAtkDrawable.setCoordinates(x + 1F,y+CARD_HEIGHT-6F);
|
||||
cardHpDrawable.setCoordinates(x+ 3F+CARD_WITH/2,y+CARD_HEIGHT-6F);
|
||||
cardAtkDrawable.setCoordinates(x + CARD_WITH*0.1F,getY() + CARD_HEIGHT - 7F);
|
||||
cardHpDrawable.setCoordinates(x + CARD_WITH*0.7F,getY() + CARD_HEIGHT - 8F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class DrawableCardDescription extends Drawable {
|
||||
int index = 1;
|
||||
for(String line : linesOfText)
|
||||
{
|
||||
c.drawText(line ,0,index*y_scaled_size/linesOfText.size(),p);
|
||||
c.drawText(line ,0,index*TEXT_Y_RES/linesOfText.size(),p);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.iutlaval.myapplication.Video.Drawables;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.iutlaval.myapplication.GameActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DrawableHpAtk extends Drawable {
|
||||
private static int TEXT_X_RES = 110;
|
||||
private static int TEXT_Y_RES = 60;
|
||||
|
||||
public DrawableHpAtk(String text, float x_pos, float y_pos, String name, float x_size, float y_size, float textSize) {
|
||||
super(text,x_pos,y_pos,name,x_size,y_size,textSize,TEXT_X_RES,TEXT_Y_RES);
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Reference in New Issue
Block a user