From e34c000f65c4f624845e00e164c36a25352443a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kayyissa=20HA=C3=8FSSOUS?= Date: Wed, 5 Apr 2023 17:10:36 +0200 Subject: [PATCH] maj pour restore --- .../example/mastermind/HotSeatActivity.java | 7 +++++- .../com/example/mastermind/game/GameView.java | 21 +++++++++++++++++- .../mastermind/game/TouchListener.java | 22 ------------------- app/src/main/res/layout/activity_main.xml | 4 +--- 4 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 app/src/main/java/com/example/mastermind/game/TouchListener.java diff --git a/app/src/main/java/com/example/mastermind/HotSeatActivity.java b/app/src/main/java/com/example/mastermind/HotSeatActivity.java index d3c417f..b0165d9 100644 --- a/app/src/main/java/com/example/mastermind/HotSeatActivity.java +++ b/app/src/main/java/com/example/mastermind/HotSeatActivity.java @@ -12,6 +12,11 @@ public class HotSeatActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(new GameView(this, new Saisie(), new Grille())); + Saisie saisie = new Saisie(); + Grille grille = new Grille(); + GameView vuePartie = new GameView(this, saisie, grille); + setContentView(vuePartie); + new SuiviPartie(vuePartie); + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/mastermind/game/GameView.java b/app/src/main/java/com/example/mastermind/game/GameView.java index 2e14dff..3acb831 100644 --- a/app/src/main/java/com/example/mastermind/game/GameView.java +++ b/app/src/main/java/com/example/mastermind/game/GameView.java @@ -5,6 +5,8 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view.View; +import android.widget.LinearLayout; +import android.widget.TableLayout; import com.example.mastermind.R; @@ -16,16 +18,24 @@ public class GameView extends View { private Collection pionsAttaquant; private Collection pionsDefenseur; private Collection pionsPasPlaces; + private TableLayout grilleView; + private TableLayout notation1View; + private TableLayout notation2View; + private LinearLayout buttonsView; + private LinearLayout choixView; + private LinearLayout selectionView; private Saisie saisie; private Grille grille; private Paint circle; + private Context context; public GameView(Context context,Saisie saisie,Grille grille) { super(context); + this.context=context; this.saisie=saisie; this.grille=grille; - this.setOnTouchListener(new TouchListener()); //on initialise les collections de pions initpions(); + createViews(); this.circle = new Paint(); } @@ -69,6 +79,15 @@ public class GameView extends View { invalidate(); } + + + + //Créer les vues nécessaires pour le jeu + public void createViews(){ + LinearLayout parent = new LinearLayout(this.context); + parent.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); + parent.setOrientation(LinearLayout.HORIZONTAL); + } //initialise les collections de pions public void initpions(){ //on initialise les pions diff --git a/app/src/main/java/com/example/mastermind/game/TouchListener.java b/app/src/main/java/com/example/mastermind/game/TouchListener.java deleted file mode 100644 index 5d9f135..0000000 --- a/app/src/main/java/com/example/mastermind/game/TouchListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.mastermind.game; - -import android.view.MotionEvent; -import android.view.View; - -public class TouchListener implements View.OnTouchListener{ - - public TouchListener(){} - - @Override - public boolean onTouch(View v, MotionEvent event) { - int action = event.getActionMasked(); - Float x = event.getX(); - Float y = event.getY(); - - if (action==MotionEvent.ACTION_UP) - { - - } - return true; - } -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index fef2934..dab38fd 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,9 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="#333" - android:padding="10dp" - tools:context=".MainActivity" - > + tools:context=".MainActivity">