fix nullpoint sur les description de carte + masque de log de timeout
This commit is contained in:
@@ -30,10 +30,11 @@ import java.net.SocketTimeoutException;
|
|||||||
|
|
||||||
public class GameLogicThread extends Thread{
|
public class GameLogicThread extends Thread{
|
||||||
|
|
||||||
public static final float BUTTON_Y_POS = 50F;
|
public static final float BUTTON_Y_POS = 45F;
|
||||||
public static final int BUTTON_X_POS = 0;
|
public static final int BUTTON_X_POS = 0;
|
||||||
public static final float BUTTON_X_SIZE = 5F;
|
public static final float BUTTON_X_SIZE = 20F;
|
||||||
public static final float BUTTON_Y_SIZE = 2.5F;
|
public static final float BUTTON_Y_SIZE = 10F;
|
||||||
|
public static final String BUTTONTURN_DRAWABLE_NAME = "buttonturn";
|
||||||
private Context cont;
|
private Context cont;
|
||||||
private Renderer renderer;
|
private Renderer renderer;
|
||||||
private boolean ready;
|
private boolean ready;
|
||||||
@@ -81,7 +82,7 @@ public class GameLogicThread extends Thread{
|
|||||||
//loading textures
|
//loading textures
|
||||||
Bitmap bitmapYourTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_your_turn);
|
Bitmap bitmapYourTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_your_turn);
|
||||||
Bitmap bitmapEnemyTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_enemy_turn);
|
Bitmap bitmapEnemyTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_enemy_turn);
|
||||||
Bitmap bitmapButtonEnd = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_enemy_turn);
|
Bitmap bitmapButtonEnd = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_btn_boutonfintour);
|
||||||
Bitmap bitmap= BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_b_board_background);
|
Bitmap bitmap= BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_b_board_background);
|
||||||
|
|
||||||
//adding the background
|
//adding the background
|
||||||
@@ -125,7 +126,7 @@ public class GameLogicThread extends Thread{
|
|||||||
coms.setLimitedTimeOut();
|
coms.setLimitedTimeOut();
|
||||||
String serveurCmd = coms.recieve();
|
String serveurCmd = coms.recieve();
|
||||||
coms.setUnlimitedTimeOut();
|
coms.setUnlimitedTimeOut();
|
||||||
Log.e("command",serveurCmd);
|
if(!serveurCmd.equals("timeout"))Log.e("command",serveurCmd);
|
||||||
switch (serveurCmd)
|
switch (serveurCmd)
|
||||||
{
|
{
|
||||||
case Command.GET_DECK:
|
case Command.GET_DECK:
|
||||||
@@ -144,7 +145,7 @@ public class GameLogicThread extends Thread{
|
|||||||
case Command.YOURTURN:
|
case Command.YOURTURN:
|
||||||
isYourTurn=true;
|
isYourTurn=true;
|
||||||
renderer.addToDraw(new DrawableSelfRemoving(new DrawableBitmap(bitmapYourTurn,0,0,"yourTurn",100F,50F),1));
|
renderer.addToDraw(new DrawableSelfRemoving(new DrawableBitmap(bitmapYourTurn,0,0,"yourTurn",100F,50F),1));
|
||||||
renderer.addToDraw(new DrawableBitmap(bitmapButtonEnd, BUTTON_X_POS, BUTTON_Y_POS,"buttonturn", BUTTON_X_SIZE, BUTTON_Y_SIZE));
|
renderer.addToDraw(new DrawableBitmap(bitmapButtonEnd, BUTTON_X_POS, BUTTON_Y_POS, BUTTONTURN_DRAWABLE_NAME, BUTTON_X_SIZE, BUTTON_Y_SIZE));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Command.SETMANA:
|
case Command.SETMANA:
|
||||||
@@ -154,6 +155,8 @@ public class GameLogicThread extends Thread{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Command.ENEMYTURN:
|
case Command.ENEMYTURN:
|
||||||
|
//on update pas vu que l'instruction suivante va le faire
|
||||||
|
renderer.removeToDrawWithoutUpdate(BUTTONTURN_DRAWABLE_NAME);
|
||||||
renderer.addToDraw(new DrawableSelfRemoving(new DrawableBitmap(bitmapEnemyTurn,0,0,"enemyTurn",100F,50F),1));
|
renderer.addToDraw(new DrawableSelfRemoving(new DrawableBitmap(bitmapEnemyTurn,0,0,"enemyTurn",100F,50F),1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -207,6 +210,9 @@ public class GameLogicThread extends Thread{
|
|||||||
//ajout la card au terain
|
//ajout la card au terain
|
||||||
board.setEnemyCard(zone,cardPlayed);
|
board.setEnemyCard(zone,cardPlayed);
|
||||||
break;
|
break;
|
||||||
|
case "timeout":
|
||||||
|
//ceci est une erreur et non une commande elle se doit donc de ne rien faire
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.e("UNKOWN COMMAND",serveurCmd);
|
Log.e("UNKOWN COMMAND",serveurCmd);
|
||||||
@@ -365,6 +371,7 @@ public class GameLogicThread extends Thread{
|
|||||||
if(isYourTurn)
|
if(isYourTurn)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
Log.e("TURN","PASSED");
|
||||||
coms.send(Command.PASS_TURN);
|
coms.send(Command.PASS_TURN);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.iutlaval.myapplication.Game;
|
package com.iutlaval.myapplication.Game;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import com.iutlaval.myapplication.GameActivity;
|
import com.iutlaval.myapplication.GameActivity;
|
||||||
@@ -188,6 +189,7 @@ public class TouchHandler {
|
|||||||
unScalled_X > GameLogicThread.BUTTON_X_POS && unScalled_X < GameLogicThread.BUTTON_X_POS + GameLogicThread.BUTTON_X_SIZE &&
|
unScalled_X > GameLogicThread.BUTTON_X_POS && unScalled_X < GameLogicThread.BUTTON_X_POS + GameLogicThread.BUTTON_X_SIZE &&
|
||||||
unScalled_Y > GameLogicThread.BUTTON_Y_POS && unScalled_Y < GameLogicThread.BUTTON_Y_POS + GameLogicThread.BUTTON_Y_SIZE)
|
unScalled_Y > GameLogicThread.BUTTON_Y_POS && unScalled_Y < GameLogicThread.BUTTON_Y_POS + GameLogicThread.BUTTON_Y_SIZE)
|
||||||
{
|
{
|
||||||
|
Log.e("push","detected");
|
||||||
gameLogic.onEndTurnButtonPushed();
|
gameLogic.onEndTurnButtonPushed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,21 +35,24 @@ public class DrawableText extends Drawable{
|
|||||||
p.setAntiAlias(true);
|
p.setAntiAlias(true);
|
||||||
p.setTextSize(textSize);
|
p.setTextSize(textSize);
|
||||||
|
|
||||||
List<String> linesOfText = cutText(20,text);
|
|
||||||
|
|
||||||
//+10 permet d'e prendre en compte les p,q,j qui dessende plus bas que les autres
|
|
||||||
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(x_canvasRatio, y_canvasRatio, Bitmap.Config.ARGB_8888);
|
Bitmap bitmap = Bitmap.createBitmap(x_canvasRatio, y_canvasRatio, Bitmap.Config.ARGB_8888);
|
||||||
setBitmap(bitmap);
|
setBitmap(bitmap);
|
||||||
Canvas c = new Canvas(bitmap);
|
Canvas c = new Canvas(bitmap);
|
||||||
int index = 1;
|
|
||||||
for(String line : linesOfText)
|
//si on a une description
|
||||||
|
if(text != null)
|
||||||
{
|
{
|
||||||
//y_canvasRatio/linesOfText.size()
|
int index = 1;
|
||||||
c.drawText(line ,0,index*textSize,p);
|
List<String> linesOfText = cutText(20,text);
|
||||||
index++;
|
for(String line : linesOfText)
|
||||||
|
{
|
||||||
|
//y_canvasRatio/linesOfText.size()
|
||||||
|
c.drawText(line ,0,index*textSize,p);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int scalled_x_size = (int)(GameActivity.screenWidth*x_size/100);
|
int scalled_x_size = (int)(GameActivity.screenWidth*x_size/100);
|
||||||
int scalled_y_size = (int)(GameActivity.screenHeight*y_size/100);
|
int scalled_y_size = (int)(GameActivity.screenHeight*y_size/100);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user