Merge branch 'master' of https://github.com/jsmaniac/2011-m1s2-ter
This commit is contained in:
commit
28a7af4186
|
@ -2,7 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.pticlic"
|
||||
android:versionCode="1" android:versionName="@string/version">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:debuggable="true">
|
||||
<activity android:name=".Main" android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -10,11 +10,11 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".Preference" android:label="Préférence" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".games.BaseGame" android:screenOrientation="portrait"></activity>
|
||||
<activity android:label="Information" android:name=".Information" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".Score" android:label="Score" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".FrontPage" android:screenOrientation="portrait"></activity>
|
||||
<activity android:name=".Preference" android:label="Préférence"></activity>
|
||||
<activity android:name=".games.BaseGame"></activity>
|
||||
<activity android:label="Information" android:name=".Information"></activity>
|
||||
<activity android:name=".Score" android:label="Score"></activity>
|
||||
<activity android:name=".FrontPage"></activity>
|
||||
</application>
|
||||
|
||||
|
||||
|
|
|
@ -4,45 +4,38 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:orientation="vertical"
|
||||
android:layout_weight="1">
|
||||
android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="2">
|
||||
|
||||
<TextView android:id="@+id/mainWord" android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" android:text="mainWord"
|
||||
android:textStyle="bold" android:gravity="center" android:textSize="30dip">
|
||||
</TextView>
|
||||
<TextView android:id="@+id/currentWord" android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" android:text="currentWord"
|
||||
android:textStyle="bold" android:gravity="center" android:textSize="20dip">
|
||||
android:text="currentWord"
|
||||
android:textStyle="bold" android:textSize="20dip" android:layout_height="fill_parent" android:gravity="top|center">
|
||||
</TextView>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||
android:layout_weight="9">
|
||||
android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="10">
|
||||
|
||||
<Button android:id="@+id/relation1" android:text="relation1"
|
||||
android:layout_height="wrap_content" android:layout_weight="1"
|
||||
android:layout_width="fill_parent" android:layout_gravity="bottom">
|
||||
</Button>
|
||||
<Button android:id="@+id/relation2" android:text="relation2"
|
||||
android:layout_height="wrap_content" android:layout_width="fill_parent"
|
||||
android:layout_weight="1" android:layout_gravity="bottom">
|
||||
</Button>
|
||||
<Button android:id="@+id/trash" android:text="trash"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_weight="1" android:layout_gravity="bottom" android:layout_height="fill_parent">
|
||||
</Button>
|
||||
<Button android:id="@+id/relation3" android:text="relation3"
|
||||
android:layout_height="wrap_content" android:layout_width="fill_parent"
|
||||
android:layout_weight="1" android:layout_gravity="bottom">
|
||||
</Button>
|
||||
<Button android:id="@+id/relation4" android:text="relation4"
|
||||
android:layout_height="wrap_content" android:layout_width="fill_parent"
|
||||
android:layout_weight="1" android:layout_gravity="bottom">
|
||||
</Button>
|
||||
<ImageView android:id="@+id/relation1"
|
||||
android:src="@drawable/contenant" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
|
||||
</ImageView>
|
||||
<ImageView android:id="@+id/relation2"
|
||||
android:src="@drawable/contenu" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
|
||||
</ImageView>
|
||||
<ImageView android:id="@+id/trash"
|
||||
android:src="@android:drawable/ic_menu_delete" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
|
||||
</ImageView>
|
||||
<ImageView android:id="@+id/relation3"
|
||||
android:src="@drawable/contraire" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
|
||||
</ImageView>
|
||||
<ImageView android:id="@+id/relation4"
|
||||
android:src="@drawable/synonyme" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
|
||||
</ImageView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -9,18 +9,22 @@ import org.pticlic.model.Network;
|
|||
import org.pticlic.model.Network.Mode;
|
||||
import org.pticlic.model.Relation;
|
||||
|
||||
import android.R.anim;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.AnimationSet;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
|
@ -37,11 +41,12 @@ import android.widget.TextView;
|
|||
* proposer celle qui lui semble le mieux approprier.
|
||||
*
|
||||
*/
|
||||
public class BaseGame extends Activity implements OnClickListener {
|
||||
private int currentWord = 0;
|
||||
private int nbWord = 0;
|
||||
private DownloadedGame game;
|
||||
private Match gamePlayed;
|
||||
public class BaseGame extends Activity implements OnClickListener, AnimationListener {
|
||||
private int currentWord = 0;
|
||||
private TextView currentWordTextView;
|
||||
private int nbWord = 0;
|
||||
private DownloadedGame game;
|
||||
private Match match;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
|
@ -62,28 +67,27 @@ public class BaseGame extends Activity implements OnClickListener {
|
|||
nbWord = game.getNbWord();
|
||||
|
||||
// On initialise la partie.
|
||||
gamePlayed = new Match();
|
||||
gamePlayed.setGame(game);
|
||||
match = new Match();
|
||||
match.setGame(game);
|
||||
|
||||
Relation r = Relation.getInstance();
|
||||
|
||||
|
||||
// Boutons des relations
|
||||
Button r1 = ((Button)findViewById(R.id.relation1));
|
||||
Button r2 = ((Button)findViewById(R.id.relation2));
|
||||
Button r3 = ((Button)findViewById(R.id.relation3));
|
||||
Button r4 = ((Button)findViewById(R.id.relation4));
|
||||
|
||||
ImageView r1 = ((ImageView)findViewById(R.id.relation1));
|
||||
ImageView r2 = ((ImageView)findViewById(R.id.relation2));
|
||||
ImageView r3 = ((ImageView)findViewById(R.id.relation3));
|
||||
ImageView r4 = ((ImageView)findViewById(R.id.relation4));
|
||||
|
||||
// TODO : Pour l'instant la poubelle ne fait rien. Il faudra certainement la ranger dans un categorie dans GamePlayed pour calculer le score.
|
||||
Button trash = ((Button)findViewById(R.id.trash));
|
||||
ImageView trash = ((ImageView)findViewById(R.id.trash));
|
||||
trash.setOnClickListener(this);
|
||||
trash.setText("poubelle");
|
||||
trash.setImageResource(android.R.drawable.ic_menu_delete);
|
||||
|
||||
// Écoute des clics sur les relations
|
||||
if (nbrel > 0) { r1.setOnClickListener(this); r1.setText(r.getRelationName(game.getCat1())); } else { r1.setVisibility(View.GONE); }
|
||||
if (nbrel > 1) { r2.setOnClickListener(this); r2.setText(r.getRelationName(game.getCat2()));} else { r2.setVisibility(View.GONE); }
|
||||
if (nbrel > 2) { r3.setOnClickListener(this); r3.setText(r.getRelationName(game.getCat3()));} else { r3.setVisibility(View.GONE); }
|
||||
if (nbrel > 3) { r4.setOnClickListener(this); r4.setText(r.getRelationName(game.getCat4()));} else { r4.setVisibility(View.GONE); }
|
||||
|
||||
if (nbrel > 0) { r1.setOnClickListener(this); r1.setImageResource(r.getRelationImage(game.getCat1())); } else { r1.setVisibility(View.GONE); }
|
||||
if (nbrel > 1) { r2.setOnClickListener(this); r2.setImageResource(r.getRelationImage(game.getCat2()));} else { r2.setVisibility(View.GONE); }
|
||||
if (nbrel > 2) { r3.setOnClickListener(this); r3.setImageResource(r.getRelationImage(game.getCat3()));} else { r3.setVisibility(View.GONE); }
|
||||
if (nbrel > 3) { r4.setOnClickListener(this); r4.setImageResource(r.getRelationImage(game.getCat4()));} else { r4.setVisibility(View.GONE); }
|
||||
|
||||
((TextView)findViewById(R.id.mainWord)).setText(DownloadedGame.getName(game.getCentre()));
|
||||
}
|
||||
|
@ -117,22 +121,31 @@ public class BaseGame extends Activity implements OnClickListener {
|
|||
|
||||
//On recupere le centre de mainWord pour l'animation de translation.
|
||||
TextView mainWord = (TextView)findViewById(R.id.mainWord);
|
||||
|
||||
currentWordTextView = (TextView)findViewById(R.id.currentWord);
|
||||
|
||||
// On defini un ensemble d'animation
|
||||
AnimationSet set = new AnimationSet(true);
|
||||
set.setFillAfter(true);
|
||||
set.setDuration(1000);
|
||||
set.setFillAfter(true);
|
||||
set.setAnimationListener(this);
|
||||
|
||||
TranslateAnimation translate = new TranslateAnimation(mainWord.getScrollX() / 2, mainWord.getScrollX() / 2, mainWord.getScrollY() / 2, width / 2);
|
||||
translate.setDuration(1000);
|
||||
translate.setDuration(500);
|
||||
set.addAnimation(translate);
|
||||
|
||||
AlphaAnimation alpha = new AlphaAnimation(.1f, 1);
|
||||
AlphaAnimation alpha = new AlphaAnimation(0, 1);
|
||||
alpha.setDuration(1000);
|
||||
set.addAnimation(alpha);
|
||||
|
||||
// Que l'on rajoute a notre vue.
|
||||
findViewById(R.id.currentWord).startAnimation(set);
|
||||
currentWordTextView.startAnimation(set);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void leaveView() {
|
||||
currentWordTextView.clearAnimation();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,10 +161,11 @@ public class BaseGame extends Activity implements OnClickListener {
|
|||
*/
|
||||
private void next() {
|
||||
if (++currentWord < nbWord) {
|
||||
leaveView();
|
||||
start();
|
||||
} else {
|
||||
Intent intent = new Intent(this, Score.class);
|
||||
intent.putExtra(Constant.SCORE_GAMEPLAYED, gamePlayed);
|
||||
intent.putExtra(Constant.SCORE_GAMEPLAYED, match);
|
||||
intent.putExtra(Constant.SCORE_MODE, Mode.SIMPLE_GAME);
|
||||
|
||||
startActivityForResult(intent, 0x100);
|
||||
|
@ -165,11 +179,28 @@ public class BaseGame extends Activity implements OnClickListener {
|
|||
public void onClick(View v) {
|
||||
int currentWord = game.getWordInCloud(this.currentWord).getId();
|
||||
switch (v.getId()) {
|
||||
case (R.id.relation1) : gamePlayed.add(1, currentWord); next(); break;
|
||||
case (R.id.relation2) : gamePlayed.add(2, currentWord); next(); break;
|
||||
case (R.id.relation3) : gamePlayed.add(3, currentWord); next(); break;
|
||||
case (R.id.relation4) : gamePlayed.add(4, currentWord); next(); break;
|
||||
case (R.id.trash) : gamePlayed.add(0, currentWord); next(); break;
|
||||
case (R.id.relation1) : match.add(1, currentWord); next(); break;
|
||||
case (R.id.relation2) : match.add(2, currentWord); next(); break;
|
||||
case (R.id.relation3) : match.add(3, currentWord); next(); break;
|
||||
case (R.id.relation4) : match.add(4, currentWord); next(); break;
|
||||
case (R.id.trash) : match.add(0, currentWord); next(); break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package org.pticlic.model;
|
|||
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.widget.ImageView;
|
||||
import org.pticlic.R;
|
||||
|
||||
/**
|
||||
* @author Bertrand BRUN
|
||||
|
@ -16,9 +16,15 @@ public class Relation {
|
|||
private static Relation instance = null;
|
||||
|
||||
HashMap<Integer, String> stringRelations;
|
||||
HashMap<Integer, ImageView> imageRelations;
|
||||
HashMap<Integer, Integer> imageRelations;
|
||||
|
||||
private Relation() {
|
||||
imageRelations = new HashMap<Integer, Integer>();
|
||||
imageRelations.put(5, R.drawable.synonyme);
|
||||
imageRelations.put(7, R.drawable.contraire);
|
||||
imageRelations.put(9, R.drawable.contenu);
|
||||
imageRelations.put(10, R.drawable.contenant);
|
||||
|
||||
stringRelations = new HashMap<Integer, String>();
|
||||
stringRelations.put(-1, "");
|
||||
stringRelations.put(0, "idée");
|
||||
|
@ -72,4 +78,8 @@ public class Relation {
|
|||
public String getRelationName(int id) {
|
||||
return stringRelations.get(id);
|
||||
}
|
||||
|
||||
public Integer getRelationImage(int id) {
|
||||
return imageRelations.get(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user