diff --git a/app/src/main/background-playstore.png b/app/src/main/background-playstore.png
new file mode 100644
index 0000000..9498e2c
Binary files /dev/null and b/app/src/main/background-playstore.png differ
diff --git a/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java
index 8aadb43..1a35a48 100644
--- a/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java
+++ b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java
@@ -80,19 +80,22 @@ public class ColorSelectorEvent extends View implements View.OnClickListener {
}
}
- if(countOfBlack == 4) {
- String[] opts = new String[] {
- "Rejouer",
- "Voir votre jeu",
- "Retourner au menu"
- };
-
- Popup popup = new Popup(this.context, opts, true, (10 - this.tentative + 1));
- popup.show();
- }
+ String[] opts = new String[] {
+ "Rejouer",
+ "Voir votre jeu",
+ "Retourner au menu"
+ };
this.tentative--;
+ if(countOfBlack == 4) {
+ Popup popup = new Popup(this.context, opts, (10 - this.tentative));
+ popup.show();
+ } else if(this.tentative == 0) {
+ Popup popup = new Popup(this.context, opts);
+ popup.show();
+ }
+
TextView tx = (TextView) this.context.findViewById(R.id.counter);
tx.setText("Tentative rest. \n" + this.tentative);
tx.invalidate();
diff --git a/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java b/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java
index bb08000..084d704 100644
--- a/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java
+++ b/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java
@@ -2,22 +2,29 @@ package com.example.jmastermind.Events;
import android.content.DialogInterface;
import android.content.Intent;
+import android.view.View;
+import android.widget.Button;
+import android.widget.PopupMenu;
import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.Game.Popup;
import com.example.jmastermind.Game.SoloGame;
import com.example.jmastermind.MainActivity;
+import com.example.jmastermind.R;
-public class PopupEvent implements DialogInterface.OnClickListener {
+public class PopupEvent implements DialogInterface.OnClickListener, View.OnClickListener {
+ private int tentative;
private AppCompatActivity context;
/**
* Event lié au popup de fin de partie
* @param context Le context
+ * @param tentative Le nombre de tentative
* */
- public PopupEvent(AppCompatActivity context) {
+ public PopupEvent(AppCompatActivity context, int tentative) {
this.context = context;
+ this.tentative = tentative;
}
@Override
@@ -30,6 +37,10 @@ public class PopupEvent implements DialogInterface.OnClickListener {
}
case 1: {
+ Button btn = (Button) this.context.findViewById(R.id.validate);
+ btn.setText("Finish HIM");
+ btn.setOnClickListener(this);
+
dialogInterface.cancel();
break;
}
@@ -41,4 +52,16 @@ public class PopupEvent implements DialogInterface.OnClickListener {
}
}
}
+
+ @Override
+ public void onClick(View view) {
+ String[] opts = new String[] {
+ "Rejouer",
+ "Voir votre jeu",
+ "Retourner au menu"
+ };
+
+ Popup pop = new Popup(this.context, opts, this.tentative);
+ pop.show();
+ }
}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Popup.java b/app/src/main/java/com/example/jmastermind/Game/Popup.java
index af80e4d..59ca4be 100644
--- a/app/src/main/java/com/example/jmastermind/Game/Popup.java
+++ b/app/src/main/java/com/example/jmastermind/Game/Popup.java
@@ -1,8 +1,11 @@
package com.example.jmastermind.Game;
+import android.widget.Button;
+
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.Events.PopupEvent;
+import com.example.jmastermind.R;
public class Popup extends AlertDialog.Builder {
private AppCompatActivity context;
@@ -11,20 +14,18 @@ public class Popup extends AlertDialog.Builder {
* Affiche la popup de fin de jeu
* @param context Le context
* @param options La liste des options (rejouer, ...)
- * @param isWinner Esceque le joueur a gagner la partie
* @param tentative Le nombre de tentatives
* */
- public Popup(AppCompatActivity context, String[] options, Boolean isWinner, int tentative) {
+ public Popup(AppCompatActivity context, String[] options, int... tentative) {
super(context);
-
this.context = context;
- if(isWinner) {
- this.setTitle("Félicitation ! Vous avez gagner en : " + tentative + " coup(s).");
- } else {
+ if(tentative.length > 0) {
+ this.setTitle("Félicitation ! Vous avez gagner en : " + tentative[0] + " coup(s).");
+ } else {
this.setTitle("Perdu !");
}
- this.setItems(options, new PopupEvent(this.context));
+ this.setItems(options, new PopupEvent(this.context, tentative[0]));
}
}
diff --git a/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java b/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java
index 2c9e4e1..08aef0b 100644
--- a/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java
+++ b/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java
@@ -1,18 +1,14 @@
package com.example.jmastermind.Geometrics;
-
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
-
import androidx.annotation.Nullable;
-
public class Circle extends View {
private Paint picasso;
private int color;
-
/**
* Les cercles du jeu "programmiser" en Java
* @param context Le context
@@ -23,7 +19,6 @@ public class Circle extends View {
this.color = Color.GRAY;
this.picasso = new Paint();
}
-
/**
* Recuperer la couleur du cercle
* @return La couleur du cercle en int
@@ -31,7 +26,6 @@ public class Circle extends View {
public int getColor() {
return this.color;
}
-
/**
* Changer la couleur d'un cercle
* @param c La nouvelle couleur
@@ -44,12 +38,19 @@ public class Circle extends View {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
-
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
int radius = Math.min(centerX, centerY);
this.picasso.setColor(this.color);
- canvas.drawCircle(centerX, centerY, radius, this.picasso);
+ this.picasso.setStyle(Paint.Style.FILL);
+
+ canvas.drawCircle(centerX, centerY, radius-2, this.picasso);
+
+ this.picasso.setColor(Color.GRAY);
+ this.picasso.setStyle(Paint.Style.STROKE);
+ this.picasso.setStrokeWidth(5f);
+
+ canvas.drawCircle(centerX, centerY, radius-3, this.picasso);
}
}
diff --git a/app/src/main/java/com/example/jmastermind/MainActivity.java b/app/src/main/java/com/example/jmastermind/MainActivity.java
index 92bc607..caf2195 100644
--- a/app/src/main/java/com/example/jmastermind/MainActivity.java
+++ b/app/src/main/java/com/example/jmastermind/MainActivity.java
@@ -1,8 +1,12 @@
package com.example.jmastermind;
import androidx.appcompat.app.AppCompatActivity;
+
+import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.Button;
+import android.widget.ImageView;
+
import com.example.jmastermind.Events.MenuEvent;
import com.example.jmastermind.Game.*;
diff --git a/app/src/main/res/drawable/background_background.xml b/app/src/main/res/drawable/background_background.xml
new file mode 100644
index 0000000..ca3826a
--- /dev/null
+++ b/app/src/main/res/drawable/background_background.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/space.png b/app/src/main/res/drawable/space.png
new file mode 100644
index 0000000..e333e17
Binary files /dev/null and b/app/src/main/res/drawable/space.png differ
diff --git a/app/src/main/res/layout/game.xml b/app/src/main/res/layout/game.xml
index 098313a..e97918e 100644
--- a/app/src/main/res/layout/game.xml
+++ b/app/src/main/res/layout/game.xml
@@ -7,7 +7,7 @@
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity"
- android:background="#FFC0CB"
+ android:background="@drawable/space"
>
diff --git a/app/src/main/res/layout/menu.xml b/app/src/main/res/layout/menu.xml
index e249086..4eea334 100644
--- a/app/src/main/res/layout/menu.xml
+++ b/app/src/main/res/layout/menu.xml
@@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context=".MainActivity"
android:screenOrientation="portrait"
- android:background="#FFC0CB"
+ android:background="@drawable/space"
android:gravity="center"
android:orientation="vertical"
>
@@ -15,7 +15,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
- android:textColor="@color/purple_700"
+ android:textColor="@color/white"
android:gravity="center"
android:text="JMastermind" />
@@ -29,6 +29,8 @@
android:id="@+id/robotselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:backgroundTint="@color/white"
+ android:textColor="@color/black"
android:text="Joueur vs Robot"
/>
@@ -36,11 +38,15 @@
android:id="@+id/jcjselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:backgroundTint="@color/white"
+ android:textColor="@color/black"
android:text="Joueur contre Joueur" />
diff --git a/app/src/main/res/mipmap-anydpi-v26/background.xml b/app/src/main/res/mipmap-anydpi-v26/background.xml
new file mode 100644
index 0000000..16794a4
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/background.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/background_round.xml b/app/src/main/res/mipmap-anydpi-v26/background_round.xml
new file mode 100644
index 0000000..16794a4
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/background_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/background.png b/app/src/main/res/mipmap-hdpi/background.png
new file mode 100644
index 0000000..f69cc30
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/background.png differ
diff --git a/app/src/main/res/mipmap-hdpi/background_foreground.png b/app/src/main/res/mipmap-hdpi/background_foreground.png
new file mode 100644
index 0000000..88fce55
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/background_foreground.png differ
diff --git a/app/src/main/res/mipmap-hdpi/background_round.png b/app/src/main/res/mipmap-hdpi/background_round.png
new file mode 100644
index 0000000..a3bf546
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/background_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/background.png b/app/src/main/res/mipmap-mdpi/background.png
new file mode 100644
index 0000000..2381f37
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/background.png differ
diff --git a/app/src/main/res/mipmap-mdpi/background_foreground.png b/app/src/main/res/mipmap-mdpi/background_foreground.png
new file mode 100644
index 0000000..d20d040
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/background_foreground.png differ
diff --git a/app/src/main/res/mipmap-mdpi/background_round.png b/app/src/main/res/mipmap-mdpi/background_round.png
new file mode 100644
index 0000000..8d28b68
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/background_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/background.png b/app/src/main/res/mipmap-xhdpi/background.png
new file mode 100644
index 0000000..3b27696
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/background.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/background_foreground.png b/app/src/main/res/mipmap-xhdpi/background_foreground.png
new file mode 100644
index 0000000..476d61c
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/background_foreground.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/background_round.png b/app/src/main/res/mipmap-xhdpi/background_round.png
new file mode 100644
index 0000000..7f6d63b
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/background_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/background.png b/app/src/main/res/mipmap-xxhdpi/background.png
new file mode 100644
index 0000000..881770a
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/background.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/background_foreground.png b/app/src/main/res/mipmap-xxhdpi/background_foreground.png
new file mode 100644
index 0000000..58e1565
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/background_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/background_round.png b/app/src/main/res/mipmap-xxhdpi/background_round.png
new file mode 100644
index 0000000..31445c5
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/background_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/background.png b/app/src/main/res/mipmap-xxxhdpi/background.png
new file mode 100644
index 0000000..2fe9efd
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/background.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/background_foreground.png b/app/src/main/res/mipmap-xxxhdpi/background_foreground.png
new file mode 100644
index 0000000..b723356
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/background_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/background_round.png b/app/src/main/res/mipmap-xxxhdpi/background_round.png
new file mode 100644
index 0000000..0c321fa
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/background_round.png differ